CPD Results

The following document contains the results of PMD's CPD 5.3.2.

Duplications

File Line
org/itracker/web/forms/AdminActionForm.java 32
org/itracker/web/forms/ImportForm.java 32
public class AdminActionForm extends ValidatorForm {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private transient org.apache.struts.upload.FormFile importFile;
    private Boolean optionreuseusers;
    private Boolean optionreuseprojects;
    private Boolean optionreuseconfig;
    private Boolean optionreusefields;
    private Boolean optioncreatepasswords;

    public void reset(ActionMapping mapping, HttpServletRequest request) {
        importFile = null;
        optionreuseusers = null;
        optionreuseprojects = null;
        optionreuseconfig = null;
        optionreusefields = null;
        optioncreatepasswords = null;

    }

    public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {
        ActionErrors errors = super.validate(mapping, request);

        return errors;
    }

    public org.apache.struts.upload.FormFile getImportFile() {
        return importFile;
    }

    public void setImportFile(org.apache.struts.upload.FormFile importFile) {
        this.importFile = importFile;
    }

    public Boolean getOptioncreatepasswords() {
        return optioncreatepasswords;
    }

    public void setOptioncreatepasswords(Boolean optioncreatepasswords) {
        this.optioncreatepasswords = optioncreatepasswords;
    }

    public Boolean getOptionreuseconfig() {
        return optionreuseconfig;
    }

    public void setOptionreuseconfig(Boolean optionreuseconfig) {
        this.optionreuseconfig = optionreuseconfig;
    }

    public Boolean getOptionreusefields() {
        return optionreusefields;
    }

    public void setOptionreusefields(Boolean optionreusefields) {
        this.optionreusefields = optionreusefields;
    }

    public Boolean getOptionreuseprojects() {
        return optionreuseprojects;
    }

    public void setOptionreuseprojects(Boolean optionreuseprojects) {
        this.optionreuseprojects = optionreuseprojects;
    }

    public Boolean getOptionreuseusers() {
        return optionreuseusers;
    }

    public void setOptionreuseusers(Boolean optionreuseusers) {
        this.optionreuseusers = optionreuseusers;
    }

}
File Line
org/itracker/web/actions/admin/user/EditUserFormAction.java 144
org/itracker/web/actions/admin/user/EditUserFormAction.java 163
                                if (permissionList.size() > 1 && i != 0) {

                                    Integer projectId = permissionList.get(i).getProject().getId();

                                    if (userPermissions.get(projectId) == null) {
                                        HashMap<String, Permission> projectPermissions = new HashMap<String, Permission>();
                                        userPermissions.put(permissionList.get(i).getProject().getId(), projectPermissions);
                                    }

                                    formPermissions.put("Perm" + permissionList.get(i).getPermissionType() + "Proj" + permissionList.get(i).getProject().getId(), "on");

                                    Integer permissionType = permissionList.get(i).getPermissionType();

                                    Permission thisPermission = permissionList.get(i);
                                    HashMap<String, Permission> permissionHashMap = ((HashMap<String, Permission>) userPermissions.get(projectId));
                                    permissionHashMap.put(String.valueOf(permissionType), thisPermission);

                                }

                            } else {
File Line
org/itracker/web/actions/admin/configuration/EditConfigurationFormAction.java 102
org/itracker/web/actions/admin/configuration/EditCustomFieldValueFormAction.java 155
org/itracker/web/forms/CustomFieldForm.java 92
            Map<String, List<String>> languages = configurationService
                    .getAvailableLanguages();
            Map<NameValuePair, List<NameValuePair>> languagesNameValuePair = new HashMap<NameValuePair, List<NameValuePair>>();
            for (Map.Entry<String, List<String>> entry : languages.entrySet()) {
                String language = entry.getKey();
                List<String> locales = entry.getValue();
                List<NameValuePair> localesNameValuePair = new ArrayList<NameValuePair>();
                for (String locale : locales) {
                    NameValuePair localeNameValuePair = new NameValuePair(
                            locale, ITrackerResources.getString(
                            "itracker.locale.name", locale));
                    localesNameValuePair.add(localeNameValuePair);
                }
                NameValuePair languageNameValuePair = new NameValuePair(
                        language, ITrackerResources.getString(
                        "itracker.locale.name", language));
                languagesNameValuePair.put(languageNameValuePair,
                        localesNameValuePair);
            }
File Line
org/itracker/web/actions/project/ListProjectsAction.java 36
org/itracker/web/actions/project/ListProjectsAction.java 75
		List<Project> projects = projectService.getAllProjects();

		ArrayList<Project> projects_tmp = new ArrayList<Project>(projects);
		Iterator<Project> projectIt = projects.iterator();
		while (projectIt.hasNext()) {
			Project project = (Project) projectIt.next();
			if (!UserUtilities.hasPermission(permissions, project.getId(),
					permissionFlags)) {
				projects_tmp.remove(project);
			}
		}

		projects = projects_tmp;
		Collections.sort(projects, new Project.ProjectComparator());

		ArrayList<ProjectPTO> ptos = new ArrayList<ProjectPTO>(projects_tmp
				.size());

		projectIt = projects.iterator();

		while (projectIt.hasNext()) {
			Project project = projectIt.next();
			ptos.add(createProjectPTO(project, projectService, permissions));
		}

		return ptos;
	}
