diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d2c737ba --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +*/target +*/proguard +*/gen +.gradle/** +gradle/** +gradlew* +*.iml +*/*.iml +.idea +*/.idea +*/.gwt +build +*/build +*/bin +*/war/WEB-INF/appengine-generated +**/local.properties diff --git a/.hgignore b/.hgignore index f1f2ff7f..403cc3d4 100644 --- a/.hgignore +++ b/.hgignore @@ -1,17 +1,32 @@ syntax: regexp -^([^/]+/)?target$ +^([^/]+/)+target$ + +syntax: regexp +^[^/]+/proguard$ syntax: regexp ^[^/]+/gen$ syntax: regexp -^discovery-appengine-sample/war/discover$ +.gradle$ + +syntax: regexp +(^[^/]+/)?.*\.iml$ + +syntax: regexp +(^[^/]+/)?.idea$ + +syntax: regexp +^[^/]+/.gwt$ + +syntax: regexp +^[^/]+/build$ syntax: regexp -^calendar-v2-atom-oauth-appengine-sample/war/calendar$ +^[^/]+/bin$ syntax: regexp -^[^/]+/war/WEB-INF/classes$ +^[^/]+/war/WEB-INF/appengine-generated syntax: regexp -^[^/]+/war/WEB-INF/appengine-generated$ +local.properties$ diff --git a/README.md b/README.md new file mode 100644 index 00000000..75c73587 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Samples of using the [Google APIs Client Library for Java](https://github.com/google/google-api-java-client) +For a complete list of Google APIs, visit https://developers.google.com/api-client-library/java/apis/ diff --git a/adexchangeseller-cmdline-sample/.classpath b/adexchangeseller-cmdline-sample/.classpath new file mode 100644 index 00000000..4b980c56 --- /dev/null +++ b/adexchangeseller-cmdline-sample/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/adexchangeseller-cmdline-sample/.project b/adexchangeseller-cmdline-sample/.project new file mode 100644 index 00000000..b77cda3c --- /dev/null +++ b/adexchangeseller-cmdline-sample/.project @@ -0,0 +1,23 @@ + + + adexchangeseller-cmdline-sample + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/adexchangeseller-cmdline-sample/.settings/org.eclipse.jdt.core.prefs b/adexchangeseller-cmdline-sample/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..faf086f4 --- /dev/null +++ b/adexchangeseller-cmdline-sample/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,380 @@ +#Fri Nov 04 10:10:38 EDT 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.annotationSuperInterface=ignore +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_member=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=24 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=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|5|48 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_field_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_for_statement=16 +org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments=16 +org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16|5|80 +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|4|49 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16|4|48 +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=false +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=100 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph=true +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.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.force_if_else_statement_brace=true +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +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_field=insert +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_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=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_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=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=do not 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.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +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=100 +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.sort_local_variable_annotations=false +org.eclipse.jdt.core.formatter.sort_member_annotations=false +org.eclipse.jdt.core.formatter.sort_package_annotations=false +org.eclipse.jdt.core.formatter.sort_parameter_annotations=false +org.eclipse.jdt.core.formatter.sort_type_annotations=false +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_comment_inline_tags=false +org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation=false +org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments=false diff --git a/adexchangeseller-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs b/adexchangeseller-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..2413e100 --- /dev/null +++ b/adexchangeseller-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,119 @@ +#Fri Nov 04 10:06:25 EDT 2011 +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=true +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=true +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_google-api-java-client +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false +formatter_profile=_google-api-java-client 100 +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=exception +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=com;org;;java;javax; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=999 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=999 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=false +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/adexchangeseller-cmdline-sample/AdExchangeSellerSample.launch b/adexchangeseller-cmdline-sample/AdExchangeSellerSample.launch new file mode 100644 index 00000000..b33ce645 --- /dev/null +++ b/adexchangeseller-cmdline-sample/AdExchangeSellerSample.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/adexchangeseller-cmdline-sample/instructions.html b/adexchangeseller-cmdline-sample/instructions.html new file mode 100644 index 00000000..e092e43d --- /dev/null +++ b/adexchangeseller-cmdline-sample/instructions.html @@ -0,0 +1,100 @@ + +adexchangeseller-cmdline-sample + +

Instructions for the Ad Exchange Seller REST API V1.1 Command-Line Sample

+ +

Browse Online

+ + + +

Register Your Application

+ + + +

Checkout Instructions

+ +

+ Prerequisites: install Java 6, Mercurial, and Maven. You may need to + set your + JAVA_HOME + . +

+ +
+cd [someDirectory]
+hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
+cd google-api-java-client-samples/adexchangeseller-cmdline-sample
+cp ~/Downloads/client_secrets.json src/main/resources/client_secrets.json
+mvn compile
+mvn -q exec:java
+  
+ +

To enable logging of HTTP requests and responses (highly recommended + when developing), please take a look at logging.properties.

+ +

Setup Project in Eclipse

+ +

+ Prerequisites: install Eclipse, + the Mercurial plugin, and the + Maven + plugin. +

+ + + + + diff --git a/adexchangeseller-cmdline-sample/logging.properties b/adexchangeseller-cmdline-sample/logging.properties new file mode 100644 index 00000000..4e59fe89 --- /dev/null +++ b/adexchangeseller-cmdline-sample/logging.properties @@ -0,0 +1,10 @@ +# Properties file which configures the operation of the JDK logging facility. +# The system will look for this config file to be specified as a system property: +# -Djava.util.logging.config.file=${project_loc:adexchangeseller-cmdline-sample}/logging.properties + +# Set up the console handler (uncomment "level" to show more fine-grained messages) +handlers = java.util.logging.ConsoleHandler +#java.util.logging.ConsoleHandler.level = CONFIG + +# Set up logging of HTTP requests and responses (uncomment "level" to show) +#com.google.api.client.http.level = CONFIG diff --git a/adexchangeseller-cmdline-sample/pom.xml b/adexchangeseller-cmdline-sample/pom.xml new file mode 100644 index 00000000..e8894782 --- /dev/null +++ b/adexchangeseller-cmdline-sample/pom.xml @@ -0,0 +1,135 @@ + + 4.0.0 + + com.google + google + 5 + + com.google.apis-samples + adexchangeseller-cmdline-sample + 1.1.0 + Example for the Ad Exchange Seller REST API v1.1 using JSON. + + http://code.google.com/p/google-api-java-client/ + + + code.google.com + http://code.google.com/p/google-api-java-client/issues/list + + + 2011 + + + 2.0.9 + + + + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + http://code.google.com/p/google-api-java-client/source/browse/?repo=samples + + + + + sgomes + Sergio Gomes + sgomes@google.com + Google + http://www.google.com + + owner + developer + + 0 + + + + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.codehaus.mojo + exec-maven-plugin + 1.1 + + + + java + + + + + com.google.api.services.samples.adexchangeseller.cmdline.AdExchangeSellerSample + + + java.util.logging.config.file + logging.properties + + + + + + maven-checkstyle-plugin + 2.6 + + ../checkstyle.xml + true + false + + + + + check + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + false + + + + + check + + + + + + ${project.artifactId}-${project.version} + + + + com.google.apis + google-api-services-adexchangeseller + v1.1-rev21-1.19.0 + + + com.google.http-client + google-http-client-jackson2 + ${project.http.version} + + + com.google.oauth-client + google-oauth-client-jetty + ${project.oauth.version} + + + + 1.19.0 + 1.19.0 + UTF-8 + + diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/AdExchangeSellerSample.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/AdExchangeSellerSample.java new file mode 100644 index 00000000..1b2bc0ae --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/AdExchangeSellerSample.java @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp; +import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; +import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; +import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.javanet.NetHttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.util.store.DataStoreFactory; +import com.google.api.client.util.store.FileDataStoreFactory; +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.AdExchangeSellerScopes; +import com.google.api.services.adexchangeseller.model.AdClients; +import com.google.api.services.adexchangeseller.model.AdUnits; +import com.google.api.services.adexchangeseller.model.CustomChannels; +import com.google.api.services.adexchangeseller.model.SavedReports; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; + +/** + * A sample application that runs multiple requests against the Ad Exchange Seller REST API. + * These include: + * + */ +public class AdExchangeSellerSample { + + /** + * Be sure to specify the name of your application. If the application name is {@code null} or + * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0". + */ + private static final String APPLICATION_NAME = ""; + + /** Directory to store user credentials. */ + private static final java.io.File DATA_STORE_DIR = + new java.io.File(System.getProperty("user.home"), ".store/adexchangeseller_sample"); + + /** + * Global instance of the {@link DataStoreFactory}. The best practice is to make it a single + * globally shared instance across your application. + */ + private static FileDataStoreFactory dataStoreFactory; + + /** Global instance of the JSON factory. */ + private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); + + // Request parameters. + private static final int MAX_LIST_PAGE_SIZE = 50; + private static final int MAX_REPORT_PAGE_SIZE = 50; + + /** Global instance of the HTTP transport. */ + private static HttpTransport httpTransport; + + /** Authorizes the installed application to access user's protected data. */ + private static Credential authorize() throws Exception { + // load client secrets + GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, + new InputStreamReader( + AdExchangeSellerSample.class.getResourceAsStream("/client_secrets.json"))); + if (clientSecrets.getDetails().getClientId().startsWith("Enter") + || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { + System.out.println("Enter Client ID and Secret from " + + "https://code.google.com/apis/console/?api=adexchangeseller into " + + "adexchangeseller-cmdline-sample/src/main/resources/client_secrets.json"); + System.exit(1); + } + // set up authorization code flow + GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( + httpTransport, JSON_FACTORY, clientSecrets, + Collections.singleton(AdExchangeSellerScopes.ADEXCHANGE_SELLER_READONLY)) + .setDataStoreFactory(dataStoreFactory).build(); + // authorize + return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user"); + } + + /** + * Performs all necessary setup steps for running requests against the API. + * + * @return An initialized AdExchangeSeller service object. + * @throws Exception + */ + private static AdExchangeSeller initializeAdExchangeSeller() throws Exception { + // Authorization. + Credential credential = authorize(); + + // Set up Ad Exchange Seller REST API client. + AdExchangeSeller adExchangeSeller = new AdExchangeSeller.Builder( + new NetHttpTransport(), JSON_FACTORY, credential).setApplicationName(APPLICATION_NAME) + .build(); + + return adExchangeSeller; + } + + /** + * Runs all the Ad Exchange Seller REST API samples. + * + * @param args command-line arguments. + */ + public static void main(String[] args) { + try { + httpTransport = GoogleNetHttpTransport.newTrustedTransport(); + dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR); + AdExchangeSeller adExchangeSeller = initializeAdExchangeSeller(); + + AdClients adClients = GetAllAdClients.run(adExchangeSeller, MAX_LIST_PAGE_SIZE); + if ((adClients.getItems() != null) && !adClients.getItems().isEmpty()) { + // Get an ad client ID, so we can run the rest of the samples. + String exampleAdClientId = adClients.getItems().get(0).getId(); + + AdUnits units = GetAllAdUnits.run(adExchangeSeller, exampleAdClientId, MAX_LIST_PAGE_SIZE); + if ((units.getItems() != null) && !units.getItems().isEmpty()) { + // Get an example ad unit ID, so we can run the following sample. + String exampleAdUnitId = units.getItems().get(0).getId(); + GetAllCustomChannelsForAdUnit.run( + adExchangeSeller, exampleAdClientId, exampleAdUnitId, MAX_LIST_PAGE_SIZE); + } + + CustomChannels channels = + GetAllCustomChannels.run(adExchangeSeller, exampleAdClientId, MAX_LIST_PAGE_SIZE); + if ((channels.getItems() != null) && !channels.getItems().isEmpty()) { + // Get an example custom channel ID, so we can run the following sample. + String exampleCustomChannelId = channels.getItems().get(0).getId(); + GetAllAdUnitsForCustomChannel.run( + adExchangeSeller, exampleAdClientId, exampleCustomChannelId, MAX_LIST_PAGE_SIZE); + } + + GetAllUrlChannels.run(adExchangeSeller, exampleAdClientId, MAX_LIST_PAGE_SIZE); + GenerateReport.run(adExchangeSeller, exampleAdClientId); + GenerateReportWithPaging.run(adExchangeSeller, exampleAdClientId, MAX_REPORT_PAGE_SIZE); + } else { + System.out.println("No ad clients found, unable to run remaining methods."); + } + + SavedReports savedReports = GetAllSavedReports.run(adExchangeSeller, MAX_REPORT_PAGE_SIZE); + if ((savedReports.getItems() != null) && !savedReports.getItems().isEmpty()) { + // Get a saved report ID, so we can generate its report. + String exampleSavedReportId = savedReports.getItems().get(0).getId(); + GenerateSavedReport.run(adExchangeSeller, exampleSavedReportId); + } else { + System.out.println("No saved report found."); + } + + GetAllDimensions.run(adExchangeSeller); + GetAllMetrics.run(adExchangeSeller); + + GetAllAlerts.run(adExchangeSeller); + + GetAllPreferredDeals.run(adExchangeSeller); + + } catch (IOException e) { + System.err.println(e.getMessage()); + } catch (Throwable t) { + t.printStackTrace(); + } + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GenerateReport.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GenerateReport.java new file mode 100644 index 00000000..10f47bc3 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GenerateReport.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.AdExchangeSeller.Reports.Generate; +import com.google.api.services.adexchangeseller.model.Report; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * This example retrieves a report, using a filter for a specified ad client. + * + *

Tags: reports.generate + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GenerateReport { + + static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param adClientId the ad client ID on which to run the report. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller, String adClientId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Running report for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Prepare report. + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DATE, -7); + Date oneWeekAgo = calendar.getTime(); + + String startDate = DATE_FORMATTER.format(oneWeekAgo); + String endDate = DATE_FORMATTER.format(today); + Generate request = adExchangeSeller.reports().generate(startDate, endDate); + + // Specify the desired ad client using a filter. + request.setFilter(Arrays.asList("AD_CLIENT_ID==" + escapeFilterParameter(adClientId))); + + request.setMetric(Arrays.asList("PAGE_VIEWS", "AD_REQUESTS", "AD_REQUESTS_COVERAGE", "CLICKS", + "AD_REQUESTS_CTR", "COST_PER_CLICK", "AD_REQUESTS_RPM", "EARNINGS")); + request.setDimension(Arrays.asList("DATE")); + + // Sort by ascending date. + request.setSort(Arrays.asList("+DATE")); + + // Run report. + Report response = request.execute(); + + if (response.getRows() != null && !response.getRows().isEmpty()) { + // Display headers. + for (Report.Headers header : response.getHeaders()) { + System.out.printf("%25s", header.getName()); + } + System.out.println(); + + // Display results. + for (List row : response.getRows()) { + for (String column : row) { + System.out.printf("%25s", column); + } + System.out.println(); + } + + System.out.println(); + } else { + System.out.println("No rows returned."); + } + + System.out.println(); + } + + /** + * Escape special characters for a parameter being used in a filter. + * @param parameter the parameter to be escaped. + * @return the escaped parameter. + */ + public static String escapeFilterParameter(String parameter) { + return parameter.replace("\\", "\\\\").replace(",", "\\,"); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GenerateReportWithPaging.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GenerateReportWithPaging.java new file mode 100644 index 00000000..66a7ed6f --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GenerateReportWithPaging.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.AdExchangeSeller.Reports.Generate; +import com.google.api.services.adexchangeseller.model.Report; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * This example retrieves a report for the specified ad client. + * + *

Please only use pagination if your application requires it due to memory or storage + * constraints. If you need to retrieve more than 5000 rows, please check GenerateReport.java, as + * due to current limitations you will not be able to use paging for large reports. + * + *

Tags: reports.generate + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GenerateReportWithPaging { + + // Maximum number of obtainable rows for paged reports (API limit). + private static final int ROW_LIMIT = 5000; + + static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param adClientId the ad client ID on which to run the report. + * @param maxReportPageSize the maximum size page to retrieve. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller, String adClientId, + long maxReportPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Running report for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Prepare report. + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DATE, -7); + Date oneWeekAgo = calendar.getTime(); + + String startDate = DATE_FORMATTER.format(oneWeekAgo); + String endDate = DATE_FORMATTER.format(today); + Generate request = adExchangeSeller.reports().generate(startDate, endDate); + + // Specify the desired ad client using a filter. + request.setFilter(Arrays.asList("AD_CLIENT_ID==" + escapeFilterParameter(adClientId))); + + request.setMetric(Arrays.asList("PAGE_VIEWS", "AD_REQUESTS", "AD_REQUESTS_COVERAGE", "CLICKS", + "AD_REQUESTS_CTR", "COST_PER_CLICK", "AD_REQUESTS_RPM", "EARNINGS")); + request.setDimension(Arrays.asList("DATE")); + + // Sort by ascending date. + request.setSort(Arrays.asList("+DATE")); + + // Run first page of report. + request.setMaxResults(maxReportPageSize); + Report response = request.execute(); + + if (response.getRows() == null || response.getRows().isEmpty()) { + System.out.println("No rows returned."); + return; + } + + // The first page, so display headers. + displayHeaders(response.getHeaders()); + + // Display first page results. + displayRows(response.getRows()); + + int totalRows = Math.min(response.getTotalMatchedRows().intValue(), ROW_LIMIT); + for (long startIndex = response.getRows().size(); startIndex < totalRows; + startIndex += response.getRows().size()) { + + // Check to see if we're going to go above the limit and get as many results as we can. + long pageSize = Math.min(maxReportPageSize, totalRows - startIndex); + + request.setStartIndex(startIndex); + request.setMaxResults(pageSize); + + // Run next page of report. + response = request.execute(); + + // If the report size changes in between paged requests, the result may be empty. + if (response.getRows() == null || response.getRows().isEmpty()) { + break; + } + + // Display results. + displayRows(response.getRows()); + } + + System.out.println(); + } + + /** + * Displays the headers for the report. + * @param headers The list of headers to be displayed. + */ + private static void displayHeaders(List headers) { + for (Report.Headers header : headers) { + System.out.printf("%25s", header.getName()); + } + System.out.println(); + } + + /** + * Displays a list of rows for the report. + * @param rows The list of rows to display. + */ + public static void displayRows(List> rows) { + // Display results. + for (List row : rows) { + for (String column : row) { + System.out.printf("%25s", column); + } + System.out.println(); + } + } + + /** + * Escape special characters for a parameter being used in a filter. + * @param parameter the parameter to be escaped. + * @return the escaped parameter. + */ + public static String escapeFilterParameter(String parameter) { + return parameter.replace("\\", "\\\\").replace(",", "\\,"); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GenerateSavedReport.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GenerateSavedReport.java new file mode 100644 index 00000000..e2a2db56 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GenerateSavedReport.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.AdExchangeSeller.Reports.Saved.Generate; +import com.google.api.services.adexchangeseller.model.Report; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * This example retrieves a saved report for the default account. + * + *

Tags: reports.saved.generate + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GenerateSavedReport { + + static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param savedReportId the saved report ID on which to run the report. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller, String savedReportId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Running saved report %s\n", savedReportId); + System.out.println("================================================================="); + + // Prepare report. + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DATE, -7); + Generate request = adExchangeSeller.reports().saved().generate(savedReportId); + + // Run saved report. + Report response = request.execute(); + + if (response.getRows() != null && !response.getRows().isEmpty()) { + // Display headers. + for (Report.Headers header : response.getHeaders()) { + System.out.printf("%25s", header.getName()); + } + System.out.println(); + + // Display results. + for (List row : response.getRows()) { + for (String column : row) { + System.out.printf("%25s", column); + } + System.out.println(); + } + + System.out.println(); + } else { + System.out.println("No rows returned."); + } + + System.out.println(); + } + + /** + * Escape special characters for a parameter being used in a filter.new. + * + * @param parameter the parameter to be escaped. + * @return the escaped parameter. + */ + public static String escapeFilterParameter(String parameter) { + return parameter.replace("\\", "\\\\").replace(",", "\\,"); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAdClients.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAdClients.java new file mode 100644 index 00000000..b6bd0110 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAdClients.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.AdClient; +import com.google.api.services.adexchangeseller.model.AdClients; + +/** +* +* This example gets all ad clients for the logged in user's account. +* +*

Tags: adclients.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllAdClients { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of retrieved ad clients. + * @throws Exception + */ + public static AdClients run(AdExchangeSeller adExchangeSeller, long maxPageSize) + throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all ad clients for account"); + System.out.println("================================================================="); + + // Retrieve ad client list in pages and display data as we receive it. + String pageToken = null; + AdClients adClients = null; + do { + adClients = adExchangeSeller.adclients().list() + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (adClients.getItems() != null && !adClients.getItems().isEmpty()) { + for (AdClient adClient : adClients.getItems()) { + System.out.printf("Ad client for product \"%s\" with ID \"%s\" was found.\n", + adClient.getProductCode(), adClient.getId()); + System.out.printf("\tSupports reporting: %s\n", + adClient.getSupportsReporting() ? "Yes" : "No"); + } + } else { + System.out.println("No ad clients found."); + } + + pageToken = adClients.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + + // Return the last page of ad clients, so that the main sample has something to run. + return adClients; + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAdUnits.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAdUnits.java new file mode 100644 index 00000000..cf1ce698 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAdUnits.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.AdUnit; +import com.google.api.services.adexchangeseller.model.AdUnits; + +/** +* +* This example gets all ad units in an ad client. +* +*

Tags: adunits.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllAdUnits { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of ad units. + * @throws Exception + */ + public static AdUnits run(AdExchangeSeller adExchangeSeller, String adClientId, long maxPageSize) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all ad units for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Retrieve ad unit list in pages and display data as we receive it. + String pageToken = null; + AdUnits adUnits = null; + do { + adUnits = adExchangeSeller.adunits().list(adClientId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (adUnits.getItems() != null && !adUnits.getItems().isEmpty()) { + for (AdUnit unit : adUnits.getItems()) { + System.out.printf("Ad unit with code \"%s\", name \"%s\" and status \"%s\" was found.\n", + unit.getCode(), unit.getName(), unit.getStatus()); + } + } else { + System.out.println("No ad units found."); + } + + pageToken = adUnits.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + + // Return the last page of ad units, so that the main sample has something to run. + return adUnits; + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAdUnitsForCustomChannel.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAdUnitsForCustomChannel.java new file mode 100644 index 00000000..25580cc3 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAdUnitsForCustomChannel.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.AdUnit; +import com.google.api.services.adexchangeseller.model.AdUnits; + +/** +* +* This example gets all ad units corresponding to a specified custom channel. +* +* Tags: customchannels.adunits.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllAdUnitsForCustomChannel { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param customChannelId the ID for the custom channel to be used. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller, String adClientId, + String customChannelId, long maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all ad units for custom channel %s\n", customChannelId); + System.out.println("================================================================="); + + // Retrieve ad unit list in pages and display data as we receive it. + String pageToken = null; + do { + AdUnits adUnits = adExchangeSeller.customchannels().adunits() + .list(adClientId, customChannelId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (adUnits.getItems() != null && !adUnits.getItems().isEmpty()) { + for (AdUnit unit : adUnits.getItems()) { + System.out.printf("Ad unit with code \"%s\", name \"%s\" and status \"%s\" was found.\n", + unit.getCode(), unit.getName(), unit.getStatus()); + } + } else { + System.out.println("No ad units found."); + } + + pageToken = adUnits.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAlerts.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAlerts.java new file mode 100644 index 00000000..2b04b057 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllAlerts.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.Alert; +import com.google.api.services.adexchangeseller.model.Alerts; + +/** +* +* Gets all alerts available for the logged in user's account. +* +*

Tags: alerts.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllAlerts { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all alerts for account"); + System.out.println("================================================================="); + + // Retrieve and display alerts. + Alerts alerts = adExchangeSeller.alerts().list().execute(); + + if (alerts.getItems() != null && !alerts.getItems().isEmpty()) { + for (Alert alert : alerts.getItems()) { + System.out.printf("Alert id \"%s\" with severity \"%s\" and type \"%s\" was found.\n", + alert.getId(), alert.getSeverity(), alert.getType()); + } + } else { + System.out.println("No alerts found."); + } + + System.out.println(); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllCustomChannels.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllCustomChannels.java new file mode 100644 index 00000000..39deaba8 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllCustomChannels.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.CustomChannel; +import com.google.api.services.adexchangeseller.model.CustomChannels; + +/** +* +* This example gets all custom channels in an ad client. +* +* Tags: customchannels.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllCustomChannels { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of custom channels. + * @throws Exception + */ + public static CustomChannels run(AdExchangeSeller adExchangeSeller, String adClientId, + long maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all custom channels for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Retrieve custom channel list in pages and display the data as we receive it. + String pageToken = null; + CustomChannels customChannels = null; + do { + customChannels = adExchangeSeller.customchannels().list(adClientId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (customChannels.getItems() != null && !customChannels.getItems().isEmpty()) { + for (CustomChannel channel : customChannels.getItems()) { + System.out.printf("Custom channel with code \"%s\" and name \"%s\" was found.\n", + channel.getCode(), channel.getName()); + } + } else { + System.out.println("No custom channels found."); + } + + pageToken = customChannels.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + return customChannels; + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllCustomChannelsForAdUnit.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllCustomChannelsForAdUnit.java new file mode 100644 index 00000000..4121e47d --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllCustomChannelsForAdUnit.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.CustomChannel; +import com.google.api.services.adexchangeseller.model.CustomChannels; + +/** +* +* This example gets all custom channels an ad unit has been added to. +* +* Tags: adunits.customchannels.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllCustomChannelsForAdUnit { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param adUnitId the ID for the ad unit to be used. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller, String adClientId, String adUnitId, + long maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all custom channels for ad unit %s\n", adUnitId); + System.out.println("================================================================="); + + // Retrieve custom channel list in pages and display the data as we receive it. + String pageToken = null; + do { + CustomChannels customChannels = adExchangeSeller.adunits().customchannels() + .list(adClientId, adUnitId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (customChannels.getItems() != null && !customChannels.getItems().isEmpty()) { + for (CustomChannel channel : customChannels.getItems()) { + System.out.printf("Custom channel with code \"%s\" and name \"%s\" was found.\n", + channel.getCode(), channel.getName()); + } + } else { + System.out.println("No custom channels found."); + } + + pageToken = customChannels.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllDimensions.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllDimensions.java new file mode 100644 index 00000000..9c05cfb3 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllDimensions.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.Metadata; +import com.google.api.services.adexchangeseller.model.ReportingMetadataEntry; + +/** +* +* Gets all dimensions available for the logged in user's account. +* +*

Tags: metadata.dimensions.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllDimensions { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all dimensions for account"); + System.out.println("================================================================="); + + // Retrieve and display dimensions. + Metadata dimensions = adExchangeSeller.metadata().dimensions().list().execute(); + + if (dimensions.getItems() != null && !dimensions.getItems().isEmpty()) { + for (ReportingMetadataEntry dimension : dimensions.getItems()) { + boolean firstProduct = true; + StringBuilder products = new StringBuilder(); + for (String product : dimension.getSupportedProducts()) { + if (!firstProduct) { + products.append(", "); + } + products.append(product); + firstProduct = false; + } + System.out.printf("Dimension id \"%s\" for product(s): [%s] was found.\n", + dimension.getId(), products.toString()); + } + } else { + System.out.println("No dimensions found."); + } + + System.out.println(); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllMetrics.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllMetrics.java new file mode 100644 index 00000000..5a5d9de9 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllMetrics.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.Metadata; +import com.google.api.services.adexchangeseller.model.ReportingMetadataEntry; + +/** +* +* Gets all metrics available for the logged in user's account. +* +*

Tags: metadata.metrics.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllMetrics { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all metrics for account"); + System.out.println("================================================================="); + + // Retrieve and display metrics. + Metadata metrics = adExchangeSeller.metadata().metrics().list().execute(); + + if (metrics.getItems() != null && !metrics.getItems().isEmpty()) { + for (ReportingMetadataEntry metric : metrics.getItems()) { + boolean firstProduct = true; + StringBuilder products = new StringBuilder(); + for (String product : metric.getSupportedProducts()) { + if (!firstProduct) { + products.append(", "); + } + products.append(product); + firstProduct = false; + } + System.out.printf("Metric id \"%s\" for product(s): [%s] was found.\n", + metric.getId(), products.toString()); + } + } else { + System.out.println("No metrics found."); + } + + System.out.println(); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllPreferredDeals.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllPreferredDeals.java new file mode 100644 index 00000000..2969d80d --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllPreferredDeals.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.PreferredDeal; +import com.google.api.services.adexchangeseller.model.PreferredDeals; + +/** +* +* Gets all preferred deals available on the logged in user's account. +* +*

Tags: preferreddeals.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllPreferredDeals { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all preferred deals on account"); + System.out.println("================================================================="); + + // Retrieve and display preferred deals. + PreferredDeals deals = adExchangeSeller.preferreddeals().list().execute(); + + if (deals.getItems() != null && !deals.getItems().isEmpty()) { + for (PreferredDeal deal : deals.getItems()) { + System.out.printf("Deal id \"%s\" ", deal.getId()); + + if (deal.getAdvertiserName() != null) { + System.out.printf("for advertiser \"%s\" ", deal.getAdvertiserName()); + } + + if (deal.getBuyerNetworkName() != null) { + System.out.printf("on network \"%s\" ", deal.getBuyerNetworkName()); + } + + System.out.println("was found."); + } + } else { + System.out.println("No preferred deals found."); + } + + System.out.println(); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllSavedReports.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllSavedReports.java new file mode 100644 index 00000000..d05131f9 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllSavedReports.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.SavedReport; +import com.google.api.services.adexchangeseller.model.SavedReports; + +/** + * + * This example gets all saved reports for the logged in user's account. + * + *

Tags: reports.saved.list + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GetAllSavedReports { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of saved reports. + * @throws Exception + */ + public static SavedReports run(AdExchangeSeller adExchangeSeller, int maxPageSize) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all saved reports for account\n"); + System.out.println("================================================================="); + + // Retrieve saved report list in pages and display the data as we receive it. + String pageToken = null; + SavedReports savedReports = null; + do { + savedReports = adExchangeSeller.reports() + .saved() + .list() + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (savedReports.getItems() != null && !savedReports.getItems().isEmpty()) { + for (SavedReport savedReport : savedReports.getItems()) { + System.out.printf("Saved report with id \"%s\" and name \"%s\" was found.\n", + savedReport.getId(), savedReport.getName()); + } + } else { + System.out.println("No saved reports found."); + } + + pageToken = savedReports.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + return savedReports; + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllUrlChannels.java b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllUrlChannels.java new file mode 100644 index 00000000..7455ff33 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/java/com/google/api/services/samples/adexchangeseller/cmdline/GetAllUrlChannels.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adexchangeseller.cmdline; + +import com.google.api.services.adexchangeseller.AdExchangeSeller; +import com.google.api.services.adexchangeseller.model.UrlChannel; +import com.google.api.services.adexchangeseller.model.UrlChannels; + +/** +* +* This example gets all URL channels in an ad client. +* +*

Tags: urlchannels.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllUrlChannels { + + /** + * Runs this sample. + * + * @param adExchangeSeller AdExchangeSeller service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdExchangeSeller adExchangeSeller, String adClientId, long maxPageSize) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all URL channels for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Retrieve URL channel list in pages and display the data as we receive it. + String pageToken = null; + do { + UrlChannels urlChannels = adExchangeSeller.urlchannels().list(adClientId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (urlChannels.getItems() != null && !urlChannels.getItems().isEmpty()) { + for (UrlChannel channel : urlChannels.getItems()) { + System.out.printf("URL channel with URL pattern \"%s\" was found.\n", + channel.getUrlPattern()); + } + } else { + System.out.println("No URL channels found."); + } + + pageToken = urlChannels.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + } +} diff --git a/adexchangeseller-cmdline-sample/src/main/resources/client_secrets.json b/adexchangeseller-cmdline-sample/src/main/resources/client_secrets.json new file mode 100644 index 00000000..e448bab9 --- /dev/null +++ b/adexchangeseller-cmdline-sample/src/main/resources/client_secrets.json @@ -0,0 +1,6 @@ +{ + "installed": { + "client_id": "Enter Client ID", + "client_secret": "Enter Client Secret" + } +} diff --git a/adsense-cmdline-sample/.classpath b/adsense-cmdline-sample/.classpath new file mode 100644 index 00000000..4b980c56 --- /dev/null +++ b/adsense-cmdline-sample/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/adsense-cmdline-sample/.project b/adsense-cmdline-sample/.project new file mode 100644 index 00000000..81f26972 --- /dev/null +++ b/adsense-cmdline-sample/.project @@ -0,0 +1,23 @@ + + + adsense-cmdline-sample + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/adsense-cmdline-sample/.settings/org.eclipse.jdt.core.prefs b/adsense-cmdline-sample/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..faf086f4 --- /dev/null +++ b/adsense-cmdline-sample/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,380 @@ +#Fri Nov 04 10:10:38 EDT 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.annotationSuperInterface=ignore +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_member=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=24 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=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|5|48 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_field_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_for_statement=16 +org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments=16 +org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16|5|80 +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|4|49 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16|4|48 +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=false +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=100 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph=true +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.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.force_if_else_statement_brace=true +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +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_field=insert +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_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=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_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=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=do not 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.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +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=100 +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.sort_local_variable_annotations=false +org.eclipse.jdt.core.formatter.sort_member_annotations=false +org.eclipse.jdt.core.formatter.sort_package_annotations=false +org.eclipse.jdt.core.formatter.sort_parameter_annotations=false +org.eclipse.jdt.core.formatter.sort_type_annotations=false +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_comment_inline_tags=false +org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation=false +org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments=false diff --git a/adsense-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs b/adsense-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..2413e100 --- /dev/null +++ b/adsense-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,119 @@ +#Fri Nov 04 10:06:25 EDT 2011 +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=true +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=true +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_google-api-java-client +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false +formatter_profile=_google-api-java-client 100 +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=exception +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=com;org;;java;javax; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=999 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=999 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=false +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/adsense-cmdline-sample/AdSenseSample.launch b/adsense-cmdline-sample/AdSenseSample.launch new file mode 100644 index 00000000..25422551 --- /dev/null +++ b/adsense-cmdline-sample/AdSenseSample.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/adsense-cmdline-sample/instructions.html b/adsense-cmdline-sample/instructions.html new file mode 100644 index 00000000..1e664a5e --- /dev/null +++ b/adsense-cmdline-sample/instructions.html @@ -0,0 +1,100 @@ + +adsense-cmdline-sample + +

Instructions for the AdSense Management API V1.3 Command-Line Sample

+ +

Browse Online

+ + + +

Register Your Application

+ + + +

Checkout Instructions

+ +

+ Prerequisites: install Java 6, Mercurial, and Maven. You may need to + set your + JAVA_HOME + . +

+ +
+cd [someDirectory]
+hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
+cd google-api-java-client-samples/adsense-cmdline-sample
+cp ~/Downloads/client_secrets.json src/main/resources/client_secrets.json
+mvn compile
+mvn -q exec:java
+  
+ +

To enable logging of HTTP requests and responses (highly recommended + when developing), please take a look at logging.properties.

+ +

Setup Project in Eclipse

+ +

+ Prerequisites: install Eclipse, + the Mercurial plugin, and the + Maven + plugin. +

+ + + + + diff --git a/adsense-cmdline-sample/logging.properties b/adsense-cmdline-sample/logging.properties new file mode 100644 index 00000000..1c97e313 --- /dev/null +++ b/adsense-cmdline-sample/logging.properties @@ -0,0 +1,10 @@ +# Properties file which configures the operation of the JDK logging facility. +# The system will look for this config file to be specified as a system property: +# -Djava.util.logging.config.file=${project_loc:adsense-cmdline-sample}/logging.properties + +# Set up the console handler (uncomment "level" to show more fine-grained messages) +handlers = java.util.logging.ConsoleHandler +#java.util.logging.ConsoleHandler.level = CONFIG + +# Set up logging of HTTP requests and responses (uncomment "level" to show) +#com.google.api.client.http.level = CONFIG diff --git a/adsense-cmdline-sample/pom.xml b/adsense-cmdline-sample/pom.xml new file mode 100644 index 00000000..a21baa08 --- /dev/null +++ b/adsense-cmdline-sample/pom.xml @@ -0,0 +1,135 @@ + + 4.0.0 + + com.google + google + 5 + + com.google.apis-samples + adsense-cmdline-sample + 1.3.0 + Example for the AdSense Management API v1.3 using JSON. + + http://code.google.com/p/google-api-java-client/ + + + code.google.com + http://code.google.com/p/google-api-java-client/issues/list + + + 2011 + + + 2.0.9 + + + + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + http://code.google.com/p/google-api-java-client/source/browse/?repo=samples + + + + + sgomes + Sergio Gomes + sergio.gomes@google.com + Google + http://www.google.com + + owner + developer + + 0 + + + + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.codehaus.mojo + exec-maven-plugin + 1.1 + + + + java + + + + + com.google.api.services.samples.adsense.cmdline.AdSenseSample + + + java.util.logging.config.file + logging.properties + + + + + + maven-checkstyle-plugin + 2.6 + + ../checkstyle.xml + true + false + + + + + check + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + false + + + + + check + + + + + + ${project.artifactId}-${project.version} + + + + com.google.apis + google-api-services-adsense + v1.3-rev54-1.19.0 + + + com.google.http-client + google-http-client-jackson2 + ${project.http.version} + + + com.google.oauth-client + google-oauth-client-jetty + ${project.oauth.version} + + + + 1.19.0 + 1.19.0 + UTF-8 + + diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/AdSenseSample.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/AdSenseSample.java new file mode 100644 index 00000000..f0737f30 --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/AdSenseSample.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp; +import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; +import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; +import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.javanet.NetHttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.util.store.DataStoreFactory; +import com.google.api.client.util.store.FileDataStoreFactory; +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.AdSenseScopes; +import com.google.api.services.adsense.model.Accounts; +import com.google.api.services.adsense.model.AdClients; +import com.google.api.services.adsense.model.AdUnits; +import com.google.api.services.adsense.model.CustomChannels; +import com.google.api.services.adsense.model.SavedReports; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; + +/** + * A sample application that runs multiple requests against the AdSense Management API. These + * include: + * + */ +public class AdSenseSample { + + /** + * Be sure to specify the name of your application. If the application name is {@code null} or + * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0". + */ + private static final String APPLICATION_NAME = ""; + + /** Directory to store user credentials. */ + private static final java.io.File DATA_STORE_DIR = + new java.io.File(System.getProperty("user.home"), ".store/adsense_management_sample"); + + /** + * Global instance of the {@link DataStoreFactory}. The best practice is to make it a single + * globally shared instance across your application. + */ + private static FileDataStoreFactory dataStoreFactory; + + /** Global instance of the JSON factory. */ + private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); + + // Request parameters. + private static final int MAX_LIST_PAGE_SIZE = 50; + private static final int MAX_REPORT_PAGE_SIZE = 50; + + /** Global instance of the HTTP transport. */ + private static HttpTransport httpTransport; + + /** Authorizes the installed application to access user's protected data. */ + private static Credential authorize() throws Exception { + // load client secrets + GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, + new InputStreamReader(AdSenseSample.class.getResourceAsStream("/client_secrets.json"))); + if (clientSecrets.getDetails().getClientId().startsWith("Enter") + || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { + System.out.println("Enter Client ID and Secret from " + + "https://code.google.com/apis/console/?api=adsense into " + + "adsense-cmdline-sample/src/main/resources/client_secrets.json"); + System.exit(1); + } + // set up authorization code flow + GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( + httpTransport, JSON_FACTORY, clientSecrets, + Collections.singleton(AdSenseScopes.ADSENSE_READONLY)).setDataStoreFactory( + dataStoreFactory).build(); + // authorize + return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user"); + } + + /** + * Performs all necessary setup steps for running requests against the API. + * + * @return An initialized AdSense service object. + * @throws Exception + */ + private static AdSense initializeAdsense() throws Exception { + // Authorization. + Credential credential = authorize(); + + // Set up AdSense Management API client. + AdSense adsense = new AdSense.Builder( + new NetHttpTransport(), JSON_FACTORY, credential).setApplicationName(APPLICATION_NAME) + .build(); + + return adsense; + } + + /** + * Runs all the AdSense Management API samples. + * + * @param args command-line arguments. + */ + public static void main(String[] args) { + try { + httpTransport = GoogleNetHttpTransport.newTrustedTransport(); + dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR); + AdSense adsense = initializeAdsense(); + + Accounts accounts = GetAllAccounts.run(adsense, MAX_LIST_PAGE_SIZE); + if ((accounts.getItems() != null) && !accounts.getItems().isEmpty()) { + // Get an example account ID, so we can run the following sample. + String exampleAccountId = accounts.getItems().get(0).getId(); + GetAccountTree.run(adsense, exampleAccountId); + GetAllAdClientsForAccount.run(adsense, exampleAccountId, MAX_LIST_PAGE_SIZE); + } + + AdClients adClients = GetAllAdClients.run(adsense, MAX_LIST_PAGE_SIZE); + if ((adClients.getItems() != null) && !adClients.getItems().isEmpty()) { + // Get an ad client ID, so we can run the rest of the samples. + String exampleAdClientId = adClients.getItems().get(0).getId(); + + AdUnits units = GetAllAdUnits.run(adsense, exampleAdClientId, MAX_LIST_PAGE_SIZE); + if ((units.getItems() != null) && !units.getItems().isEmpty()) { + // Get an example ad unit ID, so we can run the following sample. + String exampleAdUnitId = units.getItems().get(0).getId(); + GetAllCustomChannelsForAdUnit.run( + adsense, exampleAdClientId, exampleAdUnitId, MAX_LIST_PAGE_SIZE); + } + + CustomChannels channels = + GetAllCustomChannels.run(adsense, exampleAdClientId, MAX_LIST_PAGE_SIZE); + if ((channels.getItems() != null) && !channels.getItems().isEmpty()) { + // Get an example custom channel ID, so we can run the following sample. + String exampleCustomChannelId = channels.getItems().get(0).getId(); + GetAllAdUnitsForCustomChannel.run( + adsense, exampleAdClientId, exampleCustomChannelId, MAX_LIST_PAGE_SIZE); + } + + GetAllUrlChannels.run(adsense, exampleAdClientId, MAX_LIST_PAGE_SIZE); + GenerateReport.run(adsense, exampleAdClientId); + GenerateReportWithPaging.run(adsense, exampleAdClientId, MAX_REPORT_PAGE_SIZE); + } else { + System.out.println("No ad clients found, unable to run remaining methods."); + } + + SavedReports savedReports = GetAllSavedReports.run(adsense, MAX_REPORT_PAGE_SIZE); + if ((savedReports.getItems() != null) && !savedReports.getItems().isEmpty()) { + // Get a saved report ID, so we can generate its report. + String exampleSavedReportId = savedReports.getItems().get(0).getId(); + GenerateSavedReport.run(adsense, exampleSavedReportId); + } else { + System.out.println("No saved report found."); + } + + GetAllSavedAdStyles.run(adsense, MAX_LIST_PAGE_SIZE); + + GetAllDimensions.run(adsense); + GetAllMetrics.run(adsense); + + GetAllAlerts.run(adsense); + + } catch (IOException e) { + System.err.println(e.getMessage()); + } catch (Throwable t) { + t.printStackTrace(); + } + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateReport.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateReport.java new file mode 100644 index 00000000..b7d4422c --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateReport.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.AdSense.Reports.Generate; +import com.google.api.services.adsense.model.AdsenseReportsGenerateResponse; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * This example retrieves a report, using a filter for a specified ad client. + * + * Tags: reports.generate + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GenerateReport { + + static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Runs this sample. + * @param adsense AdSense service object on which to run the requests. + * @param adClientId the ad client ID on which to run the report. + * @throws Exception + */ + public static void run(AdSense adsense, String adClientId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Running report for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Prepare report. + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DATE, -7); + Date oneWeekAgo = calendar.getTime(); + + String startDate = DATE_FORMATTER.format(oneWeekAgo); + String endDate = DATE_FORMATTER.format(today); + Generate request = adsense.reports().generate(startDate, endDate); + + // Specify the desired ad client using a filter. + request.setFilter(Arrays.asList("AD_CLIENT_ID==" + escapeFilterParameter(adClientId))); + + request.setMetric(Arrays.asList("PAGE_VIEWS", "AD_REQUESTS", "AD_REQUESTS_COVERAGE", "CLICKS", + "AD_REQUESTS_CTR", "COST_PER_CLICK", "AD_REQUESTS_RPM", "EARNINGS")); + request.setDimension(Arrays.asList("DATE")); + + // Sort by ascending date. + request.setSort(Arrays.asList("+DATE")); + + // Run report. + AdsenseReportsGenerateResponse response = request.execute(); + + if (response.getRows() != null && !response.getRows().isEmpty()) { + // Display headers. + for (AdsenseReportsGenerateResponse.Headers header : response.getHeaders()) { + System.out.printf("%25s", header.getName()); + } + System.out.println(); + + // Display results. + for (List row : response.getRows()) { + for (String column : row) { + System.out.printf("%25s", column); + } + System.out.println(); + } + + System.out.println(); + } else { + System.out.println("No rows returned."); + } + + System.out.println(); + } + + /** + * Escape special characters for a parameter being used in a filter. + * @param parameter the parameter to be escaped. + * @return the escaped parameter. + */ + public static String escapeFilterParameter(String parameter) { + return parameter.replace("\\", "\\\\").replace(",", "\\,"); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateReportWithPaging.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateReportWithPaging.java new file mode 100644 index 00000000..dee158e6 --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateReportWithPaging.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.AdSense.Reports.Generate; +import com.google.api.services.adsense.model.AdsenseReportsGenerateResponse; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * This example retrieves a report for the specified ad client. + * + * Please only use pagination if your application requires it due to memory or storage constraints. + * If you need to retrieve more than 5000 rows, please check GenerateReport.java, as due to current + * limitations you will not be able to use paging for large reports. + * + * Tags: reports.generate + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GenerateReportWithPaging { + + // Maximum number of obtainable rows for paged reports (API limit). + private static final int ROW_LIMIT = 5000; + + static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param adClientId the ad client ID on which to run the report. + * @param maxReportPageSize the maximum size page to retrieve. + * @throws Exception + */ + public static void run(AdSense adsense, String adClientId, int maxReportPageSize) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Running report for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Prepare report. + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DATE, -7); + Date oneWeekAgo = calendar.getTime(); + + String startDate = DATE_FORMATTER.format(oneWeekAgo); + String endDate = DATE_FORMATTER.format(today); + Generate request = adsense.reports().generate(startDate, endDate); + + // Specify the desired ad client using a filter. + request.setFilter(Arrays.asList("AD_CLIENT_ID==" + escapeFilterParameter(adClientId))); + + request.setMetric(Arrays.asList("PAGE_VIEWS", "AD_REQUESTS", "AD_REQUESTS_COVERAGE", "CLICKS", + "AD_REQUESTS_CTR", "COST_PER_CLICK", "AD_REQUESTS_RPM", "EARNINGS")); + request.setDimension(Arrays.asList("DATE")); + + // Sort by ascending date. + request.setSort(Arrays.asList("+DATE")); + + // Run first page of report. + request.setMaxResults(maxReportPageSize); + AdsenseReportsGenerateResponse response = request.execute(); + + if (response.getRows() == null || response.getRows().isEmpty()) { + System.out.println("No rows returned."); + return; + } + + // The first page, so display headers. + displayHeaders(response.getHeaders()); + + // Display first page results. + displayRows(response.getRows()); + + int totalRows = Math.min(response.getTotalMatchedRows().intValue(), ROW_LIMIT); + for (int startIndex = response.getRows().size(); startIndex < totalRows; + startIndex += response.getRows().size()) { + + // Check to see if we're going to go above the limit and get as many results as we can. + int pageSize = Math.min(maxReportPageSize, totalRows - startIndex); + + request.setStartIndex(startIndex); + request.setMaxResults(pageSize); + + // Run next page of report. + response = request.execute(); + + // If the report size changes in between paged requests, the result may be empty. + if (response.getRows() == null || response.getRows().isEmpty()) { + break; + } + + // Display results. + displayRows(response.getRows()); + } + + System.out.println(); + } + + /** + * Displays the headers for the report. + * @param headers The list of headers to be displayed. + */ + private static void displayHeaders(List headers) { + for (AdsenseReportsGenerateResponse.Headers header : headers) { + System.out.printf("%25s", header.getName()); + } + System.out.println(); + } + + /** + * Displays a list of rows for the report. + * @param rows The list of rows to display. + */ + public static void displayRows(List> rows) { + // Display results. + for (List row : rows) { + for (String column : row) { + System.out.printf("%25s", column); + } + System.out.println(); + } + } + + /** + * Escape special characters for a parameter being used in a filter. + * @param parameter the parameter to be escaped. + * @return the escaped parameter. + */ + public static String escapeFilterParameter(String parameter) { + return parameter.replace("\\", "\\\\").replace(",", "\\,"); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateSavedReport.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateSavedReport.java new file mode 100644 index 00000000..202b38ee --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateSavedReport.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.AdSense.Reports.Saved.Generate; +import com.google.api.services.adsense.model.AdsenseReportsGenerateResponse; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * This example retrieves a saved report for the default account. + * + * Tags: reports.saved.generate + * + * @author jalc@google.com (Jose Alcérreca) + * + */ +public class GenerateSavedReport { + + static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param savedReportId the saved report ID on which to run the report. + * @throws Exception + */ + public static void run(AdSense adsense, String savedReportId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Running saved report %s\n", savedReportId); + System.out.println("================================================================="); + + // Prepare report. + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DATE, -7); + Generate request = adsense.reports().saved().generate(savedReportId); + + // Run saved report. + AdsenseReportsGenerateResponse response = request.execute(); + + if (response.getRows() != null && !response.getRows().isEmpty()) { + // Display headers. + for (AdsenseReportsGenerateResponse.Headers header : response.getHeaders()) { + System.out.printf("%25s", header.getName()); + } + System.out.println(); + + // Display results. + for (List row : response.getRows()) { + for (String column : row) { + System.out.printf("%25s", column); + } + System.out.println(); + } + + System.out.println(); + } else { + System.out.println("No rows returned."); + } + + System.out.println(); + } + + /** + * Escape special characters for a parameter being used in a filter.new. + * + * @param parameter the parameter to be escaped. + * @return the escaped parameter. + */ + public static String escapeFilterParameter(String parameter) { + return parameter.replace("\\", "\\\\").replace(",", "\\,"); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAccountTree.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAccountTree.java new file mode 100644 index 00000000..6b8a1dca --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAccountTree.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.Account; + +import java.util.List; + +/** +* +* This example gets a specific account for the logged in user. +* This includes the full tree of sub-accounts. +* +* Tags: accounts.get +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAccountTree { + + /** + * Auxiliary method to recurse through the account tree, displaying it. + * @param parentAccount the account to be print a sub-tree for. + * @param level the depth at which the top account exists in the tree. + */ + private static void displayTree(Account parentAccount, int level) { + for (int i = 0; i < level; i++) { + System.out.print(" "); + } + System.out.printf("Account with ID \"%s\" and name \"%s\" was found.\n", parentAccount.getId(), + parentAccount.getName()); + + List subAccounts = parentAccount.getSubAccounts(); + + if (subAccounts != null && !subAccounts.isEmpty()) { + for (Account subAccount : subAccounts) { + displayTree(subAccount, level + 1); + } + } + } + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param accountId the ID for the account to be used. + * @throws Exception + */ + public static void run(AdSense adsense, String accountId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Displaying AdSense account tree for %s\n", accountId); + System.out.println("================================================================="); + + // Retrieve account. + Account account = adsense.accounts().get(accountId).setTree(true).execute(); + displayTree(account, 0); + + System.out.println(); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAccounts.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAccounts.java new file mode 100644 index 00000000..a8bfa355 --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAccounts.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.Account; +import com.google.api.services.adsense.model.Accounts; + +/** + * + * This example gets all accounts for the logged in user. + * + * Tags: accounts.list + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GetAllAccounts { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of retrieved accounts. + * @throws Exception + */ + public static Accounts run(AdSense adsense, int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all AdSense accounts"); + System.out.println("================================================================="); + + // Retrieve account list in pages and display data as we receive it. + String pageToken = null; + Accounts accounts = null; + do { + accounts = adsense.accounts().list() + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (accounts.getItems() != null && !accounts.getItems().isEmpty()) { + for (Account account : accounts.getItems()) { + System.out.printf("Account with ID \"%s\" and name \"%s\" was found.\n", + account.getId(), account.getName()); + } + } else { + System.out.println("No accounts found."); + } + + pageToken = accounts.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + return accounts; + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdClients.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdClients.java new file mode 100644 index 00000000..dae69e7a --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdClients.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.AdClient; +import com.google.api.services.adsense.model.AdClients; + +/** +* +* This example gets all ad clients for the logged in user's default account. +* +* Tags: adclients.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllAdClients { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of retrieved ad clients. + * @throws Exception + */ + public static AdClients run(AdSense adsense, int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all ad clients for default account"); + System.out.println("================================================================="); + + // Retrieve ad client list in pages and display data as we receive it. + String pageToken = null; + AdClients adClients = null; + do { + adClients = adsense.adclients().list() + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (adClients.getItems() != null && !adClients.getItems().isEmpty()) { + for (AdClient adClient : adClients.getItems()) { + System.out.printf("Ad client for product \"%s\" with ID \"%s\" was found.\n", + adClient.getProductCode(), adClient.getId()); + System.out.printf("\tSupports reporting: %s\n", + adClient.getSupportsReporting() ? "Yes" : "No"); + } + } else { + System.out.println("No ad clients found."); + } + + pageToken = adClients.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + + // Return the last page of ad clients, so that the main sample has something to run. + return adClients; + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdClientsForAccount.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdClientsForAccount.java new file mode 100644 index 00000000..76081470 --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdClientsForAccount.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.AdClient; +import com.google.api.services.adsense.model.AdClients; + +/** +* +* This example gets all ad clients for an account. +* +* Tags: accounts.adclients.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllAdClientsForAccount { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param accountId the ID for the account to be used. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdSense adsense, String accountId, int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all ad clients for account %s\n", accountId); + System.out.println("================================================================="); + + // Retrieve ad client list in pages and display data as we receive it. + String pageToken = null; + AdClients adClients = null; + do { + adClients = adsense.accounts().adclients().list(accountId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (adClients.getItems() != null && !adClients.getItems().isEmpty()) { + for (AdClient adClient : adClients.getItems()) { + System.out.printf("Ad client for product \"%s\" with ID \"%s\" was found.\n", + adClient.getProductCode(), adClient.getId()); + System.out.printf("\tSupports reporting: %s\n", + adClient.getSupportsReporting() ? "Yes" : "No"); + } + } else { + System.out.println("No ad clients found."); + } + + pageToken = adClients.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdUnits.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdUnits.java new file mode 100644 index 00000000..b5b83c3b --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdUnits.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.AdUnit; +import com.google.api.services.adsense.model.AdUnits; + +/** +* +* This example gets all ad units in an ad client. +* +* Tags: adunits.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllAdUnits { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of ad units. + * @throws Exception + */ + public static AdUnits run(AdSense adsense, String adClientId, int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all ad units for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Retrieve ad unit list in pages and display data as we receive it. + String pageToken = null; + AdUnits adUnits = null; + do { + adUnits = adsense.adunits().list(adClientId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (adUnits.getItems() != null && !adUnits.getItems().isEmpty()) { + for (AdUnit unit : adUnits.getItems()) { + System.out.printf("Ad unit with code \"%s\", name \"%s\" and status \"%s\" was found.\n", + unit.getCode(), unit.getName(), unit.getStatus()); + } + } else { + System.out.println("No ad units found."); + } + + pageToken = adUnits.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + + // Return the last page of ad units, so that the main sample has something to run. + return adUnits; + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdUnitsForCustomChannel.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdUnitsForCustomChannel.java new file mode 100644 index 00000000..3d8cc5ff --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAdUnitsForCustomChannel.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.AdUnit; +import com.google.api.services.adsense.model.AdUnits; + +/** +* +* This example gets all ad units corresponding to a specified custom channel. +* +* Tags: customchannels.adunits.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllAdUnitsForCustomChannel { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param customChannelId the ID for the custom channel to be used. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdSense adsense, String adClientId, String customChannelId, + int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all ad units for custom channel %s\n", customChannelId); + System.out.println("================================================================="); + + // Retrieve ad unit list in pages and display data as we receive it. + String pageToken = null; + do { + AdUnits adUnits = adsense.customchannels().adunits().list(adClientId, customChannelId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (adUnits.getItems() != null && !adUnits.getItems().isEmpty()) { + for (AdUnit unit : adUnits.getItems()) { + System.out.printf("Ad unit with code \"%s\", name \"%s\" and status \"%s\" was found.\n", + unit.getCode(), unit.getName(), unit.getStatus()); + } + } else { + System.out.println("No ad units found."); + } + + pageToken = adUnits.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAlerts.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAlerts.java new file mode 100644 index 00000000..ed4634ce --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllAlerts.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.Alert; +import com.google.api.services.adsense.model.Alerts; + +/** +* +* Gets all alerts available for the logged in user's default account. +* +* Tags: alerts.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllAlerts { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @throws Exception + */ + public static void run(AdSense adsense) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all alerts for default account"); + System.out.println("================================================================="); + + // Retrieve and display alerts. + Alerts alerts = adsense.alerts().list().execute(); + + if (alerts.getItems() != null && !alerts.getItems().isEmpty()) { + for (Alert alert : alerts.getItems()) { + System.out.printf("Alert id \"%s\" with severity \"%s\" and type \"%s\" was found.\n", + alert.getId(), alert.getSeverity(), alert.getType()); + } + } else { + System.out.println("No alerts found."); + } + + System.out.println(); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllCustomChannels.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllCustomChannels.java new file mode 100644 index 00000000..5dba250d --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllCustomChannels.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.CustomChannel; +import com.google.api.services.adsense.model.CustomChannels; + +/** +* +* This example gets all custom channels in an ad client. +* +* Tags: customchannels.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllCustomChannels { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of custom channels. + * @throws Exception + */ + public static CustomChannels run(AdSense adsense, String adClientId, int maxPageSize) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all custom channels for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Retrieve custom channel list in pages and display the data as we receive it. + String pageToken = null; + CustomChannels customChannels = null; + do { + customChannels = adsense.customchannels().list(adClientId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (customChannels.getItems() != null && !customChannels.getItems().isEmpty()) { + for (CustomChannel channel : customChannels.getItems()) { + System.out.printf("Custom channel with code \"%s\" and name \"%s\" was found.\n", + channel.getCode(), channel.getName()); + } + } else { + System.out.println("No custom channels found."); + } + + pageToken = customChannels.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + return customChannels; + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllCustomChannelsForAdUnit.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllCustomChannelsForAdUnit.java new file mode 100644 index 00000000..4062994c --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllCustomChannelsForAdUnit.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.CustomChannel; +import com.google.api.services.adsense.model.CustomChannels; + +/** +* +* This example gets all custom channels an ad unit has been added to. +* +* Tags: adunits.customchannels.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllCustomChannelsForAdUnit { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param adUnitId the ID for the ad unit to be used. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdSense adsense, String adClientId, String adUnitId, + int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all custom channels for ad unit %s\n", adUnitId); + System.out.println("================================================================="); + + // Retrieve custom channel list in pages and display the data as we receive it. + String pageToken = null; + do { + CustomChannels customChannels = adsense.adunits().customchannels().list(adClientId, adUnitId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (customChannels.getItems() != null && !customChannels.getItems().isEmpty()) { + for (CustomChannel channel : customChannels.getItems()) { + System.out.printf("Custom channel with code \"%s\" and name \"%s\" was found.\n", + channel.getCode(), channel.getName()); + } + } else { + System.out.println("No custom channels found."); + } + + pageToken = customChannels.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllDimensions.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllDimensions.java new file mode 100644 index 00000000..8237a187 --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllDimensions.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.Metadata; +import com.google.api.services.adsense.model.ReportingMetadataEntry; + +/** +* +* Gets all dimensions available for the logged in user's default account. +* +* Tags: metadata.dimensions.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllDimensions { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @throws Exception + */ + public static void run(AdSense adsense) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all dimensions for default account"); + System.out.println("================================================================="); + + // Retrieve and display dimensions. + Metadata dimensions = adsense.metadata().dimensions().list().execute(); + + if (dimensions.getItems() != null && !dimensions.getItems().isEmpty()) { + for (ReportingMetadataEntry dimension : dimensions.getItems()) { + boolean firstProduct = true; + StringBuilder products = new StringBuilder(); + for (String product : dimension.getSupportedProducts()) { + if (!firstProduct) { + products.append(", "); + } + products.append(product); + firstProduct = false; + } + System.out.printf("Dimension id \"%s\" for product(s): [%s] was found.\n", + dimension.getId(), products.toString()); + } + } else { + System.out.println("No dimensions found."); + } + + System.out.println(); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllMetrics.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllMetrics.java new file mode 100644 index 00000000..1bab2a5f --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllMetrics.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2013 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.Metadata; +import com.google.api.services.adsense.model.ReportingMetadataEntry; + +/** +* +* Gets all metrics available for the logged in user's default account. +* +* Tags: metadata.metrics.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllMetrics { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @throws Exception + */ + public static void run(AdSense adsense) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all metrics for default account"); + System.out.println("================================================================="); + + // Retrieve and display metrics. + Metadata metrics = adsense.metadata().metrics().list().execute(); + + if (metrics.getItems() != null && !metrics.getItems().isEmpty()) { + for (ReportingMetadataEntry metric : metrics.getItems()) { + boolean firstProduct = true; + StringBuilder products = new StringBuilder(); + for (String product : metric.getSupportedProducts()) { + if (!firstProduct) { + products.append(", "); + } + products.append(product); + firstProduct = false; + } + System.out.printf("Metric id \"%s\" for product(s): [%s] was found.\n", + metric.getId(), products.toString()); + } + } else { + System.out.println("No metrics found."); + } + + System.out.println(); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllSavedAdStyles.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllSavedAdStyles.java new file mode 100644 index 00000000..3257a864 --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllSavedAdStyles.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.SavedAdStyle; +import com.google.api.services.adsense.model.SavedAdStyles; + +/** + * + * This example gets all saved ad styles for the default account. + * + * Tags: savedadstyles.list + * + * @author jalc@google.com (Jose Alcérreca) + * + */ +public class GetAllSavedAdStyles { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of ad styles. + * @throws Exception + */ + public static SavedAdStyles run(AdSense adsense, int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all saved ad styles for default account\n"); + System.out.println("================================================================="); + + // Retrieve saved ad style list and display the data as we receive it. + String pageToken = null; + SavedAdStyles savedAdStyles = null; + do { + savedAdStyles = adsense.savedadstyles() + .list() + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (savedAdStyles.getItems() != null && !savedAdStyles.getItems().isEmpty()) { + for (SavedAdStyle savedAdStyle : savedAdStyles.getItems()) { + System.out.printf("Saved ad style with name \"%s\" was found.\n", savedAdStyle.getName()); + } + } else { + System.out.println("No saved ad styles found."); + } + + pageToken = savedAdStyles.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + return savedAdStyles; + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllSavedReports.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllSavedReports.java new file mode 100644 index 00000000..64673a6c --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllSavedReports.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.SavedReport; +import com.google.api.services.adsense.model.SavedReports; + +/** + * + * This example gets all saved reports for an account. + * + * Tags: reports.saved.list + * + * @author jalc@google.com (Jose Alcérreca) + * + */ +public class GetAllSavedReports { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of saved reports. + * @throws Exception + */ + public static SavedReports run(AdSense adsense, int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all saved reports for default account\n"); + System.out.println("================================================================="); + + // Retrieve saved report list in pages and display the data as we receive it. + String pageToken = null; + SavedReports savedReports = null; + do { + savedReports = adsense.reports() + .saved() + .list() + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (savedReports.getItems() != null && !savedReports.getItems().isEmpty()) { + for (SavedReport savedReport : savedReports.getItems()) { + System.out.printf("Saved report with id \"%s\" and name \"%s\" was found.\n", + savedReport.getId(), savedReport.getName()); + } + } else { + System.out.println("No saved reports found."); + } + + pageToken = savedReports.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + return savedReports; + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllUrlChannels.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllUrlChannels.java new file mode 100644 index 00000000..09f50bd7 --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GetAllUrlChannels.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2011 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.api.services.samples.adsense.cmdline; + +import com.google.api.services.adsense.AdSense; +import com.google.api.services.adsense.model.UrlChannel; +import com.google.api.services.adsense.model.UrlChannels; + +/** +* +* This example gets all URL channels in an ad client. +* +* Tags: urlchannels.list +* +* @author sgomes@google.com (Sérgio Gomes) +* +*/ +public class GetAllUrlChannels { + + /** + * Runs this sample. + * + * @param adsense AdSense service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdSense adsense, String adClientId, int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all URL channels for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Retrieve URL channel list in pages and display the data as we receive it. + String pageToken = null; + do { + UrlChannels urlChannels = adsense.urlchannels().list(adClientId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if (urlChannels.getItems() != null && !urlChannels.getItems().isEmpty()) { + for (UrlChannel channel : urlChannels.getItems()) { + System.out.printf("URL channel with URL pattern \"%s\" was found.\n", + channel.getUrlPattern()); + } + } else { + System.out.println("No URL channels found."); + } + + pageToken = urlChannels.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + } +} diff --git a/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/HandleAccountErrors.java b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/HandleAccountErrors.java new file mode 100644 index 00000000..a20a5a7c --- /dev/null +++ b/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/HandleAccountErrors.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2012 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.api.services.samples.adsense.cmdline; + +import com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo; +import com.google.api.client.googleapis.json.GoogleJsonResponseException; +import com.google.api.services.adsense.AdSense; + +import java.util.List; + +/** + * + * This example shows how to handle different AdSense account errors. + * + * Tags: adclients.list + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class HandleAccountErrors { + + /** + * Runs this sample. + * + * @param service AdSense service object on which to run the requests. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdSense service, int maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.println("Testing error handling"); + System.out.println("================================================================="); + + try { + // Attempt API call. + service.adclients().list().setMaxResults(maxPageSize).execute(); + + System.out.println("The call succeeded. Please use an invalid, disapproved or " + + "approval-pending AdSense account to test error handling."); + + System.out.println(); + } catch (GoogleJsonResponseException e) { + // Handle a few known API errors. See full list at + // https://developers.google.com/adsense/management/v1.1/reference/#errors + List errors = e.getDetails().getErrors(); + for (ErrorInfo error : errors) { + if (error.getReason().equals("noAdSenseAccount")) { + System.out.println("Error handled! No AdSense account for this user."); + } else if (error.getReason().equals("disapprovedAccount")) { + System.out.println("Error handled! This account is disapproved."); + } else if (error.getReason().equals("accountPendingReview")) { + System.out.println("Error handled! This account is pending review."); + } else { + // Unrecognized reason, so let's use the error message returned by the API. + System.out.println("Unrecognized error, showing system message:"); + System.out.println(error.getMessage()); + } + } + } + } +} diff --git a/adsense-cmdline-sample/src/main/resources/client_secrets.json b/adsense-cmdline-sample/src/main/resources/client_secrets.json new file mode 100644 index 00000000..e448bab9 --- /dev/null +++ b/adsense-cmdline-sample/src/main/resources/client_secrets.json @@ -0,0 +1,6 @@ +{ + "installed": { + "client_id": "Enter Client ID", + "client_secret": "Enter Client Secret" + } +} diff --git a/adsensehost-cmdline-sample/.classpath b/adsensehost-cmdline-sample/.classpath new file mode 100644 index 00000000..4b980c56 --- /dev/null +++ b/adsensehost-cmdline-sample/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/adsensehost-cmdline-sample/.project b/adsensehost-cmdline-sample/.project new file mode 100644 index 00000000..b07704d0 --- /dev/null +++ b/adsensehost-cmdline-sample/.project @@ -0,0 +1,23 @@ + + + adsensehost-cmdline-sample + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/adsensehost-cmdline-sample/.settings/org.eclipse.jdt.core.prefs b/adsensehost-cmdline-sample/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..faf086f4 --- /dev/null +++ b/adsensehost-cmdline-sample/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,380 @@ +#Fri Nov 04 10:10:38 EDT 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.annotationSuperInterface=ignore +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_member=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=24 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=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|5|48 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_field_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_for_statement=16 +org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments=16 +org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16|5|80 +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|4|49 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16|4|48 +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=false +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=100 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph=true +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.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.force_if_else_statement_brace=true +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +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_field=insert +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_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=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_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=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=do not 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.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +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=100 +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.sort_local_variable_annotations=false +org.eclipse.jdt.core.formatter.sort_member_annotations=false +org.eclipse.jdt.core.formatter.sort_package_annotations=false +org.eclipse.jdt.core.formatter.sort_parameter_annotations=false +org.eclipse.jdt.core.formatter.sort_type_annotations=false +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_comment_inline_tags=false +org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation=false +org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments=false diff --git a/adsensehost-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs b/adsensehost-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..2413e100 --- /dev/null +++ b/adsensehost-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,119 @@ +#Fri Nov 04 10:06:25 EDT 2011 +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=true +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=true +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_google-api-java-client +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false +formatter_profile=_google-api-java-client 100 +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=exception +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=com;org;;java;javax; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=999 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=999 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=false +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/adsensehost-cmdline-sample/AdSenseHostSample.launch b/adsensehost-cmdline-sample/AdSenseHostSample.launch new file mode 100644 index 00000000..aa6f23de --- /dev/null +++ b/adsensehost-cmdline-sample/AdSenseHostSample.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/adsensehost-cmdline-sample/instructions.html b/adsensehost-cmdline-sample/instructions.html new file mode 100644 index 00000000..91c60b6d --- /dev/null +++ b/adsensehost-cmdline-sample/instructions.html @@ -0,0 +1,103 @@ + +adsensehost-cmdline-sample + +

Instructions for the AdSense Host API V4.1 Command-Line Sample

+ +

Browse Online

+ + + +

Register Your Application

+ +
    +
  • Visit the Google Cloud + console. +
  • +
  • If necessary, sign in to your Google Account, select or create a project, + and agree to the terms of service. Click Continue.
  • +
  • Select "Installed application" and choose type "Other" under the Installed Application type.
  • +
  • Within "OAuth 2.0 Client ID", click on "Download JSON". Later on, after you check + out the sample project, you will copy this downloaded file (e.g. + ~/Downloads/client_secrets.json) to + src/main/resources/client_secrets.json. + If you skip this step, when trying to run the sample you will get a 400 + INVALID_CLIENT error in the browser. +
  • +
+ +

Checkout Instructions

+ +

+ Prerequisites: install Java 6, Mercurial, and Maven. You may need to + set your + JAVA_HOME + . +

+ +
+cd [someDirectory]
+hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
+cd google-api-java-client-samples/adsensehost-cmdline-sample
+[editor] src/main/resources/client_secrets.json
+[editor] src/main/java/com/google/api/services/samples/adsensehost/cmdline/AdSenseHostSample.java
+(Set PUB_ACCOUNT_ID to your publisher account ID if you want the
+publisher samples to run)
+mvn compile
+mvn -q exec:java
+  
+ +

Setup Project in Eclipse

+ +

To enable logging of HTTP requests and responses (highly recommended + when developing), please take a look at logging.properties.

+ +

+ Prerequisites: install Eclipse, + the Mercurial plugin, and the + Maven + plugin. +

+ +
    +
  • Setup Eclipse Preferences +
      +
    • Window > Preferences... (or on Mac, Eclipse > + Preferences...)
    • +
    • Select Maven +
        +
      • check on "Download Artifact Sources"
      • +
      • check on "Download Artifact JavaDoc"
      • +
      +
    • +
    +
  • +
  • Import adsensehost-cmdline-sample project +
      +
    • File > Import...
    • +
    • Select "General > Existing Project into Workspace" and click + "Next"
    • +
    • Click "Browse" next to "Select root directory", find + [someDirectory]/google-api-java-client-samples/adsensehost-cmdline-sample + and click "Next" +
    • +
    • Click "Finish"
    • +
    +
  • +
  • Run +
      +
    • Right-click on project adsensehost-cmdline-sample
    • +
    • Run As > Java Application
    • +
    • If asked, type "AdSenseHostSample" and click OK
    • +
    +
  • +
+ + + diff --git a/adsensehost-cmdline-sample/logging.properties b/adsensehost-cmdline-sample/logging.properties new file mode 100644 index 00000000..1c97e313 --- /dev/null +++ b/adsensehost-cmdline-sample/logging.properties @@ -0,0 +1,10 @@ +# Properties file which configures the operation of the JDK logging facility. +# The system will look for this config file to be specified as a system property: +# -Djava.util.logging.config.file=${project_loc:adsense-cmdline-sample}/logging.properties + +# Set up the console handler (uncomment "level" to show more fine-grained messages) +handlers = java.util.logging.ConsoleHandler +#java.util.logging.ConsoleHandler.level = CONFIG + +# Set up logging of HTTP requests and responses (uncomment "level" to show) +#com.google.api.client.http.level = CONFIG diff --git a/adsensehost-cmdline-sample/pom.xml b/adsensehost-cmdline-sample/pom.xml new file mode 100644 index 00000000..77c574e8 --- /dev/null +++ b/adsensehost-cmdline-sample/pom.xml @@ -0,0 +1,135 @@ + + 4.0.0 + + com.google + google + 5 + + com.google.apis-samples + adsensehost-cmdline-sample + 1 + Example for the AdSense Host API v4.1 using JSON and OAuth 2.0. + + http://code.google.com/p/google-api-java-client/ + + + code.google.com + http://code.google.com/p/google-api-java-client/issues/list + + + 2012 + + + 2.0.9 + + + + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + http://code.google.com/p/google-api-java-client/source/browse/?repo=samples + + + + + sgomes + Sergio Gomes + sgomes@google.com + Google + http://www.google.com + + owner + developer + + 0 + + + + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.codehaus.mojo + exec-maven-plugin + 1.1 + + + + java + + + + + com.google.api.services.samples.adsensehost.cmdline.AdSenseHostSample + + + java.util.logging.config.file + logging.properties + + + + + + maven-checkstyle-plugin + 2.6 + + ../checkstyle.xml + true + false + + + + + check + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + false + + + + + check + + + + + + ${project.artifactId}-${project.version} + + + + com.google.apis + google-api-services-adsensehost + v4.1-rev96-1.19.0 + + + com.google.http-client + google-http-client-jackson2 + ${project.http.version} + + + com.google.oauth-client + google-oauth-client-jetty + ${project.oauth.version} + + + + 1.19.0 + 1.19.0 + UTF-8 + + diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AdSenseHostSample.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AdSenseHostSample.java new file mode 100644 index 00000000..3e9a8ba1 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AdSenseHostSample.java @@ -0,0 +1,211 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp; +import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; +import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; +import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.javanet.NetHttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.util.store.DataStoreFactory; +import com.google.api.client.util.store.FileDataStoreFactory; +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.AdSenseHostScopes; +import com.google.api.services.adsensehost.model.AdClients; +import com.google.api.services.adsensehost.model.AdUnit; +import com.google.api.services.adsensehost.model.CustomChannel; +import com.google.api.services.adsensehost.model.UrlChannel; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; + +/** + * A sample application that runs multiple requests against the AdSense Host API. These include: + *
    + *
  • Getting a list of all host ad clients
  • + *
  • Getting a list of all host custom channels
  • + *
  • Adding a new host custom channel
  • + *
  • Updating an existing host custom channel
  • + *
  • Deleting a host custom channel
  • + *
  • Getting a list of all host URL channels
  • + *
  • Adding a new host URL channel
  • + *
  • Deleting an existing host URL channel
  • + *
  • Running a report for a host ad client, for the past 7 days
  • + *
+ * + * If you give PUB_ACCOUNT_ID a real account ID, the following requests will also run: + *
    + *
  • Getting a list of all publisher ad clients
  • + *
  • Getting a list of all publisher ad units
  • + *
  • Adding a new ad unit
  • + *
  • Updating an existing ad unit
  • + *
  • Deleting an ad unit
  • + *
  • Running a report for a publisher ad client, for the past 7 days
  • + *
+ * + * Other samples are included for illustration purposes, but won't be run: + *
    + *
  • Getting the account data for an existing publisher, given their ad client ID
  • + *
  • Starting an association session
  • + *
  • Verifying an association session
  • + *
+ */ +public class AdSenseHostSample { + + /** + * Be sure to specify the name of your application. If the application name is {@code null} or + * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0". + */ + private static final String APPLICATION_NAME = ""; + + /** Directory to store user credentials. */ + private static final java.io.File DATA_STORE_DIR = + new java.io.File(System.getProperty("user.home"), ".store/adsense_host_sample"); + + /** + * Global instance of the {@link DataStoreFactory}. The best practice is to make it a single + * globally shared instance across your application. + */ + private static FileDataStoreFactory DATA_STORE_FACTORY; + + // Global instance of the HTTP transport. + private static HttpTransport httpTransport; + + // Global instance of the JSON factory. + private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); + + // Maximum page size for list calls. + private static final long MAX_LIST_PAGE_SIZE = 50; + // Change this constant to an example publisher account ID if you want the + // publisher samples to run. + private static final String PUB_ACCOUNT_ID = "INSERT_CLIENT_PUB_ID_HERE"; + + /** Authorizes the installed application to access user's protected data. */ + private static Credential authorize() throws Exception { + // load client secrets + GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, + new InputStreamReader(AdSenseHostSample.class.getResourceAsStream("/client_secrets.json"))); + if (clientSecrets.getDetails().getClientId().startsWith("Enter") + || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { + System.out.println("Enter Client ID and Secret from " + + "https://code.google.com/apis/console/?api=adsensehost into " + + "adsensehost-cmdline-sample/src/main/resources/client_secrets.json"); + System.exit(1); + } + // set up authorization code flow + GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( + httpTransport, JSON_FACTORY, clientSecrets, + Collections.singleton(AdSenseHostScopes.ADSENSEHOST)).setDataStoreFactory( + DATA_STORE_FACTORY).build(); + // authorize + return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user"); + } + + /** + * Performs all necessary setup steps for running requests against the API. + * + * @return An initialized AdSenseHost service object. + * @throws Exception + */ + private static AdSenseHost initializeAdsensehost() throws Exception { + // Authorization. + Credential credential = authorize(); + + // Set up AdSense Host API client. + AdSenseHost adsensehost = new AdSenseHost.Builder( + new NetHttpTransport(), new JacksonFactory(), credential).setApplicationName( + APPLICATION_NAME).build(); + + return adsensehost; + } + + /** + * Returns a unique value based on the system time. + */ + public static String getUniqueName() { + return String.valueOf(System.currentTimeMillis()); + } + + /** + * Runs all the AdSense Host API samples. + * + * @param args command-line arguments. + */ + public static void main(String[] args) { + try { + httpTransport = GoogleNetHttpTransport.newTrustedTransport(); + DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR); + AdSenseHost service = initializeAdsensehost(); + + AdClients adClients = GetAllAdClientsForHost.run(service, MAX_LIST_PAGE_SIZE); + if ((adClients.getItems() != null) && !adClients.getItems().isEmpty()) { + // Get a host ad client ID, so we can run the rest of the samples. + String exampleHostAdClientId = adClients.getItems().get(0).getId(); + + GetAllCustomChannelsForHost.run(service, exampleHostAdClientId, MAX_LIST_PAGE_SIZE); + + CustomChannel customChannel = AddCustomChannelToHost.run(service, exampleHostAdClientId); + + customChannel = + UpdateCustomChannelOnHost.run(service, exampleHostAdClientId, customChannel.getId()); + + DeleteCustomChannelOnHost.run(service, exampleHostAdClientId, customChannel.getId()); + + GetAllUrlChannelsForHost.run(service, exampleHostAdClientId, MAX_LIST_PAGE_SIZE); + + UrlChannel urlChannel = AddUrlChannelToHost.run(service, exampleHostAdClientId); + + DeleteUrlChannelOnHost.run(service, exampleHostAdClientId, urlChannel.getId()); + + GenerateReportForHost.run(service, exampleHostAdClientId); + } else { + System.out.println("No host ad clients found, unable to run remaining host samples."); + } + + if (!PUB_ACCOUNT_ID.equals("INSERT_CLIENT_PUB_ID_HERE")) { + AdClients pubAdClients = + GetAllAdClientsForPublisher.run(service, PUB_ACCOUNT_ID, MAX_LIST_PAGE_SIZE); + if ((pubAdClients.getItems() != null) && !pubAdClients.getItems().isEmpty()) { + // Get a publisher ad client ID, so we can run the rest of the samples. + String examplePubAdClientId = pubAdClients.getItems().get(0).getId(); + + GetAllAdUnitsForPublisher.run( + service, PUB_ACCOUNT_ID, examplePubAdClientId, MAX_LIST_PAGE_SIZE); + + AdUnit adUnit = AddAdUnitToPublisher.run(service, PUB_ACCOUNT_ID, examplePubAdClientId); + + UpdateAdUnitOnPublisher.run( + service, PUB_ACCOUNT_ID, examplePubAdClientId, adUnit.getId()); + + DeleteAdUnitOnPublisher.run( + service, PUB_ACCOUNT_ID, examplePubAdClientId, adUnit.getId()); + + GenerateReportForPublisher.run(service, PUB_ACCOUNT_ID, examplePubAdClientId); + } else { + System.out.println( + "No publisher ad clients found, unable to run remaining publisher samples."); + } + } + } catch (IOException e) { + System.err.println(e.getMessage()); + } catch (Throwable t) { + t.printStackTrace(); + } + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AddAdUnitToPublisher.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AddAdUnitToPublisher.java new file mode 100644 index 00000000..f45acb3a --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AddAdUnitToPublisher.java @@ -0,0 +1,83 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.AdStyle; +import com.google.api.services.adsensehost.model.AdStyle.Colors; +import com.google.api.services.adsensehost.model.AdStyle.Font; +import com.google.api.services.adsensehost.model.AdUnit; +import com.google.api.services.adsensehost.model.AdUnit.ContentAdsSettings; +import com.google.api.services.adsensehost.model.AdUnit.ContentAdsSettings.BackupOption; + +/** + * + * This example adds a new ad unit to a publisher ad client. + * + * To get ad clients, see GetAllAdClientsForPublisher.java. + * + * Tags: accounts.adunits.insert + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class AddAdUnitToPublisher { + + /** + * Runs this sample. + * + * @param service AdSensehost service object on which to run the requests. + * @param accountId the ID for the publisher account to be used. + * @param adClientId the ID for the ad client to be used. + * @return the created ad unit. + * @throws Exception + */ + public static AdUnit run(AdSenseHost service, String accountId, String adClientId) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Adding ad unit to ad client %s\n", adClientId); + System.out.println("================================================================="); + + AdUnit newAdUnit = new AdUnit() + .setName("Ad Unit #" + AdSenseHostSample.getUniqueName()) + .setContentAdsSettings(new ContentAdsSettings() + .setBackupOption(new BackupOption() + .setType("COLOR") + .setColor("ffffff")) + .setSize("SIZE_200_200") + .setType("TEXT")) + .setCustomStyle(new AdStyle() + .setColors(new Colors() + .setBackground("ffffff") + .setBorder("000000") + .setText("000000") + .setTitle("000000") + .setUrl("0000ff")) + .setCorners("SQUARE") + .setFont(new Font() + .setFamily("ACCOUNT_DEFAULT_FAMILY") + .setSize("ACCOUNT_DEFAULT_SIZE"))); + + // Create ad unit. + AdUnit adUnit = service.accounts().adunits().insert(accountId, adClientId, newAdUnit) + .execute(); + + System.out.printf("Ad unit of type \"%s\", name \"%s\" and status \"%s\" was created.\n", + adUnit.getContentAdsSettings().getType(), adUnit.getName(), adUnit.getStatus()); + + System.out.println(); + + // Return the created ad unit. + return adUnit; + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AddCustomChannelToHost.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AddCustomChannelToHost.java new file mode 100644 index 00000000..8a4d1cc9 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AddCustomChannelToHost.java @@ -0,0 +1,60 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.CustomChannel; + +/** + * + * This example adds a custom channel to a host ad client. + * + * To get ad clients, see GetAllAdClientsForHost.java. + * + * Tags: customchannels.insert + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class AddCustomChannelToHost { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @return the created custom channel. + * @throws Exception + */ + public static CustomChannel run(AdSenseHost service, String adClientId) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Adding custom channel to ad client %s\n", adClientId); + System.out.println("================================================================="); + + CustomChannel newCustomChannel = new CustomChannel() + .setName("Sample Channel #" + AdSenseHostSample.getUniqueName()); + + // Create custom channel. + CustomChannel customChannel = service.customchannels().insert(adClientId, newCustomChannel) + .execute(); + + System.out.printf("Custom channel with id \"%s\", code \"%s\" and name \"%s\" was created.\n", + customChannel.getId(), customChannel.getCode(), customChannel.getName()); + + System.out.println(); + + // Return the created custom channel. + return customChannel; + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AddUrlChannelToHost.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AddUrlChannelToHost.java new file mode 100644 index 00000000..e06d6cf9 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/AddUrlChannelToHost.java @@ -0,0 +1,60 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.UrlChannel; + +/** + * + * This example adds a URL channel to a host ad client. + * + * To get ad clients, see GetAllAdClientsForHost.java. + * + * Tags: urlchannels.insert + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class AddUrlChannelToHost { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @return the created URL channel. + * @throws Exception + */ + public static UrlChannel run(AdSenseHost service, String adClientId) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Adding URL channel to ad client %s\n", adClientId); + System.out.println("================================================================="); + + UrlChannel newUrlChannel = new UrlChannel() + .setUrlPattern("www.example.com/" + AdSenseHostSample.getUniqueName()); + + // Create URL channel. + UrlChannel urlChannel = service.urlchannels().insert(adClientId, newUrlChannel) + .execute(); + + System.out.printf("URL channel with id \"%s\" and URL pattern \"%s\" was created.\n", + urlChannel.getId(), urlChannel.getUrlPattern()); + + System.out.println(); + + // Return the created URL channel. + return urlChannel; + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/DeleteAdUnitOnPublisher.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/DeleteAdUnitOnPublisher.java new file mode 100644 index 00000000..4e7c359e --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/DeleteAdUnitOnPublisher.java @@ -0,0 +1,54 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.AdUnit; + +/** + * + * This example deletes an ad unit on a publisher ad client. + * + * To get ad clients, see GetAllAdClientsForPublisher.java. + * To get ad units, see GetAllAdUnitsForPublisher.java. + * + * Tags: accounts.adunits.delete + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class DeleteAdUnitOnPublisher { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param accountId the ID for the publisher account to be used. + * @param adClientId the ID for the ad client to be used. + * @param adUnitId the ID of the ad unit to be deleted. + * @throws Exception + */ + public static void run(AdSenseHost service, String accountId, String adClientId, + String adUnitId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Deleting ad unit %s\n", adUnitId); + System.out.println("================================================================="); + + // Delete ad unit. + AdUnit adUnit = service.accounts().adunits().delete(accountId, adClientId, adUnitId).execute(); + + System.out.printf("Ad unit with id \"%s\" was deleted.\n", adUnit.getId()); + + System.out.println(); + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/DeleteCustomChannelOnHost.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/DeleteCustomChannelOnHost.java new file mode 100644 index 00000000..b95da949 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/DeleteCustomChannelOnHost.java @@ -0,0 +1,54 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.CustomChannel; + +/** + * + * This example deletes a custom channel on a host ad client. + * + * To get ad clients, see GetAllAdClientsForPublisher.java. + * To get custom channels, see GetAllCustomChannelsForHost.java. + * + * Tags: customchannels.delete + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class DeleteCustomChannelOnHost { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param customChannelId the ID of the custom channel to be deleted. + * @throws Exception + */ + public static void run(AdSenseHost service, String adClientId, + String customChannelId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Deleting custom channel %s\n", customChannelId); + System.out.println("================================================================="); + + // Delete custom channel. + CustomChannel customChannel = + service.customchannels().delete(adClientId, customChannelId).execute(); + + System.out.printf("Custom channel with ID \"%s\" was deleted.\n", customChannel.getId()); + + System.out.println(); + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/DeleteUrlChannelOnHost.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/DeleteUrlChannelOnHost.java new file mode 100644 index 00000000..3c1d2778 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/DeleteUrlChannelOnHost.java @@ -0,0 +1,53 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.UrlChannel; + +/** + * + * This example deletes a URL channel on a host ad client. + * + * To get ad clients, see GetAllAdClientsForPublisher.java. + * To get custom channels, see GetAllUrlChannelsForHost.java. + * + * Tags: urlchannels.delete + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class DeleteUrlChannelOnHost { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param urlChannelId the ID of the URL channel to be deleted. + * @throws Exception + */ + public static void run(AdSenseHost service, String adClientId, + String urlChannelId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Deleting URL channel %s\n", urlChannelId); + System.out.println("================================================================="); + + // Delete URL channel. + UrlChannel urlChannel = service.urlchannels().delete(adClientId, urlChannelId).execute(); + + System.out.printf("URL channel with ID \"%s\" was deleted.\n", urlChannel.getId()); + + System.out.println(); + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GenerateReportForHost.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GenerateReportForHost.java new file mode 100644 index 00000000..3aeece36 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GenerateReportForHost.java @@ -0,0 +1,106 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.AdSenseHost.Reports.Generate; +import com.google.api.services.adsensehost.model.Report; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * This example retrieves a report, using a filter for a specified ad client. + * + * Tags: reports.generate + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GenerateReportForHost { + + static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param adClientId the ID of the ad client on which to run the report. + * @throws Exception + */ + public static void run(AdSenseHost service, String adClientId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Running report for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Prepare report. + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DATE, -7); + Date oneWeekAgo = calendar.getTime(); + + String startDate = DATE_FORMATTER.format(oneWeekAgo); + String endDate = DATE_FORMATTER.format(today); + Generate request = service.reports().generate(startDate, endDate); + + // Specify the desired ad client using a filter. + request.setFilter(Arrays.asList("AD_CLIENT_ID==" + escapeFilterParameter(adClientId))); + + request.setMetric(Arrays.asList("PAGE_VIEWS", "AD_REQUESTS", "AD_REQUESTS_COVERAGE", "CLICKS", + "AD_REQUESTS_CTR", "COST_PER_CLICK", "AD_REQUESTS_RPM", "EARNINGS")); + request.setDimension(Arrays.asList("DATE")); + + // Sort by ascending date. + request.setSort(Arrays.asList("+DATE")); + + // Run report. + Report response = request.execute(); + + if ((response.getRows() != null) && !response.getRows().isEmpty()) { + // Display headers. + for (Report.Headers header : response.getHeaders()) { + System.out.printf("%25s", header.getName()); + } + System.out.println(); + + // Display results. + for (List row : response.getRows()) { + for (String column : row) { + System.out.printf("%25s", column); + } + System.out.println(); + } + + System.out.println(); + } else { + System.out.println("No rows returned."); + } + + System.out.println(); + } + + /** + * Escape special characters for a parameter being used in a filter. + * + * @param parameter the parameter to be escaped. + * @return the escaped parameter. + */ + public static String escapeFilterParameter(String parameter) { + return parameter.replace("\\", "\\\\").replace(",", "\\,"); + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GenerateReportForPublisher.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GenerateReportForPublisher.java new file mode 100644 index 00000000..8b4db9a6 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GenerateReportForPublisher.java @@ -0,0 +1,114 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.AdSenseHost.Accounts.Reports.Generate; +import com.google.api.services.adsensehost.model.Report; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * This example retrieves a report for the specified publisher ad client. + * + * Note that the statistics returned in these reports only include data from ad + * units created with the AdSense Host API v4.x. + * + * To create ad units, see AddAdUnitToPublisher.java. + * To get ad clients, see GetAllAdClientsForPublisher.java. + * + * Tags: accounts.reports.generate + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GenerateReportForPublisher { + + static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param accountId the ID of the publisher account on which to run the report. + * @param adClientId the ID of the ad client on which to run the report. + * @throws Exception + */ + public static void run(AdSenseHost service, String accountId, String adClientId) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Running report for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Prepare report. + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DATE, -7); + Date oneWeekAgo = calendar.getTime(); + + String startDate = DATE_FORMATTER.format(oneWeekAgo); + String endDate = DATE_FORMATTER.format(today); + Generate request = service.accounts().reports().generate(accountId, startDate, endDate); + + // Specify the desired ad client using a filter. + request.setFilter(Arrays.asList("AD_CLIENT_ID==" + escapeFilterParameter(adClientId))); + + request.setMetric(Arrays.asList("PAGE_VIEWS", "AD_REQUESTS", "AD_REQUESTS_COVERAGE", "CLICKS", + "AD_REQUESTS_CTR", "COST_PER_CLICK", "AD_REQUESTS_RPM", "EARNINGS")); + request.setDimension(Arrays.asList("DATE")); + + // Sort by ascending date. + request.setSort(Arrays.asList("+DATE")); + + // Run report. + Report response = request.execute(); + + if ((response.getRows() != null) && !response.getRows().isEmpty()) { + // Display headers. + for (Report.Headers header : response.getHeaders()) { + System.out.printf("%25s", header.getName()); + } + System.out.println(); + + // Display results. + for (List row : response.getRows()) { + for (String column : row) { + System.out.printf("%25s", column); + } + System.out.println(); + } + + System.out.println(); + } else { + System.out.println("No rows returned."); + } + + System.out.println(); + } + + /** + * Escape special characters for a parameter being used in a filter. + * + * @param parameter the parameter to be escaped. + * @return the escaped parameter. + */ + public static String escapeFilterParameter(String parameter) { + return parameter.replace("\\", "\\\\").replace(",", "\\,"); + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAccountDataForExistingPublisher.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAccountDataForExistingPublisher.java new file mode 100644 index 00000000..9031caf4 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAccountDataForExistingPublisher.java @@ -0,0 +1,60 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.Account; +import com.google.api.services.adsensehost.model.Accounts; + +import java.util.Arrays; + +/** + * + * This example finds the account data for a publisher from their ad client ID. + * + * Tags: accounts.list + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GetAccountDataForExistingPublisher { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param adClientId the publisher ad client ID for which to get account data. + * @return the retrieved account info. + * @throws Exception + */ + public static Accounts run(AdSenseHost service, String adClientId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing publisher account for \"%s\"\n", adClientId); + System.out.println("================================================================="); + + // Retrieve account data. + Accounts accounts = service.accounts().list(Arrays.asList(adClientId)).execute(); + + if ((accounts.getItems() != null) && !accounts.getItems().isEmpty()) { + for (Account account : accounts.getItems()) { + System.out.printf("Account with ID \"%s\", name \"%s\" and status \"%s\" was found.\n", + account.getId(), account.getName(), account.getStatus()); + } + } else { + System.out.println("No accounts found."); + } + + System.out.println(); + return accounts; + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllAdClientsForHost.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllAdClientsForHost.java new file mode 100644 index 00000000..864dc098 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllAdClientsForHost.java @@ -0,0 +1,71 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.AdClient; +import com.google.api.services.adsensehost.model.AdClients; + +/** + * + * This example gets all ad clients for the host. + * + * Tags: adclients.list + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GetAllAdClientsForHost { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of retrieved host ad clients. + * @throws Exception + */ + public static AdClients run(AdSenseHost service, long maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.println("Listing all ad clients for host account"); + System.out.println("================================================================="); + + // Retrieve ad client list in pages and display data as we receive it. + String pageToken = null; + AdClients adClients = null; + do { + adClients = service.adclients().list() + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if ((adClients.getItems() != null) && !adClients.getItems().isEmpty()) { + for (AdClient adClient : adClients.getItems()) { + System.out.printf("Ad client for product \"%s\" with ID \"%s\" was found.\n", + adClient.getProductCode(), adClient.getId()); + System.out.printf("\tSupports reporting: %s\n", + adClient.getSupportsReporting() ? "Yes" : "No"); + } + } else { + System.out.println("No ad clients found."); + } + + pageToken = adClients.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + + // Return the last page of ad clients, so that the main sample has something to run. + return adClients; + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllAdClientsForPublisher.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllAdClientsForPublisher.java new file mode 100644 index 00000000..97a13055 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllAdClientsForPublisher.java @@ -0,0 +1,72 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.AdClient; +import com.google.api.services.adsensehost.model.AdClients; + +/** + * + * This example gets all ad clients for a publisher account. + * + * Tags: accounts.adclients.list + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GetAllAdClientsForPublisher { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param accountId the ID for the account to be used. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of ad clients. + * @throws Exception + */ + public static AdClients run(AdSenseHost service, String accountId, long maxPageSize) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all ad clients for account %s\n", accountId); + System.out.println("================================================================="); + + // Retrieve ad client list in pages and display data as we receive it. + String pageToken = null; + AdClients adClients = null; + do { + adClients = service.accounts().adclients().list(accountId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if ((adClients.getItems() != null) && !adClients.getItems().isEmpty()) { + for (AdClient adClient : adClients.getItems()) { + System.out.printf("Ad client for product \"%s\" with ID \"%s\" was found.\n", + adClient.getProductCode(), adClient.getId()); + System.out.printf("\tSupports reporting: %s\n", + adClient.getSupportsReporting() ? "Yes" : "No"); + } + } else { + System.out.println("No ad clients found."); + } + + pageToken = adClients.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + + return adClients; + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllAdUnitsForPublisher.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllAdUnitsForPublisher.java new file mode 100644 index 00000000..048e7cba --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllAdUnitsForPublisher.java @@ -0,0 +1,74 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.AdUnit; +import com.google.api.services.adsensehost.model.AdUnits; + +/** + * + * This example gets all ad units in a publisher ad client. + * + * To get ad clients, see GetAllAdClientsForPublisher.java. + * + * Tags: accounts.adunits.list + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GetAllAdUnitsForPublisher { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param accountId the ID for the publisher account to be used. + * @param adClientId the ID for the ad client to be used. + * @param maxPageSize the maximum page size to retrieve. + * @return the last page of ad units. + * @throws Exception + */ + public static AdUnits run(AdSenseHost service, String accountId, String adClientId, + long maxPageSize) throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all ad units for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Retrieve ad unit list in pages and display data as we receive it. + String pageToken = null; + AdUnits adUnits = null; + do { + adUnits = service.accounts().adunits().list(accountId, adClientId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if ((adUnits.getItems() != null) && !adUnits.getItems().isEmpty()) { + for (AdUnit unit : adUnits.getItems()) { + System.out.printf("Ad unit with code \"%s\", name \"%s\" and status \"%s\" was found.\n", + unit.getCode(), unit.getName(), unit.getStatus()); + } + } else { + System.out.println("No ad units found."); + } + + pageToken = adUnits.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + + // Return the last page of ad units, so that the main sample has something to run. + return adUnits; + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllCustomChannelsForHost.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllCustomChannelsForHost.java new file mode 100644 index 00000000..3ff9fba7 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllCustomChannelsForHost.java @@ -0,0 +1,69 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.CustomChannel; +import com.google.api.services.adsensehost.model.CustomChannels; + +/** + * + * This example gets all custom channels in a host ad client. + * + * To get ad clients, see GetAllAdClientsForHost.java. + * + * Tags: customchannels.list + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GetAllCustomChannelsForHost { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdSenseHost service, String adClientId, long maxPageSize) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all custom channels for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Retrieve custom channel list in pages and display the data as we receive it. + String pageToken = null; + CustomChannels customChannels = null; + do { + customChannels = service.customchannels().list(adClientId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if ((customChannels.getItems() != null) && !customChannels.getItems().isEmpty()) { + for (CustomChannel channel : customChannels.getItems()) { + System.out.printf("Custom channel with ID \"%s\", code \"%s\" and name \"%s\" found.\n", + channel.getId(), channel.getCode(), channel.getName()); + } + } else { + System.out.println("No custom channels found."); + } + + pageToken = customChannels.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllUrlChannelsForHost.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllUrlChannelsForHost.java new file mode 100644 index 00000000..e5ca3ba2 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/GetAllUrlChannelsForHost.java @@ -0,0 +1,68 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.UrlChannel; +import com.google.api.services.adsensehost.model.UrlChannels; + +/** + * + * This example gets all URL channels in a host ad client. + * + * To get ad clients, see GetAllAdClientsForHost.java. + * + * Tags: urlchannels.list + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class GetAllUrlChannelsForHost { + + /** + * Runs this sample. + * + * @param adsensehost AdSenseHost service object on which to run the requests. + * @param adClientId the ID for the ad client to be used. + * @param maxPageSize the maximum page size to retrieve. + * @throws Exception + */ + public static void run(AdSenseHost adsensehost, String adClientId, long maxPageSize) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Listing all URL channels for ad client %s\n", adClientId); + System.out.println("================================================================="); + + // Retrieve URL channel list in pages and display the data as we receive it. + String pageToken = null; + do { + UrlChannels urlChannels = adsensehost.urlchannels().list(adClientId) + .setMaxResults(maxPageSize) + .setPageToken(pageToken) + .execute(); + + if ((urlChannels.getItems() != null) && !urlChannels.getItems().isEmpty()) { + for (UrlChannel channel : urlChannels.getItems()) { + System.out.printf("URL channel with ID \"%s\" and URL pattern \"%s\" was found.\n", + channel.getId(), channel.getUrlPattern()); + } + } else { + System.out.println("No URL channels found."); + } + + pageToken = urlChannels.getNextPageToken(); + } while (pageToken != null); + + System.out.println(); + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/StartAssociationSession.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/StartAssociationSession.java new file mode 100644 index 00000000..ea911250 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/StartAssociationSession.java @@ -0,0 +1,54 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.AssociationSession; + +import java.util.List; + +/** + * + * This example starts an association session. + * + * Tags: associationsessions.start + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class StartAssociationSession { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param productCodes the list of products to associate with. + * @param websiteUrl the URL of the publisher website. + * @throws Exception + */ + public static void run(AdSenseHost service, List productCodes, String websiteUrl) + throws Exception { + System.out.println("================================================================="); + System.out.println("Creating new association session"); + System.out.println("================================================================="); + + // Request a new association session. + AssociationSession associationSession = service.associationsessions().start( + productCodes, websiteUrl).execute(); + + System.out.printf("Association with ID \"%s\" and redirect URL \"%s\" was started.\n", + associationSession.getId(), associationSession.getRedirectUrl()); + + System.out.println(); + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/UpdateAdUnitOnPublisher.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/UpdateAdUnitOnPublisher.java new file mode 100644 index 00000000..8175cabb --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/UpdateAdUnitOnPublisher.java @@ -0,0 +1,67 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.AdStyle; +import com.google.api.services.adsensehost.model.AdStyle.Colors; +import com.google.api.services.adsensehost.model.AdUnit; + +/** + * + * This example updates an ad unit on a publisher ad client. + * + * To get ad clients, see GetAllAdClientsForPublisher.java. + * To get ad units, see GetAllAdUnitsForPublisher.java. + * + * Tags: accounts.adunits.patch + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class UpdateAdUnitOnPublisher { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param accountId the ID of the pub account on which the ad unit exists. + * @param adClientId the ID of the ad client on which the ad unit exists. + * @param adUnitId the ID of the ad unit to be updated. + * @return the updated ad unit. + * @throws Exception + */ + public static AdUnit run(AdSenseHost service, String accountId, String adClientId, + String adUnitId) throws Exception { + System.out.println("================================================================="); + System.out.printf("Updating ad unit %s\n", adUnitId); + System.out.println("================================================================="); + + AdUnit patchAdUnit = new AdUnit() + .setCustomStyle(new AdStyle() + .setColors(new Colors() + .setText("ff0000"))); + + // Create ad unit. + AdUnit adUnit = service.accounts().adunits().patch(accountId, adClientId, adUnitId, + patchAdUnit).execute(); + + System.out.printf("Ad unit with ID \"%s\" was updated with text color \"%s\".\n", + adUnit.getId(), adUnit.getCustomStyle().getColors().getText()); + + System.out.println(); + + // Return the created ad unit. + return adUnit; + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/UpdateCustomChannelOnHost.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/UpdateCustomChannelOnHost.java new file mode 100644 index 00000000..2d67ee90 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/UpdateCustomChannelOnHost.java @@ -0,0 +1,63 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.CustomChannel; + +/** + * + * This example updates a custom channel on a host ad client. + * + * To get ad clients, see GetAllAdClientsForHost.java. + * To get custom channels, see GetAllCustomChannelsForHost.java. + * + * Tags: customchannels.patch + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class UpdateCustomChannelOnHost { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param adClientId the ad client ID that contains the custom channel. + * @param customChannelId the ID of the custom channel to be updated. + * @return the updated custom channel. + * @throws Exception + */ + public static CustomChannel run(AdSenseHost service, String adClientId, String customChannelId) + throws Exception { + System.out.println("================================================================="); + System.out.printf("Updating custom channel %s\n", customChannelId); + System.out.println("================================================================="); + + CustomChannel patchCustomChannel = new CustomChannel() + .setName("Updated Custom Channel #" + AdSenseHostSample.getUniqueName()); + + // Update custom channel. + CustomChannel customChannel = service.customchannels().patch(adClientId, customChannelId, + patchCustomChannel).execute(); + + System.out.printf( + "Custom channel with id \"%s\", code \"%s\" and name \"%s\" was updated.\n", + customChannel.getId(), customChannel.getCode(), customChannel.getName()); + + System.out.println(); + + // Return the updated custom channel. + return customChannel; + } +} diff --git a/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/VerifyAssociationSession.java b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/VerifyAssociationSession.java new file mode 100644 index 00000000..b005b2df --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/java/com/google/api/services/samples/adsensehost/cmdline/VerifyAssociationSession.java @@ -0,0 +1,51 @@ +/* + * 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.api.services.samples.adsensehost.cmdline; + +import com.google.api.services.adsensehost.AdSenseHost; +import com.google.api.services.adsensehost.model.AssociationSession; + +/** + * + * This example verifies an association session callback token. + * + * Tags: associationsessions.verify + * + * @author sgomes@google.com (Sérgio Gomes) + * + */ +public class VerifyAssociationSession { + + /** + * Runs this sample. + * + * @param service AdSenseHost service object on which to run the requests. + * @param callbackToken the token returned in the association callback. + * @throws Exception + */ + public static void run(AdSenseHost service, String callbackToken) throws Exception { + System.out.println("================================================================="); + System.out.println("Verifying association session"); + System.out.println("================================================================="); + + // Verify the association session token. + AssociationSession associationSession = service.associationsessions().verify( + callbackToken).execute(); + + System.out.printf("Association for account \"%s\" has status \"%s\" and ID \"%s\".\n", + associationSession.getAccountId(), associationSession.getStatus(), + associationSession.getId()); + + System.out.println(); + } +} diff --git a/adsensehost-cmdline-sample/src/main/resources/client_secrets.json b/adsensehost-cmdline-sample/src/main/resources/client_secrets.json new file mode 100644 index 00000000..e448bab9 --- /dev/null +++ b/adsensehost-cmdline-sample/src/main/resources/client_secrets.json @@ -0,0 +1,6 @@ +{ + "installed": { + "client_id": "Enter Client ID", + "client_secret": "Enter Client Secret" + } +} diff --git a/analytics-cmdline-sample/.classpath b/analytics-cmdline-sample/.classpath new file mode 100644 index 00000000..e6a132bd --- /dev/null +++ b/analytics-cmdline-sample/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/analytics-cmdline-sample/.project b/analytics-cmdline-sample/.project new file mode 100644 index 00000000..b2099177 --- /dev/null +++ b/analytics-cmdline-sample/.project @@ -0,0 +1,23 @@ + + + analytics-cmdline-sample + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/analytics-cmdline-sample/.settings/org.eclipse.jdt.core.prefs b/analytics-cmdline-sample/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..faf086f4 --- /dev/null +++ b/analytics-cmdline-sample/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,380 @@ +#Fri Nov 04 10:10:38 EDT 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.annotationSuperInterface=ignore +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_member=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=24 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=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|5|48 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_field_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_for_statement=16 +org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments=16 +org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16|5|80 +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|4|49 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16|4|48 +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=false +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=100 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph=true +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.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.force_if_else_statement_brace=true +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +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_field=insert +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_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=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_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=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=do not 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.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +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=100 +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.sort_local_variable_annotations=false +org.eclipse.jdt.core.formatter.sort_member_annotations=false +org.eclipse.jdt.core.formatter.sort_package_annotations=false +org.eclipse.jdt.core.formatter.sort_parameter_annotations=false +org.eclipse.jdt.core.formatter.sort_type_annotations=false +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_comment_inline_tags=false +org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation=false +org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments=false diff --git a/analytics-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs b/analytics-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..2413e100 --- /dev/null +++ b/analytics-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,119 @@ +#Fri Nov 04 10:06:25 EDT 2011 +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=true +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=true +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_google-api-java-client +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false +formatter_profile=_google-api-java-client 100 +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=exception +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=com;org;;java;javax; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=999 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=999 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=false +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/analytics-cmdline-sample/HelloAnalyticsApiSample.launch b/analytics-cmdline-sample/HelloAnalyticsApiSample.launch new file mode 100644 index 00000000..30c4843e --- /dev/null +++ b/analytics-cmdline-sample/HelloAnalyticsApiSample.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/analytics-cmdline-sample/McfReportingApiReferenceSample.launch b/analytics-cmdline-sample/McfReportingApiReferenceSample.launch new file mode 100644 index 00000000..a25fe27a --- /dev/null +++ b/analytics-cmdline-sample/McfReportingApiReferenceSample.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/analytics-cmdline-sample/instructions.html b/analytics-cmdline-sample/instructions.html new file mode 100644 index 00000000..d5378d30 --- /dev/null +++ b/analytics-cmdline-sample/instructions.html @@ -0,0 +1,117 @@ + +analytics-cmdline-sample + +

Instructions for the Google Analytics API Command-Line Samples

+ +

Browse Online

+ +

+ There are 3 samples. Browse + Source of all of them. Or view the main file of each sample: +

+ + + +

Register Your Application

+ +
    +
  • Visit the Google Cloud + console. +
  • +
  • If necessary, sign in to your Google Account, select or create a project, + and agree to the terms of service. Click Continue.
  • +
  • Select "Installed application" and choose type "Other" under the Installed Application type.
  • +
  • Within "OAuth 2.0 Client ID", click on "Download JSON". Later on, after you check + out the sample project, you will copy this downloaded file (e.g. + ~/Downloads/client_secrets.json) to + src/main/resources/client_secrets.json. + If you skip this step, when trying to run the sample you will get a 400 + INVALID_CLIENT error in the browser. +
  • +
+ +

Checkout Instructions

+ +

+ Prerequisites: install Java 6, Mercurial, and Maven. You may need to + set your + JAVA_HOME + . +

+ +
+cd [someDirectory]
+hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
+cd google-api-java-client-samples/analytics-cmdline-sample
+cp ~/Downloads/client_secrets.json src/main/resources/client_secrets.json
+mvn compile
+mvn -q exec:java
+  
+ +

To enable logging of HTTP requests and responses (highly recommended + when developing), please take a look at logging.properties.

+ +

Setup Project in Eclipse

+ +

+ Prerequisites: install Eclipse, + the Mercurial plugin, and the + Maven + plugin. +

+ +
    +
  • Setup Eclipse Preferences +
      +
    • Window > Preferences... (or on Mac, Eclipse > + Preferences...)
    • +
    • Select Maven +
        +
      • check on "Download Artifact Sources"
      • +
      • check on "Download Artifact JavaDoc"
      • +
      +
    • +
    +
  • +
  • Import analytics-cmdline-sample project +
      +
    • File > Import...
    • +
    • Select "General > Existing Project into Workspace" and click + "Next"
    • +
    • Click "Browse" next to "Select root directory", find + [someDirectory]/google-api-java-client-samples/analytics-cmdline-sample + and click "Next" +
    • +
    • Click "Finish"
    • +
    +
  • +
  • Run +
      +
    • Right-click on project analytics-cmdline-sample
    • +
    • Run As > Java Application
    • +
    • If asked, type "HelloAnalyticsApiSample" and click OK
    • +
    +
  • +
+

+ Note: The default for this project is to run the + HelloAnalyticsApiSample application. You can run the other samples by + updating the + pom.xml + mainClass + attribute for Maven or Right clicking the appropriate file in Eclipse. +

+ + diff --git a/analytics-cmdline-sample/logging.properties b/analytics-cmdline-sample/logging.properties new file mode 100644 index 00000000..d5064366 --- /dev/null +++ b/analytics-cmdline-sample/logging.properties @@ -0,0 +1,10 @@ +# Properties file which configures the operation of the JDK logging facility. +# The system will look for this config file to be specified as a system property: +# -Djava.util.logging.config.file=${project_loc}/logging.properties + +# Set up the console handler (uncomment "level" to show more fine-grained messages) +handlers = java.util.logging.ConsoleHandler +#java.util.logging.ConsoleHandler.level = CONFIG + +# Set up logging of HTTP requests and responses (uncomment "level" to show) +#com.google.api.client.http.level = CONFIG diff --git a/analytics-cmdline-sample/pom.xml b/analytics-cmdline-sample/pom.xml new file mode 100644 index 00000000..ad7ce928 --- /dev/null +++ b/analytics-cmdline-sample/pom.xml @@ -0,0 +1,135 @@ + + 4.0.0 + + com.google + google + 5 + + com.google.apis-samples + analytics-cmdline-sample + 1 + Example for the Analytics API v3 using JSON. + + http://code.google.com/p/google-api-java-client/ + + + code.google.com + http://code.google.com/p/google-api-java-client/issues/list + + + 2012 + + + 2.0.9 + + + + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + http://code.google.com/p/google-api-java-client/source/browse/?repo=samples + + + + + api.nickm + Nick Mihailovski + api.nickm@gmail.com + Google + http://www.google.com + + owner + developer + + 0 + + + + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.codehaus.mojo + exec-maven-plugin + 1.1 + + + + java + + + + + com.google.api.services.samples.analytics.cmdline.HelloAnalyticsApiSample + + + java.util.logging.config.file + logging.properties + + + + + + maven-checkstyle-plugin + 2.6 + + ../checkstyle.xml + true + false + + + + + check + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + false + + + + + check + + + + + + ${project.artifactId}-${project.version} + + + + com.google.apis + google-api-services-analytics + v3-rev98-1.19.0 + + + com.google.http-client + google-http-client-jackson2 + ${project.http.version} + + + com.google.oauth-client + google-oauth-client-jetty + ${project.oauth.version} + + + + 1.19.0 + 1.19.0 + UTF-8 + + diff --git a/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/CoreReportingApiReferenceSample.java b/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/CoreReportingApiReferenceSample.java new file mode 100644 index 00000000..613736c0 --- /dev/null +++ b/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/CoreReportingApiReferenceSample.java @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2012 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.api.services.samples.analytics.cmdline; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp; +import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; +import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; +import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.googleapis.json.GoogleJsonResponseException; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.util.store.DataStoreFactory; +import com.google.api.client.util.store.FileDataStoreFactory; +import com.google.api.services.analytics.Analytics; +import com.google.api.services.analytics.AnalyticsScopes; +import com.google.api.services.analytics.model.GaData; +import com.google.api.services.analytics.model.GaData.ColumnHeaders; +import com.google.api.services.analytics.model.GaData.ProfileInfo; +import com.google.api.services.analytics.model.GaData.Query; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * This application demonstrates how to use the Google Analytics Java client library to access all + * the pieces of data returned by the Google Analytics Core Reporting API v3. + * + *

+ * To run this, you must supply your Google Analytics TABLE ID. Read the Core Reporting API + * developer guide to learn how to get this value. + *

+ * + * @author api.nickm@gmail.com + */ +public class CoreReportingApiReferenceSample { + + /** + * Be sure to specify the name of your application. If the application name is {@code null} or + * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0". + */ + private static final String APPLICATION_NAME = ""; + + /** + * Used to identify from which reporting profile to retrieve data. Format is ga:xxx where xxx is + * your profile ID. + */ + private static final String TABLE_ID = "INSERT_YOUR_TABLE_ID"; + + /** Directory to store user credentials. */ + private static final java.io.File DATA_STORE_DIR = + new java.io.File(System.getProperty("user.home"), ".store/analytics_sample"); + + /** + * Global instance of the {@link DataStoreFactory}. The best practice is to make it a single + * globally shared instance across your application. + */ + private static FileDataStoreFactory DATA_STORE_FACTORY; + + /** Global instance of the HTTP transport. */ + private static HttpTransport HTTP_TRANSPORT; + + /** Global instance of the JSON factory. */ + private static final JsonFactory JSON_FACTORY = new JacksonFactory(); + + /** + * Main demo. This first initializes an Analytics service object. It then queries for the top 25 + * organic search keywords and traffic sources by visits. Finally each important part of the + * response is printed to the screen. + * + * @param args command line args. + */ + public static void main(String[] args) { + try { + HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); + DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR); + Analytics analytics = initializeAnalytics(); + GaData gaData = executeDataQuery(analytics, TABLE_ID); + + printReportInfo(gaData); + printProfileInfo(gaData); + printQueryInfo(gaData); + printPaginationInfo(gaData); + printTotalsForAllResults(gaData); + printColumnHeaders(gaData); + printDataTable(gaData); + + } catch (GoogleJsonResponseException e) { + System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + + e.getDetails().getMessage()); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + /** Authorizes the installed application to access user's protected data. */ + private static Credential authorize() throws Exception { + // load client secrets + GoogleClientSecrets clientSecrets = GoogleClientSecrets.load( + JSON_FACTORY, new InputStreamReader( + HelloAnalyticsApiSample.class.getResourceAsStream("/client_secrets.json"))); + if (clientSecrets.getDetails().getClientId().startsWith("Enter") + || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { + System.out.println( + "Enter Client ID and Secret from https://code.google.com/apis/console/?api=analytics " + + "into analytics-cmdline-sample/src/main/resources/client_secrets.json"); + System.exit(1); + } + // set up authorization code flow + GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( + HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, + Collections.singleton(AnalyticsScopes.ANALYTICS_READONLY)).setDataStoreFactory( + DATA_STORE_FACTORY).build(); + // authorize + return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user"); + } + + /** + * Performs all necessary setup steps for running requests against the API. + * + * @return an initialized Analytics service object. + * + * @throws Exception if an issue occurs with OAuth2Native authorize. + */ + private static Analytics initializeAnalytics() throws Exception { + // Authorization. + Credential credential = authorize(); + + // Set up and return Google Analytics API client. + return new Analytics.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName( + APPLICATION_NAME).build(); + } + + /** + * Returns the top 25 organic search keywords and traffic sources by visits. The Core Reporting + * API is used to retrieve this data. + * + * @param analytics the Analytics service object used to access the API. + * @param tableId the table ID from which to retrieve data. + * @return the response from the API. + * @throws IOException if an API error occured. + */ + private static GaData executeDataQuery(Analytics analytics, String tableId) throws IOException { + return analytics.data().ga().get(tableId, // Table Id. + "2012-01-01", // Start date. + "2012-01-14", // End date. + "ga:visits") // Metrics. + .setDimensions("ga:source,ga:keyword") + .setSort("-ga:visits,ga:source") + .setFilters("ga:medium==organic") + .setMaxResults(25) + .execute(); + } + + /** + * Prints general information about this report. + * + * @param gaData the data returned from the API. + */ + private static void printReportInfo(GaData gaData) { + System.out.println(); + System.out.println("Response:"); + System.out.println("ID:" + gaData.getId()); + System.out.println("Self link: " + gaData.getSelfLink()); + System.out.println("Kind: " + gaData.getKind()); + System.out.println("Contains Sampled Data: " + gaData.getContainsSampledData()); + } + + /** + * Prints general information about the profile from which this report was accessed. + * + * @param gaData the data returned from the API. + */ + private static void printProfileInfo(GaData gaData) { + ProfileInfo profileInfo = gaData.getProfileInfo(); + + System.out.println("Profile Info"); + System.out.println("Account ID: " + profileInfo.getAccountId()); + System.out.println("Web Property ID: " + profileInfo.getWebPropertyId()); + System.out.println("Internal Web Property ID: " + profileInfo.getInternalWebPropertyId()); + System.out.println("Profile ID: " + profileInfo.getProfileId()); + System.out.println("Profile Name: " + profileInfo.getProfileName()); + System.out.println("Table ID: " + profileInfo.getTableId()); + } + + /** + * Prints the values of all the parameters that were used to query the API. + * + * @param gaData the data returned from the API. + */ + private static void printQueryInfo(GaData gaData) { + Query query = gaData.getQuery(); + + System.out.println("Query Info:"); + System.out.println("Ids: " + query.getIds()); + System.out.println("Start Date: " + query.getStartDate()); + System.out.println("End Date: " + query.getEndDate()); + System.out.println("Metrics: " + query.getMetrics()); // List + System.out.println("Dimensions: " + query.getDimensions()); // List + System.out.println("Sort: " + query.getSort()); // List + System.out.println("Segment: " + query.getSegment()); + System.out.println("Filters: " + query.getFilters()); + System.out.println("Start Index: " + query.getStartIndex()); + System.out.println("Max Results: " + query.getMaxResults()); + } + + /** + * Prints common pagination information. + * + * @param gaData the data returned from the API. + */ + private static void printPaginationInfo(GaData gaData) { + System.out.println("Pagination Info:"); + System.out.println("Previous Link: " + gaData.getPreviousLink()); + System.out.println("Next Link: " + gaData.getNextLink()); + System.out.println("Items Per Page: " + gaData.getItemsPerPage()); + System.out.println("Total Results: " + gaData.getTotalResults()); + } + + /** + * Prints the total metric value for all rows the query matched. + * + * @param gaData the data returned from the API. + */ + private static void printTotalsForAllResults(GaData gaData) { + System.out.println("Metric totals over all results:"); + Map totalsMap = gaData.getTotalsForAllResults(); + for (Map.Entry entry : totalsMap.entrySet()) { + System.out.println(entry.getKey() + " : " + entry.getValue()); + } + } + + /** + * Prints the information for each column. The reporting data from the API is returned as rows of + * data. The column headers describe the names and types of each column in rows. + * + * @param gaData the data returned from the API. + */ + private static void printColumnHeaders(GaData gaData) { + System.out.println("Column Headers:"); + + for (ColumnHeaders header : gaData.getColumnHeaders()) { + System.out.println("Column Name: " + header.getName()); + System.out.println("Column Type: " + header.getColumnType()); + System.out.println("Column Data Type: " + header.getDataType()); + } + } + + /** + * Prints all the rows of data returned by the API. + * + * @param gaData the data returned from the API. + */ + private static void printDataTable(GaData gaData) { + if (gaData.getTotalResults() > 0) { + System.out.println("Data Table:"); + + // Print the column names. + for (ColumnHeaders header : gaData.getColumnHeaders()) { + System.out.format("%-32s", header.getName()); + } + System.out.println(); + + // Print the rows of data. + for (List rowValues : gaData.getRows()) { + for (String value : rowValues) { + System.out.format("%-32s", value); + } + System.out.println(); + } + } else { + System.out.println("No data"); + } + } +} diff --git a/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/HelloAnalyticsApiSample.java b/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/HelloAnalyticsApiSample.java new file mode 100644 index 00000000..3d3a979d --- /dev/null +++ b/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/HelloAnalyticsApiSample.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2012 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.api.services.samples.analytics.cmdline; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp; +import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; +import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; +import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.googleapis.json.GoogleJsonResponseException; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.util.store.DataStoreFactory; +import com.google.api.client.util.store.FileDataStoreFactory; +import com.google.api.services.analytics.Analytics; +import com.google.api.services.analytics.AnalyticsScopes; +import com.google.api.services.analytics.model.Accounts; +import com.google.api.services.analytics.model.GaData; +import com.google.api.services.analytics.model.GaData.ColumnHeaders; +import com.google.api.services.analytics.model.Profiles; +import com.google.api.services.analytics.model.Webproperties; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; +import java.util.List; + + +/** + * This is a basic hello world sample for the Google Analytics API. It is designed to run from the + * command line and will prompt a user to grant access to their data. Once complete, the sample will + * traverse the Management API hierarchy by going through the authorized user's first account, first + * web property, and finally the first profile and retrieve the first profile id. This ID is then + * used with the Core Reporting API to retrieve the top 25 organic search terms. + * + * @author api.nickm@gmail.com + */ +public class HelloAnalyticsApiSample { + + /** + * Be sure to specify the name of your application. If the application name is {@code null} or + * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0". + */ + private static final String APPLICATION_NAME = ""; + + /** Directory to store user credentials. */ + private static final java.io.File DATA_STORE_DIR = + new java.io.File(System.getProperty("user.home"), ".store/analytics_sample"); + + /** + * Global instance of the {@link DataStoreFactory}. The best practice is to make it a single + * globally shared instance across your application. + */ + private static FileDataStoreFactory dataStoreFactory; + + /** Global instance of the HTTP transport. */ + private static HttpTransport httpTransport; + + /** Global instance of the JSON factory. */ + private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); + + /** + * Main demo. This first initializes an analytics service object. It then uses the Google + * Analytics Management API to get the first profile ID for the authorized user. It then uses the + * Core Reporting API to retrieve the top 25 organic search terms. Finally the results are printed + * to the screen. If an API error occurs, it is printed here. + * + * @param args command line args. + */ + public static void main(String[] args) { + try { + httpTransport = GoogleNetHttpTransport.newTrustedTransport(); + dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR); + Analytics analytics = initializeAnalytics(); + String profileId = getFirstProfileId(analytics); + if (profileId == null) { + System.err.println("No profiles found."); + } else { + GaData gaData = executeDataQuery(analytics, profileId); + printGaData(gaData); + } + } catch (GoogleJsonResponseException e) { + System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + + e.getDetails().getMessage()); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + /** Authorizes the installed application to access user's protected data. */ + private static Credential authorize() throws Exception { + // load client secrets + GoogleClientSecrets clientSecrets = GoogleClientSecrets.load( + JSON_FACTORY, new InputStreamReader( + HelloAnalyticsApiSample.class.getResourceAsStream("/client_secrets.json"))); + if (clientSecrets.getDetails().getClientId().startsWith("Enter") + || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { + System.out.println( + "Enter Client ID and Secret from https://code.google.com/apis/console/?api=analytics " + + "into analytics-cmdline-sample/src/main/resources/client_secrets.json"); + System.exit(1); + } + // set up authorization code flow + GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( + httpTransport, JSON_FACTORY, clientSecrets, + Collections.singleton(AnalyticsScopes.ANALYTICS_READONLY)).setDataStoreFactory( + dataStoreFactory).build(); + // authorize + return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user"); + } + + /** + * Performs all necessary setup steps for running requests against the API. + * + * @return An initialized Analytics service object. + * + * @throws Exception if an issue occurs with OAuth2Native authorize. + */ + private static Analytics initializeAnalytics() throws Exception { + // Authorization. + Credential credential = authorize(); + + // Set up and return Google Analytics API client. + return new Analytics.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName( + APPLICATION_NAME).build(); + } + + /** + * Returns the first profile id by traversing the Google Analytics Management API. This makes 3 + * queries, first to the accounts collection, then to the web properties collection, and finally + * to the profiles collection. In each request the first ID of the first entity is retrieved and + * used in the query for the next collection in the hierarchy. + * + * @param analytics the analytics service object used to access the API. + * @return the profile ID of the user's first account, web property, and profile. + * @throws IOException if the API encounters an error. + */ + private static String getFirstProfileId(Analytics analytics) throws IOException { + String profileId = null; + + // Query accounts collection. + Accounts accounts = analytics.management().accounts().list().execute(); + + if (accounts.getItems().isEmpty()) { + System.err.println("No accounts found"); + } else { + String firstAccountId = accounts.getItems().get(0).getId(); + + // Query webproperties collection. + Webproperties webproperties = + analytics.management().webproperties().list(firstAccountId).execute(); + + if (webproperties.getItems().isEmpty()) { + System.err.println("No Webproperties found"); + } else { + String firstWebpropertyId = webproperties.getItems().get(0).getId(); + + // Query profiles collection. + Profiles profiles = + analytics.management().profiles().list(firstAccountId, firstWebpropertyId).execute(); + + if (profiles.getItems().isEmpty()) { + System.err.println("No profiles found"); + } else { + profileId = profiles.getItems().get(0).getId(); + } + } + } + return profileId; + } + + /** + * Returns the top 25 organic search keywords and traffic source by visits. The Core Reporting API + * is used to retrieve this data. + * + * @param analytics the analytics service object used to access the API. + * @param profileId the profile ID from which to retrieve data. + * @return the response from the API. + * @throws IOException tf an API error occured. + */ + private static GaData executeDataQuery(Analytics analytics, String profileId) throws IOException { + return analytics.data().ga().get("ga:" + profileId, // Table Id. ga: + profile id. + "2012-01-01", // Start date. + "2012-01-14", // End date. + "ga:visits") // Metrics. + .setDimensions("ga:source,ga:keyword") + .setSort("-ga:visits,ga:source") + .setFilters("ga:medium==organic") + .setMaxResults(25) + .execute(); + } + + /** + * Prints the output from the Core Reporting API. The profile name is printed along with each + * column name and all the data in the rows. + * + * @param results data returned from the Core Reporting API. + */ + private static void printGaData(GaData results) { + System.out.println( + "printing results for profile: " + results.getProfileInfo().getProfileName()); + + if (results.getRows() == null || results.getRows().isEmpty()) { + System.out.println("No results Found."); + } else { + + // Print column headers. + for (ColumnHeaders header : results.getColumnHeaders()) { + System.out.printf("%30s", header.getName()); + } + System.out.println(); + + // Print actual data. + for (List row : results.getRows()) { + for (String column : row) { + System.out.printf("%30s", column); + } + System.out.println(); + } + + System.out.println(); + } + } +} diff --git a/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/ManagementApiReferenceSample.java b/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/ManagementApiReferenceSample.java new file mode 100644 index 00000000..4a7f66cd --- /dev/null +++ b/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/ManagementApiReferenceSample.java @@ -0,0 +1,395 @@ +/* + * Copyright (c) 2012 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.api.services.samples.analytics.cmdline; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp; +import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; +import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; +import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.googleapis.json.GoogleJsonResponseException; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.util.store.DataStoreFactory; +import com.google.api.client.util.store.FileDataStoreFactory; +import com.google.api.services.analytics.Analytics; +import com.google.api.services.analytics.AnalyticsScopes; +import com.google.api.services.analytics.model.Account; +import com.google.api.services.analytics.model.Accounts; +import com.google.api.services.analytics.model.Goal; +import com.google.api.services.analytics.model.Goal.EventDetails; +import com.google.api.services.analytics.model.Goal.EventDetails.EventConditions; +import com.google.api.services.analytics.model.Goal.UrlDestinationDetails; +import com.google.api.services.analytics.model.Goal.UrlDestinationDetails.Steps; +import com.google.api.services.analytics.model.Goal.VisitNumPagesDetails; +import com.google.api.services.analytics.model.Goal.VisitTimeOnSiteDetails; +import com.google.api.services.analytics.model.Goals; +import com.google.api.services.analytics.model.Profile; +import com.google.api.services.analytics.model.Profiles; +import com.google.api.services.analytics.model.Segment; +import com.google.api.services.analytics.model.Segments; +import com.google.api.services.analytics.model.Webproperties; +import com.google.api.services.analytics.model.Webproperty; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; + +/** + * This sample application demonstrates how to traverse the Management API. At each level, all the + * important information about each entity is printed to the screen. + * + * @author api.nickm@gmail.com + */ +public class ManagementApiReferenceSample { + + /** + * Be sure to specify the name of your application. If the application name is {@code null} or + * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0". + */ + private static final String APPLICATION_NAME = ""; + + /** Directory to store user credentials. */ + private static final java.io.File DATA_STORE_DIR = + new java.io.File(System.getProperty("user.home"), ".store/analytics_sample"); + + /** + * Global instance of the {@link DataStoreFactory}. The best practice is to make it a single + * globally shared instance across your application. + */ + private static FileDataStoreFactory DATA_STORE_FACTORY; + + /** Global instance of the HTTP transport. */ + private static HttpTransport HTTP_TRANSPORT; + + /** Global instance of the JSON factory. */ + private static final JsonFactory JSON_FACTORY = new JacksonFactory(); + + /** + * Main demo. An Analytics service object is instantiated and then it is used to traverse and + * print all the Management API entities. If any exceptions occur, they are caught and printed. + * + * @param args command line args. + */ + public static void main(String args[]) { + try { + HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); + DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR); + Analytics analytics = initializeAnalytics(); + printManagementEntities(analytics); + + } catch (GoogleJsonResponseException e) { + System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + + e.getDetails().getMessage()); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + /** Authorizes the installed application to access user's protected data. */ + private static Credential authorize() throws Exception { + // load client secrets + GoogleClientSecrets clientSecrets = GoogleClientSecrets.load( + JSON_FACTORY, new InputStreamReader( + HelloAnalyticsApiSample.class.getResourceAsStream("/client_secrets.json"))); + if (clientSecrets.getDetails().getClientId().startsWith("Enter") + || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { + System.out.println( + "Enter Client ID and Secret from https://code.google.com/apis/console/?api=analytics " + + "into analytics-cmdline-sample/src/main/resources/client_secrets.json"); + System.exit(1); + } + // set up authorization code flow + GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( + HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, + Collections.singleton(AnalyticsScopes.ANALYTICS_READONLY)).setDataStoreFactory( + DATA_STORE_FACTORY).build(); + // authorize + return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user"); + } + + /** + * Performs all necessary setup steps for running requests against the API. + * + * @return An initialized Analytics service object. + * + * @throws Exception if an issue occurs with OAuth2Native authorize. + */ + private static Analytics initializeAnalytics() throws Exception { + // Authorization. + Credential credential = authorize(); + + // Set up and return Google Analytics API client. + return new Analytics.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName( + APPLICATION_NAME).setHttpRequestInitializer(credential).build(); + } + + /** + * Traverses through the Management API hiearchy and prints each entity. This retrieves and prints + * the authorized user's accounts. It then retrieves and prints all the web properties for the + * first account, retrieves and prints all the profiles for the first web property, and retrieves + * and prints all the goals for the first profile. Finally all the user's segments are prtined. + * + * @param analytics an initialized Analytics service object. + * @throws IOException if any network errors occured. + */ + private static void printManagementEntities(Analytics analytics) throws IOException { + + // Query accounts collection. + Accounts accounts = analytics.management().accounts().list().execute(); + + if (accounts.getItems().isEmpty()) { + System.err.println("No accounts found"); + } else { + printAccounts(accounts); + String firstAccountId = accounts.getItems().get(0).getId(); + + // Query webproperties collection. + Webproperties webproperties = + analytics.management().webproperties().list(firstAccountId).execute(); + + if (webproperties.getItems().isEmpty()) { + System.err.println("No webproperties found"); + } else { + printWebProperties(webproperties); + String firstWebpropertyId = webproperties.getItems().get(0).getId(); + + // Query profiles collection. + Profiles profiles = + analytics.management().profiles().list(firstAccountId, firstWebpropertyId).execute(); + + if (profiles.getItems().isEmpty()) { + System.err.println("No profiles found"); + } else { + printProfiles(profiles); + String firstProfileId = profiles.getItems().get(0).getId(); + + // Query goals collection. + Goals goals = analytics.management() + .goals().list(firstAccountId, firstWebpropertyId, firstProfileId).execute(); + + if (goals.getItems() == null || goals.getItems().isEmpty()) { + System.err.println("No goals found"); + } else { + printGoals(goals); + } + } + } + } + Segments segments = analytics.management().segments().list().execute(); + printSegments(segments); + } + + /** + * Prints all the account information from the accounts collection. + * + * @param accounts the results from the accounts collection. + */ + private static void printAccounts(Accounts accounts) { + System.out.println("\n----- Accounts Collection -----\n"); + + for (Account account : accounts.getItems()) { + System.out.println("Account ID: " + account.getId()); + System.out.println("Account Name: " + account.getName()); + System.out.println("Account Created: " + account.getCreated()); + System.out.println("Account Updated: " + account.getUpdated()); + } + } + + /** + * Prints all the webproperty information from the webproperties collection. + * + * @param webproperties the results from the webproperties collection. + */ + private static void printWebProperties(Webproperties webproperties) { + System.out.println("\n----- Webproperties Collection -----\n"); + + for (Webproperty webproperty : webproperties.getItems()) { + System.out.println("Account ID: " + webproperty.getAccountId()); + System.out.println("Web Property ID: " + webproperty.getId()); + System.out.println("Web Property Name: " + webproperty.getName()); + System.out.println("Web Property Internal Id: " + webproperty.getInternalWebPropertyId()); + System.out.println("Web Property Website URL: " + webproperty.getWebsiteUrl()); + System.out.println("Web Property Created: " + webproperty.getCreated()); + System.out.println("Web Property Updated: " + webproperty.getUpdated()); + } + } + + /** + * Prints all the profile information from the profiles collection. + * + * @param profiles the results from the profiles collection. + */ + private static void printProfiles(Profiles profiles) { + System.out.println("\n----- Profiles Collection -----\n"); + + for (Profile profile : profiles.getItems()) { + System.out.println("Account ID: " + profile.getAccountId()); + System.out.println("Web Property ID: " + profile.getWebPropertyId()); + System.out.println("Web Property Internal ID: " + profile.getInternalWebPropertyId()); + System.out.println("Profile ID: " + profile.getId()); + System.out.println("Profile Name: " + profile.getName()); + + System.out.println("Profile defaultPage: " + profile.getDefaultPage()); + System.out.println( + "Profile Exclude Query Parameters: " + profile.getExcludeQueryParameters()); + System.out.println( + "Profile Site Search Query Parameters: " + profile.getSiteSearchQueryParameters()); + System.out.println( + "Profile Site Search Category Parameters: " + profile.getSiteSearchCategoryParameters()); + + System.out.println("Profile Currency: " + profile.getCurrency()); + System.out.println("Profile Timezone: " + profile.getTimezone()); + System.out.println("Profile Created: " + profile.getCreated()); + System.out.println("Profile Updated: " + profile.getUpdated()); + } + } + + /** + * Prints all the goal information from the goals collection. A goal can be one of 4 types. + * Depending on the goal type, the appropriate goal data is printed. + * + * @param goals the results from the goals collection. + */ + private static void printGoals(Goals goals) { + System.out.println("\n----- Goals Collection -----\n"); + + for (Goal goal : goals.getItems()) { + System.out.println("Account ID: " + goal.getAccountId()); + System.out.println("Web Property ID: " + goal.getWebPropertyId()); + System.out.println("Web Property Internal Id: " + goal.getInternalWebPropertyId()); + System.out.println("Profile ID: " + goal.getId()); + + System.out.println("Goal Number: " + goal.getId()); + System.out.println("Goal Name: " + goal.getName()); + System.out.println("Is Goal Active: " + goal.getActive()); + System.out.println("Goal Value: " + goal.getValue()); + System.out.println("Goal Type: " + goal.getType()); + System.out.println("Goal Created: " + goal.getCreated()); + System.out.println("Goal Updated: " + goal.getUpdated()); + + if (goal.getType().equals("URL_DESTINATION")) { + printUrlDestinationDetails(goal.getUrlDestinationDetails()); + + } else if (goal.getType().equals("VISIT_TIME_ON_SITE")) { + printVisitTimeOnSiteDetails(goal.getVisitTimeOnSiteDetails()); + + } else if (goal.getType().equals("VISIT_NUM_PAGES")) { + printVisitNumPagesDetails(goal.getVisitNumPagesDetails()); + + } else if (goal.getType().equals("EVENT")) { + printGoalEventDetails(goal.getEventDetails()); + } + } + } + + /** + * Prints details for URL_DESTINATION type goals. Each of these goals might have one or more goal + * steps configured. If any are present, they are printed. + * + * @param destinationDetails the details of a DESTINATION type goal. + */ + private static void printUrlDestinationDetails(UrlDestinationDetails destinationDetails) { + System.out.println("Goal Url: " + destinationDetails.getUrl()); + System.out.println("Case Sensitive: " + destinationDetails.getCaseSensitive()); + System.out.println("Match Type: " + destinationDetails.getMatchType()); + System.out.println("First Step Required: " + destinationDetails.getFirstStepRequired()); + + if (destinationDetails.getSteps() != null) { + System.out.println("Goal Steps: "); + for (Steps step : destinationDetails.getSteps()) { + System.out.println("Step Number: " + step.getNumber()); + System.out.println("Name: " + step.getName()); + System.out.println("URL: " + step.getUrl()); + } + } else { + System.out.println("No Steps Configured"); + } + } + + /** + * Prints details for VISIT_TIME_ON_SITE type goals. + * + * @param visitTimeOnSiteDetails the details of a VISIT_TIME_ON_SITE goal. + */ + private static void printVisitTimeOnSiteDetails(VisitTimeOnSiteDetails visitTimeOnSiteDetails) { + + System.out.println("Goal Type: VISIT_TIME_ON_SITE"); + System.out.println( + "VISIT_TIME_ON_SITE - Comparison Type: " + visitTimeOnSiteDetails.getComparisonType()); + System.out.println( + "VISIT_TIME_ON_SITE - Comparison Value: " + visitTimeOnSiteDetails.getComparisonValue()); + } + + /** + * Prints details for VISIT_NUM_PAGES type goals. + * + * @param visitNumPagesDetails the details of a VISIT_NUM_PAGES goal. + */ + private static void printVisitNumPagesDetails(VisitNumPagesDetails visitNumPagesDetails) { + System.out.println("Goal Type: VISIT_NUM_PAGES"); + System.out.println( + "VISIT_NUM_PAGES - Comparison Type: " + visitNumPagesDetails.getComparisonType()); + System.out.println( + "VISIT_NUM_PAGES - Comparison Value: " + visitNumPagesDetails.getComparisonValue()); + } + + /** + * Prints details for EVENT type goals. + * + * @param eventDetails the details of an EVENT type goal. + */ + private static void printGoalEventDetails(EventDetails eventDetails) { + System.out.println("Goal Type: EVENT"); + System.out.println("EVENT - Use Event Value: " + eventDetails.getUseEventValue()); + + if (eventDetails.getEventConditions() != null) { + System.out.println("Goal Conditions: "); + for (EventConditions conditions : eventDetails.getEventConditions()) { + System.out.println("Type: " + conditions.getType()); + + if (conditions.getType().equals("VALUE")) { + System.out.println("Comparison Type: " + conditions.getComparisonType()); + System.out.println("Comparison Value: " + conditions.getComparisonValue()); + } else { + System.out.println("matchType: " + conditions.getMatchType()); + System.out.println("expression: " + conditions.getExpression()); + } + } + } + } + + /** + * Prints all the segment infromation from the segements collection. + * + * @param segments the results from the segments collection. + */ + private static void printSegments(Segments segments) { + System.out.println("\n----- Segments Collection -----\n"); + + for (Segment segment : segments.getItems()) { + System.out.println("Advanced Segment ID: " + segment.getId()); + System.out.println("Advanced Segment Name: " + segment.getName()); + System.out.println("Advanced Segment Definition: " + segment.getDefinition()); + + // These fields are only set for custom segments and not default segments. + if (segment.getCreated() != null) { + System.out.println("Advanced Segment Created: " + segment.getCreated()); + System.out.println("Advanced Segment Updated: " + segment.getUpdated()); + } + } + } +} diff --git a/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/McfReportingApiReferenceSample.java b/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/McfReportingApiReferenceSample.java new file mode 100644 index 00000000..ededed80 --- /dev/null +++ b/analytics-cmdline-sample/src/main/java/com/google/api/services/samples/analytics/cmdline/McfReportingApiReferenceSample.java @@ -0,0 +1,363 @@ +/* + * Copyright (c) 2012 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.api.services.samples.analytics.cmdline; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp; +import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; +import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; +import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.googleapis.json.GoogleJsonResponseException; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.util.store.DataStoreFactory; +import com.google.api.client.util.store.FileDataStoreFactory; +import com.google.api.services.analytics.Analytics; +import com.google.api.services.analytics.AnalyticsScopes; +import com.google.api.services.analytics.model.McfData; +import com.google.api.services.analytics.model.McfData.ColumnHeaders; +import com.google.api.services.analytics.model.McfData.ProfileInfo; +import com.google.api.services.analytics.model.McfData.Query; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * This application demonstrates how to use the Google Analytics Java client library to access all + * the pieces of data returned by the Google Analytics Multi-Channel Funnels API v3. + * + * To run this, you must supply your profile ID. Read the Core Reporting API developer guide to + * learn how to get this value. + * + * @author nafi@google.com + * @author api.nickm@gmail.com + */ +public class McfReportingApiReferenceSample { + + /** + * Be sure to specify the name of your application. If the application name is {@code null} or + * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0". + */ + private static final String APPLICATION_NAME = ""; + + /** Directory to store user credentials. */ + private static final java.io.File DATA_STORE_DIR = + new java.io.File(System.getProperty("user.home"), ".store/analytics_sample"); + + /** + * Global instance of the {@link DataStoreFactory}. The best practice is to make it a single + * globally shared instance across your application. + */ + private static FileDataStoreFactory DATA_STORE_FACTORY; + + /** Global instance of the HTTP transport. */ + private static HttpTransport HTTP_TRANSPORT; + + /** Global instance of the JSON factory. */ + private static final JsonFactory JSON_FACTORY = new JacksonFactory(); + + /** + * TABLE ID of the format 'ga:xxx' where 'xxx' is your profile ID. + */ + private static final String TABLE_ID = "_your_table_id_"; + + private static final String MCF_SEQUENCE_TYPE = "MCF_SEQUENCE"; + private static final String INTEGER_TYPE = "INTEGER"; + + /** + * Main demo. This first initializes an analytics service object. It then uses the MCF API to + * retrieve the top 25 source paths with most total conversions. It will also retrieve the top 25 + * organic sources with most total conversions. Finally the results are printed to the screen. If + * an API error occurs, it is printed here. + * + * @param args command line args. + */ + public static void main(String[] args) { + try { + HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); + DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR); + Analytics analytics = initializeAnalytics(); + + McfData mcfPathData = executePathQuery(analytics, TABLE_ID); + printAllInfo(mcfPathData); + + McfData mcfInteractionData = executeInteractionQuery(analytics, TABLE_ID); + printAllInfo(mcfInteractionData); + + } catch (GoogleJsonResponseException e) { + System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + + e.getDetails().getMessage()); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + /** + * Print all data returned from the API. + * + * @param mcfData the data returned from the API. + */ + public static void printAllInfo(McfData mcfData) { + printReportInfo(mcfData); + printProfileInfo(mcfData); + printQueryInfo(mcfData); + printPaginationInfo(mcfData); + printTotalsForAllResults(mcfData); + printColumnHeaders(mcfData); + printDataTable(mcfData); + System.out.println(); + System.out.println(); + } + + /** Authorizes the installed application to access user's protected data. */ + private static Credential authorize() throws Exception { + // load client secrets + GoogleClientSecrets clientSecrets = GoogleClientSecrets.load( + JSON_FACTORY, new InputStreamReader( + HelloAnalyticsApiSample.class.getResourceAsStream("/client_secrets.json"))); + if (clientSecrets.getDetails().getClientId().startsWith("Enter") + || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { + System.out.println( + "Enter Client ID and Secret from https://code.google.com/apis/console/?api=analytics " + + "into analytics-cmdline-sample/src/main/resources/client_secrets.json"); + System.exit(1); + } + // set up authorization code flow + GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( + HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, + Collections.singleton(AnalyticsScopes.ANALYTICS_READONLY)).setDataStoreFactory( + DATA_STORE_FACTORY).build(); + // authorize + return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user"); + } + + /** + * Performs all necessary setup steps for running requests against the API. + * + * @return an initialized Analytics service object. + * + * @throws Exception if an issue occurs with OAuth2Native authorize. + */ + private static Analytics initializeAnalytics() throws Exception { + // Authorization. + Credential credential = authorize(); + + // Set up and return Google Analytics API client. + return new Analytics.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName( + APPLICATION_NAME).build(); + } + + /** + * Returns the top 25 source paths with most total conversions. The MCF API is used to retrieve + * this data. + * + * @param analytics The analytics service object used to access the API. + * @param tableId The table ID from which to retrieve data. + * @return The response from the API. + * @throws IOException If an API error occurred. + */ + private static McfData executePathQuery(Analytics analytics, String tableId) throws IOException { + return analytics.data().mcf().get(tableId, "2012-01-01", // Start date. + "2012-03-31", // End date. + "mcf:totalConversions") // Metrics. + .setDimensions("mcf:sourcePath") + .setSort("-mcf:totalConversions") + .setMaxResults(25) + .execute(); + } + + /** + * Returns the top 25 organic sources with most total conversions. The MCF API is used to retrieve + * this data. + * + * @param analytics The analytics service object used to access the API. + * @param tableId The table ID from which to retrieve data. + * @return The response from the API. + * @throws IOException If an API error occurred. + */ + private static McfData executeInteractionQuery(Analytics analytics, String tableId) + throws IOException { + return analytics.data().mcf().get(tableId, "2012-01-01", // Start date. + "2012-03-31", // End date. + "mcf:totalConversions") // Metrics. + .setDimensions("mcf:source") + .setSort("-mcf:totalConversions") + .setFilters("mcf:medium==organic") + .setMaxResults(25) + .execute(); + } + + /** + * Prints general information about this report. + * + * @param mcfData the data returned from the API. + */ + private static void printReportInfo(McfData mcfData) { + System.out.println(); + System.out.println("Report Info:"); + System.out.println("ID:" + mcfData.getId()); + System.out.println("Self link: " + mcfData.getSelfLink()); + System.out.println("Kind: " + mcfData.getKind()); + System.out.println("Contains Sampled Data: " + mcfData.getContainsSampledData()); + System.out.println(); + } + + /** + * Prints general information about the profile from which this report was accessed. + * + * @param mcfData the data returned from the API. + */ + private static void printProfileInfo(McfData mcfData) { + ProfileInfo profileInfo = mcfData.getProfileInfo(); + + System.out.println("Profile Info:"); + System.out.println("Account ID: " + profileInfo.getAccountId()); + System.out.println("Web Property ID: " + profileInfo.getWebPropertyId()); + System.out.println("Internal Web Property ID: " + profileInfo.getInternalWebPropertyId()); + System.out.println("Profile ID: " + profileInfo.getProfileId()); + System.out.println("Profile Name: " + profileInfo.getProfileName()); + System.out.println("Table ID: " + profileInfo.getTableId()); + System.out.println(); + } + + /** + * Prints the values of all the parameters that were used to query the API. + * + * @param mcfData the data returned from the API. + */ + private static void printQueryInfo(McfData mcfData) { + Query query = mcfData.getQuery(); + + System.out.println("Query Info:"); + System.out.println("Ids: " + query.getIds()); + System.out.println("Start Date: " + query.getStartDate()); + System.out.println("End Date: " + query.getEndDate()); + System.out.println("Metrics: " + query.getMetrics()); // List + System.out.println("Dimensions: " + query.getDimensions()); // List + System.out.println("Sort: " + query.getSort()); // List + System.out.println("Segment: " + query.getSegment()); + System.out.println("Filters: " + query.getFilters()); + System.out.println("Start Index: " + query.getStartIndex()); + System.out.println("Max Results: " + query.getMaxResults()); + System.out.println(); + } + + /** + * Prints common pagination information. + * + * @param mcfData the data returned from the API. + */ + private static void printPaginationInfo(McfData mcfData) { + System.out.println("Pagination Info:"); + System.out.println("Previous Link: " + mcfData.getPreviousLink()); + System.out.println("Next Link: " + mcfData.getNextLink()); + System.out.println("Items Per Page: " + mcfData.getItemsPerPage()); + System.out.println("Total Results: " + mcfData.getTotalResults()); + System.out.println(); + } + + /** + * Prints the total metric value for all rows the query matched. + * + * @param mcfData the data returned from the API. + */ + private static void printTotalsForAllResults(McfData mcfData) { + System.out.println("Metric totals over all results:"); + Map totalsMap = mcfData.getTotalsForAllResults(); + for (Map.Entry entry : totalsMap.entrySet()) { + System.out.println(entry.getKey() + " : " + entry.getValue()); + } + System.out.println(); + } + + /** + * Prints the information for each column. The reporting data from the API is returned as rows of + * data. The column headers describe the names and types of each column in rows. + * + * @param mcfData the data returned from the API. + */ + private static void printColumnHeaders(McfData mcfData) { + System.out.println("Column Headers:"); + + for (ColumnHeaders header : mcfData.getColumnHeaders()) { + System.out.println("Column Name: " + header.getName()); + System.out.println("Column Type: " + header.getColumnType()); + System.out.println("Column Data Type: " + header.getDataType()); + } + System.out.println(); + } + + /** + * Prints all the rows of data returned by the API. + * + * @param mcfData the data returned from the API. + */ + private static void printDataTable(McfData mcfData) { + System.out.println("Data Table:"); + if (mcfData.getTotalResults() > 0) { + // Print the column names. + List headers = mcfData.getColumnHeaders(); + for (ColumnHeaders header : headers) { + if (header.getDataType().equals(MCF_SEQUENCE_TYPE)) { + System.out.printf("%-50s", header.getName()); + } else { + System.out.printf("%25s", header.getName()); + } + } + System.out.println(); + + // Print the rows of data. + for (List row : mcfData.getRows()) { + for (int columnIndex = 0; columnIndex < row.size(); ++columnIndex) { + ColumnHeaders header = headers.get(columnIndex); + McfData.Rows cell = row.get(columnIndex); + if (header.getDataType().equals(MCF_SEQUENCE_TYPE)) { + System.out.printf( + "%-50s", getStringFromMcfSequence(cell.getConversionPathValue(), " > ")); + } else if (header.getDataType().equals(INTEGER_TYPE)) { + System.out.printf("%25d", Long.parseLong(cell.getPrimitiveValue())); + } else { + System.out.printf("%25s", cell.getPrimitiveValue()); + } + } + System.out.println(); + } + } else { + System.out.println("No rows found"); + } + System.out.println(); + } + + /** + * Builds and gets a string to represent the path data contained in a list of + * McfData.Rows.ConversionPathValue objects. + * + * @param path List of MCF path elements. + * @param delimiter The string that will be used while joining all path elements. + */ + private static String getStringFromMcfSequence( + List path, String delimiter) { + StringBuilder stringBuilder = new StringBuilder(); + for (McfData.Rows.ConversionPathValue pathElement : path) { + if (stringBuilder.length() > 0) stringBuilder.append(delimiter); + stringBuilder.append(pathElement.getNodeValue()); + } + return stringBuilder.toString(); + } +} diff --git a/analytics-cmdline-sample/src/main/resources/client_secrets.json b/analytics-cmdline-sample/src/main/resources/client_secrets.json new file mode 100644 index 00000000..e448bab9 --- /dev/null +++ b/analytics-cmdline-sample/src/main/resources/client_secrets.json @@ -0,0 +1,6 @@ +{ + "installed": { + "client_id": "Enter Client ID", + "client_secret": "Enter Client Secret" + } +} diff --git a/bigquery-appengine-sample/.checkstyle b/bigquery-appengine-sample/.checkstyle new file mode 100644 index 00000000..c302f857 --- /dev/null +++ b/bigquery-appengine-sample/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bigquery-appengine-sample/.classpath b/bigquery-appengine-sample/.classpath new file mode 100644 index 00000000..0f7cd608 --- /dev/null +++ b/bigquery-appengine-sample/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/bigquery-appengine-sample/.project b/bigquery-appengine-sample/.project new file mode 100644 index 00000000..fc490aea --- /dev/null +++ b/bigquery-appengine-sample/.project @@ -0,0 +1,39 @@ + + + bigquery-appengine-sample + + + + + + com.google.appengine.eclipse.core.projectValidator + + + + + com.google.gdt.eclipse.core.webAppProjectValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + com.google.appengine.eclipse.core.enhancerbuilder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + com.google.appengine.eclipse.core.gaeNature + + diff --git a/bigquery-appengine-sample/.settings/com.google.appengine.eclipse.core.prefs b/bigquery-appengine-sample/.settings/com.google.appengine.eclipse.core.prefs new file mode 100644 index 00000000..e73342c6 --- /dev/null +++ b/bigquery-appengine-sample/.settings/com.google.appengine.eclipse.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +filesCopiedToWebInfLib=appengine-api-1.0-sdk-1.8.2.jar|appengine-api-labs.jar|appengine-endpoints.jar|appengine-jsr107cache-1.8.2.jar|datanucleus-appengine-1.0.10.final.jar|datanucleus-core-1.1.5.jar|datanucleus-jpa-1.1.5.jar|geronimo-jpa_3.0_spec-1.1.1.jar|geronimo-jta_1.1_spec-1.1.1.jar|jdo2-api-2.3-eb.jar|jsr107cache-1.1.jar +gaeDeployDialogSettings= diff --git a/bigquery-appengine-sample/.settings/com.google.gdt.eclipse.core.prefs b/bigquery-appengine-sample/.settings/com.google.gdt.eclipse.core.prefs new file mode 100644 index 00000000..416f1aad --- /dev/null +++ b/bigquery-appengine-sample/.settings/com.google.gdt.eclipse.core.prefs @@ -0,0 +1,5 @@ +#Fri Nov 04 10:12:20 PDT 2011 +eclipse.preferences.version=1 +jarsExcludedFromWebInfLib= +warSrcDir=target/war +warSrcDirIsOutput=true diff --git a/bigquery-appengine-sample/.settings/com.google.gwt.eclipse.core.prefs b/bigquery-appengine-sample/.settings/com.google.gwt.eclipse.core.prefs new file mode 100644 index 00000000..265a336e --- /dev/null +++ b/bigquery-appengine-sample/.settings/com.google.gwt.eclipse.core.prefs @@ -0,0 +1,4 @@ +#Wed Nov 09 11:40:20 PST 2011 +eclipse.preferences.version=1 +entryPointModules= +filesCopiedToWebInfLib= diff --git a/bigquery-appengine-sample/.settings/org.eclipse.core.resources.prefs b/bigquery-appengine-sample/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..dd5aeb3b --- /dev/null +++ b/bigquery-appengine-sample/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +#Fri Nov 11 13:26:55 PST 2011 +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 diff --git a/bigquery-appengine-sample/.settings/org.eclipse.jdt.core.prefs b/bigquery-appengine-sample/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..faf086f4 --- /dev/null +++ b/bigquery-appengine-sample/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,380 @@ +#Fri Nov 04 10:10:38 EDT 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.annotationSuperInterface=ignore +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_member=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=24 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=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|5|48 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_field_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_for_statement=16 +org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments=16 +org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16|5|80 +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|4|49 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16|4|48 +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=false +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=100 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph=true +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.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.force_if_else_statement_brace=true +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +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_field=insert +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_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=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_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=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=do not 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.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +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=100 +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.sort_local_variable_annotations=false +org.eclipse.jdt.core.formatter.sort_member_annotations=false +org.eclipse.jdt.core.formatter.sort_package_annotations=false +org.eclipse.jdt.core.formatter.sort_parameter_annotations=false +org.eclipse.jdt.core.formatter.sort_type_annotations=false +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_comment_inline_tags=false +org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation=false +org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments=false diff --git a/bigquery-appengine-sample/.settings/org.eclipse.jdt.ui.prefs b/bigquery-appengine-sample/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..96ded168 --- /dev/null +++ b/bigquery-appengine-sample/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,118 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=true +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=true +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_google-api-java-client +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_google-api-java-client 100 +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=exception +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=com;org;;java;javax; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=999 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=999 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=false +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=false +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/bigquery-appengine-sample/.settings/org.eclipse.ltk.core.refactoring.prefs b/bigquery-appengine-sample/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 00000000..daf4a5fa --- /dev/null +++ b/bigquery-appengine-sample/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,3 @@ +#Wed Nov 09 11:44:08 PST 2011 +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/bigquery-appengine-sample/.settings/org.eclipse.m2e.core.prefs b/bigquery-appengine-sample/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..939fa436 --- /dev/null +++ b/bigquery-appengine-sample/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Fri Nov 11 13:26:41 PST 2011 +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/bigquery-appengine-sample/instructions.html b/bigquery-appengine-sample/instructions.html new file mode 100644 index 00000000..ad05c8ef --- /dev/null +++ b/bigquery-appengine-sample/instructions.html @@ -0,0 +1,144 @@ + +Google Bigquery App Engine Dashboard Sample + +

Instructions for the Google Bigquery App Engine Dashboard Sample

+ +

Browse Source Code

+ + + +

Register Your Application

+ +
    +
  • Visit the Google Cloud + console. +
  • +
  • If necessary, sign in to your Google Account, select or create a project, + and agree to the terms of service. Click Continue.
  • +
  • Select the "Web Application" platform, and click Register.
  • +
  • Within "OAuth 2.0 Client ID", click on "Download JSON". Later on, after you check + out the sample project, you will copy this downloaded file (e.g. + ~/Downloads/client_secrets.json) to + src/main/resources/client_secrets.json. + If you skip this step, when trying to run the sample you will get a 400 + INVALID_CLIENT error in the browser. +
  • +
  • Within "OAuth 2.0 Client ID", in the "Redirect URI" field enter some + redirect URIs, for example + "https://yourappname.appspot.com/oauth2callback" and + "http://localhost:8888/oauth2callback". +
  • +
+ +

Checkout Instructions

+ +

+ Prerequisites: install Java 6, Google App Engine, + Mercurial, + and Maven. You may + need to set your + JAVA_HOME + . +

+ +
+cd [someDirectory]
+hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
+cd google-api-java-client-samples/bigquery-appengine-sample
+cp ~/Downloads/client_secrets.json src/main/resources/client_secrets.json
+mvn clean package
+  
+ +

To enable logging of HTTP requests and responses (highly recommended + when developing), please take a look at logging.properties.

+ +

Running and Deploying Your Application from the Command Line

+ +

To run your application locally on a development server:

+
+mvn appengine:devserver
+  
+ +

To deploy your application to appspot.com:

+ +

+ If this is the first time you are deploying your application to appspot.com, you will to perform the + following steps first. +

+ +
    +
  • Go to https://appengine.google.com and create an application.
  • +
  • Edit src/main/webapp/WEB-INF/appengine-web.xml, and enter the unique application identifier (you chose it in the prior step) + between the <application> tags.
  • +
+ +

If you've done the above, you can deploy at any time:

+
+mvn appengine:update
+
+ +

If this is the first time you have run "update" on the project, a browser window will open prompting you to log in. + Log in with the same Google account the app is registered with. +

+ +

Setup Project in Eclipse

+ +

+ Prerequisites: install Eclipse, + Google Plugin for Eclipse, and + the Mercurial plugin. +

+ +
    +
  • Setup Eclipse Preferences +
      +
    • Window > Preferences... (or on Mac, Eclipse > + Preferences...)
    • +
    • Select Maven +
        +
      • check on "Download Artifact Sources"
      • +
      • check on "Download Artifact JavaDoc"
      • +
      +
    • +
    +
  • +
  • Import bigquery-appengine-sample project +
      +
    • File > Import...
    • +
    • Select "General > Existing Project into Workspace" and click + "Next"
    • +
    • Click "Browse" next to "Select root directory", find + [someDirectory]/google-api-java-client-samples/bigquery-appengine-sample + and click "Next" +
    • +
    • Click "Finish"
    • +
    • NOTE: please ignore the "The App Engine SDK JAR * is missing in + the WEB-INF/lib directory" error messages.
    • +
    +
  • +
  • Run +
      +
    • Right-click on project bigquery-appengine-sample
    • +
    • Run As > Web Application
    • +
    +
  • +
+ +

FAQ

+
    +
  • I get a 403 Forbidden when trying to run my query. What causes + this?
    The user who is trying to run the query has to be added as a + team member to the project in the API console in order to access the data + associated with the project. +
  • +
  • I get a 404 when I run my query. What could be wrong?
    Make + sure you've added your API Console project ID to the appengine-web.xml. +
  • +
+ + + diff --git a/bigquery-appengine-sample/pom.xml b/bigquery-appengine-sample/pom.xml new file mode 100644 index 00000000..f1a19dbf --- /dev/null +++ b/bigquery-appengine-sample/pom.xml @@ -0,0 +1,231 @@ + + + 4.0.0 + + com.google + google + 5 + + com.google.apis-samples + bigquery-appengine-sample + 1 + bigquery-appengine-sample + war + + + v2-rev154-1.19.0 + 1.1.5 + 1.19.0 + 1.8.3 + ${project.build.directory}/${project.build.finalName} + UTF-8 + + + + war + ${webappDirectory}/WEB-INF/classes + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + com.google.appengine + appengine-maven-plugin + ${project.appengine.version} + + 8888 + + + + + org.datanucleus + maven-datanucleus-plugin + 1.1.4 + + false + ${basedir}/src/main/resources/log4j.properties + **/server/*.class + true + ASM + JPA + + + + + compile + + enhance + + + + + + org.datanucleus + datanucleus-core + ${datanucleus.version} + + + javax.transaction + transaction-api + + + + + org.datanucleus + datanucleus-rdbms + ${datanucleus.version} + + + org.datanucleus + datanucleus-enhancer + 1.1.4 + + + + javax.jdo + jdo2-api + 2.3-ec + runtime + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + + compile + + exploded + + + + + ${webappDirectory} + + + + maven-checkstyle-plugin + 2.6 + + ../checkstyle.xml + true + false + + + + + check + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + false + + + + + check + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-war-plugin + [2.1.1,) + + exploded + + + + + + + + + org.datanucleus + maven-datanucleus-plugin + [1.1.4,) + + enhance + + + + + + + + + + + + + + + + + com.google.appengine + appengine-api-1.0-sdk + ${project.appengine.version} + + + com.google.api-client + google-api-client-appengine + ${google-api-client.version} + + + com.google.api-client + google-api-client-jackson2 + ${google-api-client.version} + + + com.google.apis + google-api-services-bigquery + ${bigquery.version} + + + com.google.code.gson + gson + 2.1 + + + net.sf.jsr107cache + jsr107cache + 1.1 + + + com.google.guava + guava + 14.0 + + + diff --git a/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/BigqueryUtils.java b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/BigqueryUtils.java new file mode 100644 index 00000000..f6187a0b --- /dev/null +++ b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/BigqueryUtils.java @@ -0,0 +1,222 @@ +// Copyright 2011 Google Inc. All Rights Reserved. + +package com.google.api.client.sample.bigquery.appengine.dashboard; + +import com.google.api.client.util.Preconditions; +import com.google.api.services.bigquery.Bigquery; +import com.google.api.services.bigquery.model.Job; +import com.google.api.services.bigquery.model.JobConfiguration; +import com.google.api.services.bigquery.model.JobConfigurationQuery; +import com.google.api.services.bigquery.model.JobReference; +import com.google.api.services.bigquery.model.Table; +import com.google.api.services.bigquery.model.TableDataList; +import com.google.api.services.bigquery.model.TableFieldSchema; +import com.google.api.services.bigquery.model.TableReference; +import com.google.api.services.bigquery.model.TableRow; +import com.google.appengine.api.taskqueue.Queue; +import com.google.appengine.api.taskqueue.QueueFactory; +import com.google.appengine.api.taskqueue.RetryOptions; +import com.google.appengine.api.taskqueue.TaskOptions; +import com.google.common.base.Joiner; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.logging.Logger; + +import javax.servlet.http.HttpServletResponse; + +/** + * Utility methods for beginning jobs, waiting for jobs, and instantiating Bigqueries. + * + * @author lparkinson@google.com (Laura Parkinson) + */ +public class BigqueryUtils { + + private static final Logger log = Logger.getLogger(BigqueryUtils.class.getName()); + static final String projectId = + System.getProperty("com.google.api.client.sample.bigquery.appengine.dashboard.projectId"); + + private final String userId; + final Bigquery bigquery; + private Job job; + + public BigqueryUtils(String userId) throws IOException { + this(userId, null); + } + + public BigqueryUtils(String userId, final String jobId) throws IOException { + this.userId = userId; + + bigquery = ServiceUtils.loadBigqueryClient(userId); + + if (jobId != null) { + job = tryToDo(new Callable() { + @Override + public Job call() throws Exception { + return bigquery.jobs().get(projectId, jobId).execute(); + } + }); + + if (job == null) { + throw new SampleDashboardException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, + "Wasn't able to get a job for jobId " + jobId); + } + } + } + + public void beginQuery() throws SampleDashboardException { + final Job queryJob = makeJob(buildExampleQuery()); + + job = tryToDo(new Callable() { + @Override + public Job call() throws Exception { + return bigquery.jobs().insert(projectId, queryJob).execute(); + } + }); + + Preconditions.checkNotNull(job); + enqueueWaitingTask(); + } + + public boolean jobSucceeded() { + return (job != null && job.getStatus().getErrorResult() == null); + } + + public String getJobErrorMessage() { + if (job != null && job.getStatus().getErrorResult() != null) { + return job.getStatus().getErrorResult().getMessage(); + } + return ""; + } + + public boolean jobIsDone() { + String status = getJobStatus(); + return (status != null && ("DONE").equalsIgnoreCase(status)); + } + + public String getJobStatus() { + return (job != null) ? job.getStatus().getState() : null; + } + + public List getSchemaFieldNames() throws SampleDashboardException { + if (job != null) { + final TableReference tableReference = job.getConfiguration().getQuery().getDestinationTable(); + + Table table = tryToDo(new Callable() { + @Override + public Table call() throws IOException { + return bigquery.tables().get(tableReference.getProjectId(), tableReference.getDatasetId(), + tableReference.getTableId()).execute(); + } + }); + + Preconditions.checkNotNull(table); + Preconditions.checkNotNull(table.getSchema()); + Preconditions.checkNotNull(table.getSchema().getFields()); + return table.getSchema().getFields(); + } + return null; + } + + public List getTableData() throws SampleDashboardException { + if (job != null) { + final TableReference tableReference = job.getConfiguration().getQuery().getDestinationTable(); + + TableDataList tableDataList = tryToDo(new Callable() { + @Override + public TableDataList call() throws IOException { + return bigquery.tabledata().list(tableReference.getProjectId(), + tableReference.getDatasetId(), tableReference.getTableId()).execute(); + } + }); + + Preconditions.checkNotNull(tableDataList); + Preconditions.checkNotNull(tableDataList.getRows()); + return tableDataList.getRows(); + } + return null; + } + + /** + * Constructs a task with necessary parameters and options and puts it in App Engine's default + * task queue. + */ + public void enqueueWaitingTask() { + TaskOptions options = TaskOptions.Builder.withDefaults(); + options.param("jobId", job.getJobReference().getJobId()); + options.param("userId", userId); + options.url("/task"); + options.countdownMillis(1000); + options.retryOptions(RetryOptions.Builder.withTaskRetryLimit(0)); + + Queue queue = QueueFactory.getDefaultQueue(); + queue.add(options); + } + + public static String buildExampleQuery() { + String[] west = {"WA", "OR", "CA", "AK", "HI", "ID", "MT", "WY", "NV", "UT", "CO", "AZ", "NM"}; + String[] south = {"OK", "TX", "AR", "LA", "TN", "MS", "AL", "KY", "GA", "FL", "SC", "NC", "VA", + "WV", "MD", "DC", "DE"}; + String[] midwest = {"ND", "SD", "NE", "KS", "MN", "IA", "MO", "WI", "IL", "IN", "MI", "OH"}; + String[] northeast = {"NY", "PA", "NJ", "CT", "RI", "MA", "VT", "NH", "ME"}; + + Joiner joiner = Joiner.on("', '"); + + String query = "SELECT IF (state IN ('" + joiner.join(west) + "'), 'West', \n\t" + + "IF (state IN ('" + joiner.join(south) + "'), 'South', \n\t" + "IF (state IN ('" + + joiner.join(midwest) + "'), 'Midwest', \n\t" + "IF (state IN ('" + joiner.join(northeast) + + "'), 'Northeast', 'None')))) " + + "as region, \naverage_mother_age, \naverage_father_age, \nstate, \nyear \n" + + "FROM (SELECT year, \n\t\tstate, \n\t\tSUM(mother_age)/COUNT(mother_age) as " + + "average_mother_age, \n\t\tSUM(father_age)/COUNT(father_age) as average_father_age \n\t" + + "FROM publicdata:samples.natality \n\tWHERE father_age < 99 \n\tGROUP BY year, state) \n" + + "ORDER BY year, region;"; + + return query; + } + + /** + * Instantiates an example job and sets required fields. + */ + private Job makeJob(String query) { + JobConfigurationQuery jobconfigurationquery = new JobConfigurationQuery(); + + jobconfigurationquery.setQuery(query); + jobconfigurationquery.setCreateDisposition("CREATE_IF_NEEDED"); + + JobConfiguration jobconfiguration = new JobConfiguration(); + jobconfiguration.setQuery(jobconfigurationquery); + + JobReference jobreference = new JobReference(); + jobreference.setProjectId(projectId); + + Job newJob = new Job(); + newJob.setConfiguration(jobconfiguration); + newJob.setJobReference(jobreference); + + return newJob; + } + + /** + * Attempts to run the given callback with a number of retries. If the callback responds with + * SC_UNAUTHORIZED, the tokens are refreshed. + * + * @throws SampleDashboardException + */ + private T tryToDo(Callable callback) throws SampleDashboardException { + int retries = 3; + int currentTry = 0; + SampleDashboardException sdex = null; + while (currentTry < retries) { + currentTry++; + try { + return callback.call(); + } catch (Exception ex) { + sdex = new SampleDashboardException(ex); + log.warning("Caught exception (" + sdex.getStatusCode() + "): " + ex); + } + } + throw Preconditions.checkNotNull(sdex); + } +} diff --git a/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/DataServlet.java b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/DataServlet.java new file mode 100644 index 00000000..c8604708 --- /dev/null +++ b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/DataServlet.java @@ -0,0 +1,99 @@ +// Copyright 2011 Google Inc. All Rights Reserved. + +package com.google.api.client.sample.bigquery.appengine.dashboard; + +import com.google.appengine.api.datastore.Entity; +import com.google.appengine.api.users.UserServiceFactory; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * This servlet responds to a post request with the data in the datastore for the + * user in the form of json parseable by a DataTable constructor. Also returns + * the stored message and whether their query failed. + * + * @author lparkinson@google.com (Laura Parkinson) + */ +public class DataServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + // It's important that the first column be a string and the second a number. + // Also, it is expected that these are the same length. + private final String[] labels = new String[] + {"State", "Year", "Average Mother Age", "Average Father Age", "U.S. Census Region"}; + private final String[] properties = new String[] + {"state", "year", "average_mother_age", "average_father_age", "region"}; + private final String[] types = new String[] {"string", "number", "number", "number", "string"}; + + /** + * Attempts to retrieve results for the logged-in user. If the datastore contains + * results, they are written into the response as JSON. + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws IOException { + JsonWriter jsonWriter = new JsonWriter(response.getWriter()).beginObject(); + String userId = UserServiceFactory.getUserService().getCurrentUser().getUserId(); + DatastoreUtils datastoreUtils = new DatastoreUtils(userId); + + String jobStatus = datastoreUtils.getUserJobStatus(); + + if (("DONE").equalsIgnoreCase(jobStatus)) { + List results = datastoreUtils.getResults(); + if (!results.isEmpty()) { + writeResultsToMotionChartJson(jsonWriter, results); + } + } + + jsonWriter.name("failed").value(datastoreUtils.hasUserQueryFailed()); + jsonWriter.name("message").value(datastoreUtils.getUserMessage()); + jsonWriter.name("lastRun").value(datastoreUtils.getUserLastRunMessage()); + + jsonWriter.endObject().close(); + } + + /** + * Converts the query results retrieved from the datastore to json parsable by javascript + * into a DataTable object for use with a motion chart. + */ + private void writeResultsToMotionChartJson(JsonWriter jsonWriter, Iterable results) + throws IOException { + jsonWriter.name("data").beginObject(); + + // Write the header. + jsonWriter.name("cols").beginArray(); + for (int i = 0; i < properties.length; i++) { + jsonWriter.beginObject() + .name("id").value(properties[i]) + .name("label").value(labels[i]) + .name("type").value(types[i]) + .endObject(); + } + jsonWriter.endArray(); + + // Write the data. + jsonWriter.name("rows").beginArray(); + for (Entity entity : results) { + jsonWriter.beginObject().name("c").beginArray(); + for (int i = 0; i < properties.length; i++) { + String value = ""; + if (entity.getProperty(properties[i]) != null) { + value = String.valueOf(entity.getProperty(properties[i])); + } + + jsonWriter.beginObject().name("v").value(value).endObject(); + } + jsonWriter.endArray().endObject(); + } + jsonWriter.endArray(); + + jsonWriter.endObject(); + } +} diff --git a/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/DatastoreUtils.java b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/DatastoreUtils.java new file mode 100644 index 00000000..9709d538 --- /dev/null +++ b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/DatastoreUtils.java @@ -0,0 +1,152 @@ +// Copyright 2011 Google Inc. All Rights Reserved. + +package com.google.api.client.sample.bigquery.appengine.dashboard; + +import com.google.api.client.util.Preconditions; +import com.google.api.services.bigquery.model.TableCell; +import com.google.api.services.bigquery.model.TableFieldSchema; +import com.google.api.services.bigquery.model.TableRow; +import com.google.appengine.api.datastore.DatastoreService; +import com.google.appengine.api.datastore.DatastoreServiceFactory; +import com.google.appengine.api.datastore.Entity; +import com.google.appengine.api.datastore.EntityNotFoundException; +import com.google.appengine.api.datastore.FetchOptions; +import com.google.appengine.api.datastore.Key; +import com.google.appengine.api.datastore.KeyFactory; +import com.google.appengine.api.datastore.Query; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; + +/** + * Utility methods for inserting, accessing, and deleting data in the datastore. + * + * @author lparkinson@google.com (Laura Parkinson) + */ +public class DatastoreUtils { + + public static final String FAILED = "FAILED"; + + private final Key userEntityKey; + private final String resultKind; + private final DatastoreService service; + private Entity userEntity; + + public DatastoreUtils(String userId) { + userEntityKey = KeyFactory.createKey("User", userId); + service = DatastoreServiceFactory.getDatastoreService(); + resultKind = userId + "Result"; + + try { + userEntity = service.get(userEntityKey); + } catch (EntityNotFoundException e) { + userEntity = null; + } + } + + public boolean hasUserEntity() { + return userEntity != null; + } + + private void createUserIfNull() { + if (userEntity == null) { + userEntity = new Entity(userEntityKey); + } + } + + /** + * Updates the user entity with the message and status, creating it if necessary. + */ + public void putUserInformation(String message, String status) { + createUserIfNull(); + userEntity.setProperty("jobStatus", status); + userEntity.setProperty("message", message); + service.put(userEntity); + } + + /** + * Updates the user entity with the current time, creating it if necessary. + */ + public void updateSuccessfulQueryTimestamp() { + createUserIfNull(); + userEntity.setProperty("timestamp", System.currentTimeMillis()); + service.put(userEntity); + } + + public String getUserJobStatus() { + return getUserEntityProperty("jobStatus"); + } + + public Boolean hasUserQueryFailed() { + return (FAILED).equalsIgnoreCase(getUserJobStatus()); + } + + public String getUserMessage() { + return getUserEntityProperty("message"); + } + + public String getUserLastRunMessage() { + String timestamp = getUserEntityProperty("timestamp"); + if (timestamp == null) { + return "never"; + } + SimpleDateFormat format = new SimpleDateFormat("k:mm:ss 'on' MMMM d, yyyy zzz"); + Date date = new Date(Long.valueOf(timestamp)); + return format.format(date); + } + + private String getUserEntityProperty(String propertyName) { + if (userEntity != null && userEntity.hasProperty(propertyName)) { + return String.valueOf(userEntity.getProperty(propertyName)); + } + return null; + } + + public List getResults() { + Query query = new Query(resultKind, userEntityKey); + FetchOptions options = FetchOptions.Builder.withChunkSize(2000); + return service.prepare(query).asList(options); + } + + /** + * Removes any existing results for the user from the datastore. + */ + public void deleteExistingResults() { + ArrayList keys = new ArrayList(); + List results = getResults(); + for (Entity entity : results) { + keys.add(entity.getKey()); + } + service.delete(keys); + } + + /** + * Copies each row of the given data into an entity, then puts all the entities + * to the datastore with the user's entity as their ancestor. + */ + public void copyQueryResultsToDatastore(List fields, + List rows) { + ArrayList entities = new ArrayList(); + Iterator rowsIterator = rows.iterator(); + while (rowsIterator.hasNext()) { + Entity entity = new Entity(resultKind, userEntityKey); + + // Copy the row into the entity -- fields become properties. + Iterator fieldsIterator = fields.iterator(); + Iterator dataIterator = rowsIterator.next().getF().iterator(); + + Preconditions.checkState(fieldsIterator.hasNext() == dataIterator.hasNext()); + while (fieldsIterator.hasNext() && dataIterator.hasNext()) { + Object value = dataIterator.next().getV(); + String strValue = (value != null) ? String.valueOf(value) : null; + entity.setProperty(fieldsIterator.next().getName(), strValue); + Preconditions.checkState(fieldsIterator.hasNext() == dataIterator.hasNext()); + } + entities.add(entity); + } + service.put(entities); + } +} diff --git a/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/MainServlet.java b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/MainServlet.java new file mode 100644 index 00000000..d9bb72d0 --- /dev/null +++ b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/MainServlet.java @@ -0,0 +1,116 @@ +// Copyright 2011 Google Inc. All Rights Reserved. + +package com.google.api.client.sample.bigquery.appengine.dashboard; + +import com.google.api.client.auth.oauth2.AuthorizationCodeFlow; +import com.google.api.client.extensions.appengine.auth.oauth2.AbstractAppEngineAuthorizationCodeServlet; + +import java.io.IOException; +import java.util.logging.Logger; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author lparkinson@google.com (Laura Parkinson) + * + */ +public class MainServlet extends AbstractAppEngineAuthorizationCodeServlet { + + private static final long serialVersionUID = 1L; + private static final Logger log = Logger.getLogger(MainServlet.class.getName()); + + /** + * This servlet responds to a GET request with a stencil page that will be filled with a chart and + * a message by client-side javascript. Also, if no data exists in the datastore for the current + * user, it sends a query to retrieve it. + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + String userId = getUserId(request); + DatastoreUtils datastoreUtils = new DatastoreUtils(userId); + + printPage(response, datastoreUtils.getUserLastRunMessage()); + + // Try to get data if this user is unknown, or if their last try failed. + if (!datastoreUtils.hasUserEntity() || datastoreUtils.hasUserQueryFailed()) { + runQuery(request, response, userId, datastoreUtils); + } + } + + private void runQuery(HttpServletRequest request, HttpServletResponse response, String userId, + DatastoreUtils datastoreUtils) throws IOException { + // Clear the information from the last run for this user + datastoreUtils.putUserInformation("Beginning query...", null); + + String message; + String status = DatastoreUtils.FAILED; + + try { + // Begin a query. A task is begun to wait for the results of the query, + // and when the query finishes, that task (see TaskServlet) takes care + // of copying the results to the datastore. + BigqueryUtils bigqueryUtils = new BigqueryUtils(userId); + bigqueryUtils.beginQuery(); + message = "Began running your query"; + status = bigqueryUtils.getJobStatus(); + + } catch (SampleDashboardException ex) { + if (ex.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) { + ServiceUtils.deleteCredentials(userId); + message = "There was a problem running the query with your credentials. Refresh, please!"; + } + else { + message = "Encountered an exception (" + ex.getStatusCode() + "): " + ex.getMessage(); + log.severe(message); + } + } + + datastoreUtils.putUserInformation(message, status); + } + + /** + * A post to this servlet reruns the query for the logged-in user. + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + String userId = getUserId(request); + DatastoreUtils datastoreUtils = new DatastoreUtils(userId); + runQuery(request, response, userId, datastoreUtils); + } + + private void printPage(HttpServletResponse response, String lastRun) throws IOException { + response.setContentType("text/html"); + response.setCharacterEncoding("UTF-8"); + response.getWriter().print("" + + "" + + "" + + "Bigquery sample dashboard
" + + "" + + "Query last run: " + lastRun + "

" + + "
Checking the datastore for cached results...
" + + "

" + + "Show query that generated these results
" + + htmlify(BigqueryUtils.buildExampleQuery()) + "
"); + } + + private String htmlify(String s) { + s = s.replace("\n", "
"); + s = s.replace("\t", "    "); + s = s.replace(" ", " "); + return s; + } + + @Override + protected AuthorizationCodeFlow initializeFlow() throws IOException { + return ServiceUtils.newFlow(); + } + + @Override + protected String getRedirectUri(HttpServletRequest req) { + return ServiceUtils.getRedirectUri(req); + } +} diff --git a/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/OAuth2Callback.java b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/OAuth2Callback.java new file mode 100644 index 00000000..d7cb5109 --- /dev/null +++ b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/OAuth2Callback.java @@ -0,0 +1,51 @@ +// Copyright 2011 Google Inc. All Rights Reserved. + +package com.google.api.client.sample.bigquery.appengine.dashboard; + +import com.google.api.client.auth.oauth2.AuthorizationCodeFlow; +import com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl; +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.extensions.appengine.auth.oauth2.AbstractAppEngineAuthorizationCodeCallbackServlet; +import com.google.appengine.api.users.UserServiceFactory; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Holds information used in the authorization flow, such as which URL to redirect + * to on success/failure. + * + * @author lparkinson@google.com (Laura Parkinson) + */ +public class OAuth2Callback extends AbstractAppEngineAuthorizationCodeCallbackServlet { + + private static final long serialVersionUID = 1L; + + @Override + protected void onSuccess(HttpServletRequest req, HttpServletResponse resp, Credential credential) + throws IOException { + resp.sendRedirect("/"); + } + + @Override + protected void onError( + HttpServletRequest req, HttpServletResponse resp, AuthorizationCodeResponseUrl errorResponse) + throws IOException { + String nickname = UserServiceFactory.getUserService().getCurrentUser().getNickname(); + resp.getWriter().print("

" + nickname + ", why don't you want to play with me?

"); + resp.setStatus(200); + resp.addHeader("Content-Type", "text/html"); + } + + @Override + protected String getRedirectUri(HttpServletRequest req) { + return ServiceUtils.getRedirectUri(req); + } + + @Override + protected AuthorizationCodeFlow initializeFlow() throws IOException { + return ServiceUtils.newFlow(); + } +} diff --git a/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/SampleDashboardException.java b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/SampleDashboardException.java new file mode 100644 index 00000000..6489c736 --- /dev/null +++ b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/SampleDashboardException.java @@ -0,0 +1,43 @@ +// Copyright 2011 Google Inc. All Rights Reserved. + +package com.google.api.client.sample.bigquery.appengine.dashboard; + +import org.apache.http.client.HttpResponseException; + +import javax.servlet.http.HttpServletResponse; + +/** + * Exception to wrap an arbitrary exception as a HttpResponseException. + * + * @author lparkinson@google.com (Laura Parkinson) + */ +public class SampleDashboardException extends HttpResponseException { + + private static final long serialVersionUID = 1L; + + public SampleDashboardException(int statusCode, String s) { + super(statusCode, s); + } + + public SampleDashboardException(Exception ex) { + super(getStatusFromException(ex), getMessageFromException(ex)); + } + + private static String getMessageFromException(Exception ex) { + if (ex instanceof com.google.api.client.http.HttpResponseException) { + com.google.api.client.http.HttpResponseException hrex = + (com.google.api.client.http.HttpResponseException) ex; + return "The server encountered an exception: " + hrex.getStatusMessage(); + } + return "The server encountered an exception: " + ex.getMessage(); + } + + private static int getStatusFromException(Exception ex) { + if (ex instanceof com.google.api.client.http.HttpResponseException) { + com.google.api.client.http.HttpResponseException hrex = + (com.google.api.client.http.HttpResponseException) ex; + return hrex.getStatusCode(); + } + return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; + } +} diff --git a/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/ServiceUtils.java b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/ServiceUtils.java new file mode 100644 index 00000000..113ef611 --- /dev/null +++ b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/ServiceUtils.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2012 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.api.client.sample.bigquery.appengine.dashboard; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.extensions.appengine.datastore.AppEngineDataStoreFactory; +import com.google.api.client.extensions.appengine.http.UrlFetchTransport; +import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; +import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; +import com.google.api.client.http.GenericUrl; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.util.Preconditions; +import com.google.api.client.util.store.DataStoreFactory; +import com.google.api.services.bigquery.Bigquery; +import com.google.api.services.bigquery.BigqueryScopes; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Collections; + +import javax.servlet.http.HttpServletRequest; + +/** + * Utility class for Google service related tasks, for example JDO persistence, OAuth flow helpers, + * and others. + * + * @author Matthias Linder (mlinder) + */ +class ServiceUtils { + + /** Global instance of the HTTP transport. */ + static final HttpTransport HTTP_TRANSPORT = new UrlFetchTransport(); + + /** Global instance of the JSON factory. */ + static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); + + /** + * Global instance of the {@link DataStoreFactory}. The best practice is to make it a single + * globally shared instance across your application. + */ + private static final AppEngineDataStoreFactory DATA_STORE_FACTORY = + AppEngineDataStoreFactory.getDefaultInstance(); + + private static GoogleClientSecrets clientSecrets = null; + + static GoogleClientSecrets getClientCredential() throws IOException { + if (clientSecrets == null) { + clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, + new InputStreamReader(ServiceUtils.class.getResourceAsStream("/client_secrets.json"))); + Preconditions.checkArgument(!clientSecrets.getDetails().getClientId().startsWith("Enter ") + && !clientSecrets.getDetails().getClientSecret().startsWith("Enter "), + "Enter Client ID and Secret from https://code.google.com/apis/console/?api=bigquery " + + "into bigquery-appengine-sample/src/main/resources/client_secrets.json"); + } + return clientSecrets; + } + + static String getRedirectUri(HttpServletRequest req) { + GenericUrl url = new GenericUrl(req.getRequestURL().toString()); + url.setRawPath("/oauth2callback"); + return url.build(); + } + + static void deleteCredentials(String userId) throws IOException { + GoogleAuthorizationCodeFlow flow = newFlow(); + Credential credential = flow.loadCredential(userId); + if (credential != null) { + flow.getCredentialDataStore().delete(userId); + } + } + + static GoogleAuthorizationCodeFlow newFlow() throws IOException { + return new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, + getClientCredential(), Collections.singleton(BigqueryScopes.BIGQUERY)).setDataStoreFactory( + DATA_STORE_FACTORY).setAccessType("offline").build(); + } + + static Bigquery loadBigqueryClient(String userId) throws IOException { + Credential credential = newFlow().loadCredential(userId); + return new Bigquery.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).build(); + } + + private ServiceUtils() { + } +} diff --git a/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/TaskServlet.java b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/TaskServlet.java new file mode 100644 index 00000000..3df9bcac --- /dev/null +++ b/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard/TaskServlet.java @@ -0,0 +1,81 @@ +// Copyright 2011 Google Inc. All Rights Reserved. + +package com.google.api.client.sample.bigquery.appengine.dashboard; + +import java.io.IOException; +import java.util.logging.Logger; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * This servlet receives a post request when the task that was waiting for the query to finish comes + * out of the App Engine task queue. It gets the status of the query from Bigquery and: + *
    + *
  • copies the results to the datastore if the query has finished successfully
  • + *
  • enqueues another task to wait if the query is running/pending
  • + *
  • handles query failure
  • + *
+ * + * Note: Because of the auth-constraint defined in web.xml, this can only be called by App + * Engine, and not by users. + * + * @author lparkinson@google.com (Laura Parkinson) + */ +public class TaskServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + private static final Logger log = Logger.getLogger(TaskServlet.class.getName()); + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws IOException { + String userId = request.getParameter("userId"); + String jobId = request.getParameter("jobId"); + + DatastoreUtils datastoreUtils = new DatastoreUtils(userId); + String message; + String status = DatastoreUtils.FAILED; + + try { + BigqueryUtils bigqueryUtils = new BigqueryUtils(userId, jobId); + + // If the job is done, handle it; otherwise, enqueue another task to wait for it. + if (bigqueryUtils.jobIsDone()) { + // Delete any previous results for this user. + datastoreUtils.deleteExistingResults(); + + // If the job succeeded, copy the results to the datastore. + if (bigqueryUtils.jobSucceeded()) { + datastoreUtils.copyQueryResultsToDatastore( + bigqueryUtils.getSchemaFieldNames(), bigqueryUtils.getTableData()); + + message = "Here are your results!"; + status = bigqueryUtils.getJobStatus(); + + datastoreUtils.updateSuccessfulQueryTimestamp(); + } else { + message = bigqueryUtils.getJobErrorMessage(); + } + } else { + // If it's not done, keep waiting for it. + String jobStatus = bigqueryUtils.getJobStatus(); + bigqueryUtils.enqueueWaitingTask(); + message = "Waiting for the results of the query (" + jobStatus.toLowerCase() + ")"; + status = jobStatus; + } + } catch (SampleDashboardException ex) { + if (ex.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) { + ServiceUtils.deleteCredentials(userId); + message = "There was a problem running the query with your credentials. Refresh, please!"; + } else { + message = "Encountered an exception (" + ex.getStatusCode() + "): " + ex.getMessage(); + log.severe(message); + } + } + + // Update the datastore with the new message and status. + datastoreUtils.putUserInformation(message, status); + } +} diff --git a/calendar-v2-atom-oauth-appengine-sample/src/META-INF/jdoconfig.xml b/bigquery-appengine-sample/src/main/resources/META-INF/jdoconfig.xml similarity index 100% rename from calendar-v2-atom-oauth-appengine-sample/src/META-INF/jdoconfig.xml rename to bigquery-appengine-sample/src/main/resources/META-INF/jdoconfig.xml diff --git a/bigquery-appengine-sample/src/main/resources/client_secrets.json b/bigquery-appengine-sample/src/main/resources/client_secrets.json new file mode 100644 index 00000000..351dbb28 --- /dev/null +++ b/bigquery-appengine-sample/src/main/resources/client_secrets.json @@ -0,0 +1,6 @@ +{ + "web": { + "client_id": "Enter Client ID", + "client_secret": "Enter Client Secret" + } +} diff --git a/bigquery-appengine-sample/src/main/webapp/WEB-INF/appengine-web.xml b/bigquery-appengine-sample/src/main/webapp/WEB-INF/appengine-web.xml new file mode 100644 index 00000000..f405ee73 --- /dev/null +++ b/bigquery-appengine-sample/src/main/webapp/WEB-INF/appengine-web.xml @@ -0,0 +1,32 @@ + + + + + 1 + + + + true + + + + + + + + + + + + + + + + + + + + diff --git a/bigquery-appengine-sample/src/main/webapp/WEB-INF/logging.properties b/bigquery-appengine-sample/src/main/webapp/WEB-INF/logging.properties new file mode 100644 index 00000000..0c2ea51b --- /dev/null +++ b/bigquery-appengine-sample/src/main/webapp/WEB-INF/logging.properties @@ -0,0 +1,13 @@ +# A default java.util.logging configuration. +# (All App Engine logging is through java.util.logging by default). +# +# To use this configuration, copy it into your application's WEB-INF +# folder and add the following to your appengine-web.xml: +# +# +# +# +# + +# Set the default logging level for all loggers to WARNING +.level = WARNING diff --git a/bigquery-appengine-sample/src/main/webapp/WEB-INF/web.xml b/bigquery-appengine-sample/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..d7b008d4 --- /dev/null +++ b/bigquery-appengine-sample/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,69 @@ + + + + + + oauth2Callback + com.google.api.client.sample.bigquery.appengine.dashboard.OAuth2Callback + + + + oauth2Callback + /oauth2callback/* + + + + taskServlet + com.google.api.client.sample.bigquery.appengine.dashboard.TaskServlet + + + + taskServlet + /task + + + + dataServlet + com.google.api.client.sample.bigquery.appengine.dashboard.DataServlet + + + + dataServlet + /data + + + + mainServlet + com.google.api.client.sample.bigquery.appengine.dashboard.MainServlet + + + + mainServlet + / + + + + + any + /* + + + * + + + + + + any + /task + + + admin + + + + diff --git a/bigquery-appengine-sample/src/main/webapp/drawGraph.js b/bigquery-appengine-sample/src/main/webapp/drawGraph.js new file mode 100644 index 00000000..e5cb91ed --- /dev/null +++ b/bigquery-appengine-sample/src/main/webapp/drawGraph.js @@ -0,0 +1,60 @@ +// Copyright 2011 Google Inc. All Rights Reserved. + +/** + * @fileoverview This script posts to the data servlet with a request for data + * to display until either the servlet responds with data or responds that it + * failed. The servlet responds to each post with a message, which the script + * displays to the user and data if it exists, which the script draws as a + * motion chart. + * + * @author lparkinson@google.com (Laura Parkinson) + */ + +// Load the motion chart package from the Visualization API and JQuery. +google.load('visualization', '1', {packages: ['motionchart']}); +google.load('jquery', '1.6.4'); + +// Set a callback to run when the Google Visualization API is loaded. +google.setOnLoadCallback(doOnLoad); + +function doOnLoad() { + $('#query').hide(); + $('#toggle').click(function() { + $('#query').toggle(); + }); + + $('#refresh').click(function() { + $('#refresh').attr('disabled', 'disabled'); + $('#message').html('Requesting that the query be rerun...'); + $.post('/', function() { + setTimeout(postCheck, 2000); + }); + }); + + postCheck(); +} + +function postCheck() { + $.post('/data', function(dataObject) { + $('#message').html(dataObject.message); + + if (!dataObject.data && !dataObject.failed) { + setTimeout(postCheck, 2000); + } else { + $('#refresh').removeAttr('disabled'); + if (dataObject.data) { + $('#lastRun').html(dataObject.lastRun); + + var width = 800; + var height = 400; + var viz = $('#visualization'); + viz.css('width', width); + viz.css('height', height); + + var dataTable = new google.visualization.DataTable(dataObject.data); + var motionchart = new google.visualization.MotionChart(viz[0]); + motionchart.draw(dataTable, {width: width, height: height}); + } + } + }, 'json'); +} diff --git a/bigquery-json-clientlogin-sample/.classpath b/bigquery-json-clientlogin-sample/.classpath deleted file mode 100644 index de5a9e91..00000000 --- a/bigquery-json-clientlogin-sample/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/bigquery-json-clientlogin-sample/.project b/bigquery-json-clientlogin-sample/.project deleted file mode 100644 index 178205be..00000000 --- a/bigquery-json-clientlogin-sample/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - bigquery-json-clientlogin-sample - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - diff --git a/bigquery-json-clientlogin-sample/.settings/org.eclipse.jdt.core.prefs b/bigquery-json-clientlogin-sample/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7b98eb39..00000000 --- a/bigquery-json-clientlogin-sample/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Tue Jul 13 15:56:54 EDT 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.6 diff --git a/bigquery-json-clientlogin-sample/instructions.html b/bigquery-json-clientlogin-sample/instructions.html deleted file mode 100644 index df57d450..00000000 --- a/bigquery-json-clientlogin-sample/instructions.html +++ /dev/null @@ -1,73 +0,0 @@ - -BigQuery JSON ClientLogin Sample - -

Instructions for the BigQuery JSON ClientLogin Sample

- -

Browse Online

- - - -

Checkout Instructions

- -

Prerequisites: install Java 6, Mercurial and Maven. You may need to set -your JAVA_HOME.

- -

Important: after checking out the project, and before compiling -and running it, you need to edit ClientLoginCredentials.java -to enter a username and password that has access to BigQuery. Otherwise, you -will get a 403 Forbidden exception.

- -
cd [someDirectory]
-hg clone https://samples.google-api-java-client.googlecode.com/hg/ google-api-java-client-samples
-cd google-api-java-client-samples/bigquery-json-clientlogin-sample
-[editor] src/com/google/api/client/sample/bigquery/ClientLoginCredentials.java
-mvn compile
-mvn -q exec:java
- -

Setup Project in Eclipse 3.5/3.6

- -

Prerequisites: install Eclipse, -the Mercurial plugin, and the Maven -plugin.

- -
    -
  • Setup Eclipse Preferences -
      -
    • Window > Preferences... (or on Mac, Eclipse > Preferences...)
    • -
    • Select Maven -
        -
      • check on "Download Artifact Sources"
      • -
      • check on "Download Artifact JavaDoc"
      • -
      -
    • -
    -
  • -
  • Import bigquery-json-clientlogin-sample project -
      -
    • File > Import...
    • -
    • Select "General > Existing Project into Workspace" and click - "Next"
    • -
    • Click "Browse" next to "Select root directory", find [someDirectory]/google-api-java-client-samples/bigquery-json-clientlogin-sample - and click "Next"
    • -
    • Click "Finish"
    • -
    -
  • -
  • Run -
      -
    • Right-click on project bigquery-json-clientlogin-sample
    • -
    • Run As > Java Application
    • -
    -
  • -
- - - diff --git a/bigquery-json-clientlogin-sample/pom.xml b/bigquery-json-clientlogin-sample/pom.xml deleted file mode 100644 index 0b5e49bd..00000000 --- a/bigquery-json-clientlogin-sample/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ - - 4.0.0 - - com.google - google - 5 - - com.google.api.client - bigquery-json-clientlogin-sample - 1.0.2 - bigquery-json-clientlogin-sample - - Example for BigQuery using JSON and Client Login. - - - http://code.google.com/p/google-api-java-client/ - - - code.google.com - http://code.google.com/p/google-api-java-client/issues/list - - - 2010 - - - 2.0.9 - - - - scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ - scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ - http://code.google.com/p/google-api-java-client/source/browse/?repo=samples - - - - - yanivi - Yaniv Inbar - yanivi@google.com - Google - http://www.google.com - - owner - developer - - -5 - - - - - - maven-compiler-plugin - - 1.6 - 1.6 - - - - org.codehaus.mojo - exec-maven-plugin - 1.1 - - - - java - - - - - com.google.api.client.sample.bigquery.BigQuerySample - - - - ${project.artifactId}-${project.version} - src - tests_disabled - - - - com.google.api.client - google-api-client - 1.0.10-alpha - - - org.codehaus.jackson - jackson-core-asl - 1.5.3 - - - - UTF-8 - - diff --git a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/BigQuerySample.java b/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/BigQuerySample.java deleted file mode 100644 index b5abd744..00000000 --- a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/BigQuerySample.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.bigquery; - -import com.google.api.client.googleapis.GoogleTransport; -import com.google.api.client.googleapis.auth.clientlogin.ClientLogin; -import com.google.api.client.googleapis.json.JsonCParser; -import com.google.api.client.http.HttpRequest; -import com.google.api.client.http.HttpResponseException; -import com.google.api.client.http.HttpTransport; -import com.google.api.client.sample.bigquery.model.BigQueryUrl; -import com.google.api.client.sample.bigquery.model.Debug; -import com.google.api.client.sample.bigquery.model.QueryData; -import com.google.api.client.sample.bigquery.model.QueryRow; -import com.google.api.client.sample.bigquery.model.QueryValue; -import com.google.api.client.sample.bigquery.model.SchemaData; -import com.google.api.client.sample.bigquery.model.SchemaField; - -import java.io.IOException; - -/** - * @author Yaniv Inbar - */ -public class BigQuerySample { - - public static void main(String[] args) { - Debug.enableLogging(); - HttpTransport transport = GoogleTransport.create(); - transport.addParser(new JsonCParser()); - try { - try { - authenticateWithClientLogin(transport); - executeSchema(transport, "bigquery/samples/shakespeare"); - executeQuery( - transport, "select count(*) from [bigquery/samples/shakespeare];"); - executeQuery( - transport, - "select corpus, word, word_count from [bigquery/samples/shakespeare] where word_count > 600 order by word_count desc;"); - } catch (HttpResponseException e) { - System.err.println(e.response.parseAsString()); - throw e; - } - } catch (Throwable t) { - t.printStackTrace(); - System.exit(1); - } - } - - public static void authenticateWithClientLogin(HttpTransport transport) - throws IOException { - ClientLogin authenticator = new ClientLogin(); - authenticator.authTokenType = "ndev"; - authenticator.username = ClientLoginCredentials.ENTER_USERNAME; - authenticator.password = ClientLoginCredentials.ENTER_PASSWORD; - authenticator.authenticate().setAuthorizationHeader(transport); - } - - static QueryData executeQuery(HttpTransport transport, String query) - throws IOException { - header("Query: " + query); - HttpRequest request = transport.buildGetRequest(); - BigQueryUrl url = BigQueryUrl.fromRelativePath("query"); - url.q = query; - request.url = url; - QueryData result = request.execute().parseAs(QueryData.class); - if (result.fields == null) { - System.out.println("No fields"); - } else { - for (SchemaField field : result.fields) { - System.out.print(field.id + "\t"); - } - System.out.println(); - for (QueryRow row : result.rows) { - for (QueryValue value : row.f) { - System.out.print(value.value + "\t"); - } - System.out.println(); - } - } - return result; - } - - static SchemaData executeSchema(HttpTransport transport, String tableName) - throws IOException { - header("Schema: " + tableName); - HttpRequest request = transport.buildGetRequest(); - BigQueryUrl url = BigQueryUrl.fromRelativePath("tables"); - url.pathParts.add(tableName); - request.url = url; - SchemaData result = request.execute().parseAs(SchemaData.class); - if (result.fields == null) { - System.out.println("No fields"); - } else { - System.out.println(result.fields.size() + " fields:"); - for (SchemaField field : result.fields) { - System.out.println(field.type + " " + field.id); - } - } - return result; - } - - private static void header(String name) { - System.out.println(); - System.out.println("============== " + name + " =============="); - System.out.println(); - } -} diff --git a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/ClientLoginCredentials.java b/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/ClientLoginCredentials.java deleted file mode 100644 index fad9da83..00000000 --- a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/ClientLoginCredentials.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.bigquery; - -/** - * @author Yaniv Inbar - */ -public class ClientLoginCredentials { - - static final String ENTER_USERNAME = "enter_username"; - static final String ENTER_PASSWORD = "enter_password"; -} diff --git a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/BigQueryUrl.java b/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/BigQueryUrl.java deleted file mode 100644 index 7fe368ce..00000000 --- a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/BigQueryUrl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.bigquery.model; - -import com.google.api.client.googleapis.GoogleUrl; -import com.google.api.client.util.Key; - -/** - * BigQuery URL builder. - * - * @author Yaniv Inbar - */ -public final class BigQueryUrl extends GoogleUrl { - - private static final String ROOT_URL = - "https://www.googleapis.com/bigquery/v1/"; - - @Key - public String q; - - /** Constructs a new BigQuery URL from the given encoded URL. */ - public BigQueryUrl(String encodedUrl) { - super(encodedUrl); - if (Debug.ENABLED) { - prettyprint = true; - } - } - - /** - * Constructs a new BigQuery URL based on the given relative path. - * - * @param relativePath encoded path relative to the {@link #ROOT_URL} - * @return new BigQuery URL - */ - public static BigQueryUrl fromRelativePath(String relativePath) { - return new BigQueryUrl(ROOT_URL + relativePath); - } -} diff --git a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/Debug.java b/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/Debug.java deleted file mode 100644 index f35fd657..00000000 --- a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/Debug.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.bigquery.model; - -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -/** - * @author Yaniv Inbar - */ -public class Debug { - public static final boolean ENABLED = false; - - public static void enableLogging() { - if (ENABLED) { - Logger logger = Logger.getLogger("com.google.api.client"); - logger.setLevel(Level.CONFIG); - logger.addHandler(new Handler() { - - @Override - public void close() throws SecurityException { - } - - @Override - public void flush() { - } - - @Override - public void publish(LogRecord record) { - // default ConsoleHandler will take care of >= INFO - if (record.getLevel().intValue() < Level.INFO.intValue()) { - System.out.println(record.getMessage()); - } - } - }); - } - } -} diff --git a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/QueryData.java b/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/QueryData.java deleted file mode 100644 index 549cc2a1..00000000 --- a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/QueryData.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.bigquery.model; - -import com.google.api.client.util.Key; - -import java.util.List; - -/** - * @author Yaniv Inbar - */ -public class QueryData { - - @Key - public List fields; - - @Key - public List rows; -} diff --git a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/QueryRow.java b/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/QueryRow.java deleted file mode 100644 index b62b0de5..00000000 --- a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/QueryRow.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.bigquery.model; - -import com.google.api.client.util.Key; - -import java.util.List; - -/** - * @author Yaniv Inbar - */ -public class QueryRow { - - @Key - public List f; -} diff --git a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/QueryValue.java b/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/QueryValue.java deleted file mode 100644 index f47a13e7..00000000 --- a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/QueryValue.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.bigquery.model; - -import com.google.api.client.util.Key; - -/** - * @author Yaniv Inbar - */ -public class QueryValue { - - @Key("v") - public String value; -} diff --git a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/SchemaData.java b/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/SchemaData.java deleted file mode 100644 index 225f471d..00000000 --- a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/SchemaData.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.bigquery.model; - -import com.google.api.client.util.Key; - -import java.util.List; - -/** - * @author Yaniv Inbar - */ -public class SchemaData { - - @Key - public List fields; -} diff --git a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/SchemaField.java b/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/SchemaField.java deleted file mode 100644 index db17b77b..00000000 --- a/bigquery-json-clientlogin-sample/src/com/google/api/client/sample/bigquery/model/SchemaField.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.bigquery.model; - -import com.google.api.client.util.Key; - -/** - * @author Yaniv Inbar - */ -public class SchemaField { - - @Key - public String id; - - @Key - public String type; -} diff --git a/books-cmdline-sample/.classpath b/books-cmdline-sample/.classpath new file mode 100644 index 00000000..753b6eda --- /dev/null +++ b/books-cmdline-sample/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/books-cmdline-sample/.project b/books-cmdline-sample/.project new file mode 100644 index 00000000..98ced74f --- /dev/null +++ b/books-cmdline-sample/.project @@ -0,0 +1,23 @@ + + + books-cmdline-sample + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/books-cmdline-sample/.settings/org.eclipse.jdt.core.prefs b/books-cmdline-sample/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..faf086f4 --- /dev/null +++ b/books-cmdline-sample/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,380 @@ +#Fri Nov 04 10:10:38 EDT 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.annotationSuperInterface=ignore +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=ignore +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_member=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=24 +org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type_declaration=569 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=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|5|48 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_field_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_for_statement=16 +org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments=16 +org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16|5|80 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16|5|80 +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|4|49 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16|4|48 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16|4|48 +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=false +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=100 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph=true +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.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.force_if_else_statement_brace=true +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +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_field=insert +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_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=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_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=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=do not 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.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +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=100 +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.sort_local_variable_annotations=false +org.eclipse.jdt.core.formatter.sort_member_annotations=false +org.eclipse.jdt.core.formatter.sort_package_annotations=false +org.eclipse.jdt.core.formatter.sort_parameter_annotations=false +org.eclipse.jdt.core.formatter.sort_type_annotations=false +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_comment_inline_tags=false +org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation=true +org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation=false +org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments=false diff --git a/books-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs b/books-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..2413e100 --- /dev/null +++ b/books-cmdline-sample/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,119 @@ +#Fri Nov 04 10:06:25 EDT 2011 +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=true +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=true +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_google-api-java-client +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false +formatter_profile=_google-api-java-client 100 +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=exception +org.eclipse.jdt.ui.gettersetter.use.is=false +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=com;org;;java;javax; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=999 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=999 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=false +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=false +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=false +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/books-cmdline-sample/BooksSample.launch b/books-cmdline-sample/BooksSample.launch new file mode 100644 index 00000000..ab377173 --- /dev/null +++ b/books-cmdline-sample/BooksSample.launch @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/books-cmdline-sample/instructions.html b/books-cmdline-sample/instructions.html new file mode 100644 index 00000000..0f952c01 --- /dev/null +++ b/books-cmdline-sample/instructions.html @@ -0,0 +1,113 @@ + +books-cmdline-sample + +

Instructions for the Google Books V1 JSON Command-Line Sample

+ +

Browse Online

+ + + +

Register Your Application

+ +
    +
  • Visit the Google Cloud + console. +
  • +
  • If necessary, sign in to your Google Account, select or create a project, + and agree to the terms of service. Click Continue.
  • +
  • Select "Installed application" and choose type "Other" under the Installed Application type.
  • +
  • Within "OAuth 2.0 Client ID", click on "Download JSON". Later on, after you check + out the sample project, you will copy this downloaded file (e.g. + ~/Downloads/client_secrets.json) to + src/main/resources/client_secrets.json. + If you skip this step, when trying to run the sample you will get a 400 + INVALID_CLIENT error in the browser. +
  • +
+ +

Checkout Instructions

+ +

+ Prerequisites: install Java 6, Mercurial and Maven. You may need to + set your + JAVA_HOME + . +

+ +
+    cd [someDirectory]
+hg clone https://code.google.com/p/google-api-java-client.samples/ google-api-java-client-samples
+cd google-api-java-client-samples/books-cmdline-sample
+[editor] src/main/java/com/google/api/services/samples/books/cmdline/ClientCredentials.java
+mvn compile
+mvn -q exec:java -Dexec.args=Google
+  
+ +

To enable logging of HTTP requests and responses (highly recommended + when developing), please take a look at logging.properties.

+ +

Setup Project in Eclipse

+ +

+ Prerequisites: install Eclipse, + the Mercurial plugin, and the + Maven + plugin. +

+ +
    +
  • Setup Eclipse Preferences +
      +
    • Window > Preferences... (or on Mac, Eclipse > + Preferences...)
    • +
    • Select Maven +
        +
      • check on "Download Artifact Sources"
      • +
      • check on "Download Artifact JavaDoc"
      • +
      +
    • +
    +
  • +
  • Import books-cmdline-sample project +
      +
    • File > Import...
    • +
    • Select "General > Existing Project into Workspace" and click + "Next"
    • +
    • Click "Browse" next to "Select root directory", find + [someDirectory]/google-api-java-client-samples/books-cmdline-sample + and click "Next" +
    • +
    • Click "Finish"
    • +
    +
  • +
  • Run +
      +
    • Right-click on project books-cmdline-sample
    • +
    • Run As > Java Application
    • +
    • If asked, type "BooksSample" and click OK
    • +
    • To run: +
        +
      • Run > Run Configurations...
      • +
      • Click on "Java Application > BooksSample"
      • +
      • Click on "Arguments" tab
      • +
      • Program arguments: "Mark Twain"
      • +
      • See comments in BooksSample.java + for full command line arguments.
      • +
      • VM arguments: -Djava.util.logging.config.file=${project_loc}/logging.properties
      • +
      • Click "Run"
      • +
      +
    • +
    +
  • +
+ + + diff --git a/books-cmdline-sample/logging.properties b/books-cmdline-sample/logging.properties new file mode 100644 index 00000000..5d8d54f0 --- /dev/null +++ b/books-cmdline-sample/logging.properties @@ -0,0 +1,10 @@ +# Properties file which configures the operation of the JDK logging facility. +# The system will look for this config file to be specified as a system property: +# -Djava.util.logging.config.file=${project_loc:books-cmdline-sample}/logging.properties + +# Set up the console handler (uncomment "level" to show more fine-grained messages) +handlers = java.util.logging.ConsoleHandler +#java.util.logging.ConsoleHandler.level = CONFIG + +# Set up logging of HTTP requests and responses (uncomment "level" to show) +#com.google.api.client.http.level = CONFIG diff --git a/books-cmdline-sample/pom.xml b/books-cmdline-sample/pom.xml new file mode 100644 index 00000000..cd675f9a --- /dev/null +++ b/books-cmdline-sample/pom.xml @@ -0,0 +1,130 @@ + + 4.0.0 + + com.google + google + 5 + + com.google.apis-samples + books-cmdline-sample + 1.2.1 + Example for the Google Books API v1 using JSON. + + http://code.google.com/p/google-api-java-client/ + + + code.google.com + http://code.google.com/p/google-api-java-client/issues/list + + + 2011 + + + 2.0.9 + + + + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ + http://code.google.com/p/google-api-java-client/source/browse/?repo=samples + + + + + dlu + David Lu + dlu@google.com + Google + http://www.google.com + + owner + developer + + -8 + + + + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + org.codehaus.mojo + exec-maven-plugin + 1.1 + + + + java + + + + + com.google.api.services.samples.books.cmdline.BooksSample + + + java.util.logging.config.file + logging.properties + + + + + + maven-checkstyle-plugin + 2.6 + + ../checkstyle.xml + true + false + + + + + check + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + false + + + + + check + + + + + + ${project.artifactId}-${project.version} + + + + com.google.apis + google-api-services-books + v1-rev57-1.19.0 + + + com.google.http-client + google-http-client-jackson2 + ${project.http.version} + + + + 1.19.0 + 1.19.0 + UTF-8 + + diff --git a/books-cmdline-sample/src/main/java/com/google/api/services/samples/books/cmdline/BooksSample.java b/books-cmdline-sample/src/main/java/com/google/api/services/samples/books/cmdline/BooksSample.java new file mode 100644 index 00000000..8bb4dce9 --- /dev/null +++ b/books-cmdline-sample/src/main/java/com/google/api/services/samples/books/cmdline/BooksSample.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2011 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.api.services.samples.books.cmdline; + +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.services.books.Books; +import com.google.api.services.books.BooksRequestInitializer; +import com.google.api.services.books.Books.Volumes.List; +import com.google.api.services.books.model.Volume; +import com.google.api.services.books.model.Volumes; + +import java.io.IOException; +import java.net.URLEncoder; +import java.text.NumberFormat; + +/** + * A sample application that demonstrates how Google Books Client Library for + * Java can be used to query Google Books. It accepts queries in the command + * line, and prints the results to the console. + * + * $ java com.google.sample.books.BooksSample [--author|--isbn|--title] "" + * + * Please start by reviewing the Google Books API documentation at: + * http://code.google.com/apis/books/docs/getting_started.html + */ +public class BooksSample { + + /** + * Be sure to specify the name of your application. If the application name is {@code null} or + * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0". + */ + private static final String APPLICATION_NAME = ""; + + private static final NumberFormat CURRENCY_FORMATTER = NumberFormat.getCurrencyInstance(); + private static final NumberFormat PERCENT_FORMATTER = NumberFormat.getPercentInstance(); + + private static void queryGoogleBooks(JsonFactory jsonFactory, String query) throws Exception { + ClientCredentials.errorIfNotSpecified(); + + // Set up Books client. + final Books books = new Books.Builder(GoogleNetHttpTransport.newTrustedTransport(), jsonFactory, null) + .setApplicationName(APPLICATION_NAME) + .setGoogleClientRequestInitializer(new BooksRequestInitializer(ClientCredentials.API_KEY)) + .build(); + // Set query string and filter only Google eBooks. + System.out.println("Query: [" + query + "]"); + List volumesList = books.volumes().list(query); + volumesList.setFilter("ebooks"); + + // Execute the query. + Volumes volumes = volumesList.execute(); + if (volumes.getTotalItems() == 0 || volumes.getItems() == null) { + System.out.println("No matches found."); + return; + } + + // Output results. + for (Volume volume : volumes.getItems()) { + Volume.VolumeInfo volumeInfo = volume.getVolumeInfo(); + Volume.SaleInfo saleInfo = volume.getSaleInfo(); + System.out.println("=========="); + // Title. + System.out.println("Title: " + volumeInfo.getTitle()); + // Author(s). + java.util.List authors = volumeInfo.getAuthors(); + if (authors != null && !authors.isEmpty()) { + System.out.print("Author(s): "); + for (int i = 0; i < authors.size(); ++i) { + System.out.print(authors.get(i)); + if (i < authors.size() - 1) { + System.out.print(", "); + } + } + System.out.println(); + } + // Description (if any). + if (volumeInfo.getDescription() != null && volumeInfo.getDescription().length() > 0) { + System.out.println("Description: " + volumeInfo.getDescription()); + } + // Ratings (if any). + if (volumeInfo.getRatingsCount() != null && volumeInfo.getRatingsCount() > 0) { + int fullRating = (int) Math.round(volumeInfo.getAverageRating().doubleValue()); + System.out.print("User Rating: "); + for (int i = 0; i < fullRating; ++i) { + System.out.print("*"); + } + System.out.println(" (" + volumeInfo.getRatingsCount() + " rating(s))"); + } + // Price (if any). + if (saleInfo != null && "FOR_SALE".equals(saleInfo.getSaleability())) { + double save = saleInfo.getListPrice().getAmount() - saleInfo.getRetailPrice().getAmount(); + if (save > 0.0) { + System.out.print("List: " + CURRENCY_FORMATTER.format(saleInfo.getListPrice().getAmount()) + + " "); + } + System.out.print("Google eBooks Price: " + + CURRENCY_FORMATTER.format(saleInfo.getRetailPrice().getAmount())); + if (save > 0.0) { + System.out.print(" You Save: " + CURRENCY_FORMATTER.format(save) + " (" + + PERCENT_FORMATTER.format(save / saleInfo.getListPrice().getAmount()) + ")"); + } + System.out.println(); + } + // Access status. + String accessViewStatus = volume.getAccessInfo().getAccessViewStatus(); + String message = "Additional information about this book is available from Google eBooks at:"; + if ("FULL_PUBLIC_DOMAIN".equals(accessViewStatus)) { + message = "This public domain book is available for free from Google eBooks at:"; + } else if ("SAMPLE".equals(accessViewStatus)) { + message = "A preview of this book is available from Google eBooks at:"; + } + System.out.println(message); + // Link to Google eBooks. + System.out.println(volumeInfo.getInfoLink()); + } + System.out.println("=========="); + System.out.println( + volumes.getTotalItems() + " total results at http://books.google.com/ebooks?q=" + + URLEncoder.encode(query, "UTF-8")); + } + + public static void main(String[] args) { + JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); + try { + // Verify command line parameters. + if (args.length == 0) { + System.err.println("Usage: BooksSample [--author|--isbn|--title] \"\""); + System.exit(1); + } + // Parse command line parameters into a query. + // Query format: "[:]" + String prefix = null; + String query = ""; + for (String arg : args) { + if ("--author".equals(arg)) { + prefix = "inauthor:"; + } else if ("--isbn".equals(arg)) { + prefix = "isbn:"; + } else if ("--title".equals(arg)) { + prefix = "intitle:"; + } else if (arg.startsWith("--")) { + System.err.println("Unknown argument: " + arg); + System.exit(1); + } else { + query = arg; + } + } + if (prefix != null) { + query = prefix + query; + } + try { + queryGoogleBooks(jsonFactory, query); + // Success! + return; + } catch (IOException e) { + System.err.println(e.getMessage()); + } + } catch (Throwable t) { + t.printStackTrace(); + } + System.exit(0); + } +} diff --git a/books-cmdline-sample/src/main/java/com/google/api/services/samples/books/cmdline/ClientCredentials.java b/books-cmdline-sample/src/main/java/com/google/api/services/samples/books/cmdline/ClientCredentials.java new file mode 100644 index 00000000..5449d7b0 --- /dev/null +++ b/books-cmdline-sample/src/main/java/com/google/api/services/samples/books/cmdline/ClientCredentials.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011 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.api.services.samples.books.cmdline; + + +/** + * API key found in the Google apis + * console. + * + *

+ * Once at the Google apis console, click on "Add project...". If you've already set up a project, + * you may use that one instead, or create a new one by clicking on the arrow next to the project + * name and click on "Create..." under "Other projects". Finally, click on "API Access". Look for + * the section at the bottom called "Simple API Access". + *

+ * + * @author Ravi Mistry + */ +public class ClientCredentials { + + /** Value of the "API key" shown under "Simple API Access". */ + static final String API_KEY = + "Enter API Key from https://code.google.com/apis/console/?api=books into API_KEY in " + + ClientCredentials.class; + + static void errorIfNotSpecified() { + if (API_KEY.startsWith("Enter ")) { + System.err.println(API_KEY); + System.exit(1); + } + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..f3f32595 --- /dev/null +++ b/build.gradle @@ -0,0 +1,10 @@ +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:1.2.+' + } +} + diff --git a/buzz-json-oauth-sample/.classpath b/buzz-json-oauth-sample/.classpath deleted file mode 100644 index f0f3949d..00000000 --- a/buzz-json-oauth-sample/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/buzz-json-oauth-sample/.project b/buzz-json-oauth-sample/.project deleted file mode 100644 index 1ce894cd..00000000 --- a/buzz-json-oauth-sample/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - buzz-json-oauth-sample - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - diff --git a/buzz-json-oauth-sample/.settings/org.eclipse.jdt.core.prefs b/buzz-json-oauth-sample/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b4b102be..00000000 --- a/buzz-json-oauth-sample/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Wed Jul 14 14:18:33 EDT 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.6 diff --git a/buzz-json-oauth-sample/instructions.html b/buzz-json-oauth-sample/instructions.html deleted file mode 100644 index 4f2b0f4a..00000000 --- a/buzz-json-oauth-sample/instructions.html +++ /dev/null @@ -1,67 +0,0 @@ - -Buzz API JSON OAuth Sample - -

Instructions for the Buzz API JSON OAuth Sample

- -

Browse Online

- - - -

Checkout Instructions

- -

Prerequisites: install Java 6, Mercurial and Maven. You may need to set -your JAVA_HOME.

- -
cd [someDirectory]
-hg clone https://samples.google-api-java-client.googlecode.com/hg/ google-api-java-client-samples
-cd google-api-java-client-samples/buzz-json-oauth-sample
-mvn compile
-mvn -q exec:java
- -

Setup Project in Eclipse 3.5/3.6

- -

Prerequisites: install Eclipse, -the Mercurial plugin, and the Maven -plugin.

- -
    -
  • Setup Eclipse Preferences -
      -
    • Window > Preferences... (or on Mac, Eclipse > Preferences...)
    • -
    • Select Maven -
        -
      • check on "Download Artifact Sources"
      • -
      • check on "Download Artifact JavaDoc"
      • -
      -
    • -
    -
  • -
  • Import buzz-json-oauth-sample project -
      -
    • File > Import...
    • -
    • Select "General > Existing Project into Workspace" and click - "Next"
    • -
    • Click "Browse" next to "Select root directory", find [someDirectory]/google-api-java-client-samples/buzz-json-oauth-sample - and click "Next"
    • -
    • Click "Finish"
    • -
    -
  • -
  • Run -
      -
    • Right-click on project buzz-json-oauth-sample
    • -
    • Run As > Java Application
    • -
    • If asked, type "BuzzSample" and click OK
    • -
    -
  • -
- - - diff --git a/buzz-json-oauth-sample/pom.xml b/buzz-json-oauth-sample/pom.xml deleted file mode 100644 index 81e773fb..00000000 --- a/buzz-json-oauth-sample/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - 4.0.0 - - com.google - google - 5 - - com.google.api.client - buzz-json-oauth-sample - 1.0.0 - buzz-json-oauth-sample - - Example for the Buzz API using JSON and OAuth. - - - http://code.google.com/p/google-api-java-client/ - - - code.google.com - http://code.google.com/p/google-api-java-client/issues/list - - - 2010 - - - 2.0.9 - - - - scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ - scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ - http://code.google.com/p/google-api-java-client/source/browse/?repo=samples - - - - - yanivi - Yaniv Inbar - yanivi@google.com - Google - http://www.google.com - - owner - developer - - -5 - - - - - - maven-compiler-plugin - - 1.6 - 1.6 - - - - org.codehaus.mojo - exec-maven-plugin - 1.1 - - - - java - - - - - com.google.api.client.sample.buzz.BuzzSample - - - - ${project.artifactId}-${project.version} - src - tests_disabled - - - - com.google.api.client - google-api-client - 1.0.10-alpha - - - org.codehaus.jackson - jackson-core-asl - 1.5.3 - - - org.mortbay.jetty - jetty-embedded - 6.1.24 - compile - - - - UTF-8 - - diff --git a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/Auth.java b/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/Auth.java deleted file mode 100644 index 227dbec8..00000000 --- a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/Auth.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.buzz; - -import com.google.api.client.auth.oauth.OAuthAuthorizeTemporaryTokenUrl; -import com.google.api.client.auth.oauth.OAuthCredentialsResponse; -import com.google.api.client.auth.oauth.OAuthHmacSigner; -import com.google.api.client.auth.oauth.OAuthParameters; -import com.google.api.client.googleapis.auth.oauth.GoogleOAuthGetAccessToken; -import com.google.api.client.googleapis.auth.oauth.GoogleOAuthGetTemporaryToken; -import com.google.api.client.http.HttpTransport; - -import java.awt.Desktop; -import java.awt.Desktop.Action; -import java.net.URI; - -/** - * Implements OAuth authentication. - * - * @author Yaniv Inbar - */ -public class Auth { - - static final String APP_NAME = "Buzz API Java Client Sample"; - - private static OAuthHmacSigner signer; - - private static OAuthCredentialsResponse credentials; - - static void authorize(HttpTransport transport) throws Exception { - // callback server - LoginCallbackServer callbackServer = null; - String verifier = null; - String tempToken = null; - try { - callbackServer = new LoginCallbackServer(); - callbackServer.start(); - // temporary token - GoogleOAuthGetTemporaryToken temporaryToken = - new GoogleOAuthGetTemporaryToken(); - signer = new OAuthHmacSigner(); - signer.clientSharedSecret = "anonymous"; - temporaryToken.signer = signer; - temporaryToken.consumerKey = "anonymous"; - temporaryToken.scope = "https://www.googleapis.com/auth/buzz"; - temporaryToken.displayName = APP_NAME; - temporaryToken.callback = callbackServer.getCallbackUrl(); - OAuthCredentialsResponse tempCredentials = temporaryToken.execute(); - signer.tokenSharedSecret = tempCredentials.tokenSecret; - // authorization URL - OAuthAuthorizeTemporaryTokenUrl authorizeUrl = - new OAuthAuthorizeTemporaryTokenUrl( - "https://www.google.com/buzz/api/auth/OAuthAuthorizeToken"); - authorizeUrl.set("scope", temporaryToken.scope); - authorizeUrl.set("domain", "anonymous"); - authorizeUrl.set("xoauth_displayname", APP_NAME); - authorizeUrl.temporaryToken = tempToken = tempCredentials.token; - String authorizationUrl = authorizeUrl.build(); - // launch in browser - boolean browsed = false; - if (Desktop.isDesktopSupported()) { - Desktop desktop = Desktop.getDesktop(); - if (desktop.isSupported(Action.BROWSE)) { - desktop.browse(URI.create(authorizationUrl)); - browsed = true; - } - } - if (!browsed) { - String browser = "google-chrome"; - Runtime.getRuntime().exec(new String[] {browser, authorizationUrl}); - } - verifier = callbackServer.waitForVerifier(tempToken); - } finally { - if (callbackServer != null) { - callbackServer.stop(); - } - } - GoogleOAuthGetAccessToken accessToken = new GoogleOAuthGetAccessToken(); - accessToken.temporaryToken = tempToken; - accessToken.signer = signer; - accessToken.consumerKey = "anonymous"; - accessToken.verifier = verifier; - credentials = accessToken.execute(); - signer.tokenSharedSecret = credentials.tokenSecret; - createOAuthParameters().signRequestsUsingAuthorizationHeader(transport); - } - - static void revoke() { - if (credentials != null) { - try { - GoogleOAuthGetAccessToken.revokeAccessToken(createOAuthParameters()); - } catch (Exception e) { - e.printStackTrace(System.err); - } - } - } - - private static OAuthParameters createOAuthParameters() { - OAuthParameters authorizer = new OAuthParameters(); - authorizer.consumerKey = "anonymous"; - authorizer.signer = signer; - authorizer.token = credentials.token; - return authorizer; - } -} diff --git a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/BuzzSample.java b/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/BuzzSample.java deleted file mode 100644 index b5a5d12b..00000000 --- a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/BuzzSample.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.buzz; - -import com.google.api.client.googleapis.GoogleTransport; -import com.google.api.client.googleapis.json.JsonCParser; -import com.google.api.client.http.HttpResponseException; -import com.google.api.client.http.HttpTransport; -import com.google.api.client.sample.buzz.model.BuzzActivity; -import com.google.api.client.sample.buzz.model.BuzzActivityFeed; -import com.google.api.client.sample.buzz.model.BuzzObject; -import com.google.api.client.sample.buzz.model.Debug; - -import java.io.IOException; - -/** - * @author Yaniv Inbar - */ -public class BuzzSample { - - private final HttpTransport transport; - - public BuzzSample(HttpTransport transport) { - super(); - this.transport = transport; - } - - public static void main(String[] args) { - Debug.enableLogging(); - HttpTransport transport = GoogleTransport.create(); - transport.addParser(new JsonCParser()); - BuzzSample sample = new BuzzSample(transport); - try { - try { - sample.authorize(); - sample.showActivities(); - BuzzActivity activity = sample.insertActivity(); - activity = sample.updateActivity(activity); - sample.deleteActivity(activity); - Auth.revoke(); - } catch (HttpResponseException e) { - System.err.println(e.response.parseAsString()); - throw e; - } - } catch (Throwable t) { - t.printStackTrace(); - Auth.revoke(); - System.exit(1); - } - } - - private void authorize() throws Exception { - Auth.authorize(transport); - } - - private void showActivities() throws IOException { - header("Show Buzz Activities"); - BuzzActivityFeed feed = BuzzActivityFeed.list(transport); - if (feed.activities != null) { - int size = feed.activities.size(); - for (int i = 0; i < size; i++) { - BuzzActivity activity = feed.activities.get(i); - show(activity); - } - } - } - - private BuzzActivity insertActivity() throws IOException { - header("Insert Buzz Activity"); - BuzzActivity activity = new BuzzActivity(); - activity.object = new BuzzObject(); - activity.object.content = "Posting using " + Auth.APP_NAME; - BuzzActivity result = activity.post(transport); - show(result); - return result; - } - - private BuzzActivity updateActivity(BuzzActivity activity) - throws IOException { - header("Update Buzz Activity"); - activity.object.content += " (http://bit.ly/9WbLmb)"; - BuzzActivity result = activity.update(transport); - show(result); - return result; - } - - private void deleteActivity(BuzzActivity activity) throws IOException { - header("Delete Buzz Activity"); - activity.delete(transport); - System.out.println("Deleted."); - } - - private static void header(String name) { - System.out.println(); - System.out.println("============== " + name + " =============="); - System.out.println(); - } - - private static void show(BuzzActivity activity) { - System.out.println(activity.object.content); - } -} diff --git a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/LoginCallbackServer.java b/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/LoginCallbackServer.java deleted file mode 100644 index 9e02082f..00000000 --- a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/LoginCallbackServer.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.buzz; - -import com.google.api.client.repackaged.com.google.common.base.Preconditions; - -import org.mortbay.jetty.Connector; -import org.mortbay.jetty.Request; -import org.mortbay.jetty.Server; -import org.mortbay.jetty.handler.AbstractHandler; - -import java.io.IOException; -import java.io.PrintWriter; -import java.net.Socket; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * Class that runs a Jetty server on a free port, waiting for OAuth to redirect - * to it with the one-time authorization token. - *

- * Mostly copied from oacurl by phopkins@google.com. - * - * @author Yaniv Inbar - */ -public class LoginCallbackServer { - private static final String CALLBACK_PATH = "/OAuthCallback"; - - private int port; - private Server server; - - private Map verifierMap = new HashMap(); - - public void start() { - if (server != null) { - throw new IllegalStateException("Server is already started"); - } - - try { - port = getUnusedPort(); - server = new Server(port); - - for (Connector c : server.getConnectors()) { - c.setHost("localhost"); - } - - server.addHandler(new CallbackHandler()); - - server.start(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public void stop() throws Exception { - if (server != null) { - server.stop(); - server = null; - } - } - - public String getCallbackUrl() { - Preconditions.checkArgument(port != 0, "Server is not yet started"); - return "http://localhost:" + port + CALLBACK_PATH; - } - - private static int getUnusedPort() throws IOException { - Socket s = new Socket(); - s.bind(null); - - try { - return s.getLocalPort(); - } finally { - s.close(); - } - } - - /** - * Call that blocks until the OAuth provider redirects back here with the - * verifier token. - * - * @param requestToken request token - * @return The verifier token, or null if there was a timeout. - */ - public String waitForVerifier(String requestToken) { - synchronized (verifierMap) { - while (!verifierMap.containsKey(requestToken)) { - try { - verifierMap.wait(3000); - } catch (InterruptedException e) { - return null; - } - } - - return verifierMap.remove(requestToken); - } - } - - /** - * Jetty handler that takes the verifier token passed over from the OAuth - * provider and stashes it where {@link LoginCallbackServer#waitForVerifier} - * will find it. - */ - public class CallbackHandler extends AbstractHandler { - public void handle(String target, HttpServletRequest request, - HttpServletResponse response, int dispatch) throws IOException { - if (!CALLBACK_PATH.equals(target)) { - return; - } - - writeLandingHtml(response); - response.flushBuffer(); - ((Request) request).setHandled(true); - - String requestToken = request.getParameter("oauth_token"); - String verifier = request.getParameter("oauth_verifier"); - - synchronized (verifierMap) { - verifierMap.put(requestToken, verifier); - verifierMap.notifyAll(); - } - } - - private void writeLandingHtml(HttpServletResponse response) - throws IOException { - response.setStatus(HttpServletResponse.SC_OK); - response.setContentType("text/html"); - - PrintWriter doc = response.getWriter(); - doc.println(""); - doc.println( - "OAuth Authentication Token Recieved"); - doc.println(""); - doc.println("Received verifier token. Closing..."); - doc.println(""); - doc.println(""); - doc.println(""); - doc.flush(); - } - } -} diff --git a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzActivity.java b/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzActivity.java deleted file mode 100755 index 82c63ca3..00000000 --- a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzActivity.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.buzz.model; - -import com.google.api.client.googleapis.json.JsonCContent; -import com.google.api.client.http.HttpRequest; -import com.google.api.client.http.HttpTransport; -import com.google.api.client.json.GenericJson; -import com.google.api.client.util.Key; - -import java.io.IOException; - -/** - * Buzz activity, such as a Buzz post. - * - *

- * The JSON of a typical activity looks like this: - * - *

- * {
- *  id: "tag:google.com,2010:buzz:z12puk22ajfyzsz",
- *  object: {
- *   content: "Hey, this is my first Buzz Post!",
- *   ...
- *  },
- *  ...
- * }
- * 
- * - * @author Yaniv Inbar - */ -public final class BuzzActivity extends GenericJson { - - /** Activity identifier. */ - @Key - public String id; - - /** Buzz Object. */ - @Key - public BuzzObject object; - - /** - * Post this Buzz Activity. - * - * @param transport Google transport - * @return posted Buzz Activity response from the Buzz server - * @throws IOException any I/O exception - */ - public BuzzActivity post(HttpTransport transport) throws IOException { - HttpRequest request = transport.buildPostRequest(); - request.url = BuzzUrl.forMyActivityFeed(); - request.content = toContent(); - return request.execute().parseAs(BuzzActivity.class); - } - - /** - * Update this Buzz Activity. - * - * @param transport Google transport - * @return updated Buzz Activity response from the Buzz server - * @throws IOException any I/O exception - */ - public BuzzActivity update(HttpTransport transport) throws IOException { - HttpRequest request = transport.buildPutRequest(); - request.url = BuzzUrl.forMyActivity(this.id); - request.content = toContent(); - return request.execute().parseAs(BuzzActivity.class); - } - - /** - * Post this Buzz Activity. - * - * @param transport Google transport - * @throws IOException any I/O exception - */ - public void delete(HttpTransport transport) throws IOException { - HttpRequest request = transport.buildDeleteRequest(); - request.url = BuzzUrl.forMyActivity(this.id); - request.execute().ignore(); - } - - /** Returns a new JSON-C content serializer for this Buzz activity. */ - private JsonCContent toContent() { - JsonCContent result = new JsonCContent(); - result.data = this; - return result; - } -} diff --git a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzActivityFeed.java b/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzActivityFeed.java deleted file mode 100755 index a93f2308..00000000 --- a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzActivityFeed.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.buzz.model; - -import com.google.api.client.http.HttpRequest; -import com.google.api.client.http.HttpTransport; -import com.google.api.client.util.Key; - -import java.io.IOException; -import java.util.List; - -/** - * Buzz activity feed. - * - *

- * The JSON of a typical activity feed looks like this: - * - *

- * {
- * "data": {
- *   items: [
- *    {
- *     id: "tag:google.com,2010:buzz:z12puk22ajfyzsz",
- *     object: {
- *      content: "Hey, this is my first Buzz Post!",
- *      ...
- *     },
- *     ...
- *    }
- *   ]
- *  ]
- * }
- * }
- * 
- * - * @author Yaniv Inbar - */ -public final class BuzzActivityFeed { - - /** List of activities. */ - // specify the field name because it doesn't match the name used in the JSON - @Key("items") - public List activities; - - /** - * List the user's Buzz activities. - * - * @param transport Google transport - * @return Buzz activities feed response from the Buzz server - * @throws IOException any I/O exception - */ - public static BuzzActivityFeed list(HttpTransport transport) - throws IOException { - HttpRequest request = transport.buildGetRequest(); - request.url = BuzzUrl.forMyActivityFeed(); - return request.execute().parseAs(BuzzActivityFeed.class); - } -} diff --git a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzObject.java b/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzObject.java deleted file mode 100755 index e1ec4859..00000000 --- a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzObject.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.buzz.model; - -import com.google.api.client.json.GenericJson; -import com.google.api.client.util.Key; - -/** - * Buzz Object. - * - *

- * The JSON of a typical Buzz object looks like this: - * - *

- * {
- *  content: "Hey, this is my first Buzz Post!",
- *  ...
- * }
- * 
- * - * @author Yaniv Inbar - */ -public class BuzzObject extends GenericJson { - - /** HTML content. */ - @Key - public String content; -} diff --git a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzUrl.java b/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzUrl.java deleted file mode 100644 index 922aeab4..00000000 --- a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/BuzzUrl.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.buzz.model; - -import com.google.api.client.googleapis.GoogleUrl; - -/** - * Buzz URL builder. - * - * @author Yaniv Inbar - */ -public final class BuzzUrl extends GoogleUrl { - - /** Constructs a new Buzz URL from the given encoded URI. */ - public BuzzUrl(String encodedUrl) { - super(encodedUrl); - alt = "json"; - if (Debug.ENABLED) { - prettyprint = true; - } - } - - public static BuzzUrl forMyActivityFeed() { - return new BuzzUrl( - "https://www.googleapis.com/buzz/v1/activities/@me/@self"); - } - - public static BuzzUrl forMyActivity(String activityId) { - BuzzUrl result = forMyActivityFeed(); - result.pathParts.add(activityId); - return result; - } -} diff --git a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/Debug.java b/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/Debug.java deleted file mode 100644 index 47b49496..00000000 --- a/buzz-json-oauth-sample/src/com/google/api/client/sample/buzz/model/Debug.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.buzz.model; - -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -/** - * @author Yaniv Inbar - */ -public class Debug { - public static final boolean ENABLED = false; - - public static void enableLogging() { - if (ENABLED) { - Logger logger = Logger.getLogger("com.google.api.client"); - logger.setLevel(Level.CONFIG); - logger.addHandler(new Handler() { - - @Override - public void close() throws SecurityException { - } - - @Override - public void flush() { - } - - @Override - public void publish(LogRecord record) { - // default ConsoleHandler will take care of >= INFO - if (record.getLevel().intValue() < Level.INFO.intValue()) { - System.out.println(record.getMessage()); - } - } - }); - } - } -} diff --git a/calendar-android-sample/AndroidManifest.xml b/calendar-android-sample/AndroidManifest.xml new file mode 100644 index 00000000..b1ceb84a --- /dev/null +++ b/calendar-android-sample/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/calendar-android-sample/build.gradle b/calendar-android-sample/build.gradle new file mode 100644 index 00000000..8d8feae2 --- /dev/null +++ b/calendar-android-sample/build.gradle @@ -0,0 +1,40 @@ +apply plugin: 'android' + +repositories { + mavenCentral() + mavenLocal() // For google-play-services is not on Maven Central. +} + +dependencies { + compile 'com.google.apis:google-api-services-calendar:v3-rev87-1.19.0' exclude module: 'httpclient' + compile 'com.google.api-client:google-api-client-android:1.19.0' exclude module: 'httpclient' + compile 'com.google.http-client:google-http-client-gson:1.19.0' exclude module: 'httpclient' + compile 'com.google.android.gms:play-services-identity:7.3.0' +} + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + minSdkVersion 11 + targetSdkVersion 22 + } + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + res.srcDirs = ['res'] + } + } + + buildTypes { + release { + minifyEnabled true + proguardFile 'proguard-google-api-client.txt' + proguardFile getDefaultProguardFile('proguard-android.txt') + } + } + +} + diff --git a/calendar-android-sample/instructions.html b/calendar-android-sample/instructions.html new file mode 100644 index 00000000..36f3ce99 --- /dev/null +++ b/calendar-android-sample/instructions.html @@ -0,0 +1,179 @@ + +calendar-android-sample + + +

Instructions for the Calendar V3 Android Sample

+ +

Warning

+ +This sample is for illustrative purposes. Please consider using the native +Calendar + Provider API. + +

Browse Online

+ + + +

Prerequisites

+ +
    +
  • Install Java (requires 6 or higher)
  • +
  • Install Git (suggested 1.7.10 or higher) + or GitHub client (Mac) + (Windows)
  • +
  • Unzip Gradle + 2.2.1
  • +
  • Install either Android + Studio (which bundles the Android SDK) or just Android SDK if you don't want to + use Android Studio. Set your + ANDROID_HOME to the Android SDK installation directory, which for Android Studio is in the + "sdk" subdirectory. +
  • +
+ +

Register Your Application

+ +
    +
  • Visit the Google Cloud + console flow for the Google Calendar API. +
  • +
  • If necessary, sign in to your Google Account, select or create a + project, and agree to the terms of service. Click Continue. +
  • +
  • For Platform select "Android". +
      +
    • For "Package name" you should make up a unique name that has never been used before + by anyone, e.g. using your name and date like + "org.example.calendar.janedoe20130911". +
        +
      • Note: Make + sure to pick a legal Java package name since we will be using it in the + Android + project source code. The full package name must have at least two parts, so + for example "janedoe20130911" will not work. +
      • +
      • Note: If you try + to register a package name that has already been registered, you may get an + error reading "An + unexpected error has occurred." In particular, + "com.google.api.services.samples.calendar.android" has already been + registered, so you must change the package name. +
      • +
      +
    • +
    • For "SHA1 fingerprint", use the value that is output when running this command in a + Terminal: +
      +keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1
      +
      + When asked, use "android" (without the quotes) as the keystore password. +
    • +
    • Click Register.
    • +
    +
  • +
  • Click on "APIs" under "APIs & auth" in the left sidebar and make sure "Calendar API" is + enabled. +
  • +
+ +

Checkout Instructions

+ +
+cd [someDirectory]
+git clone https://github.com/google/google-api-java-client-samples.git
+cd google-api-java-client-samples/calendar-android-sample
+  
+ +

Set Up Project in Android Studio

+ +
    +
  • Run the Android SDK + Manager: +
      +
    • Run this command in a terminal: +
      $ANDROID_HOME/tools/android sdk
      +
    • +
    • Under "Tools", check on "Android SDK Build-tools" revision 22.0.1.
    • +
    • Under "Android 5.1.1 (API 22)", check on "SDK Platform" and "Google APIs".
    • +
    • Under "Extras", check on "Android Support Repository", "Android Support Library", + and "Google Repository". +
    • +
    • Click on "Install X packages..."
    • +
    +
  • +
  • Start Android Studio by running this command in a terminal: +
    android-studio/bin/studio.sh
    +
  • +
  • Import calendar-android-sample project +
      +
    • Select "Import Project..." or File > Import Project...
    • +
    • Select + [someDirectory]/google-api-java-client-samples/build.gradle + and click OK. +
        +
      • Note: it will not work if you try to import + [someDirectory]/google-api-java-client-samples/calendar-android-sample/build.gradle + . +
      • +
      +
    • +
    • Select "Use local gradle distribution" with "Gradle home" of + [someDirectory]/gradle-2.2.1 and click OK. +
    • +
    +
  • +
  • Open AndroidManifest.xml and change the package attribute of the manifest, initially + "com.google.api.services.samples.calendar.android", to match the name you registered in the + Google Cloud Console, e.g. "org.example.calendar.janedoe20130911". +
  • +
  • Rename the Java package: right-click on src/main/java, click New, click Package, and then + enter the name you registered in the + Google Cloud Console, e.g. "org.example.calendar.janedoe20130911". Next, select the Java + classes in + the package "com.google.api.services.samples.calendar.android", drag them into the new + package + you just created, and then click Refactor. +
      +
    • Note: If you get a compile error for "R", try right-clicking on the Java + package and then clicking "Optimize Imports" to remove unused imports containing the + "R". Another possibility is that the + "package" in the AndroidManifest.xml file doesn't match the Java package name. +
    • +
    + +
  • +
  • Run > Run 'calendar-android-sample' +
      +
    • Note: you must use a physical device for developing and testing + because Google Play services cannot be installed on an emulator. + + Read this page for more information on how to set up a device. +
    • +
    • To enable logging of HTTP requests and responses (highly recommended + when developing): +
      +$ANDROID_HOME/platform-tools/adb shell setprop log.tag.HttpTransport DEBUG
      +
      + and then change CalendarSampleActivity.LOGGING_LEVEL to Level.CONFIG. +
    • +
    • Note: If get "[Error] Access Not Configured" it usually means the Android app + registration didn't work or doesn't match your app's package name and SHA1 + fingerprint. It may also be because "Calendar API" isn't enabled for your project + in the Google Cloud Console (see instructions above). +
    • +
    +
  • +
+ + + diff --git a/calendar-android-sample/proguard-google-api-client.txt b/calendar-android-sample/proguard-google-api-client.txt new file mode 100644 index 00000000..41161cd0 --- /dev/null +++ b/calendar-android-sample/proguard-google-api-client.txt @@ -0,0 +1,34 @@ +# ProGuard Configuration file +# +# See http://proguard.sourceforge.net/index.html#manual/usage.html + +# Needed to keep generic types and @Key annotations accessed via reflection + +-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault + +-keepclassmembers class * { + @com.google.api.client.util.Key ; +} + +# Needed by google-http-client-android when linking against an older platform version + +-dontwarn com.google.api.client.extensions.android.** + +# Needed by google-api-client-android when linking against an older platform version + +-dontwarn com.google.api.client.googleapis.extensions.android.** + +# Needed by google-play-services when linking against an older platform version + +-dontwarn com.google.android.gms.** +-dontnote com.google.android.gms.** + +# com.google.client.util.IOUtils references java.nio.file.Files when on Java 7+ +-dontnote java.nio.file.Files, java.nio.file.Path + +# Suppress notes on LicensingServices +-dontnote **.ILicensingService + +# Suppress warnings on sun.misc.Unsafe +-dontnote sun.misc.Unsafe +-dontwarn sun.misc.Unsafe diff --git a/calendar-android-sample/res/drawable-hdpi/btn_bg_pressed.9.png b/calendar-android-sample/res/drawable-hdpi/btn_bg_pressed.9.png new file mode 100644 index 00000000..b1afd4b6 Binary files /dev/null and b/calendar-android-sample/res/drawable-hdpi/btn_bg_pressed.9.png differ diff --git a/calendar-android-sample/res/drawable-hdpi/btn_bg_selected.9.png b/calendar-android-sample/res/drawable-hdpi/btn_bg_selected.9.png new file mode 100644 index 00000000..331f96f4 Binary files /dev/null and b/calendar-android-sample/res/drawable-hdpi/btn_bg_selected.9.png differ diff --git a/calendar-android-sample/res/drawable-hdpi/ic_launcher.png b/calendar-android-sample/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..96a442e5 Binary files /dev/null and b/calendar-android-sample/res/drawable-hdpi/ic_launcher.png differ diff --git a/calendar-android-sample/res/drawable-hdpi/ic_mailboxes_accounts.png b/calendar-android-sample/res/drawable-hdpi/ic_mailboxes_accounts.png new file mode 100644 index 00000000..8425ac72 Binary files /dev/null and b/calendar-android-sample/res/drawable-hdpi/ic_mailboxes_accounts.png differ diff --git a/calendar-android-sample/res/drawable-hdpi/ic_menu_refresh.png b/calendar-android-sample/res/drawable-hdpi/ic_menu_refresh.png new file mode 100644 index 00000000..9b4f7562 Binary files /dev/null and b/calendar-android-sample/res/drawable-hdpi/ic_menu_refresh.png differ diff --git a/calendar-android-sample/res/drawable-hdpi/ic_title_add_alt.png b/calendar-android-sample/res/drawable-hdpi/ic_title_add_alt.png new file mode 100644 index 00000000..e597aea5 Binary files /dev/null and b/calendar-android-sample/res/drawable-hdpi/ic_title_add_alt.png differ diff --git a/calendar-android-sample/res/drawable-hdpi/ic_title_add_default.png b/calendar-android-sample/res/drawable-hdpi/ic_title_add_default.png new file mode 100644 index 00000000..e0305089 Binary files /dev/null and b/calendar-android-sample/res/drawable-hdpi/ic_title_add_default.png differ diff --git a/calendar-android-sample/res/drawable-ldpi/ic_launcher.png b/calendar-android-sample/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 00000000..99238729 Binary files /dev/null and b/calendar-android-sample/res/drawable-ldpi/ic_launcher.png differ diff --git a/calendar-android-sample/res/drawable-ldpi/ic_menu_refresh.png b/calendar-android-sample/res/drawable-ldpi/ic_menu_refresh.png new file mode 100644 index 00000000..e214e82d Binary files /dev/null and b/calendar-android-sample/res/drawable-ldpi/ic_menu_refresh.png differ diff --git a/calendar-android-sample/res/drawable-mdpi/ic_launcher.png b/calendar-android-sample/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..359047df Binary files /dev/null and b/calendar-android-sample/res/drawable-mdpi/ic_launcher.png differ diff --git a/calendar-android-sample/res/drawable-mdpi/ic_mailboxes_accounts.png b/calendar-android-sample/res/drawable-mdpi/ic_mailboxes_accounts.png new file mode 100644 index 00000000..a1a494f7 Binary files /dev/null and b/calendar-android-sample/res/drawable-mdpi/ic_mailboxes_accounts.png differ diff --git a/calendar-android-sample/res/drawable-mdpi/ic_menu_refresh.png b/calendar-android-sample/res/drawable-mdpi/ic_menu_refresh.png new file mode 100644 index 00000000..83ac7ae4 Binary files /dev/null and b/calendar-android-sample/res/drawable-mdpi/ic_menu_refresh.png differ diff --git a/calendar-android-sample/res/drawable-xhdpi/ic_launcher.png b/calendar-android-sample/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..71c6d760 Binary files /dev/null and b/calendar-android-sample/res/drawable-xhdpi/ic_launcher.png differ diff --git a/calendar-android-sample/res/drawable-xhdpi/ic_menu_refresh.png b/calendar-android-sample/res/drawable-xhdpi/ic_menu_refresh.png new file mode 100644 index 00000000..e4c7a4c1 Binary files /dev/null and b/calendar-android-sample/res/drawable-xhdpi/ic_menu_refresh.png differ diff --git a/calendar-android-sample/res/drawable/ic_title_add.xml b/calendar-android-sample/res/drawable/ic_title_add.xml new file mode 100644 index 00000000..a7265d2d --- /dev/null +++ b/calendar-android-sample/res/drawable/ic_title_add.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/calendar-android-sample/res/drawable/ic_title_add_light.xml b/calendar-android-sample/res/drawable/ic_title_add_light.xml new file mode 100644 index 00000000..12963c10 --- /dev/null +++ b/calendar-android-sample/res/drawable/ic_title_add_light.xml @@ -0,0 +1,22 @@ + + + + + + + + diff --git a/calendar-android-sample/res/drawable/title_button.xml b/calendar-android-sample/res/drawable/title_button.xml new file mode 100644 index 00000000..94139e9b --- /dev/null +++ b/calendar-android-sample/res/drawable/title_button.xml @@ -0,0 +1,22 @@ + + + + + + + + diff --git a/calendar-android-sample/res/layout/addcalendar.xml b/calendar-android-sample/res/layout/addcalendar.xml new file mode 100644 index 00000000..f4a4a6cb --- /dev/null +++ b/calendar-android-sample/res/layout/addcalendar.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
" + + ""); + if (history.getItems() != null) { + for (Url oneShortened : history.getItems()) { + writer.append(""); + } + } + writer.append("
OriginalShortened
"); + writer.append(oneShortened.getLongUrl()).append("").append(oneShortened.getId()); + writer.append("
"); + writer.flush(); + resp.setStatus(200); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { + String longUrl = req.getParameter("longUrl"); + Urlshortener shortener = newUrlshortener(); + Url toInsert = new Url().setLongUrl(longUrl); + try { + shortener.url().insert(toInsert).execute(); + } catch (GoogleJsonResponseException e) { + resp.sendError(404, e.getMessage()); + } + resp.sendRedirect("/"); + } +} diff --git a/urlshortener-robots-appengine-sample/src/main/resources/log4j.properties b/urlshortener-robots-appengine-sample/src/main/resources/log4j.properties new file mode 100644 index 00000000..d9c3edc9 --- /dev/null +++ b/urlshortener-robots-appengine-sample/src/main/resources/log4j.properties @@ -0,0 +1,24 @@ +# A default log4j configuration for log4j users. +# +# To use this configuration, deploy it into your application's WEB-INF/classes +# directory. You are also encouraged to edit it as you like. + +# Configure the console as our one appender +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n + +# tighten logging on the DataNucleus Categories +log4j.category.DataNucleus.JDO=WARN, A1 +log4j.category.DataNucleus.Persistence=WARN, A1 +log4j.category.DataNucleus.Cache=WARN, A1 +log4j.category.DataNucleus.MetaData=WARN, A1 +log4j.category.DataNucleus.General=WARN, A1 +log4j.category.DataNucleus.Utility=WARN, A1 +log4j.category.DataNucleus.Transaction=WARN, A1 +log4j.category.DataNucleus.Datastore=WARN, A1 +log4j.category.DataNucleus.ClassLoading=WARN, A1 +log4j.category.DataNucleus.Plugin=WARN, A1 +log4j.category.DataNucleus.ValueGeneration=WARN, A1 +log4j.category.DataNucleus.Enhancer=WARN, A1 +log4j.category.DataNucleus.SchemaTool=WARN, A1 diff --git a/urlshortener-robots-appengine-sample/src/main/webapp/WEB-INF/appengine-web.xml b/urlshortener-robots-appengine-sample/src/main/webapp/WEB-INF/appengine-web.xml new file mode 100644 index 00000000..12318fe6 --- /dev/null +++ b/urlshortener-robots-appengine-sample/src/main/webapp/WEB-INF/appengine-web.xml @@ -0,0 +1,13 @@ + + + yanivi-robot + 1 + + true + + + + + + + \ No newline at end of file diff --git a/urlshortener-robots-appengine-sample/src/main/webapp/WEB-INF/logging.properties b/urlshortener-robots-appengine-sample/src/main/webapp/WEB-INF/logging.properties new file mode 100644 index 00000000..2f7a8ca5 --- /dev/null +++ b/urlshortener-robots-appengine-sample/src/main/webapp/WEB-INF/logging.properties @@ -0,0 +1,17 @@ +# A default java.util.logging configuration. +# (All App Engine logging is through java.util.logging by default). +# +# To use this configuration, copy it into your application's WEB-INF +# folder and add the following to your appengine-web.xml: +# +# +# +# +# + +# Set the default logging level for all loggers to WARNING +.level = WARNING + +# Set the logging level for the Google APIs Java Client +# Uncomment this to debug the Google API Client Library for Java +#com.google.api.client.level = CONFIG \ No newline at end of file diff --git a/urlshortener-robots-appengine-sample/src/main/webapp/WEB-INF/web.xml b/urlshortener-robots-appengine-sample/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..2d6c0ff7 --- /dev/null +++ b/urlshortener-robots-appengine-sample/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,18 @@ + + + + + app + com.google.api.client.sample.urlshortener.appengine.robots.UrlShortenerSample + + + + app + / + + + diff --git a/youtube-jsonc-sample/.classpath b/youtube-jsonc-sample/.classpath deleted file mode 100644 index de5a9e91..00000000 --- a/youtube-jsonc-sample/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/youtube-jsonc-sample/.project b/youtube-jsonc-sample/.project deleted file mode 100644 index 5a1aaa00..00000000 --- a/youtube-jsonc-sample/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - youtube-jsonc-sample - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - diff --git a/youtube-jsonc-sample/.settings/org.eclipse.jdt.core.prefs b/youtube-jsonc-sample/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 352e83ca..00000000 --- a/youtube-jsonc-sample/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Mon Jul 19 13:11:25 EDT 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.6 diff --git a/youtube-jsonc-sample/instructions.html b/youtube-jsonc-sample/instructions.html deleted file mode 100644 index 452cdb5d..00000000 --- a/youtube-jsonc-sample/instructions.html +++ /dev/null @@ -1,66 +0,0 @@ - -YouTube Data API JSON-C Sample - -

Instructions for the YouTube Data API JSON-C Sample

- -

Browse Online

- - - -

Checkout Instructions

- -

Prerequisites: install Java 6, Mercurial and Maven. You may need to set -your JAVA_HOME.

- -
cd [someDirectory]
-hg clone https://samples.google-api-java-client.googlecode.com/hg/ google-api-java-client-samples
-cd google-api-java-client-samples/youtube-jsonc-sample
-mvn compile
-mvn -q exec:java
- -

Setup Project in Eclipse 3.5/3.6

- -

Prerequisites: install Eclipse, -the Mercurial plugin, and the Maven -plugin.

- -
    -
  • Setup Eclipse Preferences -
      -
    • Window > Preferences... (or on Mac, Eclipse > Preferences...)
    • -
    • Select Maven -
        -
      • check on "Download Artifact Sources"
      • -
      • check on "Download Artifact JavaDoc"
      • -
      -
    • -
    -
  • -
  • Import youtube-jsonc-sample project -
      -
    • File > Import...
    • -
    • Select "General > Existing Project into Workspace" and click - "Next"
    • -
    • Click "Browse" next to "Select root directory", find [someDirectory]/google-api-java-client-samples/youtube-jsonc-sample - and click "Next"
    • -
    • Click "Finish"
    • -
    -
  • -
  • Run -
      -
    • Right-click on project youtube-jsonc-sample
    • -
    • Run As > Java Application
    • -
    -
  • -
- - - diff --git a/youtube-jsonc-sample/pom.xml b/youtube-jsonc-sample/pom.xml deleted file mode 100644 index f861d035..00000000 --- a/youtube-jsonc-sample/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - 4.0.0 - - com.google - google - 5 - - com.google.api.client - youtube-jsonc-sample - 1.0.1 - youtube-jsonc-sample - - Example for the YouTube API using JSON-C. - - - http://code.google.com/p/google-api-java-client/ - - - code.google.com - http://code.google.com/p/google-api-java-client/issues/list - - - 2010 - - - 2.0.9 - - - - scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ - scm:hg:https://samples.google-api-java-client.googlecode.com/hg/ - http://code.google.com/p/google-api-java-client/source/browse/?repo=samples - - - - - yanivi - Yaniv Inbar - yanivi@google.com - Google - http://www.google.com - - owner - developer - - -5 - - - - - - maven-compiler-plugin - - 1.6 - 1.6 - - - - org.codehaus.mojo - exec-maven-plugin - 1.1 - - - - java - - - - - com.google.api.client.sample.youtube.YouTubeSample - - - - ${project.artifactId}-${project.version} - src - tests_disabled - - - - com.google.api.client - google-api-client - 1.2.0-alpha-SNAPSHOT - - - - UTF-8 - - diff --git a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/YouTubeSample.java b/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/YouTubeSample.java deleted file mode 100644 index 435befeb..00000000 --- a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/YouTubeSample.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.youtube; - -import com.google.api.client.googleapis.GoogleHeaders; -import com.google.api.client.googleapis.GoogleTransport; -import com.google.api.client.googleapis.json.JsonCParser; -import com.google.api.client.http.HttpResponseException; -import com.google.api.client.http.HttpTransport; -import com.google.api.client.sample.youtube.model.Debug; -import com.google.api.client.sample.youtube.model.Video; -import com.google.api.client.sample.youtube.model.VideoFeed; -import com.google.api.client.sample.youtube.model.YouTubeUrl; - -import java.io.IOException; - -/** - * @author Yaniv Inbar - */ -public class YouTubeSample { - - private static final int MAX_VIDEOS_TO_SHOW = 5; - - public static void main(String[] args) { - Debug.enableLogging(); - try { - try { - HttpTransport transport = setUpTransport(); - showVideos(transport); - } catch (HttpResponseException e) { - System.err.println(e.response.parseAsString()); - throw e; - } - } catch (Throwable t) { - t.printStackTrace(); - System.exit(1); - } - } - - private static HttpTransport setUpTransport() { - HttpTransport transport = GoogleTransport.create(); - GoogleHeaders headers = (GoogleHeaders) transport.defaultHeaders; - headers.setApplicationName("google-youtubejsoncsample-1.0"); - headers.gdataVersion = "2"; - transport.addParser(new JsonCParser()); - return transport; - } - - private static VideoFeed showVideos(HttpTransport transport) - throws IOException { - // build URL for the video feed for "search stories" - YouTubeUrl url = YouTubeUrl.relativeToRoot("videos"); - url.maxResults = MAX_VIDEOS_TO_SHOW; - url.author = "searchstories"; - // execute GData request for the feed - VideoFeed feed = VideoFeed.executeGet(transport, url); - System.out.println("Total number of videos: " + feed.totalItems); - for (Video video : feed.items) { - showVideo(video); - } - return feed; - } - - private static void showVideo(Video video) { - System.out.println(); - System.out.println("-----------------------------------------------"); - System.out.println("Video title: " + video.title); - System.out.println("Description: " + video.description); - System.out.println("Updated: " + video.updated); - System.out.println("Tags: " + video.tags); - System.out.println("Play URL: " + video.player.defaultUrl); - } -} diff --git a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Debug.java b/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Debug.java deleted file mode 100644 index 7f9328f4..00000000 --- a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Debug.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.youtube.model; - -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -/** - * @author Yaniv Inbar - */ -public class Debug { - public static final boolean ENABLED = false; - - public static void enableLogging() { - if (ENABLED) { - Logger logger = Logger.getLogger("com.google.api.client"); - logger.setLevel(Level.CONFIG); - logger.addHandler(new Handler() { - - @Override - public void close() throws SecurityException { - } - - @Override - public void flush() { - } - - @Override - public void publish(LogRecord record) { - // default ConsoleHandler will take care of >= INFO - if (record.getLevel().intValue() < Level.INFO.intValue()) { - System.out.println(record.getMessage()); - } - } - }); - } - } -} diff --git a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Feed.java b/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Feed.java deleted file mode 100644 index f05b06f9..00000000 --- a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Feed.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.youtube.model; - -import com.google.api.client.http.HttpRequest; -import com.google.api.client.http.HttpTransport; -import com.google.api.client.util.DateTime; -import com.google.api.client.util.Key; - -import java.io.IOException; - -/** - * @author Yaniv Inbar - */ -public class Feed { - @Key - public int itemsPerPage; - @Key - public int startIndex; - @Key - public int totalItems; - @Key - public DateTime updated; - - static Feed executeGet(HttpTransport transport, YouTubeUrl url, - Class feedClass) throws IOException { - HttpRequest request = transport.buildGetRequest(); - request.url = url; - return request.execute().parseAs(feedClass); - } -} diff --git a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Item.java b/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Item.java deleted file mode 100644 index 94aa1867..00000000 --- a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Item.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.youtube.model; - -import com.google.api.client.util.DateTime; -import com.google.api.client.util.Key; - -/** - * @author Yaniv Inbar - */ -public class Item { - @Key - public String id; - @Key - public String title; - @Key - public DateTime updated; -} diff --git a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Player.java b/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Player.java deleted file mode 100644 index 3d233853..00000000 --- a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Player.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.youtube.model; - -import com.google.api.client.util.Key; - -/** - * @author Yaniv Inbar - */ -public class Player { - // "default" is a Java keyword, so need to specify the JSON key manually - @Key("default") - public String defaultUrl; -} diff --git a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Video.java b/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Video.java deleted file mode 100644 index ef2f373e..00000000 --- a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/Video.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.youtube.model; - -import com.google.api.client.util.Key; - -import java.util.List; - -/** - * @author Yaniv Inbar - */ -public class Video extends Item { - @Key - public String description; - @Key - public List tags; - @Key - public Player player; -} \ No newline at end of file diff --git a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/VideoFeed.java b/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/VideoFeed.java deleted file mode 100644 index 75eac7b5..00000000 --- a/youtube-jsonc-sample/src/com/google/api/client/sample/youtube/model/VideoFeed.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2010 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.api.client.sample.youtube.model; - -import com.google.api.client.http.HttpTransport; -import com.google.api.client.util.Key; - -import java.io.IOException; -import java.util.List; - -/** - * @author Yaniv Inbar - */ -public class VideoFeed extends Feed { - @Key - public List