You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(217) |
Nov
(180) |
Dec
(71) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(58) |
Feb
(370) |
Mar
(105) |
Apr
(165) |
May
(93) |
Jun
(37) |
Jul
|
Aug
(21) |
Sep
(131) |
Oct
(40) |
Nov
(113) |
Dec
(401) |
| 2007 |
Jan
(180) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
| 2008 |
Jan
(163) |
Feb
(78) |
Mar
|
Apr
(4) |
May
(28) |
Jun
(2) |
Jul
|
Aug
|
Sep
(96) |
Oct
(189) |
Nov
(413) |
Dec
(121) |
| 2009 |
Jan
(34) |
Feb
(18) |
Mar
(24) |
Apr
(16) |
May
(3) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(13) |
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(3) |
Oct
(16) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
(35) |
Jun
|
Jul
(17) |
Aug
(7) |
Sep
|
Oct
(9) |
Nov
|
Dec
|
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:37
|
Update of /cvsroot/itracker/itracker/web/WEB-INF/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/web/WEB-INF/config Modified Files: Tag: itrackerhibernate struts-config.xml Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. Index: struts-config.xml =================================================================== RCS file: /cvsroot/itracker/itracker/web/WEB-INF/config/Attic/struts-config.xml,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** struts-config.xml 25 Nov 2005 20:27:41 -0000 1.1.2.4 --- struts-config.xml 27 Nov 2005 22:01:18 -0000 1.1.2.5 *************** *** 234,240 **** <action-mappings> <action path="/adminlistprojects" forward="/themes/standardtheme/admin/list_projects.jsp"/> ! <action path="/assignissue" type="cowsultants.itracker.web.actions.AssignIssueAction" name="assignIssueForm" scope="request" input="/index.jsp"/> ! <action path="/addissuerelation" type="cowsultants.itracker.web.actions.AddIssueRelationAction" name="issueRelationForm" scope="request" validate="false"> <forward name="index" path="/index.jsp" redirect="true"/> --- 234,240 ---- <action-mappings> <action path="/adminlistprojects" forward="/themes/standardtheme/admin/list_projects.jsp"/> ! <action path="/assignissue" type="cowsultants.itracker.web.actions.project.AssignIssueAction" name="assignIssueForm" scope="request" input="/index.jsp"/> ! <action path="/addissuerelation" type="cowsultants.itracker.web.actions.project.AddIssueRelationAction" name="issueRelationForm" scope="request" validate="false"> <forward name="index" path="/index.jsp" redirect="true"/> *************** *** 242,276 **** <forward name="viewissue" path="/themes/standardtheme//view_issue.jsp" redirect="true"/> </action> ! <action path="/createissue" type="cowsultants.itracker.web.actions.CreateIssueAction" name="issueForm" scope="request" input="/themes/standardtheme/create_issue.jsp"> <forward name="listissues" path="/themes/standardtheme/list_issues.jsp" redirect="true"/> </action> ! <action path="/createissueform" type="cowsultants.itracker.web.actions.CreateIssueFormAction" name="issueForm" scope="request" input="/themes/standardtheme/create_issue.jsp" validate="false"/> ! <action path="/displayreport" type="cowsultants.itracker.web.actions.DisplayReportAction" name="displayReportForm" scope="request" input="/themes/standardtheme/search_issues.jsp"> <forward name="imagesurl" path="/servlets/ReportChartController"/> </action> ! <action path="/editissue" type="cowsultants.itracker.web.actions.EditIssueAction" name="issueForm" scope="request" input="/themes/standardtheme/edit_issue.jsp"> <forward name="index" path="/index.jsp" redirect="true"/> <forward name="listissues" path="/themes/standardtheme/list_issues.jsp" redirect="true"/> </action> ! <action path="/editissueform" type="cowsultants.itracker.web.actions.EditIssueFormAction" name="issueForm" scope="request" input="/themes/standardtheme/edit_issue.jsp" validate="false"/> ! <action path="/editpreferences" type="cowsultants.itracker.web.actions.EditPreferencesAction" name="preferencesForm" scope="request" input="/themes/standardtheme/edit_preferences.jsp"/> ! <action path="/editpreferencesform" type="cowsultants.itracker.web.actions.EditPreferencesFormAction" name="preferencesForm" scope="request" input="/themes/standardtheme/edit_preferences.jsp" validate="false"/> ! <action path="/forgotpassword" type="cowsultants.itracker.web.actions.ForgotPasswordAction" name="forgotPasswordForm" scope="request" input="/themes/standardtheme/forgot_password.jsp"/> ! <action path="/login" type="cowsultants.itracker.web.actions.LoginAction" name="loginForm" scope="request" input="/themes/standardtheme/login.jsp"> <forward name="index" path="/index.jsp" redirect="true"/> </action> ! <action path="/loginauto" type="cowsultants.itracker.web.actions.LoginAction" name="loginForm" scope="request" input="/themes/standardtheme/login.jsp" validate="false"/> ! <action path="/logoff" type="cowsultants.itracker.web.actions.LogoffAction"/> ! <action path="/moveissue" type="cowsultants.itracker.web.actions.MoveIssueAction" name="moveIssueForm" scope="request" input="/themes/standardtheme/move_issue.jsp"> <forward name="index" path="/index.jsp" redirect="true"/> --- 242,276 ---- <forward name="viewissue" path="/themes/standardtheme//view_issue.jsp" redirect="true"/> </action> ! <action path="/createissue" type="cowsultants.itracker.web.actions.project.CreateIssueAction" name="issueForm" scope="request" input="/themes/standardtheme/create_issue.jsp"> <forward name="listissues" path="/themes/standardtheme/list_issues.jsp" redirect="true"/> </action> ! <action path="/createissueform" type="cowsultants.itracker.web.actions.project.CreateIssueFormAction" name="issueForm" scope="request" input="/themes/standardtheme/create_issue.jsp" validate="false"/> ! <action path="/displayreport" type="cowsultants.itracker.web.actions.report.DisplayReportAction" name="displayReportForm" scope="request" input="/themes/standardtheme/search_issues.jsp"> <forward name="imagesurl" path="/servlets/ReportChartController"/> </action> ! <action path="/editissue" type="cowsultants.itracker.web.actions.project.EditIssueAction" name="issueForm" scope="request" input="/themes/standardtheme/edit_issue.jsp"> <forward name="index" path="/index.jsp" redirect="true"/> <forward name="listissues" path="/themes/standardtheme/list_issues.jsp" redirect="true"/> </action> ! <action path="/editissueform" type="cowsultants.itracker.web.actions.project.EditIssueFormAction" name="issueForm" scope="request" input="/themes/standardtheme/edit_issue.jsp" validate="false"/> ! <action path="/editpreferences" type="cowsultants.itracker.web.actions.preferences.EditPreferencesAction" name="preferencesForm" scope="request" input="/themes/standardtheme/edit_preferences.jsp"/> ! <action path="/editpreferencesform" type="cowsultants.itracker.web.actions.preferences.EditPreferencesFormAction" name="preferencesForm" scope="request" input="/themes/standardtheme/edit_preferences.jsp" validate="false"/> ! <action path="/forgotpassword" type="cowsultants.itracker.web.actions.user.ForgotPasswordAction" name="forgotPasswordForm" scope="request" input="/themes/standardtheme/forgot_password.jsp"/> ! <action path="/login" type="cowsultants.itracker.web.actions.user.LoginAction" name="loginForm" scope="request" input="/themes/standardtheme/login.jsp"> <forward name="index" path="/index.jsp" redirect="true"/> </action> ! <action path="/loginauto" type="cowsultants.itracker.web.actions.user.LoginAction" name="loginForm" scope="request" input="/themes/standardtheme/login.jsp" validate="false"/> ! <action path="/logoff" type="cowsultants.itracker.web.actions.user.LogoffAction"/> ! <action path="/moveissue" type="cowsultants.itracker.web.actions.project.MoveIssueAction" name="moveIssueForm" scope="request" input="/themes/standardtheme/move_issue.jsp"> <forward name="index" path="/index.jsp" redirect="true"/> *************** *** 278,383 **** <forward name="viewissue" path="/themes/standardtheme/view_issue.jsp" redirect="true"/> </action> ! <action path="/moveissueform" type="cowsultants.itracker.web.actions.MoveIssueFormAction" name="moveIssueForm" scope="request" input="/themes/standardtheme/move_issue.jsp" validate="false"/> ! <action path="/searchissues" type="cowsultants.itracker.web.actions.SearchIssuesAction" name="searchForm" scope="request" input="/themes/standardtheme/search_issues.jsp"/> ! <action path="/searchissuesform" type="cowsultants.itracker.web.actions.SearchIssuesFormAction" name="searchForm" scope="request" input="/themes/standardtheme/search_issues.jsp"/> ! <action path="/selfregister" type="cowsultants.itracker.web.actions.SelfRegisterAction" name="selfRegistrationForm" scope="request" input="/themes/standardtheme/self_register.jsp"/> ! <action path="/selfregisterform" type="cowsultants.itracker.web.actions.SelfRegisterFormAction" name="preferencesForm" scope="request" input="/themes/standardtheme/self_register.jsp" validate="false"/> ! <action path="/watchissue" type="cowsultants.itracker.web.actions.WatchIssueAction" name="watchIssueForm" scope="request" input="/index.jsp" validate="false"/> ! <action path="/createlanguagekey" type="cowsultants.itracker.web.actions.CreateLanguageKeyAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/create_language_key.jsp"/> ! <action path="/createlanguagekeyform" type="cowsultants.itracker.web.actions.CreateLanguageKeyFormAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/create_language_key.jsp"/> ! <action path="/editcomponent" type="cowsultants.itracker.web.actions.EditComponentAction" name="componentForm" scope="request" input="/themes/standardtheme/admin/edit_component.jsp"/> ! <action path="/editcomponentform" type="cowsultants.itracker.web.actions.EditComponentFormAction" name="componentForm" scope="request" input="/themes/standardtheme/admin/edit_component.jsp" validate="false"/> ! <action path="/editconfiguration" type="cowsultants.itracker.web.actions.EditConfigurationAction" name="configurationForm" scope="request" input="/themes/standardtheme/admin/edit_configuration.jsp"/> ! <action path="/editconfigurationform" type="cowsultants.itracker.web.actions.EditConfigurationFormAction" name="configurationForm" scope="request" input="/themes/standardtheme/admin/edit_configuration.jsp" validate="false"/> ! <action path="/editcustomfield" type="cowsultants.itracker.web.actions.EditCustomFieldAction" name="customFieldForm" scope="request" input="/themes/standardtheme/admin/edit_customfield.jsp"/> ! <action path="/editcustomfieldform" type="cowsultants.itracker.web.actions.EditCustomFieldFormAction" name="customFieldForm" scope="request" input="/themes/standardtheme/admin/edit_customfield.jsp" validate="false"/> ! <action path="/editcustomfieldvalue" type="cowsultants.itracker.web.actions.EditCustomFieldValueAction" name="customFieldForm" scope="request" input="/themes/standardtheme/admin/edit_customfieldvalue.jsp"/> ! <action path="/editcustomfieldvalueform" type="cowsultants.itracker.web.actions.EditCustomFieldValueFormAction" name="customFieldForm" scope="request" input="/themes/standardtheme/admin/edit_customfieldvalue.jsp" validate="false"/> ! <action path="/editlanguage" type="cowsultants.itracker.web.actions.EditLanguageAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/edit_language.jsp"/> ! <action path="/editlanguageform" type="cowsultants.itracker.web.actions.EditLanguageFormAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/edit_language.jsp" validate="false"/> ! <action path="/editproject" type="cowsultants.itracker.web.actions.EditProjectAction" name="projectForm" scope="request" input="/themes/standardtheme/admin/edit_project.jsp"/> ! <action path="/editprojectform" type="cowsultants.itracker.web.actions.EditProjectFormAction" name="projectForm" scope="request" input="/themes/standardtheme/admin/edit_project.jsp"/> ! <action path="/editreport" type="cowsultants.itracker.web.actions.EditReportAction" name="reportForm" scope="request" input="/themes/standardtheme/admin/edit_report.jsp"/> ! <action path="/editreportform" type="cowsultants.itracker.web.actions.EditReportFormAction" name="reportForm" scope="request" input="/themes/standardtheme/admin/edit_report.jsp" validate="false"/> ! <action path="/edittask" type="cowsultants.itracker.web.actions.EditTaskAction" name="taskForm" scope="request" input="/themes/standardtheme/admin/edit_task.jsp"/> ! <action path="/edittaskform" type="cowsultants.itracker.web.actions.EditTaskFormAction" name="taskForm" scope="request" input="/themes/standardtheme/admin/edit_task.jsp"/> ! <action path="/edituser" type="cowsultants.itracker.web.actions.EditUserAction" name="userForm" scope="request" input="/themes/standardtheme/admin/edit_user.jsp"/> ! <action path="/edituserform" type="cowsultants.itracker.web.actions.EditUserFormAction" name="userForm" scope="request" input="/themes/standardtheme/admin/edit_user.jsp" validate="false"/> ! <action path="/editversion" type="cowsultants.itracker.web.actions.EditVersionAction" name="versionForm" scope="request" input="/themes/standardtheme/admin/edit_version.jsp"/> ! <action path="/editversionform" type="cowsultants.itracker.web.actions.EditVersionFormAction" name="versionForm" scope="request" input="/themes/standardtheme/admin/edit_version.jsp"/> ! <action path="/editworkflowscript" type="cowsultants.itracker.web.actions.EditWorkflowScriptAction" name="workflowScriptForm" scope="request" input="/themes/standardtheme/admin/edit_workflowscript.jsp"/> ! <action path="/editworkflowscriptform" type="cowsultants.itracker.web.actions.EditWorkflowScriptFormAction" name="workflowScriptForm" scope="request" input="/themes/standardtheme/admin/edit_workflowscript.jsp" validate="false"/> ! <action path="/removeworkflowscript" type="cowsultants.itracker.web.actions.RemoveWorkflowScriptAction" name="workflowScriptForm" scope="request" validate="false"/> ! <action path="/exportattachments" type="cowsultants.itracker.web.actions.ExportAttachmentsAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_attachments.jsp"/> ! <action path="/exportlanguage" type="cowsultants.itracker.web.actions.ExportLanguageAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/list_languages.jsp"/> ! <action path="/exportreport" type="cowsultants.itracker.web.actions.ExportReportAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_reports.jsp"/> ! <action path="/initializelanguages" type="cowsultants.itracker.web.actions.InitializeLanguagesAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/index.jsp"/> ! <action path="/lockuser" type="cowsultants.itracker.web.actions.LockUserAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_users.jsp"/> ! <action path="/orderconfiguration" type="cowsultants.itracker.web.actions.OrderConfigurationItemAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_configuration.jsp"/> ! <action path="/ordercustomfieldvalue" type="cowsultants.itracker.web.actions.OrderCustomFieldValueAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/edit_customfield.jsp"/> ! <action path="/removeattachment" type="cowsultants.itracker.web.actions.RemoveIssueAttachmentAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_attachments.jsp"/> ! <action path="/removeconfiguration" type="cowsultants.itracker.web.actions.RemoveConfigurationItemAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_configuration.jsp"/> ! <action path="/removecustomfield" type="cowsultants.itracker.web.actions.RemoveCustomFieldAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_configuration.jsp"/> ! <action path="/removecustomfieldvalue" type="cowsultants.itracker.web.actions.RemoveCustomFieldValueAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/edit_customfield.jsp"/> ! <action path="/removehistory" type="cowsultants.itracker.web.actions.RemoveHistoryEntryAction" name="removeHistoryForm" scope="request" input="/themes/standardtheme/edit_issue.jsp"/> ! <action path="/removerelation" type="cowsultants.itracker.web.actions.RemoveIssueRelationAction" ! name="removeRelationForm" scope="request" input="/themes/standardtheme/edit_issue.jsp"/> ! <action path="/removereport" type="cowsultants.itracker.web.actions.RemoveReportAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_reports.jsp"/> ! <action path="/removetask" type="cowsultants.itracker.web.actions.RemoveTaskAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_tasks.jsp"/> ! <action path="/unlockuser" type="cowsultants.itracker.web.actions.UnlockUserAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_users.jsp"/> ! <action path="/importdata" type="cowsultants.itracker.web.actions.ImportDataFormAction" name="importForm" scope="request" input="/themes/standardtheme/admin/import_data.jsp" validate="false"> </action> ! <action path="/importdataverify" type="cowsultants.itracker.web.actions.ImportDataVerifyAction" name="importForm" scope="request" input="/themes/standardtheme/admin/import_data.jsp" validate="true"> <forward name="importdataverify" path="/themes/standardtheme/admin/import_data_verify.jsp"/> </action> ! <action path="/importdataprocess" type="cowsultants.itracker.web.actions.ImportDataProcessAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/import_data_verify.jsp" validate="false"/> <action path="/listprojectsaction" forward="/themes/standardtheme/list_projects.jsp"/> --- 278,381 ---- <forward name="viewissue" path="/themes/standardtheme/view_issue.jsp" redirect="true"/> </action> ! <action path="/moveissueform" type="cowsultants.itracker.web.actions.project.MoveIssueFormAction" name="moveIssueForm" scope="request" input="/themes/standardtheme/move_issue.jsp" validate="false"/> ! <action path="/searchissues" type="cowsultants.itracker.web.actions.issuesearch.SearchIssuesAction" name="searchForm" scope="request" input="/themes/standardtheme/search_issues.jsp"/> ! <action path="/searchissuesform" type="cowsultants.itracker.web.actions.issuesearch.SearchIssuesFormAction" name="searchForm" scope="request" input="/themes/standardtheme/search_issues.jsp"/> ! <action path="/selfregister" type="cowsultants.itracker.web.actions.user.SelfRegisterAction" name="selfRegistrationForm" scope="request" input="/themes/standardtheme/self_register.jsp"/> ! <action path="/selfregisterform" type="cowsultants.itracker.web.actions.user.SelfRegisterFormAction" name="preferencesForm" scope="request" input="/themes/standardtheme/self_register.jsp" validate="false"/> ! <action path="/watchissue" type="cowsultants.itracker.web.actions.project.WatchIssueAction" name="watchIssueForm" scope="request" input="/index.jsp" validate="false"/> ! <action path="/createlanguagekey" type="cowsultants.itracker.web.actions.admin.language.CreateLanguageKeyAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/create_language_key.jsp"/> ! <action path="/createlanguagekeyform" type="cowsultants.itracker.web.actions.admin.language.CreateLanguageKeyFormAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/create_language_key.jsp"/> ! <action path="/editcomponent" type="cowsultants.itracker.web.actions.admin.project.EditComponentAction" name="componentForm" scope="request" input="/themes/standardtheme/admin/edit_component.jsp"/> ! <action path="/editcomponentform" type="cowsultants.itracker.web.actions.admin.project.EditComponentFormAction" name="componentForm" scope="request" input="/themes/standardtheme/admin/edit_component.jsp" validate="false"/> ! <action path="/editconfiguration" type="cowsultants.itracker.web.actions.admin.configuration.EditConfigurationAction" name="configurationForm" scope="request" input="/themes/standardtheme/admin/edit_configuration.jsp"/> ! <action path="/editconfigurationform" type="cowsultants.itracker.web.actions.admin.configuration.EditConfigurationFormAction" name="configurationForm" scope="request" input="/themes/standardtheme/admin/edit_configuration.jsp" validate="false"/> ! <action path="/editcustomfield" type="cowsultants.itracker.web.actions.admin.configuration.EditCustomFieldAction" name="customFieldForm" scope="request" input="/themes/standardtheme/admin/edit_customfield.jsp"/> ! <action path="/editcustomfieldform" type="cowsultants.itracker.web.actions.admin.configuration.EditCustomFieldFormAction" name="customFieldForm" scope="request" input="/themes/standardtheme/admin/edit_customfield.jsp" validate="false"/> ! <action path="/editcustomfieldvalue" type="cowsultants.itracker.web.actions.notyetsorted.EditCustomFieldValueAction" name="customFieldForm" scope="request" input="/themes/standardtheme/admin/edit_customfieldvalue.jsp"/> ! <action path="/editcustomfieldvalueform" type="cowsultants.itracker.web.actions.notyetsorted.EditCustomFieldValueFormAction" name="customFieldForm" scope="request" input="/themes/standardtheme/admin/edit_customfieldvalue.jsp" validate="false"/> ! <action path="/editlanguage" type="cowsultants.itracker.web.actions.admin.language.EditLanguageAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/edit_language.jsp"/> ! <action path="/editlanguageform" type="cowsultants.itracker.web.actions.admin.language.EditLanguageFormAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/edit_language.jsp" validate="false"/> ! <action path="/editproject" type="cowsultants.itracker.web.actions.admin.project.EditProjectAction" name="projectForm" scope="request" input="/themes/standardtheme/admin/edit_project.jsp"/> ! <action path="/editprojectform" type="cowsultants.itracker.web.actions.admin.project.EditProjectFormAction" name="projectForm" scope="request" input="/themes/standardtheme/admin/edit_project.jsp"/> ! <action path="/editreport" type="cowsultants.itracker.web.actions.admin.report.EditReportAction" name="reportForm" scope="request" input="/themes/standardtheme/admin/edit_report.jsp"/> ! <action path="/editreportform" type="cowsultants.itracker.web.actions.admin.report.EditReportFormAction" name="reportForm" scope="request" input="/themes/standardtheme/admin/edit_report.jsp" validate="false"/> ! <action path="/edittask" type="cowsultants.itracker.web.actions.admin.scheduler.EditTaskAction" name="taskForm" scope="request" input="/themes/standardtheme/admin/edit_task.jsp"/> ! <action path="/edittaskform" type="cowsultants.itracker.web.actions.admin.scheduler.EditTaskFormAction" name="taskForm" scope="request" input="/themes/standardtheme/admin/edit_task.jsp"/> ! <action path="/edituser" type="cowsultants.itracker.web.actions.admin.user.EditUserAction" name="userForm" scope="request" input="/themes/standardtheme/admin/edit_user.jsp"/> ! <action path="/edituserform" type="cowsultants.itracker.web.actions.admin.user.EditUserFormAction" name="userForm" scope="request" input="/themes/standardtheme/admin/edit_user.jsp" validate="false"/> ! <action path="/editversion" type="cowsultants.itracker.web.actions.admin.project.EditVersionAction" name="versionForm" scope="request" input="/themes/standardtheme/admin/edit_version.jsp"/> ! <action path="/editversionform" type="cowsultants.itracker.web.actions.admin.project.EditVersionFormAction" name="versionForm" scope="request" input="/themes/standardtheme/admin/edit_version.jsp"/> ! <action path="/editworkflowscript" type="cowsultants.itracker.web.actions.admin.workflow.EditWorkflowScriptAction" name="workflowScriptForm" scope="request" input="/themes/standardtheme/admin/edit_workflowscript.jsp"/> ! <action path="/editworkflowscriptform" type="cowsultants.itracker.web.actions.admin.workflow.EditWorkflowScriptFormAction" name="workflowScriptForm" scope="request" input="/themes/standardtheme/admin/edit_workflowscript.jsp" validate="false"/> ! <action path="/removeworkflowscript" type="cowsultants.itracker.web.actions.admin.workflow.RemoveWorkflowScriptAction" name="workflowScriptForm" scope="request" validate="false"/> ! <action path="/exportattachments" type="cowsultants.itracker.web.actions.admin.attachment.ExportAttachmentsAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_attachments.jsp"/> ! <action path="/exportlanguage" type="cowsultants.itracker.web.actions.admin.language.ExportLanguageAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/list_languages.jsp"/> ! <action path="/exportreport" type="cowsultants.itracker.web.actions.admin.report.ExportReportAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_reports.jsp"/> ! <action path="/initializelanguages" type="cowsultants.itracker.web.actions.admin.language.InitializeLanguagesAction" name="languageForm" scope="request" input="/themes/standardtheme/admin/index.jsp"/> ! <action path="/lockuser" type="cowsultants.itracker.web.actions.admin.user.LockUserAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_users.jsp"/> ! <action path="/orderconfiguration" type="cowsultants.itracker.web.actions.admin.configuration.OrderConfigurationItemAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_configuration.jsp"/> ! <action path="/ordercustomfieldvalue" type="cowsultants.itracker.web.actions.admin.configuration.OrderCustomFieldValueAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/edit_customfield.jsp"/> ! <action path="/removeattachment" type="cowsultants.itracker.web.actions.project.RemoveIssueAttachmentAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_attachments.jsp"/> ! <action path="/removeconfiguration" type="cowsultants.itracker.web.actions.admin.configuration.RemoveConfigurationItemAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_configuration.jsp"/> ! <action path="/removecustomfield" type="cowsultants.itracker.web.actions.admin.configuration.RemoveCustomFieldAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_configuration.jsp"/> ! <action path="/removecustomfieldvalue" type="cowsultants.itracker.web.actions.notyetsorted.RemoveCustomFieldValueAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/edit_customfield.jsp"/> ! <action path="/removehistory" type="cowsultants.itracker.web.actions.project.RemoveHistoryEntryAction" name="removeHistoryForm" scope="request" input="/themes/standardtheme/edit_issue.jsp"/> ! <action path="/removereport" type="cowsultants.itracker.web.actions.admin.report.RemoveReportAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_reports.jsp"/> ! <action path="/removetask" type="cowsultants.itracker.web.actions.admin.scheduler.RemoveTaskAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_tasks.jsp"/> ! <action path="/unlockuser" type="cowsultants.itracker.web.actions.admin.user.UnlockUserAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/list_users.jsp"/> ! <action path="/importdata" type="cowsultants.itracker.web.actions.admin.configuration.ImportDataFormAction" name="importForm" scope="request" input="/themes/standardtheme/admin/import_data.jsp" validate="false"> </action> ! <action path="/importdataverify" type="cowsultants.itracker.web.actions.admin.configuration.ImportDataVerifyAction" name="importForm" scope="request" input="/themes/standardtheme/admin/import_data.jsp" validate="true"> <forward name="importdataverify" path="/themes/standardtheme/admin/import_data_verify.jsp"/> </action> ! <action path="/importdataprocess" type="cowsultants.itracker.web.actions.admin.configuration.ImportDataProcessAction" name="adminActionForm" scope="request" input="/themes/standardtheme/admin/import_data_verify.jsp" validate="false"/> <action path="/listprojectsaction" forward="/themes/standardtheme/list_projects.jsp"/> |
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/report In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/admin/report Added Files: Tag: itrackerhibernate EditReportAction.java EditReportFormAction.java RemoveReportAction.java ExportReportAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: RemoveReportAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.report; import cowsultants.itracker.ejb.beans.session.ReportHandlerBean; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.ReportHandler; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class RemoveReportAction extends ITrackerAction { public RemoveReportAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); if(! UserUtilities.hasPermission(userPermissions, UserUtilities.PERMISSION_USER_ADMIN)) { return mapping.findForward("unauthorized"); } ReportHandler rh = new ReportHandlerBean(); Integer reportId = new Integer((request.getParameter("id") == null ? "-1" : request.getParameter("id"))); if(reportId.intValue() > 0) { rh.removeReport(reportId); return mapping.findForward("listreportsadmin"); } } catch(NumberFormatException nfe) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidreport")); Logger.logDebug("Invalid report id " + request.getParameter("id") + " specified."); } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); Logger.logError("System Error.", e); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditReportAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.report; import cowsultants.itracker.ejb.beans.session.ReportHandlerBean; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.upload.FormFile; import cowsultants.itracker.ejb.client.interfaces.ReportHandler; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.LanguageModel; import cowsultants.itracker.ejb.client.models.ReportModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.ReportUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditReportAction extends ITrackerAction { public EditReportAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing report."); return mapping.findForward("listreports"); } resetToken(request); HttpSession session = request.getSession(true); ReportModel report = null; try { ReportHandler rh = new ReportHandlerBean(); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); if(! UserUtilities.hasPermission(userPermissions, UserUtilities.PERMISSION_USER_ADMIN)) { return mapping.findForward("unauthorized"); } report = (ReportModel) session.getAttribute(Constants.REPORT_KEY); report = new ReportModel(); report.setId((Integer) PropertyUtils.getSimpleProperty(form, "id")); report.setName((String) PropertyUtils.getSimpleProperty(form, "name")); report.setNameKey((String) PropertyUtils.getSimpleProperty(form, "nameKey")); report.setDescription((String) PropertyUtils.getSimpleProperty(form, "description")); report.setDataType(((Integer) PropertyUtils.getSimpleProperty(form, "dataType") != null ? ((Integer) PropertyUtils.getSimpleProperty(form, "dataType")).intValue() : ReportUtilities.DATATYPE_ISSUE)); report.setReportType(((Integer) PropertyUtils.getSimpleProperty(form, "reportType") != null ? ((Integer) PropertyUtils.getSimpleProperty(form, "reportType")).intValue() : ReportUtilities.REPORTTYPE_JFREE)); try { FormFile file = (FormFile) PropertyUtils.getSimpleProperty(form, "fileData"); report.setFileData(file.getFileData()); } catch(Exception e) { Logger.logError("Exception while verifying import data.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.missingdatafile")); } String className = (String) PropertyUtils.getSimpleProperty(form, "className"); if(className == null || className.equals("")) { report.setClassName(""); } else { report.setClassName((String) PropertyUtils.getSimpleProperty(form, "className")); } String action = (String) request.getParameter("action"); if("create".equals(action)) { report = rh.createReport(report); } else if ("update".equals(action)) { report = rh.updateReport(report); } if(report == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.save")); } else if("create".equals(action)) { // If it was a create, add a new language key in the base for it. SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); sc.updateLanguageItem(new LanguageModel(ITrackerResources.BASE_LOCALE, report.getNameKey(), report.getName())); ITrackerResources.clearKeyFromBundles(report.getNameKey(), true); } } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.save")); } if(! errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } session.removeAttribute(Constants.REPORT_KEY); return mapping.findForward("listreportsadmin"); } } --- NEW FILE: EditReportFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.report; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.ReportHandler; import cowsultants.itracker.ejb.client.models.ReportModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditReportFormAction extends ITrackerAction { public EditReportFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { ReportHandler rh = getITrackerServices().getReportHandler(); HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); UserModel user = (UserModel) session.getAttribute(Constants.USER_KEY); if(! UserUtilities.hasPermission(userPermissions, UserUtilities.PERMISSION_USER_ADMIN)) { return mapping.findForward("unauthorized"); } ReportModel report = null; DynaValidatorForm reportForm = (DynaValidatorForm) form; if(reportForm == null) { reportForm = new DynaValidatorForm(); } String action = (String) request.getParameter("action"); if("create".equals(action)) { report = new ReportModel(); report.setId(new Integer(-1)); reportForm.set("action", "create"); reportForm.set("id", report.getId()); } else if ("update".equals(action)) { Integer reportId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); report = rh.getReport(reportId); if(report == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidreport")); } else { reportForm.set("action", "update"); reportForm.set("id", report.getId()); reportForm.set("name", report.getName()); reportForm.set("nameKey", report.getNameKey()); reportForm.set("description", report.getDescription()); reportForm.set("reportType", new Integer(report.getReportType())); reportForm.set("dataType", new Integer(report.getDataType())); reportForm.set("className", report.getClassName()); } } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidaction")); } if(errors.isEmpty()) { request.setAttribute("reportForm", reportForm); session.setAttribute(Constants.REPORT_KEY, report); saveToken(request); return mapping.getInputForward(); } } catch(Exception e) { Logger.logError("Exception while creating edit report form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: ExportReportAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.report; import cowsultants.itracker.ejb.beans.session.ReportHandlerBean; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.ReportHandler; import cowsultants.itracker.ejb.client.models.ReportModel; import cowsultants.itracker.ejb.client.util.Base64; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class ExportReportAction extends ITrackerAction { public ExportReportAction () { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { Integer reportId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); if(reportId == null || reportId.intValue() < 0) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidreport")); } else { ReportHandler rh = new ReportHandlerBean(); ReportModel report = rh.getReport(reportId); if(report != null) { report.setFileData(rh.getReportFile(reportId)); response.setContentType("application/x-itracker-report-export"); response.setHeader("Content-Disposition", "attachment; filename=\"ITracker_report_" + report.getId() + ".itr\""); ServletOutputStream out = response.getOutputStream(); Logger.logDebug("Attempting export for: " + report); out.println("# Exported ITracker report " + report.getName()); out.println("id=" + report.getId()); out.println("name=" + report.getName()); out.println("namekey=" + report.getNameKey()); out.println("dataType=" + report.getDataType()); out.println("reportType=" + report.getReportType()); if(report.getClassName() != null && ! report.getClassName().equals("")) { out.println("className=" + report.getClassName()); } out.println("description=" + Base64.encodeObject(report.getDescription(), Base64.DONT_BREAK_LINES)); out.println("definition=" + Base64.encodeBytes(report.getFileData(), Base64.DONT_BREAK_LINES)); out.flush(); out.close(); return null; } Logger.logDebug("Unknown report " + reportId + " specified for export"); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidreport")); } } catch(Exception e) { Logger.logError("Exception while exporting a report.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } |
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/user Added Files: Tag: itrackerhibernate SelfRegisterAction.java SelfRegisterFormAction.java LogoffAction.java ForgotPasswordAction.java LoginAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: SelfRegisterAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.user; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.exceptions.UserException; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.AuthenticationConstants; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.forms.UserForm; public class SelfRegisterAction extends ITrackerAction { public SelfRegisterAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); Logger.logDebug("Checking transactional control token."); if(! isTokenValid(request)) { return mapping.findForward("login"); } resetToken(request); try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); boolean allowSelfRegister = sc.getBooleanProperty("allow_self_register", false); if(! allowSelfRegister) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.notenabled")); } else { UserForm regForm = (UserForm) form; UserModel user = new UserModel(regForm.getLogin(), UserUtilities.encryptPassword(regForm.getPassword()), regForm.getFirstName(), regForm.getLastName(), regForm.getEmail(), UserUtilities.REGISTRATION_TYPE_SELF, false); if(! user.hasRequiredData()) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.missingfields")); } else { UserHandler uh = getITrackerServices().getUserHandler(); try { if(uh.allowRegistration(user, regForm.getPassword(), AuthenticationConstants.AUTH_TYPE_PASSWORD_PLAIN, AuthenticationConstants.REQ_SOURCE_WEB)) { user = uh.createUser(user); uh.sendNotification(user.getLogin(), user.getEmail(), getBaseURL(request)); } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.register.unauthorized")); } } catch(UserException ue) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.existinglogin")); } } } } catch(Exception e) { Logger.logInfo("Error during self registration. " + e.getMessage()); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.register.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } return mapping.findForward("login"); } } --- NEW FILE: LoginAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.user; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.beans.session.DataException; import cowsultants.itracker.ejb.client.exceptions.AuthenticatorException; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.models.UserPreferencesModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.AuthenticationConstants; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; import cowsultants.itracker.web.util.LoginUtilities; import cowsultants.itracker.web.util.SessionManager; import cowsultants.itracker.web.util.SessionTracker; public class LoginAction extends ITrackerAction { // TODO: this should live in SystemConfiguration private int SESSION_TIMEOUT = 30; public LoginAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); ActionForward errorMapping = null; String login = null; try { UserHandler uh = getITrackerServices().getUserHandler(); try { UserModel user = null; String encPassword = null; int authType = LoginUtilities.getRequestAuthType(request); if (authType == AuthenticationConstants.AUTH_TYPE_PASSWORD_PLAIN) { login = (String) request.getAttribute(Constants.AUTH_LOGIN_KEY); String authenticator = (String) request.getAttribute(Constants.AUTH_VALUE_KEY); if (login == null || login.equals("")) { login = (String) PropertyUtils.getSimpleProperty(form, "login"); } if (authenticator == null || authenticator.equals("")) { authenticator = (String) PropertyUtils.getSimpleProperty(form, "password"); } encPassword = UserUtilities.encryptPassword(authenticator); Logger.logDebug("Attempting login with plaintext password for user " + login); user = uh.checkLogin(login, authenticator, AuthenticationConstants.AUTH_TYPE_PASSWORD_PLAIN, AuthenticationConstants.REQ_SOURCE_WEB); } else if (authType == AuthenticationConstants.AUTH_TYPE_PASSWORD_ENC) { login = (String) request.getAttribute(Constants.AUTH_LOGIN_KEY); String authenticator = (String) request.getAttribute(Constants.AUTH_VALUE_KEY); if (login == null || login.equals("")) { login = (String) PropertyUtils.getSimpleProperty(form, "login"); } if (authenticator == null || authenticator.equals("")) { authenticator = (String) PropertyUtils.getSimpleProperty(form, "encpassword"); } encPassword = authenticator; Logger.logDebug("Attempting login with encrypted password for user " + login); user = uh.checkLogin(login, authenticator, AuthenticationConstants.AUTH_TYPE_PASSWORD_ENC, AuthenticationConstants.REQ_SOURCE_WEB); } else if (authType == AuthenticationConstants.AUTH_TYPE_REQUEST) { Logger.logDebug("Attempting login with request object"); user = uh.checkLogin(login, request, AuthenticationConstants.AUTH_TYPE_REQUEST, AuthenticationConstants.REQ_SOURCE_WEB); } else { Logger.logDebug("Attempting login with with unknown auth type"); user = uh.checkLogin(login, request, AuthenticationConstants.AUTH_TYPE_UNKNOWN, AuthenticationConstants.REQ_SOURCE_WEB); } if (user == null) { throw new AuthenticatorException(AuthenticatorException.UNKNOWN_USER); } login = user.getLogin(); setupSession(user, encPassword, request, response); String redirect = request.getParameter(Constants.AUTH_REDIRECT_KEY); Logger.logDebug("Redirect URL from request param = " + redirect); if (redirect == null || "".equals(redirect)) { redirect = (String) request.getAttribute(Constants.AUTH_REDIRECT_KEY); Logger.logDebug("Redirect URL from request attribute = " + redirect); } int redirectIndex = (redirect == null ? -1 : redirect.indexOf("?" + Constants.AUTH_REDIRECT_KEY + "=")); if (redirectIndex > -1) { int extraParamIndex = redirect.indexOf("&", redirectIndex); int lastParamIndex = redirect.lastIndexOf("&", redirectIndex); if (Logger.isLoggingDebug()) { Logger.logDebug("Original redirect URL = " + redirect); Logger.logDebug("Redirect Index: " + redirectIndex + " ExtraParamIndex: " + extraParamIndex + " LastParamIndex: " + lastParamIndex); } if (extraParamIndex > -1 && lastParamIndex > -1) { redirect = redirect.substring(0, redirectIndex) + "?" + redirect.substring(extraParamIndex + 1, lastParamIndex); } else if (extraParamIndex > -1) { redirect = redirect.substring(0, redirectIndex) + "?" + redirect.substring(extraParamIndex + 1); } else { redirect = redirect.substring(0, redirectIndex); } } SessionManager.createSession(user.getLogin()); Logger.logInfo("User " + (user != null ? user.getLogin() : "UNKNOWN") + " logged in successfully."); if (redirect == null || "".equals(redirect)) { return mapping.findForward("index"); } else { if (Logger.isLoggingDebug()) { Logger.logDebug("Redirecting to " + redirect); } return new ActionForward(redirect, true); } } catch (IllegalStateException ise) { if (Logger.isLoggingDebug()) { Logger.logDebug("IllegalStateException caught during login.", ise); } errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.login.system")); } catch (AuthenticatorException le) { if (Logger.isLoggingDebug()) { Logger.logDebug("Login Exception for user " + (login != null ? login : "UNKNOWN") + ". Type = " + le.getType(), le); } if (le.getType() == AuthenticatorException.INVALID_PASSWORD) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.login.badpass")); } else if (le.getType() == AuthenticatorException.INACTIVE_ACCOUNT) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.login.inactive")); } else if (le.getType() == AuthenticatorException.UNKNOWN_USER) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.login.unknown")); } else if (le.getType() == AuthenticatorException.INVALID_AUTHENTICATION_TYPE) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.login.system")); } else if (le.getType() == AuthenticatorException.CUSTOM_ERROR) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(le.getMessageKey())); } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.login.system")); } if (le.getErrorPageType() == AuthenticatorException.ERRORPAGE_TYPE_FORWARD) { errorMapping = mapping.findForward(le.getErrorPageValue()); } else if (le.getErrorPageType() == AuthenticatorException.ERRORPAGE_TYPE_URL) { errorMapping = new ActionForward(le.getErrorPageValue()); } } Logger.logInfo("User " + (login != null ? login : "UNKNOWN") + " login unsucessful."); } catch (Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.login.system")); Logger.logError("System Error.", e); } if (!errors.isEmpty()) { LogoffAction logoff = new LogoffAction(); logoff.clearSession(login, request, response); saveErrors(request, errors); } return (errorMapping == null ? mapping.findForward("login") : errorMapping); } public UserModel setupSession(String login, HttpServletRequest request, HttpServletResponse response) throws DataException { UserHandler uh = getITrackerServices().getUserHandler(); UserModel user = uh.getUserByLogin(login); if (user != null) { String encPassword = null; Cookie[] cookies = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { if (Constants.COOKIE_NAME.equals(cookies[i].getName())) { int seperator = cookies[i].getValue().indexOf('~'); if (seperator > 0) { encPassword = cookies[i].getValue().substring(seperator + 1); } } } } return setupSession(user, encPassword, request, response); } return null; } public UserModel setupSession(UserModel user, String encPassword, HttpServletRequest request, HttpServletResponse response) throws DataException { if (user == null) { return null; } UserHandler uh = getITrackerServices().getUserHandler(); if (Logger.isLoggingDebug()) { Logger.logDebug("Creating new session"); } HttpSession session = request.getSession(true); if (Logger.isLoggingDebug()) { Logger.logDebug("Setting session timeout to " + getConfiguredSessionTimeout() + " minutes"); } session.setMaxInactiveInterval(getConfiguredSessionTimeout() * 60); if (Logger.isLoggingDebug()) { Logger.logDebug("Setting session tracker"); } session.setAttribute(Constants.SESSION_TRACKER_KEY, new SessionTracker(user.getLogin(), session.getId())); if (Logger.isLoggingDebug()) { Logger.logDebug("Setting user information"); } session.setAttribute(Constants.USER_KEY, user); if (Logger.isLoggingDebug()) { Logger.logDebug("Setting preferences for user " + user.getLogin()); } UserPreferencesModel userPrefs = uh.getUserPreferencesByUserId(user.getId()); session.setAttribute(Constants.PREFERENCES_KEY, userPrefs); if (Logger.isLoggingDebug()) { Logger.logDebug("Setting user locale to " + ITrackerResources.getLocale(userPrefs.getUserLocale())); } session.setAttribute(Constants.LOCALE_KEY, ITrackerResources.getLocale(userPrefs.getUserLocale())); if (Logger.isLoggingDebug()) { Logger.logDebug("Setting autologin cookie for user " + user.getLogin()); } Cookie cookie = new Cookie(Constants.COOKIE_NAME, ""); cookie.setPath(request.getContextPath()); if (userPrefs.getSaveLogin()) { if (encPassword != null) { if (Logger.isLoggingDebug()) { Logger.logDebug("User allows autologin"); } cookie.setComment("ITracker autologin cookie"); cookie.setValue(user.getLogin() + "~" + encPassword); cookie.setMaxAge(30 * 24 * 60 * 60); } } else { if (Logger.isLoggingDebug()) { Logger.logDebug("User does not allow autologin"); } cookie.setValue(""); cookie.setMaxAge(0); } response.addCookie(cookie); if (Logger.isLoggingDebug()) { Logger.logDebug("Setting permissions for user " + user.getLogin()); } HashMap permissions = uh.getUserPermissions(user, AuthenticationConstants.REQ_SOURCE_WEB); session.setAttribute(Constants.PERMISSIONS_KEY, permissions); // Reset some session forms session.setAttribute(Constants.SEARCH_QUERY_KEY, null); SessionManager.clearSessionNeedsReset(user.getLogin()); if (Logger.isLoggingDebug()) { Logger.logDebug("User session data updated."); } return user; } private int getConfiguredSessionTimeout() { return (getITrackerServices().getSystemConfiguration().getIntegerProperty("web_session_timeout", SESSION_TIMEOUT)); } } --- NEW FILE: LogoffAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.user; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.SessionManager; public class LogoffAction extends ITrackerAction { public LogoffAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { HttpSession session = request.getSession(true); UserModel user = (UserModel) session.getAttribute("user"); String login = (user != null ? user.getLogin() : "UNKNOWN"); if(clearSession(login, request, response)) { Logger.logInfo("User " + login + " logged out successfully."); } } catch(Exception e) { Logger.logError("Error logging out user. " + e.getMessage()); } return mapping.findForward("login"); } public boolean clearSession(String login, HttpServletRequest request, HttpServletResponse response) { try { HttpSession session = request.getSession(true); session.invalidate(); if(login != null) { SessionManager.invalidateSession(login); } } catch(Exception e) { Logger.logError("Unable to clear session for user " + (login == null ? "UNKNOWN" : login)); return false; } return true; } } --- NEW FILE: SelfRegisterFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.user; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class SelfRegisterFormAction extends ITrackerAction { public SelfRegisterFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if(isLoggedIn(request, response)) { return mapping.findForward("index"); } saveToken(request); return mapping.getInputForward(); } } --- NEW FILE: ForgotPasswordAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.user; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.exceptions.PasswordException; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.EmailHandler; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class ForgotPasswordAction extends ITrackerAction { public ForgotPasswordAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); UserHandler uh = getITrackerServices().getUserHandler(); if(! sc.getBooleanProperty("allow_forgot_password", true)) { throw new PasswordException(PasswordException.FEATURE_DISABLED); } String login = (String) PropertyUtils.getSimpleProperty(form, "login"); String lastName = (String) PropertyUtils.getSimpleProperty(form, "lastName"); if(login != null && lastName != null && ! login.equals("") && ! lastName.equals("")) { UserModel user = null; try { user = uh.getUserByLogin(login); if(user == null) { throw new PasswordException(PasswordException.UNKNOWN_USER); } if(user.getLastName() == null || ! user.getLastName().equalsIgnoreCase(lastName)) { throw new PasswordException(PasswordException.INVALID_NAME); } if(user.getEmail() == null || user.getEmail().equals("")) { throw new PasswordException(PasswordException.INVALID_EMAIL); } if(user.getStatus() != UserUtilities.STATUS_ACTIVE) { throw new PasswordException(PasswordException.INACTIVE_ACCOUNT); } if(Logger.isLoggingDebug()) { Logger.logDebug("ForgotPasswordHandler found matching user: " + user.getFirstName() + " " + user.getLastName() + "(" + user.getLogin() + ")"); } String subject = ITrackerResources.getString("itracker.email.forgotpass.subject"); StringBuffer msgText = new StringBuffer(); msgText.append(ITrackerResources.getString("itracker.email.forgotpass.body")); msgText.append(ITrackerResources.getString("itracker.web.attr.password") + ": " + uh.generateUserPassword(user)); EmailHandler.sendEmail(user.getEmail(), subject, msgText.toString()); } catch(PasswordException pe) { if(Logger.isLoggingDebug()) { Logger.logDebug("Password Exception for user " + (login != null ? login : "UNKNOWN") + ". Type = " + pe.getType()); } if(pe.getType() == PasswordException.INVALID_NAME) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.forgotpass.lastname")); } else if(pe.getType() == PasswordException.INVALID_EMAIL) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.forgotpass.invalidemail")); } else if(pe.getType() == PasswordException.INACTIVE_ACCOUNT) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.forgotpass.inactive")); } else if(pe.getType() == PasswordException.UNKNOWN_USER) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.forgotpass.unknown")); } } } } catch(PasswordException pe) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.notenabled")); Logger.logError("Forgot Password function has been disabled.", pe); } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.forgotpass.system")); Logger.logError("Error during password retrieval.", e); } if(! errors.isEmpty()) { saveErrors(request, errors); return (mapping.getInputForward()); } errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.message.forgotpass")); saveErrors(request, errors); return mapping.findForward("login"); } } |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:36
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/project In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/admin/project Added Files: Tag: itrackerhibernate EditComponentAction.java EditComponentFormAction.java EditVersionAction.java EditProjectFormAction.java EditProjectAction.java EditVersionFormAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: EditVersionAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.project; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.VersionModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditVersionAction extends ITrackerAction { public EditVersionAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing version."); return mapping.findForward("listprojectsadmin"); } resetToken(request); VersionModel version = null; ProjectModel project = null; try { ProjectHandler ph = getITrackerServices().getProjectHandler(); HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); version = new VersionModel(); version.setId((Integer) PropertyUtils.getSimpleProperty(form, "id")); version.setDescription((String) PropertyUtils.getSimpleProperty(form, "description")); version.setVersionInfo((String) PropertyUtils.getSimpleProperty(form, "number")); Integer projectId = (Integer) PropertyUtils.getSimpleProperty(form, "pid"); if(projectId == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else { project = ph.getProject(projectId); version.setProjectId(projectId); if(project == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(! UserUtilities.hasPermission(userPermissions, project.getId(), UserUtilities.PERMISSION_PRODUCT_ADMIN)) { return mapping.findForward("unauthorized"); } else { String action = (String) request.getParameter("action"); if("create".equals(action)) { version = ph.addProjectVersion(project.getId(), version); } else if ("update".equals(action)) { version.setProjectId(project.getId()); version = ph.updateProjectVersion(version); } session.removeAttribute(Constants.VERSION_KEY); return new ActionForward(mapping.findForward("editproject").getPath() + "?id=" + project.getId() +"&action=update"); } } } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditProjectAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.project; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.PermissionModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.ProjectUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditProjectAction extends ITrackerAction { public EditProjectAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing project."); return mapping.findForward("listprojectsadmin"); } resetToken(request); ProjectModel project = null; try { ProjectHandler ph = getITrackerServices().getProjectHandler(); UserHandler uh = getITrackerServices().getUserHandler(); HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); UserModel user = (UserModel) session.getAttribute(Constants.USER_KEY); project = new ProjectModel(); project.setId((Integer) PropertyUtils.getSimpleProperty(form, "id")); project.setDescription((String) PropertyUtils.getSimpleProperty(form, "description")); project.setName((String) PropertyUtils.getSimpleProperty(form, "name")); Integer projectStatus = (Integer) PropertyUtils.getSimpleProperty(form, "status"); if(projectStatus != null) { project.setStatus(projectStatus.intValue()); } else { project.setStatus(ProjectUtilities.STATUS_ACTIVE); } Integer[] optionValues = (Integer[]) PropertyUtils.getSimpleProperty(form, "options"); int optionmask = 0; if(optionValues != null) { for(int i = 0; i < optionValues.length; i++) { optionmask += optionValues[i].intValue(); } } project.setOptions(optionmask); HashSet fields = new HashSet(); Integer[] fieldIds = (Integer[]) PropertyUtils.getSimpleProperty(form, "fields"); if(fieldIds != null) { for(int i = 0; i < fieldIds.length; i++) { fields.add(fieldIds[i]); } } HashSet owners = new HashSet(); Integer[] ownerIds = (Integer[]) PropertyUtils.getSimpleProperty(form, "owners"); if(ownerIds != null) { for(int i = 0; i < ownerIds.length; i++) { owners.add(ownerIds[i]); } } //TODO: commented this because it was causing authentication problems (rjst) //TODO: why is it needed anyway ? //SessionManager.setAllSessionsNeedsReset(); String action = (String) request.getParameter("action"); if("create".equals(action)) { if(! user.isSuperUser()) { return mapping.findForward("unauthorized"); } project = ph.createProject(project); if(project == null) { throw new Exception("Error creating new project."); } ph.updateProject(project); ph.setProjectOwners(project, owners); ph.setProjectFields(project, fields); Integer[] userIds = (Integer[]) PropertyUtils.getSimpleProperty(form, "users"); Integer[] permissions = (Integer[]) PropertyUtils.getSimpleProperty(form, "permissions"); if(userIds != null && permissions != null && userIds.length > 0 && permissions.length > 0) { PermissionModel[] userPermissionModels = new PermissionModel[permissions.length]; for(int i = 0; i < permissions.length; i++) { userPermissionModels[i] = new PermissionModel(project.getId(), permissions[i].intValue()); } for(int i = 0; i < userIds.length; i++) { uh.addUserPermissions(userIds[i], userPermissionModels); } } } else if ("update".equals(action)) { if(! UserUtilities.hasPermission(userPermissions, project.getId(), UserUtilities.PERMISSION_PRODUCT_ADMIN)) { return mapping.findForward("unauthorized"); } ph.updateProject(project); ph.setProjectOwners(project, owners); ph.setProjectFields(project, fields); } session.removeAttribute(Constants.PROJECT_KEY); return mapping.findForward("listprojectsadmin"); } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditProjectFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.project; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.ProjectUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditProjectFormAction extends ITrackerAction { public EditProjectFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { ProjectHandler ph = getITrackerServices().getProjectHandler(); HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); UserModel user = (UserModel) session.getAttribute(Constants.USER_KEY); ProjectModel project = null; DynaValidatorForm projectForm = (DynaValidatorForm) form; if(projectForm == null) { projectForm = new DynaValidatorForm(); } String action = (String) request.getParameter("action"); if("create".equals(action)) { if(! user.isSuperUser()) { return mapping.findForward("unauthorized"); } project = new ProjectModel(); project.setId(new Integer(-1)); projectForm.set("action", "create"); projectForm.set("id", project.getId()); } else if ("update".equals(action)) { Integer projectId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); if(projectId == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else { project = ph.getProject(projectId); if(project == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(! UserUtilities.hasPermission(userPermissions, project.getId(), UserUtilities.PERMISSION_PRODUCT_ADMIN)) { return mapping.findForward("unauthorized"); } else { projectForm.set("action", "update"); projectForm.set("id", project.getId()); projectForm.set("name", project.getName()); projectForm.set("description", project.getDescription()); projectForm.set("status", new Integer(project.getStatus())); projectForm.set("options", ProjectUtilities.getOptions(project.getOptions())); CustomFieldModel[] fields = project.getCustomFields(); Integer[] fieldIds = new Integer[fields.length]; for(int i = 0; i < fields.length; i++) { fieldIds[i] = fields[i].getId(); } projectForm.set("fields", fieldIds); UserModel[] owners = project.getOwners(); Integer[] ownerIds = new Integer[owners.length]; for(int i = 0; i < owners.length; i++) { ownerIds[i] = owners[i].getId(); } projectForm.set("owners", ownerIds); } } } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidaction")); } if(errors.isEmpty()) { request.setAttribute("projectForm", projectForm); session.setAttribute(Constants.PROJECT_KEY, project); saveToken(request); return mapping.getInputForward(); } } catch(Exception e) { Logger.logError("Exception while creating edit project form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditComponentFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.project; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.models.ComponentModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditComponentFormAction extends ITrackerAction { public EditComponentFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { ProjectHandler ph = getITrackerServices().getProjectHandler(); HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); ProjectModel project = null; ComponentModel component = null; DynaValidatorForm componentForm = (DynaValidatorForm) form; if(componentForm == null) { componentForm = new DynaValidatorForm(); } String action = (String) request.getParameter("action"); if("create".equals(action)) { Integer projectId = (Integer) PropertyUtils.getSimpleProperty(form, "pid"); if(projectId == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else { project = ph.getProject(projectId); if(project == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(! UserUtilities.hasPermission(userPermissions, project.getId(), UserUtilities.PERMISSION_PRODUCT_ADMIN)) { return mapping.findForward("unauthorized"); } else { component = new ComponentModel(); component.setId(new Integer(-1)); component.setProjectId(project.getId()); componentForm.set("action", "create"); componentForm.set("id", component.getId()); componentForm.set("pid", component.getProjectId()); } } } else if ("update".equals(action)) { Integer componentId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); component = ph.getProjectComponent(componentId); if(component == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidcomponent")); } else { project = ph.getProject(component.getProjectId()); if(component == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(! UserUtilities.hasPermission(userPermissions, component.getProjectId(), UserUtilities.PERMISSION_PRODUCT_ADMIN)) { return mapping.findForward("unauthorized"); } else { componentForm.set("action", "update"); componentForm.set("id", component.getId()); componentForm.set("pid", project.getId()); componentForm.set("name", component.getName()); componentForm.set("description", component.getDescription()); } } } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidaction")); } if(errors.isEmpty()) { request.setAttribute("componentForm", componentForm); session.setAttribute(Constants.COMPONENT_KEY, component); saveToken(request); return mapping.getInputForward(); } } catch(Exception e) { Logger.logError("Exception while creating edit component form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditComponentAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.project; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.models.ComponentModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditComponentAction extends ITrackerAction { public EditComponentAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing component."); return mapping.findForward("listprojectsadmin"); } resetToken(request); ComponentModel component = null; ProjectModel project = null; try { ProjectHandler ph = getITrackerServices().getProjectHandler(); HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); component = new ComponentModel(); component.setId((Integer) PropertyUtils.getSimpleProperty(form, "id")); component.setDescription((String) PropertyUtils.getSimpleProperty(form, "description")); component.setName((String) PropertyUtils.getSimpleProperty(form, "name")); Integer projectId = (Integer) PropertyUtils.getSimpleProperty(form, "pid"); if(projectId == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else { project = ph.getProject(projectId); if(project == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(! UserUtilities.hasPermission(userPermissions, project.getId(), UserUtilities.PERMISSION_PRODUCT_ADMIN)) { return mapping.findForward("unauthorized"); } else { String action = (String) request.getParameter("action"); if("create".equals(action)) { component = ph.addProjectComponent(project.getId(), component); } else if ("update".equals(action)) { component.setProjectId(project.getId()); component = ph.updateProjectComponent(component); } session.removeAttribute(Constants.COMPONENT_KEY); return new ActionForward(mapping.findForward("editproject").getPath() + "?id=" + project.getId() + "&action=update"); } } } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditVersionFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.project; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.models.VersionModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditVersionFormAction extends ITrackerAction { public EditVersionFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { ProjectHandler ph = getITrackerServices().getProjectHandler(); HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); UserModel user = (UserModel) session.getAttribute(Constants.USER_KEY); ProjectModel project = null; VersionModel version = null; DynaValidatorForm versionForm = (DynaValidatorForm) form; if(versionForm == null) { versionForm = new DynaValidatorForm(); } String action = (String) request.getParameter("action"); if("create".equals(action)) { Integer projectId = (Integer) PropertyUtils.getSimpleProperty(form, "pid"); if(projectId == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else { project = ph.getProject(projectId); if(project == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(! UserUtilities.hasPermission(userPermissions, project.getId(), UserUtilities.PERMISSION_PRODUCT_ADMIN)) { return mapping.findForward("unauthorized"); } else { version = new VersionModel(); version.setId(new Integer(-1)); version.setProjectId(project.getId()); versionForm.set("action", "create"); versionForm.set("id", version.getId()); versionForm.set("pid", version.getProjectId()); } } } else if ("update".equals(action)) { Integer versionId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); version = ph.getProjectVersion(versionId); if(version == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidversion")); } else { project = ph.getProject(version.getProjectId()); if(version == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(! UserUtilities.hasPermission(userPermissions, version.getProjectId(), UserUtilities.PERMISSION_PRODUCT_ADMIN)) { return mapping.findForward("unauthorized"); } else { versionForm.set("action", "update"); versionForm.set("id", version.getId()); versionForm.set("pid", project.getId()); versionForm.set("number", version.getNumber()); versionForm.set("description", version.getDescription()); } } } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidaction")); } if(errors.isEmpty()) { request.setAttribute("versionForm", versionForm); session.setAttribute(Constants.VERSION_KEY, version); saveToken(request); return mapping.getInputForward(); } } catch(Exception e) { Logger.logError("Exception while creating edit version form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:36
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/report In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/report Added Files: Tag: itrackerhibernate DisplayReportAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: DisplayReportAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.report; import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Locale; import java.util.Vector; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.beans.session.ReportHandlerBean; import cowsultants.itracker.ejb.client.exceptions.ImportExportException; import cowsultants.itracker.ejb.client.exceptions.ReportException; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.interfaces.ReportHandler; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.IssueModel; import cowsultants.itracker.ejb.client.models.IssueSearchQueryModel; import cowsultants.itracker.ejb.client.models.ReportModel; import cowsultants.itracker.ejb.client.models.SystemConfigurationModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.ImportExportTags; import cowsultants.itracker.ejb.client.util.ImportExportUtilities; import cowsultants.itracker.ejb.client.util.IssueUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.ReportUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.reports.DefaultITrackerJFreeReport; import cowsultants.itracker.web.reports.DefaultITrackerJasperReport; import cowsultants.itracker.web.reports.ITrackerReport; import cowsultants.itracker.web.util.Constants; public class DisplayReportAction extends ITrackerAction { public DisplayReportAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { HttpSession session = request.getSession(false); Locale userLocale = (Locale) session.getAttribute(Constants.LOCALE_KEY); IssueSearchQueryModel isqm = (IssueSearchQueryModel) session.getAttribute(Constants.SEARCH_QUERY_KEY); IssueModel[] reportData = new IssueModel[0]; String type = (String) PropertyUtils.getSimpleProperty(form, "type"); Integer[] projectIds = (Integer[]) PropertyUtils.getSimpleProperty(form, "projectIds"); if("all".equalsIgnoreCase(type)) { // Export all of the issues in the system UserModel currUser = (UserModel) session.getAttribute(Constants.USER_KEY); if(! currUser.isSuperUser()) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.unauthorized")); throw new ReportException(); } IssueHandler ih = getITrackerServices().getIssueHandler(); reportData = ih.getAllIssues(); Arrays.sort(reportData, new IssueModel.CompareById()); } else if("project".equalsIgnoreCase(type)) { if(projectIds != null && projectIds.length > 0) { // This wasn't a regular search. So instead, take all the selected projects and find all the // issues for them, check which ones the user can see, and then create a new array of issues Vector reportDataVector = new Vector(); IssueHandler ih = getITrackerServices().getIssueHandler(); UserModel currUser = (UserModel) session.getAttribute(Constants.USER_KEY); HashMap currPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); for(int i = 0; i < projectIds.length; i++) { IssueModel[] issues = ih.getIssuesByProjectId(projectIds[i]); for(int j = 0; j < issues.length; j++) { if(IssueUtilities.canViewIssue(issues[j], currUser, currPermissions)) { reportDataVector.add(issues[j]); } } } reportData = new IssueModel[reportDataVector.size()]; reportDataVector.copyInto(reportData); Arrays.sort(reportData, new IssueModel.CompareById()); } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.projectrequired")); throw new ReportException(); } } else { // This must be a regular search, look for a search query result. reportData = (isqm == null || isqm.getResults() == null ? new IssueModel[0] : isqm.getResults()); } Logger.logDebug("Report data contains " + reportData.length + " elements."); if(reportData.length == 0) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.noreportdata")); throw new ReportException(); } Integer reportId = (Integer) PropertyUtils.getSimpleProperty(form, "reportId"); String reportOutput = (String) PropertyUtils.getSimpleProperty(form, "reportOutput"); if(reportId == null || reportId.intValue() == 0) { Logger.logDebug("Invalid report id: " + reportId + " requested."); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidreport")); throw new ReportException(); } else if(reportId.intValue() == ReportUtilities.REPORT_EXPORT_XML) { Logger.logDebug("Issue export requested."); SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); SystemConfigurationModel config = sc.getSystemConfiguration(ImportExportTags.EXPORT_LOCALE); if(! exportIssues(reportData, config, request, response)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); throw new ReportException(); } return null; } else if(reportId.intValue() > 0) { Logger.logDebug("Defined report (" + reportId + ") requested."); ReportHandler rh = new ReportHandlerBean(); ReportModel reportModel = rh.getReport(reportId); if(reportModel == null) { Logger.logDebug("Invalid report id: " + reportId + " requested."); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidreport")); throw new ReportException(); } reportModel.setFileData(rh.getReportFile(reportModel.getId())); Logger.logDebug("Report " + reportModel.toString() + " found."); ITrackerReport report = null; if(reportModel.getClassName() != null && ! reportModel.getClassName().equals("")) { Logger.logDebug("Creating new class: " + reportModel.getClassName()); Class reportClass = Class.forName(reportModel.getClassName()); report = (ITrackerReport) reportClass.newInstance(); } else if(reportModel.getReportType() == ReportUtilities.REPORTTYPE_JFREE) { report = (ITrackerReport) new DefaultITrackerJFreeReport(); } else if(reportModel.getReportType() == ReportUtilities.REPORTTYPE_JASPER) { report = (ITrackerReport) new DefaultITrackerJasperReport(); } if(report == null) { Logger.logError("Unable to create new instance of report: " + reportModel.getName() + " class: " + reportModel.getClassName() + " type: " + reportModel.getReportType()); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidreport")); throw new ReportException(); } Logger.logDebug("Initializing report object."); report.initializeReport(reportData, reportModel, userLocale, reportOutput, session); Logger.logDebug("Augmenting report object."); report.augmentReport(); if(ReportUtilities.REPORT_OUTPUT_PDF.equals(reportOutput)) { Logger.logDebug("Processing PDF report."); report.outputPDF(request, response, mapping); return null; } else if(ReportUtilities.REPORT_OUTPUT_XLS.equals(reportOutput)) { Logger.logDebug("Processing XLS report."); report.outputXLS(request, response, mapping); return null; } else if(ReportUtilities.REPORT_OUTPUT_CSV.equals(reportOutput)) { Logger.logDebug("Processing CSV report."); report.outputCSV(request, response, mapping); return null; } else if(ReportUtilities.REPORT_OUTPUT_HTML.equals(reportOutput)) { Logger.logDebug("Processing HTML report."); report.outputHTML(request, response, mapping); return null; } else { Logger.logError("Inavlid report output format: " + reportOutput); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidreportoutput")); throw new ReportException(); } } } catch(ReportException re) { if(re.getErrorKey() != null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(re.getErrorKey())); } } catch(Exception e) { Logger.logDebug("Error in report processing: " + e.getMessage(), e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.details", e.getMessage())); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } private boolean exportIssues(IssueModel[] issues, SystemConfigurationModel config, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/xml; charset=UTF-8"); response.setHeader("Content-Disposition", "attachment; filename=\"issue_export.xml\""); PrintWriter out = response.getWriter(); out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\n"); try { String xml = ImportExportUtilities.exportIssues(issues, config); out.print(xml); out.flush(); } catch(ImportExportException iee) { Logger.logError("Error exporting issue data. Message: " + iee.getMessage(), iee); return false; } out.flush(); out.close(); return true; } } |
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/admin/user Added Files: Tag: itrackerhibernate UnlockUserAction.java LockUserAction.java EditUserFormAction.java EditUserAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: EditUserAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.user; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Vector; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.exceptions.UserException; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.PermissionModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.forms.UserForm; import cowsultants.itracker.web.util.Constants; import cowsultants.itracker.web.util.SessionManager; public class EditUserAction extends ITrackerAction { public EditUserAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing component."); return mapping.findForward("listusers"); } resetToken(request); UserForm userForm = (UserForm) form; if(userForm == null) { return mapping.findForward("listusers"); } HttpSession session = request.getSession(true); try { UserHandler uh = getITrackerServices().getUserHandler(); UserModel editUser = new UserModel(); editUser.setId(userForm.getId()); editUser.setLogin(userForm.getLogin()); editUser.setFirstName(userForm.getFirstName()); editUser.setLastName(userForm.getLastName()); editUser.setEmail(userForm.getEmail()); editUser.setSuperUser(userForm.isSuperUser()); String previousLogin = editUser.getLogin(); try { if("create".equals(userForm.getAction())) { if(! uh.allowProfileCreation(editUser, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.noprofilecreates")); saveErrors(request, errors); return mapping.findForward("error"); } Logger.logDebug("Creating new userid."); editUser.setRegistrationType(UserUtilities.REGISTRATION_TYPE_ADMIN); if(uh.allowPasswordUpdates(editUser, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB)) { editUser.setPassword(UserUtilities.encryptPassword(userForm.getPassword())); } editUser = uh.createUser(editUser); } else if ("update".equals(userForm.getAction())) { UserModel existingUser = uh.getUser(editUser.getId()); if(existingUser != null) { previousLogin = existingUser.getLogin(); boolean performUpdate = true; if(! uh.allowProfileUpdates(existingUser, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB)) { editUser = existingUser; performUpdate = false; } if(uh.allowPasswordUpdates(existingUser, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB)) { if(userForm.getPassword() != null && ! userForm.getPassword().equals("")) { editUser.setPassword(UserUtilities.encryptPassword(userForm.getPassword())); performUpdate = true; } } if(performUpdate) { editUser = uh.updateUser(editUser); } } } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidaction")); } } catch(UserException ue) { ue.printStackTrace(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.existinglogin")); saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } if(errors.isEmpty() && uh.allowPermissionUpdates(editUser, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB)) { HashMap permissions = userForm.getPermissions(); Vector permissionsVector = new Vector(); for(Iterator iter = permissions.keySet().iterator(); iter.hasNext(); ) { String paramName = (String) iter.next(); permissionsVector.addElement(new PermissionModel(new Integer(paramName.substring(paramName.lastIndexOf('j') + 1)), Integer.parseInt(paramName.substring(4,paramName.lastIndexOf('P'))))); } PermissionModel[] newPermissions = new PermissionModel[permissionsVector.size()]; permissionsVector.copyInto(newPermissions); uh.setUserPermissions(editUser.getId(), newPermissions); } if(errors.isEmpty()) { if(! previousLogin.equals(editUser.getLogin())) { if(SessionManager.getSessionStart(previousLogin) != null) { SessionManager.addRenamedLogin(previousLogin, editUser.getLogin()); SessionManager.setSessionNeedsReset(previousLogin); } } else { if(SessionManager.getSessionStart(editUser.getLogin()) != null) { SessionManager.setSessionNeedsReset(editUser.getLogin()); } } Logger.logDebug("Forwarding to list users."); session.removeAttribute(Constants.EDIT_USER_KEY); return mapping.findForward("listusers"); } } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } session.removeAttribute(Constants.EDIT_USER_KEY); return mapping.findForward("error"); } } --- NEW FILE: LockUserAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.user; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.SessionManager; public class LockUserAction extends ITrackerAction { public LockUserAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { UserHandler uh = getITrackerServices().getUserHandler(); Integer userId = new Integer((request.getParameter("id") == null ? "-1" : (request.getParameter("id")))); if(uh.setUserStatus(userId, UserUtilities.STATUS_LOCKED)) { uh.clearOwnedProjects(userId); UserModel user = uh.getUser(userId); if(user != null && SessionManager.getSessionStart(user.getLogin()) != null) { SessionManager.setSessionNeedsReset(user.getLogin()); } } } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("listusers"); } } --- NEW FILE: EditUserFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.user; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.PermissionModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.forms.UserForm; import cowsultants.itracker.web.util.Constants; public class EditUserFormAction extends ITrackerAction { public EditUserFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } HttpSession session = request.getSession(true); try { UserHandler uh = getITrackerServices().getUserHandler(); UserModel editUser = null; HashMap userPermissions = new HashMap(); UserForm userForm = (UserForm) form; if(userForm == null) { userForm = new UserForm(); } String action = (String) request.getParameter("action"); if("create".equals(action)) { if(! uh.allowProfileCreation(null, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.noprofilecreates")); saveErrors(request, errors); return mapping.findForward("error"); } editUser = new UserModel(); editUser.setId(new Integer(-1)); editUser.setStatus(UserUtilities.STATUS_ACTIVE); userForm.setAction("create"); userForm.setId(editUser.getId()); } else if ("update".equals(action)) { Integer userId = userForm.getId(); if(userId == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invaliduser")); } else { editUser = uh.getUser(userId); if(editUser == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invaliduser")); } else { userForm.setAction("update"); userForm.setId(editUser.getId()); userForm.setLogin(editUser.getLogin()); userForm.setFirstName(editUser.getFirstName()); userForm.setLastName(editUser.getLastName()); userForm.setEmail(editUser.getEmail()); userForm.setSuperUser(editUser.isSuperUser()); PermissionModel[] permissionArray = uh.getPermissionsByUserId(editUser.getId()); HashMap formPermissions = new HashMap(); for(int i = 0; i < permissionArray.length; i++) { if(userPermissions.get(permissionArray[i].getProjectId()) == null) { HashMap projectPermissions = new HashMap(); userPermissions.put(permissionArray[i].getProjectId(), projectPermissions); } formPermissions.put("Perm" + permissionArray[i].getPermissionType() + "Proj" + permissionArray[i].getProjectId(), "on"); ((HashMap) userPermissions.get(permissionArray[i].getProjectId())).put(Integer.toString(permissionArray[i].getPermissionType()), permissionArray[i]); } userForm.setPermissions(formPermissions); } } } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidaction")); } if(errors.isEmpty()) { request.setAttribute("userForm", userForm); session.setAttribute(Constants.EDIT_USER_KEY, editUser); session.setAttribute(Constants.EDIT_USER_PERMS_KEY, userPermissions); saveToken(request); return mapping.getInputForward(); } } catch(Exception e) { Logger.logError("Exception while creating edit user form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: UnlockUserAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.user; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class UnlockUserAction extends ITrackerAction { public UnlockUserAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { UserHandler uh = getITrackerServices().getUserHandler(); Integer userId = new Integer((request.getParameter("id") == null ? "-1" : (request.getParameter("id")))); uh.setUserStatus(userId, UserUtilities.STATUS_ACTIVE); } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("listusers"); } } |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:35
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/issuesearch In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/issuesearch Added Files: Tag: itrackerhibernate SearchIssuesFormAction.java SearchIssuesAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: SearchIssuesFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.issuesearch; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; import java.util.Vector; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.models.IssueSearchQueryModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.UserPreferencesModel; import cowsultants.itracker.ejb.client.util.IssueUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class SearchIssuesFormAction extends ITrackerAction { public SearchIssuesFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } HttpSession session = request.getSession(); try { ProjectHandler ph = getITrackerServices().getProjectHandler(); UserPreferencesModel userPrefs = (UserPreferencesModel) session.getAttribute(Constants.PREFERENCES_KEY); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); String projectId = request.getParameter("pid"); String action = (String) PropertyUtils.getSimpleProperty((DynaValidatorForm) form, "action"); DynaValidatorForm searchForm = (DynaValidatorForm) form; if(searchForm == null) { searchForm = new DynaValidatorForm(); } boolean newQuery = false; IssueSearchQueryModel query = (IssueSearchQueryModel) session.getAttribute(Constants.SEARCH_QUERY_KEY); Logger.logDebug("projectid = " + projectId); Logger.logDebug("query type = " + (query == null ? "NULL" : query.getType().toString())); Logger.logDebug("query projectid = " + (query == null ? "NULL" : query.getProjectId().toString())); if(query == null || query.getType() == null || "reset".equalsIgnoreCase(action) || (userPrefs != null && ! userPrefs.getRememberLastSearch())) { Logger.logDebug("New search query. No existing query, reset forced, or saved querys not allowed."); query = new IssueSearchQueryModel(); query.setType(IssueSearchQueryModel.TYPE_FULL); newQuery = true; } else if(query.getType().intValue() == IssueSearchQueryModel.TYPE_FULL.intValue() && projectId != null) { Logger.logDebug("New search query. Previous query FULL, new query PROJECT."); query = new IssueSearchQueryModel(); query.setType(IssueSearchQueryModel.TYPE_PROJECT); newQuery = true; } else if(query.getType().intValue() == IssueSearchQueryModel.TYPE_PROJECT.intValue()) { if(projectId == null || projectId.equals("")) { Logger.logDebug("New search query. Previous query PROJECT, new query FULL."); query = new IssueSearchQueryModel(); query.setType(IssueSearchQueryModel.TYPE_FULL); newQuery = true; } else if(! projectId.equals(query.getProjectId().toString())) { Logger.logDebug("New search query. Requested project (" + projectId + ") different from previous query (" + query.getProjectId().toString() + ")"); query = new IssueSearchQueryModel(); query.setType(IssueSearchQueryModel.TYPE_PROJECT); newQuery = true; } } query.setAvailableProjects(null); ProjectModel[] projects = ph.getAllAvailableProjects(); Arrays.sort(projects, new ProjectModel()); Vector availableProjectsVector = new Vector(); Vector selectedProjectsVector = new Vector(); for(int i = 0; i < projects.length; i++) { if(! UserUtilities.hasPermission(userPermissions, projects[i].getId(), UserUtilities.PERMISSION_VIEW_ALL) && ! UserUtilities.hasPermission(userPermissions, projects[i].getId(), UserUtilities.PERMISSION_VIEW_USERS)) { continue; } Logger.logDebug("Adding project " + projects[i].getId() + " to list of available projects."); availableProjectsVector.add(projects[i]); if(projectId != null && projects[i].getId().toString().equals(projectId)) { query.setType(IssueSearchQueryModel.TYPE_PROJECT); query.setProject(projects[i]); break; } else { for(int j = 0; j < query.getProjects().length; j++) { if(query.getProjects()[j].equals(projects[i].getId())) { selectedProjectsVector.add(projects[i].getId()); break; } } } } ProjectModel[] availableProjects = new ProjectModel[availableProjectsVector.size()]; availableProjectsVector.copyInto(availableProjects); Logger.logDebug("Issue Search has " + availableProjects.length + " available projects."); if(availableProjects.length != 0) { query.setAvailableProjects(availableProjects); if(query.getType().equals(IssueSearchQueryModel.TYPE_PROJECT)) { searchForm.set("project", query.getProjectId()); } if(newQuery) { Logger.logDebug("New search query. Clearing results and setting defaults."); query.setResults(null); Vector selectedStatusesVector = new Vector(); for(int i = 0; i < IssueUtilities.getStatuses().length; i++) { try { int statusNumber = Integer.parseInt(IssueUtilities.getStatuses()[i].getValue()); if(statusNumber < IssueUtilities.STATUS_CLOSED) { selectedStatusesVector.add(new Integer(statusNumber)); } } catch(Exception e) { Logger.logDebug("Invalid status entry: " + IssueUtilities.getStatuses()[i]); } } Integer[] selectedStatuses = new Integer[selectedStatusesVector.size()]; selectedStatusesVector.copyInto(selectedStatuses); searchForm.set("statuses", selectedStatuses); Integer[] selectedSeverities = new Integer[IssueUtilities.getNumberSeverities()]; for(int i = 1; i <= IssueUtilities.getNumberSeverities(); i++) { selectedSeverities[i - 1] = new Integer(i); } searchForm.set("severities", selectedSeverities); } else { Integer[] selectedProjects = new Integer[selectedProjectsVector.size()]; selectedProjectsVector.copyInto(selectedProjects); query.setProjects(selectedProjects); searchForm.set("components", query.getComponents()); searchForm.set("contributor", query.getContributor()); searchForm.set("creator", query.getCreator()); searchForm.set("orderBy", query.getOrderBy()); searchForm.set("project", query.getProjectId()); searchForm.set("projects", query.getProjects()); searchForm.set("resolution", query.getResolution()); searchForm.set("severities", query.getSeverities()); searchForm.set("statuses", query.getStatuses()); searchForm.set("targetVersion", query.getTargetVersion()); searchForm.set("textphrase", query.getText()); searchForm.set("versions", query.getVersions()); } request.setAttribute("searchForm", searchForm); session.setAttribute(Constants.SEARCH_QUERY_KEY, query); } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.noprojects")); } if(errors.isEmpty()) { return mapping.getInputForward(); } } catch(Exception e) { Logger.logError("Exception while creating search issues form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: SearchIssuesAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.issuesearch; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.exceptions.IssueSearchException; import cowsultants.itracker.ejb.client.interfaces.IssueSearch; import cowsultants.itracker.ejb.client.models.IssueModel; import cowsultants.itracker.ejb.client.models.IssueSearchQueryModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class SearchIssuesAction extends ITrackerAction { public SearchIssuesAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } HttpSession session = request.getSession(); UserModel user = (UserModel) session.getAttribute(Constants.USER_KEY); HashMap permissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); if(user == null || permissions == null) { return mapping.findForward("login"); } try { IssueSearch is = getITrackerServices().getIssueSearch(); IssueSearchQueryModel isqm = (IssueSearchQueryModel) session.getAttribute(Constants.SEARCH_QUERY_KEY); if(isqm == null) { return mapping.findForward("searchissues"); } processQueryParameters(isqm, (DynaValidatorForm) form, errors); if(errors.isEmpty()) { IssueModel[] results = is.searchIssues(isqm, user, permissions); if(Logger.isLoggingDebug()) { Logger.logDebug("SearchIssuesAction received " + results.length + " results to query."); } String order = isqm.getOrderBy(); if("id".equals(order)) { Arrays.sort(results, new IssueModel.CompareById()); } else if("sev".equals(order)) { Arrays.sort(results, new IssueModel.CompareBySeverity()); } else if("proj".equals(order)) { Arrays.sort(results, new IssueModel.CompareByProjectAndStatus()); } else if("owner".equals(order)) { Arrays.sort(results, new IssueModel.CompareByOwnerAndStatus()); } else if("lm".equals(order)) { Arrays.sort(results, new IssueModel.CompareByDate(false)); } else { Arrays.sort(results, new IssueModel()); } isqm.setResults(results); Logger.logDebug("Setting search results with " + isqm.getResults().length + " results"); session.setAttribute(Constants.SEARCH_QUERY_KEY, isqm); } } catch(IssueSearchException ise) { if(ise.getType() == IssueSearchException.ERROR_NULL_QUERY) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.nullsearch")); } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } } catch(Exception e) { Logger.logError(e.getMessage(), e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.getInputForward(); } private IssueSearchQueryModel processQueryParameters(IssueSearchQueryModel isqm, DynaValidatorForm form, ActionErrors errors) { if(isqm == null) { isqm = new IssueSearchQueryModel(); } try { Integer creatorValue = (Integer) PropertyUtils.getSimpleProperty(form, "creator"); if(creatorValue != null && creatorValue.intValue() != -1) { isqm.setCreator(creatorValue); } else { isqm.setCreator(null); } Integer contributorValue = (Integer) PropertyUtils.getSimpleProperty(form, "contributor"); if(contributorValue != null && contributorValue.intValue() != -1) { isqm.setContributor(contributorValue); } else { isqm.setContributor(null); } Integer ownerValue = (Integer) PropertyUtils.getSimpleProperty(form, "owner"); if(ownerValue != null && ownerValue.intValue() != -1) { isqm.setOwner(ownerValue); } else { isqm.setOwner(null); } String textValue = (String) PropertyUtils.getSimpleProperty(form, "textphrase"); if(textValue != null && ! textValue.equals("")) { isqm.setText(textValue); } else { isqm.setText(null); } String resolutionValue = (String) PropertyUtils.getSimpleProperty(form, "resolution"); if(resolutionValue != null && ! resolutionValue.equals("")) { isqm.setResolution(resolutionValue); } else { isqm.setResolution(null); } Integer[] projects = (Integer[]) PropertyUtils.getSimpleProperty(form, "projects"); if(projects == null || projects.length == 0) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.projectrequired")); } else { isqm.setProjects(projects); } Integer[] severities = (Integer[]) PropertyUtils.getSimpleProperty(form, "severities"); if(severities != null) { isqm.setSeverities(severities); } Integer[] statuses = (Integer[]) PropertyUtils.getSimpleProperty(form, "statuses"); if(statuses != null) { isqm.setStatuses(statuses); } Integer[] components = (Integer[]) PropertyUtils.getSimpleProperty(form, "components"); if(components != null) { isqm.setComponents(components); } Integer[] versions = (Integer[]) PropertyUtils.getSimpleProperty(form, "versions"); if(versions != null) { isqm.setVersions(versions); } Integer targetVersion = (Integer) PropertyUtils.getSimpleProperty(form, "targetVersion"); if(targetVersion != null && ! targetVersion.equals("") && targetVersion.intValue() != -1) { isqm.setTargetVersion(targetVersion); } else { isqm.setTargetVersion(null); } String orderBy = (String) PropertyUtils.getSimpleProperty(form, "orderBy"); if(orderBy != null && ! orderBy.equals("")) { isqm.setOrderBy(orderBy); } Integer type = (Integer) PropertyUtils.getSimpleProperty(form, "type"); if(type != null) { isqm.setType(type); } } catch(Exception e) { Logger.logDebug("Unable to parse search query parameters: " + e.getMessage(), e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidsearchquery")); } return isqm; } } |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:35
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/language In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/admin/language Added Files: Tag: itrackerhibernate ExportLanguageAction.java EditLanguageAction.java EditLanguageFormAction.java InitializeLanguagesAction.java CreateLanguageKeyAction.java CreateLanguageKeyFormAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: CreateLanguageKeyFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.language; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class CreateLanguageKeyFormAction extends ITrackerAction { public CreateLanguageKeyFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { saveToken(request); return mapping.getInputForward(); } catch(Exception e) { Logger.logError("Exception while creating create language key form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: ExportLanguageAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.language; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.NameValuePairModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.HTMLUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class ExportLanguageAction extends ITrackerAction { public ExportLanguageAction () { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); String locale = (String) PropertyUtils.getSimpleProperty(form, "locale"); if(locale != null && ! locale.equals("")) { StringBuffer output = new StringBuffer("# ITracker language properties file for locale " + locale + "\n\n"); NameValuePairModel[] items = sc.getDefinedKeysAsArray(locale); for(int i = 0; i < items.length; i++) { if(items[i].getName() != null && items[i].getValue() != null) { output.append(ITrackerResources.escapeUnicodeString(items[i].getName(), false) + "=" + ITrackerResources.escapeUnicodeString(HTMLUtilities.escapeNewlines(items[i].getValue()), false) + "\n"); } } response.setHeader("Content-Disposition", "attachment; filename=\"ITracker" + (locale.equals(ITrackerResources.BASE_LOCALE) ? "" : "_" + locale) + ".properties\""); response.setHeader("Content-Type", "application/x-itracker-language-export; charset=UTF-8"); ServletOutputStream out = response.getOutputStream(); out.println(output.toString()); out.flush(); return null; } errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidlocale")); } catch(Exception e) { Logger.logError("Exception while exporting language.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: CreateLanguageKeyAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.language; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.LanguageModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class CreateLanguageKeyAction extends ITrackerAction { public CreateLanguageKeyAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while creating language key."); return mapping.findForward("listlanguages"); } resetToken(request); try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); String key = (String) PropertyUtils.getSimpleProperty(form, "key"); HashMap items = (HashMap) PropertyUtils.getSimpleProperty(form, "items"); // Move to validation code if(items != null) { Logger.logDebug("Adding new language key: " + key); for(Iterator iter = items.keySet().iterator(); iter.hasNext(); ) { String locale = (String) iter.next(); Logger.logDebug("Checking translation for locale " + locale); if(locale != null) { String value = (String) items.get(locale); Logger.logDebug("Locale value: " + value); if(value != null && ! value.equals("")) { Logger.logDebug("Adding new translation for locale " + locale + " for key " + key); sc.updateLanguageItem(new LanguageModel(locale, key, value)); } } } String baseValue = (String) items.get(ITrackerResources.BASE_LOCALE); //if(baseValue == null || baseValue.equals("")) { //errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.required", )); sc.updateLanguageItem(new LanguageModel(ITrackerResources.BASE_LOCALE, key, baseValue)); ITrackerResources.clearKeyFromBundles(key, true); } return mapping.findForward("listlanguages"); } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } return mapping.findForward("error"); } } --- NEW FILE: InitializeLanguagesAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.language; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class InitializeLanguagesAction extends ITrackerAction { public InitializeLanguagesAction () { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); SystemConfigurationUtilities.initializeAllLanguages(sc, true); return mapping.getInputForward(); } catch(Exception e) { Logger.logError("Exception while reinitializing languages.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditLanguageAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.language; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import java.util.MissingResourceException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.ConfigurationModel; import cowsultants.itracker.ejb.client.models.LanguageModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.ejb.beans.session.NoSuchEntityException; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditLanguageAction extends ITrackerAction { public EditLanguageAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing language."); return mapping.findForward("listlanguages"); } resetToken(request); HttpSession session = request.getSession(true); try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); String action = (String) PropertyUtils.getSimpleProperty(form, "action"); String locale = (String) PropertyUtils.getSimpleProperty(form, "locale"); HashMap items = (HashMap) PropertyUtils.getSimpleProperty(form, "items"); if(items == null) { return mapping.findForward("listlanguages"); } // Fixes added for bug in beanutils. Can remove all of the replace calls in the following // code once the bug is fixed. Make sure the fix in EditLanguageFormAction is also removed. if(locale == null || "".equals(locale.trim())) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidlocale")); } else if("create".equals(action)) { if(locale.length() != 2 && (locale.length() != 5 || locale.indexOf('_') != 2)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidlocale")); } else { ConfigurationModel localeConfig = new ConfigurationModel(SystemConfigurationUtilities.TYPE_LOCALE, locale); if(sc.configurationItemExists(localeConfig)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidlocale")); } else { for(Iterator iter = items.keySet().iterator(); iter.hasNext(); ) { String key = (String) iter.next(); if(key != null) { String value = (String) items.get(key); if(value != null && ! value.trim().equals("")) { sc.updateLanguageItem(new LanguageModel(locale, key.replace('/', '.'), value)); } } } sc.createConfigurationItem(localeConfig); clearSessionObjects(session); return mapping.findForward("listlanguages"); } } } else if("update".equals(action)) { Locale updateLocale = ITrackerResources.getLocale(locale); for(Iterator iter = items.keySet().iterator(); iter.hasNext(); ) { String key = (String) iter.next(); if(key != null) { String value = (String) items.get(key); try { String currValue = ITrackerResources.getCheckForKey(key.replace('/', '.'), updateLocale); if(value == null || value.trim().equals("")) { try { sc.removeLanguageItem(new LanguageModel(locale, key.replace('/', '.'))); ITrackerResources.clearKeyFromBundles(key.replace('/', '.'), true); } catch ( NoSuchEntityException e ) { // do nothing; we want to delete it, so... } } else if(! value.equals(currValue)) { sc.updateLanguageItem(new LanguageModel(locale, key.replace('/', '.'), value)); ITrackerResources.clearKeyFromBundles(key.replace('/', '.'), true); } } catch(MissingResourceException mre) { if(value != null && ! value.trim().equals("")) { sc.updateLanguageItem(new LanguageModel(locale, key.replace('/', '.'), value)); ITrackerResources.clearKeyFromBundles(key.replace('/', '.'), true); } } } } clearSessionObjects(session); return mapping.findForward("listlanguages"); } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidaction")); } } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } clearSessionObjects(session); return mapping.findForward("error"); } private void clearSessionObjects(HttpSession session) { session.removeAttribute(Constants.EDIT_LANGUAGE_KEYS_KEY); session.removeAttribute(Constants.EDIT_LANGUAGE_BASE_KEY); session.removeAttribute(Constants.EDIT_LANGUAGE_LANG_KEY); session.removeAttribute(Constants.EDIT_LANGUAGE_LOC_KEY); session.removeAttribute(Constants.EDIT_LANGUAGE_TYPE_KEY); } } --- NEW FILE: EditLanguageFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.language; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditLanguageFormAction extends ITrackerAction { public EditLanguageFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); HttpSession session = request.getSession(true); DynaValidatorForm languageForm = (DynaValidatorForm) form; if(languageForm == null) { languageForm = new DynaValidatorForm(); } String locale = (String) PropertyUtils.getSimpleProperty(form, "locale"); int localeType = SystemConfigurationUtilities.getLocaleType(locale); if(localeType == SystemConfigurationUtilities.LOCALE_TYPE_INVALID) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidlocale")); } else { if("create".equals((String) PropertyUtils.getSimpleProperty(form, "action"))) { // The locale passed in on a create action is actually the parent locale. Reset the parent // locale, increment the type (since we are creating the next type, and clear the locale localeType++; languageForm.set("parentLocale", locale); if(localeType == SystemConfigurationUtilities.LOCALE_TYPE_LOCALE) { languageForm.set("locale", locale + "_"); } else { languageForm.set("locale", ""); } } String[] sortedKeys = sc.getSortedKeys(); // Fix for bug in beanutils. Can remove this logic here and in EditLanguageAction // once the bug is fixed. for(int i = 0; i < sortedKeys.length; i++) { sortedKeys[i] = sortedKeys[i].replace('.', '/'); } HashMap baseItems = new HashMap(); HashMap langItems = new HashMap(); HashMap locItems = new HashMap(); HashMap items = new HashMap(); Logger.logDebug("Loading language elements for edit. Edit type is " + localeType); if(localeType >= SystemConfigurationUtilities.LOCALE_TYPE_BASE) { baseItems = sc.getDefinedKeys(null); items = baseItems; Logger.logDebug("Base Locale has " + baseItems.size() + " keys defined."); } if(localeType >= SystemConfigurationUtilities.LOCALE_TYPE_LANGUAGE) { if(! locale.equalsIgnoreCase(ITrackerResources.BASE_LOCALE)) { String parentLocale = SystemConfigurationUtilities.getLocalePart(locale, SystemConfigurationUtilities.LOCALE_TYPE_LANGUAGE); languageForm.set( "parentLocale" , parentLocale ); langItems = sc.getDefinedKeys(parentLocale); items = langItems; Logger.logDebug("Language " + parentLocale + " has " + langItems.size() + " keys defined."); } } if(localeType == SystemConfigurationUtilities.LOCALE_TYPE_LOCALE) { locItems = sc.getDefinedKeys(locale); items = locItems; Logger.logDebug("Locale " + locale + " has " + locItems.size() + " keys defined."); } if(! "create".equals((String) PropertyUtils.getSimpleProperty(form, "action"))) { // Fix for bug in beanutils. Can remove this logic here and in EditLanguageAction // once the bug is fixed. // languageForm.set("items", items); HashMap formItems = new HashMap(); for(Iterator iter = items.keySet().iterator(); iter.hasNext(); ) { String key = (String) iter.next(); formItems.put(key.replace('.', '/'), (String) items.get(key)); } languageForm.set("items", formItems); } session.setAttribute(Constants.EDIT_LANGUAGE_KEYS_KEY, sortedKeys); session.setAttribute(Constants.EDIT_LANGUAGE_BASE_KEY, baseItems); session.setAttribute(Constants.EDIT_LANGUAGE_LANG_KEY, langItems); session.setAttribute(Constants.EDIT_LANGUAGE_LOC_KEY, locItems); session.setAttribute(Constants.EDIT_LANGUAGE_TYPE_KEY, new Integer(localeType)); request.setAttribute("languageForm", languageForm); Logger.logDebug("Locale = " + languageForm.get("locale")); saveToken(request); return mapping.getInputForward(); } } catch(Exception e) { Logger.logError("Exception while creating edit language form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:35
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/notyetsorted In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/notyetsorted Added Files: Tag: itrackerhibernate EditCustomFieldValueFormAction.java EditCustomFieldValueAction.java ITrackerAction.java RemoveCustomFieldValueAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: ITrackerAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.notyetsorted; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.Action; import cowsultants.itracker.ejb.beans.session.ITrackerServices; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.util.Constants; import cowsultants.itracker.web.util.LoginUtilities; import cowsultants.itracker.web.util.ServletContextUtils; public abstract class ITrackerAction extends Action { protected boolean hasPermission(int[] permissionsNeeded, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (isLoggedIn(request, response)) { HttpSession session = request.getSession(false); HashMap permissions = (session == null ? null : (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY)); if (!UserUtilities.hasPermission(permissions, permissionsNeeded)) { return false; } return true; } return false; } protected boolean hasPermission(int permissionNeeded, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (isLoggedIn(request, response)) { HttpSession session = request.getSession(false); HashMap permissions = (session == null ? null : (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY)); if (!UserUtilities.hasPermission(permissions, permissionNeeded)) { return false; } return true; } return false; } protected boolean isLoggedIn(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { HttpSession session = request.getSession(false); UserModel user = (session == null ? null : (UserModel) session.getAttribute(Constants.USER_KEY)); String login = (user == null ? null : user.getLogin()); if (login == null || "".equals(login)) { LoginUtilities.checkAutoLogin(request, getAllowSaveLogin()); return false; } return true; } public String getBaseURL(HttpServletRequest request) { return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); } protected ITrackerServices getITrackerServices() { return ServletContextUtils.getItrackerServices(getServlet().getServletContext()); } private boolean getAllowSaveLogin() { return(getITrackerServices().getSystemConfiguration().getBooleanProperty("allow_save_login", true)); } } --- NEW FILE: EditCustomFieldValueFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.notyetsorted; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.exceptions.SystemConfigurationException; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.CustomFieldValueModel; import cowsultants.itracker.ejb.client.models.LanguageModel; import cowsultants.itracker.ejb.client.util.CustomFieldUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; public class EditCustomFieldValueFormAction extends ITrackerAction { public EditCustomFieldValueFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); DynaValidatorForm customFieldValueForm = (DynaValidatorForm) form; if(customFieldValueForm == null) { customFieldValueForm = new DynaValidatorForm(); } CustomFieldValueModel customFieldValue = new CustomFieldValueModel(); String action = (String) PropertyUtils.getSimpleProperty(customFieldValueForm, "action"); if("update".equals(action)) { Integer id = (Integer) PropertyUtils.getSimpleProperty(customFieldValueForm, "id"); customFieldValue = sc.getCustomFieldValue(id); if(customFieldValue == null) { throw new SystemConfigurationException("Invalid custom field value id " + id); } customFieldValueForm.set("id", id); customFieldValueForm.set("value", customFieldValue.getValue()); HashMap translations = new HashMap(); LanguageModel[] languageItems = sc.getLanguageItemsByKey(CustomFieldUtilities.getCustomFieldOptionLabelKey(customFieldValue.getCustomFieldId(), customFieldValue.getId())); for(int i = 0; i < languageItems.length; i++) { translations.put(languageItems[i].getLocale(), languageItems[i].getResourceValue()); } customFieldValueForm.set("translations", translations); } request.setAttribute("customFieldValueForm", customFieldValueForm); saveToken(request); return mapping.getInputForward(); } catch(SystemConfigurationException sce) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidcustomfieldvalue")); } catch(Exception e) { Logger.logError("Exception while creating edit custom field value form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditCustomFieldValueAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.notyetsorted; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.exceptions.SystemConfigurationException; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.CustomFieldValueModel; import cowsultants.itracker.ejb.client.models.LanguageModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.CustomFieldUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.web.util.Constants; public class EditCustomFieldValueAction extends ITrackerAction { public EditCustomFieldValueAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } HttpSession session = request.getSession(true); CustomFieldModel customField = (CustomFieldModel) session.getAttribute(Constants.CUSTOMFIELD_KEY); if(customField == null) { return mapping.findForward("listconfiguration"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing custom field value."); return new ActionForward(mapping.findForward("editcustomfield").getPath() + "?id=" + customField.getId() + "&action=update"); } resetToken(request); try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); String action = (String) PropertyUtils.getSimpleProperty(form, "action"); if(action == null) { return new ActionForward(mapping.findForward("editcustomfield").getPath() + "?id=" + customField.getId() + "&action=update"); } CustomFieldValueModel customFieldValue = null; if("create".equals(action)) { Integer id = (Integer) PropertyUtils.getSimpleProperty(form, "id"); CustomFieldValueModel[] currOptions = customField.getOptions(); int highestSortOrder = (currOptions.length == 0 ? 1 : currOptions[currOptions.length - 1].getSortOrder()); customFieldValue = new CustomFieldValueModel(); customFieldValue.setCustomFieldId(customField.getId()); customFieldValue.setValue((String) PropertyUtils.getSimpleProperty(form, "value")); customFieldValue.setSortOrder(highestSortOrder + 1); customFieldValue = sc.createCustomFieldValue(customFieldValue); } else if("update".equals(action)) { Integer id = (Integer) PropertyUtils.getSimpleProperty(form, "id"); customFieldValue = sc.getCustomFieldValue(id); if(customField == null) { throw new SystemConfigurationException("Invalid custom field value id " + id); } customFieldValue.setValue((String) PropertyUtils.getSimpleProperty(form, "value")); customFieldValue = sc.updateCustomFieldValue(customFieldValue); } else { throw new SystemConfigurationException("Invalid action " + action + " while editing custom field value."); } if(customFieldValue == null) { throw new SystemConfigurationException("Unable to create new custom field value model."); } HashMap translations = (HashMap) PropertyUtils.getSimpleProperty(form, "translations"); String key = CustomFieldUtilities.getCustomFieldOptionLabelKey(customField.getId(), customFieldValue.getId()); Logger.logDebug("Processing label translations for custom field value " + customFieldValue.getId() + " with key " + key); if(translations != null && key != null && ! key.equals("")) { for(Iterator iter = translations.keySet().iterator(); iter.hasNext(); ) { String locale = (String) iter.next(); if(locale != null) { String translation = (String) translations.get(locale); if(translation != null && ! translation.equals("")) { Logger.logDebug("Adding new translation for locale " + locale + " for " + customFieldValue); sc.updateLanguageItem(new LanguageModel(locale, key, translation)); } } } String baseValue = (String) translations.get(ITrackerResources.BASE_LOCALE); sc.updateLanguageItem(new LanguageModel(ITrackerResources.BASE_LOCALE, key, baseValue)); ITrackerResources.clearKeyFromBundles(key, true); } // Now reset the cached versions in IssueUtilities sc.resetConfigurationCache(SystemConfigurationUtilities.TYPE_CUSTOMFIELD); return new ActionForward(mapping.findForward("editcustomfield").getPath() + "?id=" + customField.getId() + "&action=update"); } catch(SystemConfigurationException sce) { Logger.logError("Exception processing form data: " + sce.getMessage(), sce); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(sce.getKey())); } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); saveToken(request); request.setAttribute("customFieldValueForm", form); return mapping.getInputForward(); } return mapping.findForward("error"); } } --- NEW FILE: RemoveCustomFieldValueAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.notyetsorted; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.exceptions.SystemConfigurationException; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.CustomFieldValueModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.CustomFieldUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.util.Constants; public class RemoveCustomFieldValueAction extends ITrackerAction { public RemoveCustomFieldValueAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); Integer valueId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); if(valueId == null || valueId.intValue() <= 0) { throw new SystemConfigurationException("Invalid custom field value id."); } CustomFieldValueModel customFieldValue = sc.getCustomFieldValue(valueId); if(customFieldValue == null) { throw new SystemConfigurationException("Invalid custom field value id."); } String key = CustomFieldUtilities.getCustomFieldOptionLabelKey(customFieldValue.getCustomFieldId(), customFieldValue.getId()); sc.removeCustomFieldValue(customFieldValue.getId()); sc.resetConfigurationCache(SystemConfigurationUtilities.TYPE_CUSTOMFIELD); if(key != null) { sc.removeLanguageKey(key); ITrackerResources.clearKeyFromBundles(key, false); } HttpSession session = request.getSession(true); CustomFieldModel customField = (CustomFieldModel) session.getAttribute(Constants.CUSTOMFIELD_KEY); if(customField == null) { return mapping.findForward("listconfiguration"); } return new ActionForward(mapping.findForward("editcustomfield").getPath() + "?id=" + customField.getId() + "&action=update"); } catch(SystemConfigurationException sce) { Logger.logDebug(sce.getMessage(), sce); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidcustomfieldvalue")); } catch(NumberFormatException nfe) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidcustomfieldvalue")); Logger.logDebug("Invalid custom field value id " + request.getParameter("id") + " specified."); } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); Logger.logError("System Error.", e); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:35
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/scheduler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/admin/scheduler Added Files: Tag: itrackerhibernate EditTaskFormAction.java EditTaskAction.java RemoveTaskAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: EditTaskFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.scheduler; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.SchedulerHandler; import cowsultants.itracker.ejb.client.models.ScheduledTaskModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.scheduler.SchedulerUtilities; import cowsultants.itracker.web.util.Constants; public class EditTaskFormAction extends ITrackerAction { public EditTaskFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { SchedulerHandler sh = getITrackerServices().getSchedulerHandler(); HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); if(! UserUtilities.hasPermission(userPermissions, UserUtilities.PERMISSION_USER_ADMIN)) { return mapping.findForward("unauthorized"); } ScheduledTaskModel task = null; DynaValidatorForm taskForm = (DynaValidatorForm) form; if(taskForm == null) { taskForm = new DynaValidatorForm(); } String action = (String) request.getParameter("action"); if("create".equals(action)) { task = new ScheduledTaskModel(); task.setId(new Integer(-1)); taskForm.set("action", "create"); taskForm.set("id", task.getId()); } else if ("update".equals(action)) { Integer taskId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); task = sh.getTask(taskId); if(task == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidtask")); } else { taskForm.set("action", "update"); taskForm.set("id", task.getId()); if(! task.isAll(task.getMonths())) { taskForm.set("months", task.joinString(task.getMonths())); } if(! task.isAll(task.getDaysOfMonth())) { taskForm.set("daysOfMonth", task.joinString(task.getDaysOfMonth())); } if(! task.isAll(task.getHours())) { taskForm.set("hours", task.joinString(task.getHours())); } if(! task.isAll(task.getMinutes())) { taskForm.set("minutes", task.joinString(task.getMinutes())); } if(! task.isAll(task.getWeekdays())) { taskForm.set("weekdays", task.joinString(task.getWeekdays())); } if(SchedulerUtilities.getClassKey(task.getClassName()) != null) { taskForm.set("className", task.getClassName()); } else { taskForm.set("classNameText", task.getClassName()); } taskForm.set("args", task.getArgsAsString()); } } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidaction")); } if(errors.isEmpty()) { request.setAttribute("taskForm", taskForm); session.setAttribute(Constants.TASK_KEY, task); saveToken(request); return mapping.getInputForward(); } } catch(Exception e) { Logger.logError("Exception while creating edit task form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: RemoveTaskAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.scheduler; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.SchedulerHandler; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.scheduler.Scheduler; import cowsultants.itracker.web.util.Constants; public class RemoveTaskAction extends ITrackerAction { public RemoveTaskAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); if(! UserUtilities.hasPermission(userPermissions, UserUtilities.PERMISSION_USER_ADMIN)) { return mapping.findForward("unauthorized"); } SchedulerHandler sh = getITrackerServices().getSchedulerHandler(); Integer taskId = new Integer((request.getParameter("id") == null ? "-1" : request.getParameter("id"))); if(taskId.intValue() > 0) { sh.removeTask(taskId); Scheduler.removeTask(taskId.intValue()); return mapping.findForward("listtasks"); } } catch(NumberFormatException nfe) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidtask")); Logger.logDebug("Invalid taskId " + request.getParameter("id") + " specified."); } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); Logger.logError("System Error.", e); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditTaskAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.scheduler; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.SchedulerHandler; import cowsultants.itracker.ejb.client.models.ScheduledTaskModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.scheduler.Scheduler; import cowsultants.itracker.web.util.Constants; public class EditTaskAction extends ITrackerAction { public EditTaskAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing task."); return mapping.findForward("listtasks"); } resetToken(request); HttpSession session = request.getSession(true); ScheduledTaskModel task = null; try { SchedulerHandler sh = getITrackerServices().getSchedulerHandler(); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); if(! UserUtilities.hasPermission(userPermissions, UserUtilities.PERMISSION_USER_ADMIN)) { return mapping.findForward("unauthorized"); } task = (ScheduledTaskModel) session.getAttribute(Constants.TASK_KEY); task = new ScheduledTaskModel(); task.setId((Integer) PropertyUtils.getSimpleProperty(form, "id")); task.setMonths((String) PropertyUtils.getSimpleProperty(form, "months")); task.setDaysOfMonth((String) PropertyUtils.getSimpleProperty(form, "daysOfMonth")); task.setHours((String) PropertyUtils.getSimpleProperty(form, "hours")); task.setMinutes((String) PropertyUtils.getSimpleProperty(form, "minutes")); task.setWeekdays((String) PropertyUtils.getSimpleProperty(form, "weekdays")); String className = (String) PropertyUtils.getSimpleProperty(form, "className"); if(className != null && ! className.equals("")) { try { Class.forName( className ); task.setClassName(className); } catch ( ClassNotFoundException e ) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError( "itracker.web.error.save" ) ); saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } } else { String classNameText = (String) PropertyUtils.getSimpleProperty(form, "classNameText"); try { Class.forName( classNameText ); task.setClassName( classNameText ); } catch ( ClassNotFoundException e ) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError( "itracker.web.error.save" ) ); saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } } task.setArgs((String) PropertyUtils.getSimpleProperty(form, "args")); String action = (String) request.getParameter("action"); if("create".equals(action)) { task = sh.createTask(task); } else if ("update".equals(action)) { task = sh.updateTask(task); } if(task == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.save")); } else if("update".equals(action)) { Scheduler.removeTask(task.getId().intValue()); } Scheduler.addTask(task); } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.save")); } if(! errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } session.removeAttribute(Constants.TASK_KEY); return mapping.findForward("listtasks"); } } |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:35
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/attachment In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/admin/attachment Added Files: Tag: itrackerhibernate ExportAttachmentsAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: ExportAttachmentsAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.attachment; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.models.IssueAttachmentModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class ExportAttachmentsAction extends ITrackerAction { public ExportAttachmentsAction () { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { IssueHandler ih = getITrackerServices().getIssueHandler(); IssueAttachmentModel[] attachments = ih.getAllIssueAttachments(); if(attachments.length > 0) { response.setHeader("Content-Disposition", "attachment; filename=\"ITracker_attachments.zip\""); ServletOutputStream out = response.getOutputStream(); ZipOutputStream zipOut = new ZipOutputStream(out); try { for(int i = 0; i < attachments.length; i++) { Logger.logDebug("Attempting export for: " + attachments[i]); byte[] attachmentData = ih.getIssueAttachmentData(attachments[i].getId()); if(attachmentData.length > 0) { ZipEntry zipEntry = new ZipEntry(attachments[i].getFileName() + attachments[i].getFileExtension()); zipEntry.setSize(attachmentData.length); zipEntry.setTime(attachments[i].getLastModifiedDate().getTime()); zipOut.putNextEntry(zipEntry); zipOut.write(attachmentData, 0, attachmentData.length); zipOut.closeEntry(); } } zipOut.close(); out.flush(); out.close(); } catch(Exception e) { Logger.logError("Exception while exporting attachments.", e); } return null; } errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.noattachments")); } catch(Exception e) { Logger.logError("Exception while exporting attachments.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } |
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/workflow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/admin/workflow Added Files: Tag: itrackerhibernate EditWorkflowScriptFormAction.java EditWorkflowScriptAction.java RemoveWorkflowScriptAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: RemoveWorkflowScriptAction.java --- /* * RemoveWorkflowScriptAction.java * * Created on 13. November 2005, 04:51 */ package cowsultants.itracker.web.actions.admin.workflow; import cowsultants.itracker.ejb.beans.entity.WorkflowScriptBean; import cowsultants.itracker.ejb.beans.session.WorkflowScriptFactory; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; /** * Action to remove a workflow script * * <ol> * <li>get all project and remove the script to be deleted</li> * <li>delete the script</li> * </ol> * * @author mb...@bc... */ public class RemoveWorkflowScriptAction extends ITrackerAction { /** * executes the action which removes a workflow script * * @param form the form with user input * @param request the request triggering the action * @param response response to the client * @param mapping The action mapping * * @throws ServletException thrown if execution fails * @throws IOException thrown if io to client fails * * @return the <code>ActionForward</code> to forward to */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); ActionForward fw = mapping.findForward("error"); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } // check permissions HttpSession session = request.getSession(true); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); if(! UserUtilities.hasPermission(userPermissions, UserUtilities.PERMISSION_USER_ADMIN)) { return mapping.findForward("unauthorized"); } try { // get the id from the form Integer scriptId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); // remove the script this.getITrackerServices().getSystemConfiguration() .removeWorkflowScript(scriptId); // find the mapping for the list of all worksflows fw = mapping.findForward( "listworkflow" ); } catch (InvocationTargetException ex) { Logger.logError( ex.getMessage(), ex ); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidworkflowscript")); } catch (NoSuchMethodException ex) { Logger.logError( ex.getMessage(), ex ); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidworkflowscript")); } catch (IllegalAccessException ex) { Logger.logError( ex.getMessage(), ex ); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidworkflowscript")); } if(! errors.isEmpty()) { this.saveErrors(request, errors); } return fw; } } --- NEW FILE: EditWorkflowScriptFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.workflow; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.exceptions.SystemConfigurationException; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.WorkflowScriptModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditWorkflowScriptFormAction extends ITrackerAction { public EditWorkflowScriptFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { DynaValidatorForm workflowScriptForm = (DynaValidatorForm) form; if(workflowScriptForm == null) { workflowScriptForm = new DynaValidatorForm(); } String action = (String) PropertyUtils.getSimpleProperty(workflowScriptForm, "action"); WorkflowScriptModel workflowScript = new WorkflowScriptModel(); if ("update".equals(action)) { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); Integer id = (Integer) PropertyUtils.getSimpleProperty(workflowScriptForm, "id"); workflowScript = sc.getWorkflowScript(id); if(workflowScript == null) { throw new SystemConfigurationException("Invalid workflow script id " + id); } workflowScriptForm.set("action", "update"); workflowScriptForm.set("id", workflowScript.getId()); workflowScriptForm.set("name", workflowScript.getName()); workflowScriptForm.set("event", new Integer(workflowScript.getEvent())); workflowScriptForm.set("script", workflowScript.getScript()); } if(errors.isEmpty()) { HttpSession session = request.getSession(true); request.setAttribute("workflowScriptForm", workflowScriptForm); session.setAttribute(Constants.WORKFLOW_SCRIPT_KEY, workflowScript); saveToken(request); return mapping.getInputForward(); } } catch(SystemConfigurationException sce) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidworkflowscript")); } catch(Exception e) { Logger.logError("Exception while creating edit workflowScript form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: EditWorkflowScriptAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.workflow; import java.io.ByteArrayInputStream; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import bsh.ParseException; import bsh.Parser; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.WorkflowScriptModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class EditWorkflowScriptAction extends ITrackerAction { public EditWorkflowScriptAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing workflow script."); return mapping.findForward("listworkflow"); } resetToken(request); WorkflowScriptModel script = null; try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); String scriptData = (String) PropertyUtils.getSimpleProperty(form, "script"); if ( scriptData != null && scriptData.trim().length() > 0 ) { ByteArrayInputStream sbis = new ByteArrayInputStream(scriptData.getBytes()); Parser parser = new Parser(sbis); try { while(!parser.Line()) { // do nothing, if script is syntactically correct // no exception is thrown } } catch(Throwable t) { throw new ParseException(t.getMessage()); } } script = new WorkflowScriptModel(); script.setId((Integer) PropertyUtils.getSimpleProperty(form, "id")); script.setName((String) PropertyUtils.getSimpleProperty(form, "name")); script.setEvent(((Integer) PropertyUtils.getSimpleProperty(form, "event")).intValue()); script.setScript(scriptData); String action = (String) request.getParameter("action"); if("create".equals(action)) { script = sc.createWorkflowScript(script); } else if ("update".equals(action)) { script = sc.updateWorkflowScript(script); } if (script == null) { throw new Exception("Error creating/updating workflow script."); } HttpSession session = request.getSession(true); session.removeAttribute(Constants.WORKFLOW_SCRIPT_KEY); return mapping.findForward("listworkflow"); } catch(ParseException pe) { Logger.logDebug("Error parseing script. Redisplaying form for correction.", pe); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidscriptdata", pe.getMessage())); saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } |
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/project In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/project Added Files: Tag: itrackerhibernate MoveIssueAction.java WatchIssueAction.java EditIssueAction.java AddIssueRelationAction.java CreateIssueFormAction.java RemoveIssueAttachmentAction.java EditIssueFormAction.java RemoveHistoryEntryAction.java MoveIssueFormAction.java AssignIssueAction.java CreateIssueAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: MoveIssueAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.project; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.models.IssueModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class MoveIssueAction extends ITrackerAction { public MoveIssueAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while creating issue."); return mapping.findForward("index"); } resetToken(request); try { IssueHandler ih = getITrackerServices().getIssueHandler(); Integer issueId = (Integer) PropertyUtils.getSimpleProperty(form, "issueId"); Integer projectId = (Integer) PropertyUtils.getSimpleProperty(form, "projectId"); String caller = (String) PropertyUtils.getSimpleProperty(form, "caller"); if(caller == null) { caller = "index"; } IssueModel issue = ih.getIssue(issueId); if(issue == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidissue")); } if(errors.isEmpty()) { HttpSession session = request.getSession(true); UserModel user = (UserModel) session.getAttribute(Constants.USER_KEY); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); if(! UserUtilities.hasPermission(userPermissions, issue.getProjectId(), UserUtilities.PERMISSION_EDIT)) { Logger.logDebug("User not authorized to move issue " + issueId); return mapping.findForward("unauthorized"); } if(! UserUtilities.hasPermission(userPermissions, projectId, new int[] {UserUtilities.PERMISSION_EDIT, UserUtilities.PERMISSION_CREATE})) { Logger.logDebug("User attempted to move issue " + issueId + " to unauthorized project."); return mapping.findForward("unauthorized"); } ih.moveIssue(issue, projectId, user.getId()); session.removeAttribute(Constants.PROJECTS_KEY); session.removeAttribute(Constants.ISSUE_KEY); if("editissue".equals((String) PropertyUtils.getSimpleProperty(form, "caller"))) { return new ActionForward(mapping.findForward("editissue").getPath() + "?id=" + issue.getId()); } else if("viewissue".equals((String) PropertyUtils.getSimpleProperty(form, "caller"))) { return new ActionForward(mapping.findForward("viewissue").getPath() + "?id=" + issue.getId()); } else { return mapping.findForward("index"); } } } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: RemoveIssueAttachmentAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.project; import java.io.File; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.IssueAttachmentModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class RemoveIssueAttachmentAction extends ITrackerAction { public RemoveIssueAttachmentAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { IssueHandler ih = getITrackerServices().getIssueHandler(); try { Integer attachmentId = new Integer((request.getParameter("id") == null ? "-1" : request.getParameter("id"))); IssueAttachmentModel attachment = ih.getIssueAttachment(attachmentId); if(attachment != null) { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); File attachmentFile = new File( sc.getProperty("attachment_dir") + File.separator + attachment.getFileName()); attachmentFile.delete(); ih.removeIssueAttachment(attachmentId); } } catch(NumberFormatException nfe) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.removeattachment")); if(Logger.isLoggingDebug()) { Logger.logDebug("Invalid attachmentId " + request.getParameter("id") + " specified."); } } } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("listattachments"); } } --- NEW FILE: CreateIssueFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.project; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; import java.util.Locale; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.ComponentModel; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.NameValuePairModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.ProjectScriptModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.models.VersionModel; import cowsultants.itracker.ejb.client.util.Convert; import cowsultants.itracker.ejb.client.util.CustomFieldUtilities; import cowsultants.itracker.ejb.client.util.IssueUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.ProjectUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.ejb.client.util.WorkflowUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.forms.IssueForm; import cowsultants.itracker.web.util.Constants; import cowsultants.itracker.web.util.LoginUtilities; public class CreateIssueFormAction extends ITrackerAction { public CreateIssueFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { ProjectHandler ph = getITrackerServices().getProjectHandler(); UserHandler uh = getITrackerServices().getUserHandler(); Integer projectId = new Integer((request.getParameter("pid") == null ? "-1" : (request.getParameter("pid")))); HttpSession session = request.getSession(true); UserModel currUser = (UserModel) session.getAttribute(Constants.USER_KEY); HashMap currPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); Locale currLocale = LoginUtilities.getCurrentLocale(request); if(! UserUtilities.hasPermission(currPermissions, projectId, UserUtilities.PERMISSION_CREATE)) { Logger.logDebug("Unauthorized user requested access to create issue for project " + projectId); return mapping.findForward("unauthorized"); } ProjectModel project = ph.getProject(projectId); Logger.logDebug("Received request for project " + projectId + "(" + project.getName() + ")"); if(project == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(project.getStatus() != ProjectUtilities.STATUS_ACTIVE) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.projectlocked")); } if(errors.isEmpty()) { HashMap listOptions = new HashMap(); if(UserUtilities.hasPermission(currPermissions, project.getId(), UserUtilities.PERMISSION_ASSIGN_OTHERS)) { UserModel[] possibleOwners = uh.getPossibleOwners(null, project.getId(), currUser.getId()); Arrays.sort(possibleOwners, new UserModel.CompareByFirstName()); listOptions.put(new Integer(IssueUtilities.FIELD_OWNER), Convert.UsersToNVP(possibleOwners)); } else if(UserUtilities.hasPermission(currPermissions, project.getId(), UserUtilities.PERMISSION_ASSIGN_SELF)) { listOptions.put(new Integer(IssueUtilities.FIELD_OWNER), new NameValuePairModel[] { new NameValuePairModel(currUser.getFirstName() + " " + currUser.getLastName(), currUser.getId().toString()) }); } if(UserUtilities.hasPermission(currPermissions, project.getId(), UserUtilities.PERMISSION_CREATE_OTHERS)) { UserModel[] possibleCreators = uh.getUsersWithAnyProjectPermission(project.getId(), new int[] {UserUtilities.PERMISSION_VIEW_ALL, UserUtilities.PERMISSION_VIEW_USERS}); Arrays.sort(possibleCreators, new UserModel.CompareByFirstName()); listOptions.put(new Integer(IssueUtilities.FIELD_CREATOR), Convert.UsersToNVP(possibleCreators)); } NameValuePairModel[] severities = IssueUtilities.getSeverities(currLocale); listOptions.put(new Integer(IssueUtilities.FIELD_SEVERITY), severities); ComponentModel[] components = project.getComponents(); Arrays.sort(components, new ComponentModel()); listOptions.put(new Integer(IssueUtilities.FIELD_COMPONENTS), Convert.ComponentsToNVP(components)); VersionModel[] versions = project.getVersions(); Arrays.sort(versions, new VersionModel()); listOptions.put(new Integer(IssueUtilities.FIELD_VERSIONS), Convert.VersionsToNVP(versions)); CustomFieldModel[] projectFields = project.getCustomFields(); for(int i = 0; i < projectFields.length; i++) { if(projectFields[i].getFieldType() == CustomFieldUtilities.TYPE_LIST) { projectFields[i].setLabels(currLocale); listOptions.put(projectFields[i].getId(), Convert.CustomFieldOptionsToNVP(projectFields[i].getOptions())); } } DynaValidatorForm issueForm = (DynaValidatorForm) form; if(issueForm == null) { issueForm = new IssueForm(); } issueForm.set("creatorId", currUser.getId()); if(severities.length > 0) { try { int midPoint = (severities.length / 2); issueForm.set("severity", new Integer(severities[midPoint].getValue())); } catch(NumberFormatException nfe) { Logger.logDebug("Invalid status number found while preparing create issue form."); } } if(versions.length > 0) { issueForm.set("versions", new Integer[] {versions[0].getId()}); } ProjectScriptModel[] scripts = project.getScripts(); WorkflowUtilities.ProcessFieldScripts(scripts, WorkflowUtilities.EVENT_FIELD_ONPOPULATE, listOptions, errors, issueForm); WorkflowUtilities.ProcessFieldScripts(scripts, WorkflowUtilities.EVENT_FIELD_ONSETDEFAULT, null, errors, issueForm); if(errors == null || errors.isEmpty()) { Logger.logDebug("Forwarding to create issue form for project " + project.getId()); request.setAttribute("issueForm", issueForm); session.setAttribute(Constants.PROJECT_KEY, project); session.setAttribute(Constants.LIST_OPTIONS_KEY, listOptions); saveToken(request); return mapping.getInputForward(); } } } catch(Exception e) { Logger.logError("Exception while creating create issue form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: RemoveHistoryEntryAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.project; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class RemoveHistoryEntryAction extends ITrackerAction { public RemoveHistoryEntryAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { IssueHandler ih = getITrackerServices().getIssueHandler(); Integer historyId = (Integer) PropertyUtils.getSimpleProperty(form, "historyId"); String caller = (String) PropertyUtils.getSimpleProperty(form, "caller"); if(caller == null) { caller = ""; } HttpSession session = request.getSession(true); UserModel currUser = (UserModel) session.getAttribute(Constants.USER_KEY); if(! currUser.isSuperUser()) { return mapping.findForward("unauthorized"); } else { Integer issueId = ih.removeIssueHistoryEntry(historyId, currUser.getId()); return new ActionForward(mapping.findForward("editissue").getPath() + "?id=" + issueId + "&caller=" + caller); } } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); Logger.logError("System Error.", e); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: AddIssueRelationAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.project; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.models.IssueModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.IssueUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class AddIssueRelationAction extends ITrackerAction { public AddIssueRelationAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } Integer issueId = null; String caller = "index"; try { IssueHandler ih = getITrackerServices().getIssueHandler(); caller = (String) PropertyUtils.getSimpleProperty(form, "caller"); issueId = (Integer) PropertyUtils.getSimpleProperty(form, "issueId"); Integer relatedIssueId = (Integer) PropertyUtils.getSimpleProperty(form, "relatedIssueId"); int relationType = ((Integer) PropertyUtils.getSimpleProperty(form, "relationType")).intValue(); HttpSession session = request.getSession(true); UserModel currUser = (UserModel) session.getAttribute(Constants.USER_KEY); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); Integer currUserId = currUser.getId(); IssueModel issue = ih.getIssue(issueId); if(issue == null || issue.getProjectId() == null || ! IssueUtilities.canEditIssue(issue, currUserId, userPermissions)) { return mapping.findForward("unauthorized"); } IssueModel relatedIssue = ih.getIssue(relatedIssueId); if(relatedIssue == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.relation.invalidissue")); } else if(relatedIssue.getProjectId() == null || ! IssueUtilities.canEditIssue(relatedIssue, currUserId, userPermissions)) { return mapping.findForward("unauthorized"); } else { if(IssueUtilities.hasIssueRelation(issue, relatedIssueId)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.relation.exists", relatedIssueId)); } if(! ih.addIssueRelation(issueId, relatedIssueId, relationType, currUser.getId())) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.relation.adderror")); } } } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return new ActionForward(mapping.findForward(caller).getPath() + (issueId != null ? "?id=" + issueId : "")); } } --- NEW FILE: EditIssueFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.project; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Locale; import java.util.MissingResourceException; import java.util.Vector; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.ComponentModel; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.IssueFieldModel; import cowsultants.itracker.ejb.client.models.IssueModel; import cowsultants.itracker.ejb.client.models.NameValuePairModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.ProjectScriptModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.models.VersionModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.Convert; import cowsultants.itracker.ejb.client.util.CustomFieldUtilities; import cowsultants.itracker.ejb.client.util.HTMLUtilities; import cowsultants.itracker.ejb.client.util.IssueUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.ProjectUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.ejb.client.util.WorkflowUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.forms.IssueForm; import cowsultants.itracker.web.util.Constants; /** * This class populates an IssueForm object for display by the edit issue page. */ public class EditIssueFormAction extends ITrackerAction { public EditIssueFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { IssueHandler ih = getITrackerServices().getIssueHandler(); UserHandler uh = getITrackerServices().getUserHandler(); Integer issueId = new Integer((request.getParameter("id") == null ? "-1" : (request.getParameter("id")))); IssueModel issue = ih.getIssue(issueId); ProjectModel project = ih.getIssueProject(issueId); if(issue == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidissue")); } else if(project == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(project.getStatus() != ProjectUtilities.STATUS_ACTIVE) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.projectlocked")); } else { HttpSession session = request.getSession(true); UserModel currUser = (UserModel) session.getAttribute(Constants.USER_KEY); HashMap currPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); Locale currLocale = (Locale) session.getAttribute(Constants.LOCALE_KEY); if(! IssueUtilities.canEditIssue(issue, currUser.getId(), currPermissions)) { Logger.logDebug("Unauthorized user requested access to edit issue for project " + project.getId()); return mapping.findForward("unauthorized"); } if(errors.isEmpty()) { HashMap listOptions = new HashMap(); boolean hasFullEdit = UserUtilities.hasPermission(currPermissions, project.getId(), UserUtilities.PERMISSION_EDIT_FULL); Vector ownersVector = new Vector(); if(UserUtilities.hasPermission(currPermissions, project.getId(), UserUtilities.PERMISSION_ASSIGN_OTHERS)) { if(issue.getOwner() == null) { ownersVector.addElement(new NameValuePairModel(ITrackerResources.getString("itracker.web.generic.unassigned", currLocale), "-1")); } else { ownersVector.addElement(new NameValuePairModel(ITrackerResources.getString("itracker.web.generic.unassign", currLocale), "-1")); } UserModel[] possibleOwners = uh.getPossibleOwners(issue, project.getId(), currUser.getId()); Arrays.sort(possibleOwners, new UserModel.CompareByFirstName()); NameValuePairModel[] ownerNames = Convert.UsersToNVP(possibleOwners); for(int i = 0; i < ownerNames.length; i++) { ownersVector.addElement(ownerNames[i]); } } else if(UserUtilities.hasPermission(currPermissions, project.getId(), UserUtilities.PERMISSION_ASSIGN_SELF)) { if(issue.getOwner() != null) { if(IssueUtilities.canUnassignIssue(issue, currUser.getId(), currPermissions)) { ownersVector.addElement(new NameValuePairModel(ITrackerResources.getString("itracker.web.generic.unassign", currLocale), "-1")); } if(! issue.getOwner().getId().equals(currUser.getId())) { ownersVector.addElement(new NameValuePairModel(issue.getOwner().getFirstName() + " " + issue.getOwner().getLastName(), issue.getOwner().getId().toString())); ownersVector.addElement(new NameValuePairModel(currUser.getFirstName() + " " + currUser.getLastName(), currUser.getId().toString())); } else { ownersVector.addElement(new NameValuePairModel(currUser.getFirstName() + " " + currUser.getLastName(), currUser.getId().toString())); } } } else if(issue.getOwner() != null && IssueUtilities.canUnassignIssue(issue, currUser.getId(), currPermissions)) { ownersVector.addElement(new NameValuePairModel(ITrackerResources.getString("itracker.web.generic.unassign", currLocale), "-1")); ownersVector.addElement(new NameValuePairModel(issue.getOwner().getFirstName() + " " + issue.getOwner().getLastName(), issue.getOwner().getId().toString())); } NameValuePairModel[] ownersArray = new NameValuePairModel[ownersVector.size()]; ownersVector.copyInto(ownersArray); listOptions.put(new Integer(IssueUtilities.FIELD_OWNER), ownersArray); NameValuePairModel[] allStatuses = IssueUtilities.getStatuses(currLocale); Vector statusVector = new Vector(); if(! hasFullEdit) { if(issue.getStatus() >= IssueUtilities.STATUS_RESOLVED && UserUtilities.hasPermission(currPermissions, project.getId(), UserUtilities.PERMISSION_CLOSE)) { for(int i = 0; i < allStatuses.length; i++) { int statusNumber = Integer.parseInt(allStatuses[i].getValue()); if(issue.getStatus() >= IssueUtilities.STATUS_CLOSED && statusNumber >= IssueUtilities.STATUS_CLOSED) { statusVector.addElement(allStatuses[i]); } else if(issue.getStatus() >= IssueUtilities.STATUS_RESOLVED && statusNumber >= IssueUtilities.STATUS_RESOLVED) { statusVector.addElement(allStatuses[i]); } } } else { // Can't change } } else { if(currUser.isSuperUser()) { for(int i = 0; i < allStatuses.length; i++) { statusVector.addElement(allStatuses[i]); } } else if(issue.getStatus() >= IssueUtilities.STATUS_ASSIGNED && issue.getStatus() < IssueUtilities.STATUS_RESOLVED) { for(int i = 0; i < allStatuses.length; i++) { int statusNumber = Integer.parseInt(allStatuses[i].getValue()); if(statusNumber >= IssueUtilities.STATUS_ASSIGNED && statusNumber < IssueUtilities.STATUS_CLOSED) { statusVector.addElement(allStatuses[i]); } else if(statusNumber >= IssueUtilities.STATUS_CLOSED && ProjectUtilities.hasOption(ProjectUtilities.OPTION_ALLOW_ASSIGN_TO_CLOSE, project.getOptions()) && UserUtilities.hasPermission(currPermissions, project.getId(), UserUtilities.PERMISSION_CLOSE)) { statusVector.addElement(allStatuses[i]); } } } else if(issue.getStatus() >= IssueUtilities.STATUS_RESOLVED && issue.getStatus() < IssueUtilities.STATUS_CLOSED) { for(int i = 0; i < allStatuses.length; i++) { int statusNumber = Integer.parseInt(allStatuses[i].getValue()); if(statusNumber >= IssueUtilities.STATUS_ASSIGNED && statusNumber < IssueUtilities.STATUS_CLOSED) { statusVector.addElement(allStatuses[i]); } else if(statusNumber >= IssueUtilities.STATUS_CLOSED && UserUtilities.hasPermission(currPermissions, project.getId(), UserUtilities.PERMISSION_CLOSE)) { statusVector.addElement(allStatuses[i]); } } } else if(issue.getStatus() >= IssueUtilities.STATUS_CLOSED) { for(int i = 0; i < allStatuses.length; i++) { int statusNumber = Integer.parseInt(allStatuses[i].getValue()); if((statusNumber >= IssueUtilities.STATUS_ASSIGNED && statusNumber < IssueUtilities.STATUS_RESOLVED) || statusNumber >= IssueUtilities.STATUS_CLOSED) { statusVector.addElement(allStatuses[i]); } } } else { // Can't change } } NameValuePairModel[] statuses = new NameValuePairModel[statusVector.size()]; statusVector.copyInto(statuses); listOptions.put(new Integer(IssueUtilities.FIELD_STATUS), statuses); NameValuePairModel[] severities = IssueUtilities.getSeverities(currLocale); listOptions.put(new Integer(IssueUtilities.FIELD_SEVERITY), severities); NameValuePairModel[] resolutions = IssueUtilities.getResolutions(currLocale); listOptions.put(new Integer(IssueUtilities.FIELD_RESOLUTION), resolutions); ComponentModel[] components = project.getComponents(); Arrays.sort(components, new ComponentModel()); listOptions.put(new Integer(IssueUtilities.FIELD_COMPONENTS), Convert.ComponentsToNVP(components)); VersionModel[] versions = project.getVersions(); Arrays.sort(versions, new VersionModel()); listOptions.put(new Integer(IssueUtilities.FIELD_VERSIONS), Convert.VersionsToNVP(versions)); listOptions.put(new Integer(IssueUtilities.FIELD_TARGET_VERSION), Convert.VersionsToNVP(versions)); CustomFieldModel[] projectFields = project.getCustomFields(); for(int i = 0; i < projectFields.length; i++) { if(projectFields[i].getFieldType() == CustomFieldUtilities.TYPE_LIST) { projectFields[i].setLabels(currLocale); listOptions.put(projectFields[i].getId(), Convert.CustomFieldOptionsToNVP(projectFields[i].getOptions())); } } DynaValidatorForm issueForm = (DynaValidatorForm) form; if(issueForm == null) { issueForm = new IssueForm(); } issueForm.set("id", issue.getId()); issueForm.set("projectId", issue.getProjectId()); issueForm.set("prevStatus", new Integer(issue.getStatus())); issueForm.set("caller", request.getParameter("caller")); issueForm.set("description", HTMLUtilities.handleQuotes(issue.getDescription())); issueForm.set("status", new Integer(issue.getStatus())); if(! ProjectUtilities.hasOption(ProjectUtilities.OPTION_PREDEFINED_RESOLUTIONS, project.getOptions())) { try { issue.setResolution(IssueUtilities.checkResolutionName(issue.getResolution(), currLocale)); } catch(MissingResourceException mre) { } catch(NumberFormatException nfe) { } } issueForm.set("resolution", HTMLUtilities.handleQuotes(issue.getResolution())); issueForm.set("severity", new Integer(issue.getSeverity())); issueForm.set("targetVersion", (issue.getTargetVersionId() == null ? new Integer(-1) : issue.getTargetVersionId())); issueForm.set("ownerId", (issue.getOwnerId() == null ? new Integer(-1) : issue.getOwnerId())); IssueFieldModel[] fields = issue.getFields(); HashMap customFields = new HashMap(); for(int i = 0; i < fields.length; i++) { customFields.put(fields[i].getCustomFieldId(), fields[i].getValue(currLocale)); } issueForm.set("customFields", customFields); HashSet selectedComponents = ih.getIssueComponentIds(issueId); if(selectedComponents != null) { Integer[] componentIds = new Integer[selectedComponents.size()]; int i = 0; for(Iterator iter = selectedComponents.iterator(); iter.hasNext(); i++) { componentIds[i] = (Integer) iter.next(); } issueForm.set("components", componentIds); } HashSet selectedVersions = ih.getIssueVersionIds(issueId); if(selectedVersions != null) { Integer[] versionIds = new Integer[selectedVersions.size()]; int i = 0; for(Iterator iter = selectedVersions.iterator(); iter.hasNext(); i++) { versionIds[i] = (Integer) iter.next(); } issueForm.set("versions", versionIds); } ProjectScriptModel[] scripts = project.getScripts(); WorkflowUtilities.ProcessFieldScripts(scripts, WorkflowUtilities.EVENT_FIELD_ONPOPULATE, listOptions, errors, issueForm); WorkflowUtilities.ProcessFieldScripts(scripts, WorkflowUtilities.EVENT_FIELD_ONSETDEFAULT, null, errors, issueForm); if(errors == null || errors.isEmpty()) { Logger.logDebug("Forwarding to edit issue form for issue " + issue.getId()); request.setAttribute("issueForm", issueForm); session.setAttribute(Constants.ISSUE_KEY, issue); session.setAttribute(Constants.LIST_OPTIONS_KEY, listOptions); saveToken(request); return mapping.getInputForward(); } } } } catch(Exception e) { Logger.logError("Exception while creating edit issue form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: WatchIssueAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.project; import java.io.IOException; import java.util.HashMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.models.NotificationModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.NotificationUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class WatchIssueAction extends ITrackerAction { public WatchIssueAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { IssueHandler ih = getITrackerServices().getIssueHandler(); Integer issueId = new Integer((request.getParameter("id") == null ? "-1" : (request.getParameter("id")))); ProjectModel project = ih.getIssueProject(issueId); if(project == null) { return mapping.findForward("unauthorized"); } HttpSession session = request.getSession(true); UserModel currUser = (UserModel) session.getAttribute(Constants.USER_KEY); HashMap userPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); Integer currUserId = currUser.getId(); if(! UserUtilities.hasPermission(userPermissions, project.getId(), UserUtilities.PERMISSION_VIEW_ALL)) { return mapping.findForward("unauthorized"); } NotificationModel model = new NotificationModel(); model.setUserId(currUser.getId()); model.setIssueId(issueId); model.setNotificationRole(NotificationUtilities.ROLE_IP); ih.addIssueNotification(model); String caller = request.getParameter("caller"); if("editissue".equals(caller)) { return new ActionForward(mapping.findForward("editissue").getPath() + "?id=" + issueId); } else if("viewissue".equals(caller)) { return new ActionForward(mapping.findForward("viewissue").getPath() + "?id=" + issueId); } else if("index".equals(caller)) { return mapping.findForward("index"); } else { return new ActionForward(mapping.findForward("listissues").getPath() + "?pid=" + project.getId()); } } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.login.system")); Logger.logError("System Error.", e); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: CreateIssueAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.project; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Locale; import java.util.Vector; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.upload.FormFile; import org.apache.struts.validator.DynaValidatorForm; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.IssueAttachmentModel; import cowsultants.itracker.ejb.client.models.IssueFieldModel; import cowsultants.itracker.ejb.client.models.IssueHistoryModel; import cowsultants.itracker.ejb.client.models.IssueModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.ProjectScriptModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.util.IssueUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.NotificationUtilities; import cowsultants.itracker.ejb.client.util.ProjectUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.ejb.client.util.WorkflowUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.AttachmentUtilities; import cowsultants.itracker.web.util.Constants; public class CreateIssueAction extends ITrackerAction { public CreateIssueAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while creating issue."); return mapping.findForward("listprojects"); } resetToken(request); try { IssueHandler ih = getITrackerServices().getIssueHandler(); ProjectHandler ph = getITrackerServices().getProjectHandler();; HttpSession session = request.getSession(true); UserModel currUser = (UserModel) session.getAttribute(Constants.USER_KEY); HashMap currPermissions = (HashMap) session.getAttribute(Constants.PERMISSIONS_KEY); Locale currLocale = (Locale) session.getAttribute(Constants.LOCALE_KEY); Integer currUserId = currUser.getId(); ProjectModel project = null; Integer projectId = (Integer) PropertyUtils.getSimpleProperty(form, "projectId"); if(projectId == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else { project = ph.getProject(projectId); } if(errors.isEmpty() && project == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidproject")); } else if(errors.isEmpty() && project.getStatus() != ProjectUtilities.STATUS_ACTIVE) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.projectlocked")); } else if(! UserUtilities.hasPermission(currPermissions, projectId, UserUtilities.PERMISSION_CREATE)) { return mapping.findForward("unauthorized"); } else { ProjectScriptModel[] scripts = project.getScripts(); WorkflowUtilities.ProcessFieldScripts(scripts, WorkflowUtilities.EVENT_FIELD_ONPRESUBMIT, null, errors, (DynaValidatorForm) form); IssueModel issue = new IssueModel(); issue.setDescription((String) PropertyUtils.getSimpleProperty(form, "description")); issue.setSeverity(((Integer) PropertyUtils.getSimpleProperty(form, "severity")).intValue()); issue.setStatus(IssueUtilities.STATUS_NEW); Integer creator = currUserId; // TODO temporarily disabled creating issues as another user /*if(UserUtilities.hasPermission(currPermissions, projectId, UserUtilities.PERMISSION_CREATE_OTHERS)) { creator = (Integer) PropertyUtils.getSimpleProperty(form, "creatorId"); Logger.logDebug("New issue creator set to " + creator + ". Issue created by " + currUserId); }*/ issue = ih.createIssue(issue, projectId, (creator == null ? currUserId : creator), currUserId); if(issue != null) { Integer newOwner = (Integer) PropertyUtils.getSimpleProperty(form, "ownerId"); if(newOwner != null && newOwner.intValue() >= 0) { if(UserUtilities.hasPermission(currPermissions, UserUtilities.PERMISSION_ASSIGN_OTHERS) || (UserUtilities.hasPermission(currPermissions, UserUtilities.PERMISSION_ASSIGN_SELF) && currUserId.equals(newOwner))) { ih.assignIssue(issue.getId(), newOwner, currUserId); } } IssueFieldModel[] issueFields = new IssueFieldModel[0]; HashMap customFields = (HashMap) PropertyUtils.getSimpleProperty(form, "customFields"); if(customFields != null && customFields.size() > 0) { Vector issueFieldsVector = new Vector(); for(Iterator iter = customFields.keySet().iterator(); iter.hasNext(); ) { try { Integer fieldId = new Integer((String) iter.next()); CustomFieldModel field = IssueUtilities.getCustomField(fieldId); String fieldValue = (String) PropertyUtils.getMappedProperty(form, "customFields(" + fieldId + ")"); if(fieldValue != null && ! fieldValue.equals("")) { IssueFieldModel issueField = new IssueFieldModel(field, issue.getId()); issueField.setValue(fieldValue, currLocale); issueFieldsVector.add(issueField); } } catch(Exception e) { } } issueFields = new IssueFieldModel[issueFieldsVector.size()]; issueFieldsVector.copyInto(issueFields); } ih.setIssueFields(issue.getId(), issueFields); IssueHistoryModel issueHistory = new IssueHistoryModel((String) PropertyUtils.getSimpleProperty(form, "history"), IssueUtilities.HISTORY_STATUS_AVAILABLE, issue.getId(), creator); ih.addIssueHistory(issueHistory); HashSet components = new HashSet(); Integer[] componentIds = (Integer[]) PropertyUtils.getSimpleProperty(form, "components"); if(componentIds != null) { for(int i = 0; i < componentIds.length; i++) { components.add(componentIds[i]); } ih.setIssueComponents(issue.getId(), components, creator); } HashSet versions = new HashSet(); Integer[] versionIds = (Integer[]) PropertyUtils.getSimpleProperty(form, "versions"); if(versionIds != null) { for(int i = 0; i < versionIds.length; i++) { versions.add(versionIds[i]); } ih.setIssueVersions(issue.getId(), versions, creator); } if(! ProjectUtilities.hasOption(ProjectUtilities.OPTION_NO_ATTACHMENTS, project.getOptions())) { FormFile file = (FormFile) PropertyUtils.getSimpleProperty(form, "attachment"); if(file != null && ! "".equals(file.getFileName())) { String origFileName = file.getFileName(); if(AttachmentUtilities.checkFile(file, this.getITrackerServices())) { int lastSlash = Math.max(origFileName.lastIndexOf('/'), origFileName.lastIndexOf('\\')); if(lastSlash > -1) { origFileName = origFileName.substring(lastSlash + 1); } IssueAttachmentModel attachmentModel = new IssueAttachmentModel(origFileName, file.getContentType(), (String) PropertyUtils.getSimpleProperty(form, "attachmentDescription"), file.getFileSize(), issue.getId(), creator); ih.addIssueAttachment(attachmentModel, file.getFileData()); } } } try { Integer relatedIssueId = (Integer) PropertyUtils.getSimpleProperty(form, "relatedIssueId"); Integer relationType = (Integer) PropertyUtils.getSimpleProperty(form, "relationType"); if(relatedIssueId != null && relatedIssueId.intValue() > 0 && relationType != null && relationType.intValue() > 0) { IssueModel relatedIssue = ih.getIssue(relatedIssueId); if(relatedIssue == null) { Logger.logDebug("Unknown relation issue, relation not created."); } else if(relatedIssue.getProjectId() == null || ! IssueUtilities.canEditIssue(relatedIssue, currUserId, currPermissions)) { Logger.logInfo("User not authorized to add issue r... [truncated message content] |
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/configuration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/admin/configuration Added Files: Tag: itrackerhibernate EditCustomFieldFormAction.java EditCustomFieldAction.java RemoveConfigurationItemAction.java RemoveCustomFieldAction.java ImportDataProcessAction.java OrderCustomFieldValueAction.java EditConfigurationFormAction.java ImportDataVerifyAction.java ImportDataFormAction.java OrderConfigurationItemAction.java EditConfigurationAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: ImportDataProcessAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.configuration; import java.io.IOException; import java.util.HashSet; import javax.naming.InitialContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.ComponentModel; import cowsultants.itracker.ejb.client.models.ConfigurationModel; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.GenericModel; import cowsultants.itracker.ejb.client.models.ImportDataModel; import cowsultants.itracker.ejb.client.models.IssueAttachmentModel; import cowsultants.itracker.ejb.client.models.IssueFieldModel; import cowsultants.itracker.ejb.client.models.IssueHistoryModel; import cowsultants.itracker.ejb.client.models.IssueModel; import cowsultants.itracker.ejb.client.models.LanguageModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.models.VersionModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.CustomFieldUtilities; import cowsultants.itracker.ejb.client.util.ImportExportUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class ImportDataProcessAction extends ITrackerAction { public ImportDataProcessAction () { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { InitialContext ic = new InitialContext(); HttpSession session = request.getSession(true); UserModel importer = (UserModel) session.getAttribute(Constants.USER_KEY); if(importer == null) { return mapping.findForward("unauthorized"); } ImportDataModel model = (ImportDataModel) session.getAttribute(Constants.IMPORT_DATA_KEY); GenericModel[] importData = model.getData(); Logger.logDebug("Importing configuration data."); createConfig(model, importer, ic); Logger.logDebug("Importing user data."); createUsers(model, importer, ic); Logger.logDebug("Importing project data."); createProjects(model, importer, ic); Logger.logDebug("Importing issue data."); createIssues(model, importer, ic); Logger.logDebug("Import complete."); } catch(Exception e) { Logger.logError("Exception while importing data.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); return mapping.findForward("error"); } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.importexport.importcomplete")); saveErrors(request, errors); } return mapping.findForward("adminindex"); } private boolean createConfig(ImportDataModel model, UserModel importer, InitialContext ic) { try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); GenericModel[] importData = model.getData(); for(int i = 0; i < importData.length; i++) { if(importData[i] instanceof ConfigurationModel && ! model.getExistingModel(i)) { ConfigurationModel configItem = (ConfigurationModel) importData[i]; ConfigurationModel newConfigItem = sc.createConfigurationItem(configItem); configItem.setId(newConfigItem.getId()); // Now add a new language key String key = SystemConfigurationUtilities.getLanguageKey(configItem); sc.updateLanguageItem(new LanguageModel(ImportExportUtilities.EXPORT_LOCALE_STRING, key, configItem.getName())); ITrackerResources.clearKeyFromBundles(key, true); } else if(importData[i] instanceof CustomFieldModel && ! model.getExistingModel(i)) { CustomFieldModel customField = (CustomFieldModel) importData[i]; CustomFieldModel newCustomField = sc.createCustomField(customField); customField.setId(newCustomField.getId()); // Now add new language keys. One for the field and then add one for for // each option that exists. String key = CustomFieldUtilities.getCustomFieldLabelKey(customField.getId()); sc.updateLanguageItem(new LanguageModel(ImportExportUtilities.EXPORT_LOCALE_STRING, key, customField.getName())); ITrackerResources.clearKeyFromBundles(key, true); if(customField.getFieldType() == CustomFieldUtilities.TYPE_LIST) { for(int j = 0; j < customField.getOptions().length; j++) { String optionKey = CustomFieldUtilities.getCustomFieldOptionLabelKey(customField.getId(), customField.getOptions()[j].getId()); sc.updateLanguageItem(new LanguageModel(ImportExportUtilities.EXPORT_LOCALE_STRING, optionKey, customField.getOptions()[j].getName())); ITrackerResources.clearKeyFromBundles(optionKey, true); } } } } sc.resetConfigurationCache(); } catch(Exception e) { return false; } return true; } private boolean createUsers(ImportDataModel model, UserModel importer, InitialContext ic) { try { UserHandler uh = getITrackerServices().getUserHandler(); GenericModel[] importData = model.getData(); for(int i = 0; i < importData.length; i++) { if(importData[i] instanceof UserModel && ! model.getExistingModel(i)) { UserModel user = (UserModel) importData[i]; user.setRegistrationType(UserUtilities.REGISTRATION_TYPE_IMPORT); if(model.getCreatePasswords()) { user.setPassword(UserUtilities.encryptPassword(user.getLogin())); } user.setLogin(user.getLogin()); UserModel newUser = uh.createUser(user); user.setId(newUser.getId()); } } } catch(Exception e) { return false; } return true; } private boolean createProjects(ImportDataModel model, UserModel importer, InitialContext ic) { try { ProjectHandler ph = getITrackerServices().getProjectHandler(); GenericModel[] importData = model.getData(); for(int i = 0; i < importData.length; i++) { if(importData[i] instanceof ProjectModel && ! model.getExistingModel(i)) { ProjectModel project = (ProjectModel) importData[i]; ProjectModel newProject = ph.createProject(project); project.setId(newProject.getId()); HashSet owners = new HashSet(); for(int j = 0; j < project.getOwners().length; j++) { owners.add(project.getOwners()[j].getId()); } ph.setProjectOwners(project, owners); HashSet fields = new HashSet(); for(int j = 0; j < project.getCustomFields().length; j++) { fields.add(project.getCustomFields()[j].getId()); } ph.setProjectFields(project, fields); ComponentModel[] components = project.getComponents(); for(int j = 0; j < components.length; j++) { ComponentModel newComponent = ph.addProjectComponent(project.getId(), components[j]); components[j].setId(newComponent.getId()); } VersionModel[] versions = project.getVersions(); for(int j = 0; j < versions.length; j++) { VersionModel newVersion = ph.addProjectVersion(project.getId(), versions[j]); versions[j].setId(newVersion.getId()); } } } } catch(Exception e) { return false; } return true; } private boolean createIssues(ImportDataModel model, UserModel importer, InitialContext ic) { try { IssueHandler ih = getITrackerServices().getIssueHandler(); GenericModel[] importData = model.getData(); for(int i = 0; i < importData.length; i++) { if(importData[i] instanceof IssueModel && ! model.getExistingModel(i)) { IssueModel issue = (IssueModel) importData[i]; IssueModel newIssue = ih.createIssue(issue, issue.getProjectId(), issue.getCreatorId(), importer.getId()); issue.setId(newIssue.getId()); // Assign the issue if(issue.getOwner() != null) { ih.assignIssue(issue.getId(), issue.getOwnerId(), importer.getId()); } // Now set Issue Custom Fields IssueFieldModel[] fields = issue.getFields(); if(fields.length > 0) { for(int j = 0; j < fields.length; j++) { fields[j].setIssueId(issue.getId()); } ih.setIssueFields(issue.getId(), issue.getFields()); } // Now add all the issue history IssueHistoryModel[] history = issue.getHistory(); if(history.length > 0) { for(int j = 0; j < history.length; j++) { history[j].setIssueId(issue.getId()); ih.addIssueHistory(history[j]); } } // Now add components and versions HashSet components = new HashSet(); ComponentModel[] componentsArray = issue.getComponents(); if(componentsArray.length > 0) { for(int j = 0; j < componentsArray.length; j++) { components.add(componentsArray[j].getId()); } ih.setIssueComponents(issue.getId(), components, importer.getId()); } HashSet versions = new HashSet(); VersionModel[] versionsArray = issue.getVersions(); if(versionsArray.length > 0) { for(int j = 0; j < versionsArray.length; j++) { versions.add(versionsArray[j].getId()); } ih.setIssueVersions(issue.getId(), versions, importer.getId()); } // Now add any attachments IssueAttachmentModel[] attachments = issue.getAttachments(); if(attachments.length > 0) { for(int j = 0; j < history.length; j++) { attachments[j].setIssueId(issue.getId()); ih.addIssueAttachment(attachments[j], null); } } } } } catch(Exception e) { return false; } return true; } private void printArray(GenericModel[] models) { for(int i = 0; i < models.length; i++) { Logger.logDebug(i + ") " + models[i].toString()); } } } --- NEW FILE: EditCustomFieldAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.configuration; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.exceptions.SystemConfigurationException; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.LanguageModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.CustomFieldUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class EditCustomFieldAction extends ITrackerAction { public EditCustomFieldAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing configuration."); return mapping.findForward("listconfiguration"); } resetToken(request); try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); String action = (String) PropertyUtils.getSimpleProperty(form, "action"); if(action == null) { return mapping.findForward("listconfiguration"); } CustomFieldModel customField = null; if("create".equals(action)) { customField = new CustomFieldModel(); customField.setFieldType(((Integer) PropertyUtils.getSimpleProperty(form, "fieldType")).intValue()); customField.setRequired(("true".equals((String) PropertyUtils.getSimpleProperty(form, "required")) ? true : false)); customField.setSortOptionsByName(("true".equals((String) PropertyUtils.getSimpleProperty(form, "sortOptionsByName")) ? true : false)); customField.setDateFormat((String) PropertyUtils.getSimpleProperty(form, "dateFormat")); customField = sc.createCustomField(customField); } else if("update".equals(action)) { Integer id = (Integer) PropertyUtils.getSimpleProperty(form, "id"); customField = sc.getCustomField(id); if(customField == null) { throw new SystemConfigurationException("Invalid custom field id " + id); } customField.setFieldType(((Integer) PropertyUtils.getSimpleProperty(form, "fieldType")).intValue()); customField.setRequired(("true".equals((String) PropertyUtils.getSimpleProperty(form, "required")) ? true : false)); customField.setSortOptionsByName(("true".equals((String) PropertyUtils.getSimpleProperty(form, "sortOptionsByName")) ? true : false)); customField.setDateFormat((String) PropertyUtils.getSimpleProperty(form, "dateFormat")); // Set options to null so they don't get updated. customField.setOptions(null); customField = sc.updateCustomField(customField); } else { throw new SystemConfigurationException("Invalid action " + action + " while editing custom field."); } if(customField == null) { throw new SystemConfigurationException("Unable to create new custom field model."); } HashMap translations = (HashMap) PropertyUtils.getSimpleProperty(form, "translations"); String key = CustomFieldUtilities.getCustomFieldLabelKey(customField.getId()); Logger.logDebug("Processing label translations for custom field " + customField.getId() + " with key " + key); if(translations != null && key != null && ! key.equals("")) { for(Iterator iter = translations.keySet().iterator(); iter.hasNext(); ) { String locale = (String) iter.next(); if(locale != null) { String translation = (String) translations.get(locale); if(translation != null && ! translation.equals("")) { Logger.logDebug("Adding new translation for locale " + locale + " for " + customField); sc.updateLanguageItem(new LanguageModel(locale, key, translation)); } } } String baseValue = (String) translations.get(ITrackerResources.BASE_LOCALE); sc.updateLanguageItem(new LanguageModel(ITrackerResources.BASE_LOCALE, key, baseValue)); ITrackerResources.clearKeyFromBundles(key, true); } // Now reset the cached versions in IssueUtilities sc.resetConfigurationCache(SystemConfigurationUtilities.TYPE_CUSTOMFIELD); return mapping.findForward("listconfiguration"); } catch(SystemConfigurationException sce) { Logger.logError("Exception processing form data: " + sce.getMessage(), sce); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(sce.getKey())); } catch(Exception e) { Logger.logError("Exception processing form data", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } return mapping.findForward("error"); } } --- NEW FILE: ImportDataVerifyAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.configuration; import java.io.IOException; import javax.naming.InitialContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.upload.FormFile; import cowsultants.itracker.ejb.client.exceptions.ImportExportException; import cowsultants.itracker.ejb.client.interfaces.ProjectHandler; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.ConfigurationModel; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.GenericModel; import cowsultants.itracker.ejb.client.models.ImportDataModel; import cowsultants.itracker.ejb.client.models.IssueModel; import cowsultants.itracker.ejb.client.models.ProjectModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.ImportExportUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; /** * Performs a verification on the import data to ensure that it contains no errors, * applies any import options, and also updates the data to reuse any current system * data if needed. It also collects statistics on the import data to display to the user * before the import is actually processed. * <br><br> * When reusing existing system data. The following criteria is used to determine if * a piece of data matches an existing system resource:<br> * User - the login<br> * Project - the project name<br> * Status, Severity, Resolution - the name of the item as defined in the language root/base locale<br> * Custom Fields - the label name of the custom field as defined in the language root/base locale<br> */ public class ImportDataVerifyAction extends ITrackerAction { private static final int UPDATE_STATUS = 1; private static final int UPDATE_SEVERITY = 2; private static final int UPDATE_RESOLUTION = 3; public ImportDataVerifyAction () { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { FormFile file = (FormFile) PropertyUtils.getSimpleProperty(form, "importFile"); String xmlData = new String(file.getFileData()); ImportDataModel model = new ImportDataModel(); GenericModel[] importData = ImportExportUtilities.importIssues(xmlData); boolean[] existingModel = new boolean[importData.length]; model.setReuseUsers((Boolean) PropertyUtils.getSimpleProperty(form, "optionreuseusers")); model.setReuseProjects((Boolean) PropertyUtils.getSimpleProperty(form, "optionreuseprojects")); model.setReuseConfig((Boolean) PropertyUtils.getSimpleProperty(form, "optionreuseconfig")); model.setCreatePasswords((Boolean) PropertyUtils.getSimpleProperty(form, "optioncreatepasswords")); model.setData(importData, existingModel); InitialContext ic = new InitialContext(); checkConfig(model, ic); Logger.logDebug(model.toString()); checkUsers(model, ic); Logger.logDebug(model.toString()); checkProjects(model, ic); Logger.logDebug(model.toString()); checkIssues(model, ic); Logger.logDebug(model.toString()); HttpSession session = request.getSession(true); session.setAttribute(Constants.IMPORT_DATA_KEY, model); } catch(ImportExportException iee) { if(iee.getType() == ImportExportException.TYPE_INVALID_LOGINS) { Logger.logError("Invalid logins found while verifying import data."); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.importexport.invalidlogins", iee.getMessage())); } else if(iee.getType() == ImportExportException.TYPE_INVALID_STATUS) { Logger.logError("Invalid status found while verifying import data."); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.importexport.invalidstatus", iee.getMessage())); } else { Logger.logError("Exception while verifying import data.", iee); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } } catch(Exception e) { Logger.logError("Exception while verifying import data.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } if(! errors.isEmpty()) { saveErrors(request, errors); return mapping.getInputForward(); } return mapping.findForward("importdataverify"); } private void checkConfig(ImportDataModel model, InitialContext ic) throws ImportExportException { try { int maxSeverityValue = 1; int maxResolutionValue = 1; SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); ConfigurationModel[] statuses = sc.getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_STATUS, ImportExportUtilities.EXPORT_LOCALE); ConfigurationModel[] severities = sc.getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_SEVERITY, ImportExportUtilities.EXPORT_LOCALE); ConfigurationModel[] resolutions = sc.getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_RESOLUTION, ImportExportUtilities.EXPORT_LOCALE); CustomFieldModel[] fields = sc.getCustomFields(ImportExportUtilities.EXPORT_LOCALE); for(int i = 0; i < severities.length; i++) { maxSeverityValue = Math.max(maxSeverityValue, Integer.parseInt(severities[i].getValue())); } for(int i = 0; i < resolutions.length; i++) { maxResolutionValue = Math.max(maxResolutionValue, Integer.parseInt(resolutions[i].getValue())); } GenericModel[] importData = model.getData(); for(int i = 0; i < importData.length; i++) { if(importData[i] instanceof ConfigurationModel) { // Need to check to see if it finds a matching name. If so change value. // For status, if it finds a matching value but not name, this is an error. // Otherwise, just change the value for the resolution and severity. Then iterate // through the issues and update the old value to the new one since they are all stored // as strings/ints, not the id to the config item. ConfigurationModel configItem = (ConfigurationModel) importData[i]; if(configItem.getType() == SystemConfigurationUtilities.TYPE_STATUS) { boolean found = false; for(int j = 0; j < statuses.length; j++) { if(model.getReuseConfig() && statuses[j].getName().equalsIgnoreCase(configItem.getName())) { // Matching status, update issues updateIssues(importData, UPDATE_STATUS, configItem.getValue(), statuses[j].getValue()); model.setExistingModel(i, true); model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_STATUSES, ImportExportUtilities.IMPORT_STAT_REUSED); found = true; break; } else if(statuses[j].getValue().equalsIgnoreCase(configItem.getValue())) { // Found a matching status value, and the name didn't match throw new ImportExportException(configItem.getValue(), ImportExportException.TYPE_INVALID_STATUS); } } if(! found) { model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_STATUSES, ImportExportUtilities.IMPORT_STAT_NEW); } } else if(configItem.getType() == SystemConfigurationUtilities.TYPE_SEVERITY) { boolean found = false; if(model.getReuseConfig()) { for(int j = 0; j < severities.length; j++) { if(severities[j].getName().equalsIgnoreCase(configItem.getName())) { // Matching severity, update issues updateIssues(importData, UPDATE_SEVERITY, configItem.getValue(), severities[j].getValue()); model.setExistingModel(i, true); model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_SEVERITIES, ImportExportUtilities.IMPORT_STAT_REUSED); found = true; break; } } } if(! found) { updateIssues(importData, UPDATE_SEVERITY, configItem.getValue(), Integer.toString(++maxSeverityValue)); configItem.setValue(Integer.toString(maxSeverityValue)); model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_SEVERITIES, ImportExportUtilities.IMPORT_STAT_NEW); } } else if(configItem.getType() == SystemConfigurationUtilities.TYPE_RESOLUTION) { boolean found = false; if(model.getReuseConfig()) { for(int j = 0; j < resolutions.length; j++) { if(resolutions[j].getName().equalsIgnoreCase(configItem.getName())) { // Matching resolution, update issues updateIssues(importData, UPDATE_RESOLUTION, configItem.getValue(), resolutions[j].getValue()); model.setExistingModel(i, true); model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_RESOLUTIONS, ImportExportUtilities.IMPORT_STAT_REUSED); found = true; break; } } } if(! found) { updateIssues(importData, UPDATE_RESOLUTION, configItem.getValue(), Integer.toString(++maxResolutionValue)); configItem.setValue(Integer.toString(maxResolutionValue)); model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_RESOLUTIONS, ImportExportUtilities.IMPORT_STAT_NEW); } } } else if(importData[i] instanceof CustomFieldModel) { boolean found = false; CustomFieldModel field = (CustomFieldModel) importData[i]; if(model.getReuseFields()) { for(int j = 0; j < fields.length; j++) { if(fields[j].getFieldType() == field.getFieldType() && fields[j].getName().equalsIgnoreCase(field.getName())) { // Matching custom field. Set id, but don't need to update issues // since it contains the customfield model field.setId(fields[j].getId()); model.setExistingModel(i, true); model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_FIELDS, ImportExportUtilities.IMPORT_STAT_REUSED); found = true; break; } } } if(! found) { model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_FIELDS, ImportExportUtilities.IMPORT_STAT_NEW); } } } } catch(ImportExportException iee) { throw iee; } catch(Exception e) { Logger.logError("Error verifiying import data.", e); throw new ImportExportException(e.getMessage()); } } private void checkUsers(ImportDataModel model, InitialContext ic) throws ImportExportException { String invalidLogins = null; try { UserHandler uh = getITrackerServices().getUserHandler(); GenericModel[] importData = model.getData(); for(int i = 0; i < importData.length; i++) { if(importData[i] instanceof UserModel) { UserModel user = (UserModel) importData[i]; UserModel existingUser = uh.getUserByLogin(user.getLogin()); if(existingUser != null) { if(model.getReuseUsers()) { user.setId(existingUser.getId()); model.setExistingModel(i, true); model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_USERS, ImportExportUtilities.IMPORT_STAT_REUSED); Logger.logDebug("Reusing existing user " + user.getLogin() + "(" + user.getId() + ") during import."); } else { Logger.logDebug("Existing user " + existingUser.getLogin() + "(" + existingUser.getId() + ") during import. Adding to invalid login list."); invalidLogins = (invalidLogins == null ? existingUser.getLogin() : invalidLogins + ", " + existingUser.getLogin()); } } else { model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_USERS, ImportExportUtilities.IMPORT_STAT_NEW); } } } } catch(Exception e) { Logger.logError("Error verifiying import data.", e); throw new ImportExportException(e.getMessage()); } if(invalidLogins != null) { throw new ImportExportException(invalidLogins, ImportExportException.TYPE_INVALID_LOGINS); } } private void checkProjects(ImportDataModel model, InitialContext ic) throws ImportExportException { try { ProjectHandler ph = getITrackerServices().getProjectHandler(); ProjectModel[] existingProjects = ph.getAllProjects(); if(existingProjects.length == 0) { return; } GenericModel[] importData = model.getData(); for(int i = 0; i < importData.length; i++) { if(importData[i] instanceof ProjectModel) { if(! model.getReuseProjects()) { model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_PROJECTS, ImportExportUtilities.IMPORT_STAT_NEW); continue; } ProjectModel project = (ProjectModel) importData[i]; boolean found = false; for(int j = 0; j < existingProjects.length; j++) { Logger.logDebug("Project Name: " + project.getName() + " Existing Project: " + existingProjects[j].getName()); Logger.logDebug("Project Name: " + ITrackerResources.escapeUnicodeString(project.getName(), false) + " Existing Project: " + ITrackerResources.escapeUnicodeString(existingProjects[j].getName(), false)); if(project.getName() != null && project.getName().equalsIgnoreCase(existingProjects[j].getName())) { project.setId(existingProjects[j].getId()); model.setExistingModel(i, true); model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_PROJECTS, ImportExportUtilities.IMPORT_STAT_REUSED); found = true; Logger.logDebug("Reusing existing project " + project.getName() + "(" + project.getId() + ") during import."); break; } } if(! found) { model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_PROJECTS, ImportExportUtilities.IMPORT_STAT_NEW); } } } } catch(Exception e) { Logger.logError("Error verifiying import data.", e); throw new ImportExportException(e.getMessage()); } } private void checkIssues(ImportDataModel model, InitialContext ic) throws ImportExportException { GenericModel[] importData = model.getData(); for(int i = 0; i < importData.length; i++) { if(importData[i] instanceof IssueModel) { model.addVerifyStatistic(ImportExportUtilities.IMPORT_STAT_ISSUES, ImportExportUtilities.IMPORT_STAT_NEW); } } } private void updateIssues(GenericModel[] models, int updateType, String currentValue, String newValue) throws ImportExportException { if(models == null || currentValue == null || newValue == null) { return; } try { for(int i = 0; i < models.length; i++) { if(models[i] instanceof IssueModel) { IssueModel issue = (IssueModel) models[i]; if(updateType == UPDATE_STATUS && issue.getStatus() == Integer.parseInt(currentValue)) { issue.setStatus(Integer.parseInt(newValue)); } else if(updateType == UPDATE_SEVERITY && issue.getSeverity() == Integer.parseInt(currentValue)) { issue.setSeverity(Integer.parseInt(newValue)); } else if(updateType == UPDATE_RESOLUTION && currentValue.equalsIgnoreCase(issue.getResolution())) { issue.setResolution(newValue); } } } } catch(Exception e) { Logger.logDebug("Unable to update configuration data in issues.", e); throw new ImportExportException("Unable to update configuration data in issues: " + e.getMessage()); } } } --- NEW FILE: RemoveCustomFieldAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.configuration; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.exceptions.SystemConfigurationException; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.CustomFieldValueModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.CustomFieldUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class RemoveCustomFieldAction extends ITrackerAction { public RemoveCustomFieldAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); Integer valueId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); if(valueId == null || valueId.intValue() <= 0) { throw new SystemConfigurationException("Invalid custom field id."); } CustomFieldModel customField = sc.getCustomField(valueId); if(customField == null) { throw new SystemConfigurationException("Invalid custom field id."); } if(customField.getFieldType() == CustomFieldUtilities.TYPE_LIST) { CustomFieldValueModel[] options = customField.getOptions(); for(int i = 0; i < options.length; i++) { String key = CustomFieldUtilities.getCustomFieldOptionLabelKey(customField.getId(), options[i].getId()); sc.removeCustomFieldValue(options[i].getId()); if(key != null) { sc.removeLanguageKey(key); ITrackerResources.clearKeyFromBundles(key, false); } } } String key = CustomFieldUtilities.getCustomFieldLabelKey(customField.getId()); sc.removeCustomField(customField.getId()); if(key != null) { sc.removeLanguageKey(key); ITrackerResources.clearKeyFromBundles(key, false); } sc.resetConfigurationCache(SystemConfigurationUtilities.TYPE_CUSTOMFIELD); return mapping.findForward("listconfiguration"); } catch(SystemConfigurationException sce) { Logger.logDebug(sce.getMessage(), sce); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidcustomfield")); } catch(NumberFormatException nfe) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidcustomfield")); Logger.logDebug("Invalid custom field id " + request.getParameter("id") + " specified."); } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); Logger.logError("System Error.", e); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: OrderCustomFieldValueAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.configuration; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.exceptions.SystemConfigurationException; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.CustomFieldModel; import cowsultants.itracker.ejb.client.models.CustomFieldValueModel; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; public class OrderCustomFieldValueAction extends ITrackerAction { public OrderCustomFieldValueAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); Integer valueId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); String action = (String) PropertyUtils.getSimpleProperty(form, "action"); if(valueId == null || valueId.intValue() <= 0) { throw new SystemConfigurationException("Invalid custom field value id."); } CustomFieldValueModel customFieldValue = sc.getCustomFieldValue(valueId); if(customFieldValue == null) { throw new SystemConfigurationException("Invalid custom field value id."); } CustomFieldModel customField = sc.getCustomField(customFieldValue.getCustomFieldId()); if(customField == null) { throw new SystemConfigurationException("Invalid custom field id."); } CustomFieldValueModel[] values = customField.getOptions(); for(int i = 0; i < values.length; i++) { if(values[i] != null && valueId.equals(values[i].getId())) { if("up".equalsIgnoreCase(action) && i > 0) { int tempOrder = values[i].getSortOrder(); values[i].setSortOrder(values[i - 1].getSortOrder()); values[i - 1].setSortOrder(tempOrder); values = sc.updateCustomFieldValues(customField.getId(), values); } else if("down".equalsIgnoreCase(action) && i < (values.length - 1)) { int tempOrder = values[i].getSortOrder(); values[i].setSortOrder(values[i + 1].getSortOrder()); values[i + 1].setSortOrder(tempOrder); values = sc.updateCustomFieldValues(customField.getId(), values); } break; } } sc.resetConfigurationCache(SystemConfigurationUtilities.TYPE_CUSTOMFIELD); return new ActionForward(mapping.findForward("editcustomfield").getPath() + "?id=" + customField.getId() + "&action=update"); } catch(SystemConfigurationException nfe) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidcustomfieldvalue")); Logger.logDebug("Invalid custom field value id " + request.getParameter("id") + " specified."); } catch(NumberFormatException nfe) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.invalidcustomfieldvalue")); Logger.logDebug("Invalid custom field value id " + request.getParameter("id") + " specified."); } catch(Exception e) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); Logger.logError("System Error.", e); } if(! errors.isEmpty()) { saveErrors(request, errors); } return mapping.findForward("error"); } } --- NEW FILE: RemoveConfigurationItemAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.admin.configuration; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.beans.entity.IssueActivityBean; import cowsultants.itracker.ejb.client.exceptions.SystemConfigurationException; import cowsultants.itracker.ejb.client.interfaces.IssueHandler; import cowsultants.itracker.ejb.client.interfaces.SystemConfiguration; import cowsultants.itracker.ejb.client.models.ConfigurationModel; import cowsultants.itracker.ejb.client.models.IssueModel; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.IssueUtilities; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.util.Constants; public class RemoveConfigurationItemAction extends ITrackerAction { public RemoveConfigurationItemAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! hasPermission(UserUtilities.PERMISSION_USER_ADMIN, request, response)) { return mapping.findForward("unauthorized"); } try { SystemConfiguration sc = getITrackerServices().getSystemConfiguration(); Integer configId = (Integer) PropertyUtils.getSimpleProperty(form, "id"); if(configId == null || configId.intValue() <= 0) { throw new SystemConfigurationException("Invalid configuration id."); } ConfigurationModel configItem = sc.getConfigurationItem(configId); if(configItem == null) { throw new SystemConfigurationException("Invalid configuration id."); } String key = null; if(configItem.getType() == SystemConfigurationUtilities.TYPE_SEVERITY) { key = ITrackerResources.KEY_BASE_SEVERITY + configItem.getValue(); // Need to promote all issues with the deleted severity. The safest thing to do is // promote them to the next higher severity. try { String currConfigValue = configItem.getValue(); String newConfigValue = null; ConfigurationModel[] configItems = sc.getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_SEVERITY); for(int i = 0; i < configItems.length; i++) { if(configItems[i] != null && configId.equals(configItems[i].getId())) { if(i == 0 && (i + 1) < configItems.length) { newConfigValue = configItems[i + 1].getValue(); break; } else if(i > 0) { newConfigValue = configItems[i - 1].getValue(); break; } } } int currSeverity = Integer.parseInt(currConfigValue); int newSeverity = Integer.parseInt(newConfigValue); Logger.logDebug("Promoting issues in severity " + IssueUtilities.getSeverityName(currSeverity) + " to " + IssueUtilities.getSeverityName(newSeverity)); HttpSession session = request.getSession(true); UserModel currUser = (UserModel) session.getAttribute(Constants.USER_KEY); Integer currUserId = (currUser == null ? new Integer(-1) : currUser.getId()); IssueHandler ih = getITrackerServices().getIssueHandler(); IssueModel[] issues = ih.getIssuesWithSeverity(currSeverity); for(int i = 0; i < issues.length; i++) { if(issues[i] != null) { issues[i].setSeverity(newSeverity); issues[i] = ih.updateIssue(issues[i], currUserId); IssueActivityBean activity = new IssueActivityBean(); activity.setType(IssueUtilities.ACTIVITY_SYSTEM_UPDATE); activity.setDescription(ITrackerResources.getString("itracker.activity.system.severity")); //, issues[i].getId(), currUserId) // TODO: need to fix this - RJST //ih.addIssueActivity(activity); } } } catch(Exception e) { Logger.logDebug("Exception while promoting issues with severity " + configItem.getValue(), e); } } else if(configItem.getType() == SystemConfigurationUtilities.TYPE_STATUS) { key = ITrackerResources.KEY_BASE_STATUS + configItem.getValue(); // Need to demote all issues with the deleted severity. The safest thing to do is // move them down one status to make sure they don't skip something important in any // workflow. try { String currConfigValue = configItem.getValue(); String newConfigValue = null; ConfigurationModel[] configItems = sc.getConfigurationItemsByType(SystemConfigurationUtilities.TYPE_STATUS); for(int i = 0; i < configItems.length; i++) { if(configItems[i] != null && configId.equals(configItems[i].getId())) { if(i == 0 && (i + 1) < configItems.length) { newConfigValue = configItems[i + 1].getValue(); break; } else if(i > 0) { newConfigValue = configItems[i - 1].getValue(); break; } } } int currStatus = Integer.parseInt(currConfigValue); int newStatus = Integer.parseInt(newConfigValue); Logger.logDebug("Promoting issues in status " + IssueUtilities.g... [truncated message content] |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:31
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/preferences In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions/preferences Added Files: Tag: itrackerhibernate EditPreferencesAction.java EditPreferencesFormAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- NEW FILE: EditPreferencesAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.preferences; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.exceptions.AuthenticatorException; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.models.UserPreferencesModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.AuthenticationConstants; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.forms.UserForm; import cowsultants.itracker.web.util.Constants; /** * This class performas an update of the user's profile information based on their input. * Only the users core profile information, password, and preferences are updated, no permissions * can be updated from here. Also each type of information is only updated, if it is allowed * by the current systems plugable authentication. */ public class EditPreferencesAction extends ITrackerAction { public EditPreferencesAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Logger.logDebug("Starting pref mod"); ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } if(! isTokenValid(request)) { Logger.logDebug("Invalid request token while editing user preferences."); return mapping.findForward("index"); } resetToken(request); UserModel user = null; try { UserHandler uh = getITrackerServices().getUserHandler(); HttpSession session = request.getSession(); user = (UserModel) session.getAttribute(Constants.USER_KEY); if(user == null) { return mapping.findForward("login"); } UserModel existingUser = uh.getUser(user.getId()); if(existingUser == null || user.getId().intValue() != existingUser.getId().intValue()) { Logger.logDebug("Unauthorized edit preferences request from " + user.getLogin() + "(" + user.getId() + ") for " + existingUser.getLogin() + "(" + existingUser.getId() + ")"); return mapping.findForward("unauthorized"); } UserForm userForm = (UserForm) form; errors = form.validate(mapping, request); if(errors.isEmpty()) { if(uh.allowPasswordUpdates(existingUser, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB)) { if(userForm.getPassword() != null && userForm.getPassword().trim().length() > 1) { if(userForm.getCurrPassword() == null || "".equals(userForm.getCurrPassword())) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.missingpassword")); } else { try { UserModel passwordCheck = uh.checkLogin(user.getLogin(), userForm.getCurrPassword(), AuthenticationConstants.AUTH_TYPE_PASSWORD_PLAIN, AuthenticationConstants.REQ_SOURCE_WEB); if(passwordCheck == null) { throw new AuthenticatorException(AuthenticatorException.INVALID_DATA); } existingUser.setPassword(UserUtilities.encryptPassword(userForm.getPassword().trim())); } catch(AuthenticatorException ae) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.wrongpassword")); } } } } if(uh.allowProfileUpdates(existingUser, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB)) { existingUser.setFirstName(userForm.getFirstName()); existingUser.setLastName(userForm.getLastName()); existingUser.setEmail(userForm.getEmail()); } } if(errors.isEmpty()) { Logger.logDebug("Passed required checks. Updating user info for " + user.getLogin()); user = uh.updateUser(existingUser); UserPreferencesModel userPrefs = new UserPreferencesModel(); if(uh.allowPreferenceUpdates(existingUser, null, UserUtilities.AUTH_TYPE_UNKNOWN, UserUtilities.REQ_SOURCE_WEB)) { userPrefs.setUserId(existingUser.getId()); userPrefs.setUserLogin(existingUser.getLogin()); userPrefs.setUserLocale(userForm.getUserLocale()); userPrefs.setSaveLogin(("true".equals(userForm.getSaveLogin()) ? true : false)); try { userPrefs.setNumItemsOnIndex(Integer.parseInt(userForm.getNumItemsOnIndex())); } catch(NumberFormatException nfe) { userPrefs.setNumItemsOnIndex(-1); } try { userPrefs.setNumItemsOnIssueList(Integer.parseInt(userForm.getNumItemsOnIssueList())); } catch(NumberFormatException nfe) { userPrefs.setNumItemsOnIssueList(-1); } userPrefs.setShowClosedOnIssueList(("true".equals(userForm.getShowClosedOnIssueList()) ? true : false)); userPrefs.setSortColumnOnIssueList(userForm.getSortColumnOnIssueList()); int hiddenSections = 0; Integer[] hiddenSectionsArray = userForm.getHiddenIndexSections(); if(hiddenSectionsArray != null) { for(int i = 0; i < hiddenSectionsArray.length; i++) { hiddenSections += hiddenSectionsArray[i].intValue(); } } userPrefs.setHiddenIndexSections(hiddenSections); userPrefs.setRememberLastSearch(("true".equals(userForm.getRememberLastSearch()) ? true : false)); userPrefs.setUseTextActions(("true".equals(userForm.getUseTextActions()) ? true : false)); userPrefs = uh.updateUserPreferences(userPrefs); } session.setAttribute(Constants.USER_KEY, existingUser); session.setAttribute(Constants.PREFERENCES_KEY, userPrefs); session.setAttribute(Constants.LOCALE_KEY, ITrackerResources.getLocale(userPrefs.getUserLocale())); session.removeAttribute(Constants.EDIT_USER_KEY); session.removeAttribute(Constants.EDIT_USER_PREFS_KEY); } } catch(Exception e) { e.printStackTrace(); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.save")); } if(! errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return mapping.getInputForward(); } return mapping.findForward("index"); } } --- NEW FILE: EditPreferencesFormAction.java --- /* * This software was designed and created by Jason Carroll. * Copyright (c) 2002, 2003, 2004 Jason Carroll. * The author can be reached at jca...@co... * ITracker website: http://www.cowsultants.com * ITracker forums: http://www.cowsultants.com/phpBB/index.php * * This program is free software; you can redistribute it and/or modify * it only under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package cowsultants.itracker.web.actions.preferences; import java.io.IOException; import java.util.Locale; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import cowsultants.itracker.ejb.client.interfaces.UserHandler; import cowsultants.itracker.ejb.client.models.UserModel; import cowsultants.itracker.ejb.client.models.UserPreferencesModel; import cowsultants.itracker.ejb.client.resources.ITrackerResources; import cowsultants.itracker.ejb.client.util.Logger; import cowsultants.itracker.ejb.client.util.UserUtilities; import cowsultants.itracker.web.actions.notyetsorted.ITrackerAction; import cowsultants.itracker.web.forms.UserForm; import cowsultants.itracker.web.util.Constants; public class EditPreferencesFormAction extends ITrackerAction { public EditPreferencesFormAction() { } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionErrors errors = new ActionErrors(); if(! isLoggedIn(request, response)) { return mapping.findForward("login"); } try { UserHandler uh = getITrackerServices().getUserHandler(); HttpSession session = request.getSession(); UserModel user = (UserModel) session.getAttribute(Constants.USER_KEY); if(user == null) { return mapping.findForward("login"); } UserPreferencesModel userPrefs = uh.getUserPreferencesByUserId(user.getId()); UserForm userForm = (UserForm) form; if(userForm == null) { userForm = new UserForm(); } userForm.setLogin(user.getLogin()); userForm.setEmail(user.getEmail()); userForm.setFirstName(user.getFirstName()); userForm.setLastName(user.getLastName()); Locale userLocale = ITrackerResources.getLocale(userPrefs.getUserLocale()); userForm.setUserLocale((userLocale == null ? ITrackerResources.getDefaultLocale() : userLocale.toString())); userForm.setSaveLogin((userPrefs.getSaveLogin() ? "true" : "false")); userForm.setNumItemsOnIndex((userPrefs.getNumItemsOnIndex() < 1 ? ITrackerResources.getString("itracker.web.generic.all", userLocale) : Integer.toString(userPrefs.getNumItemsOnIndex()))); userForm.setNumItemsOnIssueList((userPrefs.getNumItemsOnIssueList() < 1 ? ITrackerResources.getString("itracker.web.generic.all", userLocale) : Integer.toString(userPrefs.getNumItemsOnIssueList()))); userForm.setShowClosedOnIssueList((userPrefs.getShowClosedOnIssueList() ? "true" : "false")); userForm.setSortColumnOnIssueList(userPrefs.getSortColumnOnIssueList()); userForm.setHiddenIndexSections(UserUtilities.getHiddenIndexSections(userPrefs.getHiddenIndexSections())); userForm.setRememberLastSearch((userPrefs.getRememberLastSearch() ? "true" : "false")); userForm.setUseTextActions((userPrefs.getUseTextActions() ? "true" : "false")); request.setAttribute("preferencesForm", userForm); session.setAttribute(Constants.EDIT_USER_KEY, user); session.setAttribute(Constants.EDIT_USER_PREFS_KEY, userPrefs); saveToken(request); return mapping.getInputForward(); } catch(Exception e) { Logger.logError("Exception while creating edit issue form.", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("itracker.web.error.system")); } return mapping.findForward("error"); } } |
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2817/src/cowsultants/itracker/web/actions Removed Files: Tag: itrackerhibernate EditLanguageAction.java RemoveReportAction.java RemoveCustomFieldAction.java EditConfigurationAction.java AddIssueRelationAction.java SelfRegisterFormAction.java EditTaskAction.java CreateLanguageKeyAction.java CreateIssueFormAction.java EditCustomFieldFormAction.java EditCustomFieldValueFormAction.java MoveIssueAction.java RemoveWorkflowScriptAction.java SearchIssuesAction.java SearchIssuesFormAction.java ForgotPasswordAction.java EditWorkflowScriptFormAction.java EditLanguageFormAction.java UnlockUserAction.java EditReportFormAction.java EditCustomFieldAction.java RemoveTaskAction.java RemoveCustomFieldValueAction.java EditProjectFormAction.java SelfRegisterAction.java AssignIssueAction.java LogoffAction.java EditComponentAction.java EditWorkflowScriptAction.java LoginAction.java OrderCustomFieldValueAction.java InitializeLanguagesAction.java OrderConfigurationItemAction.java ImportDataVerifyAction.java EditReportAction.java DisplayReportAction.java ImportDataFormAction.java CreateLanguageKeyFormAction.java EditTaskFormAction.java EditIssueFormAction.java MoveIssueFormAction.java EditVersionFormAction.java EditPreferencesFormAction.java EditProjectAction.java RemoveConfigurationItemAction.java EditComponentFormAction.java ImportDataProcessAction.java RemoveHistoryEntryAction.java EditCustomFieldValueAction.java ExportReportAction.java EditUserFormAction.java ExportAttachmentsAction.java CreateIssueAction.java EditUserAction.java ExportLanguageAction.java EditVersionAction.java RemoveIssueAttachmentAction.java EditIssueAction.java WatchIssueAction.java EditConfigurationFormAction.java EditPreferencesAction.java LockUserAction.java ITrackerAction.java Log Message: Modularizing the Struts actions to be able to get a modular system that is easier to read for everybody. --- EditVersionAction.java DELETED --- --- CreateIssueFormAction.java DELETED --- --- SearchIssuesFormAction.java DELETED --- --- SelfRegisterFormAction.java DELETED --- --- RemoveCustomFieldAction.java DELETED --- --- EditIssueAction.java DELETED --- --- ImportDataProcessAction.java DELETED --- --- RemoveTaskAction.java DELETED --- --- EditConfigurationAction.java DELETED --- --- EditCustomFieldFormAction.java DELETED --- --- RemoveWorkflowScriptAction.java DELETED --- --- MoveIssueFormAction.java DELETED --- --- EditCustomFieldValueAction.java DELETED --- --- EditWorkflowScriptAction.java DELETED --- --- MoveIssueAction.java DELETED --- --- EditPreferencesFormAction.java DELETED --- --- RemoveHistoryEntryAction.java DELETED --- --- ForgotPasswordAction.java DELETED --- --- EditIssueFormAction.java DELETED --- --- WatchIssueAction.java DELETED --- --- ITrackerAction.java DELETED --- --- OrderCustomFieldValueAction.java DELETED --- --- EditLanguageFormAction.java DELETED --- --- EditTaskFormAction.java DELETED --- --- ExportLanguageAction.java DELETED --- --- LogoffAction.java DELETED --- --- EditReportAction.java DELETED --- --- EditComponentAction.java DELETED --- --- EditVersionFormAction.java DELETED --- --- ImportDataFormAction.java DELETED --- --- SearchIssuesAction.java DELETED --- --- OrderConfigurationItemAction.java DELETED --- --- EditLanguageAction.java DELETED --- --- ExportAttachmentsAction.java DELETED --- --- RemoveIssueAttachmentAction.java DELETED --- --- EditProjectAction.java DELETED --- --- EditWorkflowScriptFormAction.java DELETED --- --- UnlockUserAction.java DELETED --- --- EditCustomFieldValueFormAction.java DELETED --- --- ImportDataVerifyAction.java DELETED --- --- CreateIssueAction.java DELETED --- --- EditTaskAction.java DELETED --- --- AddIssueRelationAction.java DELETED --- --- LoginAction.java DELETED --- --- EditConfigurationFormAction.java DELETED --- --- CreateLanguageKeyAction.java DELETED --- --- EditUserAction.java DELETED --- --- DisplayReportAction.java DELETED --- --- AssignIssueAction.java DELETED --- --- RemoveCustomFieldValueAction.java DELETED --- --- EditPreferencesAction.java DELETED --- --- EditProjectFormAction.java DELETED --- --- ExportReportAction.java DELETED --- --- EditComponentFormAction.java DELETED --- --- EditCustomFieldAction.java DELETED --- --- SelfRegisterAction.java DELETED --- --- LockUserAction.java DELETED --- --- CreateLanguageKeyFormAction.java DELETED --- --- RemoveConfigurationItemAction.java DELETED --- --- EditReportFormAction.java DELETED --- --- EditUserFormAction.java DELETED --- --- InitializeLanguagesAction.java DELETED --- --- RemoveReportAction.java DELETED --- |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:13
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/language In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703/src/cowsultants/itracker/web/actions/admin/language Log Message: Directory /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/language added to the repository |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:09
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/preferences In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703/src/cowsultants/itracker/web/actions/preferences Log Message: Directory /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/preferences added to the repository --> Using per-directory sticky tag `itrackerhibernate' |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:09
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/project In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703/src/cowsultants/itracker/web/actions/project Log Message: Directory /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/project added to the repository --> Using per-directory sticky tag `itrackerhibernate' |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:08
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703/src/cowsultants/itracker/web/actions/admin/user Log Message: Directory /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/user added to the repository |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:07
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/scheduler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703/src/cowsultants/itracker/web/actions/admin/scheduler Log Message: Directory /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/admin/scheduler added to the repository |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:07
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/notyetsorted In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703/src/cowsultants/itracker/web/actions/notyetsorted Log Message: Directory /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/notyetsorted added to the repository --> Using per-directory sticky tag `itrackerhibernate' |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:06
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/issuesearch In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703/src/cowsultants/itracker/web/actions/issuesearch Log Message: Directory /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/issuesearch added to the repository --> Using per-directory sticky tag `itrackerhibernate' |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:06
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/report In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703/src/cowsultants/itracker/web/actions/report Log Message: Directory /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/report added to the repository --> Using per-directory sticky tag `itrackerhibernate' |
|
From: Marky G. <mar...@us...> - 2005-11-27 22:01:06
|
Update of /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703/src/cowsultants/itracker/web/actions/user Log Message: Directory /cvsroot/itracker/itracker/src/cowsultants/itracker/web/actions/user added to the repository --> Using per-directory sticky tag `itrackerhibernate' |