File Line
org/itracker/web/actions/admin/report/DownloadReportAction.java 47
org/itracker/web/actions/admin/report/ExportReportAction.java 48
        String pageTitleArg = "";

        if (!LoginUtilities.hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) {
            return mapping.findForward("unauthorized");
        }

        try {
            Integer reportId = new Integer((request.getParameter("id") == null ? "-1" : request.getParameter("id")));
            if (reportId == null || reportId.intValue() < 0) {
                errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.invalidreport"));
            } else {
                ReportService reportService = ServletContextUtils.getItrackerServices().getReportService();

                Report report = reportService.getReportDAO().findByPrimaryKey(reportId);
                if (report != null) {
                    response.setContentType("application/x-itracker-report-export");
                    response.setHeader("Content-Disposition", "attachment; filename=\"ITracker_report_" + report.getId() + ".def\"");
File Line
org/itracker/services/implementations/UserServiceImpl.java 807
org/itracker/services/implementations/UserServiceImpl.java 835
org/itracker/services/implementations/UserServiceImpl.java 863
org/itracker/services/implementations/UserServiceImpl.java 891
                return authenticator.allowProfileCreation(user, authentication, authType,
                        (reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource));
            }

            logger.error("Unable to create new authenticator.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (IllegalAccessException iae) {
            logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (InstantiationException ie) {
            logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (ClassCastException cce) {
            logger.error("Authenticator class " + authenticatorClassName
                    + " does not extend the PluggableAuthenticator class.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        }
    }

    public boolean allowProfileUpdates(User user, Object authentication, int authType, int reqSource)
File Line
org/itracker/services/implementations/UserServiceImpl.java 747
org/itracker/services/implementations/UserServiceImpl.java 807
org/itracker/services/implementations/UserServiceImpl.java 835
org/itracker/services/implementations/UserServiceImpl.java 863
org/itracker/services/implementations/UserServiceImpl.java 891
                return authenticator.checkLogin(login, authentication, authType,
                        (reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource));
            }

            logger.error("Unable to create new authenticator.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (IllegalAccessException iae) {
            logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (InstantiationException ie) {
            logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (ClassCastException cce) {
            logger.error("Authenticator class " + authenticatorClassName
                    + " does not extend the PluggableAuthenticator class.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        }
    }

    public boolean allowRegistration(User user, Object authentication, int authType, int reqSource)
File Line
org/itracker/services/implementations/UserServiceImpl.java 807
org/itracker/services/implementations/UserServiceImpl.java 835
org/itracker/services/implementations/UserServiceImpl.java 863
org/itracker/services/implementations/UserServiceImpl.java 891
org/itracker/services/implementations/UserServiceImpl.java 919
                return authenticator.allowProfileCreation(user, authentication, authType,
                        (reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource));
            }

            logger.error("Unable to create new authenticator.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (IllegalAccessException iae) {
            logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (InstantiationException ie) {
            logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (ClassCastException cce) {
            logger.error("Authenticator class " + authenticatorClassName
                    + " does not extend the PluggableAuthenticator class.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        }
    }
File Line
org/itracker/model/util/UserUtilities.java 383
org/itracker/persistence/dao/UserDAOImpl.java 136
                new HashMap<Integer, Set<PermissionType>>();

        for (int i = 0; i < permissionsList.size(); i++) {
            Permission permission = permissionsList.get(i);

            // Super user has access to all projects, which is indicated by the "null" project. 
            final Integer projectId = (permission.getProject() == null)
                    ? null : permission.getProject().getId();

            Set<PermissionType> projectPermissions = permissionsByProjectId.get(projectId);

            if (projectPermissions == null) {
                // First permission for the project. 
                projectPermissions = new HashSet<PermissionType>();
                permissionsByProjectId.put(projectId, projectPermissions);
            } //else { // Add the permission to the existing set of permissions for the project. }

            PermissionType permissionType = PermissionType.fromCode(permission.getPermissionType());
            projectPermissions.add(permissionType);
        }
File Line
org/itracker/services/implementations/UserServiceImpl.java 747
org/itracker/services/implementations/UserServiceImpl.java 919
                return authenticator.checkLogin(login, authentication, authType,
                        (reqSource == 0 ? AuthenticationConstants.REQ_SOURCE_UNKNOWN : reqSource));
            }

            logger.error("Unable to create new authenticator.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (IllegalAccessException iae) {
            logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (InstantiationException ie) {
            logger.error("Authenticator class " + authenticatorClassName + " can not be instantiated.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        } catch (ClassCastException cce) {
            logger.error("Authenticator class " + authenticatorClassName
                    + " does not extend the PluggableAuthenticator class.");
            throw new AuthenticatorException(AuthenticatorException.SYSTEM_ERROR);
        }
    }
File Line
org/itracker/web/actions/admin/configuration/RemoveConfigurationItemAction.java 80
org/itracker/web/actions/admin/configuration/RemoveConfigurationItemAction.java 124
                    List<Configuration> configItems = configurationService.getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_SEVERITY);
                    for (int i = 0; i < configItems.size(); i++) {
                        if (configItems.get(i) != null && configId.equals(configItems.get(i).getId())) {
                            if (i == 0 && (i + 1) < configItems.size()) {
                                newConfigValue = configItems.get(i + 1).getValue();
                                break;
                            } else if (i > 0) {
                                newConfigValue = configItems.get(i - 1).getValue();
                                break;
                            }
                        }
                    }

                    int currSeverity = Integer.parseInt(currConfigValue);
File Line
org/itracker/web/taglib/FormatCustomFieldTag.java 145
org/itracker/web/taglib/FormatCustomFieldTag.java 260
                    final List<CustomFieldValue> options = field.getOptions();

                    buf.append("<select name=\"customFields(").append(
                            field.getId()).append(
                            ")\" class=\"editColumnText\">\n");
                    for (int i = 0; i < options.size(); i++) {
                        buf.append("<option value=\"").append(
                                HTMLUtilities.escapeTags(options.get(i)
                                        .getValue())).append("\"");
                        if (currentValue != null
                                && currentValue.equals(options.get(i)
                                .getValue())) {
                            buf.append(" selected=\"selected\"");
                        }
                        buf.append(" class=\"editColumnText\">");
                        buf.append(CustomFieldUtilities
File Line
org/itracker/services/implementations/NotificationServiceImpl.java 318
org/itracker/services/implementations/NotificationServiceImpl.java 647
                                                            .getSeverity()),
                                            (issue.getOwner().getFirstName() != null ? issue
                                                    .getOwner().getFirstName()
                                                    : "")
                                                    + " "
                                                    + (issue.getOwner()
                                                    .getLastName() != null ? issue
                                                    .getOwner()
                                                    .getLastName()
                                                    : ""),
                                            componentString,
                                            (history == null ? "" : history
                                                    .getUser().getFirstName()
                                                    + " "
                                                    + history.getUser()
                                                    .getLastName()),
                                            (history == null ? ""
                                                    : HTMLUtilities
                                                    .removeMarkup(history
                                                            .getDescription())),
File Line
org/itracker/web/actions/admin/project/EditComponentFormAction.java 45
org/itracker/web/actions/admin/project/EditVersionFormAction.java 44
    private static final Logger log = Logger.getLogger(EditComponentFormAction.class);


    @SuppressWarnings("unchecked")
    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
            throws ServletException, IOException {
        ActionMessages errors = new ActionMessages();

        String pageTitleKey = "";
        String pageTitleArg = "";


        try {
            ProjectService projectService = ServletContextUtils.getItrackerServices().getProjectService();

            HttpSession session = request.getSession(true);
            String action = request.getParameter("action");
            Map<Integer, Set<PermissionType>> userPermissions = (Map<Integer, Set<PermissionType>>) session.getAttribute(Constants.PERMISSIONS_KEY);
File Line
org/itracker/web/forms/ComponentForm.java 48
org/itracker/web/forms/VersionForm.java 48
        name = null;
        description = null;
        status = 0;
    }

    public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {
        ActionErrors errors = super.validate(mapping, request);

        return errors;
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
File Line
org/itracker/web/actions/admin/configuration/RemoveCustomFieldAction.java 42
org/itracker/web/actions/admin/configuration/RemoveCustomFieldValueAction.java 45
    private static final Logger log = Logger.getLogger(RemoveCustomFieldAction.class);


    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ActionMessages errors = new ActionMessages();


        if (!LoginUtilities.hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) {
            return mapping.findForward("unauthorized");
        }

        try {
            ConfigurationService configurationService = ServletContextUtils.getItrackerServices().getConfigurationService();

            Integer valueId = (Integer) PropertyUtils.getSimpleProperty(form, "id");
            if (valueId == null || valueId.intValue() <= 0) {
                throw new SystemConfigurationException("Invalid custom field id.");

R.Ø.S.A.