Update license; improve coverage; add docs dir
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / controller / RoleManageController.java
index 2d0fe27..7c4a4e8 100644 (file)
@@ -1,21 +1,39 @@
 /*-
- * ================================================================================
- * ECOMP Portal
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
  * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
+ *             http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *             https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 package org.openecomp.portalapp.portal.controller;
 
@@ -26,9 +44,13 @@ import org.openecomp.portalapp.controller.EPRestrictedBaseController;
 import org.openecomp.portalapp.controller.core.RoleController;
 import org.openecomp.portalapp.controller.core.RoleFunctionListController;
 import org.openecomp.portalapp.controller.core.RoleListController;
+import org.openecomp.portalapp.portal.domain.EPApp;
 import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse;
 import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum;
 import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
+import org.openecomp.portalapp.portal.service.ExternalAccessRolesService;
+import org.openecomp.portalapp.portal.service.ExternalAccessRolesServiceImpl;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -47,6 +69,7 @@ import org.springframework.web.servlet.ModelAndView;
 @EnableAspectJAutoProxy
 @EPAuditLog
 public class RoleManageController extends EPRestrictedBaseController {
+       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RoleManageController.class);
 
        @Autowired
        private RoleController roleController;
@@ -57,6 +80,9 @@ public class RoleManageController extends EPRestrictedBaseController {
        @Autowired
        private RoleFunctionListController roleFunctionListController;
 
+
+       @Autowired
+       ExternalAccessRolesService externalAccessRolesService;
        /**
         * Calls an SDK-Core library method that gets the available roles and writes
         * them to the request object. Portal specifies a Hibernate mappings from
@@ -120,7 +146,7 @@ public class RoleManageController extends EPRestrictedBaseController {
        }
 
        @RequestMapping(value = { "/portalApi/get_role" }, method = RequestMethod.GET)
-       public void getRole(HttpServletRequest request, HttpServletResponse response) {
+       public void getRole(HttpServletRequest request, HttpServletResponse response) throws Exception{
                getRoleController().getRole(request, response);
        }
 
@@ -163,4 +189,13 @@ public class RoleManageController extends EPRestrictedBaseController {
                this.roleFunctionListController = roleFunctionListController;
        }
 
+       @RequestMapping(value = { "/portalApi/syncRoles" }, method = RequestMethod.GET)
+       public void  syncRoles(EPApp app)
+       {
+               try {
+                       externalAccessRolesService.syncApplicationRolesWithEcompDB(app);
+               } catch (Exception e) {
+                       logger.error(EELFLoggerDelegate.debugLogger, "failed syncRoles");
+               }
+       }
 }