private void checkProjectAdminPermission(Handler handler, ProjectComponent component, ApplicationUser user) { if (component == null) { handler.addErrorKey(KEY_NO_SUCH_COMPONENT, null, ErrorCollection.Reason.FORBIDDEN); } else { Long projectId = component.getProjectId(); checkProjectAdminPermission(handler, projectId, user); } }
private void checkProjectAdminPermission(ErrorCollection errorCollection, ProjectComponent component, ApplicationUser user) { if (component == null) { errorCollection.addErrorMessage(translateKeyToMessage(KEY_NO_SUCH_COMPONENT, null), ErrorCollection.Reason.FORBIDDEN); } else { Long projectId = component.getProjectId(); checkProjectAdminPermission(errorCollection, projectId, user); } }
@Override public void deleteComponentForIssues(final JiraServiceContext context, Long componentId) { final ErrorCollection errorCollection = context.getErrorCollection(); final ApplicationUser user = context.getLoggedInUser(); // Validate that we can find the component we are deleting ProjectComponent component = validateAndGetComponent(componentId, KEY_NO_SUCH_COMPONENT, KEY_NO_SUCH_COMPONENT_WITH_ID, errorCollection); if(errorCollection.hasAnyErrors()) { return; } // Validate that we have permission to delete and swap the components checkProjectAdminPermission(errorCollection, component, user); if(errorCollection.hasAnyErrors()) { return; } // Now lets remove the component from all affected issues. removeComponentForAffectedIssues(context, component); if(errorCollection.hasAnyErrors()) { return; } // Now do the actual delete if there were no errors swaping components delete(context, componentId); }
checkProjectAdminPermission(errorCollection, component, user); if(errorCollection.hasAnyErrors())