diff options
author | Shawn O. Pearce <sop@google.com> | 2008-12-20 17:48:48 -0800 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2008-12-20 17:48:48 -0800 |
commit | f14a1ded658afedc4f2f98e4d25a1e065fee1d42 (patch) | |
tree | 20e8640a2c2f6e25962807116a440ed07a6e9186 /webapp | |
parent | 91b1f7187a0696e83ef8b6dd3d9c61004beedf13 (diff) |
Switch build system to use Maven 2
This way we can easily depend upon other projects which also use
Maven, without needing to embed all of their dependencies directly
within our repository.
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'webapp')
193 files changed, 0 insertions, 14106 deletions
diff --git a/webapp/.classpath b/webapp/.classpath deleted file mode 100644 index 4574cc5a4a..0000000000 --- a/webapp/.classpath +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> - <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/GWT"/> - <classpathentry kind="lib" path="lib/gson.jar" sourcepath="lib/gson_src.zip"/> - <classpathentry kind="lib" path="lib/gwtjsonrpc.jar"/> - <classpathentry kind="lib" path="lib/commons-codec.jar"/> - <classpathentry kind="lib" path="lib/antlr.jar"/> - <classpathentry kind="lib" path="lib/asm.jar"/> - <classpathentry kind="lib" path="lib/gwtorm.jar"/> - <classpathentry kind="lib" path="lib/dyuproject-openid.jar"/> - <classpathentry kind="lib" path="lib/dyuproject-util.jar"/> - <classpathentry kind="lib" path="lib/jetty-util.jar"/> - <classpathentry kind="lib" path="lib/jdbc-h2.jar"/> - <classpathentry kind="lib" path="lib/jdbc-postgresql.jar"/> - <classpathentry kind="lib" path="lib/jgit.jar" sourcepath="lib/jgit_src.zip"/> - <classpathentry kind="lib" path="lib/jsch.jar"/> - <classpathentry kind="output" path="classes"/> -</classpath> diff --git a/webapp/.gitignore b/webapp/.gitignore deleted file mode 100644 index 65a63c1261..0000000000 --- a/webapp/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/classes -/tomcat -/www -/gensrc -/src/GerritServer.properties -/ReviewDb.*.db diff --git a/webapp/.project b/webapp/.project deleted file mode 100644 index ca7d4b5f83..0000000000 --- a/webapp/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>Gerrit-webapp</name> - <comment>GerritUI project</comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/webapp/.settings/org.eclipse.core.resources.prefs b/webapp/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 82eb859e3b..0000000000 --- a/webapp/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Tue Sep 02 16:59:24 PDT 2008 -eclipse.preferences.version=1 -encoding/<project>=UTF-8 diff --git a/webapp/.settings/org.eclipse.core.runtime.prefs b/webapp/.settings/org.eclipse.core.runtime.prefs deleted file mode 100644 index 8667cfd4a3..0000000000 --- a/webapp/.settings/org.eclipse.core.runtime.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Tue Sep 02 16:59:24 PDT 2008 -eclipse.preferences.version=1 -line.separator=\n diff --git a/webapp/.settings/org.eclipse.jdt.core.prefs b/webapp/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index fa64d21829..0000000000 --- a/webapp/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,268 +0,0 @@ -#Thu Sep 04 11:18:51 PDT 2008 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=16 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=0 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=0 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=2 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=true -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=true -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=80 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=3 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=2 -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true diff --git a/webapp/.settings/org.eclipse.jdt.ui.prefs b/webapp/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index f37f6f00a4..0000000000 --- a/webapp/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Sep 02 17:00:18 PDT 2008 -eclipse.preferences.version=1 -formatter_profile=_Google Format -formatter_settings_version=11 -org.eclipse.jdt.ui.ignorelowercasenames=true -org.eclipse.jdt.ui.importorder=com.google;com;junit;net;org;java;javax; -org.eclipse.jdt.ui.ondemandthreshold=99 -org.eclipse.jdt.ui.staticondemandthreshold=99 -org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/> diff --git a/webapp/Gerrit-webapp_Generic.launch b/webapp/Gerrit-webapp_Generic.launch deleted file mode 100644 index 87d45f30ff..0000000000 --- a/webapp/Gerrit-webapp_Generic.launch +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/Gerrit-webapp"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="4"/> -</listAttribute> -<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="Gerrit-webapp" path="1" type="4"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/Gerrit-webapp/src" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="Gerrit-webapp"/> </runtimeClasspathEntry> "/> -</listAttribute> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.GWTShell"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-out www com.google.gerrit.Gerrit/Gerrit.html"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Gerrit-webapp"/> -<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M"/> -</launchConfiguration> diff --git a/webapp/Gerrit-webapp_MacOS.launch b/webapp/Gerrit-webapp_MacOS.launch deleted file mode 100644 index fb18169106..0000000000 --- a/webapp/Gerrit-webapp_MacOS.launch +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/Gerrit-webapp"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="4"/> -</listAttribute> -<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="Gerrit-webapp" path="1" type="4"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/Gerrit-webapp/src" path="3" type="2"/> "/> -<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="Gerrit-webapp"/> </runtimeClasspathEntry> "/> -</listAttribute> -<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.GWTShell"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-out www com.google.gerrit.Gerrit/Gerrit.html"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Gerrit-webapp"/> -<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M -XstartOnFirstThread"/> -</launchConfiguration> diff --git a/webapp/lib/.gitignore b/webapp/lib/.gitignore deleted file mode 100644 index 4bca9f3ee9..0000000000 --- a/webapp/lib/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/*_src.zip -/gwtjsonrpc.jar -/gson.jar -/commons-codec.jar -/antlr.jar -/asm.jar -/gwtorm.jar -/jgit.jar -/jsch.jar -/jdbc-*.jar diff --git a/webapp/lib/dyuproject-openid.jar b/webapp/lib/dyuproject-openid.jar Binary files differdeleted file mode 100644 index 4bda683ec3..0000000000 --- a/webapp/lib/dyuproject-openid.jar +++ /dev/null diff --git a/webapp/lib/dyuproject-util.jar b/webapp/lib/dyuproject-util.jar Binary files differdeleted file mode 100644 index 960316083e..0000000000 --- a/webapp/lib/dyuproject-util.jar +++ /dev/null diff --git a/webapp/lib/jetty-util.jar b/webapp/lib/jetty-util.jar Binary files differdeleted file mode 100644 index 4e827baae2..0000000000 --- a/webapp/lib/jetty-util.jar +++ /dev/null diff --git a/webapp/src/GerritServer.properties_example b/webapp/src/GerritServer.properties_example deleted file mode 100644 index fe10ac62aa..0000000000 --- a/webapp/src/GerritServer.properties_example +++ /dev/null @@ -1,18 +0,0 @@ -# Any properties starting with "database." will be fed to the JDBC driver, -# after removing the "database." prefix. -# -# The following "special" properties are removed from that set: -# -# database.driver : Class name of the driver to load. -# database.url : The connection URL -# - -# H2 -# database.driver = org.h2.Driver -# database.url = jdbc:h2:file:ReviewDb - -# PostgreSQL -# database.driver = org.postgresql.Driver -# database.url = jdbc:postgresql:reviewdb -# database.user = gerrit2 -# database.password = supersecretcode diff --git a/webapp/src/com/google/gerrit/Gerrit.gwt.xml b/webapp/src/com/google/gerrit/Gerrit.gwt.xml deleted file mode 100644 index 680d6386ae..0000000000 --- a/webapp/src/com/google/gerrit/Gerrit.gwt.xml +++ /dev/null @@ -1,28 +0,0 @@ -<module> - <inherits name='com.google.gwt.user.User'/> - <inherits name='com.google.gwt.i18n.I18N'/> - <inherits name='com.google.gwtjsonrpc.GWTJSONRPC'/> - <inherits name='com.google.gwtorm.GWTORM'/> - - <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> - <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> --> - <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> - - <entry-point class='com.google.gerrit.client.Gerrit'/> - <stylesheet src='Gerrit.css' /> - - <servlet path='/Gerrit' - class='com.google.gerrit.server.HostPageServlet'/> - <servlet path='/login' - class='com.google.gerrit.server.LoginServlet'/> - <servlet path='/rpc/AccountService' - class='com.google.gerrit.server.AccountServiceSrv'/> - <servlet path='/rpc/ChangeDetailService' - class='com.google.gerrit.server.ChangeDetailServiceSrv'/> - <servlet path='/rpc/ChangeListService' - class='com.google.gerrit.server.ChangeListServiceSrv'/> - <servlet path='/rpc/PatchDetailService' - class='com.google.gerrit.server.PatchDetailServiceSrv'/> - <servlet path='/rpc/SystemInfoService' - class='com.google.gerrit.server.SystemInfoServiceSrv'/> -</module> diff --git a/webapp/src/com/google/gerrit/client/ErrorDialog.java b/webapp/src/com/google/gerrit/client/ErrorDialog.java deleted file mode 100644 index e99b959613..0000000000 --- a/webapp/src/com/google/gerrit/client/ErrorDialog.java +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client; - -import com.google.gerrit.client.rpc.RpcUtil; -import com.google.gerrit.client.ui.AutoCenterDialogBox; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.ClickListener; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.Widget; -import com.google.gwtjsonrpc.client.RemoteJsonException; - -/** A dialog box showing an error message, when bad things happen. */ -public class ErrorDialog extends AutoCenterDialogBox { - private final FlowPanel body; - - protected ErrorDialog() { - super(/* auto hide */true, /* modal */true); - setText(Gerrit.C.errorDialogTitle()); - - body = new FlowPanel(); - final FlowPanel buttons = new FlowPanel(); - buttons.setStyleName("gerrit-ErrorDialog-Buttons"); - final Button closey = new Button(); - closey.setText(Gerrit.C.errorDialogClose()); - closey.addClickListener(new ClickListener() { - public void onClick(final Widget sender) { - hide(); - } - }); - buttons.add(closey); - - final FlowPanel center = new FlowPanel(); - center.setStyleName("gerrit-ErrorDialog"); - center.add(body); - center.add(buttons); - add(center); - } - - /** Create a dialog box to show a single message string. */ - public ErrorDialog(final String message) { - this(); - body.add(label(message, "gerrit-ErrorDialog-ErrorMessage")); - } - - /** Create a dialog box to nicely format an exception. */ - public ErrorDialog(final Throwable what) { - this(); - - String cn; - if (what instanceof RemoteJsonException) { - cn = RpcUtil.C.errorRemoteJsonException(); - } else { - cn = what.getClass().getName(); - if (cn.startsWith("java.lang.")) { - cn = cn.substring("java.lang.".length()); - } - } - - body.add(label(cn, "gerrit-ErrorDialog-ErrorType")); - body.add(label(what.getMessage(), "gerrit-ErrorDialog-ErrorMessage")); - } - - private static Label label(final String what, final String style) { - final Label r = new Label(what); - r.setStyleName(style); - return r; - } -} diff --git a/webapp/src/com/google/gerrit/client/FormatUtil.java b/webapp/src/com/google/gerrit/client/FormatUtil.java deleted file mode 100644 index ad2be3da53..0000000000 --- a/webapp/src/com/google/gerrit/client/FormatUtil.java +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client; - -import com.google.gerrit.client.data.AccountInfo; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gwt.i18n.client.DateTimeFormat; - -import java.util.Date; - -/** Misc. formatting functions. */ -public class FormatUtil { - private static final DateTimeFormat dtfmt = - DateTimeFormat.getMediumDateTimeFormat(); - - /** Format a date using the locale's medium length format. */ - public static String mediumFormat(final Date dt) { - return dtfmt.format(dt); - } - - /** Format an account as a name and email address. */ - public static String nameEmail(final Account acct) { - return nameEmail(new AccountInfo(acct)); - } - - /** - * Formats an account as an name and an email address. - * <p> - * Example output: - * <ul> - * <li><code>A U. Thor <author@example.com></code>: full populated</li> - * <li><code>A U. Thor (12)</code>: missing email address</li> - * <li><code>Anonymous Coward <author@example.com></code>: missing name</li> - * <li><code>Anonymous Coward (12)</code>: missing name and email address</li> - * </ul> - */ - public static String nameEmail(final AccountInfo acct) { - String name = acct.getFullName(); - if (name == null) { - name = Gerrit.C.anonymousCoward(); - } - - final StringBuilder b = new StringBuilder(); - b.append(name); - if (acct.getPreferredEmail() != null) { - b.append(" <"); - b.append(acct.getPreferredEmail()); - b.append(">"); - } else { - b.append(" ("); - b.append(acct.getId().get()); - b.append(")"); - } - return b.toString(); - } - - /** - * Formats an account name. - * <p> - * If the account has a full name, it returns only the full name. Otherwise it - * returns a longer form that includes the email address. - */ - public static String name(final AccountInfo ai) { - if (ai.getFullName() != null) { - return ai.getFullName(); - } - if (ai.getPreferredEmail() != null) { - return ai.getPreferredEmail(); - } - return nameEmail(ai); - } -} diff --git a/webapp/src/com/google/gerrit/client/Gerrit.java b/webapp/src/com/google/gerrit/client/Gerrit.java deleted file mode 100644 index 98a7f3cfee..0000000000 --- a/webapp/src/com/google/gerrit/client/Gerrit.java +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client; - -import com.google.gerrit.client.data.GerritConfig; -import com.google.gerrit.client.data.SystemInfoService; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.rpc.GerritCallback; -import com.google.gerrit.client.ui.LinkMenuBar; -import com.google.gerrit.client.ui.LinkMenuItem; -import com.google.gerrit.client.ui.Screen; -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.Cookies; -import com.google.gwt.user.client.DeferredCommand; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.WindowResizeListener; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.MenuBar; -import com.google.gwt.user.client.ui.MenuItem; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwtjsonrpc.client.JsonUtil; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.Map.Entry; - -public class Gerrit implements EntryPoint { - /** - * Name of the Cookie our authentication data is stored in. - * <p> - * If this cookie has a value we assume we are signed in. - * - * @see #isSignedIn() - */ - public static final String ACCOUNT_COOKIE = "GerritAccount"; - public static final String OPENIDUSER_COOKIE = "GerritOpenIdUser"; - - public static final GerritConstants C = GWT.create(GerritConstants.class); - public static final GerritIcons ICONS = GWT.create(GerritIcons.class); - public static final SystemInfoService SYSTEM_SVC; - - private static GerritConfig config; - private static Account myAccount; - private static final ArrayList<SignedInListener> signedInListeners = - new ArrayList<SignedInListener>(); - - private static LinkMenuBar menuBar; - private static RootPanel body; - private static Screen currentScreen; - private static final LinkedHashMap<Object, Screen> priorScreens = - new LinkedHashMap<Object, Screen>(10, 0.75f, true) { - @Override - protected boolean removeEldestEntry(final Entry<Object, Screen> eldest) { - return 3 <= size(); - } - }; - - static { - SYSTEM_SVC = GWT.create(SystemInfoService.class); - JsonUtil.bind(SYSTEM_SVC, "rpc/SystemInfoService"); - } - - public static void display(final Screen view) { - if (view.isRequiresSignIn() && !isSignedIn()) { - doSignIn(new AsyncCallback<Object>() { - public void onSuccess(final Object result) { - display(view); - } - - public void onFailure(final Throwable caught) { - } - }); - return; - } - - if (currentScreen != null) { - body.remove(currentScreen); - final Object sct = currentScreen.getScreenCacheToken(); - if (sct != null) { - priorScreens.put(sct, currentScreen); - } - } - - final Screen p = priorScreens.get(view.getScreenCacheToken()); - currentScreen = p != null ? p.recycleThis(view) : view; - body.add(currentScreen); - } - - /** Get the public configuration data used by this Gerrit server. */ - public static GerritConfig getGerritConfig() { - return config; - } - - /** @return the currently signed in user's account data; null if no account */ - public static Account getUserAccount() { - return myAccount; - } - - /** @return true if the user is currently authenticated */ - public static boolean isSignedIn() { - return getUserAccount() != null; - } - - /** - * Sign the user into the application. - * - * @param callback optional; if sign in is successful the onSuccess method - * will be called. - */ - public static void doSignIn(final AsyncCallback<?> callback) { - new SignInDialog(callback).center(); - } - - /** Sign the user out of the application (and discard the cookies). */ - public static void doSignOut() { - myAccount = null; - Cookies.removeCookie(ACCOUNT_COOKIE); - Cookies.removeCookie(OPENIDUSER_COOKIE); - - for (final SignedInListener l : signedInListeners) { - l.onSignOut(); - } - refreshMenuBar(); - - if (currentScreen != null && currentScreen.isRequiresSignIn()) { - History.newItem(Link.ALL); - } - } - - /** Add a listener to monitor sign-in status. */ - public static void addSignedInListener(final SignedInListener l) { - if (!signedInListeners.contains(l)) { - signedInListeners.add(l); - } - } - - /** Remove a previously added sign in listener. */ - public static void removeSignedInListener(final SignedInListener l) { - signedInListeners.remove(l); - } - - public void onModuleLoad() { - final RootPanel topMenu = RootPanel.get("gerrit_topmenu"); - menuBar = new LinkMenuBar(); - topMenu.add(menuBar); - - body = RootPanel.get("gerrit_body"); - body.setHeight(Window.getClientHeight() + "px"); - Window.addWindowResizeListener(new WindowResizeListener() { - public void onWindowResized(final int width, final int height) { - body.setHeight(height + "px"); - } - }); - - JsonUtil.addRpcStatusListener(new RpcStatus(topMenu)); - SYSTEM_SVC.loadGerritConfig(new GerritCallback<GerritConfig>() { - public void onSuccess(final GerritConfig result) { - config = result; - onModuleLoad2(); - } - }); - } - - private void onModuleLoad2() { - if (Cookies.getCookie(ACCOUNT_COOKIE) != null) { - // If the user is likely to already be signed into their account, - // load the account data and update the UI with that. - // - com.google.gerrit.client.account.Util.ACCOUNT_SVC - .myAccount(new AsyncCallback<Account>() { - public void onSuccess(final Account result) { - if (result != null) { - postSignIn(result); - } else { - Cookies.removeCookie(ACCOUNT_COOKIE); - refreshMenuBar(); - } - showInitialScreen(); - } - - public void onFailure(final Throwable caught) { - if (!GWT.isScript() && !GerritCallback.isNotSignedIn(caught)) { - GWT.log("Unexpected failure from validating account", caught); - } - Cookies.removeCookie(ACCOUNT_COOKIE); - refreshMenuBar(); - showInitialScreen(); - } - }); - } else { - refreshMenuBar(); - showInitialScreen(); - } - } - - private void showInitialScreen() { - History.addHistoryListener(new Link()); - if ("".equals(History.getToken())) { - if (isSignedIn()) { - History.newItem(Link.MINE); - } else { - History.newItem(Link.ALL); - } - } else { - History.fireCurrentHistoryState(); - } - } - - /** Hook from {@link SignInDialog} to let us know to refresh the UI. */ - static void postSignIn(final Account acct) { - myAccount = acct; - refreshMenuBar(); - DeferredCommand.addCommand(new Command() { - public void execute() { - for (final SignedInListener l : signedInListeners) { - l.onSignIn(); - } - } - }); - } - - private static void refreshMenuBar() { - menuBar.clearItems(); - - final boolean signedIn = isSignedIn(); - MenuBar m; - - m = new MenuBar(true); - addLink(m, C.menuAllRecentChanges(), Link.ALL); - addLink(m, C.menuAllUnclaimedChanges(), Link.ALL_UNCLAIMED); - menuBar.addItem(C.menuAll(), m); - - if (signedIn) { - m = new MenuBar(true); - addLink(m, C.menuMyChanges(), Link.MINE); - addLink(m, C.menuMyUnclaimedChanges(), Link.MINE_UNCLAIMED); - addLink(m, C.menuMyStarredChanges(), Link.MINE_STARRED); - menuBar.addItem(C.menuMine(), m); - } - - if (signedIn) { - m = new MenuBar(true); - addLink(m, C.menuPeople(), Link.ADMIN_PEOPLE); - addLink(m, C.menuGroups(), Link.ADMIN_GROUPS); - addLink(m, C.menuProjects(), Link.ADMIN_PROJECTS); - menuBar.addItem(C.menuAdmin(), m); - } - - menuBar.lastInGroup(); - menuBar.addGlue(); - - if (signedIn) { - whoAmI(); - menuBar.addItem(new LinkMenuItem(C.menuSettings(), Link.SETTINGS)); - menuBar.addItem(C.menuSignOut(), new Command() { - public void execute() { - doSignOut(); - } - }); - } else { - menuBar.addItem(C.menuSignIn(), new Command() { - public void execute() { - doSignIn(null); - } - }); - } - menuBar.lastInGroup(); - } - - private static void whoAmI() { - final String name = FormatUtil.nameEmail(getUserAccount()); - final MenuItem me = menuBar.addItem(name, (Command) null); - me.removeStyleName("gwt-MenuItem"); - me.addStyleName("gerrit-MenuBarUserName"); - } - - private static void addLink(final MenuBar m, final String text, - final String historyToken) { - m.addItem(new LinkMenuItem(text, historyToken)); - } -} diff --git a/webapp/src/com/google/gerrit/client/GerritConstants.java b/webapp/src/com/google/gerrit/client/GerritConstants.java deleted file mode 100644 index 8021185d6b..0000000000 --- a/webapp/src/com/google/gerrit/client/GerritConstants.java +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client; - -import com.google.gwt.i18n.client.Constants; - -public interface GerritConstants extends Constants { - String menuSignIn(); - String menuSignOut(); - String menuSettings(); - String signInDialogTitle(); - - String errorDialogTitle(); - String errorDialogClose(); - - String notFoundTitle(); - String notFoundBody(); - - String menuAll(); - String menuAllUnclaimedChanges(); - String menuAllRecentChanges(); - - String menuMine(); - String menuMyChanges(); - String menuMyUnclaimedChanges(); - String menuMyStarredChanges(); - - String menuAdmin(); - String menuPeople(); - String menuGroups(); - String menuProjects(); - - String rpcStatusLoading(); - String anonymousCoward(); -} diff --git a/webapp/src/com/google/gerrit/client/GerritConstants.properties b/webapp/src/com/google/gerrit/client/GerritConstants.properties deleted file mode 100644 index 07de1976cd..0000000000 --- a/webapp/src/com/google/gerrit/client/GerritConstants.properties +++ /dev/null @@ -1,27 +0,0 @@ -menuSignIn = Sign In -menuSignOut = Sign Out -menuSettings = Settings -signInDialogTitle = Code Review - Sign In - -errorDialogTitle = Code Review - Unexpected Error -errorDialogClose = Close - -notFoundTitle = Not Found -notFoundBody = The page you requested was not found. - -menuAll = All -menuAllUnclaimedChanges = Unclaimed Changes -menuAllRecentChanges = Recent Changes - -menuMine = Mine -menuMyChanges = My Changes -menuMyUnclaimedChanges = Unclaimed Changes -menuMyStarredChanges = Starred Changes - -menuAdmin = Admin -menuPeople = People -menuGroups = Groups -menuProjects = Projects - -rpcStatusLoading = Loading ... -anonymousCoward = Anonymous Coward diff --git a/webapp/src/com/google/gerrit/client/GerritIcons.java b/webapp/src/com/google/gerrit/client/GerritIcons.java deleted file mode 100644 index fdf359bb39..0000000000 --- a/webapp/src/com/google/gerrit/client/GerritIcons.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client; - -import com.google.gwt.user.client.ui.AbstractImagePrototype; -import com.google.gwt.user.client.ui.ImageBundle; - -public interface GerritIcons extends ImageBundle { - public AbstractImagePrototype arrowRight(); - - public AbstractImagePrototype starOpen(); - - public AbstractImagePrototype starFilled(); - - public AbstractImagePrototype greenCheck(); - - public AbstractImagePrototype redNot(); -} diff --git a/webapp/src/com/google/gerrit/client/Link.java b/webapp/src/com/google/gerrit/client/Link.java deleted file mode 100644 index d31c4dc188..0000000000 --- a/webapp/src/com/google/gerrit/client/Link.java +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client; - -import com.google.gerrit.client.account.AccountSettings; -import com.google.gerrit.client.changes.AccountDashboardScreen; -import com.google.gerrit.client.changes.ChangeScreen; -import com.google.gerrit.client.changes.MineStarredScreen; -import com.google.gerrit.client.data.AccountInfo; -import com.google.gerrit.client.data.ChangeInfo; -import com.google.gerrit.client.patches.PatchSideBySideScreen; -import com.google.gerrit.client.patches.PatchUnifiedScreen; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.rpc.RpcUtil; -import com.google.gerrit.client.ui.Screen; -import com.google.gwt.http.client.URL; -import com.google.gwt.user.client.HistoryListener; - -public class Link implements HistoryListener { - public static final String SETTINGS = "settings"; - - public static final String MINE = "mine"; - public static final String MINE_UNCLAIMED = "mine,unclaimed"; - public static final String MINE_STARRED = "mine,starred"; - - public static final String ALL = "all"; - public static final String ALL_OPEN = "all,open"; - public static final String ALL_UNCLAIMED = "all,unclaimed"; - - public static final String ADMIN_PEOPLE = "admin,people"; - public static final String ADMIN_GROUPS = "admin,groups"; - public static final String ADMIN_PROJECTS = "admin,projects"; - - public static String toChange(final ChangeInfo c) { - return toChange(c.getId()); - } - - public static String toChange(final Change.Id c) { - return "change," + c.get(); - } - - public static String toAccountDashboard(final AccountInfo acct) { - return toAccountDashboard(acct.getId()); - } - - public static String toAccountDashboard(final Account.Id acct) { - return "dashboard," + acct.get(); - } - - public static String toPatchSideBySide(final Patch.Id id) { - return toPatch("sidebyside", id); - } - - public static String toPatchUnified(final Patch.Id id) { - return toPatch("unified", id); - } - - public static String toPatch(final String type, final Patch.Id id) { - final PatchSet.Id psId = id.getParentKey(); - final Change.Id chId = psId.getParentKey(); - final String encp = encodePath(id.get()); - return "patch," + type + "," + chId.get() + "," + psId.get() + "," + encp; - } - - public void onHistoryChanged(final String token) { - final Screen s = select(token); - if (s != null) { - Gerrit.display(s); - } else { - Gerrit.display(new NotFoundScreen()); - } - } - - private Screen select(final String token) { - if (token == null) - return null; - - else if (SETTINGS.equals(token)) - return new AccountSettings(); - - else if (MINE.equals(token)) - return new AccountDashboardScreen(RpcUtil.getAccountId()); - - else if (MINE_STARRED.equals(token)) - return new MineStarredScreen(); - - else if (token.startsWith("patch,sidebyside,")) - return new PatchSideBySideScreen(patchId(token)); - - else if (token.startsWith("patch,unified,")) - return new PatchUnifiedScreen(patchId(token)); - - else if (token.matches("^change,\\d+$")) { - final String id = token.substring("change,".length()); - return new ChangeScreen(Change.Id.fromString(id)); - } - - else if (token.matches("^dashboard,\\d+$")) { - final String id = token.substring("dashboard,".length()); - return new AccountDashboardScreen(new Account.Id(Integer.parseInt(id))); - - } - - return null; - } - - private static Patch.Id patchId(final String token) { - final String[] p = token.split(","); - final Change.Id cId = Change.Id.fromString(p[2]); - final PatchSet.Id psId = new PatchSet.Id(cId, Integer.parseInt(p[3])); - return new Patch.Id(psId, URL.decodeComponent(p[4])); - } - - private static native String encodePath(String path) /*-{ return encodeURIComponent(path).replace(/%20/g, "+").replace(/%2F/g, "/"); }-*/; -} diff --git a/webapp/src/com/google/gerrit/client/NotFoundScreen.java b/webapp/src/com/google/gerrit/client/NotFoundScreen.java deleted file mode 100644 index 1e68a51c9c..0000000000 --- a/webapp/src/com/google/gerrit/client/NotFoundScreen.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.google.gerrit.client; - -import com.google.gerrit.client.ui.Screen; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; - -/** Displays an error message letting the user know the page doesn't exist. */ -public class NotFoundScreen extends Screen { - public NotFoundScreen() { - super(Gerrit.C.notFoundTitle()); - - final Element body = DOM.createDiv(); - DOM.setInnerText(body, Gerrit.C.notFoundBody()); - DOM.appendChild(getElement(), body); - } -} diff --git a/webapp/src/com/google/gerrit/client/RpcStatus.java b/webapp/src/com/google/gerrit/client/RpcStatus.java deleted file mode 100644 index 8343767ffe..0000000000 --- a/webapp/src/com/google/gerrit/client/RpcStatus.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client; - -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.InlineLabel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.Panel; -import com.google.gwtjsonrpc.client.RpcStatusListener; - -class RpcStatus implements RpcStatusListener { - private final Label loading; - private int activeCalls; - - RpcStatus(final Panel p) { - final FlowPanel r = new FlowPanel(); - r.setStyleName("gerrit-RpcStatusPanel"); - p.add(r); - - loading = new InlineLabel(); - loading.setText(Gerrit.C.rpcStatusLoading()); - loading.setStyleName("gerrit-RpcStatus"); - loading.addStyleDependentName("Loading"); - loading.setVisible(false); - r.add(loading); - } - - public void onCallStart() { - if (++activeCalls == 1) { - loading.setVisible(true); - } - } - - public void onCallEnd() { - if (--activeCalls == 0) { - loading.setVisible(false); - } - } -} diff --git a/webapp/src/com/google/gerrit/client/SignInDialog.java b/webapp/src/com/google/gerrit/client/SignInDialog.java deleted file mode 100644 index 0031d8f70c..0000000000 --- a/webapp/src/com/google/gerrit/client/SignInDialog.java +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client; - -import com.google.gerrit.client.account.SignInResult; -import com.google.gerrit.client.account.SignInResult.Status; -import com.google.gerrit.client.rpc.GerritCallback; -import com.google.gerrit.client.ui.AutoCenterDialogBox; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DeferredCommand; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Frame; -import com.google.gwtjsonrpc.client.CallbackHandle; - -/** - * Prompts the user to sign in to their account. - * <p> - * This dialog performs the login within an iframe, allowing normal HTML based - * login pages to be used, including those which aren't served from the same - * server as Gerrit. This is important to permit an OpenID provider or some - * other web based single-sign-on system to be used for authentication. - * <p> - * Post login the iframe content is expected to execute the JavaScript snippet: - * - * <pre> - * $callback(account); - * </pre> - * - * where <code>$callback</code> is the parameter in the initial request and - * <code>account</code> is either <code>!= null</code> (the user is now signed - * in) or <code>null</code> (the sign in was aborted/canceled before it - * completed). - */ -public class SignInDialog extends AutoCenterDialogBox { - private static SignInDialog current; - - private final CallbackHandle<SignInResult> signInCallback; - private final AsyncCallback<?> appCallback; - private final Frame loginFrame; - - /** - * Create a new dialog to handle user sign in. - * - * @param callback optional; onSuccess will be called if sign is completed. - * This can be used to trigger sending an RPC or some other action. - */ - public SignInDialog(final AsyncCallback<?> callback) { - super(/* auto hide */true, /* modal */true); - - signInCallback = - com.google.gerrit.client.account.Util.LOGIN_SVC - .signIn(new GerritCallback<SignInResult>() { - public void onSuccess(final SignInResult result) { - onCallback(result); - } - }); - appCallback = callback; - - loginFrame = new Frame(); - onResize(Window.getClientWidth(), Window.getClientHeight()); - add(loginFrame); - setText(Gerrit.C.signInDialogTitle()); - } - - @Override - protected void onResize(final int width, final int height) { - resizeFrame(width, height); - super.onResize(width, height); - } - - private void resizeFrame(final int width, final int height) { - final int w = Math.min(630, width - 15); - final int h = Math.min(440, height - 60); - loginFrame.setWidth(w + "px"); - loginFrame.setHeight(h + "px"); - } - - @Override - public void show() { - if (current != null) { - current.hide(); - } - - super.show(); - - current = this; - signInCallback.install(); - - final StringBuilder url = new StringBuilder(); - url.append(GWT.getModuleBaseURL()); - url.append("login"); - url.append("?"); - url.append("callback=parent." + signInCallback.getFunctionName()); - loginFrame.setUrl(url.toString()); - } - - @Override - protected void onUnload() { - if (current == this) { - signInCallback.cancel(); - current = null; - } - super.onUnload(); - } - - private void onCallback(final SignInResult result) { - final Status rc = result.getStatus(); - if (rc == SignInResult.Status.CANCEL) { - hide(); - } else if (rc == SignInResult.Status.SUCCESS) { - onSuccess(result); - } else { - GWT.log("Unexpected SignInResult.Status " + rc, null); - } - } - - private void onSuccess(final SignInResult result) { - Gerrit.postSignIn(result.getAccount()); - hide(); - final AsyncCallback<?> ac = appCallback; - if (ac != null) { - DeferredCommand.addCommand(new Command() { - public void execute() { - ac.onSuccess(null); - } - }); - } - } -} diff --git a/webapp/src/com/google/gerrit/client/SignedInListener.java b/webapp/src/com/google/gerrit/client/SignedInListener.java deleted file mode 100644 index 31905e5d03..0000000000 --- a/webapp/src/com/google/gerrit/client/SignedInListener.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client; - -/** Listener to monitor the state of the user's account token. */ -public interface SignedInListener { - /** Invoked after the user has finished sign-in to their account. */ - public void onSignIn(); - - /** Invoked while the user is signing out of their account. */ - public void onSignOut(); -} diff --git a/webapp/src/com/google/gerrit/client/account/AccountConstants.java b/webapp/src/com/google/gerrit/client/account/AccountConstants.java deleted file mode 100644 index 20d3552884..0000000000 --- a/webapp/src/com/google/gerrit/client/account/AccountConstants.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.account; - -import com.google.gwt.i18n.client.Constants; - -public interface AccountConstants extends Constants { - String accountSettingsHeading(); -} diff --git a/webapp/src/com/google/gerrit/client/account/AccountConstants.properties b/webapp/src/com/google/gerrit/client/account/AccountConstants.properties deleted file mode 100644 index a12336d590..0000000000 --- a/webapp/src/com/google/gerrit/client/account/AccountConstants.properties +++ /dev/null @@ -1 +0,0 @@ -accountSettingsHeading = Account Settings diff --git a/webapp/src/com/google/gerrit/client/account/AccountService.java b/webapp/src/com/google/gerrit/client/account/AccountService.java deleted file mode 100644 index 16da26180c..0000000000 --- a/webapp/src/com/google/gerrit/client/account/AccountService.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.account; - -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.rpc.SignInRequired; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtjsonrpc.client.RemoteJsonService; - -public interface AccountService extends RemoteJsonService { - @SignInRequired - void myAccount(AsyncCallback<Account> callback); -} diff --git a/webapp/src/com/google/gerrit/client/account/AccountServiceImpl.java b/webapp/src/com/google/gerrit/client/account/AccountServiceImpl.java deleted file mode 100644 index a2e33e6a7b..0000000000 --- a/webapp/src/com/google/gerrit/client/account/AccountServiceImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.account; - -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gerrit.client.rpc.BaseServiceImplementation; -import com.google.gerrit.client.rpc.RpcUtil; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.SchemaFactory; - -public class AccountServiceImpl extends BaseServiceImplementation implements - AccountService { - public AccountServiceImpl(final SchemaFactory<ReviewDb> rdf) { - super(rdf); - } - - public void myAccount(final AsyncCallback<Account> callback) { - run(callback, new Action<Account>() { - public Account run(ReviewDb db) throws OrmException { - return db.accounts().byId(RpcUtil.getAccountId()); - } - }); - } -} diff --git a/webapp/src/com/google/gerrit/client/account/AccountSettings.java b/webapp/src/com/google/gerrit/client/account/AccountSettings.java deleted file mode 100644 index 6aadf79dd2..0000000000 --- a/webapp/src/com/google/gerrit/client/account/AccountSettings.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.account; - -import com.google.gerrit.client.Link; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.rpc.GerritCallback; -import com.google.gerrit.client.ui.AccountScreen; -import com.google.gwt.core.client.GWT; - -public class AccountSettings extends AccountScreen { - public AccountSettings() { - super(Util.C.accountSettingsHeading()); - } - - @Override - public Object getScreenCacheToken() { - return Link.SETTINGS; - } - - @Override - public void onLoad() { - super.onLoad(); - Util.ACCOUNT_SVC.myAccount(new GerritCallback<Account>() { - public void onSuccess(Account result) { - GWT.log("yay, i am " + result.getPreferredEmail(), null); - GWT.log("created on " + result.getRegisteredOn(), null); - } - }); - } -} diff --git a/webapp/src/com/google/gerrit/client/account/LoginService.java b/webapp/src/com/google/gerrit/client/account/LoginService.java deleted file mode 100644 index 8c89cba9a3..0000000000 --- a/webapp/src/com/google/gerrit/client/account/LoginService.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.account; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtjsonrpc.client.CallbackHandle; -import com.google.gwtjsonrpc.client.RemoteJsonService; - -/** Works with the LoginServlet to connect to accounts. */ -public interface LoginService extends RemoteJsonService { - /** - * Create a callback for LoginServlet to call post sign in. - * <p> - * The LoginResult.getStatus() is {@link SignInResult.Status#CANCEL} is null - * if the sign in was aborted by the user (or failed too many times). - */ - CallbackHandle<SignInResult> signIn(AsyncCallback<SignInResult> c); -} diff --git a/webapp/src/com/google/gerrit/client/account/SignInResult.java b/webapp/src/com/google/gerrit/client/account/SignInResult.java deleted file mode 100644 index b1efe9d3e1..0000000000 --- a/webapp/src/com/google/gerrit/client/account/SignInResult.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.account; - -import com.google.gerrit.client.reviewdb.Account; - -/** Result from a sign-in attempt via the LoginServlet. */ -public class SignInResult { - public static enum Status { - /** The user canceled the sign-in and wasn't able to complete it */ - @SuppressWarnings("hiding") - CANCEL, - - /** The sign-in was successful and we have the account data */ - SUCCESS, - } - - /** Singleton representing {@link Status#CANCEL}. */ - public static final SignInResult CANCEL = - new SignInResult(Status.CANCEL, null); - - protected Status status; - protected Account account; - - protected SignInResult() { - } - - /** Create a new result. */ - public SignInResult(final Status s, final Account a) { - status = s; - account = a; - } - - /** The status of the login attempt */ - public Status getStatus() { - return status; - } - - /** The account data; only if {@link #getStatus()} is {@link Status#SUCCESS} */ - public Account getAccount() { - return account; - } -} diff --git a/webapp/src/com/google/gerrit/client/account/Util.java b/webapp/src/com/google/gerrit/client/account/Util.java deleted file mode 100644 index f36ba2ea8b..0000000000 --- a/webapp/src/com/google/gerrit/client/account/Util.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.account; - -import com.google.gwt.core.client.GWT; -import com.google.gwtjsonrpc.client.JsonUtil; - -public class Util { - public static final AccountConstants C = GWT.create(AccountConstants.class); - public static final AccountService ACCOUNT_SVC; - public static final LoginService LOGIN_SVC; - - static { - ACCOUNT_SVC = GWT.create(AccountService.class); - JsonUtil.bind(ACCOUNT_SVC, "rpc/AccountService"); - - LOGIN_SVC = GWT.create(LoginService.class); - } -} diff --git a/webapp/src/com/google/gerrit/client/arrowRight.gif b/webapp/src/com/google/gerrit/client/arrowRight.gif Binary files differdeleted file mode 100644 index d9e63a5754..0000000000 --- a/webapp/src/com/google/gerrit/client/arrowRight.gif +++ /dev/null diff --git a/webapp/src/com/google/gerrit/client/changes/AccountDashboardScreen.java b/webapp/src/com/google/gerrit/client/changes/AccountDashboardScreen.java deleted file mode 100644 index 5b2247dafe..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/AccountDashboardScreen.java +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.Link; -import com.google.gerrit.client.data.AccountDashboardInfo; -import com.google.gerrit.client.data.AccountInfo; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.rpc.ScreenLoadCallback; -import com.google.gerrit.client.ui.Screen; - - -public class AccountDashboardScreen extends Screen { - private Account.Id ownerId; - private ChangeTable table; - private ChangeTable.Section byOwner; - private ChangeTable.Section forReview; - private ChangeTable.Section closed; - - public AccountDashboardScreen(final Account.Id id) { - ownerId = id; - } - - @Override - public Object getScreenCacheToken() { - return getClass(); - } - - @Override - public Screen recycleThis(final Screen newScreen) { - ownerId = ((AccountDashboardScreen) newScreen).ownerId; - return this; - } - - @Override - public void onLoad() { - if (table == null) { - table = new ChangeTable(); - byOwner = new ChangeTable.Section(""); - forReview = new ChangeTable.Section(""); - closed = new ChangeTable.Section(""); - - table.addSection(byOwner); - table.addSection(forReview); - table.addSection(closed); - add(table); - } - table.setSavePointerId(Link.toAccountDashboard(ownerId)); - super.onLoad(); - Util.LIST_SVC.forAccount(ownerId, - new ScreenLoadCallback<AccountDashboardInfo>() { - public void onSuccess(final AccountDashboardInfo r) { - // TODO Actually we want to cancel the RPC if detached. - if (isAttached()) { - display(r); - } - } - }); - } - - private void display(final AccountDashboardInfo r) { - table.setAccountInfoCache(r.getAccounts()); - - final AccountInfo o = r.getAccounts().get(r.getOwner()); - setTitleText(Util.M.accountDashboardTitle(o.getFullName())); - byOwner.setTitleText(Util.M.changesUploadedBy(o.getFullName())); - forReview.setTitleText(Util.M.changesReviewableBy(o.getFullName())); - closed.setTitleText(Util.C.changesRecentlyClosed()); - - byOwner.display(r.getByOwner()); - forReview.display(r.getForReview()); - closed.display(r.getClosed()); - table.finishDisplay(true); - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/ApprovalTable.java b/webapp/src/com/google/gerrit/client/changes/ApprovalTable.java deleted file mode 100644 index 340fa8f0e6..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ApprovalTable.java +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.Gerrit; -import com.google.gerrit.client.data.AccountInfoCache; -import com.google.gerrit.client.data.ApprovalDetail; -import com.google.gerrit.client.data.ApprovalType; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.ApprovalCategory; -import com.google.gerrit.client.reviewdb.ApprovalCategoryValue; -import com.google.gerrit.client.reviewdb.ChangeApproval; -import com.google.gerrit.client.ui.AccountDashboardLink; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; - -import java.util.List; -import java.util.Map; - -/** Displays a table of {@link ApprovalDetail} objects for a change record. */ -public class ApprovalTable extends Composite { - private final List<ApprovalType> types; - private final Grid table; - private AccountInfoCache accountCache = AccountInfoCache.empty(); - - public ApprovalTable() { - types = Gerrit.getGerritConfig().getApprovalTypes(); - table = new Grid(1, 3 + types.size()); - table.addStyleName("gerrit-InfoTable"); - displayHeader(); - - initWidget(table); - } - - private void displayHeader() { - int col = 0; - header(col++, Util.C.approvalTableReviewer()); - header(col++, ""); - - for (final ApprovalType t : types) { - header(col++, t.getCategory().getName()); - } - applyEdgeStyles(0); - } - - private void header(final int col, final String title) { - table.setText(0, col, title); - table.getCellFormatter().addStyleName(0, col, "header"); - } - - private void applyEdgeStyles(final int row) { - final CellFormatter fmt = table.getCellFormatter(); - fmt.addStyleName(row, 0, "leftmost"); - fmt.addStyleName(row, 0, "reviewer"); - fmt.addStyleName(row, 1, "approvalrole"); - fmt.addStyleName(row, 1 + types.size(), "rightmost"); - fmt.addStyleName(row, 2 + types.size(), "approvalhint"); - } - - private void applyScoreStyles(final int row) { - final CellFormatter fmt = table.getCellFormatter(); - for (int col = 0; col < types.size(); col++) { - fmt.addStyleName(row, 2 + col, "approvalscore"); - } - } - - public void setAccountInfoCache(final AccountInfoCache aic) { - assert aic != null; - accountCache = aic; - } - - private AccountDashboardLink link(final Account.Id id) { - return AccountDashboardLink.link(accountCache, id); - } - - public void display(final List<ApprovalDetail> rows) { - final int oldcnt = table.getRowCount(); - table.resizeRows(1 + rows.size()); - if (oldcnt < 1 + rows.size()) { - for (int row = oldcnt; row < 1 + rows.size(); row++) { - applyEdgeStyles(row); - applyScoreStyles(row); - } - } - - for (int i = 0; i < rows.size(); i++) { - displayRow(i + 1, rows.get(i)); - } - } - - private void displayRow(final int row, final ApprovalDetail ad) { - final CellFormatter fmt = table.getCellFormatter(); - final Map<ApprovalCategory.Id, ChangeApproval> am = ad.getApprovalMap(); - final StringBuilder hint = new StringBuilder(); - int col = 0; - table.setWidget(row, col++, link(ad.getAccount())); - table.clearCell(row, col++); // TODO populate the account role - - for (final ApprovalType type : types) { - final ChangeApproval ca = am.get(type.getCategory().getId()); - if (ca == null || ca.getValue() == 0) { - table.clearCell(row, col); - col++; - continue; - } - - final ApprovalCategoryValue acv = type.getValue(ca); - if (acv != null) { - if (hint.length() > 0) { - hint.append("; "); - } - hint.append(acv.getName()); - } - - if (type.isMaxNegative(ca)) { - table.setWidget(row, col, Gerrit.ICONS.redNot().createImage()); - - } else if (type.isMaxPositive(ca)) { - table.setWidget(row, col, Gerrit.ICONS.greenCheck().createImage()); - - } else { - String vstr = String.valueOf(ca.getValue()); - if (ca.getValue() > 0) { - vstr = "+" + vstr; - fmt.removeStyleName(row, col, "negscore"); - fmt.addStyleName(row, col, "posscore"); - } else { - fmt.addStyleName(row, col, "negscore"); - fmt.removeStyleName(row, col, "posscore"); - } - table.setText(row, col, vstr); - } - - col++; - } - - table.setText(row, col++, hint.toString()); - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeConstants.java b/webapp/src/com/google/gerrit/client/changes/ChangeConstants.java deleted file mode 100644 index f2b34c1182..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeConstants.java +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gwt.i18n.client.Constants; - -public interface ChangeConstants extends Constants { - String statusLongNew(); - String statusLongMerged(); - String statusLongAbandoned(); - - String changesRecentlyClosed(); - - String starredHeading(); - - String changeTableColumnID(); - String changeTableColumnSubject(); - String changeTableColumnOwner(); - String changeTableColumnReviewers(); - String changeTableColumnProject(); - String changeTableColumnLastUpdate(); - String changeTableNone(); - - String patchTableColumnName(); - String patchTableColumnDelta(); - String patchTableColumnComments(); - String patchTableColumnDiff(); - String patchTableDiffSideBySide(); - String patchTableDiffUnified(); - - String changeScreenDescription(); - String changeScreenDependencies(); - String changeScreenDependsOn(); - String changeScreenNeededBy(); - String changeScreenApprovals(); - String changeScreenMessages(); - - String approvalTableReviewer(); - - String changeInfoBlockOwner(); - String changeInfoBlockProject(); - String changeInfoBlockBranch(); - String changeInfoBlockUploaded(); - String changeInfoBlockStatus(); - String changePermalink(); - - String messageNoAuthor(); - String messageExpandRecent(); - String messageExpandAll(); - String messageCollapseAll(); - - String patchSetInfoDownload(); -} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeConstants.properties b/webapp/src/com/google/gerrit/client/changes/ChangeConstants.properties deleted file mode 100644 index 3951652027..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeConstants.properties +++ /dev/null @@ -1,44 +0,0 @@ -statusLongNew = Review in Progress -statusLongMerged = Merged -statusLongAbandoned = Abandoned - -starredHeading = Starred Changes -changesRecentlyClosed = Recently closed changes - -changeTableColumnID = ID -changeTableColumnSubject = Subject -changeTableColumnOwner = Owner -changeTableColumnReviewers = Reviewers -changeTableColumnProject = Project -changeTableColumnLastUpdate = LastUpdate -changeTableNone = (None) - -patchTableColumnName = File Path -patchTableColumnDelta = Delta From -patchTableColumnComments = Comments -patchTableColumnDiff = Diff -patchTableDiffSideBySide = Side-by-Side -patchTableDiffUnified = Unified - -changeScreenDescription = Description -changeScreenDependencies = Dependencies -changeScreenDependsOn = Depends On -changeScreenNeededBy = Needed By -changeScreenApprovals = Approvals -changeScreenMessages = Messages - -approvalTableReviewer = Reviewer - -changeInfoBlockOwner = Owner -changeInfoBlockProject = Project -changeInfoBlockBranch = Branch -changeInfoBlockUploaded = Uploaded -changeInfoBlockStatus = Status -changePermalink = Permalink - -messageNoAuthor = Gerrit Code Review -messageExpandRecent = Expand Recent -messageExpandAll = Expand All -messageCollapseAll = Collapse All - -patchSetInfoDownload = Download diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeDetailService.java b/webapp/src/com/google/gerrit/client/changes/ChangeDetailService.java deleted file mode 100644 index 5045a8276a..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeDetailService.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.data.ChangeDetail; -import com.google.gerrit.client.data.PatchSetDetail; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtjsonrpc.client.AllowCrossSiteRequest; -import com.google.gwtjsonrpc.client.RemoteJsonService; - -public interface ChangeDetailService extends RemoteJsonService { - @AllowCrossSiteRequest - void changeDetail(Change.Id id, AsyncCallback<ChangeDetail> callback); - - @AllowCrossSiteRequest - void patchSetDetail(PatchSet.Id key, AsyncCallback<PatchSetDetail> callback); -} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeDetailServiceImpl.java b/webapp/src/com/google/gerrit/client/changes/ChangeDetailServiceImpl.java deleted file mode 100644 index bcf078c02b..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeDetailServiceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.data.AccountInfoCacheFactory; -import com.google.gerrit.client.data.ChangeDetail; -import com.google.gerrit.client.data.PatchSetDetail; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gerrit.client.rpc.BaseServiceImplementation; -import com.google.gerrit.client.rpc.NoSuchEntityException; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.SchemaFactory; - -public class ChangeDetailServiceImpl extends BaseServiceImplementation - implements ChangeDetailService { - public ChangeDetailServiceImpl(final SchemaFactory<ReviewDb> rdf) { - super(rdf); - } - - public void changeDetail(final Change.Id id, - final AsyncCallback<ChangeDetail> callback) { - run(callback, new Action<ChangeDetail>() { - public ChangeDetail run(final ReviewDb db) throws OrmException, Failure { - final Change change = db.changes().get(id); - if (change == null) { - throw new Failure(new NoSuchEntityException()); - } - - final ChangeDetail d = new ChangeDetail(); - d.load(db, new AccountInfoCacheFactory(db), change); - return d; - } - }); - } - - public void patchSetDetail(final PatchSet.Id id, - final AsyncCallback<PatchSetDetail> callback) { - run(callback, new Action<PatchSetDetail>() { - public PatchSetDetail run(final ReviewDb db) throws OrmException, Failure { - final PatchSet ps = db.patchSets().get(id); - if (ps == null) { - throw new Failure(new NoSuchEntityException()); - } - - final PatchSetDetail d = new PatchSetDetail(); - d.load(db, ps); - return d; - } - }); - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeInfoBlock.java b/webapp/src/com/google/gerrit/client/changes/ChangeInfoBlock.java deleted file mode 100644 index f4f10b4f12..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeInfoBlock.java +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.FormatUtil; -import com.google.gerrit.client.data.ChangeDetail; -import com.google.gerrit.client.reviewdb.Branch; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.ui.AccountDashboardLink; -import com.google.gerrit.client.ui.ChangeLink; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; - -public class ChangeInfoBlock extends Composite { - private static final int R_OWNER = 0; - private static final int R_PROJECT = 1; - private static final int R_BRANCH = 2; - private static final int R_UPLOADED = 3; - private static final int R_STATUS = 4; - private static final int R_PERMALINK = 5; - private static final int R_CNT = 6; - - private final Grid table; - - public ChangeInfoBlock() { - table = new Grid(R_CNT, 2); - table.setStyleName("gerrit-InfoBlock"); - table.addStyleName("gerrit-ChangeInfoBlock"); - - initRow(R_OWNER, Util.C.changeInfoBlockOwner()); - initRow(R_PROJECT, Util.C.changeInfoBlockProject()); - initRow(R_BRANCH, Util.C.changeInfoBlockBranch()); - initRow(R_UPLOADED, Util.C.changeInfoBlockUploaded()); - initRow(R_STATUS, Util.C.changeInfoBlockStatus()); - - final CellFormatter fmt = table.getCellFormatter(); - fmt.addStyleName(0, 0, "topmost"); - fmt.addStyleName(0, 1, "topmost"); - fmt.addStyleName(R_CNT - 2, 0, "bottomheader"); - fmt.addStyleName(R_PERMALINK, 0, "permalink"); - fmt.addStyleName(R_PERMALINK, 1, "permalink"); - - initWidget(table); - } - - private void initRow(final int row, final String name) { - table.setText(row, 0, name); - table.getCellFormatter().addStyleName(row, 0, "header"); - } - - public void display(final ChangeDetail detail) { - final Change chg = detail.getChange(); - final Branch.NameKey dst = chg.getDest(); - table.setWidget(R_OWNER, 1, AccountDashboardLink.link(detail.getAccounts(), - detail.getChange().getOwner())); - table.setText(R_PROJECT, 1, dst.getParentKey().get()); - table.setText(R_BRANCH, 1, dst.getShortName()); - table.setText(R_UPLOADED, 1, FormatUtil.mediumFormat(chg.getCreatedOn())); - table.setText(R_STATUS, 1, Util.toLongString(chg.getStatus())); - - if (chg.getStatus().isClosed()) { - table.getCellFormatter().addStyleName(R_STATUS, 1, "closedstate"); - } else { - table.getCellFormatter().removeStyleName(R_STATUS, 1, "closedstate"); - } - - table.setWidget(R_PERMALINK, 1, new ChangeLink(Util.C.changePermalink(), - chg.getKey())); - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeListService.java b/webapp/src/com/google/gerrit/client/changes/ChangeListService.java deleted file mode 100644 index 7addfb3ea1..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeListService.java +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.data.AccountDashboardInfo; -import com.google.gerrit.client.data.MineStarredInfo; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.rpc.SignInRequired; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtjsonrpc.client.RemoteJsonService; -import com.google.gwtjsonrpc.client.VoidResult; - -import java.util.Set; - -public interface ChangeListService extends RemoteJsonService { - /** Get the data to show {@link AccountDashboardScreen} for an account. */ - void forAccount(Account.Id id, AsyncCallback<AccountDashboardInfo> callback); - - /** Get the changes starred by the caller. */ - @SignInRequired - void myStarredChanges(AsyncCallback<MineStarredInfo> callback); - - /** Get the ids of all changes starred by the caller. */ - @SignInRequired - void myStarredChangeIds(AsyncCallback<Set<Change.Id>> callback); - - /** - * Add and/or remove changes from the set of starred changes of the caller. - * - * @param req the add and remove cluster. - */ - @SignInRequired - void toggleStars(ToggleStarRequest req, AsyncCallback<VoidResult> callback); -} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeListServiceImpl.java b/webapp/src/com/google/gerrit/client/changes/ChangeListServiceImpl.java deleted file mode 100644 index 9b288b8221..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeListServiceImpl.java +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.data.AccountDashboardInfo; -import com.google.gerrit.client.data.AccountInfoCacheFactory; -import com.google.gerrit.client.data.ChangeInfo; -import com.google.gerrit.client.data.MineStarredInfo; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.reviewdb.ChangeAccess; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gerrit.client.reviewdb.StarredChange; -import com.google.gerrit.client.reviewdb.Change.Id; -import com.google.gerrit.client.rpc.BaseServiceImplementation; -import com.google.gerrit.client.rpc.NoSuchEntityException; -import com.google.gerrit.client.rpc.RpcUtil; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtjsonrpc.client.VoidResult; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.ResultSet; -import com.google.gwtorm.client.SchemaFactory; -import com.google.gwtorm.client.Transaction; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class ChangeListServiceImpl extends BaseServiceImplementation implements - ChangeListService { - public ChangeListServiceImpl(final SchemaFactory<ReviewDb> rdf) { - super(rdf); - } - - public void forAccount(final Account.Id id, - final AsyncCallback<AccountDashboardInfo> callback) { - final Account.Id me = RpcUtil.getAccountId(); - final Account.Id target = id != null ? id : me; - if (target == null) { - callback.onFailure(new NoSuchEntityException()); - return; - } - - run(callback, new Action<AccountDashboardInfo>() { - public AccountDashboardInfo run(final ReviewDb db) throws OrmException, - Failure { - final AccountInfoCacheFactory ac = new AccountInfoCacheFactory(db); - final Account user = ac.get(target); - if (user == null) { - throw new Failure(new NoSuchEntityException()); - } - - final Set<Change.Id> stars = starredBy(db, me); - final ChangeAccess changes = db.changes(); - final AccountDashboardInfo d; - - d = new AccountDashboardInfo(target); - d.setByOwner(list(changes.byOwnerOpen(target), stars, ac)); - d.setClosed(list(changes.byOwnerMerged(target), stars, ac)); - d.setAccounts(ac.create()); - return d; - } - }); - } - - public void myStarredChanges(final AsyncCallback<MineStarredInfo> callback) { - run(callback, new Action<MineStarredInfo>() { - public MineStarredInfo run(final ReviewDb db) throws OrmException, - Failure { - final Account.Id me = RpcUtil.getAccountId(); - final AccountInfoCacheFactory ac = new AccountInfoCacheFactory(db); - final Account user = ac.get(me); - if (user == null) { - throw new Failure(new NoSuchEntityException()); - } - - final MineStarredInfo d = new MineStarredInfo(me); - final Set<Change.Id> starred = starredBy(db, me); - d.setStarred(list(db.changes().get(starred), starred, ac)); - Collections.sort(d.getStarred(), new Comparator<ChangeInfo>() { - public int compare(final ChangeInfo o1, final ChangeInfo o2) { - // TODO Sort starred changes by something other than just Id - return o1.getId().get() - o2.getId().get(); - } - }); - d.setAccounts(ac.create()); - return d; - } - }); - } - - public void toggleStars(final ToggleStarRequest req, - final AsyncCallback<VoidResult> callback) { - run(callback, new Action<VoidResult>() { - public VoidResult run(final ReviewDb db) throws OrmException { - final Account.Id me = RpcUtil.getAccountId(); - final Set<Change.Id> existing = starredBy(db, me); - final ArrayList<StarredChange> add = new ArrayList<StarredChange>(); - final ArrayList<StarredChange> remove = new ArrayList<StarredChange>(); - - if (req.getAddSet() != null) { - for (final Change.Id id : req.getAddSet()) { - if (!existing.contains(id)) { - add.add(new StarredChange(new StarredChange.Key(me, id))); - } - } - } - - if (req.getRemoveSet() != null) { - for (final Change.Id id : req.getRemoveSet()) { - if (existing.contains(id)) { - remove.add(new StarredChange(new StarredChange.Key(me, id))); - } - } - } - - if (!add.isEmpty() || !remove.isEmpty()) { - final Transaction txn = db.beginTransaction(); - db.starredChanges().insert(add); - db.starredChanges().delete(remove); - txn.commit(); - } - return VoidResult.INSTANCE; - } - }); - } - - public void myStarredChangeIds(final AsyncCallback<Set<Change.Id>> callback) { - run(callback, new Action<Set<Change.Id>>() { - public Set<Id> run(final ReviewDb db) throws OrmException { - return starredBy(db, RpcUtil.getAccountId()); - } - }); - } - - private static List<ChangeInfo> list(final ResultSet<Change> rs, - final Set<Change.Id> starred, final AccountInfoCacheFactory accts) { - final ArrayList<ChangeInfo> r = new ArrayList<ChangeInfo>(); - for (final Change c : rs) { - final ChangeInfo ci = new ChangeInfo(c, accts); - ci.setStarred(starred.contains(ci.getId())); - r.add(ci); - } - return r; - } - - private static Set<Change.Id> starredBy(final ReviewDb db, final Account.Id me) - throws OrmException { - final Set<Change.Id> existing = new HashSet<Change.Id>(); - if (me != null) { - for (final StarredChange sc : db.starredChanges().byAccount(me)) { - existing.add(sc.getChangeId()); - } - } - return existing; - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeMessages.java b/webapp/src/com/google/gerrit/client/changes/ChangeMessages.java deleted file mode 100644 index bcafaadd44..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeMessages.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gwt.i18n.client.Messages; - -public interface ChangeMessages extends Messages { - String accountDashboardTitle(String fullName); - String changesUploadedBy(String fullName); - String changesReviewableBy(String fullName); - - String changeScreenTitleId(int id); - String patchSetHeader(int id); - String repoDownload(String project, int change, int ps); - - String patchTableComments(@PluralCount int count); - - String messageWrittenOn(String date); - - String renamedFrom(String sourcePath); - String copiedFrom(String sourcePath); - String otherFrom(String sourcePath); -} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeMessages.properties b/webapp/src/com/google/gerrit/client/changes/ChangeMessages.properties deleted file mode 100644 index 0a224611d1..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeMessages.properties +++ /dev/null @@ -1,16 +0,0 @@ -accountDashboardTitle = Changes for {0} -changesUploadedBy = Changes uploaded by {0} -changesReviewableBy = Changes reviewable by {0} - -changeScreenTitleId = Change {0} -patchSetHeader = Patch Set {0} -repoDownload = repo download {0} {1}/{2} - -patchTableComments[one] = 1 comment -patchTableComments = {0} comments - -messageWrittenOn = on {0} - -renamedFrom = renamed from {0} -copiedFrom = copied from {0} -otherFrom = from {0} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeScreen.java b/webapp/src/com/google/gerrit/client/changes/ChangeScreen.java deleted file mode 100644 index 3bb7243bc5..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeScreen.java +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.FormatUtil; -import com.google.gerrit.client.Gerrit; -import com.google.gerrit.client.data.AccountInfoCache; -import com.google.gerrit.client.data.ChangeDetail; -import com.google.gerrit.client.data.ChangeInfo; -import com.google.gerrit.client.data.GitwebLink; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.reviewdb.ChangeMessage; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.rpc.ScreenLoadCallback; -import com.google.gerrit.client.ui.ComplexDisclosurePanel; -import com.google.gerrit.client.ui.ExpandAllCommand; -import com.google.gerrit.client.ui.LinkMenuBar; -import com.google.gerrit.client.ui.Screen; -import com.google.gwt.i18n.client.LocaleInfo; -import com.google.gwt.user.client.ui.Anchor; -import com.google.gwt.user.client.ui.DisclosurePanel; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.HorizontalPanel; -import com.google.gwt.user.client.ui.InlineLabel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.Panel; -import com.google.gwt.user.client.ui.Widget; - -import java.sql.Timestamp; -import java.util.List; - - -public class ChangeScreen extends Screen { - private Change.Id changeId; - private ChangeInfo changeInfo; - - private ChangeInfoBlock infoBlock; - private DisclosurePanel descriptionPanel; - private Label description; - - private DisclosurePanel dependenciesPanel; - private ChangeTable dependencies; - private ChangeTable.Section dependsOn; - private ChangeTable.Section neededBy; - - private DisclosurePanel approvalsPanel; - private ApprovalTable approvals; - - private FlowPanel patchSetPanels; - - private DisclosurePanel messagesPanel; - private Panel messagesContent; - - public ChangeScreen(final Change.Id toShow) { - changeId = toShow; - } - - public ChangeScreen(final ChangeInfo c) { - this(c.getId()); - changeInfo = c; - } - - @Override - public Object getScreenCacheToken() { - return getClass(); - } - - @Override - public Screen recycleThis(final Screen newScreen) { - final ChangeScreen s = (ChangeScreen) newScreen; - changeId = s.changeId; - changeInfo = s.changeInfo; - return this; - } - - @Override - public void onLoad() { - if (descriptionPanel == null) { - initUI(); - } - - displayTitle(changeInfo != null ? changeInfo.getSubject() : null); - super.onLoad(); - - Util.DETAIL_SVC.changeDetail(changeId, - new ScreenLoadCallback<ChangeDetail>() { - public void onSuccess(final ChangeDetail r) { - // TODO Actually we want to cancel the RPC if detached. - if (isAttached()) { - display(r); - } - } - }); - } - - private void initUI() { - addStyleName("gerrit-ChangeScreen"); - - infoBlock = new ChangeInfoBlock(); - - description = newDescriptionLabel(); - - descriptionPanel = new DisclosurePanel(Util.C.changeScreenDescription()); - { - final Label glue = new Label(); - final HorizontalPanel hp = new HorizontalPanel(); - hp.add(description); - hp.add(glue); - hp.add(infoBlock); - hp.setCellWidth(glue, "100%"); - add(hp); - descriptionPanel.setContent(hp); - descriptionPanel.setWidth("100%"); - add(descriptionPanel); - } - - dependencies = new ChangeTable(); - dependsOn = new ChangeTable.Section(Util.C.changeScreenDependsOn()); - neededBy = new ChangeTable.Section(Util.C.changeScreenNeededBy()); - dependencies.addSection(dependsOn); - dependencies.addSection(neededBy); - - dependenciesPanel = new DisclosurePanel(Util.C.changeScreenDependencies()); - dependenciesPanel.setContent(dependencies); - dependenciesPanel.setWidth("95%"); - add(dependenciesPanel); - - approvals = new ApprovalTable(); - approvalsPanel = new DisclosurePanel(Util.C.changeScreenApprovals()); - approvalsPanel.setContent(wrap(approvals)); - dependenciesPanel.setWidth("95%"); - add(approvalsPanel); - - patchSetPanels = new FlowPanel(); - add(patchSetPanels); - - messagesContent = new FlowPanel(); - messagesContent.setStyleName("gerrit-ChangeMessages"); - messagesPanel = new DisclosurePanel(Util.C.changeScreenMessages()); - messagesPanel.setContent(messagesContent); - add(messagesPanel); - } - - private void displayTitle(final String subject) { - final StringBuilder titleBuf = new StringBuilder(); - if (LocaleInfo.getCurrentLocale().isRTL()) { - if (subject != null) { - titleBuf.append(subject); - titleBuf.append(" :"); - } - titleBuf.append(Util.M.changeScreenTitleId(changeId.get())); - } else { - titleBuf.append(Util.M.changeScreenTitleId(changeId.get())); - if (subject != null) { - titleBuf.append(": "); - titleBuf.append(subject); - } - } - setTitleText(titleBuf.toString()); - } - - private void display(final ChangeDetail detail) { - if (changeInfo == null) { - // We couldn't set the title correctly when we loaded the page - // into the browser, update it now that we have the full detail. - // - displayTitle(detail.getChange().getSubject()); - } - - dependencies.setAccountInfoCache(detail.getAccounts()); - approvals.setAccountInfoCache(detail.getAccounts()); - - infoBlock.display(detail); - description.setText(detail.getDescription()); - dependsOn.display(detail.getDependsOn()); - neededBy.display(detail.getNeededBy()); - approvals.display(detail.getApprovals()); - - addPatchSets(detail); - addMessages(detail); - - // If any dependency change is still open, show our dependency list. - // - boolean depsOpen = false; - if (!detail.getChange().getStatus().isClosed() - && detail.getDependsOn() != null) { - for (final ChangeInfo ci : detail.getDependsOn()) { - if (ci.getStatus() != Change.Status.MERGED) { - depsOpen = true; - break; - } - } - } - - descriptionPanel.setOpen(true); - dependenciesPanel.setOpen(depsOpen); - approvalsPanel.setOpen(true); - } - - private void addPatchSets(final ChangeDetail detail) { - patchSetPanels.clear(); - - final PatchSet currps = detail.getCurrentPatchSet(); - final GitwebLink gw = Gerrit.getGerritConfig().getGitwebLink(); - for (final PatchSet ps : detail.getPatchSets()) { - final ComplexDisclosurePanel panel = - new ComplexDisclosurePanel(Util.M.patchSetHeader(ps.getId()), - ps == currps); - final PatchSetPanel psp = new PatchSetPanel(detail, ps); - panel.setContent(psp); - - if (gw != null) { - final Anchor revlink = - new Anchor(ps.getRevision().get(), false, gw.toRevision(detail - .getChange().getDest().getParentKey(), ps)); - revlink.addStyleName("gerrit-PatchSetLink"); - panel.getHeader().add(revlink); - } - - if (ps == currps) { - psp.ensureLoaded(detail.getCurrentPatchSetDetail()); - } else { - panel.addEventHandler(psp); - } - add(panel); - patchSetPanels.add(panel); - } - } - - private void addMessages(final ChangeDetail detail) { - messagesContent.clear(); - - final AccountInfoCache accts = detail.getAccounts(); - final List<ChangeMessage> msgList = detail.getMessages(); - if (msgList.size() > 1) { - messagesContent.add(messagesMenuBar()); - } - - final long AGE = 7 * 24 * 60 * 60 * 1000L; - final Timestamp aged = new Timestamp(System.currentTimeMillis() - AGE); - - for (int i = 0; i < msgList.size(); i++) { - final ChangeMessage msg = msgList.get(i); - final MessagePanel mp = new MessagePanel(msg); - final String panelHeader; - final ComplexDisclosurePanel panel; - - if (msg.getAuthor() != null) { - panelHeader = FormatUtil.nameEmail(accts.get(msg.getAuthor())); - } else { - panelHeader = Util.C.messageNoAuthor(); - } - - if (i == msgList.size() - 1) { - mp.isRecent = true; - } else { - // TODO Instead of opening messages by strict age, do it by "unread"? - mp.isRecent = msg.getWrittenOn().after(aged); - } - - panel = new ComplexDisclosurePanel(panelHeader, mp.isRecent); - panel.getHeader().add( - new InlineLabel(Util.M.messageWrittenOn(FormatUtil.mediumFormat(msg - .getWrittenOn())))); - panel.setContent(mp); - messagesContent.add(panel); - } - - if (msgList.size() > 1) { - messagesContent.add(messagesMenuBar()); - } - messagesPanel.setOpen(msgList.size() > 0); - } - - private LinkMenuBar messagesMenuBar() { - final Panel c = messagesContent; - final LinkMenuBar m = new LinkMenuBar(); - m.addItem(Util.C.messageExpandRecent(), new ExpandAllCommand(c, true) { - @Override - protected void expand(final ComplexDisclosurePanel w) { - final MessagePanel mp = (MessagePanel) w.getContent(); - w.setOpen(mp.isRecent); - } - }); - m.addItem(Util.C.messageExpandAll(), new ExpandAllCommand(c, true)); - m.addItem(Util.C.messageCollapseAll(), new ExpandAllCommand(c, false)); - m.lastInGroup(); - return m; - } - - private static FlowPanel wrap(final Widget w) { - final FlowPanel p = new FlowPanel(); - p.add(w); - return p; - } - - private static Label newDescriptionLabel() { - final Label d = new Label(); - d.setStyleName("gerrit-ChangeScreen-Description"); - return d; - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/ChangeTable.java b/webapp/src/com/google/gerrit/client/changes/ChangeTable.java deleted file mode 100644 index 1a4240d3b0..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ChangeTable.java +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.Gerrit; -import com.google.gerrit.client.Link; -import com.google.gerrit.client.SignedInListener; -import com.google.gerrit.client.data.AccountInfoCache; -import com.google.gerrit.client.data.ChangeInfo; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.rpc.GerritCallback; -import com.google.gerrit.client.ui.AccountDashboardLink; -import com.google.gerrit.client.ui.ChangeLink; -import com.google.gerrit.client.ui.FancyFlexTable; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.ui.AbstractImagePrototype; -import com.google.gwt.user.client.ui.Image; -import com.google.gwt.user.client.ui.SourcesTableEvents; -import com.google.gwt.user.client.ui.TableListener; -import com.google.gwt.user.client.ui.Widget; -import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter; -import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; -import com.google.gwtjsonrpc.client.VoidResult; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -public class ChangeTable extends FancyFlexTable<ChangeInfo> { - private static final String S_C_ID = "C_ID"; - private static final String S_C_SUBJECT = "C_SUBJECT"; - private static final String S_SECTION_HEADER = "SectionHeader"; - private static final String S_EMPTY_SECTION = "EmptySection"; - - private static final int C_STAR = 1; - private static final int C_ID = 2; - private static final int C_SUBJECT = 3; - private static final int C_OWNER = 4; - private static final int C_REVIEWERS = 5; - private static final int C_PROJECT = 6; - private static final int C_LAST_UPDATE = 7; - private static final int COLUMNS = 8; - - private final List<Section> sections; - private final SignedInListener signedInListener; - private AccountInfoCache accountCache = AccountInfoCache.empty(); - - public ChangeTable() { - sections = new ArrayList<Section>(); - table.setText(0, C_STAR, ""); - table.setText(0, C_ID, Util.C.changeTableColumnID()); - table.setText(0, C_SUBJECT, Util.C.changeTableColumnSubject()); - table.setText(0, C_OWNER, Util.C.changeTableColumnOwner()); - table.setText(0, C_REVIEWERS, Util.C.changeTableColumnReviewers()); - table.setText(0, C_PROJECT, Util.C.changeTableColumnProject()); - table.setText(0, C_LAST_UPDATE, Util.C.changeTableColumnLastUpdate()); - - final FlexCellFormatter fmt = table.getFlexCellFormatter(); - fmt.addStyleName(0, C_STAR, S_ICON_HEADER); - fmt.addStyleName(0, C_ID, S_C_ID); - for (int i = C_ID; i < COLUMNS; i++) { - fmt.addStyleName(0, i, S_DATA_HEADER); - } - - table.addTableListener(new TableListener() { - public void onCellClicked(SourcesTableEvents sender, int row, int cell) { - if (cell == C_STAR) { - onStarClick(row); - } - } - }); - - signedInListener = new SignedInListener() { - public void onSignIn() { - if (table.getRowCount() <= sections.size()) { - // There are no data rows in this table, so star status is - // simply not relevant to the caller. - // - return; - } - - Util.LIST_SVC.myStarredChangeIds(new GerritCallback<Set<Change.Id>>() { - public void onSuccess(final Set<Change.Id> result) { - final FlexCellFormatter fmt = table.getFlexCellFormatter(); - final int max = table.getRowCount(); - for (int row = 0; row < max; row++) { - final ChangeInfo c = getRowItem(row); - if (c != null) { - c.setStarred(result.contains(c.getId())); - setStar(row, c); - } - } - } - }); - } - - public void onSignOut() { - final FlexCellFormatter fmt = table.getFlexCellFormatter(); - final int max = table.getRowCount(); - for (int row = 0; row < max; row++) { - if (getRowItem(row) != null) { - table.clearCell(row, C_STAR); - } - } - } - }; - } - - protected void onStarClick(final int row) { - final ChangeInfo c = getRowItem(row); - if (c != null && Gerrit.isSignedIn()) { - final boolean prior = c.isStarred(); - c.setStarred(!prior); - setStar(row, c); - - final ToggleStarRequest req = new ToggleStarRequest(); - req.toggle(c.getId(), c.isStarred()); - Util.LIST_SVC.toggleStars(req, new GerritCallback<VoidResult>() { - public void onSuccess(final VoidResult result) { - } - - @Override - public void onFailure(final Throwable caught) { - super.onFailure(caught); - c.setStarred(prior); - setStar(row, c); - } - }); - } - } - - @Override - protected Object getRowItemKey(final ChangeInfo item) { - return item.getId(); - } - - @Override - protected boolean onKeyPress(final char keyCode, final int modifiers) { - if (super.onKeyPress(keyCode, modifiers)) { - return true; - } - if (modifiers == 0) { - switch (keyCode) { - case 's': - onStarClick(getCurrentRow()); - return true; - } - } - return false; - } - - @Override - protected void onOpenItem(final ChangeInfo c) { - History.newItem(Link.toChange(c), false); - Gerrit.display(new ChangeScreen(c)); - } - - @Override - public void onLoad() { - super.onLoad(); - Gerrit.addSignedInListener(signedInListener); - } - - @Override - public void onUnload() { - Gerrit.removeSignedInListener(signedInListener); - super.onUnload(); - } - - private void insertNoneRow(final int row) { - insertRow(row); - table.setText(row, 0, Util.C.changeTableNone()); - final FlexCellFormatter fmt = table.getFlexCellFormatter(); - fmt.setColSpan(row, 0, COLUMNS); - fmt.setStyleName(row, 0, S_EMPTY_SECTION); - } - - private void insertChangeRow(final int row) { - insertRow(row); - applyDataRowStyle(row); - } - - @Override - protected void applyDataRowStyle(final int row) { - super.applyDataRowStyle(row); - final CellFormatter fmt = table.getCellFormatter(); - fmt.addStyleName(row, C_STAR, S_ICON_CELL); - for (int i = C_ID; i < COLUMNS; i++) { - fmt.addStyleName(row, i, S_DATA_CELL); - } - fmt.addStyleName(row, C_ID, S_C_ID); - fmt.addStyleName(row, C_SUBJECT, S_C_SUBJECT); - } - - private void populateChangeRow(final int row, final ChangeInfo c) { - final String idstr = String.valueOf(c.getId().get()); - table.setWidget(row, C_ARROW, null); - if (Gerrit.isSignedIn()) { - setStar(row, c); - } - table.setWidget(row, C_ID, new ChangeLink(idstr, c)); - - String s = c.getSubject(); - if (c.getStatus() != null && c.getStatus() != Change.Status.NEW) { - s += " (" + c.getStatus().name() + ")"; - } - table.setWidget(row, C_SUBJECT, new ChangeLink(s, c)); - table.setWidget(row, C_OWNER, link(c.getOwner())); - table.setText(row, C_REVIEWERS, "TODO"); - table.setText(row, C_PROJECT, c.getProject().getName()); - table.setText(row, C_LAST_UPDATE, "TODO"); - setRowItem(row, c); - } - - private AccountDashboardLink link(final Account.Id id) { - return AccountDashboardLink.link(accountCache, id); - } - - private void setStar(final int row, final ChangeInfo c) { - final AbstractImagePrototype star; - if (c.isStarred()) { - star = Gerrit.ICONS.starFilled(); - } else { - star = Gerrit.ICONS.starOpen(); - } - - final Widget i = table.getWidget(row, C_STAR); - if (i instanceof Image) { - star.applyTo((Image) i); - } else { - table.setWidget(row, C_STAR, star.createImage()); - } - } - - public void addSection(final Section s) { - assert s.parent == null; - - if (s.titleText != null) { - s.titleRow = table.getRowCount(); - table.setText(s.titleRow, 0, s.titleText); - final FlexCellFormatter fmt = table.getFlexCellFormatter(); - fmt.setColSpan(s.titleRow, 0, COLUMNS); - fmt.addStyleName(s.titleRow, 0, S_SECTION_HEADER); - } else { - s.titleRow = -1; - } - - s.parent = this; - s.dataBegin = table.getRowCount(); - insertNoneRow(s.dataBegin); - sections.add(s); - } - - public void setAccountInfoCache(final AccountInfoCache aic) { - assert aic != null; - accountCache = aic; - } - - private int insertRow(final int beforeRow) { - for (final Section s : sections) { - boolean dirty = false; - if (beforeRow <= s.titleRow) { - s.titleRow++; - } - if (beforeRow < s.dataBegin) { - s.dataBegin++; - } - } - return table.insertRow(beforeRow); - } - - private void removeRow(final int row) { - for (final Section s : sections) { - if (row < s.titleRow) { - s.titleRow--; - } - if (row < s.dataBegin) { - s.dataBegin--; - } - } - table.removeRow(row); - } - - public static class Section { - String titleText; - - ChangeTable parent; - int titleRow = -1; - int dataBegin; - int rows; - - public Section() { - this(null); - } - - public Section(final String titleText) { - setTitleText(titleText); - } - - public void setTitleText(final String text) { - titleText = text; - if (titleRow >= 0) { - parent.table.setText(titleRow, 0, titleText); - } - } - - public void display(final List<ChangeInfo> changeList) { - final int sz = changeList != null ? changeList.size() : 0; - final boolean hadData = rows > 0; - - if (hadData) { - while (sz < rows) { - parent.removeRow(dataBegin); - rows--; - } - } - - if (sz == 0) { - if (hadData) { - parent.insertNoneRow(dataBegin); - } - } else { - if (!hadData) { - parent.removeRow(dataBegin); - } - - while (rows < sz) { - parent.insertChangeRow(dataBegin + rows); - rows++; - } - for (int i = 0; i < sz; i++) { - parent.populateChangeRow(dataBegin + i, changeList.get(i)); - } - } - } - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/MessagePanel.java b/webapp/src/com/google/gerrit/client/changes/MessagePanel.java deleted file mode 100644 index 45a75d7410..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/MessagePanel.java +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.reviewdb.ChangeMessage; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.Label; - -public class MessagePanel extends Composite { - boolean isRecent; - - public MessagePanel(final ChangeMessage msg) { - final Label l = new Label(msg.getMessage().trim()); - l.setStyleName("gerrit-ChangeMessage-Message"); - initWidget(l); - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/MineStarredScreen.java b/webapp/src/com/google/gerrit/client/changes/MineStarredScreen.java deleted file mode 100644 index 0157542f50..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/MineStarredScreen.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.Link; -import com.google.gerrit.client.data.MineStarredInfo; -import com.google.gerrit.client.rpc.GerritCallback; -import com.google.gerrit.client.ui.AccountScreen; - - -public class MineStarredScreen extends AccountScreen { - private ChangeTable table; - private ChangeTable.Section starred; - - public MineStarredScreen() { - super(Util.C.starredHeading()); - - table = new ChangeTable(); - starred = new ChangeTable.Section(); - - table.addSection(starred); - table.setSavePointerId(Link.MINE_STARRED); - - add(table); - } - - @Override - public Object getScreenCacheToken() { - return Link.MINE_STARRED; - } - - @Override - public void onLoad() { - super.onLoad(); - Util.LIST_SVC.myStarredChanges(new GerritCallback<MineStarredInfo>() { - public void onSuccess(final MineStarredInfo result) { - table.setAccountInfoCache(result.getAccounts()); - starred.display(result.getStarred()); - table.finishDisplay(true); - } - }); - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/PatchSetPanel.java b/webapp/src/com/google/gerrit/client/changes/PatchSetPanel.java deleted file mode 100644 index 1d8732ccbf..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/PatchSetPanel.java +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.data.ChangeDetail; -import com.google.gerrit.client.data.PatchSetDetail; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.rpc.GerritCallback; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.DisclosureEvent; -import com.google.gwt.user.client.ui.DisclosureHandler; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.Grid; -import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; - -class PatchSetPanel extends Composite implements DisclosureHandler { - private static final int R_DOWNLOAD = 0; - private static final int R_CNT = 1; - - private final ChangeDetail changeDetail; - private final PatchSet patchSet; - private final FlowPanel body; - - private Grid infoTable; - private PatchTable patchTable; - - PatchSetPanel(final ChangeDetail detail, final PatchSet ps) { - changeDetail = detail; - patchSet = ps; - body = new FlowPanel(); - initWidget(body); - } - - public void ensureLoaded(final PatchSetDetail detail) { - infoTable = new Grid(R_CNT, 2); - infoTable.setStyleName("gerrit-InfoBlock"); - infoTable.addStyleName("gerrit-PatchSetInfoBlock"); - - initRow(R_DOWNLOAD, Util.C.patchSetInfoDownload()); - - final CellFormatter itfmt = infoTable.getCellFormatter(); - itfmt.addStyleName(0, 0, "topmost"); - itfmt.addStyleName(0, 1, "topmost"); - itfmt.addStyleName(R_CNT - 1, 0, "bottomheader"); - itfmt.addStyleName(R_DOWNLOAD, 1, "command"); - - infoTable.setText(R_DOWNLOAD, 1, Util.M.repoDownload(changeDetail - .getChange().getDest().getParentKey().get(), changeDetail.getChange() - .getId(), patchSet.getId())); - - patchTable = new PatchTable(); - patchTable.setSavePointerId("patchTable " - + changeDetail.getChange().getId() + " " + patchSet.getId()); - patchTable.display(detail.getPatches()); - patchTable.finishDisplay(false); - - body.add(infoTable); - body.add(patchTable); - } - - public void onOpen(final DisclosureEvent event) { - if (infoTable == null) { - Util.DETAIL_SVC.patchSetDetail(patchSet.getKey(), - new GerritCallback<PatchSetDetail>() { - public void onSuccess(final PatchSetDetail result) { - ensureLoaded(result); - } - }); - } - } - - public void onClose(final DisclosureEvent event) { - } - - private void initRow(final int row, final String name) { - infoTable.setText(row, 0, name); - infoTable.getCellFormatter().addStyleName(row, 0, "header"); - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/PatchTable.java b/webapp/src/com/google/gerrit/client/changes/PatchTable.java deleted file mode 100644 index 88185f2b79..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/PatchTable.java +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.Link; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.ui.FancyFlexTable; -import com.google.gerrit.client.ui.PatchLink; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.InlineLabel; -import com.google.gwt.user.client.ui.Widget; -import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter; -import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; - -import java.util.List; - -public class PatchTable extends FancyFlexTable<Patch> { - private static final int C_TYPE = 1; - private static final int C_NAME = 2; - private static final int C_DELTA = 3; - private static final int C_COMMENTS = 4; - private static final int C_DIFF = 5; - private static final int N_DIFF = 2; - - public PatchTable() { - table.setText(0, C_TYPE, ""); - table.setText(0, C_NAME, Util.C.patchTableColumnName()); - table.setText(0, C_DELTA, Util.C.patchTableColumnDelta()); - table.setText(0, C_COMMENTS, Util.C.patchTableColumnComments()); - table.setText(0, C_DIFF, Util.C.patchTableColumnDiff()); - - final FlexCellFormatter fmt = table.getFlexCellFormatter(); - fmt.addStyleName(0, C_TYPE, S_ICON_HEADER); - fmt.addStyleName(0, C_NAME, S_DATA_HEADER); - fmt.addStyleName(0, C_DELTA, S_DATA_HEADER); - fmt.addStyleName(0, C_COMMENTS, S_DATA_HEADER); - fmt.addStyleName(0, C_DIFF, S_DATA_HEADER); - fmt.setColSpan(0, C_DIFF, N_DIFF); - } - - @Override - protected Object getRowItemKey(final Patch item) { - return item.getKey(); - } - - @Override - protected void onOpenItem(final Patch item) { - History.newItem(Link.toPatchSideBySide(item.getKey())); - } - - @Override - protected void applyDataRowStyle(final int row) { - super.applyDataRowStyle(row); - final CellFormatter fmt = table.getCellFormatter(); - fmt.addStyleName(row, C_TYPE, "ChangeTypeCell"); - - fmt.addStyleName(row, C_NAME, S_DATA_CELL); - fmt.addStyleName(row, C_NAME, "FilePathCell"); - - fmt.addStyleName(row, C_DELTA, S_DATA_CELL); - - fmt.addStyleName(row, C_COMMENTS, S_DATA_CELL); - fmt.addStyleName(row, C_COMMENTS, "CommentCell"); - - fmt.addStyleName(row, C_DIFF + 0, S_DATA_CELL); - fmt.addStyleName(row, C_DIFF + 0, "DiffLinkCell"); - - fmt.addStyleName(row, C_DIFF + 1, S_DATA_CELL); - fmt.addStyleName(row, C_DIFF + 1, "DiffLinkCell"); - } - - public void display(final List<Patch> list) { - final int sz = list != null ? list.size() : 0; - int dataRows = table.getRowCount() - 1; - while (sz < dataRows) { - table.removeRow(dataRows); - dataRows--; - } - - for (int i = 0; i < sz; i++) { - if (dataRows <= i) { - table.insertRow(++dataRows); - applyDataRowStyle(i + 1); - } - populate(i + 1, list.get(i)); - } - } - - private void populate(final int row, final Patch patch) { - table.setWidget(row, C_ARROW, null); - table.setText(row, C_TYPE, "" + patch.getChangeType().getCode()); - - Widget nameLink; - if (patch.getPatchType() == Patch.PatchType.UNIFIED) { - nameLink = new PatchLink.SideBySide(patch.getKey().get(), patch.getKey()); - } else { - nameLink = new PatchLink.Unified(patch.getKey().get(), patch.getKey()); - } - if (patch.getSourceFileName() != null) { - final String secondLine; - if (patch.getChangeType() == Patch.ChangeType.RENAMED) { - secondLine = Util.M.renamedFrom(patch.getSourceFileName()); - - } else if (patch.getChangeType() == Patch.ChangeType.COPIED) { - secondLine = Util.M.copiedFrom(patch.getSourceFileName()); - - } else { - secondLine = Util.M.otherFrom(patch.getSourceFileName()); - } - - final InlineLabel secondLineLabel = new InlineLabel(secondLine); - secondLineLabel.setStyleName("SourceFilePath"); - - final FlowPanel fp = new FlowPanel(); - fp.add(nameLink); - fp.add(secondLineLabel); - nameLink = fp; - } - table.setWidget(row, C_NAME, nameLink); - - table.clearCell(row, C_DELTA); - - final int cnt = patch.getCommentCount(); - if (cnt == 0) { - table.clearCell(row, C_COMMENTS); - } else { - table.setText(row, C_COMMENTS, Util.M.patchTableComments(cnt)); - } - - if (patch.getPatchType() == Patch.PatchType.UNIFIED) { - table.setWidget(row, C_DIFF + 0, new PatchLink.SideBySide(Util.C - .patchTableDiffSideBySide(), patch.getKey())); - } else { - table.clearCell(row, C_DIFF + 0); - } - table.setWidget(row, C_DIFF + 1, new PatchLink.Unified(Util.C - .patchTableDiffUnified(), patch.getKey())); - - setRowItem(row, patch); - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/ToggleStarRequest.java b/webapp/src/com/google/gerrit/client/changes/ToggleStarRequest.java deleted file mode 100644 index ed76729be0..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/ToggleStarRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.reviewdb.Change; - -import java.util.HashSet; -import java.util.Set; - -/** Request parameters to update the changes the user has toggled. */ -public class ToggleStarRequest { - protected Set<Change.Id> add; - protected Set<Change.Id> remove; - - /** - * Request an update to the change's star status. - * - * @param id unique id of the change, must not be null. - * @param on true if the change should now be starred; false if it should now - * be not starred. - */ - public void toggle(final Change.Id id, final boolean on) { - if (on) { - if (add == null) { - add = new HashSet<Change.Id>(); - } - add.add(id); - if (remove != null) { - remove.remove(id); - } - } else { - if (remove == null) { - remove = new HashSet<Change.Id>(); - } - remove.add(id); - if (add != null) { - add.remove(id); - } - } - } - - /** Get the set of changes which should have stars added; may be null. */ - public Set<Change.Id> getAddSet() { - return add; - } - - /** Get the set of changes which should have stars removed; may be null. */ - public Set<Change.Id> getRemoveSet() { - return remove; - } -} diff --git a/webapp/src/com/google/gerrit/client/changes/Util.java b/webapp/src/com/google/gerrit/client/changes/Util.java deleted file mode 100644 index f8dd5f8bd6..0000000000 --- a/webapp/src/com/google/gerrit/client/changes/Util.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.changes; - -import com.google.gerrit.client.reviewdb.Change; -import com.google.gwt.core.client.GWT; -import com.google.gwtjsonrpc.client.JsonUtil; - -public class Util { - public static final ChangeConstants C = GWT.create(ChangeConstants.class); - public static final ChangeMessages M = GWT.create(ChangeMessages.class); - - public static final ChangeDetailService DETAIL_SVC; - public static final ChangeListService LIST_SVC; - - static { - DETAIL_SVC = GWT.create(ChangeDetailService.class); - JsonUtil.bind(DETAIL_SVC, "rpc/ChangeDetailService"); - - LIST_SVC = GWT.create(ChangeListService.class); - JsonUtil.bind(LIST_SVC, "rpc/ChangeListService"); - } - - public static String toLongString(final Change.Status status) { - if (status == null) { - return ""; - } else if (status == Change.Status.NEW) { - return C.statusLongNew(); - } else if (status == Change.Status.MERGED) { - return C.statusLongMerged(); - } else if (status == Change.Status.ABANDONED) { - return C.statusLongAbandoned(); - } else { - return status.name(); - } - } -} diff --git a/webapp/src/com/google/gerrit/client/data/AccountDashboardInfo.java b/webapp/src/com/google/gerrit/client/data/AccountDashboardInfo.java deleted file mode 100644 index e17ef5e4c4..0000000000 --- a/webapp/src/com/google/gerrit/client/data/AccountDashboardInfo.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.changes.AccountDashboardScreen; -import com.google.gerrit.client.reviewdb.Account; - -import java.util.List; - -/** Summary information needed for {@link AccountDashboardScreen}. */ -public class AccountDashboardInfo { - protected AccountInfoCache accounts; - protected Account.Id owner; - protected List<ChangeInfo> byOwner; - protected List<ChangeInfo> forReview; - protected List<ChangeInfo> closed; - - protected AccountDashboardInfo() { - } - - public AccountDashboardInfo(final Account.Id forUser) { - owner = forUser; - } - - public AccountInfoCache getAccounts() { - return accounts; - } - - public void setAccounts(final AccountInfoCache ac) { - accounts = ac; - } - - public Account.Id getOwner() { - return owner; - } - - public List<ChangeInfo> getByOwner() { - return byOwner; - } - - public void setByOwner(List<ChangeInfo> c) { - byOwner = c; - } - - public List<ChangeInfo> getForReview() { - return forReview; - } - - public void setForReview(List<ChangeInfo> c) { - forReview = c; - } - - public List<ChangeInfo> getClosed() { - return closed; - } - - public void setClosed(List<ChangeInfo> c) { - closed = c; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/AccountInfo.java b/webapp/src/com/google/gerrit/client/data/AccountInfo.java deleted file mode 100644 index bdfd787a3c..0000000000 --- a/webapp/src/com/google/gerrit/client/data/AccountInfo.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.Account; - -/** Summary information about an {@link Account}, for simple tabular displays. */ -public class AccountInfo { - protected Account.Id id; - protected String fullName; - protected String preferredEmail; - - protected AccountInfo() { - } - - /** - * Create an 'Anonymous Coward' account info, when only the id is known. - * <p> - * This constructor should only be a last-ditch effort, when the usual account - * lookup has failed and a stale account id has been discovered in the data - * store. - */ - public AccountInfo(final Account.Id id) { - this.id = id; - } - - /** - * Create an account description from a real data store record. - * - * @param a the data store record holding the specific account details. - */ - public AccountInfo(final Account a) { - id = a.getId(); - fullName = a.getFullName(); - preferredEmail = a.getPreferredEmail(); - } - - /** @return the unique local id of the account */ - public Account.Id getId() { - return id; - } - - /** @return the full name of the account holder; null if not supplied */ - public String getFullName() { - return fullName; - } - - /** @return the email address of the account holder; null if not supplied */ - public String getPreferredEmail() { - return preferredEmail; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/AccountInfoCache.java b/webapp/src/com/google/gerrit/client/data/AccountInfoCache.java deleted file mode 100644 index 46b4090671..0000000000 --- a/webapp/src/com/google/gerrit/client/data/AccountInfoCache.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.Account; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** In-memory table of {@link AccountInfo}, indexed by {@link Account.Id}. */ -public class AccountInfoCache { - private static final AccountInfoCache EMPTY; - static { - EMPTY = new AccountInfoCache(); - EMPTY.accounts = Collections.emptyMap(); - } - - /** Obtain an empty cache singleton. */ - public static AccountInfoCache empty() { - return EMPTY; - } - - protected Map<Account.Id, AccountInfo> accounts; - - protected AccountInfoCache() { - } - - AccountInfoCache(final Iterable<AccountInfo> list) { - accounts = new HashMap<Account.Id, AccountInfo>(); - for (final AccountInfo ai : list) { - accounts.put(ai.getId(), ai); - } - } - - /** - * Lookup the account summary - * <p> - * The return value can take on one of three forms: - * <ul> - * <li><code>null</code>, if <code>id == null</code>.</li> - * <li>a valid info block, if <code>id</code> was loaded.</li> - * <li>an anonymous info block, if <code>id</code> was not loaded.</li> - * </ul> - * - * @param id the id desired. - * @return info block for the account. - */ - public AccountInfo get(final Account.Id id) { - if (id == null) { - return null; - } - - AccountInfo r = accounts.get(id); - if (r == null) { - r = new AccountInfo(id); - accounts.put(id, r); - } - return r; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/AccountInfoCacheFactory.java b/webapp/src/com/google/gerrit/client/data/AccountInfoCacheFactory.java deleted file mode 100644 index 22fae0dee2..0000000000 --- a/webapp/src/com/google/gerrit/client/data/AccountInfoCacheFactory.java +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gwtorm.client.OrmException; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - -/** Efficiently builds a {@link AccountInfoCache}. */ -public class AccountInfoCacheFactory { - private final ReviewDb db; - private final HashMap<Account.Id, Account> cache; - private final HashSet<Account.Id> toFetch; - - public AccountInfoCacheFactory(final ReviewDb schema) { - db = schema; - cache = new HashMap<Account.Id, Account>(); - toFetch = new HashSet<Account.Id>(); - } - - /** - * Indicate an account will be needed later on. - * <p> - * This method permits batch fetching from the data store by building a list - * of Account.Ids which need to be obtained during the next {@link #fetch}. - * - * @param id identity that will be needed in the future; may be null. - */ - public void want(final Account.Id id) { - if (id != null && !cache.containsKey(id)) { - toFetch.add(id); - } - } - - /** Indicate one or more accounts will be needed later on. */ - public void want(final Collection<Account.Id> ids) { - for (final Account.Id id : ids) { - want(id); - } - } - - /** Fetch all accounts previously queued by {@link #want(Account.Id)} */ - public void fetch() throws OrmException { - if (!toFetch.isEmpty()) { - for (final Account a : db.accounts().get(toFetch)) { - cache.put(a.getId(), a); - } - toFetch.clear(); - } - } - - /** Load one account entity, reusing a cached instance if already loaded. */ - public Account get(final Account.Id id) throws OrmException { - if (id == null) { - return null; - } - - Account a = cache.get(id); - if (a == null) { - if (toFetch.isEmpty()) { - a = db.accounts().byId(id); - if (a != null) { - cache.put(id, a); - } - } else { - toFetch.add(id); - fetch(); - a = cache.get(id); - } - } - return a; - } - - /** - * Create an AccountInfoCache with the currently loaded Account entities. - * <p> - * Implicitly invokes {@link #fetch()} prior to creating the cache, ensuring - * any previously enqueued entities will be included in the result. - * */ - public AccountInfoCache create() throws OrmException { - fetch(); - final List<AccountInfo> r = new ArrayList<AccountInfo>(cache.size()); - for (final Account a : cache.values()) { - r.add(new AccountInfo(a)); - } - return new AccountInfoCache(r); - } -} diff --git a/webapp/src/com/google/gerrit/client/data/ApprovalDetail.java b/webapp/src/com/google/gerrit/client/data/ApprovalDetail.java deleted file mode 100644 index 9e8c3ae6f7..0000000000 --- a/webapp/src/com/google/gerrit/client/data/ApprovalDetail.java +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.ApprovalCategory; -import com.google.gerrit.client.reviewdb.ChangeApproval; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ApprovalDetail { - static final Timestamp EG_0 = new Timestamp(0); - static final Timestamp EG_D = new Timestamp(Long.MAX_VALUE); - - protected Account.Id account; - protected List<ChangeApproval> approvals; - - transient Timestamp sortOrder = EG_D; - - protected ApprovalDetail() { - } - - public ApprovalDetail(final Account.Id id) { - account = id; - approvals = new ArrayList<ChangeApproval>(); - } - - public Account.Id getAccount() { - return account; - } - - public Map<ApprovalCategory.Id, ChangeApproval> getApprovalMap() { - final HashMap<ApprovalCategory.Id, ChangeApproval> r; - r = new HashMap<ApprovalCategory.Id, ChangeApproval>(); - for (final ChangeApproval ca : approvals) { - r.put(ca.getCategoryId(), ca); - } - return r; - } - - void add(final ChangeApproval ca) { - approvals.add(ca); - - final Timestamp g = ca.getGranted(); - if (g != null && g.compareTo(sortOrder) < 0) { - sortOrder = g; - } - } -} diff --git a/webapp/src/com/google/gerrit/client/data/ApprovalType.java b/webapp/src/com/google/gerrit/client/data/ApprovalType.java deleted file mode 100644 index 00d8883f36..0000000000 --- a/webapp/src/com/google/gerrit/client/data/ApprovalType.java +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.ApprovalCategory; -import com.google.gerrit.client.reviewdb.ApprovalCategoryValue; -import com.google.gerrit.client.reviewdb.ChangeApproval; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ApprovalType { - protected ApprovalCategory category; - protected List<ApprovalCategoryValue> values; - protected short maxNegative; - protected short maxPositive; - - private transient Map<Short, ApprovalCategoryValue> byValue; - - protected ApprovalType() { - } - - public ApprovalType(final ApprovalCategory ac, - final List<ApprovalCategoryValue> valueList) { - category = ac; - values = new ArrayList<ApprovalCategoryValue>(valueList); - Collections.sort(values, new Comparator<ApprovalCategoryValue>() { - public int compare(ApprovalCategoryValue o1, ApprovalCategoryValue o2) { - return o1.getValue() - o2.getValue(); - } - }); - - maxNegative = Short.MIN_VALUE; - maxPositive = Short.MAX_VALUE; - if (values.size() > 0) { - if (values.get(0).getValue() < 0) { - maxNegative = values.get(0).getValue(); - } - if (values.get(values.size() - 1).getValue() > 0) { - maxPositive = values.get(values.size() - 1).getValue(); - } - } - } - - public ApprovalCategory getCategory() { - return category; - } - - public List<ApprovalCategoryValue> getValues() { - return values; - } - - public boolean isMaxNegative(final ChangeApproval ca) { - return maxNegative == ca.getValue(); - } - - public boolean isMaxPositive(final ChangeApproval ca) { - return maxPositive == ca.getValue(); - } - - public ApprovalCategoryValue getValue(final ChangeApproval ca) { - if (byValue == null) { - byValue = new HashMap<Short, ApprovalCategoryValue>(); - for (final ApprovalCategoryValue acv : values) { - byValue.put(acv.getValue(), acv); - } - } - return byValue.get(ca.getValue()); - } -} diff --git a/webapp/src/com/google/gerrit/client/data/BasePatchDetail.java b/webapp/src/com/google/gerrit/client/data/BasePatchDetail.java deleted file mode 100644 index cd32bc9445..0000000000 --- a/webapp/src/com/google/gerrit/client/data/BasePatchDetail.java +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.patches.PatchScreen; -import com.google.gerrit.client.reviewdb.Patch; - -/** Detail necessary to display {@link PatchScreen}. */ -public abstract class BasePatchDetail { - protected AccountInfoCache accounts; - protected Patch patch; - - protected BasePatchDetail() { - } - - public BasePatchDetail(final Patch p, final AccountInfoCache aic) { - patch = p; - accounts = aic; - } - - public AccountInfoCache getAccounts() { - return accounts; - } - - public Patch getPatch() { - return patch; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/ChangeDetail.java b/webapp/src/com/google/gerrit/client/data/ChangeDetail.java deleted file mode 100644 index 499204e0d6..0000000000 --- a/webapp/src/com/google/gerrit/client/data/ChangeDetail.java +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.changes.ChangeScreen; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.reviewdb.ChangeApproval; -import com.google.gerrit.client.reviewdb.ChangeMessage; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.reviewdb.PatchSetAncestor; -import com.google.gerrit.client.reviewdb.RevId; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gwtorm.client.OrmException; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -/** Detail necessary to display {@link ChangeScreen}. */ -public class ChangeDetail { - protected AccountInfoCache accounts; - protected Change change; - protected List<ChangeInfo> dependsOn; - protected List<ChangeInfo> neededBy; - protected List<PatchSet> patchSets; - protected List<ApprovalDetail> approvals; - protected List<ChangeMessage> messages; - protected PatchSet.Id currentPatchSetId; - protected PatchSetDetail currentDetail; - - public ChangeDetail() { - } - - public void load(final ReviewDb db, final AccountInfoCacheFactory acc, - final Change c) throws OrmException { - change = c; - acc.want(change.getOwner()); - - patchSets = db.patchSets().byChange(change.getKey()).toList(); - messages = db.changeMessages().byChange(change.getKey()).toList(); - for (final ChangeMessage m : messages) { - acc.want(m.getAuthor()); - } - - final HashMap<Account.Id, ApprovalDetail> ad = - new HashMap<Account.Id, ApprovalDetail>(); - { - final ApprovalDetail d = new ApprovalDetail(change.getOwner()); - d.sortOrder = ApprovalDetail.EG_0; - // TODO Mark self-approved, self-verified if permitted. - ad.put(d.getAccount(), d); - } - for (ChangeApproval ca : db.changeApprovals().byChange(change.getKey())) { - ApprovalDetail d = ad.get(ca.getAccountId()); - if (d == null) { - d = new ApprovalDetail(ca.getAccountId()); - ad.put(d.getAccount(), d); - } - d.add(ca); - } - acc.want(ad.keySet()); - approvals = new ArrayList<ApprovalDetail>(ad.values()); - Collections.sort(approvals, new Comparator<ApprovalDetail>() { - public int compare(final ApprovalDetail o1, final ApprovalDetail o2) { - return o2.sortOrder.compareTo(o1.sortOrder); - } - }); - - currentPatchSetId = change.currentPatchSetId(); - if (currentPatchSetId != null) { - currentDetail = new PatchSetDetail(); - currentDetail.load(db, getCurrentPatchSet()); - - final HashSet<Change.Id> changesToGet = new HashSet<Change.Id>(); - final List<Change.Id> ancestorOrder = new ArrayList<Change.Id>(); - for (final PatchSetAncestor a : db.patchSetAncestors().ancestorsOf( - currentPatchSetId).toList()) { - for (PatchSet p : db.patchSets().byRevision(a.getAncestorRevision())) { - final Change.Id ck = p.getKey().getParentKey(); - if (changesToGet.add(ck)) { - ancestorOrder.add(ck); - } - } - } - - final RevId cprev = getCurrentPatchSet().getRevision(); - final List<PatchSetAncestor> descendants = - cprev != null ? db.patchSetAncestors().descendantsOf(cprev).toList() - : Collections.<PatchSetAncestor> emptyList(); - for (final PatchSetAncestor a : descendants) { - changesToGet.add(a.getPatchSet().getParentKey()); - } - final Map<Change.Id, Change> m = - db.changes().toMap(db.changes().get(changesToGet)); - - dependsOn = new ArrayList<ChangeInfo>(); - for (final Change.Id a : ancestorOrder) { - final Change ac = m.get(a); - if (ac != null) { - dependsOn.add(new ChangeInfo(ac, acc)); - } - } - - neededBy = new ArrayList<ChangeInfo>(); - for (final PatchSetAncestor a : descendants) { - final Change ac = m.get(a.getPatchSet().getParentKey()); - if (ac != null) { - neededBy.add(new ChangeInfo(ac, acc)); - } - } - - Collections.sort(neededBy, new Comparator<ChangeInfo>() { - public int compare(final ChangeInfo o1, final ChangeInfo o2) { - // TODO sort neededBy by something more reasonable than Id - return o1.getId().get() - o2.getId().get(); - } - }); - } - - accounts = acc.create(); - } - - public AccountInfoCache getAccounts() { - return accounts; - } - - public Change getChange() { - return change; - } - - public List<ChangeInfo> getDependsOn() { - return dependsOn; - } - - public List<ChangeInfo> getNeededBy() { - return neededBy; - } - - public List<ChangeMessage> getMessages() { - return messages; - } - - public List<PatchSet> getPatchSets() { - return patchSets; - } - - public List<ApprovalDetail> getApprovals() { - return approvals; - } - - public PatchSet getCurrentPatchSet() { - if (currentPatchSetId != null) { - // We search through the list backwards because its *very* likely - // that the current patch set is also the last patch set. - // - for (int i = patchSets.size() - 1; i >= 0; i--) { - final PatchSet ps = patchSets.get(i); - if (ps.getKey().equals(currentPatchSetId)) { - return ps; - } - } - } - return null; - } - - public PatchSetDetail getCurrentPatchSetDetail() { - return currentDetail; - } - - public String getDescription() { - return currentDetail != null ? currentDetail.getInfo().getMessage() : ""; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/ChangeInfo.java b/webapp/src/com/google/gerrit/client/data/ChangeInfo.java deleted file mode 100644 index bc9a244c6c..0000000000 --- a/webapp/src/com/google/gerrit/client/data/ChangeInfo.java +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.Change; - -public class ChangeInfo { - protected Change.Id id; - protected Account.Id owner; - protected String subject; - protected Change.Status status; - protected ProjectInfo project; - protected boolean starred; - - protected ChangeInfo() { - } - - public ChangeInfo(final Change c, final AccountInfoCacheFactory acc) { - id = c.getKey(); - owner = c.getOwner(); - subject = c.getSubject(); - status = c.getStatus(); - project = new ProjectInfo(c.getDest().getParentKey()); - - acc.want(owner); - } - - public Change.Id getId() { - return id; - } - - public Account.Id getOwner() { - return owner; - } - - public String getSubject() { - return subject; - } - - public Change.Status getStatus() { - return status; - } - - public ProjectInfo getProject() { - return project; - } - - public boolean isStarred() { - return starred; - } - - public void setStarred(final boolean s) { - starred = s; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/GerritConfig.java b/webapp/src/com/google/gerrit/client/data/GerritConfig.java deleted file mode 100644 index a48e11e2e5..0000000000 --- a/webapp/src/com/google/gerrit/client/data/GerritConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import java.util.ArrayList; -import java.util.List; - -public class GerritConfig { - private String canonicalUrl; - private GitwebLink gitweb; - private List<ApprovalType> approvalTypes; - - public GerritConfig() { - } - - public String getCanonicalUrl() { - return canonicalUrl; - } - - public void setCanonicalUrl(final String u) { - canonicalUrl = u; - } - - public GitwebLink getGitwebLink() { - return gitweb; - } - - public void setGitwebLink(final GitwebLink w) { - gitweb = w; - } - - public void add(final ApprovalType t) { - initApprovalTypes(); - approvalTypes.add(t); - } - - public List<ApprovalType> getApprovalTypes() { - initApprovalTypes(); - return approvalTypes; - } - - private void initApprovalTypes() { - if (approvalTypes == null) { - approvalTypes = new ArrayList<ApprovalType>(); - } - } -} diff --git a/webapp/src/com/google/gerrit/client/data/GitwebLink.java b/webapp/src/com/google/gerrit/client/data/GitwebLink.java deleted file mode 100644 index a39f6c9a2b..0000000000 --- a/webapp/src/com/google/gerrit/client/data/GitwebLink.java +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.Branch; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.reviewdb.Project; -import com.google.gwt.http.client.URL; - -/** Link to an external gitweb server. */ -public class GitwebLink { - protected String baseUrl; - - protected GitwebLink() { - } - - public GitwebLink(final String base) { - baseUrl = base + "?"; - } - - public String toRevision(final Project.NameKey project, final PatchSet ps) { - final StringBuilder r = new StringBuilder(); - p(r, project); - h(r, ps); - return baseUrl + r; - } - - public String toProject(final Project.NameKey project) { - final StringBuilder r = new StringBuilder(); - p(r, project); - a(r, "summary"); - return baseUrl + r; - } - - public String toBranch(final Branch.NameKey branch) { - final StringBuilder r = new StringBuilder(); - p(r, branch.getParentKey()); - h(r, branch); - a(r, "shortlog"); - return baseUrl + r; - } - - private static void p(final StringBuilder r, final Project.NameKey project) { - String n = project.get(); - if (!n.endsWith(".git")) { - n += ".git"; - } - var(r, "p", n); - } - - private static void h(final StringBuilder r, final PatchSet ps) { - var(r, "h", ps.getRevision().get()); - } - - private static void h(final StringBuilder r, final Branch.NameKey branch) { - var(r, "h", branch.get()); - } - - private static void a(final StringBuilder r, final String where) { - var(r, "a", where); - } - - private static void var(final StringBuilder r, final String n, final String v) { - if (r.length() > 0) { - r.append(";"); - } - r.append(n); - r.append("="); - r.append(URL.encodeComponent(v)); - } -} diff --git a/webapp/src/com/google/gerrit/client/data/LineWithComments.java b/webapp/src/com/google/gerrit/client/data/LineWithComments.java deleted file mode 100644 index 3e7fb27ab0..0000000000 --- a/webapp/src/com/google/gerrit/client/data/LineWithComments.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.PatchLineComment; - -import java.util.ArrayList; -import java.util.List; - -public abstract class LineWithComments { - protected List<PatchLineComment> comments; - - protected LineWithComments() { - } - - public List<PatchLineComment> getComments() { - return comments; - } - - public void addComment(final PatchLineComment plc) { - if (comments == null) { - comments = new ArrayList<PatchLineComment>(4); - } - comments.add(plc); - } -} diff --git a/webapp/src/com/google/gerrit/client/data/MineStarredInfo.java b/webapp/src/com/google/gerrit/client/data/MineStarredInfo.java deleted file mode 100644 index 82e0999010..0000000000 --- a/webapp/src/com/google/gerrit/client/data/MineStarredInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.changes.MineStarredScreen; -import com.google.gerrit.client.reviewdb.Account; - -import java.util.List; - -/** Summary information needed for {@link MineStarredScreen}. */ -public class MineStarredInfo { - protected AccountInfoCache accounts; - protected Account.Id owner; - protected List<ChangeInfo> starred; - - protected MineStarredInfo() { - } - - public MineStarredInfo(final Account.Id forUser) { - owner = forUser; - } - - public AccountInfoCache getAccounts() { - return accounts; - } - - public void setAccounts(final AccountInfoCache ac) { - accounts = ac; - } - - public Account.Id getOwner() { - return owner; - } - - public List<ChangeInfo> getStarred() { - return starred; - } - - public void setStarred(List<ChangeInfo> c) { - starred = c; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/PatchLine.java b/webapp/src/com/google/gerrit/client/data/PatchLine.java deleted file mode 100644 index 7c6ed59461..0000000000 --- a/webapp/src/com/google/gerrit/client/data/PatchLine.java +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -/** A single line of a 2-way patch file. */ -public class PatchLine extends LineWithComments { - public static enum Type { - FILE_HEADER, - - HUNK_HEADER, - - PRE_IMAGE, - - CONTEXT, - - POST_IMAGE; - } - - protected int oldLineNumber; - protected int newLineNumber; - protected PatchLine.Type type; - protected String text; - - protected PatchLine() { - } - - public PatchLine(final int oLine, final int nLine, final PatchLine.Type t, - final String s) { - oldLineNumber = oLine; - newLineNumber = nLine; - type = t; - text = s; - } - - public int getOldLineNumber() { - return oldLineNumber; - } - - public int getNewLineNumber() { - return newLineNumber; - } - - public PatchLine.Type getType() { - return type; - } - - public String getText() { - return text; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/PatchSetDetail.java b/webapp/src/com/google/gerrit/client/data/PatchSetDetail.java deleted file mode 100644 index 4eca6e4019..0000000000 --- a/webapp/src/com/google/gerrit/client/data/PatchSetDetail.java +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.reviewdb.PatchSetInfo; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gwtorm.client.OrmException; - -import java.util.List; - -public class PatchSetDetail { - protected PatchSet patchSet; - protected PatchSetInfo info; - protected List<Patch> patches; - - public PatchSetDetail() { - } - - public void load(final ReviewDb db, final PatchSet ps) throws OrmException { - patchSet = ps; - info = db.patchSetInfo().get(patchSet.getKey()); - patches = db.patches().byPatchSet(patchSet.getKey()).toList(); - } - - public PatchSet getPatchSet() { - return patchSet; - } - - public PatchSetInfo getInfo() { - return info; - } - - public List<Patch> getPatches() { - return patches; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/ProjectInfo.java b/webapp/src/com/google/gerrit/client/data/ProjectInfo.java deleted file mode 100644 index 86f68faf08..0000000000 --- a/webapp/src/com/google/gerrit/client/data/ProjectInfo.java +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.reviewdb.Project; - -public class ProjectInfo { - protected Project.NameKey key; - - protected ProjectInfo() { - } - - public ProjectInfo(final Project.NameKey key) { - this.key = key; - } - - public String getName() { - return key.get(); - } -} diff --git a/webapp/src/com/google/gerrit/client/data/SideBySideLine.java b/webapp/src/com/google/gerrit/client/data/SideBySideLine.java deleted file mode 100644 index 3f0537ad3b..0000000000 --- a/webapp/src/com/google/gerrit/client/data/SideBySideLine.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -/** A line of a file in a side-by-side view. */ -public class SideBySideLine extends LineWithComments { - public static enum Type { - DELETE, INSERT, EQUAL; - } - - protected int lineNumber; - protected SideBySideLine.Type type; - protected String text; - - protected SideBySideLine() { - } - - public SideBySideLine(final int line, final SideBySideLine.Type t, - final String s) { - lineNumber = line; - type = t; - text = s; - } - - public int getLineNumber() { - return lineNumber; - } - - public SideBySideLine.Type getType() { - return type; - } - - public String getText() { - return text; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/SideBySidePatchDetail.java b/webapp/src/com/google/gerrit/client/data/SideBySidePatchDetail.java deleted file mode 100644 index f2b63f6f27..0000000000 --- a/webapp/src/com/google/gerrit/client/data/SideBySidePatchDetail.java +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.patches.PatchSideBySideScreen; -import com.google.gerrit.client.reviewdb.Patch; - -import java.util.List; - -/** Detail necessary to display {@link PatchSideBySideScreen}. */ -public class SideBySidePatchDetail extends BasePatchDetail { - protected int fileCount; - protected int lineCount; - protected List<List<SideBySideLine>> lines; - - protected SideBySidePatchDetail() { - } - - public SideBySidePatchDetail(final Patch p, final AccountInfoCache aic) { - super(p, aic); - } - - public int getFileCount() { - return fileCount; - } - - public int getLineCount() { - return lineCount; - } - - public List<List<SideBySideLine>> getLines() { - return lines; - } - - public void setLines(final int fc, final int lc, - final List<List<SideBySideLine>> in) { - fileCount = fc; - lineCount = lc; - lines = in; - } -} diff --git a/webapp/src/com/google/gerrit/client/data/SystemInfoService.java b/webapp/src/com/google/gerrit/client/data/SystemInfoService.java deleted file mode 100644 index 4859a604d8..0000000000 --- a/webapp/src/com/google/gerrit/client/data/SystemInfoService.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtjsonrpc.client.AllowCrossSiteRequest; -import com.google.gwtjsonrpc.client.HostPageCache; -import com.google.gwtjsonrpc.client.RemoteJsonService; - -public interface SystemInfoService extends RemoteJsonService { - @AllowCrossSiteRequest - @HostPageCache(name = "gerrit_gerritconfig", once = true) - void loadGerritConfig(AsyncCallback<GerritConfig> callback); -} diff --git a/webapp/src/com/google/gerrit/client/data/UnifiedPatchDetail.java b/webapp/src/com/google/gerrit/client/data/UnifiedPatchDetail.java deleted file mode 100644 index 8280231077..0000000000 --- a/webapp/src/com/google/gerrit/client/data/UnifiedPatchDetail.java +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.data; - -import com.google.gerrit.client.patches.PatchUnifiedScreen; -import com.google.gerrit.client.reviewdb.Patch; - -import java.util.List; - -/** Detail necessary to display {@link PatchUnifiedScreen}. */ -public class UnifiedPatchDetail extends BasePatchDetail { - protected List<PatchLine> lines; - - protected UnifiedPatchDetail() { - } - - public UnifiedPatchDetail(final Patch p, final AccountInfoCache aic) { - super(p, aic); - } - - public List<PatchLine> getLines() { - return lines; - } - - public void setLines(final List<PatchLine> in) { - lines = in; - } -} diff --git a/webapp/src/com/google/gerrit/client/greenCheck.png b/webapp/src/com/google/gerrit/client/greenCheck.png Binary files differdeleted file mode 100644 index cd70687c82..0000000000 --- a/webapp/src/com/google/gerrit/client/greenCheck.png +++ /dev/null diff --git a/webapp/src/com/google/gerrit/client/patches/AbstractPatchContentTable.java b/webapp/src/com/google/gerrit/client/patches/AbstractPatchContentTable.java deleted file mode 100644 index 177f888700..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/AbstractPatchContentTable.java +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.FormatUtil; -import com.google.gerrit.client.Gerrit; -import com.google.gerrit.client.changes.Util; -import com.google.gerrit.client.data.AccountInfoCache; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.reviewdb.PatchLineComment; -import com.google.gerrit.client.ui.ComplexDisclosurePanel; -import com.google.gerrit.client.ui.FancyFlexTable; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.InlineLabel; -import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter; -import com.google.gwtjsonrpc.client.VoidResult; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; - -public abstract class AbstractPatchContentTable extends FancyFlexTable<Object> { - private static final long AGE = 7 * 24 * 60 * 60 * 1000L; - protected AccountInfoCache accountCache = AccountInfoCache.empty(); - protected Patch.Id patchKey; - private final Timestamp aged = - new Timestamp(System.currentTimeMillis() - AGE); - - protected AbstractPatchContentTable() { - table.setStyleName("gerrit-PatchContentTable"); - } - - @Override - protected MyFlexTable createFlexTable() { - return new DoubleClickFlexTable(); - } - - @Override - protected Object getRowItemKey(final Object item) { - return null; - } - - /** Invoked when the user clicks on a table cell. */ - protected abstract void onCellDoubleClick(int row, int column); - - protected PatchLineComment newComment(final int line, final short side) { - final PatchLineComment r = - new PatchLineComment(new PatchLineComment.Id(patchKey, "blargh"), line, - Gerrit.getUserAccount().getId()); - r.setSide(side); - r.setMessage(""); - return r; - } - - protected void createCommentEditor(final int row, final int column, - final int line, final short side) { - if (!Gerrit.isSignedIn()) { - Gerrit.doSignIn(new AsyncCallback<VoidResult>() { - public void onSuccess(final VoidResult result) { - createCommentEditor(row, column, line, side); - } - - public void onFailure(Throwable caught) { - } - }); - return; - } - - final PatchLineComment newComment = newComment(line, side); - table.insertRow(row); - table.setWidget(row, column, new CommentEditorPanel(newComment) { - @Override - void onCancel() { - final int n = table.getRowCount(); - for (int i = 0; i < n; i++) { - if (column < table.getCellCount(i) - && table.getWidget(i, column) == this) { - table.removeRow(i); - break; - } - } - } - }); - } - - @Override - protected void onOpenItem(final Object item) { - if (item instanceof CommentList) { - for (final ComplexDisclosurePanel p : ((CommentList) item).panels) { - p.setOpen(!p.isOpen()); - } - } - } - - public void setAccountInfoCache(final AccountInfoCache aic) { - assert aic != null; - accountCache = aic; - } - - public void setPatchKey(final Patch.Id id) { - patchKey = id; - } - - protected void bindComment(final int row, final int col, - final PatchLineComment line, final boolean isLast) { - final LineCommentPanel mp = new LineCommentPanel(line); - String panelHeader; - final ComplexDisclosurePanel panel; - - if (line.getAuthor() != null) { - panelHeader = FormatUtil.nameEmail(accountCache.get(line.getAuthor())); - } else { - panelHeader = Util.C.messageNoAuthor(); - } - - if (isLast) { - mp.isRecent = true; - } else { - // TODO Instead of opening messages by strict age, do it by "unread"? - mp.isRecent = line.getWrittenOn().after(aged); - } - - panel = new ComplexDisclosurePanel(panelHeader, mp.isRecent); - panel.getHeader().add( - new InlineLabel(Util.M.messageWrittenOn(FormatUtil.mediumFormat(line - .getWrittenOn())))); - if (line.getStatus() == PatchLineComment.Status.DRAFT) { - final InlineLabel d = new InlineLabel(PatchUtil.C.draft()); - d.setStyleName("CommentIsDraftFlag"); - panel.getHeader().add(d); - } - panel.setContent(mp); - table.setWidget(row, col, panel); - - final FlexCellFormatter fmt = table.getFlexCellFormatter(); - fmt.setStyleName(row, col, "Comment"); - - CommentList l = (CommentList) getRowItem(row); - if (l == null) { - l = new CommentList(); - setRowItem(row, l); - } - l.comments.add(line); - l.panels.add(panel); - } - - protected static class CommentList { - final List<PatchLineComment> comments = new ArrayList<PatchLineComment>(); - final List<ComplexDisclosurePanel> panels = - new ArrayList<ComplexDisclosurePanel>(); - } - - protected class DoubleClickFlexTable extends MyFlexTable { - public DoubleClickFlexTable() { - sinkEvents(Event.ONDBLCLICK); - } - - @Override - public void onBrowserEvent(final Event event) { - switch (DOM.eventGetType(event)) { - case Event.ONDBLCLICK: { - // Find out which cell was actually clicked. - Element td = getEventTargetCell(event); - if (td == null) { - return; - } - Element tr = DOM.getParent(td); - Element body = DOM.getParent(tr); - int row = DOM.getChildIndex(body, tr); - int column = DOM.getChildIndex(tr, td); - onCellDoubleClick(row, column); - break; - } - default: - super.onBrowserEvent(event); - } - } - } -} diff --git a/webapp/src/com/google/gerrit/client/patches/CommentEditorPanel.java b/webapp/src/com/google/gerrit/client/patches/CommentEditorPanel.java deleted file mode 100644 index b05484cfca..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/CommentEditorPanel.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.reviewdb.PatchLineComment; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.ClickListener; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.TextArea; -import com.google.gwt.user.client.ui.Widget; - -public class CommentEditorPanel extends Composite implements ClickListener { - private final PatchLineComment comment; - private final TextArea text; - private final Button save; - private final Button cancel; - - public CommentEditorPanel(final PatchLineComment plc) { - comment = plc; - - final FlowPanel body = new FlowPanel(); - body.setStyleName("gerrit-CommentEditor"); - - text = new TextArea(); - text.setCharacterWidth(60); - text.setVisibleLines(5); - body.add(text); - - final FlowPanel buttons = new FlowPanel(); - buttons.setStyleName("gerrit-CommentEditor-Buttons"); - body.add(buttons); - - save = new Button(); - save.setText("Save"); - save.addClickListener(this); - buttons.add(save); - - cancel = new Button(); - cancel.setText("Cancel"); - cancel.addClickListener(this); - buttons.add(cancel); - - initWidget(body); - } - - public void onClick(Widget sender) { - if (sender == save) { - onSave(); - } else if (sender == cancel) { - onCancel(); - } - } - - void onSave() { - } - - void onCancel() { - } -} diff --git a/webapp/src/com/google/gerrit/client/patches/LineCommentPanel.java b/webapp/src/com/google/gerrit/client/patches/LineCommentPanel.java deleted file mode 100644 index 856fbb7ed4..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/LineCommentPanel.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.reviewdb.PatchLineComment; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.Label; - -public class LineCommentPanel extends Composite { - PatchLineComment comment; - boolean isRecent; - - public LineCommentPanel(final PatchLineComment msg) { - comment = msg; - final Label l = new Label(comment.getMessage().trim()); - l.setStyleName("gerrit-PatchLineComment"); - initWidget(l); - } -} diff --git a/webapp/src/com/google/gerrit/client/patches/PatchConstants.java b/webapp/src/com/google/gerrit/client/patches/PatchConstants.java deleted file mode 100644 index 82a1b42b5f..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/PatchConstants.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gwt.i18n.client.Constants; - -public interface PatchConstants extends Constants { - String draft(); - - String patchHeaderOld(); - String patchHeaderNew(); -} diff --git a/webapp/src/com/google/gerrit/client/patches/PatchConstants.properties b/webapp/src/com/google/gerrit/client/patches/PatchConstants.properties deleted file mode 100644 index dcd572eee4..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/PatchConstants.properties +++ /dev/null @@ -1,4 +0,0 @@ -draft = (DRAFT) - -patchHeaderOld = Old Version -patchHeaderNew = New Version diff --git a/webapp/src/com/google/gerrit/client/patches/PatchDetailService.java b/webapp/src/com/google/gerrit/client/patches/PatchDetailService.java deleted file mode 100644 index e89da74451..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/PatchDetailService.java +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.data.SideBySidePatchDetail; -import com.google.gerrit.client.data.UnifiedPatchDetail; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtjsonrpc.client.AllowCrossSiteRequest; -import com.google.gwtjsonrpc.client.RemoteJsonService; - -public interface PatchDetailService extends RemoteJsonService { - @AllowCrossSiteRequest - void sideBySidePatchDetail(Patch.Id key, - AsyncCallback<SideBySidePatchDetail> callback); - - @AllowCrossSiteRequest - void unifiedPatchDetail(Patch.Id key, - AsyncCallback<UnifiedPatchDetail> callback); -} diff --git a/webapp/src/com/google/gerrit/client/patches/PatchMessages.java b/webapp/src/com/google/gerrit/client/patches/PatchMessages.java deleted file mode 100644 index 05fd9d256f..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/PatchMessages.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gwt.i18n.client.Messages; - -public interface PatchMessages extends Messages { - String patchHeaderAncestor(int id); - String patchSkipRegion(@PluralCount int lineCnt); -} diff --git a/webapp/src/com/google/gerrit/client/patches/PatchMessages.properties b/webapp/src/com/google/gerrit/client/patches/PatchMessages.properties deleted file mode 100644 index 8f5f6db451..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/PatchMessages.properties +++ /dev/null @@ -1,4 +0,0 @@ -patchHeaderAncestor = Ancestor {0} - -patchSkipRegion[one] = (... skipping 1 common line ...) -patchSkipRegion = (...skipping {0} common lines ...) diff --git a/webapp/src/com/google/gerrit/client/patches/PatchScreen.java b/webapp/src/com/google/gerrit/client/patches/PatchScreen.java deleted file mode 100644 index ffae7d0862..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/PatchScreen.java +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.ui.Screen; - -public class PatchScreen extends Screen { - protected final Patch.Id patchId; - - public PatchScreen(final Patch.Id id) { - patchId = id; - setTitleText(id.get()); - } -} diff --git a/webapp/src/com/google/gerrit/client/patches/PatchSideBySideScreen.java b/webapp/src/com/google/gerrit/client/patches/PatchSideBySideScreen.java deleted file mode 100644 index 819d463340..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/PatchSideBySideScreen.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.data.SideBySidePatchDetail; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.rpc.ScreenLoadCallback; -import com.google.gwt.user.client.ui.FlowPanel; - -public class PatchSideBySideScreen extends PatchScreen { - private SideBySideTable sbsTable; - - public PatchSideBySideScreen(final Patch.Id id) { - super(id); - } - - @Override - public void onLoad() { - if (sbsTable == null) { - initUI(); - } - - super.onLoad(); - - PatchUtil.DETAIL_SVC.sideBySidePatchDetail(patchId, - new ScreenLoadCallback<SideBySidePatchDetail>() { - public void onSuccess(final SideBySidePatchDetail r) { - // TODO Actually we want to cancel the RPC if detached. - if (isAttached()) { - display(r); - } - } - }); - } - - private void initUI() { - final FlowPanel sbsPanel = new FlowPanel(); - sbsPanel.setStyleName("gerrit-SideBySideScreen-SideBySideTable"); - sbsTable = new SideBySideTable(); - sbsPanel.add(sbsTable); - add(sbsPanel); - } - - private void display(final SideBySidePatchDetail detail) { - sbsTable.setAccountInfoCache(detail.getAccounts()); - sbsTable.display(detail); - } -} diff --git a/webapp/src/com/google/gerrit/client/patches/PatchUnifiedScreen.java b/webapp/src/com/google/gerrit/client/patches/PatchUnifiedScreen.java deleted file mode 100644 index d95d0d5527..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/PatchUnifiedScreen.java +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.data.UnifiedPatchDetail; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.rpc.ScreenLoadCallback; - -public class PatchUnifiedScreen extends PatchScreen { - private UnifiedDiffTable diffTable; - - public PatchUnifiedScreen(final Patch.Id id) { - super(id); - } - - @Override - public void onLoad() { - if (diffTable == null) { - initUI(); - } - - super.onLoad(); - - PatchUtil.DETAIL_SVC.unifiedPatchDetail(patchId, - new ScreenLoadCallback<UnifiedPatchDetail>() { - public void onSuccess(final UnifiedPatchDetail r) { - // TODO Actually we want to cancel the RPC if detached. - if (isAttached()) { - display(r); - } - } - }); - } - - private void initUI() { - diffTable = new UnifiedDiffTable(); - add(diffTable); - } - - private void display(final UnifiedPatchDetail detail) { - diffTable.setPatchKey(detail.getPatch().getKey()); - diffTable.setAccountInfoCache(detail.getAccounts()); - diffTable.display(detail.getLines()); - } -} diff --git a/webapp/src/com/google/gerrit/client/patches/PatchUtil.java b/webapp/src/com/google/gerrit/client/patches/PatchUtil.java deleted file mode 100644 index 69ea33b0ef..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/PatchUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.ui.DomUtil; -import com.google.gwt.core.client.GWT; -import com.google.gwtjsonrpc.client.JsonUtil; - -public class PatchUtil { - public static final PatchConstants C = GWT.create(PatchConstants.class); - public static final PatchMessages M = GWT.create(PatchMessages.class); - public static final PatchDetailService DETAIL_SVC; - - static { - DETAIL_SVC = GWT.create(PatchDetailService.class); - JsonUtil.bind(DETAIL_SVC, "rpc/PatchDetailService"); - } - - public static String lineToHTML(final String src) { - String html = DomUtil.escape(src); - html = expandTabs(html); - return html; - } - - private native static String expandTabs(String src) - /*-{ return src.replace(/\t/g, '<span title="Visual Tab" class="gerrit-visualtab">»</span>\t'); }-*/; -} diff --git a/webapp/src/com/google/gerrit/client/patches/SideBySideTable.java b/webapp/src/com/google/gerrit/client/patches/SideBySideTable.java deleted file mode 100644 index ce68081e6c..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/SideBySideTable.java +++ /dev/null @@ -1,255 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.data.SideBySideLine; -import com.google.gerrit.client.data.SideBySidePatchDetail; -import com.google.gerrit.client.reviewdb.PatchLineComment; -import com.google.gerrit.client.ui.DomUtil; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.InlineLabel; - -import java.util.Iterator; -import java.util.List; - -public class SideBySideTable extends AbstractPatchContentTable { - private int fileCnt; - private int maxLineNumber; - - @Override - protected void onCellDoubleClick(final int row, final int column) { - if (column > 1 && getRowItem(row) instanceof SideBySideLineList) { - final SideBySideLineList pl = (SideBySideLineList) getRowItem(row); - final short file = (short) ((column - 1) / 2); - final SideBySideLine line = pl.lines.get(file); - switch (line.getType()) { - case DELETE: - case EQUAL: - case INSERT: { - createCommentEditor(row + 1, column, line.getLineNumber(), file); - break; - } - } - } - } - - public void display(final SideBySidePatchDetail detail) { - setAccountInfoCache(detail.getAccounts()); - setPatchKey(detail.getPatch().getKey()); - fileCnt = detail.getFileCount(); - maxLineNumber = detail.getLineCount(); - - List<SideBySideLine> prior = null; - - // Generate the table in HTML, because its quicker than by DOM. - // This pass does not include the line comments; they need full - // GWT widgets and are relatively infrequent. We do them later. - // - final StringBuilder nc = new StringBuilder(); - appendHeader(nc); - for (final List<SideBySideLine> pLine : detail.getLines()) { - if (skipped(prior, pLine) > 0) { - appendSkipLine(nc); - } - prior = pLine; - appendFileLine(nc, pLine); - } - if (skipped(prior, null) > 0) { - appendSkipLine(nc); - } - resetHtml(nc.toString()); - - // Insert the comment widgets now that the table DOM has been - // parsed out of the HTML by the browser. We also bind each - // of the row item objects. - // - int row = 1; - prior = null; - for (final List<SideBySideLine> pLine : detail.getLines()) { - final int skipCnt = skipped(prior, pLine); - if (skipCnt > 0) { - bindSkipLine(row, skipCnt); - row++; - } - prior = pLine; - - setRowItem(row, new SideBySideLineList(pLine)); - - int nextComment = row; - int lastComment = row; - for (int fileId = 0; fileId < fileCnt; fileId++) { - final SideBySideLine s = pLine.get(fileId); - if (s == null) { - continue; - } - - final List<PatchLineComment> comments = s.getComments(); - if (comments == null) { - continue; - } - - for (Iterator<PatchLineComment> ci = comments.iterator(); ci.hasNext();) { - final PatchLineComment c = ci.next(); - if (nextComment == lastComment) { - lastComment++; - table.insertRow(lastComment); - table.getCellFormatter().setStyleName(lastComment, 0, S_ICON_CELL); - } - nextComment++; - table.setWidget(nextComment, 1 + 2 * fileId, null); - bindComment(nextComment, 1 + 2 * fileId + 1, c, !ci.hasNext()); - } - } - - row = lastComment + 1; - } - final int skipCnt = skipped(prior, null); - if (skipCnt > 0) { - bindSkipLine(row, skipCnt); - row++; - } - } - - private void appendHeader(final StringBuilder nc) { - final String width = (100 / fileCnt) + "%"; - nc.append("<tr>"); - nc.append("<td class=\"FileColumnHeader " + S_ICON_CELL + "\"> </td>"); - - if (fileCnt == 2) { - nc.append("<td class=\"FileColumnHeader LineNumber\"> </td>"); - nc.append("<td class=\"FileColumnHeader\" width=\""); - nc.append(width); - nc.append("\">"); - nc.append(DomUtil.escape(PatchUtil.C.patchHeaderOld())); - nc.append("</td>"); - } else { - for (int fileId = 0; fileId < fileCnt - 1; fileId++) { - nc.append("<td class=\"FileColumnHeader LineNumber\"> </td>"); - nc.append("<td class=\"FileColumnHeader\" width=\""); - nc.append(width); - nc.append("\">"); - nc.append(DomUtil.escape(PatchUtil.M.patchHeaderAncestor(fileId + 1))); - nc.append("</td>"); - } - } - - nc.append("<td class=\"FileColumnHeader LineNumber\"> </td>"); - nc.append("<td class=\"FileColumnHeader\" width=\""); - nc.append(width); - nc.append("\">"); - nc.append(DomUtil.escape(PatchUtil.C.patchHeaderNew())); - nc.append("</td>"); - - nc.append("</tr>"); - } - - private int skipped(List<SideBySideLine> prior, - final List<SideBySideLine> pLine) { - int existCnt = 0; - int gapCnt = 0; - int lines = 0; - - if (prior != null && pLine != null) { - for (int i = 0; i < fileCnt; i++) { - final SideBySideLine ps = prior.get(i); - final SideBySideLine cs = pLine.get(i); - if (ps != null && cs != null) { - existCnt++; - if (ps.getLineNumber() + 1 != cs.getLineNumber()) { - lines = - Math.max(lines, cs.getLineNumber() - ps.getLineNumber() - 1); - gapCnt++; - } - } - } - } else if (prior != null) { - for (int i = 0; i < fileCnt; i++) { - final SideBySideLine ps = prior.get(i); - if (ps != null) { - existCnt++; - if (ps.getLineNumber() < maxLineNumber) { - lines = Math.max(lines, maxLineNumber - ps.getLineNumber() - 1); - gapCnt++; - } - } - } - } else { - for (int i = 0; i < fileCnt; i++) { - final SideBySideLine cs = pLine.get(i); - if (cs != null) { - existCnt++; - if (1 != cs.getLineNumber()) { - lines = Math.max(lines, cs.getLineNumber() - 1); - gapCnt++; - } - } - } - } - return existCnt == gapCnt ? lines : 0; - } - - private void appendSkipLine(final StringBuilder body) { - body.append("<tr>"); - body.append("<td class=\"" + S_ICON_CELL + "\"> </td>"); - body.append("<td class=\"SkipLine\" colspan=\""); - body.append(fileCnt * 2); - body.append("\">"); - body.append("</td>"); - body.append("</tr>"); - } - - private void bindSkipLine(int row, final int skipCnt) { - final FlowPanel skipPanel = new FlowPanel(); - skipPanel.add(new InlineLabel(PatchUtil.M.patchSkipRegion(skipCnt))); - table.setWidget(row, 1, skipPanel); - } - - private void appendFileLine(final StringBuilder nc, - final List<SideBySideLine> line) { - nc.append("<tr>"); - nc.append("<td class=\"" + S_ICON_CELL + "\"> </td>"); - - for (int fileId = 0; fileId < fileCnt; fileId++) { - final SideBySideLine s = line.get(fileId); - if (s != null) { - nc.append("<td class=\"LineNumber\">"); - nc.append((int) s.getLineNumber()); - nc.append("</td>"); - - nc.append("<td class=\"FileLine FileLine-"); - nc.append(s.getType().name()); - nc.append("\">"); - if (!"".equals(s.getText())) - nc.append(PatchUtil.lineToHTML(s.getText())); - else - nc.append(" "); - nc.append("</td>"); - } else { - nc.append("<td class=\"LineNumber\"> </td>"); - nc.append("<td class=\"FileLine FileLineNone\"> </td>"); - } - } - - nc.append("</tr>"); - } - - private static class SideBySideLineList { - final List<SideBySideLine> lines; - - SideBySideLineList(final List<SideBySideLine> a) { - lines = a; - } - } -} diff --git a/webapp/src/com/google/gerrit/client/patches/UnifiedDiffTable.java b/webapp/src/com/google/gerrit/client/patches/UnifiedDiffTable.java deleted file mode 100644 index b522e1538f..0000000000 --- a/webapp/src/com/google/gerrit/client/patches/UnifiedDiffTable.java +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.patches; - -import com.google.gerrit.client.data.PatchLine; -import com.google.gerrit.client.reviewdb.PatchLineComment; - -import java.util.Iterator; -import java.util.List; - -public class UnifiedDiffTable extends AbstractPatchContentTable { - @Override - protected void onCellDoubleClick(final int row, final int column) { - if (column == 1 && getRowItem(row) instanceof PatchLine) { - final PatchLine pl = (PatchLine) getRowItem(row); - switch (pl.getType()) { - case PRE_IMAGE: - case CONTEXT: - createCommentEditor(row + 1, column, pl.getOldLineNumber(), (short) 0); - break; - case POST_IMAGE: - createCommentEditor(row + 1, column, pl.getOldLineNumber(), (short) 1); - break; - } - } - } - - public void display(final List<PatchLine> list) { - final StringBuilder nc = new StringBuilder(); - for (final PatchLine pLine : list) { - appendLine(nc, pLine); - } - resetHtml(nc.toString()); - - int row = 0; - for (final PatchLine pLine : list) { - setRowItem(row, pLine); - row++; - - final List<PatchLineComment> comments = pLine.getComments(); - if (comments != null) { - for (final Iterator<PatchLineComment> ci = comments.iterator(); ci - .hasNext();) { - final PatchLineComment c = ci.next(); - table.insertRow(row); - bindComment(row, 1, c, !ci.hasNext()); - row++; - } - } - } - } - - private void appendLine(final StringBuilder nc, final PatchLine line) { - nc.append("<tr>"); - nc.append("<td class=\"" + S_ICON_CELL + "\"> </td>"); - - nc.append("<td class=\"DiffText DiffText-"); - nc.append(line.getType().name()); - nc.append("\">"); - if (!"".equals(line.getText())) - nc.append(PatchUtil.lineToHTML(line.getText())); - else - nc.append(" "); - nc.append("</td>"); - - nc.append("</tr>"); - } -} diff --git a/webapp/src/com/google/gerrit/client/redNot.png b/webapp/src/com/google/gerrit/client/redNot.png Binary files differdeleted file mode 100644 index 4e83a8fdb5..0000000000 --- a/webapp/src/com/google/gerrit/client/redNot.png +++ /dev/null diff --git a/webapp/src/com/google/gerrit/client/reviewdb/Account.java b/webapp/src/com/google/gerrit/client/reviewdb/Account.java deleted file mode 100644 index c3b681858a..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/Account.java +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.IntKey; - -import java.sql.Timestamp; - -/** Preferences and information about a single user. */ -public final class Account { - /** Key local to Gerrit to identify a user. */ - public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> { - @Column - protected int id; - - protected Id() { - } - - public Id(final int id) { - this.id = id; - } - - @Override - public int get() { - return id; - } - } - - @Column - protected Id accountId; - - /** Date and time the user registered with the review server. */ - @Column - protected Timestamp registeredOn; - - /** Full name of the user ("Given-name Surname" style). */ - @Column(notNull = false) - protected String fullName; - - /** Email address the user prefers to be contacted through. */ - @Column(notNull = false) - protected String preferredEmail; - - /** Non-Internet based contact details for the account's owner. */ - @Column(notNull = false) - protected ContactInformation contact; - - protected Account() { - } - - /** - * Create a new account. - * - * @param newId unique id, see {@link ReviewDb#nextAccountId()}. - */ - public Account(final Account.Id newId) { - accountId = newId; - registeredOn = new Timestamp(System.currentTimeMillis()); - } - - /** Get local id of this account, to link with in other entities */ - public Account.Id getId() { - return accountId; - } - - /** Get the full name of the user ("Given-name Surname" style). */ - public String getFullName() { - return fullName; - } - - /** Set the full name of the user ("Given-name Surname" style). */ - public void setFullName(final String name) { - fullName = name; - } - - /** Email address the user prefers to be contacted through. */ - public String getPreferredEmail() { - return preferredEmail; - } - - /** Set the email address the user prefers to be contacted through. */ - public void setPreferredEmail(final String addr) { - preferredEmail = addr; - } - - /** Get the date and time the user first registered. */ - public Timestamp getRegisteredOn() { - return registeredOn; - } - - public ContactInformation getContactInformation() { - return contact; - } - - public void setContactInformation(final ContactInformation i) { - contact = i; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/AccountAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/AccountAccess.java deleted file mode 100644 index 63df47cfe7..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/AccountAccess.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -/** Access interface for {@link Account}. */ -public interface AccountAccess extends Access<Account, Account.Id> { - /** Locate an account by our locally generated identity. */ - @PrimaryKey("accountId") - Account byId(Account.Id key) throws OrmException; - - @Query("WHERE preferredEmail = ? LIMIT 2") - ResultSet<Account> byPreferredEmail(String email) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/AccountAgreement.java b/webapp/src/com/google/gerrit/client/reviewdb/AccountAgreement.java deleted file mode 100644 index 26bfa834c4..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/AccountAgreement.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -import java.sql.Timestamp; - -/** Electronic acceptance of a {@link ContributorAgreement} by {@link Account} */ -public final class AccountAgreement { - public static class Key implements com.google.gwtorm.client.Key<Account.Id> { - @Column - protected Account.Id accountId; - - @Column - protected ContributorAgreement.Id claId; - - protected Key() { - accountId = new Account.Id(); - claId = new ContributorAgreement.Id(); - } - - public Key(final Account.Id account, final ContributorAgreement.Id cla) { - this.accountId = account; - this.claId = cla; - } - - public Account.Id getParentKey() { - return accountId; - } - - @Override - public int hashCode() { - return accountId.hashCode() * 31 + claId.hashCode(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof Key && ((Key) o).accountId.equals(accountId) - && ((Key) o).claId.equals(claId); - } - } - - protected static final char NEW_CODE = 'n'; - - public static enum Status { - NEW(NEW_CODE), - - VERIFIED('V'), - - REJECTED('R'); - - private final char code; - - private Status(final char c) { - code = c; - } - - public char getCode() { - return code; - } - - public static Status forCode(final char c) { - for (final Status s : Status.values()) { - if (s.code == c) { - return s; - } - } - return null; - } - } - - - @Column(name = Column.NONE) - protected Key key; - - @Column - protected Timestamp acceptedOn; - - @Column - protected char status; - - @Column(notNull = false) - protected Account.Id reviewedBy; - - @Column(notNull = false) - protected Timestamp reviewedOn; - - @Column(notNull = false, length = Integer.MAX_VALUE) - protected String reviewComments; - - protected AccountAgreement() { - } - - public AccountAgreement(final AccountAgreement.Key k) { - key = k; - acceptedOn = new Timestamp(System.currentTimeMillis()); - status = Status.NEW.getCode(); - } - - public Timestamp getAcceptedOn() { - return acceptedOn; - } - - public Status getStatus() { - return Status.forCode(status); - } - - public Timestamp getReviewedOn() { - return reviewedOn; - } - - public Account.Id getReviewedBy() { - return reviewedBy; - } - - public String getReviewComments() { - return reviewComments; - } - - public void setReviewComments(final String s) { - reviewComments = s; - } - - public void review(final Status newStatus, final Account.Id by) { - status = newStatus.getCode(); - reviewedBy = by; - reviewedOn = new Timestamp(System.currentTimeMillis()); - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/AccountAgreementAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/AccountAgreementAccess.java deleted file mode 100644 index 77285a3bfc..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/AccountAgreementAccess.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface AccountAgreementAccess extends - Access<AccountAgreement, AccountAgreement.Key> { - @PrimaryKey("key") - AccountAgreement get(AccountAgreement.Key key) throws OrmException; - - @Query("WHERE key.accountId = ? ORDER BY acceptedOn DESC") - ResultSet<AccountAgreement> byAccount(Account.Id id) throws OrmException; - - @Query("WHERE status = '" + AccountAgreement.NEW_CODE - + "' ORDER BY acceptedOn DESC") - ResultSet<AccountAgreement> unreviewed() throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/AccountExternalId.java b/webapp/src/com/google/gerrit/client/reviewdb/AccountExternalId.java deleted file mode 100644 index bfc072381e..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/AccountExternalId.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** Association of an external account identifier to a local {@link Account}. */ -public final class AccountExternalId { - public static class Key implements com.google.gwtorm.client.Key<Account.Id> { - @Column - protected Account.Id accountId; - - @Column - protected String externalId; - - protected Key() { - accountId = new Account.Id(); - } - - public Key(final Account.Id a, final String e) { - accountId = a; - externalId = e; - } - - public Account.Id getParentKey() { - return accountId; - } - - @Override - public int hashCode() { - return accountId.hashCode() * 31 + externalId.hashCode(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof Key && ((Key) o).accountId.equals(accountId) - && ((Key) o).externalId.equals(externalId); - } - } - - @Column(name = Column.NONE) - protected Key key; - - protected AccountExternalId() { - } - - /** - * Create a new binding to an external identity. - * - * @param k the binding key. - */ - public AccountExternalId(final AccountExternalId.Key k) { - key = k; - } - - /** Get local id of this account, to link with in other entities */ - public Account.Id getAccountId() { - return key.accountId; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/AccountExternalIdAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/AccountExternalIdAccess.java deleted file mode 100644 index 40f5181fd7..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/AccountExternalIdAccess.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface AccountExternalIdAccess extends - Access<AccountExternalId, AccountExternalId.Key> { - @PrimaryKey("key") - AccountExternalId get(AccountExternalId.Key key) throws OrmException; - - @Query("WHERE key.externalId = ? LIMIT 2") - ResultSet<AccountExternalId> byExternal(String id) throws OrmException; - - @Query("WHERE key.accountId = ?") - ResultSet<AccountExternalId> byAccount(Account.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/AccountGroup.java b/webapp/src/com/google/gerrit/client/reviewdb/AccountGroup.java deleted file mode 100644 index a59fd7104b..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/AccountGroup.java +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.IntKey; -import com.google.gwtorm.client.StringKey; - -/** Named group of one or more accounts, typically used for access controls. */ -public final class AccountGroup { - /** Group name key */ - public static class NameKey extends - StringKey<com.google.gwtorm.client.Key<?>> { - @Column(length = 40) - protected String name; - - protected NameKey() { - } - - public NameKey(final String n) { - name = n; - } - - @Override - public String get() { - return name; - } - } - - /** Synthetic key to link to within the database */ - public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> { - @Column - protected int id; - - protected Id() { - } - - public Id(final int id) { - this.id = id; - } - - @Override - public int get() { - return id; - } - } - - @Column - protected NameKey name; - - @Column - protected Id groupId; - - @Column(length = Integer.MAX_VALUE, notNull = false) - protected String description; - - protected AccountGroup() { - } - - public AccountGroup(final AccountGroup.NameKey newName, - final AccountGroup.Id newId) { - name = newName; - groupId = newId; - } - - public AccountGroup.Id getId() { - return groupId; - } - - public String getName() { - return name.get(); - } - - public String getDescription() { - return description; - } - - public void setDescription(final String d) { - description = d; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/AccountGroupAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/AccountGroupAccess.java deleted file mode 100644 index f6e8571692..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/AccountGroupAccess.java +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.SecondaryKey; - -public interface AccountGroupAccess extends - Access<AccountGroup, AccountGroup.NameKey> { - @PrimaryKey("name") - AccountGroup get(AccountGroup.NameKey name) throws OrmException; - - @SecondaryKey("groupId") - AccountGroup byGroupId(AccountGroup.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/AccountGroupMember.java b/webapp/src/com/google/gerrit/client/reviewdb/AccountGroupMember.java deleted file mode 100644 index e9c1c13d0f..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/AccountGroupMember.java +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** Membership of an {@link Account} in an {@link AccountGroup}. */ -public final class AccountGroupMember { - public static class Key implements com.google.gwtorm.client.Key<Account.Id> { - @Column - protected Account.Id accountId; - - @Column - protected AccountGroup.Id groupId; - - protected Key() { - accountId = new Account.Id(); - groupId = new AccountGroup.Id(); - } - - public Key(final Account.Id a, final AccountGroup.Id g) { - accountId = a; - groupId = g; - } - - public Account.Id getParentKey() { - return accountId; - } - - @Override - public int hashCode() { - return accountId.hashCode() * 31 + groupId.hashCode(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof Key && ((Key) o).accountId.equals(accountId) - && ((Key) o).groupId.equals(groupId); - } - } - - @Column(name = Column.NONE) - protected Key key; - - /** If true, this user owns this group and can edit the membership. */ - @Column - protected boolean owner; - - protected AccountGroupMember() { - } - - public AccountGroupMember(final AccountGroupMember.Key k) { - key = k; - } - - public Account.Id getAccountId() { - return key.accountId; - } - - public AccountGroup.Id getAccountGroupId() { - return key.groupId; - } - - public boolean isGroupOwner() { - return owner; - } - - public void setGroupOwner(final boolean o) { - owner = o; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/AccountGroupMemberAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/AccountGroupMemberAccess.java deleted file mode 100644 index d5ea0e32bb..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/AccountGroupMemberAccess.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface AccountGroupMemberAccess extends - Access<AccountGroupMember, AccountGroupMember.Key> { - @PrimaryKey("key") - AccountGroupMember get(AccountGroupMember.Key key) throws OrmException; - - @Query("WHERE key.accountId = ?") - ResultSet<AccountGroupMember> byAccount(Account.Id id) throws OrmException; - - @Query("WHERE key.groupId = ?") - ResultSet<AccountGroupMember> byGroup(AccountGroup.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategory.java b/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategory.java deleted file mode 100644 index 8296c12a71..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategory.java +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.Key; -import com.google.gwtorm.client.StringKey; - -/** Types of approvals that can be associated with a {@link Change}. */ -public final class ApprovalCategory { - public static class Id extends StringKey<Key<?>> { - @Column(length = 4) - protected String id; - - protected Id() { - } - - public Id(final String a) { - id = a; - } - - @Override - public String get() { - return id; - } - } - - @Column - protected Id categoryId; - - @Column(length = 20) - protected String name; - - @Column - protected short position; - - protected ApprovalCategory() { - } - - public ApprovalCategory(final ApprovalCategory.Id id, final String name) { - this.categoryId = id; - this.name = name; - } - - public ApprovalCategory.Id getId() { - return categoryId; - } - - public String getName() { - return name; - } - - public void setName(final String n) { - name = n; - } - - public short getPosition() { - return position; - } - - public void setPosition(final short p) { - position = p; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategoryAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategoryAccess.java deleted file mode 100644 index abe5ca3ef4..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategoryAccess.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; -import com.google.gwtorm.client.SecondaryKey; - -public interface ApprovalCategoryAccess extends - Access<ApprovalCategory, ApprovalCategory.Id> { - @PrimaryKey("categoryId") - ApprovalCategory get(ApprovalCategory.Id id) throws OrmException; - - @SecondaryKey("name") - ApprovalCategory byName(String name) throws OrmException; - - @Query("ORDER BY position, name") - ResultSet<ApprovalCategory> all() throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategoryValue.java b/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategoryValue.java deleted file mode 100644 index 798963d623..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategoryValue.java +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** Valid value for a {@link ApprovalCategory}. */ -public final class ApprovalCategoryValue { - public static class Key implements - com.google.gwtorm.client.Key<ApprovalCategory.Id> { - @Column - protected ApprovalCategory.Id categoryId; - - @Column - protected short value; - - protected Key() { - categoryId = new ApprovalCategory.Id(); - } - - public Key(final ApprovalCategory.Id cat, final short v) { - categoryId = cat; - value = v; - } - - public ApprovalCategory.Id getParentKey() { - return categoryId; - } - - @Override - public int hashCode() { - return categoryId.hashCode() * 31 + value; - } - - @Override - public boolean equals(final Object o) { - return o instanceof Key && ((Key) o).categoryId.equals(categoryId) - && ((Key) o).value == value; - } - } - - @Column(name = Column.NONE) - protected Key key; - - @Column(length = 50) - protected String name; - - protected ApprovalCategoryValue() { - } - - public ApprovalCategoryValue(final ApprovalCategoryValue.Key id, - final String name) { - this.key = id; - this.name = name; - } - - public ApprovalCategory.Id getCategoryId() { - return key.categoryId; - } - - public short getValue() { - return key.value; - } - - public String getName() { - return name; - } - - public void setName(final String n) { - name = n; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategoryValueAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategoryValueAccess.java deleted file mode 100644 index ee1d727fe6..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ApprovalCategoryValueAccess.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface ApprovalCategoryValueAccess extends - Access<ApprovalCategoryValue, ApprovalCategoryValue.Key> { - @PrimaryKey("key") - ApprovalCategoryValue get(ApprovalCategoryValue.Key key) throws OrmException; - - @Query("WHERE key.categoryId = ? ORDER BY key.value") - ResultSet<ApprovalCategoryValue> byCategory(ApprovalCategory.Id id) - throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/Branch.java b/webapp/src/com/google/gerrit/client/reviewdb/Branch.java deleted file mode 100644 index 7180b4e26c..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/Branch.java +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.IntKey; -import com.google.gwtorm.client.StringKey; - -/** Registered line of development within a {@link Project}. */ -public final class Branch { - /** Branch name key */ - public static class NameKey extends StringKey<Project.NameKey> { - @Column - protected Project.NameKey projectName; - - @Column - protected String branchName; - - protected NameKey() { - projectName = new Project.NameKey(); - } - - public NameKey(final Project.NameKey proj, final String n) { - projectName = proj; - branchName = n; - } - - @Override - public String get() { - return branchName; - } - - @Override - public Project.NameKey getParentKey() { - return projectName; - } - - public String getShortName() { - final String n = get(); - - // Git style branches will tend to start with "refs/heads/". - // - if (n.startsWith("refs/heads/")) { - return n.substring("refs/heads/".length()); - } - - return n; - } - } - - /** Synthetic key to link to within the database */ - public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> { - @Column - protected int id; - - protected Id() { - } - - public Id(final int id) { - this.id = id; - } - - @Override - public int get() { - return id; - } - } - - @Column(name = Column.NONE) - protected NameKey name; - - @Column - protected Id branchId; - - protected Branch() { - } - - public Branch(final Branch.NameKey newName, final Branch.Id newId) { - name = newName; - branchId = newId; - } - - public Branch.Id getId() { - return branchId; - } - - public String getName() { - return name.get(); - } - - public String getShortName() { - return name.getShortName(); - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/BranchAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/BranchAccess.java deleted file mode 100644 index 5d7e668da5..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/BranchAccess.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; -import com.google.gwtorm.client.SecondaryKey; - -public interface BranchAccess extends Access<Branch, Branch.NameKey> { - @PrimaryKey("name") - Branch byName(Branch.NameKey name) throws OrmException; - - @SecondaryKey("branchId") - Branch byId(Branch.Id id) throws OrmException; - - @Query("WHERE name.projectName = ? ORDER BY name.branchName") - ResultSet<Branch> byProject(Project.NameKey key) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/Change.java b/webapp/src/com/google/gerrit/client/reviewdb/Change.java deleted file mode 100644 index 5a15a3bd5d..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/Change.java +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.IntKey; -import com.google.gwtorm.client.RowVersion; - -import java.sql.Timestamp; - -/** A change recommended to be inserted into {@link Branch}. */ -public final class Change { - public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> { - @Column - protected int id; - - protected Id() { - } - - public Id(final int id) { - this.id = id; - } - - @Override - public int get() { - return id; - } - - /** Parse a Change.Id out of a string representation. */ - public static Id fromString(final String str) { - return new Id(Integer.parseInt(str)); - } - } - - protected static final char STATUS_NEW = 'n'; - protected static final char STATUS_MERGED = 'M'; - - public static enum Status { - NEW(STATUS_NEW, false), - - MERGED(STATUS_MERGED, true), - - ABANDONED('A', true); - - private final char code; - private final boolean closed; - - private Status(final char c, final boolean o) { - code = c; - closed = o; - } - - public char getCode() { - return code; - } - - public boolean isClosed() { - return closed; - } - - public static Status forCode(final char c) { - for (final Status s : Status.values()) { - if (s.code == c) { - return s; - } - } - return null; - } - } - - /** Locally assigned unique identifier of the change */ - @Column - protected Id changeId; - - /** optimistic locking */ - @Column - @RowVersion - protected int rowVersion; - - /** When this change was first introduced into the database. */ - @Column - protected Timestamp createdOn; - - @Column(name = "owner_account_id") - protected Account.Id owner; - - /** The branch (and project) this change merges into. */ - @Column - protected Branch.NameKey dest; - - /** Current state code; see {@link Status}. */ - @Column - protected char status; - - /** The total number of {@link PatchSet} children in this Change. */ - @Column - protected int nbrPatchSets; - - /** The current patch set. */ - @Column - protected int currentPatchSetId; - - /** Subject from the current patch set. */ - @Column - protected String subject; - - protected Change() { - } - - public Change(final Change.Id newId, final Account.Id ownedBy, - final Branch.NameKey forBranch) { - changeId = newId; - createdOn = new Timestamp(System.currentTimeMillis()); - owner = ownedBy; - dest = forBranch; - setStatus(Status.NEW); - } - - public Change.Id getKey() { - return changeId; - } - - public int getId() { - return changeId.get(); - } - - public Timestamp getCreatedOn() { - return createdOn; - } - - public Account.Id getOwner() { - return owner; - } - - public Branch.NameKey getDest() { - return dest; - } - - public String getSubject() { - return subject; - } - - /** Get the id of the most current {@link PatchSet} in this change. */ - public PatchSet.Id currentPatchSetId() { - if (currentPatchSetId > 0) { - return new PatchSet.Id(changeId, currentPatchSetId); - } - return null; - } - - public void setCurrentPatchSet(final PatchSetInfo ps) { - currentPatchSetId = ps.getKey().get(); - subject = ps.getSubject(); - } - - /** - * Allocate a new PatchSet id within this change. - * <p> - * <b>Note: This makes the change dirty. Call update() after.</b> - */ - public PatchSet.Id newPatchSetId() { - return new PatchSet.Id(changeId, ++nbrPatchSets); - } - - public Status getStatus() { - return Status.forCode(status); - } - - public void setStatus(final Status newStatus) { - status = newStatus.getCode(); - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ChangeAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/ChangeAccess.java deleted file mode 100644 index 544e9a2ca5..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ChangeAccess.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface ChangeAccess extends Access<Change, Change.Id> { - @PrimaryKey("changeId") - Change get(Change.Id id) throws OrmException; - - @Query("WHERE owner = ? AND status = '" + Change.STATUS_NEW - + "' ORDER BY createdOn DESC") - ResultSet<Change> byOwnerOpen(Account.Id id) throws OrmException; - - @Query("WHERE owner = ? AND status = '" + Change.STATUS_MERGED - + "' ORDER BY createdOn DESC LIMIT 20") - ResultSet<Change> byOwnerMerged(Account.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ChangeApproval.java b/webapp/src/com/google/gerrit/client/reviewdb/ChangeApproval.java deleted file mode 100644 index 57f91f2903..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ChangeApproval.java +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -import java.sql.Timestamp; - -/** An approval (or negative approval) on a change. */ -public final class ChangeApproval { - public static class Key implements com.google.gwtorm.client.Key<Change.Id> { - @Column - protected Change.Id changeId; - - @Column - protected Account.Id accountId; - - @Column - protected ApprovalCategory.Id categoryId; - - protected Key() { - changeId = new Change.Id(); - accountId = new Account.Id(); - categoryId = new ApprovalCategory.Id(); - } - - public Key(final Change.Id change, final Account.Id a, - final ApprovalCategory.Id c) { - this.changeId = change; - this.accountId = a; - this.categoryId = c; - } - - public Change.Id getParentKey() { - return changeId; - } - - @Override - public int hashCode() { - int h = changeId.hashCode(); - h *= 31; - h += accountId.hashCode(); - h *= 31; - h += categoryId.hashCode(); - return h; - } - - @Override - public boolean equals(final Object o) { - return o instanceof Key && ((Key) o).changeId.equals(changeId) - && ((Key) o).accountId.equals(accountId) - && ((Key) o).categoryId.equals(categoryId); - } - } - - @Column(name = Column.NONE) - protected Key key; - - /** - * Value assigned by the user. - * <p> - * The precise meaning of "value" is up to each category. - * <p> - * In general: - * <ul> - * <li><b>< 0:</b> The approval is rejected/revoked.</li> - * <li><b>= 0:</b> No indication either way is provided.</li> - * <li><b>> 0:</b> The approval is approved/positive.</li> - * </ul> - * and in the negative and positive direction a magnitude can be assumed.The - * further from 0 the more assertive the approval. - */ - @Column - protected short value; - - @Column - protected Timestamp granted; - - protected ChangeApproval() { - } - - public ChangeApproval(final ChangeApproval.Key k) { - key = k; - setValue((short) 0); - } - - public Change.Id getChangeId() { - return key.changeId; - } - - public Account.Id getAccountId() { - return key.accountId; - } - - public ApprovalCategory.Id getCategoryId() { - return key.categoryId; - } - - public short getValue() { - return value; - } - - public void setValue(final short v) { - value = v; - granted = new Timestamp(System.currentTimeMillis()); - } - - public Timestamp getGranted() { - return granted; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ChangeApprovalAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/ChangeApprovalAccess.java deleted file mode 100644 index 4b83d7128b..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ChangeApprovalAccess.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface ChangeApprovalAccess extends - Access<ChangeApproval, ChangeApproval.Key> { - @PrimaryKey("key") - ChangeApproval get(ChangeApproval.Key key) throws OrmException; - - @Query("WHERE key.changeId = ?") - ResultSet<ChangeApproval> byChange(Change.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ChangeMessage.java b/webapp/src/com/google/gerrit/client/reviewdb/ChangeMessage.java deleted file mode 100644 index 12dbff85d5..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ChangeMessage.java +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.StringKey; - -import java.sql.Timestamp; - -/** A message attached to a {@link Change}. */ -public final class ChangeMessage { - public static class Id extends StringKey<Change.Id> { - @Column - protected Change.Id changeId; - - @Column(length = 40) - protected String uuid; - - protected Id() { - changeId = new Change.Id(); - } - - public Id(final Change.Id change, final String uuid) { - this.changeId = change; - this.uuid = uuid; - } - - @Override - public Change.Id getParentKey() { - return changeId; - } - - @Override - public String get() { - return uuid; - } - } - - @Column(name = Column.NONE) - protected Id key; - - /** Who wrote this comment; null if it was written by the Gerrit system. */ - @Column(name = "author_id", notNull = false) - protected Account.Id author; - - /** When this comment was drafted. */ - @Column - protected Timestamp writtenOn; - - /** The text left by the user. */ - @Column(notNull = false, length = Integer.MAX_VALUE) - protected String message; - - protected ChangeMessage() { - } - - public ChangeMessage(final ChangeMessage.Id k, final Account.Id a) { - key = k; - author = a; - writtenOn = new Timestamp(System.currentTimeMillis()); - } - - public ChangeMessage.Id getKey() { - return key; - } - - /** If null, the message was written 'by the Gerrit system'. */ - public Account.Id getAuthor() { - return author; - } - - public Timestamp getWrittenOn() { - return writtenOn; - } - - public String getMessage() { - return message; - } - - public void setMessage(final String s) { - message = s; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ChangeMessageAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/ChangeMessageAccess.java deleted file mode 100644 index 1ccca767e4..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ChangeMessageAccess.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface ChangeMessageAccess extends - Access<ChangeMessage, ChangeMessage.Id> { - @PrimaryKey("key") - ChangeMessage get(ChangeMessage.Id id) throws OrmException; - - @Query("WHERE key.changeId = ? ORDER BY writtenOn") - ResultSet<ChangeMessage> byChange(Change.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ContactInformation.java b/webapp/src/com/google/gerrit/client/reviewdb/ContactInformation.java deleted file mode 100644 index 1b44fe05c9..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ContactInformation.java +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** Non-Internet contact details, such as a postal address and telephone. */ -public final class ContactInformation { - @Column(length = Integer.MAX_VALUE, notNull = false) - protected String address; - - @Column(notNull = false, length = 40) - protected String country; - - @Column(notNull = false, length = 30) - protected String phoneNbr; - - @Column(notNull = false, length = 30) - protected String faxNbr; - - public ContactInformation() { - } - - public String getAddress() { - return address; - } - - public void setAddress(final String a) { - address = a; - } - - public String getCountry() { - return country; - } - - public void setCountry(final String c) { - country = c; - } - - public String getPhoneNumber() { - return phoneNbr; - } - - public void setPhoneNumber(final String p) { - phoneNbr = p; - } - - public String getFaxNumber() { - return faxNbr; - } - - public void setFaxNumber(final String f) { - faxNbr = f; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ContributorAgreement.java b/webapp/src/com/google/gerrit/client/reviewdb/ContributorAgreement.java deleted file mode 100644 index 3b24c512d1..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ContributorAgreement.java +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.IntKey; - -/** - * An agreement {@link Account} must acknowledge to contribute changes. - * - * @see AccountAgreement - */ -public final class ContributorAgreement { - public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> { - @Column(name = "cla_id") - protected int id; - - protected Id() { - } - - public Id(final int id) { - this.id = id; - } - - @Override - public int get() { - return id; - } - } - - @Column - protected Id id; - - /** Is this an active agreement contributors can use. */ - @Column - protected boolean active; - - /** Is this agreement one that covers a group of people? */ - @Column - protected boolean groupAgreement; - - /** Does this agreement require the {@link Account} to have contact details? */ - @Column - protected boolean requireContactInformation; - - /** A short name for the agreement. */ - @Column(length = 40) - protected String shortName; - - /** A short one-line description text to appear next to the name. */ - @Column(notNull = false) - protected String shortDescription; - - /** Text of the agreement, in formatted HTML */ - @Column(length = Integer.MAX_VALUE) - protected String agreementHtml; - - protected ContributorAgreement() { - } - - /** - * Create a new agreement. - * - * @param newId unique id, see {@link ReviewDb#nextAccountId()}. - * @param name a short title/name for the agreement. - */ - public ContributorAgreement(final ContributorAgreement.Id newId, - final String name) { - id = newId; - shortName = name; - } - - public ContributorAgreement.Id getId() { - return id; - } - - public boolean isActive() { - return active; - } - - public void setActive(final boolean a) { - active = a; - } - - public boolean isGroupAgreement() { - return groupAgreement; - } - - public void setGroupAgreement(final boolean g) { - groupAgreement = g; - } - - public boolean isRequireContactInformation() { - return requireContactInformation; - } - - public void setRequireContactInformation(final boolean r) { - requireContactInformation = r; - } - - public String getShortName() { - return shortName; - } - - public String getShortDescription() { - return shortDescription; - } - - public void setShortDescription(final String d) { - shortDescription = d; - } - - public String getAgreementHtml() { - return agreementHtml; - } - - public void setAgreementHtml(final String h) { - agreementHtml = h; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ContributorAgreementAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/ContributorAgreementAccess.java deleted file mode 100644 index ac6ac809a9..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ContributorAgreementAccess.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -/** Access interface for {@link ContributorAgreement}. */ -public interface ContributorAgreementAccess extends - Access<ContributorAgreement, ContributorAgreement.Id> { - @PrimaryKey("id") - ContributorAgreement get(ContributorAgreement.Id key) throws OrmException; - - @Query("WHERE active = true ORDER BY shortName") - ResultSet<ContributorAgreement> active() throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/Patch.java b/webapp/src/com/google/gerrit/client/reviewdb/Patch.java deleted file mode 100644 index 4c63288126..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/Patch.java +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.StringKey; - -/** A single modified file in a {@link PatchSet}. */ -public final class Patch { - public static class Id extends StringKey<PatchSet.Id> { - @Column(name = Column.NONE) - protected PatchSet.Id patchSetId; - - @Column - protected String fileName; - - protected Id() { - patchSetId = new PatchSet.Id(); - } - - public Id(final PatchSet.Id ps, final String name) { - this.patchSetId = ps; - this.fileName = name; - } - - @Override - public PatchSet.Id getParentKey() { - return patchSetId; - } - - @Override - public String get() { - return fileName; - } - } - - public static enum ChangeType { - ADD('A'), - - MODIFIED('M'), - - DELETED('D'), - - RENAMED('R'), - - COPIED('C'); - - private final char code; - - private ChangeType(final char c) { - code = c; - } - - public char getCode() { - return code; - } - - public static ChangeType forCode(final char c) { - for (final ChangeType s : ChangeType.values()) { - if (s.code == c) { - return s; - } - } - return null; - } - } - - public static enum PatchType { - UNIFIED('U'), - - BINARY('B'), - - N_WAY('N'); - - private final char code; - - private PatchType(final char c) { - code = c; - } - - public char getCode() { - return code; - } - - public static PatchType forCode(final char c) { - for (final PatchType s : PatchType.values()) { - if (s.code == c) { - return s; - } - } - return null; - } - } - - @Column(name = Column.NONE) - protected Id key; - - /** What sort of change is this to the path; see {@link ChangeType}. */ - @Column - protected char changeType; - - /** What type of patch is this; see {@link PatchType}. */ - @Column - protected char patchType; - - @Column(notNull = false) - protected PatchContent.Key contentSha1; - - /** Number of published comments on this patch. */ - @Column - protected int nbrComments; - - /** - * Original if {@link #changeType} is {@link ChangeType#COPIED} or - * {@link ChangeType#RENAMED}. - */ - @Column(notNull = false) - protected String sourceFileName; - - protected Patch() { - } - - public Patch(final Patch.Id newId) { - key = newId; - setChangeType(ChangeType.MODIFIED); - setPatchType(PatchType.UNIFIED); - } - - public Patch.Id getKey() { - return key; - } - - public int getCommentCount() { - return nbrComments; - } - - public ChangeType getChangeType() { - return ChangeType.forCode(changeType); - } - - public void setChangeType(final ChangeType type) { - changeType = type.getCode(); - } - - public PatchType getPatchType() { - return PatchType.forCode(patchType); - } - - public void setPatchType(final PatchType type) { - patchType = type.getCode(); - } - - public String getFileName() { - return key.fileName; - } - - public PatchContent.Key getContent() { - return contentSha1; - } - - public void setContent(final PatchContent.Key k) { - contentSha1 = k; - } - - public String getSourceFileName() { - return sourceFileName; - } - - public void setSourceFileName(final String n) { - sourceFileName = n; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchAccess.java deleted file mode 100644 index 4537597390..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchAccess.java +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface PatchAccess extends Access<Patch, Patch.Id> { - @PrimaryKey("key") - Patch get(Patch.Id id) throws OrmException; - - @Query("WHERE key.patchSetId = ? ORDER BY key.fileName") - ResultSet<Patch> byPatchSet(PatchSet.Id ps) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchContent.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchContent.java deleted file mode 100644 index 85e6604e67..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchContent.java +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** Content of a single patch file */ -public final class PatchContent { - public static class Key implements - com.google.gwtorm.client.Key<com.google.gwtorm.client.Key<?>> { - @Column(length = 40) - protected String sha1; - - protected Key() { - } - - public Key(final String ps) { - sha1 = ps; - } - - @Override - public int hashCode() { - return sha1.hashCode(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof Key && sha1.equals(((Key) o).sha1); - } - - public com.google.gwtorm.client.Key<?> getParentKey() { - return null; - } - } - - @Column(name = Column.NONE) - protected PatchContent.Key key; - - @Column(length = Integer.MAX_VALUE) - protected String content; - - protected PatchContent() { - } - - public PatchContent(final PatchContent.Key k, final String c) { - key = k; - content = c; - } - - public PatchContent.Key getKey() { - return key; - } - - public String getContent() { - return content; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchContentAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchContentAccess.java deleted file mode 100644 index 4d6e21d305..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchContentAccess.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; - -public interface PatchContentAccess extends - Access<PatchContent, PatchContent.Key> { - @PrimaryKey("key") - PatchContent get(PatchContent.Key key) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchLineComment.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchLineComment.java deleted file mode 100644 index f6a362662e..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchLineComment.java +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.StringKey; - -import java.sql.Timestamp; - -/** A comment left by a user on a specific line of a {@link Patch}. */ -public final class PatchLineComment { - public static class Id extends StringKey<Patch.Id> { - @Column(name = Column.NONE) - protected Patch.Id patchId; - - @Column(length = 40) - protected String uuid; - - protected Id() { - patchId = new Patch.Id(); - } - - public Id(final Patch.Id p, final String uuid) { - this.patchId = p; - this.uuid = uuid; - } - - @Override - public Patch.Id getParentKey() { - return patchId; - } - - @Override - public String get() { - return uuid; - } - } - - protected static final char STATUS_DRAFT = 'd'; - protected static final char STATUS_PUBLISHED = 'P'; - - public static enum Status { - DRAFT(STATUS_DRAFT), - - PUBLISHED(STATUS_PUBLISHED); - - private final char code; - - private Status(final char c) { - code = c; - } - - public char getCode() { - return code; - } - - public static Status forCode(final char c) { - for (final Status s : Status.values()) { - if (s.code == c) { - return s; - } - } - return null; - } - } - - @Column(name = Column.NONE) - protected Id key; - - /** Line number this comment applies to; it should display after the line. */ - @Column - protected int lineNbr; - - /** Who wrote this comment. */ - @Column(name = "author_id") - protected Account.Id author; - - /** When this comment was drafted. */ - @Column - protected Timestamp writtenOn; - - /** Current publication state of the comment; see {@link Status}. */ - @Column - protected char status; - - /** Which file is this comment; 0 is ancestor, 1 is new version. */ - @Column - protected short side; - - /** The text left by the user. */ - @Column(notNull = false, length = Integer.MAX_VALUE) - protected String message; - - protected PatchLineComment() { - } - - public PatchLineComment(final PatchLineComment.Id id, final int line, - final Account.Id a) { - key = id; - lineNbr = line; - author = a; - writtenOn = new Timestamp(System.currentTimeMillis()); - setStatus(Status.DRAFT); - } - - public PatchLineComment.Id getKey() { - return key; - } - - public int getLine() { - return lineNbr; - } - - public Account.Id getAuthor() { - return author; - } - - public Timestamp getWrittenOn() { - return writtenOn; - } - - public Status getStatus() { - return Status.forCode(status); - } - - public void setStatus(final Status s) { - status = s.getCode(); - } - - public short getSide() { - return side; - } - - public void setSide(final short s) { - side = s; - } - - public String getMessage() { - return message; - } - - public void setMessage(final String s) { - message = s; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchLineCommentAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchLineCommentAccess.java deleted file mode 100644 index 1b2273f8a2..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchLineCommentAccess.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface PatchLineCommentAccess extends - Access<PatchLineComment, PatchLineComment.Id> { - @PrimaryKey("key") - PatchLineComment get(PatchLineComment.Id id) throws OrmException; - - @Query("WHERE key.patchId = ? AND status = '" - + PatchLineComment.STATUS_PUBLISHED + "' ORDER BY lineNbr,writtenOn") - ResultSet<PatchLineComment> published(Patch.Id id) throws OrmException; - - @Query("WHERE key.patchId = ? AND status = '" + PatchLineComment.STATUS_DRAFT - + "' AND author = ? ORDER BY lineNbr,writtenOn") - ResultSet<PatchLineComment> draft(Patch.Id patch, Account.Id author) - throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchSet.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchSet.java deleted file mode 100644 index 88441adb10..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchSet.java +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.IntKey; - -/** A single revision of a {@link Change}. */ -public final class PatchSet { - public static class Id extends IntKey<Change.Id> { - @Column - protected Change.Id changeId; - - @Column - protected int patchSetId; - - protected Id() { - changeId = new Change.Id(); - } - - public Id(final Change.Id change, final int id) { - this.changeId = change; - this.patchSetId = id; - } - - @Override - public Change.Id getParentKey() { - return changeId; - } - - @Override - public int get() { - return patchSetId; - } - } - - @Column(name = Column.NONE) - protected Id key; - - @Column(notNull = false) - protected RevId revision; - - protected PatchSet() { - } - - public PatchSet(final PatchSet.Id k) { - key = k; - } - - public PatchSet.Id getKey() { - return key; - } - - public int getId() { - return key.get(); - } - - public RevId getRevision() { - return revision; - } - - public void setRevision(final RevId i) { - revision = i; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchSetAccess.java deleted file mode 100644 index 2bb604020f..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetAccess.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface PatchSetAccess extends Access<PatchSet, PatchSet.Id> { - @PrimaryKey("key") - PatchSet get(PatchSet.Id id) throws OrmException; - - @Query("WHERE key.changeId = ? ORDER BY key.patchSetId") - ResultSet<PatchSet> byChange(Change.Id id) throws OrmException; - - @Query("WHERE revision = ? LIMIT 2") - ResultSet<PatchSet> byRevision(RevId rev) throws OrmException; - - @Query("WHERE revision >= ? AND revision <= ? LIMIT 2") - ResultSet<PatchSet> byRevisionRange(RevId reva, RevId revb) - throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetAncestor.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchSetAncestor.java deleted file mode 100644 index 62e9d72388..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetAncestor.java +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.IntKey; - -/** Ancestors of a {@link PatchSet} that the PatchSet depends upon. */ -public final class PatchSetAncestor { - public static class Key extends IntKey<PatchSet.Id> { - @Column(name = Column.NONE) - protected PatchSet.Id patchSetId; - - @Column - protected int position; - - protected Key() { - patchSetId = new PatchSet.Id(); - } - - public Key(final PatchSet.Id psId, final int pos) { - this.patchSetId = psId; - this.position = pos; - } - - @Override - public PatchSet.Id getParentKey() { - return patchSetId; - } - - @Override - public int get() { - return position; - } - } - - @Column(name = Column.NONE) - protected Key key; - - @Column - protected RevId ancestorRevision; - - protected PatchSetAncestor() { - } - - public PatchSetAncestor(final PatchSetAncestor.Key k) { - key = k; - } - - public PatchSetAncestor.Key getKey() { - return key; - } - - public PatchSet.Id getPatchSet() { - return key.patchSetId; - } - - public int getPosition() { - return key.position; - } - - public RevId getAncestorRevision() { - return ancestorRevision; - } - - public void setAncestorRevision(final RevId id) { - ancestorRevision = id; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetAncestorAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchSetAncestorAccess.java deleted file mode 100644 index a4217ddedb..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetAncestorAccess.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface PatchSetAncestorAccess extends - Access<PatchSetAncestor, PatchSetAncestor.Key> { - @PrimaryKey("key") - PatchSetAncestor get(PatchSetAncestor.Key key) throws OrmException; - - @Query("WHERE key.patchSetId = ? ORDER BY key.position") - ResultSet<PatchSetAncestor> ancestorsOf(PatchSet.Id id) throws OrmException; - - @Query("WHERE ancestorRevision = ?") - ResultSet<PatchSetAncestor> descendantsOf(RevId revision) - throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetInfo.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchSetInfo.java deleted file mode 100644 index a9b32d91dd..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetInfo.java +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** - * Additional data about a {@link PatchSet} not normally loaded. - * <p> - * This is stored out of band from the PatchSet itself, to reduce the size of - * each PatchSet record. - */ -public final class PatchSetInfo { - @Column(name = Column.NONE) - protected PatchSet.Id key; - - /** First line of {@link #message}. */ - @Column(notNull = false) - protected String subject; - - /** The complete description of the change the patch set introduces. */ - @Column(notNull = false, length = Integer.MAX_VALUE) - protected String message; - - /** Identity of who wrote the patch set. May differ from {@link #committer}. */ - @Column(notNull = false) - protected UserIdentity author; - - /** Identity of who committed the patch set to the VCS. */ - @Column(notNull = false) - protected UserIdentity committer; - - protected PatchSetInfo() { - } - - public PatchSetInfo(final PatchSet.Id k) { - key = k; - } - - public PatchSet.Id getKey() { - return key; - } - - public String getSubject() { - return subject; - } - - public void setSubject(final String s) { - if (s != null && s.length() > 255) { - subject = s.substring(0, 255); - } else { - subject = s; - } - } - - public String getMessage() { - return message; - } - - public void setMessage(final String m) { - message = m; - } - - public UserIdentity getAuthor() { - return author; - } - - public void setAuthor(final UserIdentity u) { - author = u; - } - - public UserIdentity getCommitter() { - return committer; - } - - public void setCommitter(final UserIdentity u) { - committer = u; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetInfoAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/PatchSetInfoAccess.java deleted file mode 100644 index 1682cb7a8e..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/PatchSetInfoAccess.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; - -public interface PatchSetInfoAccess extends Access<PatchSetInfo, PatchSet.Id> { - @PrimaryKey("key") - PatchSetInfo get(PatchSet.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/Project.java b/webapp/src/com/google/gerrit/client/reviewdb/Project.java deleted file mode 100644 index 46644ec38e..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/Project.java +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.IntKey; -import com.google.gwtorm.client.StringKey; - -/** Projects match a source code repository managed by Gerrit */ -public final class Project { - /** Project name key */ - public static class NameKey extends - StringKey<com.google.gwtorm.client.Key<?>> { - @Column - protected String name; - - protected NameKey() { - } - - public NameKey(final String n) { - name = n; - } - - @Override - public String get() { - return name; - } - } - - /** Synthetic key to link to within the database */ - public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> { - @Column - protected int id; - - protected Id() { - } - - public Id(final int id) { - this.id = id; - } - - @Override - public int get() { - return id; - } - } - - @Column - protected NameKey name; - - @Column - protected Id projectId; - - @Column(length = Integer.MAX_VALUE, notNull = false) - protected String description; - - protected Project() { - } - - public Project(final Project.NameKey newName, final Project.Id newId) { - name = newName; - projectId = newId; - } - - public Project.Id getId() { - return projectId; - } - - public String getName() { - return name.get(); - } - - public String getDescription() { - return description; - } - - public void setDescription(final String d) { - description = d; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ProjectAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/ProjectAccess.java deleted file mode 100644 index 03dcb08525..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ProjectAccess.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; -import com.google.gwtorm.client.SecondaryKey; - -public interface ProjectAccess extends Access<Project, Project.NameKey> { - @PrimaryKey("name") - Project byName(Project.NameKey name) throws OrmException; - - @SecondaryKey("projectId") - Project byId(Project.Id id) throws OrmException; - - @Query("ORDER BY name") - ResultSet<Project> all() throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadAccount.java b/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadAccount.java deleted file mode 100644 index 418130d492..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadAccount.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** Single {@link Account} as owner/manager of a project. */ -public final class ProjectLeadAccount { - public static class Key implements - com.google.gwtorm.client.Key<Project.NameKey> { - @Column - protected Project.NameKey projectName; - - @Column - protected Account.Id accountId; - - protected Key() { - projectName = new Project.NameKey(); - accountId = new Account.Id(); - } - - public Key(final Project.NameKey p, final Account.Id a) { - projectName = p; - accountId = a; - } - - public Project.NameKey getParentKey() { - return projectName; - } - - @Override - public int hashCode() { - return projectName.hashCode() * 31 + accountId.hashCode(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof Key && ((Key) o).projectName.equals(projectName) - && ((Key) o).accountId.equals(accountId); - } - } - - @Column(name = Column.NONE) - protected Key key; - - protected ProjectLeadAccount() { - } - - public ProjectLeadAccount(final ProjectLeadAccount.Key k) { - key = k; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadAccountAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadAccountAccess.java deleted file mode 100644 index f7d4c26c1c..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadAccountAccess.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface ProjectLeadAccountAccess extends - Access<ProjectLeadAccount, ProjectLeadAccount.Key> { - @PrimaryKey("key") - ProjectLeadAccount get(ProjectLeadAccount.Key key) throws OrmException; - - @Query("WHERE key.projectName= ?") - ResultSet<ProjectLeadAccount> byProject(Project.NameKey id) - throws OrmException; - - @Query("WHERE key.accountId = ?") - ResultSet<ProjectLeadAccount> byAccount(Account.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadGroup.java b/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadGroup.java deleted file mode 100644 index 379ef618fe..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadGroup.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** {@link AccountGroup} as owner/manager of a project. */ -public final class ProjectLeadGroup { - public static class Key implements - com.google.gwtorm.client.Key<Project.NameKey> { - @Column - protected Project.NameKey projectName; - - @Column - protected AccountGroup.Id groupId; - - protected Key() { - projectName = new Project.NameKey(); - groupId = new AccountGroup.Id(); - } - - public Key(final Project.NameKey p, final AccountGroup.Id a) { - projectName = p; - groupId = a; - } - - public Project.NameKey getParentKey() { - return projectName; - } - - @Override - public int hashCode() { - return projectName.hashCode() * 31 + groupId.hashCode(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof Key && ((Key) o).projectName.equals(projectName) - && ((Key) o).groupId.equals(groupId); - } - } - - @Column(name = Column.NONE) - protected Key key; - - protected ProjectLeadGroup() { - } - - public ProjectLeadGroup(final ProjectLeadGroup.Key k) { - key = k; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadGroupAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadGroupAccess.java deleted file mode 100644 index 3695ee5d59..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ProjectLeadGroupAccess.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface ProjectLeadGroupAccess extends - Access<ProjectLeadGroup, ProjectLeadGroup.Key> { - @PrimaryKey("key") - ProjectLeadGroup get(ProjectLeadGroup.Key key) throws OrmException; - - @Query("WHERE key.projectName= ?") - ResultSet<ProjectLeadGroup> byProject(Project.NameKey id) throws OrmException; - - @Query("WHERE key.groupId = ?") - ResultSet<ProjectLeadGroup> byGroup(AccountGroup.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/RevId.java b/webapp/src/com/google/gerrit/client/reviewdb/RevId.java deleted file mode 100644 index f8a5eb69e0..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/RevId.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** A revision identifier for a file or a change. */ -public final class RevId { - public static final int LEN = 40; - - @Column(length = LEN) - protected String id; - - protected RevId() { - } - - public RevId(final String str) { - id = str; - } - - /** @return the value of this revision id. */ - public String get() { - return id; - } - - /** @return true if this revision id has all required digits. */ - public boolean isComplete() { - return get().length() == LEN; - } - - /** - * @return if {@link #isComplete()}, <code>this</code>. Otherwise a new RevId - * with '~' appended on the end until {@link #LEN} is reached. - */ - public RevId max() { - if (isComplete()) { - return this; - } - - final StringBuilder revEnd = new StringBuilder(LEN); - revEnd.append(get()); - while (revEnd.length() < LEN) { - revEnd.append('~'); - } - return new RevId(revEnd.toString()); - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/ReviewDb.java b/webapp/src/com/google/gerrit/client/reviewdb/ReviewDb.java deleted file mode 100644 index 7338155a0f..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/ReviewDb.java +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Relation; -import com.google.gwtorm.client.Schema; -import com.google.gwtorm.client.Sequence; - -/** The review service database schema. */ -public interface ReviewDb extends Schema { - @Relation - SystemConfigAccess systemConfig(); - - @Relation - ApprovalCategoryAccess approvalCategories(); - - @Relation - ApprovalCategoryValueAccess approvalCategoryValues(); - - @Relation - ContributorAgreementAccess contributorAgreements(); - - @Relation - AccountAccess accounts(); - - @Relation - AccountExternalIdAccess accountExternalIds(); - - @Relation - AccountAgreementAccess accountAgreements(); - - @Relation - AccountGroupAccess accountGroups(); - - @Relation - AccountGroupMemberAccess accountGroupMembers(); - - @Relation - StarredChangeAccess starredChanges(); - - @Relation - ProjectAccess projects(); - - @Relation - BranchAccess branches(); - - @Relation - ProjectLeadAccountAccess projectLeadAccounts(); - - @Relation - ProjectLeadGroupAccess projectLeadGroups(); - - @Relation - ChangeAccess changes(); - - @Relation - ChangeApprovalAccess changeApprovals(); - - @Relation - ChangeMessageAccess changeMessages(); - - @Relation - PatchSetAccess patchSets(); - - @Relation - PatchSetInfoAccess patchSetInfo(); - - @Relation - PatchSetAncestorAccess patchSetAncestors(); - - @Relation - PatchAccess patches(); - - @Relation - PatchContentAccess patchContents(); - - @Relation - PatchLineCommentAccess patchComments(); - - /** Create the next unique id for an {@link Account}. */ - @Sequence(startWith = 1000000) - int nextAccountId(); - - /** Create the next unique id for a {@link ContributorAgreement}. */ - @Sequence - int nextContributorAgreementId(); - - /** Next unique id for a {@link AccountGroup}. */ - @Sequence - int nextAccountGroupId(); - - /** Next unique id for a {@link Project}. */ - @Sequence - int nextProjectId(); - - /** Next unique id for a {@link Branch}. */ - @Sequence - int nextBranchId(); - - /** Next unique id for a {@link Change}. */ - @Sequence - int nextChangeId(); -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/StarredChange.java b/webapp/src/com/google/gerrit/client/reviewdb/StarredChange.java deleted file mode 100644 index 3bda3532fa..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/StarredChange.java +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -/** A {@link Change} starred by an {@link Account}. */ -public class StarredChange { - public static class Key implements com.google.gwtorm.client.Key<Account.Id> { - @Column - protected Account.Id accountId; - - @Column - protected Change.Id changeId; - - protected Key() { - accountId = new Account.Id(); - changeId = new Change.Id(); - } - - public Key(final Account.Id a, final Change.Id g) { - accountId = a; - changeId = g; - } - - public Account.Id getParentKey() { - return accountId; - } - - @Override - public int hashCode() { - return accountId.hashCode() * 31 + changeId.hashCode(); - } - - @Override - public boolean equals(final Object o) { - return o instanceof Key && ((Key) o).accountId.equals(accountId) - && ((Key) o).changeId.equals(changeId); - } - } - - @Column(name = Column.NONE) - protected Key key; - - protected StarredChange() { - } - - public StarredChange(final StarredChange.Key k) { - key = k; - } - - public Account.Id getAccountId() { - return key.accountId; - } - - public Change.Id getChangeId() { - return key.changeId; - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/StarredChangeAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/StarredChangeAccess.java deleted file mode 100644 index 391d8b2e25..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/StarredChangeAccess.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; -import com.google.gwtorm.client.Query; -import com.google.gwtorm.client.ResultSet; - -public interface StarredChangeAccess extends - Access<StarredChange, StarredChange.Key> { - @PrimaryKey("key") - StarredChange get(StarredChange.Key key) throws OrmException; - - @Query("WHERE key.accountId = ?") - ResultSet<StarredChange> byAccount(Account.Id id) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/SystemConfig.java b/webapp/src/com/google/gerrit/client/reviewdb/SystemConfig.java deleted file mode 100644 index 2f9dba9900..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/SystemConfig.java +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gerrit.server.HostPageServlet; -import com.google.gwtorm.client.Column; -import com.google.gwtorm.client.StringKey; - -/** Global configuration needed to serve web requests. */ -public final class SystemConfig { - public static final class Key extends - StringKey<com.google.gwtorm.client.Key<?>> { - private static final String VALUE = "X"; - - @Column(length = 1) - protected String one = VALUE; - - public Key() { - } - - @Override - public String get() { - return VALUE; - } - } - - public static SystemConfig create() { - final SystemConfig r = new SystemConfig(); - r.singleton = new SystemConfig.Key(); - r.maxSessionAge = 12 * 60 * 60 /* seconds */; - return r; - } - - @Column - protected Key singleton; - - /** Private key to sign XSRF protection tokens. */ - @Column(length = 36) - public transient String xsrfPrivateKey; - - /** Private key to sign account identification cookies. */ - @Column(length = 36) - public transient String accountPrivateKey; - - /** Maximum web session age, in seconds. */ - @Column - public transient int maxSessionAge; - - /** - * Local filesystem location of header/footer/CSS configuration files - * - * @see HostPageServlet - */ - @Column(notNull = false) - public String sitePath; - - /** Optional canonical URL for this application. */ - @Column(notNull = false) - public String canonicalUrl; - - /** Optional URL of a gitweb installation to also view changes through. */ - @Column(notNull = false) - public String gitwebUrl; - - /** Local filesystem loction all projects reside within. */ - @Column(notNull = false) - public String gitBasePath; - - protected SystemConfig() { - } -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/SystemConfigAccess.java b/webapp/src/com/google/gerrit/client/reviewdb/SystemConfigAccess.java deleted file mode 100644 index 6aa428b081..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/SystemConfigAccess.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Access; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.PrimaryKey; - -/** Access interface for {@link SystemConfig}. */ -public interface SystemConfigAccess extends - Access<SystemConfig, SystemConfig.Key> { - @PrimaryKey("singleton") - SystemConfig get(SystemConfig.Key key) throws OrmException; -} diff --git a/webapp/src/com/google/gerrit/client/reviewdb/UserIdentity.java b/webapp/src/com/google/gerrit/client/reviewdb/UserIdentity.java deleted file mode 100644 index 2c7d4a28bd..0000000000 --- a/webapp/src/com/google/gerrit/client/reviewdb/UserIdentity.java +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.reviewdb; - -import com.google.gwtorm.client.Column; - -import java.sql.Timestamp; - -public final class UserIdentity { - /** Full name of the user. */ - @Column - protected String name; - - /** Email address (or user@host style string anyway). */ - @Column - protected String email; - - /** Time (in UTC) when the identity was constructed. */ - @Column - protected Timestamp when; - - /** Offset from UTC */ - @Column - protected int tz; - - public String getName() { - return name; - } - - public void setName(final String n) { - name = n; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String e) { - email = e; - } - - public Timestamp getDate() { - return when; - } - - public void setDate(final Timestamp d) { - when = d; - } - - public int getTimeZone() { - return tz; - } - - public void setTimeZone(final int offset) { - tz = offset; - } -} diff --git a/webapp/src/com/google/gerrit/client/rpc/BaseServiceImplementation.java b/webapp/src/com/google/gerrit/client/rpc/BaseServiceImplementation.java deleted file mode 100644 index 4cf3715f6e..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/BaseServiceImplementation.java +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.rpc; - -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.SchemaFactory; - -/** Support for services which require a {@link ReviewDb} instance. */ -public class BaseServiceImplementation { - protected final SchemaFactory<ReviewDb> schema; - - protected BaseServiceImplementation(final SchemaFactory<ReviewDb> rdf) { - schema = rdf; - } - - /** - * Executes <code>action.run</code> with an active ReviewDb connection. - * <p> - * A database handle is automatically opened and closed around the action's - * {@link Action#run(ReviewDb)} method. OrmExceptions are caught and passed - * into the onFailure method of the callback. - * - * @param <T> type of result the callback expects. - * @param callback the callback that will receive the result. - * @param action the action logic to perform. - */ - protected <T> void run(final AsyncCallback<T> callback, final Action<T> action) { - try { - final ReviewDb db = schema.open(); - final T r; - try { - r = action.run(db); - } finally { - db.close(); - } - if (r != null) { - callback.onSuccess(r); - } - } catch (OrmException e) { - callback.onFailure(e); - } catch (Failure e) { - callback.onFailure(e.getCause()); - } - } - - /** Exception whose cause is passed into onFailure. */ - public static class Failure extends Exception { - public Failure(final Throwable why) { - super(why); - } - } - - /** Arbitrary action to run with a database connection. */ - public static interface Action<T> { - /** - * Perform this action, returning the onSuccess value. - * - * @param db an open database handle to be used by this connection. - * @return he value to pass to {@link AsyncCallback#onSuccess(Object)}. - * @throws OrmException any schema based action failed. - * @throws Failure cause is given to - * {@link AsyncCallback#onFailure(Throwable)}. - */ - T run(ReviewDb db) throws OrmException, Failure; - } -} diff --git a/webapp/src/com/google/gerrit/client/rpc/CorruptEntityException.java b/webapp/src/com/google/gerrit/client/rpc/CorruptEntityException.java deleted file mode 100644 index 1f34540d77..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/CorruptEntityException.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.rpc; - -import com.google.gwtorm.client.Key; - -/** Error indicating the entity's database records are invalid. */ -public class CorruptEntityException extends Exception { - public static final String MESSAGE_PREFIX = "Corrupt Database Entity: "; - - public CorruptEntityException(final Key<?> key) { - super(MESSAGE_PREFIX + key); - } -} diff --git a/webapp/src/com/google/gerrit/client/rpc/GerritCallback.java b/webapp/src/com/google/gerrit/client/rpc/GerritCallback.java deleted file mode 100644 index 603b745f42..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/GerritCallback.java +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.rpc; - -import com.google.gerrit.client.ErrorDialog; -import com.google.gerrit.client.Gerrit; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwtjsonrpc.client.RemoteJsonException; -import com.google.gwtjsonrpc.client.ServerUnavailableException; - -/** Abstract callback handling generic error conditions automatically */ -public abstract class GerritCallback<T> implements AsyncCallback<T> { - public void onFailure(final Throwable caught) { - if (isNotSignedIn(caught)) { - new ErrorDialog(RpcUtil.C.errorNotSignedIn()).center(); - - } else if (isNoSuchEntity(caught)) { - new ErrorDialog(Gerrit.C.notFoundBody()).center(); - - } else if (caught instanceof ServerUnavailableException) { - new ErrorDialog(RpcUtil.C.errorServerUnavailable()).center(); - - } else { - GWT.log(getClass().getName() + " caught " + caught, caught); - new ErrorDialog(caught).center(); - } - } - - public static boolean isNotSignedIn(final Throwable caught) { - if (caught instanceof NotSignedInException) { - return true; - } - return caught instanceof RemoteJsonException - && caught.getMessage().equals(NotSignedInException.MESSAGE); - } - - public static boolean isNoSuchEntity(final Throwable caught) { - if (caught instanceof NoSuchEntityException) { - return true; - } - return caught instanceof RemoteJsonException - && caught.getMessage().equals(NoSuchEntityException.MESSAGE); - } -} diff --git a/webapp/src/com/google/gerrit/client/rpc/NoSuchEntityException.java b/webapp/src/com/google/gerrit/client/rpc/NoSuchEntityException.java deleted file mode 100644 index a6bde9424f..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/NoSuchEntityException.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.rpc; - -/** Error indicating the entity requested doesn't exist. */ -public class NoSuchEntityException extends Exception { - public static final String MESSAGE = "Not Found"; - - public NoSuchEntityException() { - super(MESSAGE); - } -} diff --git a/webapp/src/com/google/gerrit/client/rpc/NotSignedInException.java b/webapp/src/com/google/gerrit/client/rpc/NotSignedInException.java deleted file mode 100644 index 9418b669e3..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/NotSignedInException.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.rpc; - -/** Error stating the user must be signed-in in order to perform this action. */ -public class NotSignedInException extends Exception { - public static final String MESSAGE = "Not Signed In"; - - public NotSignedInException() { - super(MESSAGE); - } -} diff --git a/webapp/src/com/google/gerrit/client/rpc/RpcConstants.java b/webapp/src/com/google/gerrit/client/rpc/RpcConstants.java deleted file mode 100644 index afa4202a9f..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/RpcConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.rpc; - -import com.google.gwt.i18n.client.Constants; - -public interface RpcConstants extends Constants { - String errorNotSignedIn(); - String errorServerUnavailable(); - String errorRemoteJsonException(); -} diff --git a/webapp/src/com/google/gerrit/client/rpc/RpcConstants.properties b/webapp/src/com/google/gerrit/client/rpc/RpcConstants.properties deleted file mode 100644 index 6e596b5571..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/RpcConstants.properties +++ /dev/null @@ -1,3 +0,0 @@ -errorNotSignedIn = Not Signed In -errorServerUnavailable = Server Unavailable -errorRemoteJsonException = Server Error diff --git a/webapp/src/com/google/gerrit/client/rpc/RpcUtil.java b/webapp/src/com/google/gerrit/client/rpc/RpcUtil.java deleted file mode 100644 index 7deb21e100..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/RpcUtil.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.rpc; - -import com.google.gerrit.client.Gerrit; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gwt.core.client.GWT; - -public class RpcUtil { - public static final RpcConstants C; - private static CurrentAccountImpl caImpl; - - static { - if (GWT.isClient()) { - C = GWT.create(RpcConstants.class); - caImpl = new CurrentAccountImpl() { - public Account.Id getAccountId() { - final Account a = Gerrit.getUserAccount(); - return a != null ? a.getId() : null; - } - }; - } else { - C = null; - } - } - - /** Get the unique id for this account; null if there is no account. */ - public static Account.Id getAccountId() { - return caImpl.getAccountId(); - } - - public static void setCurrentAccountImpl(final CurrentAccountImpl i) { - caImpl = i; - } - - public interface CurrentAccountImpl { - /** Get the unique id for this account; null if there is no account. */ - public Account.Id getAccountId(); - } -} diff --git a/webapp/src/com/google/gerrit/client/rpc/ScreenLoadCallback.java b/webapp/src/com/google/gerrit/client/rpc/ScreenLoadCallback.java deleted file mode 100644 index e7e07a50f3..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/ScreenLoadCallback.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.rpc; - -import com.google.gerrit.client.Gerrit; -import com.google.gerrit.client.NotFoundScreen; - -/** Callback switching {@link NoSuchEntityException} to {@link NotFoundScreen} */ -public abstract class ScreenLoadCallback<T> extends GerritCallback<T> { - @Override - public void onFailure(final Throwable caught) { - if (isNoSuchEntity(caught)) { - Gerrit.display(new NotFoundScreen()); - } else { - super.onFailure(caught); - } - } -} diff --git a/webapp/src/com/google/gerrit/client/rpc/SignInRequired.java b/webapp/src/com/google/gerrit/client/rpc/SignInRequired.java deleted file mode 100644 index f19fc18d6f..0000000000 --- a/webapp/src/com/google/gerrit/client/rpc/SignInRequired.java +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.rpc; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation indicating a service method requires a current user. - * <p> - * If there is no current user then {@link NotSignedInException} will be given - * to the callback's onFailure method. Methods tagged with this will never get - * null from {@link RpcUtil#getAccountId()}. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface SignInRequired { -} diff --git a/webapp/src/com/google/gerrit/client/starFilled.gif b/webapp/src/com/google/gerrit/client/starFilled.gif Binary files differdeleted file mode 100644 index 77619f0dc3..0000000000 --- a/webapp/src/com/google/gerrit/client/starFilled.gif +++ /dev/null diff --git a/webapp/src/com/google/gerrit/client/starOpen.gif b/webapp/src/com/google/gerrit/client/starOpen.gif Binary files differdeleted file mode 100644 index e8dc0a3aa2..0000000000 --- a/webapp/src/com/google/gerrit/client/starOpen.gif +++ /dev/null diff --git a/webapp/src/com/google/gerrit/client/ui/AccountDashboardLink.java b/webapp/src/com/google/gerrit/client/ui/AccountDashboardLink.java deleted file mode 100644 index 4c8d8c30e7..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/AccountDashboardLink.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gerrit.client.FormatUtil; -import com.google.gerrit.client.Link; -import com.google.gerrit.client.changes.AccountDashboardScreen; -import com.google.gerrit.client.data.AccountInfo; -import com.google.gerrit.client.data.AccountInfoCache; -import com.google.gerrit.client.reviewdb.Account; - -/** Link to any user's account dashboard. */ -public class AccountDashboardLink extends DirectScreenLink { - /** Create a link after locating account details from an active cache. */ - public static AccountDashboardLink link(final AccountInfoCache cache, - final Account.Id id) { - final AccountInfo ai = cache.get(id); - return ai != null ? new AccountDashboardLink(ai) : null; - } - - private AccountInfo account; - - public AccountDashboardLink(final AccountInfo ai) { - this(FormatUtil.name(ai), ai); - } - - public AccountDashboardLink(final String text, final AccountInfo ai) { - super(text, Link.toAccountDashboard(ai)); - addStyleName("gerrit-AccountName"); - account = ai; - } - - @Override - protected Screen createScreen() { - return new AccountDashboardScreen(account.getId()); - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/AccountScreen.java b/webapp/src/com/google/gerrit/client/ui/AccountScreen.java deleted file mode 100644 index 3ffa07e65a..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/AccountScreen.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -/** A screen that requires the user to be signed-into their account. */ -public class AccountScreen extends Screen { - public AccountScreen(final String heading) { - super(heading); - setRequiresSignIn(true); - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/AutoCenterDialogBox.java b/webapp/src/com/google/gerrit/client/ui/AutoCenterDialogBox.java deleted file mode 100644 index 43569d5085..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/AutoCenterDialogBox.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.WindowResizeListener; -import com.google.gwt.user.client.ui.DialogBox; - -/** A DialogBox that automatically re-centers itself if the window changes */ -public class AutoCenterDialogBox extends DialogBox { - private WindowResizeListener recenter; - - public AutoCenterDialogBox() { - } - - public AutoCenterDialogBox(final boolean autoHide) { - super(autoHide); - } - - public AutoCenterDialogBox(final boolean autoHide, final boolean modal) { - super(autoHide, modal); - } - - @Override - public void show() { - if (recenter == null) { - recenter = new WindowResizeListener() { - public void onWindowResized(final int width, final int height) { - onResize(width, height); - } - }; - Window.addWindowResizeListener(recenter); - } - super.show(); - } - - @Override - protected void onUnload() { - if (recenter != null) { - Window.removeWindowResizeListener(recenter); - recenter = null; - } - super.onUnload(); - } - - protected void onResize(final int width, final int height) { - center(); - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/ChangeLink.java b/webapp/src/com/google/gerrit/client/ui/ChangeLink.java deleted file mode 100644 index af202b9b21..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/ChangeLink.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gerrit.client.Link; -import com.google.gerrit.client.changes.ChangeScreen; -import com.google.gerrit.client.data.ChangeInfo; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.DOM; - -public class ChangeLink extends DirectScreenLink { - private Change.Id id; - private ChangeInfo info; - - public ChangeLink(final String text, final Change.Id c) { - super(text, Link.toChange(c)); - final String plink = GWT.getModuleBaseURL() + c.get(); - DOM.setElementProperty(DOM.getFirstChild(getElement()), "href", plink); - id = c; - } - - public ChangeLink(final String text, final ChangeInfo c) { - this(text, c.getId()); - info = c; - } - - @Override - protected Screen createScreen() { - return info != null ? new ChangeScreen(info) : new ChangeScreen(id); - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/ComplexDisclosurePanel.java b/webapp/src/com/google/gerrit/client/ui/ComplexDisclosurePanel.java deleted file mode 100644 index 838bcceacb..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/ComplexDisclosurePanel.java +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.ComplexPanel; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.DisclosureHandler; -import com.google.gwt.user.client.ui.DisclosurePanel; -import com.google.gwt.user.client.ui.FiresDisclosureEvents; -import com.google.gwt.user.client.ui.Panel; -import com.google.gwt.user.client.ui.Widget; - -public class ComplexDisclosurePanel extends Composite implements - FiresDisclosureEvents { - private final DisclosurePanel main; - private final Panel header; - - public ComplexDisclosurePanel(final String text, final boolean isOpen) { - // Ick. GWT's DisclosurePanel won't let us subclass it, or do any - // other modification of its header. We're stuck with injecting - // into the DOM directly. - // - main = new DisclosurePanel(text, isOpen); - final Element headerParent; - { - final Element table = main.getElement(); - final Element tbody = DOM.getFirstChild(table); - final Element tr1 = DOM.getChild(tbody, 0); - final Element tr2 = DOM.getChild(tbody, 1); - - DOM.setElementProperty(DOM.getChild(tr1, 0), "width", "20px"); - DOM.setElementPropertyInt(DOM.getChild(tr2, 0), "colSpan", 2); - headerParent = tr1; - } - - header = new ComplexPanel() { - { - setElement(DOM.createTD()); - DOM.setInnerHTML(getElement(), " "); - addStyleName("complexHeader"); - } - - @Override - public void add(Widget w) { - add(w, getElement()); - } - }; - - initWidget(new ComplexPanel() { - { - final DisclosurePanel main = ComplexDisclosurePanel.this.main; - setElement(main.getElement()); - getChildren().add(main); - adopt(main); - - add(ComplexDisclosurePanel.this.header, headerParent); - } - }); - } - - public Panel getHeader() { - return header; - } - - public void setContent(final Widget w) { - main.setContent(w); - } - - public Widget getContent() { - return main.getContent(); - } - - public void addEventHandler(final DisclosureHandler handler) { - main.addEventHandler(handler); - } - - public void removeEventHandler(final DisclosureHandler handler) { - main.removeEventHandler(handler); - } - - /** @return true if the panel's content is visible. */ - public boolean isOpen() { - return main.isOpen(); - } - - /** - * Changes the visible state of this panel's content. - * - * @param isOpen <code>true</code> to open, <code>false</code> to close - */ - public void setOpen(final boolean isOpen) { - main.setOpen(isOpen); - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/DirectScreenLink.java b/webapp/src/com/google/gerrit/client/ui/DirectScreenLink.java deleted file mode 100644 index e263ce753a..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/DirectScreenLink.java +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gerrit.client.Gerrit; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.ui.Hyperlink; - -/** - * Link to a Screen which can carry richer payload. - * <p> - * A standard Hyperlink widget which updates the current history token when - * activated, but subclasses are able to create the Screen instance themselves, - * passing additional data into the Screen's constructor. This may permit the - * screen to show some limited information early, before RPCs required to fully - * populate it are even started. - */ -public abstract class DirectScreenLink extends Hyperlink { - /** - * Creates a link with its text and target history token specified. - * - * @param text the hyperlink's text - * @param historyToken the history token to which it will link - */ - protected DirectScreenLink(final String text, final String historyToken) { - super(text, historyToken); - } - - @Override - public void onBrowserEvent(final Event event) { - if (DOM.eventGetType(event) == Event.ONCLICK) { - History.newItem(getTargetHistoryToken(), false); - Gerrit.display(createScreen()); - DOM.eventPreventDefault(event); - } - } - - /** Create the screen this link wants to display. */ - protected abstract Screen createScreen(); -} diff --git a/webapp/src/com/google/gerrit/client/ui/DomUtil.java b/webapp/src/com/google/gerrit/client/ui/DomUtil.java deleted file mode 100644 index ea6970281e..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/DomUtil.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gwt.core.client.GWT; - -/** Utilities for dealing with the DOM. */ -public abstract class DomUtil { - private static final Impl INSTANCE; - - static { - if (GWT.isClient()) - INSTANCE = new ClientImpl(); - else - INSTANCE = new JavaImpl(); - } - - /** Escape XML/HTML special characters in the input string. */ - public static String escape(final String in) { - return INSTANCE.escape(in); - } - - private DomUtil() { - } - - private static abstract class Impl { - abstract String escape(String in); - } - - private static class ClientImpl extends Impl { - @Override - native String escape(String src)/*-{ return src.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"'); }-*/; - } - - private static class JavaImpl extends Impl { - @Override - String escape(final String in) { - final StringBuilder r = new StringBuilder(in.length()); - for (int i = 0; i < in.length(); i++) { - final char c = in.charAt(i); - switch (c) { - case '&': - r.append("&"); - break; - case '>': - r.append(">"); - break; - case '<': - r.append("<"); - break; - case '"': - r.append("""); - break; - default: - r.append(c); - } - } - return r.toString(); - } - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/ExpandAllCommand.java b/webapp/src/com/google/gerrit/client/ui/ExpandAllCommand.java deleted file mode 100644 index 6fd7329a73..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/ExpandAllCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.ui.Panel; -import com.google.gwt.user.client.ui.Widget; - -/** Expands all {@link ComplexDisclosurePanel} in a parent panel. */ -public class ExpandAllCommand implements Command { - private final Panel panel; - protected final boolean open; - - public ExpandAllCommand(final Panel p, final boolean isOpen) { - panel = p; - open = isOpen; - } - - public void execute() { - for (final Widget w : panel) { - if (w instanceof ComplexDisclosurePanel) { - expand((ComplexDisclosurePanel) w); - } - } - } - - protected void expand(final ComplexDisclosurePanel w) { - w.setOpen(open); - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/FancyFlexTable.java b/webapp/src/com/google/gerrit/client/ui/FancyFlexTable.java deleted file mode 100644 index 0530f8962b..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/FancyFlexTable.java +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gerrit.client.Gerrit; -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.DeferredCommand; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.FlexTable; -import com.google.gwt.user.client.ui.FocusListener; -import com.google.gwt.user.client.ui.FocusPanel; -import com.google.gwt.user.client.ui.HasFocus; -import com.google.gwt.user.client.ui.Image; -import com.google.gwt.user.client.ui.KeyboardListener; -import com.google.gwt.user.client.ui.KeyboardListenerAdapter; -import com.google.gwt.user.client.ui.Widget; - -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map.Entry; - -public abstract class FancyFlexTable<RowItem> extends Composite implements - HasFocus { - protected static final String MY_STYLE = "gerrit-ChangeTable"; - protected static final String S_ICON_HEADER = "IconHeader"; - protected static final String S_DATA_HEADER = "DataHeader"; - protected static final String S_ICON_CELL = "IconCell"; - protected static final String S_DATA_CELL = "DataCell"; - - protected static final int C_ARROW = 0; - - private static final LinkedHashMap<String, Object> savedPositions = - new LinkedHashMap<String, Object>(10, 0.75f, true) { - @Override - protected boolean removeEldestEntry(Entry<String, Object> eldest) { - return size() >= 20; - } - }; - - protected final MyFlexTable table; - private final FocusPanel focusy; - private final Image pointer; - private String saveId; - private int currentRow = -1; - - protected FancyFlexTable() { - pointer = Gerrit.ICONS.arrowRight().createImage(); - table = createFlexTable(); - table.addStyleName(MY_STYLE); - focusy = new FocusPanel(table); - focusy.addKeyboardListener(new KeyboardListenerAdapter() { - @Override - public void onKeyPress(Widget sender, char keyCode, int modifiers) { - if (FancyFlexTable.this.onKeyPress(keyCode, modifiers)) { - final Event event = DOM.eventGetCurrentEvent(); - DOM.eventCancelBubble(event, true); - DOM.eventPreventDefault(event); - } - } - }); - focusy.addFocusListener(new FocusListener() { - public void onFocus(final Widget sender) { - if (currentRow < 0) { - onDown(); - } - } - - public void onLostFocus(final Widget sender) { - } - }); - initWidget(focusy); - - table.setText(0, C_ARROW, ""); - table.getCellFormatter().addStyleName(0, C_ARROW, S_ICON_HEADER); - } - - protected MyFlexTable createFlexTable() { - return new MyFlexTable(); - } - - protected RowItem getRowItem(final int row) { - return FancyFlexTable.<RowItem> getRowItem(table.getCellFormatter() - .getElement(row, 0)); - } - - protected void setRowItem(final int row, final RowItem item) { - setRowItem(table.getCellFormatter().getElement(row, 0), item); - } - - protected void resetHtml(final String body) { - for (final Iterator<Widget> i = table.iterator(); i.hasNext();) { - i.next(); - i.remove(); - } - DOM.setInnerHTML(table.getBodyElement(), body); - } - - protected boolean onKeyPress(final char keyCode, final int modifiers) { - if (modifiers == 0) { - switch (keyCode) { - case 'k': - case KeyboardListener.KEY_UP: - onUp(); - return true; - - case 'j': - case KeyboardListener.KEY_DOWN: - onDown(); - return true; - - case 'o': - case KeyboardListener.KEY_ENTER: - onOpen(); - return true; - } - } - return false; - } - - private void onUp() { - for (int row = currentRow - 1; row >= 0; row--) { - if (getRowItem(row) != null) { - movePointerTo(row); - break; - } - } - } - - private void onDown() { - final int max = table.getRowCount(); - for (int row = currentRow + 1; row < max; row++) { - if (getRowItem(row) != null) { - movePointerTo(row); - break; - } - } - } - - private void onOpen() { - if (0 <= currentRow && currentRow < table.getRowCount()) { - final RowItem item = getRowItem(currentRow); - if (item != null) { - onOpenItem(item); - } - } - } - - protected void onOpenItem(final RowItem item) { - } - - protected abstract Object getRowItemKey(RowItem item); - - protected int getCurrentRow() { - return currentRow; - } - - protected void movePointerTo(final int newRow) { - if (newRow >= 0) { - table.setWidget(newRow, C_ARROW, pointer); - table.getCellFormatter().getElement(newRow, C_ARROW).scrollIntoView(); - } else if (currentRow >= 0) { - table.setWidget(currentRow, C_ARROW, null); - } - currentRow = newRow; - } - - protected void applyDataRowStyle(final int newRow) { - table.getCellFormatter().addStyleName(newRow, C_ARROW, S_ICON_CELL); - } - - public void finishDisplay(final boolean requestFocus) { - if (saveId != null) { - final Object oldId = savedPositions.get(saveId); - if (oldId != null) { - final int max = table.getRowCount(); - for (int row = 0; row < max; row++) { - final RowItem c = getRowItem(row); - if (c != null && oldId.equals(getRowItemKey(c))) { - movePointerTo(row); - break; - } - } - } - } - - if (currentRow < 0) { - onDown(); - } - - if (requestFocus && currentRow >= 0) { - DeferredCommand.addCommand(new Command() { - public void execute() { - setFocus(true); - } - }); - } - } - - public void setSavePointerId(final String id) { - saveId = id; - } - - @Override - public void onUnload() { - if (saveId != null && currentRow >= 0) { - final RowItem c = getRowItem(currentRow); - if (c != null) { - savedPositions.put(saveId, getRowItemKey(c)); - } - } - super.onUnload(); - } - - public int getTabIndex() { - return focusy.getTabIndex(); - } - - public void setAccessKey(char key) { - focusy.setAccessKey(key); - } - - public void setFocus(boolean focused) { - focusy.setFocus(focused); - } - - public void setTabIndex(int index) { - focusy.setTabIndex(index); - } - - public void addFocusListener(FocusListener listener) { - focusy.addFocusListener(listener); - } - - public void addKeyboardListener(KeyboardListener listener) { - focusy.addKeyboardListener(listener); - } - - public void removeFocusListener(FocusListener listener) { - focusy.removeFocusListener(listener); - } - - public void removeKeyboardListener(KeyboardListener listener) { - focusy.removeKeyboardListener(listener); - } - - protected static class MyFlexTable extends FlexTable { - @Override - public Element getBodyElement() { - return super.getBodyElement(); - } - } - - private static final native <ItemType> void setRowItem(Element td, ItemType c)/*-{ td["__gerritRowItem"] = c; }-*/; - - private static final native <ItemType> ItemType getRowItem(Element td)/*-{ return td["__gerritRowItem"]; }-*/; -} diff --git a/webapp/src/com/google/gerrit/client/ui/LinkMenuBar.java b/webapp/src/com/google/gerrit/client/ui/LinkMenuBar.java deleted file mode 100644 index d14d515978..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/LinkMenuBar.java +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gwt.user.client.ui.MenuBar; -import com.google.gwt.user.client.ui.MenuItem; - -/** A GWT MenuBar, rendering its items as through they were normal links. */ -public class LinkMenuBar extends MenuBar { - public LinkMenuBar() { - setStyleName("gerrit-LinkMenuBar"); - } - - @Override - public MenuItem addItem(final MenuItem item) { - item.addStyleDependentName("NormalItem"); - return super.addItem(item); - } - - /** - * Add a cell to fill the screen width. - * <p> - * The glue has 100% width, forcing the browser to align out the next element - * as far right as possible. If there is exactly 1 glue in the menu bar, the - * bar is split into a left and right section. If there are 2 glues, the bar - * will be split into thirds. - */ - public void addGlue() { - addSeparator().setStyleName("gerrit-FillMenuCenter"); - } - - /** - * Mark this item as the last in its group, so it has no border. - * <p> - * Usually this is used just before {@link #addGlue()} and after the last item - * has been added. - */ - public void lastInGroup() { - if (!getItems().isEmpty()) { - final MenuItem i = getItems().get(getItems().size() - 1); - i.removeStyleDependentName("NormalItem"); - i.addStyleDependentName("LastItem"); - } - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/LinkMenuItem.java b/webapp/src/com/google/gerrit/client/ui/LinkMenuItem.java deleted file mode 100644 index c3910ba9c5..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/LinkMenuItem.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.ui.MenuItem; - -/** - * A GWT {@link MenuItem} that uses a normal HTML link widget for its UI. - * <p> - * Using this widget instead of MenuItem permits the menu item to have the - * standard right-click "Open in new window" and "Open in new tab" feature found - * in popular browsers. - */ -public class LinkMenuItem extends MenuItem { - /** - * Creates a hyperlink with its text and target history token specified. - * - * @param text the hyperlink's text - * @param targetHistoryToken the history token to which it will link - */ - public LinkMenuItem(final String text, final String targetHistoryToken) { - super("", new Command() { - public void execute() { - History.newItem(targetHistoryToken); - } - }); - final Element a = DOM.createAnchor(); - DOM.setElementProperty(a, "href", "#" + targetHistoryToken); - DOM.setInnerText(a, text); - DOM.appendChild(getElement(), a); - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/PatchLink.java b/webapp/src/com/google/gerrit/client/ui/PatchLink.java deleted file mode 100644 index 3f2a0ff7da..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/PatchLink.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gerrit.client.Link; -import com.google.gerrit.client.patches.PatchSideBySideScreen; -import com.google.gerrit.client.patches.PatchUnifiedScreen; -import com.google.gerrit.client.reviewdb.Patch; - -public abstract class PatchLink extends DirectScreenLink { - protected Patch.Id id; - - public PatchLink(final String text, final Patch.Id p, final String token) { - super(text, token); - id = p; - } - - public static class SideBySide extends PatchLink { - public SideBySide(final String text, final Patch.Id p) { - super(text, p, Link.toPatchSideBySide(p)); - } - - @Override - protected Screen createScreen() { - return new PatchSideBySideScreen(id); - } - } - - public static class Unified extends PatchLink { - public Unified(final String text, final Patch.Id p) { - super(text, p, Link.toPatchUnified(p)); - } - - @Override - protected Screen createScreen() { - return new PatchUnifiedScreen(id); - } - } -} diff --git a/webapp/src/com/google/gerrit/client/ui/Screen.java b/webapp/src/com/google/gerrit/client/ui/Screen.java deleted file mode 100644 index 82d10a91c2..0000000000 --- a/webapp/src/com/google/gerrit/client/ui/Screen.java +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.client.ui; - -import com.google.gerrit.client.Gerrit; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.FlowPanel; - -public class Screen extends FlowPanel { - private boolean requiresSignIn; - private Element headerElem; - - protected Screen() { - this(""); - } - - protected Screen(final String headingText) { - setStyleName("gerrit-Screen"); - - headerElem = DOM.createElement("h1"); - DOM.appendChild(getElement(), headerElem); - - setTitleText(headingText); - } - - public void setTitleText(final String text) { - DOM.setInnerText(headerElem, text); - } - - /** Set whether or not {@link Gerrit#isSignedIn()} must be true. */ - public void setRequiresSignIn(final boolean b) { - requiresSignIn = b; - } - - /** Does {@link Gerrit#isSignedIn()} have to be true to be on this screen? */ - public boolean isRequiresSignIn() { - return requiresSignIn; - } - - /** Get the token to cache this screen's widget; null if it shouldn't cache. */ - public Object getScreenCacheToken() { - return null; - } - - /** - * Reconfigure this screen after being recycled. - * <p> - * This method is invoked on a cached screen instance just before it is - * recycled into the UI. The returned screen instance is what will actually be - * shown to the user. - * - * @param newScreen the screen object created by the Link class (or some other - * form of screen constructor) and that was just passed into - * {@link Gerrit#display(Screen)}. Its {@link #getScreenCacheToken()} - * is equal to <code>this.getScreenCacheToken()</code> but it may have - * other parameter information worth copying. - * @return typically <code>this</code> to reuse the cached screen; - * <code>newScreen</code> to discard the cached screen instance and - * use the new one. - */ - public Screen recycleThis(final Screen newScreen) { - return this; - } -} diff --git a/webapp/src/com/google/gerrit/git/GitMetaUtil.java b/webapp/src/com/google/gerrit/git/GitMetaUtil.java deleted file mode 100644 index 1457cb3465..0000000000 --- a/webapp/src/com/google/gerrit/git/GitMetaUtil.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.git; - -import org.spearce.jgit.lib.Repository; - -import java.io.File; -import java.io.IOException; -import java.util.Random; - -public class GitMetaUtil { - private static final int SLEEP_MIN = 100; // milliseconds - private static final int SLEEP_MAX = 2 * 60 * 1000; // milliseconds - private static final ThreadLocal<Random> SLEEP_RNG = - new ThreadLocal<Random>() { - @Override - protected Random initialValue() { - return new Random(); - } - }; - - private static int waitTime() { - return SLEEP_MIN + SLEEP_RNG.get().nextInt(SLEEP_MAX - SLEEP_MIN); - } - - public static void randomSleep() { - try { - Thread.sleep(waitTime()); - } catch (InterruptedException ie) { - // Just let the thread continue anyway. - } - } - - public static boolean isGitRepository(final File gitdir) { - return new File(gitdir, "config").isFile() - && new File(gitdir, "HEAD").isFile() - && new File(gitdir, "objects").isDirectory() - && new File(gitdir, "refs/heads").isDirectory(); - } - - public static Repository open(final File gitdir) throws IOException { - if (isGitRepository(gitdir)) { - return new Repository(gitdir); - } - - if (isGitRepository(new File(gitdir, ".git"))) { - return new Repository(new File(gitdir, ".git")); - } - - final String name = gitdir.getName(); - final File parent = gitdir.getParentFile(); - if (isGitRepository(new File(parent, name + ".git"))) { - return new Repository(new File(parent, name + ".git")); - } - - return null; - } -} diff --git a/webapp/src/com/google/gerrit/git/InvalidRepositoryException.java b/webapp/src/com/google/gerrit/git/InvalidRepositoryException.java deleted file mode 100644 index 0686f21a75..0000000000 --- a/webapp/src/com/google/gerrit/git/InvalidRepositoryException.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.git; - -/** Indicates a directory does not contain a valid Git repository. */ -public class InvalidRepositoryException extends Exception { - public InvalidRepositoryException(final String name) { - super(name); - } - - public InvalidRepositoryException(final String name, final Throwable err) { - super(name, err); - } -} diff --git a/webapp/src/com/google/gerrit/git/PatchSetImporter.java b/webapp/src/com/google/gerrit/git/PatchSetImporter.java deleted file mode 100644 index 36a83bbd87..0000000000 --- a/webapp/src/com/google/gerrit/git/PatchSetImporter.java +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.git; - -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.reviewdb.PatchContent; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.reviewdb.PatchSetAncestor; -import com.google.gerrit.client.reviewdb.PatchSetInfo; -import com.google.gerrit.client.reviewdb.RevId; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gerrit.client.reviewdb.UserIdentity; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.Transaction; - -import org.spearce.jgit.lib.Commit; -import org.spearce.jgit.lib.Constants; -import org.spearce.jgit.lib.ObjectId; -import org.spearce.jgit.lib.ObjectWriter; -import org.spearce.jgit.lib.PersonIdent; -import org.spearce.jgit.lib.Repository; -import org.spearce.jgit.lib.Tree; -import org.spearce.jgit.patch.CombinedFileHeader; -import org.spearce.jgit.patch.FileHeader; -import org.spearce.jgit.revwalk.RevCommit; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** Imports a {@link PatchSet} from a {@link Commit}. */ -public class PatchSetImporter { - private static final int MAX_TRIES = 10; - private final ReviewDb db; - private final Repository repo; - private final RevCommit src; - private final PatchSet dst; - private final boolean isNew; - private org.spearce.jgit.patch.Patch gitpatch; - - private PatchSetInfo info; - private boolean infoIsNew; - - private final MessageDigest contentmd = Constants.newMessageDigest(); - private final Map<String, Patch> patchExisting = new HashMap<String, Patch>(); - private final List<Patch> patchInsert = new ArrayList<Patch>(); - private final List<Patch> patchUpdate = new ArrayList<Patch>(); - private final Map<PatchContent.Key, String> content = - new HashMap<PatchContent.Key, String>(); - - private final Map<Integer, PatchSetAncestor> ancestorExisting = - new HashMap<Integer, PatchSetAncestor>(); - private final List<PatchSetAncestor> ancestorInsert = - new ArrayList<PatchSetAncestor>(); - private final List<PatchSetAncestor> ancestorUpdate = - new ArrayList<PatchSetAncestor>(); - - public PatchSetImporter(final ReviewDb dstDb, final Repository srcRepo, - final RevCommit srcCommit, final PatchSet dstPatchSet, - final boolean isNewPatchSet) { - db = dstDb; - repo = srcRepo; - src = srcCommit; - dst = dstPatchSet; - isNew = isNewPatchSet; - } - - public void run() throws IOException, OrmException { - gitpatch = readGitPatch(); - - dst.setRevision(toRevId(src)); - - if (!isNew) { - // If we aren't a new patch set then we need to load the existing - // files so we can update or delete them if there are corrections. - // - info = db.patchSetInfo().get(dst.getKey()); - for (final Patch p : db.patches().byPatchSet(dst.getKey())) { - patchExisting.put(p.getFileName(), p); - } - for (final PatchSetAncestor a : db.patchSetAncestors().ancestorsOf( - dst.getKey())) { - ancestorExisting.put(a.getPosition(), a); - } - } - - importInfo(); - for (final FileHeader fh : gitpatch.getFiles()) { - importFile(fh); - } - - // Ensure all content entities exist - // - putPatchContent(); - - final Transaction txn = db.beginTransaction(); - if (isNew) { - db.patchSets().insert(Collections.singleton(dst)); - } - if (infoIsNew) { - db.patchSetInfo().insert(Collections.singleton(info)); - } else { - db.patchSetInfo().update(Collections.singleton(info)); - } - db.patches().insert(patchInsert, txn); - db.patchSetAncestors().insert(ancestorInsert, txn); - if (!isNew) { - db.patches().update(patchUpdate, txn); - db.patches().delete(patchExisting.values(), txn); - - db.patchSetAncestors().update(ancestorUpdate, txn); - db.patchSetAncestors().delete(ancestorExisting.values(), txn); - } - txn.commit(); - } - - private void importInfo() { - if (info == null) { - info = new PatchSetInfo(dst.getKey()); - infoIsNew = true; - } - - info.setSubject(src.getShortMessage()); - info.setMessage(src.getFullMessage()); - info.setAuthor(toUserIdentity(src.getAuthorIdent())); - info.setCommitter(toUserIdentity(src.getCommitterIdent())); - - for (int p = 0; p < src.getParentCount(); p++) { - PatchSetAncestor a = ancestorExisting.remove(p + 1); - if (a == null) { - a = new PatchSetAncestor(new PatchSetAncestor.Key(dst.getKey(), p + 1)); - ancestorInsert.add(a); - } else { - ancestorUpdate.add(a); - } - a.setAncestorRevision(toRevId(src.getParent(p))); - } - } - - private UserIdentity toUserIdentity(final PersonIdent who) { - final UserIdentity u = new UserIdentity(); - u.setName(who.getName()); - u.setEmail(who.getEmailAddress()); - u.setDate(new Timestamp(who.getWhen().getTime())); - u.setTimeZone(who.getTimeZoneOffset()); - return u; - } - - private void importFile(final FileHeader fh) - throws UnsupportedEncodingException { - final String path; - if (fh.getChangeType() == FileHeader.ChangeType.DELETE) { - path = fh.getOldName(); - } else { - path = fh.getNewName(); - } - - Patch p = patchExisting.remove(path); - if (p == null) { - p = new Patch(new Patch.Id(dst.getKey(), path)); - patchInsert.add(p); - } else { - p.setSourceFileName(null); - patchUpdate.add(p); - } - - // Convert the ChangeType - // - if (fh.getChangeType() == FileHeader.ChangeType.ADD) { - p.setChangeType(Patch.ChangeType.ADD); - - } else if (fh.getChangeType() == FileHeader.ChangeType.MODIFY) { - p.setChangeType(Patch.ChangeType.MODIFIED); - - } else if (fh.getChangeType() == FileHeader.ChangeType.DELETE) { - p.setChangeType(Patch.ChangeType.DELETED); - - } else if (fh.getChangeType() == FileHeader.ChangeType.RENAME) { - p.setChangeType(Patch.ChangeType.RENAMED); - p.setSourceFileName(fh.getOldName()); - - } else if (fh.getChangeType() == FileHeader.ChangeType.COPY) { - p.setChangeType(Patch.ChangeType.COPIED); - p.setSourceFileName(fh.getOldName()); - } - - // Convert the PatchType - // - if (fh instanceof CombinedFileHeader) { - p.setPatchType(Patch.PatchType.N_WAY); - - } else if (fh.getPatchType() == FileHeader.PatchType.GIT_BINARY) { - p.setPatchType(Patch.PatchType.BINARY); - - } else if (fh.getPatchType() == FileHeader.PatchType.BINARY) { - p.setPatchType(Patch.PatchType.BINARY); - } - - // Hash the content. - // - final String contentStr = fh.getScriptText(); - contentmd.reset(); - contentmd.update(contentStr.getBytes("UTF-8")); - final PatchContent.Key contentKey = - new PatchContent.Key(ObjectId.fromRaw(contentmd.digest()).name()); - content.put(contentKey, contentStr); - p.setContent(contentKey); - } - - private void putPatchContent() throws OrmException { - OrmException contentPutError = null; - for (int attempts = 0; !content.isEmpty() && ++attempts < MAX_TRIES;) { - for (final PatchContent pc : db.patchContents().get(content.keySet())) { - content.remove(pc.getKey()); - } - - for (final Iterator<Map.Entry<PatchContent.Key, String>> i = - content.entrySet().iterator(); i.hasNext();) { - final Map.Entry<PatchContent.Key, String> e = i.next(); - final PatchContent pc = new PatchContent(e.getKey(), e.getValue()); - try { - db.patchContents().insert(Collections.singleton(pc)); - i.remove(); - } catch (OrmException err) { - contentPutError = err; - } - } - - if (!content.isEmpty()) { - GitMetaUtil.randomSleep(); - } - } - if (!content.isEmpty() && contentPutError != null) { - throw contentPutError; - } - } - - private static RevId toRevId(final RevCommit src) { - return new RevId(src.getId().name()); - } - - private org.spearce.jgit.patch.Patch readGitPatch() throws IOException { - final List<String> args = new ArrayList<String>(); - args.add("git"); - args.add("--git-dir=."); - args.add("diff-tree"); - args.add("-M"); - args.add("--full-index"); - - switch (src.getParentCount()) { - case 0: - args.add("--unified=5"); - args.add(new ObjectWriter(repo).writeTree(new Tree(repo)).name()); - args.add(src.getTree().getId().name()); - break; - case 1: - args.add("--unified=5"); - args.add(src.getParent(0).getId().name()); - args.add(src.getId().name()); - break; - default: - args.add("--cc"); - args.add(src.getId().name()); - break; - } - - final Process proc = - Runtime.getRuntime().exec(args.toArray(new String[args.size()]), null, - repo.getDirectory()); - try { - final org.spearce.jgit.patch.Patch p = new org.spearce.jgit.patch.Patch(); - proc.getOutputStream().close(); - proc.getErrorStream().close(); - p.parse(proc.getInputStream()); - proc.getInputStream().close(); - return p; - } finally { - try { - if (proc.waitFor() != 0) { - throw new IOException("git diff-tree exited abnormally"); - } - } catch (InterruptedException ie) { - } - } - } -} diff --git a/webapp/src/com/google/gerrit/git/RepositoryCache.java b/webapp/src/com/google/gerrit/git/RepositoryCache.java deleted file mode 100644 index 83b58eaa8e..0000000000 --- a/webapp/src/com/google/gerrit/git/RepositoryCache.java +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.git; - -import org.spearce.jgit.lib.Repository; - -import java.io.File; -import java.io.IOException; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - -/** Cache of active Git repositories being used by the manager. */ -public class RepositoryCache { - private static final Pattern REPO_NAME = - Pattern.compile("^[A-Za-z][A-Za-z0-9/_-]+$"); - - private final File base; - - private final Map<String, Reference<Repository>> cache; - - /** - * Create a new cache to manage a specific base directory (and below). - * - * @param basedir top level directory that contains all repositories. - */ - public RepositoryCache(final File basedir) { - base = basedir; - cache = new HashMap<String, Reference<Repository>>(); - } - - /** - * @return the base directory which contains all known repositories. - */ - public File getBaseDirectory() { - return base; - } - - /** - * Get (or open) a repository by name. - * - * @param name the repository name, relative to the base directory supplied - * when the cache was created. - * @return the cached Repository instance. - * @throws InvalidRepositoryException the name does not denote an existing - * repository, or the name cannot be read as a repository. - */ - public synchronized Repository get(String name) - throws InvalidRepositoryException { - if (name.endsWith(".git")) { - name = name.substring(0, name.length() - 4); - } - - if (!REPO_NAME.matcher(name).matches()) { - throw new InvalidRepositoryException(name); - } - - final Reference<Repository> ref = cache.get(name); - Repository db = ref != null ? ref.get() : null; - if (db == null) { - try { - db = GitMetaUtil.open(new File(base, name)); - if (db == null) { - throw new InvalidRepositoryException(name); - } - } catch (IOException err) { - throw new InvalidRepositoryException(name, err); - } - cache.put(name, new SoftReference<Repository>(db)); - } - return db; - } -} diff --git a/webapp/src/com/google/gerrit/pgm/ReimportPatchSets.java b/webapp/src/com/google/gerrit/pgm/ReimportPatchSets.java deleted file mode 100644 index 1e8255a43a..0000000000 --- a/webapp/src/com/google/gerrit/pgm/ReimportPatchSets.java +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.pgm; - -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gerrit.git.InvalidRepositoryException; -import com.google.gerrit.git.PatchSetImporter; -import com.google.gerrit.server.GerritServer; -import com.google.gwtjsonrpc.server.XsrfException; -import com.google.gwtorm.client.OrmException; - -import org.spearce.jgit.lib.ObjectId; -import org.spearce.jgit.lib.ProgressMonitor; -import org.spearce.jgit.lib.Repository; -import org.spearce.jgit.lib.TextProgressMonitor; -import org.spearce.jgit.revwalk.RevCommit; -import org.spearce.jgit.revwalk.RevWalk; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.sql.SQLException; -import java.util.ArrayList; - -/** - * Recreates PatchSet and Patch entities for the changes supplied. - * <p> - * Takes on input strings of the form <code>change_id|patch_set_id</code>, such - * as might be created by the following PostgreSQL database dump: - * - * <pre> - * psql reviewdb -tAc 'select change_id,patch_set_id from patch_sets' - * </pre> - * <p> - * For each supplied PatchSet the info and patch entities are completely updated - * based on the data stored in Git. - */ -public class ReimportPatchSets { - public static void main(final String[] argv) throws OrmException, - XsrfException, IOException { - final ArrayList<PatchSet.Id> todo = new ArrayList<PatchSet.Id>(); - final BufferedReader br = - new BufferedReader(new InputStreamReader(System.in)); - String line; - while ((line = br.readLine()) != null) { - final String[] idstr = line.split("\\|"); - todo.add(new PatchSet.Id(Change.Id.fromString(idstr[0]), Integer - .parseInt(idstr[1]))); - } - - final GerritServer gs = GerritServer.getInstance(); - final ReviewDb db = gs.getDatabase().open(); - final ProgressMonitor pm = new TextProgressMonitor(); - try { - pm.start(1); - pm.beginTask("Import patch sets", todo.size()); - for (int i = 0; i < todo.size(); i++) { - final PatchSet.Id psid = todo.get(i); - final PatchSet ps = db.patchSets().get(psid); - if (ps == null) { - System.err.println(); - System.err.println("NotFound " + psid); - continue; - } - - final Change c = db.changes().get(ps.getKey().getParentKey()); - if (c == null) { - System.err.println(); - System.err.println("Orphan " + psid); - continue; - } - - final String projectName = c.getDest().getParentKey().get(); - final Repository repo; - try { - repo = gs.getRepositoryCache().get(projectName); - } catch (InvalidRepositoryException ie) { - System.err.println(); - System.err.println("NoProject " + psid); - System.err.println("NoProject " + ie.getMessage()); - continue; - } - - final RevWalk rw = new RevWalk(repo); - final RevCommit src = - rw.parseCommit(ObjectId.fromString(ps.getRevision().get())); - new PatchSetImporter(db, repo, src, ps, false).run(); - pm.update(1); - } - } catch (OrmException e) { - System.err.println(); - e.printStackTrace(); - if (e.getCause() instanceof SQLException) { - final SQLException e2 = (SQLException) e.getCause(); - if (e2.getNextException() != null) { - e2.getNextException().printStackTrace(); - } - } - } finally { - pm.endTask(); - db.close(); - } - } -} diff --git a/webapp/src/com/google/gerrit/public/Gerrit.css b/webapp/src/com/google/gerrit/public/Gerrit.css deleted file mode 100644 index 25f2c57ff9..0000000000 --- a/webapp/src/com/google/gerrit/public/Gerrit.css +++ /dev/null @@ -1,475 +0,0 @@ -#gerrit_body { - font-size: 11pt; - padding-left: 5px; - padding-right: 5px; - width: 98%; -} - -#gerrit_topmenu { - font-size: 9pt; - padding-top: 5px; - padding-left: 5px; - padding-right: 5px; - height: 15px; -} -#gerrit_endtopmenu { - clear: both; - height: 5px; - border-bottom: 1px solid #B0BDCC; -} - - -/** Widgets **/ -.gerrit-Hyperlink { - text-decoration: underline; -} - -.gerrit-AccountName { - white-space: nowrap; -} - -.gerrit-visualtab { - color: red; - font-weight: bold; - font-size: 8pt; -} - - -/** Menu **/ -.gerrit-LinkMenuBar .gwt-MenuItem { - font-size: 9pt; - color: #0000AA; - text-decoration: underline; - padding-left: 5px; - padding-right: 5px; - white-space: nowrap; - cursor: pointer; - cursor: hand; -} -.gerrit-LinkMenuBar .gwt-MenuItem-NormalItem { - border-right: 1px solid black; -} -.gerrit-LinkMenuBar .gwt-MenuItem-LastItem { -} -.gerrit-FillMenuCenter { - width: 100%; -} -.gwt-MenuItem .gwt-Hyperlink { - font-size: 9pt; - white-space: nowrap; -} -.gerrit-MenuBarUserName { - font-size: 9pt; - font-weight: bold; - padding-left: 5px; - padding-right: 5px; - white-space: nowrap; -} - -/** RPC Status **/ -.gerrit-RpcStatusPanel { - position: absolute; - left: 50%; - float: left; -} - -.gerrit-RpcStatus { - padding-top: 4px; - padding-bottom: 4px; - padding-left: 10px; - padding-right: 10px; - text-align: center; - font-weight: bold; -} - -.gerrit-RpcStatus-Loading { - background: #FFF1A8; -} - - -/** Error Dialog **/ -.gerrit-ErrorDialog { - margin: 10px 10px 10px 10px; -} - -.gerrit-ErrorDialog-ErrorType { - font-weight: bold; - white-space: nowrap; - margin-bottom: 15px; -} - -.gerrit-ErrorDialog-ErrorMessage { -} - -.gerrit-ErrorDialog-Buttons { - width: 100%; - margin-top: 15px; - text-align: right; -} - - -/** Screen **/ -.gerrit-Screen { -} - -.gerrit-Screen h1 { - white-space: nowrap; - font-size: 16pt; - margin: 3px 0 8px; - text-overflow: ellipsis; - overflow: hidden; -} - - -/** ChangeTable **/ -.gerrit-ChangeTable { - width: 100%; - border-collapse: separate; - border-spacing: 0; -} - -.gerrit-ChangeTable .IconCell { - width: 1px; - padding: 0px; - vertical-align: center; - border-bottom: 1px solid #d4e9a9; -} - -.gerrit-ChangeTable .ChangeTypeCell { - width: 1px; - padding-left: 5px; - padding-right: 5px; - border-right: 1px solid #d4e9a9; - border-bottom: 1px solid #d4e9a9; -} - -.gerrit-ChangeTable .CommentCell { - text-align: right; - font-weight: bold; - white-space: nowrap; -} - -.gerrit-ChangeTable .FilePathCell { - white-space: nowrap; -} - -.gerrit-ChangeTable .FilePathCell .SourceFilePath { - font-style: italic; - font-size: 9pt; -} - -.gerrit-ChangeTable .DiffLinkCell { - white-space: nowrap; -} - -.gerrit-ChangeTable .DataCell { - padding-left: 5px; - padding-right: 5px; - border-right: 1px solid #d4e9a9; - border-bottom: 1px solid #d4e9a9; -} - -.gerrit-ChangeTable .C_ID { - width: 3.5em; - text-align: right; -} - -.gerrit-ChangeTable .C_SUBJECT { - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; -} - -.gerrit-ChangeTable .IconHeader { - border-top: 1px solid white; - border-bottom: 1px solid white; - background-color: #d4e9a9; -} - -.gerrit-ChangeTable .DataHeader { - border: 1px solid white; - padding: 2px 6px 1px; - background-color: #d4e9a9; - font-style: italic; - white-space: nowrap; -} - -.gerrit-ChangeTable .SectionHeader { - border-top: 8px solid white; - padding: 2px 6px 1px; - background-color: #d4e9a9; - white-space: nowrap; - font-weight: bold; -} - -.gerrit-ChangeTable .EmptySection { - border-right: 1px solid #d4e9a9; - border-bottom: 1px solid #d4e9a9; - font-style: italic; - padding-left: 25px; -} - - -/** PatchContentTable **/ -.gerrit-PatchContentTable { - width: 100%; - border-collapse: separate; - border-spacing: 0; -} - -.gerrit-PatchContentTable .IconCell { - width: 1px; - padding: 0px; - vertical-align: center; -} - -.gerrit-PatchContentTable .DiffText { - white-space: pre; - font-family: Courier New, Courier, monospace; - font-size: small; -} - -.gerrit-PatchContentTable .DiffText-FILE_HEADER { - color: grey; - font-weight: bold; -} -.gerrit-PatchContentTable .DiffText-HUNK_HEADER { - color: blue; -} -.gerrit-PatchContentTable .DiffText-PRE_IMAGE { - color: red; -} -.gerrit-PatchContentTable .DiffText-CONTEXT { - color: grey; -} -.gerrit-PatchContentTable .DiffText-POST_IMAGE { - color: #00a000; -} - -.gerrit-PatchContentTable .Comment .header { - width: 35em; -} -.gerrit-PatchContentTable .gwt-DisclosurePanel .header td { - white-space: nowrap; -} -.gerrit-PatchContentTable .Comment .complexHeader { - white-space: nowrap; - width: 5em; -} -.gerrit-PatchContentTable .Comment .content { - border-top: 3px solid #e3e3e3; -} -.gerrit-PatchContentTable .CommentIsDraftFlag { - font-weight: bold; - margin-left: 0.5em; - margin-right: 0.5em; -} - -.gerrit-PatchContentTable .FileColumnHeader { - background: #d4e9a9; - font-weight: bold; - text-align: center; -} - -.gerrit-PatchContentTable .LineNumber { - font-family: Courier New, Courier, monospace; - width: 3.5em; - padding: 0px; - text-align: right; - border-right: thin solid #b0bdcc; - padding-left: 0.2em; - padding-right: 0.2em; -} - -.gerrit-PatchContentTable .NoLineLineNumber { - font-family: Courier New, Courier, monospace; - width: 3.5em; - padding-left: 0.2em; - padding-right: 0.2em; -} - -.gerrit-PatchContentTable .FileLine { - padding-left: 0.2em; - white-space: pre; - font-family: Courier New, Courier, monospace; - font-size: small; - padding-right: 0.2em; -} - -.gerrit-PatchContentTable .FileLineNone { - background: #eeeeee; -} -.gerrit-PatchContentTable .FileLine-DELETE { - background: #ffeeee; -} -.gerrit-PatchContentTable .FileLine-EQUAL { -} -.gerrit-PatchContentTable .FileLine-INSERT { - background: #ddffdd; -} - -.gerrit-PatchContentTable .SkipLine { - text-align: center; - font-style: italic; - background: lightblue; -} -.gerrit-PatchContentTable .SkipLine div { - display: inline; -} - - -/** Change **/ -.gerrit-ChangeScreen .gwt-DisclosurePanel .header td { - font-weight: bold; - white-space: nowrap; -} - -.gerrit-ChangeScreen .gwt-DisclosurePanel .complexHeader { - white-space: nowrap; -} - -.gerrit-ChangeScreen .gwt-DisclosurePanel .complexHeader .gerrit-PatchSetLink { - padding-left: 20px; - font-size: 8pt; -} - -.gerrit-ChangeScreen .gwt-DisclosurePanel .content { - margin-bottom: 10px; -} - -.gerrit-ChangeScreen-Description { - white-space: pre; - font-family: Courier New, Courier, monospace; - font-size: small; -} - -.gerrit-ChangeScreen .gerrit-ChangeMessages .header { - width: 35em; -} -.gerrit-ChangeScreen .gerrit-ChangeMessages .complexHeader { - width: 5em; -} -.gerrit-ChangeScreen .gerrit-ChangeMessages .content { - border-top: 3px solid #e3e3e3; -} - -.gerrit-ChangeMessage-Message { - white-space: pre; - font-size: small; -} - -.gerrit-InfoTable { - border-collapse: collapse; - border-spacing: 0; -} - -.gerrit-InfoTable td { - border-left: 1px solid #d4e9a9; - border-bottom: 1px solid #d4e9a9; - padding: 2px 6px 1px; -} - -.gerrit-InfoTable td.header { - background-color: #d4e9a9; - border-left: 1px solid white; - font-weight: normal; - padding: 2px 4px 0 6px; - font-style: italic; - text-align: left; - vertical-align: top; - white-space: nowrap; -} - -.gerrit-InfoTable td.leftmost { -} - -.gerrit-InfoTable td.rightmost { - border-right: 1px solid #d4e9a9; -} - -.gerrit-InfoTable td.approvalrole { - width: 5em; - border-left: none; - font-style: italic; - white-space: nowrap; -} - -.gerrit-InfoTable td.approvalscore { - text-align: center; -} -.gerrit-InfoTable td.negscore { - color: red; -} -.gerrit-InfoTable td.posscore { - color: #08a400; -} - -.gerrit-InfoTable td.approvalhint { - white-space: nowrap; - background-left: 1px none; - background-bottom: 1px none; - border: none; - color: #444444; -} - -.gerrit-ChangeInfoBlock { -} - -.gerrit-InfoBlock { - border-collapse: collapse; - border-spacing: 0; -} - -.gerrit-InfoBlock td { - padding: 2px 4px 2px 6px; - border-right: 1px solid #d4e9a9; - border-bottom: 1px solid #d4e9a9; - text-align: left; - white-space: nowrap; -} - -.gerrit-InfoBlock td.topmost { - border-top: 1px solid #d4e9a9; -} - -.gerrit-InfoBlock td.header { - border-bottom: 1px solid white; - background-color: #d4e9a9; - font-style: italic; - text-align: right; -} - -.gerrit-InfoBlock td.bottomheader { - border-bottom: 1px solid #d4e9a9; -} - -.gerrit-InfoBlock td.closedstate { - font-weight: bold; -} - -.gerrit-InfoBlock td.permalink { - border-right: 1px none; - border-bottom: 1px none; - text-align: right; -} - -.gerrit-InfoBlock td.command { - white-space: pre; - font-family: Courier New, Courier, monospace; -} - -.gerrit-PatchSetInfoBlock { - margin-bottom: 10px; -} - - -/** SideBySideScreen */ -.gerrit-SideBySideScreen-SideBySideTable { - width: 100%; - border: 1px solid #B0BDCC; - display: table; -} - -.gerrit-PatchLineComment { - font-size: small; -} diff --git a/webapp/src/com/google/gerrit/public/Gerrit.html b/webapp/src/com/google/gerrit/public/Gerrit.html deleted file mode 100644 index da37f008cb..0000000000 --- a/webapp/src/com/google/gerrit/public/Gerrit.html +++ /dev/null @@ -1,19 +0,0 @@ -<html> - <head> - <title>Gerrit Code Review</title> - <script id="gerrit_gerritconfig"></script> - <script type="text/javascript" language="javascript" src="com.google.gerrit.Gerrit.nocache.js"></script> - <style type="text/css" id="gerrit_sitecss"></style> - </head> - <body> - <div id="gerrit_topmenu"></div> - <div id="gerrit_endtopmenu"></div> - <div id="gerrit_header"></div> - <noscript> - <p>Gerrit requires a JavaScript enabled browser.</p> - </noscript> - <div id="gerrit_body"></div> - <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> - <div id="gerrit_footer"></div> - </body> -</html> diff --git a/webapp/src/com/google/gerrit/public/SetCookie.html b/webapp/src/com/google/gerrit/public/SetCookie.html deleted file mode 100644 index fd7ff71ab4..0000000000 --- a/webapp/src/com/google/gerrit/public/SetCookie.html +++ /dev/null @@ -1,28 +0,0 @@ -<html> - <head> - <style type="text/css"> - #login_div { - width: 100%; - margin-left: auto; - margin-right: auto; - } - #submit { - font-weight: bold; - } - </style> - </head> - <body> - <div style="height: 50px"></div> - <table width="100%" border="0"> - <tr> - <td width="50%"></td> - <td> - <form id="set_form" action="/replace" method="POST"> - <input id="submit" type="submit" value="Finish Sign-in"/> - </form> - </td> - <td width="50%"></td> - </tr> - </table> - </body> -</html> diff --git a/webapp/src/com/google/gerrit/server/AccountServiceSrv.java b/webapp/src/com/google/gerrit/server/AccountServiceSrv.java deleted file mode 100644 index ca8ea8b4af..0000000000 --- a/webapp/src/com/google/gerrit/server/AccountServiceSrv.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.client.account.AccountServiceImpl; - -/** Publishes {@link AccountServiceImpl} over JSON. */ -public class AccountServiceSrv extends GerritJsonServlet { - @Override - protected Object createServiceHandle() throws Exception { - return new AccountServiceImpl(GerritServer.getInstance().getDatabase()); - } -} diff --git a/webapp/src/com/google/gerrit/server/CacheControlFilter.java b/webapp/src/com/google/gerrit/server/CacheControlFilter.java deleted file mode 100644 index 055be93e40..0000000000 --- a/webapp/src/com/google/gerrit/server/CacheControlFilter.java +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import java.io.IOException; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * Forces GWT resources to cache for a very long time. - * <p> - * GWT compiled JavaScript and ImageBundles can be cached indefinitely by a - * browser and/or an edge proxy, as they never contain user-specific data and - * are named by a unique checksum. If their content is ever modified then the - * URL changes, so user agents would request a different resource. We force - * these resources to have very long expiration times. - */ -public class CacheControlFilter implements Filter { - public void init(final FilterConfig config) { - } - - public void destroy() { - } - - public void doFilter(final ServletRequest sreq, final ServletResponse srsp, - final FilterChain chain) throws IOException, ServletException { - final HttpServletRequest req = (HttpServletRequest) sreq; - final HttpServletResponse rsp = (HttpServletResponse) srsp; - final String pathInfo = pathInfo(req); - - if (cacheForever(pathInfo)) { - rsp.setHeader("Cache-Control", "max-age=31536000,public"); - rsp.setDateHeader("Expires", System.currentTimeMillis() + 31536000000L); - } else if (nocache(pathInfo)) { - rsp.setHeader("Expires", "Fri, 01 Jan 1980 00:00:00 GMT"); - rsp.setHeader("Pragma", "no-cache"); - rsp.setHeader("Cache-Control", "no-cache, must-revalidate"); - } - - chain.doFilter(req, rsp); - } - - private static boolean cacheForever(final String pathInfo) { - if (pathInfo.endsWith(".cache.gif")) { - return true; - } - if (pathInfo.endsWith(".cache.html")) { - return true; - } - if (pathInfo.endsWith(".cache.png")) { - return true; - } - return false; - } - - private static boolean nocache(final String pathInfo) { - if (pathInfo.endsWith(".nocache.js")) { - return true; - } - return false; - } - - private static String pathInfo(final HttpServletRequest req) { - final String uri = req.getRequestURI(); - final String ctx = req.getContextPath(); - return uri.startsWith(ctx) ? uri.substring(ctx.length()) : uri; - } -} diff --git a/webapp/src/com/google/gerrit/server/ChangeDetailServiceSrv.java b/webapp/src/com/google/gerrit/server/ChangeDetailServiceSrv.java deleted file mode 100644 index a1aa93e560..0000000000 --- a/webapp/src/com/google/gerrit/server/ChangeDetailServiceSrv.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.client.changes.ChangeDetailServiceImpl; - -/** Publishes {@link ChangeDetailServiceImpl} over JSON. */ -public class ChangeDetailServiceSrv extends GerritJsonServlet { - @Override - protected Object createServiceHandle() throws Exception { - return new ChangeDetailServiceImpl(GerritServer.getInstance().getDatabase()); - } -} diff --git a/webapp/src/com/google/gerrit/server/ChangeListServiceSrv.java b/webapp/src/com/google/gerrit/server/ChangeListServiceSrv.java deleted file mode 100644 index 55b2e7ed16..0000000000 --- a/webapp/src/com/google/gerrit/server/ChangeListServiceSrv.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.client.changes.ChangeListServiceImpl; - -/** Publishes {@link ChangeListServiceImpl} over JSON. */ -public class ChangeListServiceSrv extends GerritJsonServlet { - @Override - protected Object createServiceHandle() throws Exception { - return new ChangeListServiceImpl(GerritServer.getInstance().getDatabase()); - } -} diff --git a/webapp/src/com/google/gerrit/server/GerritCall.java b/webapp/src/com/google/gerrit/server/GerritCall.java deleted file mode 100644 index bda3ee2f27..0000000000 --- a/webapp/src/com/google/gerrit/server/GerritCall.java +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.client.Gerrit; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.rpc.RpcUtil; -import com.google.gerrit.client.rpc.RpcUtil.CurrentAccountImpl; -import com.google.gwtjsonrpc.server.ActiveCall; -import com.google.gwtjsonrpc.server.ValidToken; -import com.google.gwtorm.client.OrmException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public class GerritCall extends ActiveCall { - static { - RpcUtil.setCurrentAccountImpl(new CurrentAccountImpl() { - public Account.Id getAccountId() { - final GerritCall c = GerritJsonServlet.getCurrentCall(); - return c != null ? c.getAccountId() : null; - } - }); - } - - private final GerritServer server; - private boolean accountRead; - private ValidToken accountInfo; - private Account.Id accountId; - - public GerritCall(final GerritServer gs, final HttpServletRequest i, - final HttpServletResponse o) { - super(i, o); - server = gs; - } - - @Override - public void onFailure(final Throwable error) { - if (error instanceof OrmException) { - onInternalFailure(error); - } else { - super.onFailure(error); - } - } - - @Override - public String getUser() { - initAccount(); - return accountInfo != null ? accountInfo.getData() : null; - } - - public Account.Id getAccountId() { - initAccount(); - return accountId; - } - - private void initAccount() { - if (accountRead) { - return; - } - - accountRead = true; - accountInfo = getCookie(Gerrit.ACCOUNT_COOKIE, server.getAccountToken()); - - if (accountInfo == null) { - if (getCookie(Gerrit.ACCOUNT_COOKIE) != null) { - // The cookie is bogus, but it was sent. Send an expired cookie - // back to clear it out of the browser's cookie store. - // - removeCookie(Gerrit.ACCOUNT_COOKIE); - } - return; - } - - try { - accountId = new Account.Id(Integer.parseInt(accountInfo.getData())); - } catch (NumberFormatException e) { - // Whoa, did we change our cookie format or something? This should - // never happen on a valid acocunt token, but discard it anyway. - // - removeCookie(Gerrit.ACCOUNT_COOKIE); - accountInfo = null; - accountId = null; - return; - } - - if (accountInfo.needsRefresh()) { - // The cookie is valid, but its getting stale. Update it with a - // newer date so it doesn't expire on an active user. - // - final String idstr = String.valueOf(accountId.get()); - setCookie(Gerrit.ACCOUNT_COOKIE, idstr, server.getAccountToken()); - } - } -} diff --git a/webapp/src/com/google/gerrit/server/GerritJsonServlet.java b/webapp/src/com/google/gerrit/server/GerritJsonServlet.java deleted file mode 100644 index 15c26a609f..0000000000 --- a/webapp/src/com/google/gerrit/server/GerritJsonServlet.java +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.client.rpc.NotSignedInException; -import com.google.gerrit.client.rpc.SignInRequired; -import com.google.gwtjsonrpc.server.JsonServlet; -import com.google.gwtjsonrpc.server.SignedToken; -import com.google.gwtjsonrpc.server.XsrfException; -import com.google.gwtorm.client.OrmException; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * Base JSON servlet to ensure the current user is not forged. - */ -public abstract class GerritJsonServlet extends JsonServlet<GerritCall> { - @SuppressWarnings("unchecked") - public static final GerritCall getCurrentCall() { - return JsonServlet.<GerritCall> getCurrentCall(); - } - - private GerritServer server; - - @Override - public void init(final ServletConfig config) throws ServletException { - super.init(config); - - try { - server = GerritServer.getInstance(); - } catch (OrmException e) { - throw new ServletException("Cannot configure GerritServer", e); - } catch (XsrfException e) { - throw new ServletException("Cannot configure GerritServer", e); - } - } - - @Override - protected SignedToken createXsrfSignedToken() throws XsrfException { - try { - return GerritServer.getInstance().getXsrfToken(); - } catch (OrmException e) { - throw new XsrfException("Cannot configure GerritServer", e); - } - } - - @Override - protected GerritCall createActiveCall(final HttpServletRequest req, - final HttpServletResponse resp) { - return new GerritCall(server, req, resp); - } - - @Override - protected void preInvoke(final GerritCall call) { - super.preInvoke(call); - if (!call.isComplete() - && call.getMethod().getAnnotation(SignInRequired.class) != null - && call.getAccountId() == null) { - // If SignInRequired exists on the method and we don't have an - // account id in the request, we can't permit this call to finish. - // - call.onFailure(new NotSignedInException()); - } - } - - @Override - protected abstract Object createServiceHandle() throws Exception; -} diff --git a/webapp/src/com/google/gerrit/server/GerritServer.java b/webapp/src/com/google/gerrit/server/GerritServer.java deleted file mode 100644 index 45aa935449..0000000000 --- a/webapp/src/com/google/gerrit/server/GerritServer.java +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.client.data.ApprovalType; -import com.google.gerrit.client.data.GerritConfig; -import com.google.gerrit.client.data.GitwebLink; -import com.google.gerrit.client.reviewdb.ApprovalCategory; -import com.google.gerrit.client.reviewdb.ApprovalCategoryValue; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gerrit.client.reviewdb.SystemConfig; -import com.google.gerrit.git.RepositoryCache; -import com.google.gwtjsonrpc.server.SignedToken; -import com.google.gwtjsonrpc.server.XsrfException; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.Transaction; -import com.google.gwtorm.jdbc.Database; -import com.google.gwtorm.jdbc.SimpleDataSource; - -import org.apache.commons.codec.binary.Base64; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Map; -import java.util.Properties; - -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.sql.DataSource; - -/** Global server-side state for Gerrit. */ -public class GerritServer { - private static GerritServer impl; - - /** - * Obtain the singleton server instance for this web application. - * - * @return the server instance. Never null. - * @throws OrmException the database could not be configured. There is - * something wrong with the schema configuration in {@link ReviewDb} - * that must be addressed by a developer. - * @throws XsrfException the XSRF support could not be correctly configured to - * protect the application against cross-site request forgery. The JVM - * is most likely lacking critical security algorithms. - */ - public static synchronized GerritServer getInstance() throws OrmException, - XsrfException { - if (impl == null) { - impl = new GerritServer(); - } - return impl; - } - - private final Database<ReviewDb> db; - private SystemConfig sConfig; - private GerritConfig gerritConfig; - private final SignedToken xsrf; - private final SignedToken account; - private final RepositoryCache repositories; - - private GerritServer() throws OrmException, XsrfException { - db = createDatabase(); - loadSystemConfig(); - if (sConfig == null) { - throw new OrmException("No " + SystemConfig.class.getName() + " found"); - } - - xsrf = new SignedToken(sConfig.maxSessionAge, sConfig.xsrfPrivateKey); - account = new SignedToken(sConfig.maxSessionAge, sConfig.accountPrivateKey); - - if (sConfig.gitBasePath != null) { - repositories = new RepositoryCache(new File(sConfig.gitBasePath)); - } else { - repositories = null; - } - } - - private Database<ReviewDb> createDatabase() throws OrmException { - final String dsName = "java:comp/env/jdbc/ReviewDb"; - final String pName = "GerritServer.properties"; - DataSource ds; - try { - ds = (DataSource) new InitialContext().lookup(dsName); - } catch (NamingException namingErr) { - final Properties p = readGerritDataSource(pName); - if (p == null) { - throw new OrmException("No DataSource " + dsName + " and no " + pName - + " in CLASSPATH. GerritServer requires either format.", namingErr); - } - - try { - ds = new SimpleDataSource(p); - } catch (SQLException se) { - throw new OrmException("Database in " + pName + " unavailable", se); - } - } - return new Database<ReviewDb>(ds, ReviewDb.class); - } - - private Properties readGerritDataSource(final String name) - throws OrmException { - final Properties srvprop = new Properties(); - final InputStream in; - - in = getClass().getClassLoader().getResourceAsStream(name); - if (in == null) { - return null; - } - try { - try { - srvprop.load(in); - } finally { - in.close(); - } - } catch (IOException e) { - throw new OrmException("Cannot read " + name, e); - } - - final Properties dbprop = new Properties(); - for (final Map.Entry<Object, Object> e : srvprop.entrySet()) { - final String key = (String) e.getKey(); - if (key.startsWith("database.")) { - dbprop.put(key.substring("database.".length()), e.getValue()); - } - } - return dbprop; - } - - private void initSystemConfig(final ReviewDb c) throws OrmException { - final SystemConfig s = SystemConfig.create(); - s.xsrfPrivateKey = SignedToken.generateRandomKey(); - s.accountPrivateKey = SignedToken.generateRandomKey(); - c.systemConfig().insert(Collections.singleton(s)); - } - - private void initVerifiedCategory(final ReviewDb c) throws OrmException { - final Transaction txn = c.beginTransaction(); - final ApprovalCategory cat; - final ArrayList<ApprovalCategoryValue> vals; - - cat = new ApprovalCategory(new ApprovalCategory.Id("VRIF"), "Verified"); - cat.setPosition((short) 0); - vals = new ArrayList<ApprovalCategoryValue>(); - vals.add(value(cat, 1, "Verified")); - vals.add(value(cat, 0, "No score")); - vals.add(value(cat, -1, "Fails")); - c.approvalCategories().insert(Collections.singleton(cat), txn); - c.approvalCategoryValues().insert(vals); - txn.commit(); - } - - private void initCodeReviewCategory(final ReviewDb c) throws OrmException { - final Transaction txn = c.beginTransaction(); - final ApprovalCategory cat; - final ArrayList<ApprovalCategoryValue> vals; - - cat = new ApprovalCategory(new ApprovalCategory.Id("CRVW"), "Code Review"); - cat.setPosition((short) 1); - vals = new ArrayList<ApprovalCategoryValue>(); - vals.add(value(cat, 2, "Looks good to me, approved")); - vals.add(value(cat, 1, "Looks good to me, but someone else must approve")); - vals.add(value(cat, 0, "No score")); - vals.add(value(cat, -1, "I would prefer that you didn't submit this")); - vals.add(value(cat, -2, "Do not submit")); - c.approvalCategories().insert(Collections.singleton(cat), txn); - c.approvalCategoryValues().insert(vals); - txn.commit(); - } - - private static ApprovalCategoryValue value(final ApprovalCategory cat, - final int value, final String name) { - return new ApprovalCategoryValue(new ApprovalCategoryValue.Key(cat.getId(), - (short) value), name); - } - - private void loadSystemConfig() throws OrmException { - final ReviewDb c = db.open(); - try { - try { - sConfig = c.systemConfig().get(new SystemConfig.Key()); - } catch (OrmException e) { - // Assume the schema doesn't exist, and create it. - // TODO Implement schema upgrades and/or exporting to a script file. - // - sConfig = null; - c.createSchema(); - } - - if (sConfig == null) { - // Assume the schema is empty and populate it. - // - initSystemConfig(c); - initVerifiedCategory(c); - initCodeReviewCategory(c); - sConfig = c.systemConfig().get(new SystemConfig.Key()); - } - - loadGerritConfig(c); - } finally { - c.close(); - } - } - - private void loadGerritConfig(final ReviewDb db) throws OrmException { - final GerritConfig r = new GerritConfig(); - r.setCanonicalUrl(getCanonicalURL()); - if (sConfig.gitwebUrl != null) { - r.setGitwebLink(new GitwebLink(sConfig.gitwebUrl)); - } - - for (final ApprovalCategory c : db.approvalCategories().all()) { - r.add(new ApprovalType(c, db.approvalCategoryValues().byCategory( - c.getId()).toList())); - } - - gerritConfig = r; - } - - /** Get the {@link ReviewDb} schema factory for the server. */ - public Database<ReviewDb> getDatabase() { - return db; - } - - /** Time (in seconds) that user sessions stay "signed in". */ - public int getSessionAge() { - return sConfig.maxSessionAge; - } - - /** Get the signature support used to protect against XSRF attacks. */ - public SignedToken getXsrfToken() { - return xsrf; - } - - /** Get the signature support used to protect user identity cookies. */ - public SignedToken getAccountToken() { - return account; - } - - /** A binary string key to encrypt cookies related to account data. */ - public String getAccountCookieKey() { - byte[] r = new byte[sConfig.accountPrivateKey.length()]; - for (int k = r.length - 1; k >= 0; k--) { - r[k] = (byte) sConfig.accountPrivateKey.charAt(k); - } - r = Base64.decodeBase64(r); - final StringBuilder b = new StringBuilder(); - for (int i = 0; i < r.length; i++) { - b.append((char) r[i]); - } - return b.toString(); - } - - /** Local filesystem location of header/footer/CSS configuration files. */ - public File getSitePath() { - return sConfig.sitePath != null ? new File(sConfig.sitePath) : null; - } - - /** Optional canonical URL for this application. */ - public String getCanonicalURL() { - String u = sConfig.canonicalUrl; - if (u != null && !u.endsWith("/")) { - u += "/"; - } - return u; - } - - /** Get the cached configuration data used by the client. */ - public GerritConfig getGerritConfig() { - return gerritConfig; - } - - /** Get the repositories maintained by this server. */ - public RepositoryCache getRepositoryCache() { - return repositories; - } -} diff --git a/webapp/src/com/google/gerrit/server/GoogleAccountDiscovery.java b/webapp/src/com/google/gerrit/server/GoogleAccountDiscovery.java deleted file mode 100644 index d39bc13972..0000000000 --- a/webapp/src/com/google/gerrit/server/GoogleAccountDiscovery.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.dyuproject.openid.Discovery; -import com.dyuproject.openid.OpenIdContext; -import com.dyuproject.openid.OpenIdUser; - -import java.util.HashMap; -import java.util.Map; - -/** Discovery support for Google Accounts and other standard OpenID providers */ -public class GoogleAccountDiscovery implements Discovery { - /** OpenID discovery end-point for Google Accounts */ - public static final String GOOGLE_ACCOUNT = - "https://www.google.com/accounts/o8/id"; - - private final Discovery base; - - public GoogleAccountDiscovery(final Discovery base) { - this.base = base; - } - - public OpenIdUser discover(final String claimedId, final OpenIdContext context) - throws Exception { - if (GOOGLE_ACCOUNT.equals(claimedId)) { - // TODO We shouldn't hard-code the XRDS discovery result. - // - final Map<String, String> m = new HashMap<String, String>(); - m.put("ci", claimedId); - m.put("os", "https://www.google.com/accounts/o8/ud"); - - final OpenIdUser u = new OpenIdUser(); - u.fromJSON(m); - return u; - } - - return base.discover(claimedId, context); - } -} diff --git a/webapp/src/com/google/gerrit/server/HostPageServlet.java b/webapp/src/com/google/gerrit/server/HostPageServlet.java deleted file mode 100644 index 16c2a1aa98..0000000000 --- a/webapp/src/com/google/gerrit/server/HostPageServlet.java +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gwt.user.server.rpc.RPCServletUtils; -import com.google.gwtjsonrpc.server.XsrfException; -import com.google.gwtorm.client.OrmException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.StringWriter; -import java.util.zip.GZIPOutputStream; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** Sends the Gerrit host page to clients. */ -public class HostPageServlet extends HttpServlet { - private static final long MAX_AGE = 5 * 60 * 1000L/* milliseconds */; - private static final String CACHE_CTRL = - "public, max-age=" + (MAX_AGE / 1000L); - - private String canonicalUrl; - private byte[] hostPageRaw; - private byte[] hostPageCompressed; - private long lastModified; - - @Override - public void init(final ServletConfig config) throws ServletException { - super.init(config); - - final GerritServer srv; - try { - srv = GerritServer.getInstance(); - } catch (OrmException e) { - throw new ServletException("Cannot load GerritServer", e); - } catch (XsrfException e) { - throw new ServletException("Cannot load GerritServer", e); - } - - final File sitePath = srv.getSitePath(); - canonicalUrl = srv.getCanonicalURL(); - - final String hostPageName = "com/google/gerrit/public/Gerrit.html"; - final Document hostDoc = HtmlDomUtil.parseFile(hostPageName); - if (hostDoc == null) { - throw new ServletException("No " + hostPageName + " in CLASSPATH"); - } - injectJson(hostDoc, "gerrit_gerritconfig", srv.getGerritConfig()); - injectCssFile(hostDoc, "gerrit_sitecss", sitePath, "GerritSite.css"); - injectXmlFile(hostDoc, "gerrit_header", sitePath, "GerritSiteHeader.html"); - injectXmlFile(hostDoc, "gerrit_footer", sitePath, "GerritSiteFooter.html"); - try { - hostPageRaw = HtmlDomUtil.toUTF8(hostDoc); - } catch (IOException e) { - throw new ServletException(e.getMessage(), e); - } - hostPageCompressed = compress(hostPageRaw); - lastModified = System.currentTimeMillis(); - } - - private void injectXmlFile(final Document hostDoc, final String id, - final File sitePath, final String fileName) throws ServletException { - final Element banner = HtmlDomUtil.find(hostDoc, id); - if (banner == null) { - return; - } - - while (banner.getFirstChild() != null) { - banner.removeChild(banner.getFirstChild()); - } - - final Document html = HtmlDomUtil.parseFile(sitePath, fileName); - if (html == null) { - banner.getParentNode().removeChild(banner); - return; - } - - final Element content = html.getDocumentElement(); - banner.appendChild(hostDoc.importNode(content, true)); - } - - private void injectCssFile(final Document hostDoc, final String id, - final File sitePath, final String fileName) throws ServletException { - final Element banner = HtmlDomUtil.find(hostDoc, id); - if (banner == null) { - return; - } - - while (banner.getFirstChild() != null) { - banner.removeChild(banner.getFirstChild()); - } - - final String css = HtmlDomUtil.readFile(sitePath, fileName); - if (css == null) { - banner.getParentNode().removeChild(banner); - return; - } - - banner.removeAttribute("id"); - banner.appendChild(hostDoc.createCDATASection("\n" + css + "\n")); - } - - private void injectJson(final Document hostDoc, final String id, - final Object obj) { - final Element scriptNode = HtmlDomUtil.find(hostDoc, id); - if (scriptNode == null) { - return; - } - - while (scriptNode.getFirstChild() != null) { - scriptNode.removeChild(scriptNode.getFirstChild()); - } - - if (obj == null) { - scriptNode.getParentNode().removeChild(scriptNode); - return; - } - - final StringWriter w = new StringWriter(); - w.write("<!--\n"); - w.write("var "); - w.write(id); - w.write("="); - GerritJsonServlet.defaultGsonBuilder().create().toJson(obj, w); - w.write(";\n// -->\n"); - scriptNode.removeAttribute("id"); - scriptNode.setAttribute("type", "text/javascript"); - scriptNode.setAttribute("language", "javascript"); - scriptNode.appendChild(hostDoc.createCDATASection(w.toString())); - } - - private byte[] compress(final byte[] raw) throws ServletException { - try { - final ByteArrayOutputStream out = new ByteArrayOutputStream(); - final GZIPOutputStream gz = new GZIPOutputStream(out); - gz.write(raw); - gz.finish(); - gz.flush(); - return out.toByteArray(); - } catch (IOException e) { - throw new ServletException("Cannot compress host page", e); - } - } - - @Override - protected long getLastModified(final HttpServletRequest req) { - return lastModified; - } - - @Override - protected void doGet(final HttpServletRequest req, - final HttpServletResponse rsp) throws IOException { - if (canonicalUrl != null - && !canonicalUrl.equals(LoginServlet.serverUrl(req))) { - rsp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); - rsp.setHeader("Location", canonicalUrl + "Gerrit"); - return; - } - - final byte[] tosend; - if (RPCServletUtils.acceptsGzipEncoding(req)) { - rsp.setHeader("Content-Encoding", "gzip"); - tosend = hostPageCompressed; - } else { - tosend = hostPageRaw; - } - - rsp.setHeader("Cache-Control", CACHE_CTRL); - rsp.setDateHeader("Expires", System.currentTimeMillis() + MAX_AGE); - rsp.setDateHeader("Last-Modified", lastModified); - rsp.setContentType("text/html"); - rsp.setCharacterEncoding(HtmlDomUtil.ENC); - rsp.setContentLength(tosend.length); - final OutputStream out = rsp.getOutputStream(); - try { - out.write(tosend); - } finally { - out.close(); - } - } -} diff --git a/webapp/src/com/google/gerrit/server/HtmlDomUtil.java b/webapp/src/com/google/gerrit/server/HtmlDomUtil.java deleted file mode 100644 index c59772ceae..0000000000 --- a/webapp/src/com/google/gerrit/server/HtmlDomUtil.java +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringWriter; - -import javax.servlet.ServletException; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -/** Utility functions to deal with HTML using W3C DOM operations. */ -public class HtmlDomUtil { - /** Standard character encoding we prefer (UTF-8). */ - public static final String ENC = "UTF-8"; - - /** DOCTYPE for a standards mode HTML document. */ - public static final String HTML_STRICT = - "-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd"; - - /** Convert a document to a UTF-8 byte sequence. */ - public static byte[] toUTF8(final Document hostDoc) throws IOException { - return toString(hostDoc).getBytes(ENC); - } - - /** Convert a document to a String, assuming later encoding to UTF-8. */ - public static String toString(final Document hostDoc) throws IOException { - try { - final StringWriter out = new StringWriter(); - final DOMSource domSource = new DOMSource(hostDoc); - final StreamResult streamResult = new StreamResult(out); - final TransformerFactory tf = TransformerFactory.newInstance(); - final Transformer serializer = tf.newTransformer(); - serializer.setOutputProperty(OutputKeys.ENCODING, ENC); - serializer.setOutputProperty(OutputKeys.METHOD, "html"); - serializer.setOutputProperty(OutputKeys.INDENT, "no"); - serializer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, - HtmlDomUtil.HTML_STRICT); - serializer.transform(domSource, streamResult); - return out.toString(); - } catch (TransformerConfigurationException e) { - final IOException r = new IOException("Error transforming page"); - r.initCause(e); - throw r; - } catch (TransformerException e) { - final IOException r = new IOException("Error transforming page"); - r.initCause(e); - throw r; - } - } - - /** Find an element by its "id" attribute; null if no element is found. */ - public static Element find(final Node parent, final String name) { - final NodeList list = parent.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - final Node n = list.item(i); - if (n instanceof Element) { - final Element e = (Element) n; - if (name.equals(e.getAttribute("id"))) { - return e; - } - } - final Element r = find(n, name); - if (r != null) { - return r; - } - } - return null; - } - - /** Append an HTML <input type="hidden"> to the form. */ - public static void addHidden(final Element form, final String name, - final String value) { - final Element in = form.getOwnerDocument().createElement("input"); - in.setAttribute("type", "hidden"); - in.setAttribute("name", name); - in.setAttribute("value", value); - form.appendChild(in); - } - - /** Clone a document so it can be safely modified on a per-request basis. */ - public static Document clone(final Document doc) throws IOException { - final Document d; - try { - d = newBuilder().newDocument(); - } catch (ParserConfigurationException e) { - throw new IOException("Cannot clone document"); - } - final Node n = d.importNode(doc.getDocumentElement(), true); - d.appendChild(n); - return d; - } - - /** Parse an XHTML file from our CLASSPATH and return the instance. */ - public static Document parseFile(final String name) throws ServletException { - final InputStream in; - - in = HtmlDomUtil.class.getClassLoader().getResourceAsStream(name); - if (in == null) { - return null; - } - try { - try { - try { - return newBuilder().parse(in); - } catch (SAXException e) { - throw new ServletException("Error reading " + name, e); - } catch (ParserConfigurationException e) { - throw new ServletException("Error reading " + name, e); - } - } finally { - in.close(); - } - } catch (IOException e) { - throw new ServletException("Error reading " + name, e); - } - } - - /** Parse an XHTML file from the local drive and return the instance. */ - public static Document parseFile(final File parentDir, final String name) - throws ServletException { - if (parentDir == null) { - return null; - } - final File path = new File(parentDir, name); - try { - final InputStream in = new FileInputStream(path); - try { - try { - return newBuilder().parse(in); - } catch (SAXException e) { - throw new ServletException("Error reading " + path, e); - } catch (ParserConfigurationException e) { - throw new ServletException("Error reading " + path, e); - } - } finally { - in.close(); - } - } catch (FileNotFoundException e) { - return null; - } catch (IOException e) { - throw new ServletException("Error reading " + path, e); - } - } - - /** Read a UTF-8 text file from the local drive. */ - public static String readFile(final File parentDir, final String name) - throws ServletException { - if (parentDir == null) { - return null; - } - final File path = new File(parentDir, name); - try { - final InputStream in = new FileInputStream(path); - try { - final StringBuilder w = new StringBuilder(); - final InputStreamReader r = new InputStreamReader(in, ENC); - final char[] buf = new char[512]; - int n; - while ((n = r.read(buf)) > 0) { - w.append(buf, 0, n); - } - return w.toString(); - } finally { - in.close(); - } - } catch (FileNotFoundException e) { - return null; - } catch (IOException e) { - throw new ServletException("Error reading " + path, e); - } - } - - private static DocumentBuilder newBuilder() - throws ParserConfigurationException { - final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(false); - factory.setExpandEntityReferences(false); - factory.setIgnoringComments(true); - final DocumentBuilder parser = factory.newDocumentBuilder(); - return parser; - } -} diff --git a/webapp/src/com/google/gerrit/server/LoginServlet.java b/webapp/src/com/google/gerrit/server/LoginServlet.java deleted file mode 100644 index 8e3e240209..0000000000 --- a/webapp/src/com/google/gerrit/server/LoginServlet.java +++ /dev/null @@ -1,495 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.client.Gerrit; -import com.google.gerrit.client.account.SignInResult; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.AccountExternalId; -import com.google.gerrit.client.reviewdb.AccountExternalIdAccess; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gwt.user.server.rpc.RPCServletUtils; -import com.google.gwtjsonrpc.server.JsonServlet; -import com.google.gwtjsonrpc.server.ValidToken; -import com.google.gwtjsonrpc.server.XsrfException; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.Transaction; - -import com.dyuproject.openid.Constants; -import com.dyuproject.openid.OpenIdContext; -import com.dyuproject.openid.OpenIdUser; -import com.dyuproject.openid.RelyingParty; - -import org.mortbay.util.UrlEncoded; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.StringWriter; -import java.util.Collections; -import java.util.List; -import java.util.Properties; -import java.util.zip.GZIPOutputStream; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** Handles the <code>/login</code> URL for web based single-sign-on. */ -public class LoginServlet extends HttpServlet { - private static final String CALLBACK_PARMETER = "callback"; - private static final String AX_SCHEMA = "http://openid.net/srv/ax/1.0"; - private static final String GMODE_CHKCOOKIE = "gerrit_chkcookie"; - private static final String GMODE_SETCOOKIE = "gerrit_setcookie"; - - private GerritServer server; - private String canonicalUrl; - private RelyingParty relyingParty; - private Document pleaseSetCookieDoc; - - @Override - public void init(final ServletConfig config) throws ServletException { - super.init(config); - - try { - server = GerritServer.getInstance(); - } catch (OrmException e) { - e.printStackTrace(); - throw new ServletException("Cannot configure GerritServer", e); - } catch (XsrfException e) { - e.printStackTrace(); - throw new ServletException("Cannot configure GerritServer", e); - } - - canonicalUrl = server.getCanonicalURL(); - String cookieKey = server.getAccountCookieKey(); - if (cookieKey.length() > 24) { - cookieKey = cookieKey.substring(0, 24); - } - - try { - final int sessionAge = server.getSessionAge(); - final Properties p = new Properties(); - p.setProperty("openid.cookie.name", Gerrit.OPENIDUSER_COOKIE); - p.setProperty("openid.cookie.security.secretKey", cookieKey); - p.setProperty("openid.cookie.maxAge", String.valueOf(sessionAge)); - - relyingParty = RelyingParty.newInstance(p); - - final OpenIdContext ctx = relyingParty.getOpenIdContext(); - ctx.setDiscovery(new GoogleAccountDiscovery(ctx.getDiscovery())); - } catch (IOException e) { - throw new ServletException("Cannot setup RelyingParty", e); - } - - final String scHtmlName = "com/google/gerrit/public/SetCookie.html"; - pleaseSetCookieDoc = HtmlDomUtil.parseFile(scHtmlName); - if (pleaseSetCookieDoc == null) { - throw new ServletException("No " + scHtmlName + " in CLASSPATH"); - } - } - - @Override - public void doGet(final HttpServletRequest req, final HttpServletResponse rsp) - throws IOException { - doPost(req, rsp); - } - - @Override - public void doPost(final HttpServletRequest req, final HttpServletResponse rsp) - throws IOException { - try { - doAuth(req, rsp); - } catch (Exception e) { - getServletContext().log("Unexpected error during authentication", e); - callback(req, rsp, SignInResult.CANCEL); - } - } - - private void doAuth(final HttpServletRequest req, - final HttpServletResponse rsp) throws Exception { - final String mode = req.getParameter(Constants.OPENID_MODE); - if ("cancel".equals(mode)) { - // Provider wants us to cancel the attempt. - // - callback(req, rsp, SignInResult.CANCEL); - return; - } else if (GMODE_CHKCOOKIE.equals(mode)) { - modeChkSetCookie(req, rsp, true); - return; - } else if (GMODE_SETCOOKIE.equals(mode)) { - modeChkSetCookie(req, rsp, false); - return; - } - - final OpenIdUser user = relyingParty.discover(req); - if (user == null) { - // User isn't known, no provider is known. - // - redirectChooseProvider(req, rsp); - return; - } - - if (user.isAuthenticated()) { - // User already authenticated. - // - initializeAccount(req, rsp, user, null); - return; - } - - if (user.isAssociated() && RelyingParty.isAuthResponse(req)) { - if (!relyingParty.verifyAuth(user, req, rsp)) { - // Failed verification... re-authenticate. - // - redirectChooseProvider(req, rsp); - return; - } - - // Authentication was successful. - // - String email = null; - for (int i = 1;; i++) { - final String nskey = "openid.ns.ext" + i; - final String nsval = req.getParameter(nskey); - if (nsval == null) { - break; - } - - final String ext = "openid.ext" + i + "."; - if (AX_SCHEMA.equals(nsval) - && "fetch_response".equals(req.getParameter(ext + "mode"))) { - email = req.getParameter(ext + "value.email"); - } - } - - initializeAccount(req, rsp, user, email); - return; - } - - if (!relyingParty.associate(user, req, rsp)) { - // Failed association. Try again. - // - redirectChooseProvider(req, rsp); - return; - } - - // Authenticate user through his/her OpenID provider - // - final String realm = serverUrl(req); - final StringBuilder retTo = new StringBuilder(req.getRequestURL()); - append(retTo, CALLBACK_PARMETER, req.getParameter(CALLBACK_PARMETER)); - final StringBuilder auth; - - auth = RelyingParty.getAuthUrlBuffer(user, realm, realm, retTo.toString()); - append(auth, "openid.ns.ext1", AX_SCHEMA); - final String ext1 = "openid.ext1."; - append(auth, ext1 + "mode", "fetch_request"); - append(auth, ext1 + "type.email", "http://schema.openid.net/contact/email"); - append(auth, ext1 + "required", "email"); - rsp.sendRedirect(auth.toString()); - } - - private void redirectChooseProvider(final HttpServletRequest req, - final HttpServletResponse rsp) throws IOException { - if (canonicalUrl != null && !canonicalUrl.equals(serverUrl(req))) { - rsp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); - rsp.setHeader("Location", canonicalUrl + "login"); - return; - } - - // Hard-code to use the Google Account service. - // - final StringBuilder url = new StringBuilder(req.getRequestURL()); - append(url, CALLBACK_PARMETER, req.getParameter(CALLBACK_PARMETER)); - append(url, RelyingParty.DEFAULT_PARAMETER, - GoogleAccountDiscovery.GOOGLE_ACCOUNT); - rsp.sendRedirect(url.toString()); - } - - private void initializeAccount(final HttpServletRequest req, - final HttpServletResponse rsp, final OpenIdUser user, final String email) - throws IOException { - Account account = null; - if (user != null) { - try { - final ReviewDb d = server.getDatabase().open(); - try { - final AccountExternalIdAccess extAccess = d.accountExternalIds(); - AccountExternalId acctExt = lookup(extAccess, user.getIdentity()); - - if (acctExt == null && email != null && isGoogleAccount(user)) { - acctExt = lookup(extAccess, "GoogleAccount/" + email); - if (acctExt != null) { - // Legacy user from Gerrit 1? Attach the OpenID identity. - // - final AccountExternalId openidExt = - new AccountExternalId(new AccountExternalId.Key(acctExt - .getAccountId(), user.getIdentity())); - extAccess.insert(Collections.singleton(openidExt)); - acctExt = openidExt; - } - } - - if (acctExt != null) { - account = d.accounts().byId(acctExt.getAccountId()); - } else { - account = null; - } - - if (account != null) { - // Existing user; double check the email is current. - // - if (email != null && !email.equals(account.getPreferredEmail())) { - account.setPreferredEmail(email); - d.accounts().update(Collections.singleton(account)); - } - } else { - // New user; create an account entity for them. - // - final Transaction txn = d.beginTransaction(); - - account = new Account(new Account.Id(d.nextAccountId())); - account.setPreferredEmail(email); - - acctExt = - new AccountExternalId(new AccountExternalId.Key( - account.getId(), user.getIdentity())); - - d.accounts().insert(Collections.singleton(account), txn); - extAccess.insert(Collections.singleton(acctExt), txn); - txn.commit(); - } - } finally { - d.close(); - } - } catch (OrmException e) { - getServletContext().log("Account lookup failed", e); - account = null; - } - } - - rsp.reset(); - - Cookie c; - c = new Cookie(Gerrit.OPENIDUSER_COOKIE, ""); - c.setMaxAge(0); - rsp.addCookie(c); - - String tok; - try { - final String idstr = String.valueOf(account.getId().get()); - tok = server.getAccountToken().newToken(idstr); - } catch (XsrfException e) { - getServletContext().log("Account cookie signature impossible", e); - account = null; - tok = ""; - } - - c = new Cookie(Gerrit.ACCOUNT_COOKIE, tok); - c.setPath(req.getContextPath() + "/"); - - if (account == null) { - c.setMaxAge(0); - rsp.addCookie(c); - callback(req, rsp, SignInResult.CANCEL); - } else { - c.setMaxAge(server.getSessionAge()); - rsp.addCookie(c); - - final StringBuilder me = new StringBuilder(req.getRequestURL()); - append(me, Constants.OPENID_MODE, GMODE_CHKCOOKIE); - append(me, CALLBACK_PARMETER, req.getParameter(CALLBACK_PARMETER)); - append(me, Gerrit.ACCOUNT_COOKIE, tok); - rsp.sendRedirect(me.toString()); - } - } - - private static AccountExternalId lookup( - final AccountExternalIdAccess extAccess, final String id) - throws OrmException { - final List<AccountExternalId> extRes = extAccess.byExternal(id).toList(); - switch (extRes.size()) { - case 0: - return null; - case 1: - return extRes.get(0); - default: - throw new OrmException("More than one account matches: " + id); - } - } - - private static boolean isGoogleAccount(final OpenIdUser user) { - return user.getIdentity().startsWith(GoogleAccountDiscovery.GOOGLE_ACCOUNT); - } - - private void modeChkSetCookie(final HttpServletRequest req, - final HttpServletResponse rsp, final boolean isCheck) throws IOException { - final String exp = req.getParameter(Gerrit.ACCOUNT_COOKIE); - final ValidToken chk; - try { - chk = server.getAccountToken().checkToken(exp, null); - } catch (XsrfException e) { - getServletContext().log("Cannot validate cookie token", e); - redirectChooseProvider(req, rsp); - return; - } - - final Account.Id id; - try { - id = new Account.Id(Integer.parseInt(chk.getData())); - } catch (NumberFormatException e) { - redirectChooseProvider(req, rsp); - return; - } - - Account account; - try { - final ReviewDb db = server.getDatabase().open(); - try { - account = db.accounts().byId(id); - } finally { - db.close(); - } - } catch (OrmException e) { - getServletContext().log("Account lookup failed for " + id, e); - account = null; - } - if (account == null) { - redirectChooseProvider(req, rsp); - return; - } - - final String act = getCookie(req, Gerrit.ACCOUNT_COOKIE); - if (isCheck && !exp.equals(act)) { - // Cookie won't set without "user interaction" (thanks Safari). Lets - // send an HTML page to the browser and ask the user to click to let - // us set the cookie. - // - sendSetCookieHtml(req, rsp, exp); - return; - } - - final Cookie c = new Cookie(Gerrit.ACCOUNT_COOKIE, exp); - c.setPath(req.getContextPath() + "/"); - c.setMaxAge(server.getSessionAge()); - rsp.addCookie(c); - callback(req, rsp, new SignInResult(SignInResult.Status.SUCCESS, account)); - } - - private void sendSetCookieHtml(final HttpServletRequest req, - final HttpServletResponse rsp, final String exp) throws IOException { - final Document doc = HtmlDomUtil.clone(pleaseSetCookieDoc); - final Element set_form = HtmlDomUtil.find(doc, "set_form"); - set_form.setAttribute("action", req.getRequestURL().toString()); - HtmlDomUtil.addHidden(set_form, Constants.OPENID_MODE, GMODE_SETCOOKIE); - HtmlDomUtil.addHidden(set_form, Gerrit.ACCOUNT_COOKIE, exp); - HtmlDomUtil.addHidden(set_form, CALLBACK_PARMETER, req - .getParameter(CALLBACK_PARMETER)); - sendHtml(req, rsp, HtmlDomUtil.toString(doc)); - } - - private static String getCookie(final HttpServletRequest req, - final String name) { - final Cookie[] allCookies = req.getCookies(); - if (allCookies != null) { - for (final Cookie c : allCookies) { - if (name.equals(c.getName())) { - return c.getValue(); - } - } - } - return null; - } - - private void callback(final HttpServletRequest req, - final HttpServletResponse rsp, final SignInResult result) - throws IOException { - final String cb = req.getParameter(CALLBACK_PARMETER); - final StringWriter body = new StringWriter(); - body.write("<html>"); - if (JsonServlet.SAFE_CALLBACK.matcher(cb).matches()) { - body.write("<script><!--\n"); - body.write(cb); - body.write("("); - JsonServlet.defaultGsonBuilder().create().toJson(result, body); - body.write(");\n"); - body.write("// -->\n"); - body.write("</script>"); - } else { - body.append("<body>"); - body.append("Unsafe JSON callback requested; refusing to execute it."); - body.append("</body>"); - } - body.write("</html>"); - sendHtml(req, rsp, body.toString()); - } - - private void sendHtml(final HttpServletRequest req, - final HttpServletResponse rsp, final String bodystr) throws IOException { - final byte[] raw = bodystr.getBytes(HtmlDomUtil.ENC); - final byte[] tosend; - if (RPCServletUtils.acceptsGzipEncoding(req)) { - rsp.setHeader("Content-Encoding", "gzip"); - final ByteArrayOutputStream compressed = new ByteArrayOutputStream(); - final GZIPOutputStream gz = new GZIPOutputStream(compressed); - gz.write(raw); - gz.finish(); - gz.flush(); - tosend = compressed.toByteArray(); - } else { - tosend = raw; - } - - rsp.setCharacterEncoding(HtmlDomUtil.ENC); - rsp.setContentType("text/html"); - rsp.setHeader("Expires", "Fri, 01 Jan 1980 00:00:00 GMT"); - rsp.setHeader("Pragma", "no-cache"); - rsp.setHeader("Cache-Control", "no-cache, must-revalidate"); - rsp.setContentLength(tosend.length); - final OutputStream out = rsp.getOutputStream(); - try { - out.write(tosend); - } finally { - out.close(); - } - } - - static String serverUrl(final HttpServletRequest req) { - // Assume this servlet is in the context with a simple name like "login" - // and we were accessed without any path info. Clipping the last part of - // the name from the URL should generate the web application's root path. - // - final String uri = req.getRequestURL().toString(); - final int s = uri.lastIndexOf('/'); - return s >= 0 ? uri.substring(0, s + 1) : uri; - } - - private static void append(final StringBuilder buffer, final String name, - final String value) { - if (buffer.indexOf("?") >= 0) { - buffer.append('&'); - } else { - buffer.append('?'); - } - buffer.append(name); - buffer.append('='); - buffer.append(UrlEncoded.encodeString(value)); - } -} diff --git a/webapp/src/com/google/gerrit/server/PatchDetailServiceSrv.java b/webapp/src/com/google/gerrit/server/PatchDetailServiceSrv.java deleted file mode 100644 index 3f08a0663c..0000000000 --- a/webapp/src/com/google/gerrit/server/PatchDetailServiceSrv.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.server.patch.PatchDetailServiceImpl; - -/** Publishes {@link PatchDetailServiceImpl} over JSON. */ -public class PatchDetailServiceSrv extends GerritJsonServlet { - @Override - protected Object createServiceHandle() throws Exception { - return new PatchDetailServiceImpl(GerritServer.getInstance()); - } -} diff --git a/webapp/src/com/google/gerrit/server/SystemInfoServiceImpl.java b/webapp/src/com/google/gerrit/server/SystemInfoServiceImpl.java deleted file mode 100644 index 95cd763a8b..0000000000 --- a/webapp/src/com/google/gerrit/server/SystemInfoServiceImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.client.data.GerritConfig; -import com.google.gerrit.client.data.SystemInfoService; -import com.google.gwt.user.client.rpc.AsyncCallback; - -public class SystemInfoServiceImpl implements SystemInfoService { - private final GerritServer server; - - public SystemInfoServiceImpl(final GerritServer server) { - this.server = server; - } - - public void loadGerritConfig(final AsyncCallback<GerritConfig> callback) { - callback.onSuccess(server.getGerritConfig()); - } -} diff --git a/webapp/src/com/google/gerrit/server/SystemInfoServiceSrv.java b/webapp/src/com/google/gerrit/server/SystemInfoServiceSrv.java deleted file mode 100644 index 2efbc8c193..0000000000 --- a/webapp/src/com/google/gerrit/server/SystemInfoServiceSrv.java +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - - -/** Publishes {@link SystemInfoServiceImpl} over JSON. */ -public class SystemInfoServiceSrv extends GerritJsonServlet { - @Override - protected Object createServiceHandle() throws Exception { - return new SystemInfoServiceImpl(GerritServer.getInstance()); - } -} diff --git a/webapp/src/com/google/gerrit/server/UrlRewriteFilter.java b/webapp/src/com/google/gerrit/server/UrlRewriteFilter.java deleted file mode 100644 index 7cd6e352c9..0000000000 --- a/webapp/src/com/google/gerrit/server/UrlRewriteFilter.java +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server; - -import com.google.gerrit.client.Link; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.reviewdb.PatchSet; -import com.google.gerrit.client.reviewdb.RevId; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gwtjsonrpc.server.XsrfException; -import com.google.gwtorm.client.OrmException; - -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** Rewrites Gerrit 1 style URLs to Gerrit 2 style URLs. */ -public class UrlRewriteFilter implements Filter { - private static final Pattern CHANGE_ID = Pattern.compile("^/(\\d+)/?$"); - private static final Pattern REV_ID = - Pattern.compile("^/r/([0-9a-fA-F]{4," + RevId.LEN + "})/?$"); - private static final Pattern USER_PAGE = Pattern.compile("^/user/(.*)/?$"); - private static final Map<String, String> staticLinks; - private static final Set<String> staticExtensions; - - static { - staticLinks = new HashMap<String, String>(); - staticLinks.put("", ""); - staticLinks.put("/", ""); - - staticLinks.put("/mine", Link.MINE); - staticLinks.put("/unclaimed", Link.MINE_UNCLAIMED); - staticLinks.put("/starred", Link.MINE_STARRED); - - staticLinks.put("/all", Link.ALL); - staticLinks.put("/all_unclaimed", Link.ALL_UNCLAIMED); - staticLinks.put("/open", Link.ALL_OPEN); - - staticExtensions = new HashSet<String>(); - staticExtensions.add(".css"); - staticExtensions.add(".gif"); - staticExtensions.add(".html"); - staticExtensions.add(".js"); - staticExtensions.add(".png"); - } - - private FilterConfig config; - private GerritServer server; - - public void init(final FilterConfig config) throws ServletException { - this.config = config; - try { - server = GerritServer.getInstance(); - } catch (OrmException e) { - throw new ServletException("Cannot initialize GerritServer", e); - } catch (XsrfException e) { - throw new ServletException("Cannot initialize GerritServer", e); - } - } - - public void destroy() { - } - - public void doFilter(final ServletRequest sreq, final ServletResponse srsp, - final FilterChain chain) throws IOException, ServletException { - final HttpServletRequest req = (HttpServletRequest) sreq; - final HttpServletResponse rsp = (HttpServletResponse) srsp; - final String pathInfo = pathInfo(req); - - if (pathInfo.startsWith("/rpc/")) { - // RPC requests are very common in Gerrit 2, we want to make sure - // they run quickly by jumping through the chain as fast as we can. - // - chain.doFilter(req, rsp); - } else if (staticExtension(pathInfo, req, rsp, chain)) { - } else if (staticLink(pathInfo, req, rsp)) { - } else if (bareChangeId(pathInfo, req, rsp)) { - } else if (bareRevisionId(pathInfo, req, rsp)) { - } else if (bareUserEmailDashboard(pathInfo, req, rsp)) { - } else { - // Anything else is either a static resource request (which the container - // can do for us) or is going to be a 404 error when the container cannot - // find the resource. Either form of request is not very common compared - // to the above cases. - // - chain.doFilter(req, rsp); - } - } - - private static boolean staticExtension(final String pathInfo, - final HttpServletRequest req, final HttpServletResponse rsp, - final FilterChain chain) throws IOException, ServletException { - final int d = pathInfo.lastIndexOf('.'); - if (d > 0 && staticExtensions.contains(pathInfo.substring(d + 1))) { - // Any URL which ends in this static extension is meant to be handled - // by the servlet container, by returning a resource from the WAR. - // We don't need to evaluate it any further. - // - chain.doFilter(req, rsp); - return true; - } - return false; - } - - private static boolean staticLink(final String pathInfo, - final HttpServletRequest req, final HttpServletResponse rsp) - throws IOException { - final String newLink = staticLinks.get(pathInfo); - if (newLink == null) { - return false; - } - - // A static link (one with no parameters). - // - final StringBuffer url = toGerrit(req); - if (newLink.length() > 0) { - url.append('#'); - url.append(newLink); - } - rsp.sendRedirect(url.toString()); - return true; - } - - private static boolean bareChangeId(final String pathInfo, - final HttpServletRequest req, final HttpServletResponse rsp) - throws IOException { - final Matcher m = CHANGE_ID.matcher(pathInfo); - if (!m.matches()) { - return false; - } - - final Change.Id id = Change.Id.fromString(m.group(1)); - final StringBuffer url = toGerrit(req); - url.append('#'); - url.append(Link.toChange(id)); - rsp.sendRedirect(url.toString()); - return true; - } - - private boolean bareRevisionId(final String pathInfo, - final HttpServletRequest req, final HttpServletResponse rsp) - throws IOException { - final Matcher m = REV_ID.matcher(pathInfo); - if (!m.matches()) { - return false; - } - - final String rev = m.group(1).toLowerCase(); - if (rev.length() > RevId.LEN) { - rsp.sendError(HttpServletResponse.SC_NOT_FOUND); - return true; - } - - final RevId id = new RevId(rev); - final List<PatchSet> patches; - try { - final ReviewDb db = server.getDatabase().open(); - try { - if (id.isComplete()) { - patches = db.patchSets().byRevision(id).toList(); - } else { - patches = db.patchSets().byRevisionRange(id, id.max()).toList(); - } - } finally { - db.close(); - } - } catch (OrmException e) { - config.getServletContext().log("Unable to query for " + rev, e); - rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - return true; - } - - if (patches.size() == 0) { - rsp.sendError(HttpServletResponse.SC_NOT_FOUND); - } else if (patches.size() == 1) { - final StringBuffer url = toGerrit(req); - url.append('#'); - url.append(Link.toChange(patches.get(0).getKey().getParentKey())); - rsp.sendRedirect(url.toString()); - } else { - // TODO Someday this should be a menu of choices. - rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } - return true; - } - - private boolean bareUserEmailDashboard(final String pathInfo, - final HttpServletRequest req, final HttpServletResponse rsp) - throws IOException { - final Matcher m = USER_PAGE.matcher(pathInfo); - if (!m.matches()) { - return false; - } - - final String email = cleanEmail(m.group(1)); - final List<Account> people; - try { - final ReviewDb db = server.getDatabase().open(); - try { - people = db.accounts().byPreferredEmail(email).toList(); - } finally { - db.close(); - } - } catch (OrmException e) { - config.getServletContext().log("Unable to query for " + email, e); - rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - return true; - } - - if (people.size() == 0) { - rsp.sendError(HttpServletResponse.SC_NOT_FOUND); - } else if (people.size() == 1) { - final StringBuffer url = toGerrit(req); - url.append('#'); - url.append(Link.toAccountDashboard(people.get(0).getId())); - rsp.sendRedirect(url.toString()); - } else { - // TODO Someday this should be a menu of choices. - rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } - return true; - } - - private static String cleanEmail(final String email) { - int dc = email.indexOf(",,"); - if (dc >= 0) { - return email.substring(0, dc) + "@" + email.substring(dc + 2); - } - - dc = email.indexOf(','); - if (dc >= 0) { - return email.substring(0, dc) + "@" + email.substring(dc + 1); - } - return email; - } - - private static String pathInfo(final HttpServletRequest req) { - final String uri = req.getRequestURI(); - final String ctx = req.getContextPath(); - return uri.startsWith(ctx) ? uri.substring(ctx.length()) : uri; - } - - private static StringBuffer toGerrit(final HttpServletRequest req) { - final StringBuffer url = new StringBuffer(); - url.append(req.getContextPath()); - url.append("/Gerrit"); - return url; - } -} diff --git a/webapp/src/com/google/gerrit/server/patch/PatchDetailAction.java b/webapp/src/com/google/gerrit/server/patch/PatchDetailAction.java deleted file mode 100644 index 5f1517cbf3..0000000000 --- a/webapp/src/com/google/gerrit/server/patch/PatchDetailAction.java +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server.patch; - -import com.google.gerrit.client.data.AccountInfoCacheFactory; -import com.google.gerrit.client.data.LineWithComments; -import com.google.gerrit.client.reviewdb.Account; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.reviewdb.PatchContent; -import com.google.gerrit.client.reviewdb.PatchLineComment; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gerrit.client.rpc.CorruptEntityException; -import com.google.gerrit.client.rpc.NoSuchEntityException; -import com.google.gerrit.client.rpc.RpcUtil; -import com.google.gerrit.client.rpc.BaseServiceImplementation.Action; -import com.google.gerrit.client.rpc.BaseServiceImplementation.Failure; -import com.google.gwtorm.client.OrmException; -import com.google.gwtorm.client.ResultSet; - -import org.spearce.jgit.errors.IncorrectObjectTypeException; -import org.spearce.jgit.lib.AnyObjectId; -import org.spearce.jgit.lib.Constants; -import org.spearce.jgit.lib.ObjectId; -import org.spearce.jgit.lib.ObjectLoader; -import org.spearce.jgit.lib.Repository; -import org.spearce.jgit.patch.CombinedFileHeader; -import org.spearce.jgit.patch.FileHeader; -import org.spearce.jgit.patch.FormatError; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - - -abstract class PatchDetailAction<T> implements Action<T> { - protected static final byte[] EMPTY_FILE = {}; - - protected final Patch.Id key; - protected Patch patch; - protected FileHeader file; - protected int fileCnt; - protected AccountInfoCacheFactory accountInfo; - protected Account.Id me; - - protected HashMap<Integer, List<PatchLineComment>> published[]; - protected HashMap<Integer, List<PatchLineComment>> drafted[]; - - PatchDetailAction(final Patch.Id key) { - this.key = key; - } - - protected void init(final ReviewDb db) throws OrmException, Failure { - patch = db.patches().get(key); - if (patch == null) { - throw new Failure(new NoSuchEntityException()); - } - - file = parse(patch, read(db, patch)); - if (file instanceof CombinedFileHeader) { - fileCnt = ((CombinedFileHeader) file).getParentCount() + 1; - } else { - fileCnt = 2; - } - - accountInfo = new AccountInfoCacheFactory(db); - me = RpcUtil.getAccountId(); - - published = new HashMap[fileCnt]; - for (int n = 0; n < fileCnt; n++) { - published[n] = new HashMap<Integer, List<PatchLineComment>>(); - } - indexComments(published, db.patchComments().published(key)); - - if (me != null) { - drafted = new HashMap[fileCnt]; - for (int n = 0; n < fileCnt; n++) { - drafted[n] = new HashMap<Integer, List<PatchLineComment>>(); - } - indexComments(drafted, db.patchComments().draft(key, me)); - } - } - - protected static void indexComments( - final HashMap<Integer, List<PatchLineComment>>[] out, - final ResultSet<PatchLineComment> comments) { - for (final PatchLineComment c : comments) { - if (0 <= c.getSide() && c.getSide() < out.length) { - final HashMap<Integer, List<PatchLineComment>> m = out[c.getSide()]; - List<PatchLineComment> l = m.get(c.getLine()); - if (l == null) { - l = new ArrayList<PatchLineComment>(4); - m.put(c.getLine(), l); - } - l.add(c); - } - } - } - - protected void addComments(final LineWithComments pLine, - final HashMap<Integer, List<PatchLineComment>>[] cache, final int side, - final int line) { - List<PatchLineComment> l = cache[side].get(line); - if (l != null) { - for (final PatchLineComment c : l) { - pLine.addComment(c); - accountInfo.want(c.getAuthor()); - } - } - } - - protected byte[] read(final Repository repo, final AnyObjectId id) - throws Failure { - if (id == null || ObjectId.zeroId().equals(id)) { - return EMPTY_FILE; - } - try { - final ObjectLoader ldr = repo.openObject(id); - if (ldr == null) { - throw new Failure(new CorruptEntityException(patch.getKey())); - } - final byte[] content = ldr.getCachedBytes(); - if (ldr.getType() != Constants.OBJ_BLOB) { - throw new Failure(new IncorrectObjectTypeException(id.toObjectId(), - Constants.TYPE_BLOB)); - } - return content; - } catch (IOException err) { - throw new Failure(err); - } - } - - protected static String read(final ReviewDb db, final Patch patch) - throws Failure, OrmException { - final PatchContent.Key key = patch.getContent(); - if (key == null) { - throw new Failure(new CorruptEntityException(patch.getKey())); - } - - final PatchContent pc = db.patchContents().get(key); - if (pc == null || pc.getContent() == null) { - throw new Failure(new CorruptEntityException(patch.getKey())); - } - - return pc.getContent(); - } - - protected static FileHeader parse(final Patch patch, final String content) - throws Failure { - final byte[] buf = Constants.encode(content); - final org.spearce.jgit.patch.Patch p = new org.spearce.jgit.patch.Patch(); - p.parse(buf, 0, buf.length); - for (final FormatError err : p.getErrors()) { - if (err.getSeverity() == FormatError.Severity.ERROR) { - throw new Failure(new CorruptEntityException(patch.getKey())); - } - } - if (p.getFiles().size() != 1) { - throw new Failure(new CorruptEntityException(patch.getKey())); - } - return p.getFiles().get(0); - } -} diff --git a/webapp/src/com/google/gerrit/server/patch/PatchDetailServiceImpl.java b/webapp/src/com/google/gerrit/server/patch/PatchDetailServiceImpl.java deleted file mode 100644 index 25e86f1c61..0000000000 --- a/webapp/src/com/google/gerrit/server/patch/PatchDetailServiceImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server.patch; - -import com.google.gerrit.client.data.SideBySidePatchDetail; -import com.google.gerrit.client.data.UnifiedPatchDetail; -import com.google.gerrit.client.patches.PatchDetailService; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.rpc.BaseServiceImplementation; -import com.google.gerrit.git.RepositoryCache; -import com.google.gerrit.server.GerritServer; -import com.google.gwt.user.client.rpc.AsyncCallback; - -public class PatchDetailServiceImpl extends BaseServiceImplementation implements - PatchDetailService { - private final GerritServer server; - - public PatchDetailServiceImpl(final GerritServer gs) { - super(gs.getDatabase()); - server = gs; - } - - public void sideBySidePatchDetail(final Patch.Id key, - final AsyncCallback<SideBySidePatchDetail> callback) { - final RepositoryCache rc = server.getRepositoryCache(); - if (rc == null) { - callback.onFailure(new Exception("No Repository Cache configured")); - return; - } - run(callback, new SideBySidePatchDetailAction(rc, key)); - } - - public void unifiedPatchDetail(final Patch.Id key, - final AsyncCallback<UnifiedPatchDetail> callback) { - run(callback, new UnifiedPatchDetailAction(key)); - } -} diff --git a/webapp/src/com/google/gerrit/server/patch/SideBySidePatchDetailAction.java b/webapp/src/com/google/gerrit/server/patch/SideBySidePatchDetailAction.java deleted file mode 100644 index 246979c218..0000000000 --- a/webapp/src/com/google/gerrit/server/patch/SideBySidePatchDetailAction.java +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server.patch; - -import static org.spearce.jgit.util.RawParseUtils.decode; -import static org.spearce.jgit.util.RawParseUtils.nextLF; - -import com.google.gerrit.client.data.SideBySideLine; -import com.google.gerrit.client.data.SideBySidePatchDetail; -import com.google.gerrit.client.reviewdb.Change; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gerrit.client.rpc.CorruptEntityException; -import com.google.gerrit.client.rpc.BaseServiceImplementation.Failure; -import com.google.gerrit.git.InvalidRepositoryException; -import com.google.gerrit.git.RepositoryCache; -import com.google.gwtorm.client.OrmException; - -import org.spearce.jgit.lib.AbbreviatedObjectId; -import org.spearce.jgit.lib.Constants; -import org.spearce.jgit.lib.Repository; -import org.spearce.jgit.patch.CombinedFileHeader; -import org.spearce.jgit.patch.CombinedHunkHeader; -import org.spearce.jgit.patch.HunkHeader; -import org.spearce.jgit.util.IntList; -import org.spearce.jgit.util.RawParseUtils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -class SideBySidePatchDetailAction extends - PatchDetailAction<SideBySidePatchDetail> { - private final RepositoryCache repoCache; - private int fileCount; - private byte[][] fileContents; - private IntList[] lineIndex; - - SideBySidePatchDetailAction(final RepositoryCache rc, final Patch.Id key) { - super(key); - repoCache = rc; - } - - public SideBySidePatchDetail run(final ReviewDb db) throws OrmException, - Failure { - init(db); - - if (file.getHunks().isEmpty()) { - throw new Failure(new CorruptEntityException(key)); - } - - openContents(db); - - final ArrayList<List<SideBySideLine>> lines = - new ArrayList<List<SideBySideLine>>(); - if (file instanceof CombinedFileHeader) { - for (final CombinedHunkHeader h : ((CombinedFileHeader) file).getHunks()) { - } - - } else { - for (final HunkHeader h : file.getHunks()) { - int oldLine = h.getOldImage().getStartLine(); - int newLine = h.getNewStartLine(); - - final byte[] buf = h.getBuffer(); - final int hunkEnd = h.getEndOffset(); - int ptr = h.getStartOffset(); - int eol = nextLF(buf, ptr); - SCAN: for (ptr = eol; ptr < hunkEnd; ptr = eol) { - eol = nextLF(buf, ptr); - - final SideBySideLine o, n; - switch (buf[ptr]) { - case ' ': - case '\n': { - final String text = decode(Constants.CHARSET, buf, ptr + 1, eol); - - o = new SideBySideLine(oldLine, SideBySideLine.Type.EQUAL, text); - n = new SideBySideLine(newLine, SideBySideLine.Type.EQUAL, text); - oldLine++; - newLine++; - break; - } - case '-': { - final String text = decode(Constants.CHARSET, buf, ptr + 1, eol); - o = new SideBySideLine(oldLine, SideBySideLine.Type.DELETE, text); - n = null; - oldLine++; - break; - } - case '+': { - final String text = decode(Constants.CHARSET, buf, ptr + 1, eol); - o = null; - n = new SideBySideLine(newLine, SideBySideLine.Type.INSERT, text); - newLine++; - - // Attempt to insert this line backwards where it matches as a - // replacement for a prior deletion. Typically the delete is - // presented first in the patch, then the addition, so we only - // need to backtrack here. - // - int p = lines.size(); - while (0 < p && lines.get(p - 1).get(1) == null) { - p--; - } - if (0 < p && p < lines.size() && lines.get(p).get(1) == null) { - lines.get(p).set(1, n); - continue; - } - break; - } - case '\\': - continue; - default: - break SCAN; - } - lines.add(Arrays.asList(new SideBySideLine[] {o, n})); - } - } - } - - for (final List<SideBySideLine> p : lines) { - for (int i = 0; i < fileCount; i++) { - final SideBySideLine line = p.get(i); - if (line != null) { - addComments(line, published, i, line.getLineNumber()); - if (drafted != null) { - addComments(line, drafted, i, line.getLineNumber()); - } - } - } - } - - int maxLine = 0; - for (int i = 0; i < fileCount; i++) { - maxLine = Math.max(maxLine, lineIndex[i].size()); - } - - final SideBySidePatchDetail d; - d = new SideBySidePatchDetail(patch, accountInfo.create()); - d.setLines(fileCount, maxLine, lines); - return d; - } - - private void openContents(final ReviewDb db) throws Failure, OrmException { - final Change.Id changeId = key.getParentKey().getParentKey(); - final Change change = db.changes().get(changeId); - if (change == null || change.getDest() == null) { - throw new Failure(new CorruptEntityException(changeId)); - } - - final Repository repo; - try { - repo = repoCache.get(change.getDest().getParentKey().get()); - } catch (InvalidRepositoryException err) { - throw new Failure(err); - } - - if (file instanceof CombinedFileHeader) { - final CombinedFileHeader ch = (CombinedFileHeader) file; - - fileCount = ch.getParentCount() + 1; - fileContents = new byte[fileCount][]; - for (int i = 0; i < ch.getParentCount(); i++) { - final AbbreviatedObjectId old = ch.getOldId(i); - if (old == null || !old.isComplete()) { - throw new Failure(new CorruptEntityException(key)); - } - fileContents[i] = read(repo, old.toObjectId()); - } - - } else { - if (file.getOldId() == null || !file.getOldId().isComplete()) { - throw new Failure(new CorruptEntityException(key)); - } - - fileCount = 2; - fileContents = new byte[fileCount][]; - fileContents[0] = read(repo, file.getOldId().toObjectId()); - } - - if (file.getNewId() == null || !file.getNewId().isComplete()) { - throw new Failure(new CorruptEntityException(key)); - } - fileContents[fileCount - 1] = read(repo, file.getNewId().toObjectId()); - - lineIndex = new IntList[fileCount]; - for (int i = 0; i < fileCount; i++) { - final byte[] c = fileContents[i]; - lineIndex[i] = RawParseUtils.lineMap(c, 0, c.length); - } - } -} diff --git a/webapp/src/com/google/gerrit/server/patch/UnifiedPatchDetailAction.java b/webapp/src/com/google/gerrit/server/patch/UnifiedPatchDetailAction.java deleted file mode 100644 index b952a8d1d5..0000000000 --- a/webapp/src/com/google/gerrit/server/patch/UnifiedPatchDetailAction.java +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.gerrit.server.patch; - -import static org.spearce.jgit.util.RawParseUtils.decode; -import static org.spearce.jgit.util.RawParseUtils.nextLF; - -import com.google.gerrit.client.data.PatchLine; -import com.google.gerrit.client.data.UnifiedPatchDetail; -import com.google.gerrit.client.data.PatchLine.Type; -import com.google.gerrit.client.reviewdb.Patch; -import com.google.gerrit.client.reviewdb.ReviewDb; -import com.google.gerrit.client.rpc.BaseServiceImplementation.Failure; -import com.google.gwtorm.client.OrmException; - -import org.spearce.jgit.lib.Constants; -import org.spearce.jgit.patch.HunkHeader; - -import java.util.ArrayList; - -class UnifiedPatchDetailAction extends PatchDetailAction<UnifiedPatchDetail> { - UnifiedPatchDetailAction(final Patch.Id key) { - super(key); - } - - public UnifiedPatchDetail run(final ReviewDb db) throws OrmException, Failure { - init(db); - - final byte[] buf = file.getBuffer(); - int ptr = file.getStartOffset(); - final int end = file.getEndOffset(); - final int hdrEnd; - final ArrayList<PatchLine> lines = new ArrayList<PatchLine>(); - - if (file.getHunks().size() > 0) { - hdrEnd = file.getHunks().get(0).getStartOffset(); - } else if (file.getForwardBinaryHunk() != null) { - hdrEnd = file.getForwardBinaryHunk().getStartOffset(); - } else if (file.getReverseBinaryHunk() != null) { - hdrEnd = file.getReverseBinaryHunk().getStartOffset(); - } else { - hdrEnd = end; - } - - int eol; - for (; ptr < hdrEnd; ptr = eol) { - eol = nextLF(buf, ptr); - lines.add(new PatchLine(0, 0, Type.FILE_HEADER, decode(Constants.CHARSET, - buf, ptr, eol))); - } - - for (final HunkHeader h : file.getHunks()) { - final int hunkEnd = h.getEndOffset(); - if (ptr < hunkEnd) { - eol = nextLF(buf, ptr); - lines.add(new PatchLine(h.getOldImage().getStartLine(), h - .getNewStartLine(), Type.HUNK_HEADER, decode(Constants.CHARSET, - buf, ptr, eol))); - ptr = eol; - } - - int oldLine = h.getOldImage().getStartLine() - 1; - int newLine = h.getNewStartLine() - 1; - SCAN: for (; ptr < hunkEnd; ptr = eol) { - eol = nextLF(buf, ptr); - final PatchLine.Type type; - switch (buf[ptr]) { - case ' ': - case '\n': - oldLine++; - newLine++; - type = Type.CONTEXT; - break; - case '-': - oldLine++; - type = Type.PRE_IMAGE; - break; - case '+': - newLine++; - type = Type.POST_IMAGE; - break; - case '\\': - type = Type.CONTEXT; - break; - default: - break SCAN; - } - - final PatchLine pLine = - new PatchLine(oldLine, newLine, type, decode(Constants.CHARSET, - buf, ptr, eol)); - addComments(pLine, published, 0, oldLine); - addComments(pLine, published, 1, newLine); - if (drafted != null) { - addComments(pLine, drafted, 0, oldLine); - addComments(pLine, drafted, 1, newLine); - } - lines.add(pLine); - } - } - - final UnifiedPatchDetail d; - d = new UnifiedPatchDetail(patch, accountInfo.create()); - d.setLines(lines); - return d; - } -} diff --git a/webapp/src/com/google/gerrit/web.xml b/webapp/src/com/google/gerrit/web.xml deleted file mode 100644 index 4409e51082..0000000000 --- a/webapp/src/com/google/gerrit/web.xml +++ /dev/null @@ -1,96 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<web-app> - <resource-ref> - <res-ref-name>jdbc/ReviewDb</res-ref-name> - <res-type>javax.sql.DataSource</res-type> - <res-auth>Container</res-auth> - </resource-ref> - - <filter> - <filter-name>UrlRewrite</filter-name> - <filter-class>com.google.gerrit.server.UrlRewriteFilter</filter-class> - </filter> - <filter-mapping> - <filter-name>UrlRewrite</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - - <filter> - <filter-name>CacheControl</filter-name> - <filter-class>com.google.gerrit.server.CacheControlFilter</filter-class> - </filter> - <filter-mapping> - <filter-name>CacheControl</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - - <servlet> - <servlet-name>Gerrit</servlet-name> - <servlet-class>com.google.gerrit.server.HostPageServlet</servlet-class> - <load-on-startup>1</load-on-startup> - </servlet> - <servlet-mapping> - <servlet-name>Gerrit</servlet-name> - <url-pattern>/Gerrit</url-pattern> - </servlet-mapping> - - <servlet> - <servlet-name>Login</servlet-name> - <servlet-class>com.google.gerrit.server.LoginServlet</servlet-class> - <load-on-startup>1</load-on-startup> - </servlet> - <servlet-mapping> - <servlet-name>Login</servlet-name> - <url-pattern>/login</url-pattern> - </servlet-mapping> - - <servlet> - <servlet-name>AccountService</servlet-name> - <servlet-class>com.google.gerrit.server.AccountServiceSrv</servlet-class> - <load-on-startup>1</load-on-startup> - </servlet> - <servlet-mapping> - <servlet-name>AccountService</servlet-name> - <url-pattern>/rpc/AccountService</url-pattern> - </servlet-mapping> - - <servlet> - <servlet-name>ChangeDetailService</servlet-name> - <servlet-class>com.google.gerrit.server.ChangeDetailServiceSrv</servlet-class> - <load-on-startup>1</load-on-startup> - </servlet> - <servlet-mapping> - <servlet-name>ChangeDetailService</servlet-name> - <url-pattern>/rpc/ChangeDetailService</url-pattern> - </servlet-mapping> - - <servlet> - <servlet-name>ChangeListService</servlet-name> - <servlet-class>com.google.gerrit.server.ChangeListServiceSrv</servlet-class> - <load-on-startup>1</load-on-startup> - </servlet> - <servlet-mapping> - <servlet-name>ChangeListService</servlet-name> - <url-pattern>/rpc/ChangeListService</url-pattern> - </servlet-mapping> - - <servlet> - <servlet-name>PatchDetailService</servlet-name> - <servlet-class>com.google.gerrit.server.PatchDetailServiceSrv</servlet-class> - <load-on-startup>1</load-on-startup> - </servlet> - <servlet-mapping> - <servlet-name>PatchDetailService</servlet-name> - <url-pattern>/rpc/PatchDetailService</url-pattern> - </servlet-mapping> - - <servlet> - <servlet-name>SystemInfoService</servlet-name> - <servlet-class>com.google.gerrit.server.SystemInfoServiceSrv</servlet-class> - <load-on-startup>1</load-on-startup> - </servlet> - <servlet-mapping> - <servlet-name>SystemInfoService</servlet-name> - <url-pattern>/rpc/SystemInfoService</url-pattern> - </servlet-mapping> -</web-app> |