Source:
<code>public boolean chkAuthorization(String userName, Object workspaceObj, String[] userRoles) throws QuadrigaStorageException, QuadrigaAccessException { boolean haveAccess = false; IWorkSpace workspace; String workspaceId = null; if (workspaceObj.getClass().equals(String.class)) { workspaceId = (String) workspaceObj; workspace = wsManager.getWorkspaceDetails(workspaceId, userName); } else { workspace = (IWorkSpace) workspaceObj; <START> } <END> IProject project = workspace.getProjectWorkspace().getProject(); List<String> projects = new ArrayList<String>(); projects.add(project.getProjectId()); boolean isProjectOwnerOrAdmin = projectAuthorization.chkAuthorization(userName, projects, new String[] { RoleNames.ROLE_PROJ_COLLABORATOR_ADMIN }); if (isProjectOwnerOrAdmin) { return true; } if (workspace != null) { String workspaceOwner = workspace.getOwner().getUserName(); if (userName.equals(workspaceOwner)) { haveAccess = true; } if (!haveAccess) { if (userRoles.length > 0) { ArrayList<String> roles = getAccessRoleList(userRoles); List<IWorkspaceCollaborator> workspaceCollaboratorList = workspace.getWorkspaceCollaborators(); if (workspaceCollaboratorList != null) { for (IWorkspaceCollaborator workspaceCollaborator : workspaceCollaboratorList) { String collaboratorName = null; if (workspaceCollaborator.getCollaborator() != null) { collaboratorName = workspaceCollaborator.getCollaborator().getUserObj().getUserName(); } if (collaboratorName != null) { if (userName.equals(collaboratorName)) { List<IQuadrigaRole> collaboratorRoles = null; if (workspaceCollaborator.getCollaborator() != null) { collaboratorRoles = workspaceCollaborator.getCollaborator() .getCollaboratorRoles(); } if (collaboratorRoles != null) { for (IQuadrigaRole collabRole : collaboratorRoles) { String collaboratorRoleId = collabRole.getId(); if (roles.contains(collaboratorRoleId)) { haveAccess = true; return haveAccess; } } } } } } } } } } return haveAccess; }</code><technical_language>for of cases, throw exception</technical_language>

Target:
public boolean chkAuthorization(String userName, Object workspaceObj, String[] userRoles) throws QuadrigaStorageException, QuadrigaAccessException { IWorkSpace workspace; if (workspaceObj instanceof String) { String workspaceId = (String) workspaceObj; workspace = wsManager.getWorkspaceDetails(workspaceId, userName); } else { try { workspace = (IWorkSpace) workspaceObj; } catch (ClassCastException cce) { throw new IllegalObjectException(cce); } } IProject project = workspace.getProjectWorkspace().getProject(); List<String> projects = new ArrayList<String>(); projects.add(project.getProjectId()); boolean isProjectOwnerOrAdmin = projectAuthorization.chkAuthorization(userName, projects, new String[] { RoleNames.ROLE_PROJ_COLLABORATOR_ADMIN }); if (isProjectOwnerOrAdmin) { return true; } if (workspace != null) { String workspaceOwner = workspace.getOwner().getUserName(); if (userName.equals(workspaceOwner)) { return true; } else { if (userRoles.length > 0) { List<String> roles = Arrays.asList(userRoles); List<IWorkspaceCollaborator> workspaceCollaboratorList = workspace.getWorkspaceCollaborators(); if (workspaceCollaboratorList != null) { for (IWorkspaceCollaborator workspaceCollaborator : workspaceCollaboratorList) { String collaboratorName = null; if (workspaceCollaborator.getCollaborator() != null) { collaboratorName = workspaceCollaborator.getCollaborator().getUserObj().getUserName(); } if (collaboratorName != null) { if (userName.equals(collaboratorName)) { List<IQuadrigaRole> collaboratorRoles = null; if (workspaceCollaborator.getCollaborator() != null) { collaboratorRoles = workspaceCollaborator.getCollaborator() .getCollaboratorRoles(); } if (collaboratorRoles != null) { for (IQuadrigaRole collabRole : collaboratorRoles) { String collaboratorRoleId = collabRole.getId(); if (roles.contains(collaboratorRoleId)) { return true; } } } } } } } } } } return false; }