2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
37 package org.onap.portalapp.portal.controller;
39 import com.fasterxml.jackson.databind.ObjectMapper;
40 import io.swagger.annotations.ApiOperation;
41 import java.lang.reflect.InvocationTargetException;
42 import java.lang.reflect.Method;
43 import java.util.ArrayList;
44 import java.util.Arrays;
45 import java.util.Collections;
46 import java.util.HashMap;
47 import java.util.List;
49 import java.util.Optional;
50 import java.util.concurrent.atomic.AtomicReference;
51 import java.util.jar.Attributes;
52 import java.util.regex.Matcher;
53 import java.util.regex.Pattern;
54 import javax.servlet.http.HttpServletRequest;
55 import javax.servlet.http.HttpServletResponse;
56 import org.onap.aaf.cadi.aaf.AAFPermission;
57 import org.onap.portalapp.annotation.ApiVersion;
58 import org.onap.portalapp.externalsystemapproval.model.ExternalSystemUser;
59 import org.onap.portalapp.portal.domain.CentralV2RoleFunction;
60 import org.onap.portalapp.portal.domain.EPUser;
61 import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
62 import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
63 import org.onap.portalapp.portal.logging.aop.EPAuditLog;
64 import org.onap.portalapp.portal.service.ManifestService;
65 import org.onap.portalapp.portal.transport.Analytics;
66 import org.onap.portalapp.portal.transport.CentralUser;
67 import org.onap.portalapp.portal.transport.CentralV2Role;
68 import org.onap.portalapp.portal.transport.EpNotificationItem;
69 import org.onap.portalapp.portal.transport.FavoritesFunctionalMenuItemJson;
70 import org.onap.portalapp.portal.transport.FunctionalMenuItem;
71 import org.onap.portalapp.portal.transport.OnboardingApp;
72 import org.onap.portalapp.validation.DataValidator;
73 import org.onap.portalapp.validation.SecureString;
74 import org.onap.portalsdk.core.domain.Role;
75 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
76 import org.onap.portalsdk.core.onboarding.crossapi.PortalAPIResponse;
77 import org.onap.portalsdk.core.restful.domain.EcompRole;
78 import org.onap.portalsdk.core.restful.domain.EcompUser;
79 import org.springframework.beans.BeansException;
80 import org.springframework.beans.factory.annotation.Autowired;
81 import org.springframework.context.ApplicationContext;
82 import org.springframework.context.ApplicationContextAware;
83 import org.springframework.context.annotation.Configuration;
84 import org.springframework.context.annotation.EnableAspectJAutoProxy;
85 import org.springframework.web.bind.annotation.PathVariable;
86 import org.springframework.web.bind.annotation.RequestBody;
87 import org.springframework.web.bind.annotation.RequestMapping;
88 import org.springframework.web.bind.annotation.RequestMethod;
89 import org.springframework.web.bind.annotation.RequestParam;
90 import org.springframework.web.bind.annotation.ResponseBody;
91 import org.springframework.web.bind.annotation.RestController;
94 @RequestMapping("/auxapi")
96 @EnableAspectJAutoProxy
98 public class AuxApiRequestMapperController implements ApplicationContextAware, BasicAuthenticationController {
100 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AuxApiRequestMapperController.class);
101 private DataValidator dataValidator = new DataValidator();
103 ApplicationContext context = null;
104 int minorVersion = 0;
107 private ManifestService manifestService;
109 @ApiOperation(value = "Gets user roles for an application which is upgraded to newer version.", response = String.class, responseContainer = "List")
110 @RequestMapping(value = { "/v3/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json")
111 public String getUser(HttpServletRequest request, HttpServletResponse response,
112 @PathVariable("loginId") String loginId) throws Exception {
114 SecureString secureLoginId = new SecureString(loginId);
115 if (!dataValidator.isValid(secureLoginId))
116 return "Provided data is not valid";
120 Map<String, Object> res = getMethod(request, response);
121 String answer = null;
123 answer = (String) invokeMethod(res, request, response, loginId);
124 } catch (Exception e) {
125 logger.error(EELFLoggerDelegate.errorLogger, "getUser failed", e);
130 @SuppressWarnings("unchecked")
131 @ApiOperation(value = "Gets roles for an application which is upgraded to newer version.", response = CentralV2Role.class, responseContainer = "Json")
132 @RequestMapping(value = { "/v3/roles" }, method = RequestMethod.GET, produces = "application/json")
133 public List<CentralV2Role> getRoles(HttpServletRequest request, HttpServletResponse response) throws Exception {
134 Map<String, Object> res = getMethod(request, response);
136 List<CentralV2Role> answer = null;
138 answer = (List<CentralV2Role>) invokeMethod(res, request, response);
139 } catch (Exception e) {
140 logger.error(EELFLoggerDelegate.errorLogger, "getRoles failed", e);
145 @SuppressWarnings("unchecked")
146 @ApiOperation(value = "Saves role for an application.", response = PortalRestResponse.class, responseContainer = "Json")
147 @RequestMapping(value = { "/v3/role" }, method = RequestMethod.POST, produces = "application/json")
148 public PortalRestResponse<String> saveRole(HttpServletRequest request, HttpServletResponse response,
149 @RequestBody Role role) throws Exception {
150 Map<String, Object> res = getMethod(request, response);
151 PortalRestResponse<String> out = null;
153 out = (PortalRestResponse<String>) invokeMethod(res, request, response, role);
154 } catch (Exception e) {
155 logger.error(EELFLoggerDelegate.errorLogger, "saveRole failed", e);
156 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
161 @ApiOperation(value = "Gets v2 role information for an application which is upgraded to newer version.", response = CentralV2Role.class, responseContainer = "Json")
162 @RequestMapping(value = { "/v3/role/{role_id}" }, method = RequestMethod.GET, produces = "application/json")
163 public CentralV2Role getRoleInfo(HttpServletRequest request, HttpServletResponse response,
164 @PathVariable("role_id") Long roleId) throws Exception {
165 Map<String, Object> res = getMethod(request, response);
166 CentralV2Role role = null;
168 role = (CentralV2Role) invokeMethod(res, request, response, roleId);
169 } catch (Exception e) {
170 logger.error(EELFLoggerDelegate.errorLogger, "getRoleInfo failed", e);
176 @SuppressWarnings("unchecked")
177 @ApiOperation(value = "Gets all active Users of application", response = String.class, responseContainer = "Json")
178 @RequestMapping(value = { "/v3/users" }, method = RequestMethod.GET, produces = "application/json")
179 public List<EcompUser> getUsersOfApplication(HttpServletRequest request, HttpServletResponse response)
181 Map<String, Object> res = getMethod(request, response);
182 List<EcompUser> users = null;
184 users = (List<EcompUser>) invokeMethod(res, request, response);
185 } catch (Exception e) {
186 logger.error(EELFLoggerDelegate.errorLogger, "getUsersOfApplication failed", e);
191 @SuppressWarnings("unchecked")
192 @ApiOperation(value = "Gets all role functions for an application which is upgraded to newer version.", response = CentralV2RoleFunction.class, responseContainer = "Json")
193 @RequestMapping(value = { "/v3/functions" }, method = RequestMethod.GET, produces = "application/json")
194 public List<CentralV2RoleFunction> getRoleFunctionsList(HttpServletRequest request, HttpServletResponse response)
196 Map<String, Object> res = getMethod(request, response);
197 List<CentralV2RoleFunction> roleFunctionsList = null;
199 roleFunctionsList = (List<CentralV2RoleFunction>) invokeMethod(res, request, response);
200 } catch (Exception e) {
201 logger.error(EELFLoggerDelegate.errorLogger, "getRoleFunctionsList failed", e);
203 return roleFunctionsList;
206 @ApiOperation(value = "Gets role information for an application provided by function code.", response = CentralV2RoleFunction.class, responseContainer = "Json")
207 @RequestMapping(value = { "/v3/function/{code}" }, method = RequestMethod.GET, produces = "application/json")
208 public CentralV2RoleFunction getRoleFunction(HttpServletRequest request, HttpServletResponse response,
209 @PathVariable("code") String code) throws Exception {
211 SecureString secureCode = new SecureString(code);
212 if (!dataValidator.isValid(secureCode))
213 return new CentralV2RoleFunction();
216 Map<String, Object> res = getMethod(request, response);
217 CentralV2RoleFunction roleFunction = null;
219 roleFunction = (CentralV2RoleFunction) invokeMethod(res, request, response, code);
220 } catch (Exception e) {
221 logger.error(EELFLoggerDelegate.errorLogger, "getRoleFunction failed", e);
226 @SuppressWarnings("unchecked")
227 @ApiOperation(value = "Saves role function for an application.", response = PortalRestResponse.class, responseContainer = "Json")
228 @RequestMapping(value = { "/v3/roleFunction" }, method = RequestMethod.POST, produces = "application/json")
229 public PortalRestResponse<String> saveRoleFunction(HttpServletRequest request, HttpServletResponse response,
230 @RequestBody String roleFunc) throws Exception {
232 SecureString secureRoleFunc = new SecureString(roleFunc);
233 if(!dataValidator.isValid(secureRoleFunc))
234 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "Provided data is not valid", "Failed");
236 Optional<PortalRestResponse<String>> result = null;
237 Map<String, Object> res = getMethod(request, response);
239 result = Optional.ofNullable((PortalRestResponse<String>) invokeMethod(res, request, response));
240 if (!result.isPresent()){
241 logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction failed", new Exception("saveRoleFunction failed"));
242 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "saveRoleFunction failed", "Failed");
244 } catch (Exception e) {
245 logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction failed", e);
246 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
251 @SuppressWarnings("unchecked")
252 @ApiOperation(value = "Deletes role function for an application.", response = PortalRestResponse.class, responseContainer = "Json")
253 @RequestMapping(value = { "/v3/roleFunction/{code}" }, method = RequestMethod.DELETE, produces = "application/json")
254 public PortalRestResponse<String> deleteRoleFunction(HttpServletRequest request, HttpServletResponse response,
255 @PathVariable("code") String code) throws Exception {
256 PortalRestResponse<String> result = null;
259 SecureString secureCode = new SecureString(code);
260 if(!dataValidator.isValid(secureCode))
261 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "Provided data is not valid", "Failed");
264 Map<String, Object> res = getMethod(request, response);
266 result = (PortalRestResponse<String>) invokeMethod(res, request, response, code);
268 } catch (Exception e) {
269 logger.error(EELFLoggerDelegate.errorLogger, "deleteRoleFunction failed", e);
270 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
274 @SuppressWarnings("unchecked")
275 @ApiOperation(value = "deletes roles for an application.", response = PortalRestResponse.class, responseContainer = "Json")
276 @RequestMapping(value = { "/v3/deleteRole/{roleId}" }, method = RequestMethod.DELETE, produces = "application/json")
277 public PortalRestResponse<String> deleteRole(HttpServletRequest request, HttpServletResponse response,
278 @PathVariable("roleId") Long roleId) throws Exception {
279 PortalRestResponse<String> result = null;
280 Map<String, Object> res = getMethod(request, response);
282 result = (PortalRestResponse<String>) invokeMethod(res, request, response, roleId);
284 } catch (Exception e) {
285 logger.error(EELFLoggerDelegate.errorLogger, "deleteRole failed", e);
286 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
290 @SuppressWarnings("unchecked")
291 @ApiOperation(value = "Gets active roles for an application.", response = CentralV2Role.class, responseContainer = "Json")
292 @RequestMapping(value = { "/v3/activeRoles" }, method = RequestMethod.GET, produces = "application/json")
293 public List<CentralV2Role> getActiveRoles(HttpServletRequest request, HttpServletResponse response)
295 List<CentralV2Role> cenRole = null;
296 Map<String, Object> res = getMethod(request, response);
298 cenRole = (List<CentralV2Role>) invokeMethod(res, request, response);
299 } catch (Exception e) {
300 logger.error(EELFLoggerDelegate.errorLogger, "getActiveRoles failed", e);
305 @ApiOperation(value = "Gets ecompUser of an application.", response = CentralUser.class, responseContainer = "List")
306 @RequestMapping(value = { "/v4/user/{loginId}" }, method = RequestMethod.GET, produces = "application/json")
307 public String getEcompUser(HttpServletRequest request, HttpServletResponse response,
308 @PathVariable("loginId") String loginId) throws Exception {
309 Map<String, Object> res = getMethod(request, response);
312 SecureString secureLoginId = new SecureString(loginId);
314 if (!dataValidator.isValid(secureLoginId))
318 String answer = null;
320 answer = (String) invokeMethod(res, request, response, loginId);
321 } catch (Exception e) {
322 logger.error(EELFLoggerDelegate.errorLogger, "getEcompUser failed", e);
327 @SuppressWarnings("unchecked")
328 @ApiOperation(value = "Gets user ecomp role for an application.", response = CentralUser.class, responseContainer = "List")
329 @RequestMapping(value = { "/v4/roles" }, method = RequestMethod.GET, produces = "application/json")
330 public List<EcompRole> getEcompRolesOfApplication(HttpServletRequest request, HttpServletResponse response)
332 Map<String, Object> res = getMethod(request, response);
333 List<EcompRole> answer = null;
335 answer = (List<EcompRole>) invokeMethod(res, request, response);
336 } catch (Exception e) {
337 logger.error(EELFLoggerDelegate.errorLogger, "getEcompRolesOfApplication failed", e);
342 @ApiOperation(value = "Gets session slot-check interval, a duration in milliseconds.", response = Integer.class)
343 @RequestMapping(value = {
344 "/v3/getSessionSlotCheckInterval" }, method = RequestMethod.GET, produces = "application/json")
345 public Integer getSessionSlotCheckInterval(HttpServletRequest request, HttpServletResponse response)
347 Map<String, Object> res = getMethod(request, response);
350 ans = (Integer) invokeMethod(res, request, response);
351 } catch (Exception e) {
352 logger.error(EELFLoggerDelegate.errorLogger, "getSessionSlotCheckInterval failed", e);
357 @ApiOperation(value = "Extends session timeout values for all on-boarded applications.", response = Boolean.class)
358 @RequestMapping(value = { "/v3/extendSessionTimeOuts" }, method = RequestMethod.POST)
359 public Boolean extendSessionTimeOuts(HttpServletRequest request, HttpServletResponse response,
360 @RequestParam String sessionMap) throws Exception {
362 if (sessionMap!=null){
363 SecureString secureSessionMap = new SecureString(sessionMap);
364 if (!dataValidator.isValid(secureSessionMap)){
369 Map<String, Object> res = getMethod(request, response);
372 ans = (Boolean) invokeMethod(res, request, response, sessionMap);
373 } catch (Exception e) {
374 logger.error(EELFLoggerDelegate.errorLogger, "extendSessionTimeOuts failed", e);
379 @ApiOperation(value = "Gets javascript with functions that support gathering and reporting web analytics.", response = String.class)
380 @RequestMapping(value = { "/v3/analytics" }, method = RequestMethod.GET, produces = "application/javascript")
381 public String getAnalyticsScript(HttpServletRequest request, HttpServletResponse response) throws Exception {
382 Map<String, Object> res = getMethod(request, response);
385 ans = (String) invokeMethod(res, request, response);
386 } catch (Exception e) {
387 logger.error(EELFLoggerDelegate.errorLogger, "getAnalyticsScript failed", e);
392 @RequestMapping(value = { "/v3/storeAnalytics" }, method = RequestMethod.POST, produces = "application/json")
394 @ApiOperation(value = "Accepts data from partner applications with web analytics data.", response = PortalAPIResponse.class)
395 public PortalAPIResponse storeAnalyticsScript(HttpServletRequest request, HttpServletResponse response,
396 @RequestBody Analytics analyticsMap) throws Exception {
398 if (analyticsMap!=null){
399 if (!dataValidator.isValid(analyticsMap))
400 return new PortalAPIResponse(false, "analyticsScript is not valid");
403 Map<String, Object> res = getMethod(request, response);
404 PortalAPIResponse ans = new PortalAPIResponse(true, "error");
406 ans = (PortalAPIResponse) invokeMethod(res, request, response, analyticsMap);
407 } catch (Exception e) {
408 logger.error(EELFLoggerDelegate.errorLogger, "storeAnalyticsScript failed", e);
414 @SuppressWarnings("unchecked")
415 @ApiOperation(value = "Bulk upload functions for an application.", response = PortalRestResponse.class, responseContainer = "Json")
416 @RequestMapping(value = {
417 "/v3/upload/portal/functions" }, method = RequestMethod.POST, produces = "application/json")
418 public PortalRestResponse<String> bulkUploadFunctions(HttpServletRequest request, HttpServletResponse response)
420 Optional<PortalRestResponse<String>> result = null;
421 Map<String, Object> res = getMethod(request, response);
423 result = Optional.ofNullable((PortalRestResponse<String>) invokeMethod(res, request, response));
424 if (!result.isPresent()){
425 logger.error(EELFLoggerDelegate.errorLogger, "Failed to bulkUploadFunctions", new Exception("Failed to bulkUploadFunctions"));
426 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Failed to bulkUploadFunctions", "Failed");
428 } catch (Exception e) {
429 logger.error(EELFLoggerDelegate.errorLogger, "bulkUploadFunctions failed", e);
430 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
435 @SuppressWarnings("unchecked")
436 @ApiOperation(value = "Bulk upload roles for an application.", response = PortalRestResponse.class, responseContainer = "Json")
437 @RequestMapping(value = { "/v3/upload/portal/roles" }, method = RequestMethod.POST, produces = "application/json")
438 public PortalRestResponse<String> bulkUploadRoles(HttpServletRequest request, HttpServletResponse response)
440 Optional<PortalRestResponse<String>> result;
441 Map<String, Object> res = getMethod(request, response);
443 result = Optional.ofNullable((PortalRestResponse<String>) invokeMethod(res, request, response));
444 if (!result.isPresent()){
445 logger.error(EELFLoggerDelegate.errorLogger, "Failed to bulkUploadRoles", new Exception("Failed to bulkUploadRoles"));
446 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Failed to bulkUploadRoles", "Failed");
449 } catch (Exception e) {
450 logger.error(EELFLoggerDelegate.errorLogger, "bulkUploadRoles failed", e);
451 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
455 @SuppressWarnings("unchecked")
456 @ApiOperation(value = "Bulk upload role functions for an application.", response = PortalRestResponse.class, responseContainer = "Json")
457 @RequestMapping(value = {
458 "/v3/upload/portal/roleFunctions" }, method = RequestMethod.POST, produces = "application/json")
459 public PortalRestResponse<String> bulkUploadRoleFunctions(HttpServletRequest request, HttpServletResponse response)
461 Optional<PortalRestResponse<String>> result;
462 Map<String, Object> res = getMethod(request, response);
464 result = Optional.ofNullable((PortalRestResponse<String>) invokeMethod(res, request, response));
465 if (!result.isPresent()){
466 logger.error(EELFLoggerDelegate.errorLogger, "Failed to bulkUploadRoleFunctions", new Exception("Failed to bulkUploadRoleFunctions"));
467 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Failed to bulkUploadRoleFunctions", "Failed");
470 } catch (Exception e) {
471 logger.error(EELFLoggerDelegate.errorLogger, "bulkUploadRoleFunctions failed", e);
472 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
476 @SuppressWarnings("unchecked")
477 @ApiOperation(value = "Bulk upload user roles for an application.", response = PortalRestResponse.class, responseContainer = "Json")
478 @RequestMapping(value = {
479 "/v3/upload/portal/userRoles" }, method = RequestMethod.POST, produces = "application/json")
480 public PortalRestResponse<String> bulkUploadUserRoles(HttpServletRequest request, HttpServletResponse response)
482 Optional<PortalRestResponse<String>> result;
483 Map<String, Object> res = getMethod(request, response);
485 result = Optional.ofNullable((PortalRestResponse<String>) invokeMethod(res, request, response));
486 if (!result.isPresent()){
487 logger.error(EELFLoggerDelegate.errorLogger, "Failed to bulkUploadUserRoles", new Exception("Failed to bulkUploadUserRoles"));
488 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Failed to bulkUploadUserRoles", "Failed");
491 } catch (Exception e) {
492 logger.error(EELFLoggerDelegate.errorLogger, "bulkUploadUserRoles failed", e);
493 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
498 @SuppressWarnings("unchecked")
499 @ApiOperation(value = "Bulk upload users for renamed role of an application.", response = PortalRestResponse.class, responseContainer = "Json")
500 @RequestMapping(value = {
501 "/v3/upload/portal/userRole/{roleId}" }, method = RequestMethod.POST, produces = "application/json")
502 public PortalRestResponse<String> bulkUploadUsersSingleRole(HttpServletRequest request,
503 HttpServletResponse response, @PathVariable Long roleId) throws Exception {
504 Optional<PortalRestResponse<String>> result = null;
505 Map<String, Object> res = getMethod(request, response);
507 result = Optional.ofNullable((PortalRestResponse<String>) invokeMethod(res, request, response));
508 if (!result.isPresent()){
509 logger.error(EELFLoggerDelegate.errorLogger, "Failed to bulkUploadUsersSingleRole", new Exception("Failed to bulkUploadUsersSingleRole"));
510 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Failed to bulkUploadUsersSingleRole", "Failed");
513 } catch (Exception e) {
514 logger.error(EELFLoggerDelegate.errorLogger, "bulkUploadUsersSingleRole failed", e);
515 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
519 @SuppressWarnings("unchecked")
520 @ApiOperation(value = "Bulk upload functions for an partner application.", response = PortalRestResponse.class, responseContainer = "Json")
521 @RequestMapping(value = {
522 "/v3/upload/partner/functions" }, method = RequestMethod.POST, produces = "application/json")
523 public PortalRestResponse<String> bulkUploadPartnerFunctions(HttpServletRequest request,
524 HttpServletResponse response) throws Exception {
525 Optional<PortalRestResponse<String>> result = null;
526 Map<String, Object> res = getMethod(request, response);
528 result = Optional.ofNullable((PortalRestResponse<String>) invokeMethod(res, request, response));
529 if (!result.isPresent()){
530 logger.error(EELFLoggerDelegate.errorLogger, "Failed to bulkUploadPartnerRoleFunctions", new Exception("Failed to bulkUploadPartnerRoleFunctions"));
531 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Failed to bulkUploadPartnerRoleFunctions", "Failed");
534 } catch (Exception e) {
535 logger.error(EELFLoggerDelegate.errorLogger, "bulkUploadPartnerFunctions failed", e);
536 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
541 @SuppressWarnings("unchecked")
542 @ApiOperation(value = "Bulk upload roles for an partner application.", response = PortalRestResponse.class, responseContainer = "Json")
543 @RequestMapping(value = { "/v3/upload/partner/roles" }, method = RequestMethod.POST, produces = "application/json")
544 public PortalRestResponse<String> bulkUploadPartnerRoles(HttpServletRequest request, HttpServletResponse response,
545 @RequestBody List<Role> upload) throws Exception {
546 Optional<PortalRestResponse<String>> result = null;
547 Map<String, Object> res = getMethod(request, response);
549 result = Optional.ofNullable((PortalRestResponse<String>) invokeMethod(res, request, response));
550 if (!result.isPresent()){
551 logger.error(EELFLoggerDelegate.errorLogger, "Failed to bulkUploadRoles", new Exception("Failed to bulkUploadRoles"));
552 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Failed to bulkUploadRoles", "Failed");
555 } catch (Exception e) {
556 logger.error(EELFLoggerDelegate.errorLogger, "bulkUploadPartnerRoles failed", e);
557 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
561 @SuppressWarnings("unchecked")
562 @ApiOperation(value = "Bulk upload role functions for an partner application.", response = PortalRestResponse.class, responseContainer = "Json")
563 @RequestMapping(value = {
564 "/v3/upload/partner/roleFunctions" }, method = RequestMethod.POST, produces = "application/json")
565 public PortalRestResponse<String> bulkUploadPartnerRoleFunctions(HttpServletRequest request,
566 HttpServletResponse response) throws Exception {
567 Optional<PortalRestResponse<String>> result = null;
568 Map<String, Object> res = getMethod(request, response);
570 result = Optional.ofNullable((PortalRestResponse<String>) invokeMethod(res, request, response));
571 if (!result.isPresent()){
572 logger.error(EELFLoggerDelegate.errorLogger, "Failed to bulkUploadPartnerRoleFunctions", new Exception("Failed to bulkUploadPartnerRoleFunctions"));
573 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Failed to bulkUploadPartnerRoleFunctions", "Failed");
576 } catch (Exception e) {
577 logger.error(EELFLoggerDelegate.errorLogger, "bulkUploadPartnerRoleFunctions failed", e);
578 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
582 @SuppressWarnings("unchecked")
583 @ApiOperation(value = "Gets all functions along with global functions", response = List.class, responseContainer = "Json")
584 @RequestMapping(value = { "/v3/menuFunctions" }, method = RequestMethod.GET, produces = "application/json")
585 public List<String> getMenuFunctions(HttpServletRequest request, HttpServletResponse response) throws Exception {
586 List<String> functionsList = null;
587 Map<String, Object> res = getMethod(request, response);
589 functionsList = (List<String>) invokeMethod(res, request, response);
590 } catch (Exception e) {
591 logger.error(EELFLoggerDelegate.errorLogger, "getMenuFunctions failed", e);
593 return functionsList;
596 private String getPatchNumber() {
597 String response = "0";
599 Attributes attributes = manifestService.getWebappManifest();
600 response = attributes.getValue("Build-Number");
601 } catch (Exception ex) {
602 logger.error(EELFLoggerDelegate.errorLogger, "getPatchNumber failed", ex);
607 @SuppressWarnings("rawtypes")
608 private List<Object> getObject(HttpServletRequest request, HttpServletResponse response) {
609 Map<String, Object> beans = context.getBeansWithAnnotation(ApiVersion.class);
610 @SuppressWarnings("unchecked")
611 List<Object> beansList = new ArrayList(beans.values());
616 private Map<String, Object> getMethod(HttpServletRequest request, HttpServletResponse response) {
617 Method finalmethod = null;
618 String url = request.getRequestURI();
621 Object currentObject = null;
622 Map<String, Object> res = new HashMap<String, Object>();
623 String[] uriArray = url.split("/auxapi");
624 List<Integer> minorversionList = new ArrayList<>();
625 if (uriArray.length > 1) {
626 service = uriArray[1];
628 int first = service.indexOf("/");
629 int second = service.indexOf("/", first + 1);
630 version = service.substring(first + 1, second);
631 int min = minorVersion;
632 if (request.getHeader("MinorVersion") != null) {
633 min = Integer.parseInt(request.getHeader("MinorVersion"));
635 res.put("min", version+"."+min);
636 res.put("service", service);
637 List<Object> objList = getObject(request, response);
638 String requestedApiMethodType = request.getMethod();
639 String majorVersion = latestMajorVersionOfService(objList, service, version, requestedApiMethodType);
640 int latestMinorVersion = latestMinorVersionOfService(objList, service, version, requestedApiMethodType);
641 res.put("majorVersion", majorVersion);
642 res.put("latestMinorVersion", String.valueOf(latestMinorVersion));
643 outerloop: for (Object obj : objList) {
644 final List<Method> allMethods = getAllMethodsOfClass(obj);
645 for (final Method method : allMethods) {
646 if (method.isAnnotationPresent(ApiVersion.class)) {
647 ApiVersion annotInstance = method.getAnnotation(ApiVersion.class);
648 Pattern p = Pattern.compile(annotInstance.service(),
649 Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
650 Matcher matcher = p.matcher(service);
651 boolean b = matcher.matches();
652 logger.debug(EELFLoggerDelegate.debugLogger, "Requested Servie is:" + service
653 + "Requested MinVersion is:" + min + "Requested MajorVersion is: " + version);
654 if (annotInstance.max().equals(version) && b && annotInstance.min() == min
655 && annotInstance.method().equals(request.getMethod())) {
656 finalmethod = method;
658 res.put("method", method);
668 private String latestMajorVersionOfService(List<Object> objList, String service, String reuqestedVersion,
669 String requestedApiMethodType) {
670 Integer majorVersion = 0;
671 String serviceEndPoint = service;
672 int firstindex = serviceEndPoint.indexOf("/");
673 int secondindex = serviceEndPoint.indexOf("/", firstindex + 1);
674 serviceEndPoint = serviceEndPoint.substring(secondindex + 1);
676 List<Integer> latestMajorVersionList = new ArrayList<>();
677 for (Object obj : objList) {
678 final List<Method> allMethods = getAllMethodsOfClass(obj);
679 for (final Method method : allMethods) {
680 if (method.isAnnotationPresent(ApiVersion.class)) {
681 ApiVersion annotInstance = method.getAnnotation(ApiVersion.class);
682 String endpoint = annotInstance.service();
683 int first = endpoint.indexOf("/");
684 int second = endpoint.indexOf("/", first + 1);
685 endpoint = endpoint.substring(second + 1);
686 Pattern p = Pattern.compile(endpoint,
687 Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
688 Matcher matcher = p.matcher(serviceEndPoint);
689 boolean b = matcher.matches();
690 if (b && annotInstance.method().equals(requestedApiMethodType)) {
691 int index1 = annotInstance.service().indexOf("/");
692 int index2 = annotInstance.service().indexOf("/", index1 + 1);
693 String majorversion = annotInstance.service().substring(index1 + 2, index2);
694 latestMajorVersionList.add(Integer.parseInt(majorversion));
699 majorVersion = Collections.max(latestMajorVersionList);
700 String majorVersionWithLastestMin = "/v"+String.valueOf(majorVersion)+"/"+serviceEndPoint;
701 int latestMinorVersion = latestMinorVersionOfService(objList, majorVersionWithLastestMin, "v"+String.valueOf(majorVersion), requestedApiMethodType);
702 return majorVersion+"."+latestMinorVersion;
705 private List<Method> getAllMethodsOfClass(Object obj) {
706 List<Method> allMethods = new ArrayList<>();
707 Class<?> objClz = obj.getClass();
708 if (org.springframework.aop.support.AopUtils.isAopProxy(obj)) {
709 objClz = org.springframework.aop.support.AopUtils.getTargetClass(obj);
711 allMethods = new ArrayList<Method>(Arrays.asList(objClz.getMethods()));
712 allMethods.removeIf(s -> !(s.isAnnotationPresent(ApiVersion.class)));
716 private Integer latestMinorVersionOfService(List<Object> objList, String service, String reuqestedVersion,
717 String requestedApiMethodType) {
718 Integer minVersion = 0;
719 String serviceEndPoint = service;
720 List<Integer> latestMinorVersionList = new ArrayList<>();
721 for (Object obj : objList) {
722 final List<Method> allMethods = getAllMethodsOfClass(obj);
723 for (final Method method : allMethods) {
724 if (method.isAnnotationPresent(ApiVersion.class)) {
725 ApiVersion annotInstance = method.getAnnotation(ApiVersion.class);
726 String endpoint = annotInstance.service();
728 Pattern p = Pattern.compile(endpoint,
729 Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
730 Matcher matcher = p.matcher(serviceEndPoint);
731 boolean b = matcher.matches();
732 if (annotInstance.max().equals(reuqestedVersion) && b
733 && annotInstance.method().equals(requestedApiMethodType)) {
734 int minorversion = annotInstance.min();
735 latestMinorVersionList.add(minorversion);
740 minVersion = Collections.max(latestMinorVersionList);
744 private HttpServletResponse setResponse(HttpServletResponse response, String requestedMinVersion,
745 String majorVersion, String latestMinorVersion, String service) {
746 response.setHeader("X-MinorVersion", requestedMinVersion.toUpperCase());
747 response.setHeader("X-PatchVersion", getPatchNumber());
748 response.setHeader("X-LatestVersion", "V"+majorVersion);
756 * method parameters(Maintain HttpServletRequest at 0th position
757 * and HttpServletResponse at 1th position in args array)
761 private Object invokeMethod(Map<String, Object> res, Object... args) throws Exception {
762 Method method = (Method) res.get("method");
763 Object obj = res.get("Obj");
764 Object responseObj = null;
765 String min = res.get("min").toString();
766 String majorVersion = res.get("majorVersion").toString();
767 String latestMinorVersion = res.get("latestMinorVersion").toString();
768 String service = res.get("service").toString();
769 HttpServletRequest request = (HttpServletRequest) args[0];
770 HttpServletResponse response = (HttpServletResponse) args[1];
771 setResponse(response, min, majorVersion, latestMinorVersion, service);
772 final Map<String, String> errorMap = new HashMap<>();
773 ObjectMapper mapper = new ObjectMapper();
776 if (method != null && obj != null) {
777 responseObj = method.invoke(obj, args);
779 errorMap.put("error", "Requested api is not available");
780 reason = mapper.writeValueAsString(errorMap);
781 response.getWriter().write(reason);
782 logger.debug(EELFLoggerDelegate.debugLogger, "Requested api " + request.getRequestURI()
783 + "is not available with minorVersion " + request.getHeader("MinorVersion"));
784 response.setStatus(HttpServletResponse.SC_NOT_FOUND);
786 } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
787 logger.error(EELFLoggerDelegate.errorLogger, "Method :" + method + "invocation failed", e);
793 public void setApplicationContext(ApplicationContext context) throws BeansException {
794 this.context = context;
797 @SuppressWarnings("unchecked")
798 @ApiOperation(value = "Creates an application user with the specified roles.", response = PortalRestResponse.class)
799 @RequestMapping(value = { "/v3/userProfile" }, method = RequestMethod.POST, produces = "application/json")
800 public PortalRestResponse<String> postUserProfile(HttpServletRequest request,
801 @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) {
803 if (extSysUser!=null){
804 if (!dataValidator.isValid(extSysUser))
805 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "ExternalSystemUser is not valid", "Failed");
808 PortalRestResponse<String> result = null;
809 Map<String, Object> res = getMethod(request, response);
811 result = (PortalRestResponse<String>) invokeMethod(res, request, response, extSysUser);
813 } catch (Exception e) {
814 logger.error(EELFLoggerDelegate.errorLogger, "postUserProfile failed", e);
815 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
819 @SuppressWarnings("unchecked")
820 @ApiOperation(value = "Updates an application user to have only the specified roles.", response = PortalRestResponse.class)
821 @RequestMapping(value = { "/v3/userProfile" }, method = RequestMethod.PUT, produces = "application/json")
822 public PortalRestResponse<String> putUserProfile(HttpServletRequest request,
823 @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) {
825 if (extSysUser!=null){
826 if (!dataValidator.isValid(extSysUser))
827 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "ExternalSystemUser is not valid", "Failed");
830 PortalRestResponse<String> result = null;
831 Map<String, Object> res = getMethod(request, response);
833 result = (PortalRestResponse<String>) invokeMethod(res, request, response, extSysUser);
835 } catch (Exception e) {
836 logger.error(EELFLoggerDelegate.errorLogger, "putUserProfile failed", e);
837 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
841 @SuppressWarnings("unchecked")
842 @ApiOperation(value = "Processes a request to delete one or more application roles for one specified user who has roles.", response = PortalRestResponse.class)
843 @RequestMapping(value = { "/v3/userProfile" }, method = RequestMethod.DELETE, produces = "application/json")
844 public PortalRestResponse<String> deleteUserProfile(HttpServletRequest request,
845 @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) {
847 if (extSysUser!=null){
848 if (!dataValidator.isValid(extSysUser))
849 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "ExternalSystemUser is not valid", "Failed");
852 PortalRestResponse<String> result = null;
853 Map<String, Object> res = getMethod(request, response);
855 result = (PortalRestResponse<String>) invokeMethod(res, request, response, extSysUser);
857 } catch (Exception e) {
858 logger.error(EELFLoggerDelegate.errorLogger, "deleteUserProfile failed", e);
859 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
863 @SuppressWarnings("unchecked")
864 @ApiOperation(value = "Accepts messages from external ticketing systems and creates notifications for Portal users.", response = PortalRestResponse.class)
865 @RequestMapping(value = { "/v3/ticketevent" }, method = RequestMethod.POST)
866 public PortalRestResponse<String> handleRequest(HttpServletRequest request, HttpServletResponse response,
867 @RequestBody String ticketEventJson) throws Exception {
869 if (ticketEventJson!=null){
870 SecureString secureTicketEventJson = new SecureString(ticketEventJson);
871 if (!dataValidator.isValid(secureTicketEventJson))
872 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "ticketEventJson is not valid", "Failed");
875 PortalRestResponse<String> result = null;
876 Map<String, Object> res = getMethod(request, response);
878 result = (PortalRestResponse<String>) invokeMethod(res, request, response, ticketEventJson);
880 } catch (Exception e) {
881 logger.error(EELFLoggerDelegate.errorLogger, "handleRequest failed", e);
882 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
886 @SuppressWarnings("unchecked")
887 @ApiOperation(value = "Creates a new user as a Portal administrator.", response = PortalRestResponse.class)
888 @RequestMapping(value = "/v3/portalAdmin", method = RequestMethod.POST, produces = "application/json")
890 public PortalRestResponse<String> postPortalAdmin(HttpServletRequest request, HttpServletResponse response,
891 @RequestBody EPUser epUser) {
894 if (!dataValidator.isValid(epUser))
895 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "EPUser is not valid", "Failed");
898 PortalRestResponse<String> result = null;
899 Map<String, Object> res = getMethod(request, response);
901 result = (PortalRestResponse<String>) invokeMethod(res, request, response, epUser);
903 } catch (Exception e) {
904 logger.error(EELFLoggerDelegate.errorLogger, "postPortalAdmin failed", e);
905 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
909 @ApiOperation(value = "Gets the specified application that is on-boarded in Portal.", response = OnboardingApp.class)
910 @RequestMapping(value = { "/v3/onboardApp/{appId}" }, method = RequestMethod.GET, produces = "application/json")
912 public OnboardingApp getOnboardAppExternal(HttpServletRequest request, HttpServletResponse response,
913 @PathVariable("appId") Long appId) {
914 OnboardingApp result = new OnboardingApp();
915 Map<String, Object> res = getMethod(request, response);
917 result = (OnboardingApp) invokeMethod(res, request, response, appId);
918 } catch (Exception e) {
919 logger.error(EELFLoggerDelegate.errorLogger, "getOnboardAppExternal failed", e);
924 @SuppressWarnings("unchecked")
925 @ApiOperation(value = "Adds a new application to Portal.", response = PortalRestResponse.class)
926 @RequestMapping(value = { "/v3/onboardApp" }, method = RequestMethod.POST, produces = "application/json")
928 public PortalRestResponse<String> postOnboardAppExternal(HttpServletRequest request, HttpServletResponse response,
929 @RequestBody OnboardingApp newOnboardApp) {
931 if (newOnboardApp!=null){
932 if (!dataValidator.isValid(newOnboardApp))
933 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "OnboardingApp is not valid", "Failed");
936 PortalRestResponse<String> result = new PortalRestResponse<>();
937 Map<String, Object> res = getMethod(request, response);
939 result = (PortalRestResponse<String>) invokeMethod(res, request, response, newOnboardApp);
941 } catch (Exception e) {
942 logger.error(EELFLoggerDelegate.errorLogger, "postOnboardAppExternal failed", e);
943 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
948 @SuppressWarnings("unchecked")
949 @ApiOperation(value = "Updates information about an on-boarded application in Portal.", response = PortalRestResponse.class)
950 @RequestMapping(value = { "/v3/onboardApp/{appId}" }, method = RequestMethod.PUT, produces = "application/json")
952 public PortalRestResponse<String> putOnboardAppExternal(HttpServletRequest request, HttpServletResponse response,
953 @PathVariable("appId") Long appId, @RequestBody OnboardingApp oldOnboardApp) {
955 if (oldOnboardApp!=null){
956 if (!dataValidator.isValid(oldOnboardApp))
957 return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "OnboardingApp is not valid", "Failed");
960 PortalRestResponse<String> result;
961 Map<String, Object> res = getMethod(request, response);
963 result = (PortalRestResponse<String>) invokeMethod(res, request, response, appId, oldOnboardApp);
965 } catch (Exception e) {
966 logger.error(EELFLoggerDelegate.errorLogger, "putOnboardAppExternal failed", e);
967 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");
971 @ApiOperation(value = "Creates a Portal user notification for roles identified in the content from an external application.", response = PortalAPIResponse.class)
972 @RequestMapping(value = { "/v3/publishNotification" }, method = RequestMethod.POST, produces = "application/json")
974 public PortalAPIResponse publishNotification(HttpServletRequest request,
975 @RequestBody EpNotificationItem notificationItem, HttpServletResponse response) {
977 if (notificationItem!=null){
978 if (!dataValidator.isValid(notificationItem))
979 return new PortalAPIResponse(false, "EpNotificationItem is not valid");
982 Map<String, Object> res = getMethod(request, response);
984 return (PortalAPIResponse) invokeMethod(res, request, response, notificationItem);
985 } catch (Exception e) {
986 logger.error(EELFLoggerDelegate.errorLogger, "publishNotification failed", e);
987 return new PortalAPIResponse(false, e.getMessage());
991 @SuppressWarnings("unchecked")
992 @ApiOperation(value = "Gets favorite items within the functional menu for the current user.", response = FavoritesFunctionalMenuItemJson.class, responseContainer = "List")
993 @RequestMapping(value = { "/v3/getFavorites" }, method = RequestMethod.GET, produces = "application/json")
994 public List<FavoritesFunctionalMenuItemJson> getFavoritesForUser(HttpServletRequest request,
995 HttpServletResponse response) throws Exception {
996 List<FavoritesFunctionalMenuItemJson> favorites = null;
997 Map<String, Object> res = getMethod(request, response);
999 favorites = (List<FavoritesFunctionalMenuItemJson>) invokeMethod(res, request, response);
1000 } catch (Exception e) {
1001 logger.error(EELFLoggerDelegate.errorLogger, "getFavoritesForUser failed", e);
1006 @SuppressWarnings("unchecked")
1007 @ApiOperation(value = "Gets functional menu items appropriate for the current user.", response = FunctionalMenuItem.class, responseContainer = "List")
1008 @RequestMapping(value = {
1009 "/v3/functionalMenuItemsForUser" }, method = RequestMethod.GET, produces = "application/json")
1010 public List<FunctionalMenuItem> getFunctionalMenuItemsForUser(HttpServletRequest request,
1011 HttpServletResponse response) throws Exception {
1012 List<FunctionalMenuItem> fnMenuItems = null;
1013 Map<String, Object> res = getMethod(request, response);
1015 fnMenuItems = (List<FunctionalMenuItem>) invokeMethod(res, request, response);
1016 } catch (Exception e) {
1017 logger.error(EELFLoggerDelegate.errorLogger, "getFunctionalMenuItemsForUser failed", e);
1023 @ApiOperation(value = "Gets MechId roles", response = String.class, responseContainer = "List")
1024 @RequestMapping(value = { "/v3/systemUser" }, method = RequestMethod.GET, produces = "application/json")
1025 public List<AAFPermission> getSystemUserPerms(HttpServletRequest request, HttpServletResponse response) throws Exception {
1026 List<AAFPermission> permsList = null;
1027 Map<String, Object> res = getMethod(request, response);
1029 permsList = (List<AAFPermission>) invokeMethod(res, request, response);
1030 } catch (Exception e) {
1031 logger.error(EELFLoggerDelegate.errorLogger, "getSystemUserPerms failed", e);
1036 @ApiOperation(value = "Update role description in external auth system for an application.", response = PortalRestResponse.class, responseContainer = "Json")
1037 @RequestMapping(value = { "/v3/update/app/roleDescription" }, method = RequestMethod.PUT, produces = "application/json")
1038 public PortalRestResponse<String> updateAppRoleDescription(HttpServletRequest request, HttpServletResponse response) throws Exception {
1039 PortalRestResponse<String> result = null;
1040 Map<String, Object> res = getMethod(request, response);
1042 result = (PortalRestResponse<String>) invokeMethod(res, request, response);
1044 } catch (Exception e) {
1045 logger.error(EELFLoggerDelegate.errorLogger, "updateAppRoleDescription failed", e);
1046 return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, e.getMessage(), "Failed");