CPD Results

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

Duplications

File Line
org/itracker/web/forms/AdminActionForm.java 33
org/itracker/web/forms/ImportForm.java 33
public class ImportForm 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/services/implementations/NotificationServiceImpl.java 387
org/itracker/services/implementations/NotificationServiceImpl.java 721
										currentLocale,
										new Object[] {
												new StringBuffer(url).append("/module-projects/view_issue.do?id=").append(issue.getId()).toString(),
												issue.getProject().getName(),
												issue.getDescription(),
												IssueUtilities.getStatusName(issue
														.getStatus()),
												resolution,
												IssueUtilities
														.getSeverityName(issue
																.getSeverity()),
												(null != issue.getOwner() && null != issue.getOwner().getFirstName() ? issue
														.getOwner().getFirstName()
														: "")
														+ " "
														+ (null != issue.getOwner() && null != issue.getOwner()
																.getLastName() ? issue
																.getOwner()
																.getLastName()
																: ""),
												componentString,
												(history == null ? "" : history
														.getUser().getFirstName()
														+ " "
														+ history.getUser()
																.getLastName()),
												(history == null ? ""
														: HTMLUtilities
																.removeMarkup(history
																		.getDescription())),
												activityString });
					}

File Line
org/itracker/services/implementations/NotificationServiceImpl.java 244
org/itracker/services/implementations/NotificationServiceImpl.java 558
		List<IssueActivity> activity = getIssueService().getIssueActivity(
				issue.getId(), false);
		issue.getActivities();
		List<IssueHistory> histories = issue.getHistory();
		Iterator<IssueHistory> it = histories.iterator();
		IssueHistory history = null, currentHistory;
		history = getIssueService().getLastIssueHistory(issue.getId());

		Integer historyId = 0;
		// find history with greatest id
		while (it.hasNext()) {
			currentHistory = (IssueHistory) it.next();
			if (logger.isDebugEnabled()) {
				logger.debug("handleIssueNotification: found history: "
						+ currentHistory.getDescription() + " (time: "
						+ currentHistory.getCreateDate());
			}
			if (currentHistory.getId() > historyId) {
				historyId = currentHistory.getId();
				history = currentHistory;
			}
		}
		if (logger.isDebugEnabled() && null != history) {
			logger
					.debug("handleIssueNotification: got most recent history: "
							+ history
							+ " ("
							+ history.getDescription()
							+ ")");
		}

File Line
org/itracker/web/actions/admin/report/DownloadReportAction.java 43
org/itracker/web/actions/admin/report/ExportReportAction.java 44
    public ExportReportAction () {
    }

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

        if(! 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 = getITrackerServices().getReportService();

                Report report = reportService.getReportDAO().findByPrimaryKey(reportId);
                if(report != null) {
                    //report.setFileData(reportService.getReportFile(reportId));
                    response.setContentType("application/x-itracker-report-export");
                    response.setHeader("Content-Disposition", "attachment; filename=\"ITracker_report_" + report.getId() + ".itr\"");

File Line
org/itracker/web/actions/admin/user/EditUserFormAction.java 166
org/itracker/web/actions/admin/user/EditUserFormAction.java 185
                            } else {

                                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);

                            }

                        }

File Line
org/itracker/services/implementations/NotificationServiceImpl.java 341
org/itracker/services/implementations/NotificationServiceImpl.java 674
										currentLocale,
										new Object[] {
												url
														+ "/module-projects/view_issue.do?id="
														+ issue.getId(),
												issue.getProject().getName(),
												issue.getDescription(),
												IssueUtilities.getStatusName(issue
														.getStatus()),
												IssueUtilities
														.getSeverityName(issue
																.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/configuration/EditConfigurationFormAction.java 109
org/itracker/web/actions/admin/configuration/EditCustomFieldActionUtil.java 72
		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();
//			System.out.println(language);
//			System.out.println(locales);
			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 41
org/itracker/web/actions/project/ListProjectsAction.java 80
		List<Project> projects = projectService.getAllAvailableProjects();

		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/services/implementations/NotificationServiceImpl.java 323
org/itracker/services/implementations/NotificationServiceImpl.java 653
										.getActivityType(), currentLocale)).append(": ").append(
								activity.get(i).getDescription()).append("\n");
	
					}
					
					activityString = sb.toString();
					// TODO localize..
					for (int i = 0; i < components.size(); i++) {
						componentString += (i != 0 ? ", " : "")
								+ components.get(i).getName();
					}
					for (int i = 0; i < versions.size(); i++) {
						versionString += (i != 0 ? ", " : "")
								+ versions.get(i).getNumber();
					}
	
					String msgText = "";
					if (type == Type.ISSUE_REMINDER) {
						msgText = ITrackerResources
								.getString(
										"itracker.email.issue.body.reminder",

File Line
org/itracker/web/actions/admin/project/EditProjectScriptAction.java 123
org/itracker/web/actions/admin/workflow/EditWorkflowScriptAction.java 108
            return new ActionForward(mapping.findForward("listworkflow").getPath() + "?id=" + workflowScript.getId() +"&action=update");
        } catch(ParseException pe) {
            log.debug("Error parseing script.  Redisplaying form for correction.", pe);
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.invalidscriptdata", pe.getMessage()));
            saveErrors(request, errors);
            saveToken(request);
            return mapping.getInputForward();
        } catch(Exception e) {
            log.error("Exception processing form data", e);
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system"));
        }

        if(! errors.isEmpty()) {
        	saveErrors(request, errors);
        }
        return mapping.findForward("error");
    }

}

File Line
org/itracker/services/implementations/UserServiceImpl.java 869
org/itracker/services/implementations/UserServiceImpl.java 953
                return authenticator.allowPermissionUpdates(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 allowPreferenceUpdates(User user, Object authentication, int authType, int reqSource)

File Line
org/itracker/services/implementations/UserServiceImpl.java 869
org/itracker/services/implementations/UserServiceImpl.java 981
                return authenticator.allowPreferenceUpdates(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/services/implementations/UserServiceImpl.java 809
org/itracker/services/implementations/UserServiceImpl.java 897
                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/persistence/dao/UserDAOImpl.java 145
org/itracker/services/util/UserUtilities.java 361
                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 809
org/itracker/services/implementations/UserServiceImpl.java 981
                return authenticator.allowPreferenceUpdates(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/web/actions/admin/configuration/RemoveConfigurationItemAction.java 85
org/itracker/web/actions/admin/configuration/RemoveConfigurationItemAction.java 129
                    List<Configuration> configItems = configurationService.getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_STATUS);
                    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 currStatus = Integer.parseInt(currConfigValue);

File Line
org/itracker/web/actions/admin/project/EditComponentFormAction.java 48
org/itracker/web/actions/admin/project/EditVersionFormAction.java 50
	private static final Logger log = Logger.getLogger(EditVersionFormAction.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 = getITrackerServices().getProjectService();

			HttpSession session = request.getSession(true);
			String action = (String) 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 49
org/itracker/web/forms/VersionForm.java 49
		number = 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 getNumber() {


R.Ø.S.A.