* ===================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ===================================================================
* ===================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ===================================================================
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
* 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
* 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
import javax.validation.ConstraintViolation;
import javax.validation.Valid;
import javax.validation.Validation;
import javax.validation.ConstraintViolation;
import javax.validation.Valid;
import javax.validation.Validation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public void getRoles(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId)
throws Exception {
try {
public void getRoles(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId)
throws Exception {
try {
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
List<CentralV2Role> answer = null;
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
List<CentralV2Role> answer = null;
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
public Map<String, Object> toggleRole(HttpServletRequest request, HttpServletResponse response,
@PathVariable("appId") Long appId, @PathVariable("roleId") Long roleId) throws Exception {
EPApp requestedApp = null;
public Map<String, Object> toggleRole(HttpServletRequest request, HttpServletResponse response,
@PathVariable("appId") Long appId, @PathVariable("roleId") Long roleId) throws Exception {
EPApp requestedApp = null;
public Map<String, Object> removeRole(HttpServletRequest request, HttpServletResponse response,
@PathVariable("appId") Long appId, @PathVariable("roleId") Long roleId) throws Exception {
public Map<String, Object> removeRole(HttpServletRequest request, HttpServletResponse response,
@PathVariable("appId") Long appId, @PathVariable("roleId") Long roleId) throws Exception {
requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
externalRequestFieldsValidator = externalAccessRolesService.deleteDependencyRoleRecord(roleId,
requestedApp.getUebKey(), user.getOrgUserId());
boolean deleteResponse = externalRequestFieldsValidator.isResult();
externalRequestFieldsValidator = externalAccessRolesService.deleteDependencyRoleRecord(roleId,
requestedApp.getUebKey(), user.getOrgUserId());
boolean deleteResponse = externalRequestFieldsValidator.isResult();
public Map<String, Object> saveRole(HttpServletRequest request, HttpServletResponse response,
@PathVariable("appId") Long appId) throws Exception {
EPUser user = EPUserUtils.getUserSession(request);
public Map<String, Object> saveRole(HttpServletRequest request, HttpServletResponse response,
@PathVariable("appId") Long appId) throws Exception {
EPUser user = EPUserUtils.getUserSession(request);
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
if (existRole.getName().equalsIgnoreCase(role.getName()))
throw new DuplicateRecordException("Role already exists: " + existRole.getName());
if (existRole.getName().equalsIgnoreCase(role.getName()))
throw new DuplicateRecordException("Role already exists: " + existRole.getName());
domainRole.setName(role.getName());
domainRole.setPriority(role.getPriority());
domainRole.setActive(role.getActive());
domainRole.setName(role.getName());
domainRole.setPriority(role.getPriority());
domainRole.setActive(role.getActive());
public ModelAndView removeRoleRoleFunction(HttpServletRequest request, HttpServletResponse response)
throws Exception {
return getRoleController().removeRoleFunction(request, response);
}
public ModelAndView removeRoleRoleFunction(HttpServletRequest request, HttpServletResponse response)
throws Exception {
return getRoleController().removeRoleFunction(request, response);
}
public ModelAndView addRoleRoRoleFunction(HttpServletRequest request, HttpServletResponse response)
throws Exception {
return getRoleController().addRoleFunction(request, response);
}
public ModelAndView addRoleRoRoleFunction(HttpServletRequest request, HttpServletResponse response)
throws Exception {
return getRoleController().addRoleFunction(request, response);
}
public ModelAndView removeChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception {
return getRoleController().removeChildRole(request, response);
}
public ModelAndView removeChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception {
return getRoleController().removeChildRole(request, response);
}
public ModelAndView addChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception {
return getRoleController().addChildRole(request, response);
}
public ModelAndView addChildRole(HttpServletRequest request, HttpServletResponse response) throws Exception {
return getRoleController().addChildRole(request, response);
}
public void getRole(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId,
@PathVariable("roleId") Long roleId) throws Exception {
try {
public void getRole(HttpServletRequest request, HttpServletResponse response, @PathVariable("appId") Long appId,
@PathVariable("roleId") Long roleId) throws Exception {
try {
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
CentralV2Role answer = externalAccessRolesService.getRoleInfo(roleId, requestedApp.getUebKey());
logger.info(EELFLoggerDelegate.applicationLogger, "role_id" + roleId);
Map<String, Object> model = new HashMap<>();
CentralV2Role answer = externalAccessRolesService.getRoleInfo(roleId, requestedApp.getUebKey());
logger.info(EELFLoggerDelegate.applicationLogger, "role_id" + roleId);
Map<String, Object> model = new HashMap<>();
public void getRoleFunctionList(HttpServletRequest request, HttpServletResponse response,
@PathVariable("appId") Long appId) throws Exception {
try {
public void getRoleFunctionList(HttpServletRequest request, HttpServletResponse response,
@PathVariable("appId") Long appId) throws Exception {
try {
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
List<CentralV2RoleFunction> answer = null;
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
List<CentralV2RoleFunction> answer = null;
Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
public PortalRestResponse<String> saveRoleFunction(HttpServletRequest request, HttpServletResponse response, @Valid @RequestBody CentralV2RoleFunction roleFunc,
@PathVariable("appId") Long appId) throws Exception {
if (roleFunc!=null) {
public PortalRestResponse<String> saveRoleFunction(HttpServletRequest request, HttpServletResponse response, @Valid @RequestBody CentralV2RoleFunction roleFunc,
@PathVariable("appId") Long appId) throws Exception {
if (roleFunc!=null) {
EPUser user = EPUserUtils.getUserSession(request);
boolean saveOrUpdateResponse = false;
try {
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
EPUser user = EPUserUtils.getUserSession(request);
boolean saveOrUpdateResponse = false;
try {
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
String code = roleFunc.getType() + PIPE + roleFunc.getCode() + PIPE + roleFunc.getAction();
CentralV2RoleFunction domainRoleFunction = externalAccessRolesService.getRoleFunction(code,
requestedApp.getUebKey());
String code = roleFunc.getType() + PIPE + roleFunc.getCode() + PIPE + roleFunc.getAction();
CentralV2RoleFunction domainRoleFunction = externalAccessRolesService.getRoleFunction(code,
requestedApp.getUebKey());
public PortalRestResponse<String> removeRoleFunction(HttpServletRequest request, HttpServletResponse response,
@RequestBody String roleFunc, @PathVariable("appId") Long appId) throws Exception {
EPUser user = EPUserUtils.getUserSession(request);
public PortalRestResponse<String> removeRoleFunction(HttpServletRequest request, HttpServletResponse response,
@RequestBody String roleFunc, @PathVariable("appId") Long appId) throws Exception {
EPUser user = EPUserUtils.getUserSession(request);
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
EPApp requestedApp = appService.getApp(appId);
if (isAuthorizedUser(user, requestedApp)) {
fieldsValidation(requestedApp);
- @RequestMapping(value = { "/portalApi/centralizedApps" }, method = RequestMethod.GET)
- public List<CentralizedApp> getCentralizedAppRoles(HttpServletRequest request, HttpServletResponse response, String userId) throws IOException {
+ @GetMapping(value = { "/portalApi/centralizedApps" })
+ public List<CentralizedApp> getCentralizedAppRoles(HttpServletRequest request, HttpServletResponse response, String userId) {
EPUser user = EPUserUtils.getUserSession(request);
List<CentralizedApp> applicationsList = null;
if (adminRolesService.isAccountAdmin(user) || adminRolesService.isSuperAdmin(user)
EPUser user = EPUserUtils.getUserSession(request);
List<CentralizedApp> applicationsList = null;
if (adminRolesService.isAccountAdmin(user) || adminRolesService.isSuperAdmin(user)
public PortalRestResponse<String> syncRoles(HttpServletRequest request, HttpServletResponse response,
@RequestBody Long appId) {
EPUser user = EPUserUtils.getUserSession(request);
public PortalRestResponse<String> syncRoles(HttpServletRequest request, HttpServletResponse response,
@RequestBody Long appId) {
EPUser user = EPUserUtils.getUserSession(request);
return new PortalRestResponse<>(PortalRestStatusEnum.OK, "Sync roles completed successfully!", "Success");
}
return new PortalRestResponse<>(PortalRestStatusEnum.OK, "Sync roles completed successfully!", "Success");
}
public PortalRestResponse<String> syncFunctions(HttpServletRequest request, HttpServletResponse response,
@RequestBody Long appId) {
EPUser user = EPUserUtils.getUserSession(request);
public PortalRestResponse<String> syncFunctions(HttpServletRequest request, HttpServletResponse response,
@RequestBody Long appId) {
EPUser user = EPUserUtils.getUserSession(request);
throw new InvalidApplicationException("Invalid credentials");
}
if (!appInfo.isEmpty() && EcompPortalUtils.checkIfRemoteCentralAccessAllowed()
throw new InvalidApplicationException("Invalid credentials");
}
if (!appInfo.isEmpty() && EcompPortalUtils.checkIfRemoteCentralAccessAllowed()
ResponseEntity<String> response = externalAccessRolesService.getNameSpaceIfExists(appInfo.get(0));
if (response.getStatusCode().value() == HttpServletResponse.SC_NOT_FOUND)
throw new InvalidApplicationException("Invalid NameSpace");
ResponseEntity<String> response = externalAccessRolesService.getNameSpaceIfExists(appInfo.get(0));
if (response.getStatusCode().value() == HttpServletResponse.SC_NOT_FOUND)
throw new InvalidApplicationException("Invalid NameSpace");
private boolean isAuthorizedUser(EPUser user, EPApp requestedApp) {
if (user != null && (adminRolesService.isAccountAdminOfApplication(user, requestedApp)
private boolean isAuthorizedUser(EPUser user, EPApp requestedApp) {
if (user != null && (adminRolesService.isAccountAdminOfApplication(user, requestedApp)
- @RequestMapping(value = {
- "/portalApi/uploadRoleFunction/{appId}" }, method = RequestMethod.POST, produces = "application/json")
+ @PostMapping(value = {
+ "/portalApi/uploadRoleFunction/{appId}" }, produces = "application/json")
public PortalRestResponse<String> bulkUploadRoleFunc(HttpServletRequest request, HttpServletResponse response,
@RequestBody UploadRoleFunctionExtSystem data, @PathVariable("appId") Long appId) {
EPUser user = EPUserUtils.getUserSession(request);
public PortalRestResponse<String> bulkUploadRoleFunc(HttpServletRequest request, HttpServletResponse response,
@RequestBody UploadRoleFunctionExtSystem data, @PathVariable("appId") Long appId) {
EPUser user = EPUserUtils.getUserSession(request);