Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2007-09-30 18:11:02 +0000
committerJohn Arthorne2007-09-30 18:11:02 +0000
commit2ccb446cc885495686cc9eb430c4a98031b3cfc5 (patch)
tree207e30d5f61856ece926ed3548297aa3958132c9 /bundles/org.eclipse.equinox.p2.artifact.repository
parentc4f6662ccd02bb75cba95a6ae56a2da38c6cadde (diff)
downloadrt.equinox.p2-2ccb446cc885495686cc9eb430c4a98031b3cfc5.tar.gz
rt.equinox.p2-2ccb446cc885495686cc9eb430c4a98031b3cfc5.tar.xz
rt.equinox.p2-2ccb446cc885495686cc9eb430c4a98031b3cfc5.zip
Renamed prov bundles to p2
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/.classpath7
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/.project28
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.jdt.core.prefs343
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.jdt.ui.prefs57
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF29
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/about.html28
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/build.properties16
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml21
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/schema/artifactRepositories.exsd124
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/schema/processingSteps.exsd110
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/Activator.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRepositoryIO.java74
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRepositoryManager.java296
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRequest.java90
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ECFTransport.java128
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/FileDownloadRequest.java41
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/MirrorRequest.java73
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SignatureVerifier.java81
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SimpleArtifactRepository.java333
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SimpleArtifactRepositoryFactory.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/Unpack200Step.java103
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/ArtifactDescriptor.java98
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactDescriptor.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepository.java73
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepositoryFactory.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepositoryManager.java85
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRequest.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IWritableArtifactRepository.java56
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/Mapper.java130
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/RepositoryDescriptor.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/Transport.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStep.java116
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStepDescriptor.java86
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStepHandler.java74
35 files changed, 2929 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/.classpath b/bundles/org.eclipse.equinox.p2.artifact.repository/.classpath
new file mode 100644
index 000000000..7cdeb7319
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/CDC-1.1%Foundation-1.1"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/.project b/bundles/org.eclipse.equinox.p2.artifact.repository/.project
new file mode 100644
index 000000000..c94254214
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.equinox.prov.artifact.repository</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..3f53e5adb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,343 @@
+#Mon Sep 17 23:16:48 EDT 2007
+eclipse.preferences.version=1
+instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+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.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+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=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+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=error
+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.invalidJavadoc=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+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=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=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+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.unsafeTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+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=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+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=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+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=1
+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=false
+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=false
+org.eclipse.jdt.core.formatter.comment.format_comments=false
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false
+org.eclipse.jdt.core.formatter.comment.format_line_comments=false
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=false
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=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=do not 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=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=800
+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=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+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.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 000000000..e71c32e23
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,57 @@
+#Sun Sep 23 11:57:38 EDT 2007
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_core
+formatter_settings_version=11
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=;
+org.eclipse.jdt.ui.ondemandthreshold=3
+org.eclipse.jdt.ui.staticondemandthreshold=3
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><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_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+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.format_source_code=true
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+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/bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.pde.core.prefs b/bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..979e4e8b4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+
+eclipse.preferences.version=1
+pluginProject.extensions=true
+resolve.requirebundle=false
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..ffbacbb41
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Artifact Repository Bundle (Incubation)
+Bundle-SymbolicName: org.eclipse.equinox.prov.artifact.repository;singleton:=true
+Bundle-Version: 0.1.0.qualifier
+Export-Package: org.eclipse.equinox.internal.prov.artifact.repository;x-friends:="org.eclipse.equinox.prov.metadata.generator,org.eclipse.equinox.prov.test,org.eclipse.equinox.prov.selfhosting",
+ org.eclipse.equinox.prov.artifact.repository,
+ org.eclipse.equinox.prov.artifact.repository.processing
+Import-Package: com.thoughtworks.xstream,
+ org.eclipse.core.runtime.preferences,
+ org.eclipse.equinox.internal.p2.jarprocessor;resolution:=optional,
+ org.eclipse.equinox.p2.jarprocessor;resolution:=optional,
+ org.eclipse.equinox.prov.core.helpers,
+ org.eclipse.equinox.prov.core.location,
+ org.eclipse.equinox.prov.core.repository,
+ org.eclipse.equinox.prov.metadata,
+ org.eclipse.osgi.internal.provisional.verifier,
+ org.osgi.framework;version="1.3.0",
+ org.osgi.service.prefs;version="1.1.0",
+ org.osgi.util.tracker;version="1.3.0"
+Bundle-Activator: org.eclipse.equinox.internal.prov.artifact.repository.Activator
+Eclipse-LazyStart: true
+Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,
+ J2SE-1.4
+Require-Bundle: org.eclipse.ecf.filetransfer,
+ org.eclipse.ecf,
+ org.eclipse.equinox.common,
+ org.eclipse.equinox.registry
+Eclipse-BuddyPolicy: registered
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/about.html b/bundles/org.eclipse.equinox.p2.artifact.repository/about.html
new file mode 100644
index 000000000..460233046
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 2, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties b/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties
new file mode 100644
index 000000000..8917af773
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ about.html
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml b/bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml
new file mode 100644
index 000000000..be934eedd
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="artifactRepositories" name="Artifact Repositories" schema="schema/artifactRepositories.exsd"/>
+ <extension-point id="processingSteps" name="Processing Steps" schema="schema/processingSteps.exsd"/>
+ <extension id="simpleRepository" point="org.eclipse.equinox.prov.artifact.repository.artifactRepositories">
+ <filter suffix="artifacts.xml"/>
+ <factory class="org.eclipse.equinox.internal.prov.artifact.repository.SimpleArtifactRepositoryFactory"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.equinox.prov.artifact.repository.processingSteps"
+ id="org.eclipse.equinox.p2.processing.Pack200Unpacker">
+ <step class="org.eclipse.equinox.internal.prov.artifact.repository.Unpack200Step"/>
+ </extension>
+ <extension
+ point="org.eclipse.equinox.prov.artifact.repository.processingSteps"
+ id="org.eclipse.equinox.p2.processing.SignatureVerifier">
+ <step class="org.eclipse.equinox.internal.prov.artifact.repository.SignatureVerifier"/>
+ </extension>
+</plugin>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/schema/artifactRepositories.exsd b/bundles/org.eclipse.equinox.p2.artifact.repository/schema/artifactRepositories.exsd
new file mode 100644
index 000000000..18db7af66
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/schema/artifactRepositories.exsd
@@ -0,0 +1,124 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.equinox.prov.artifact.repository">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.equinox.prov.artifact.repository" id="artifactRepositories" name="Artifact Repositories"/>
+ </appInfo>
+ <documentation>
+ This extension point is used to provide artifact repository implementations
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="factory"/>
+ <element ref="filter" minOccurs="0" maxOccurs="1"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="factory">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the fully-qualified name of a class which implements
+&lt;samp&gt;org.eclipse.equinox.prov.artifact.repository.IArtifactRepository&lt;/samp&gt;.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.equinox.prov.artifact.repository.IArtifactRepository"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="filter">
+ <complexType>
+ <attribute name="suffix" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ org.eclipse.equinox.prov.artifact.repository 0.1.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The value of the class attribute must represent an
+implementor of &lt;tt&gt;org.eclipse.equinox.prov.artifact.repository.IArtifactRepository&lt;/tt&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2007 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made
+available under the terms of the Eclipse Public License v1.0 which
+accompanies this distribution, and is available at &lt;a
+href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/schema/processingSteps.exsd b/bundles/org.eclipse.equinox.p2.artifact.repository/schema/processingSteps.exsd
new file mode 100644
index 000000000..2d3eaa7ab
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/schema/processingSteps.exsd
@@ -0,0 +1,110 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.equinox.prov.artifact.repository">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.equinox.prov.artifact.repository" id="processingSteps" name="Processing Steps"/>
+ </appInfo>
+ <documentation>
+ This extension point is used to provide processing step implementations
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="step"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="step">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.equinox.prov.artifact.repository.processing.IProcessingStep"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ org.eclipse.equinox.prov.artifact.repository ?.?.?
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The value of the class attribute must represent an
+implementor of &lt;tt&gt;org.eclipse.equinox.prov.artifact.processing.IProcessingStep&lt;/tt&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2007 compeople AG and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made
+available under the terms of the Eclipse Public License v1.0 which
+accompanies this distribution, and is available at &lt;a
+href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/Activator.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/Activator.java
new file mode 100644
index 000000000..e21be5826
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/Activator.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import org.eclipse.equinox.prov.artifact.repository.IArtifactRepositoryManager;
+import org.osgi.framework.*;
+
+public class Activator implements BundleActivator {
+ private static BundleContext context;
+ public static final String ID = "org.eclipse.equinox.prov.artifact.repository";
+ public static final String REPO_PROVIDER_XPT = ID + '.' + "artifactRepositories";
+ public IArtifactRepositoryManager repoManager;
+ public ServiceRegistration repoManagerRegistration;
+
+ public void start(BundleContext context) throws Exception {
+ Activator.context = context;
+ // repoManager = new ArtifactRepoManager();
+ // repoManagerRegistration = context.registerService(IArtifactRepoManager.class.getName(), repoManager, null);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ Activator.context = null;
+ // repoManager = null;
+ // repoManagerRegistration = null;
+ }
+
+ public static BundleContext getContext() {
+ return Activator.context;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRepositoryIO.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRepositoryIO.java
new file mode 100644
index 000000000..3457ae896
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRepositoryIO.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import com.thoughtworks.xstream.XStream;
+import java.io.*;
+import org.eclipse.equinox.prov.artifact.repository.IArtifactRepository;
+import org.eclipse.equinox.prov.core.repository.RepositoryCreationException;
+
+/**
+ * This class reads and writes artifact repository
+ * (eg. table of contents files);
+ *
+ * This class is not used for reading or writing the actual artifacts.
+ *
+ * The implementation currently uses XStream.
+ */
+class ArtifactRepositoryIO {
+
+ /**
+ * Reads the artifact repository from the given stream,
+ * and returns the contained array of abstract artifact repositories.
+ *
+ * This method performs buffering, and closes the stream when finished.
+ */
+ public static IArtifactRepository read(InputStream input) throws RepositoryCreationException {
+ XStream stream = new XStream();
+ BufferedInputStream bufferedInput = null;
+ try {
+ try {
+ bufferedInput = new BufferedInputStream(input);
+ return (IArtifactRepository) stream.fromXML(bufferedInput);
+ } finally {
+ if (bufferedInput != null)
+ bufferedInput.close();
+ }
+ } catch (IOException e) {
+ throw new RepositoryCreationException(e);
+ }
+ }
+
+ /**
+ * Writes the given artifact repository to the stream.
+ * This method performs buffering, and closes the stream when finished.
+ */
+ public static void write(IArtifactRepository repository, OutputStream output) {
+ XStream stream = new XStream();
+ OutputStream bufferedOutput = null;
+ try {
+ try {
+ bufferedOutput = new BufferedOutputStream(output);
+ stream.toXML(repository, bufferedOutput);
+ } finally {
+ if (bufferedOutput != null) {
+ bufferedOutput.close();
+ }
+ }
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRepositoryManager.java
new file mode 100644
index 000000000..cd7c8854f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRepositoryManager.java
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.equinox.prov.artifact.repository.*;
+import org.eclipse.equinox.prov.core.helpers.*;
+import org.eclipse.equinox.prov.core.location.AgentLocation;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+// TODO Need to react to repository going away
+// TODO the current assumption that the "location" is the dir/root limits us to
+// having just one repo in a given URL..
+public class ArtifactRepositoryManager implements IArtifactRepositoryManager {
+ private static final String ATTR_FILTER = "filter"; //$NON-NLS-1$
+ private static final String ATTR_SUFFIX = "suffix"; //$NON-NLS-1$
+ private static final String EL_FACTORY = "factory"; //$NON-NLS-1$
+
+ private static final String KEY_DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String KEY_NAME = "name"; //$NON-NLS-1$
+ private static final String KEY_PROVIDER = "provider"; //$NON-NLS-1$
+ private static final String KEY_TYPE = "type"; //$NON-NLS-1$
+ private static final String KEY_URL = "url"; //$NON-NLS-1$
+ private static final String KEY_VERSION = "version"; //$NON-NLS-1$
+ private static final String NODE_REPOSITORIES = "repositories"; //$NON-NLS-1$
+
+ private List repositories = Collections.synchronizedList(new ArrayList());
+
+ public ArtifactRepositoryManager() {
+ restoreRepositories();
+ }
+
+ public void addRepository(IArtifactRepository repository) {
+ repositories.add(repository);
+ // save the given repository in the preferences.
+ remember(repository);
+ }
+
+ public IArtifactRequest createDownloadRequest(IArtifactKey key, IPath destination) {
+ return new FileDownloadRequest(key, destination);
+ }
+
+ private Object createExecutableExtension(IExtension extension, String element) throws CoreException {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i].getName().equals(element))
+ return elements[i].createExecutableExtension("class"); //$NON-NLS-1$
+ }
+ throw new CoreException(new Status(IStatus.ERROR, Activator.ID, "Malformed extension"));
+ }
+
+ public IArtifactRequest createMirrorRequest(IArtifactKey key, IWritableArtifactRepository destination) {
+ return new MirrorRequest(key, destination);
+ }
+
+ public IArtifactRepository createRepository(URL location, String name, String type) {
+ IArtifactRepository result = loadRepository(location, (IProgressMonitor) null);
+ if (result != null)
+ return result;
+ IExtension extension = RegistryFactory.getRegistry().getExtension(Activator.REPO_PROVIDER_XPT, type);
+ if (extension == null)
+ return null;
+ try {
+ IArtifactRepositoryFactory factory = (IArtifactRepositoryFactory) createExecutableExtension(extension, EL_FACTORY);
+ if (factory == null)
+ return null;
+ result = factory.create(location, name, type);
+ if (result != null)
+ addRepository(result);
+ return result;
+ } catch (CoreException e) {
+ log("Failed to load artifact repository extension: " + location, e); //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ private IExtension[] findMatchingRepositoryExtensions(String suffix) {
+ IConfigurationElement[] elt = RegistryFactory.getRegistry().getConfigurationElementsFor(Activator.REPO_PROVIDER_XPT);
+ int count = 0;
+ for (int i = 0; i < elt.length; i++) {
+ if (ATTR_FILTER.equals(elt[i].getName())) {
+ if (!suffix.equals(elt[i].getAttribute(ATTR_SUFFIX))) {
+ elt[i] = null;
+ } else {
+ count++;
+ }
+ } else {
+ elt[i] = null;
+ }
+ }
+ IExtension[] results = new IExtension[count];
+ for (int i = 0; i < elt.length; i++) {
+ if (elt[i] != null)
+ results[--count] = elt[i].getDeclaringExtension();
+ }
+ return results;
+ }
+
+ private void forget(IArtifactRepository toRemove) throws BackingStoreException {
+ getPreferences().node(getKey(toRemove)).removeNode();
+ }
+
+ private String[] getAllSuffixes() {
+ IConfigurationElement[] elements = RegistryFactory.getRegistry().getConfigurationElementsFor(Activator.REPO_PROVIDER_XPT);
+ ArrayList result = new ArrayList(elements.length);
+ for (int i = 0; i < elements.length; i++)
+ if (elements[i].getName().equals(ATTR_FILTER))
+ result.add(elements[i].getAttribute(ATTR_SUFFIX));
+ return (String[]) result.toArray(new String[result.size()]);
+ }
+
+ /*
+ * Return an encoded repository key that is suitable for using
+ * as the name of a preference node.
+ */
+ private String getKey(IArtifactRepository repository) {
+ return repository.getLocation().toExternalForm().replace('/', '_');
+ }
+
+ public IArtifactRepository[] getKnownRepositories() {
+ if (repositories == null)
+ restoreRepositories();
+ return (IArtifactRepository[]) repositories.toArray(new IArtifactRepository[repositories.size()]);
+ }
+
+ /*
+ * Return the root preference node where we store the repository information.
+ */
+ private Preferences getPreferences() {
+ return new ConfigurationScope().getNode(Activator.ID).node(NODE_REPOSITORIES);
+ }
+
+ public IArtifactRepository getRepository(URL location) {
+ if (repositories == null)
+ restoreRepositories();
+ for (Iterator iterator = repositories.iterator(); iterator.hasNext();) {
+ IArtifactRepository match = (IArtifactRepository) iterator.next();
+ if (Utils.sameURL(match.getLocation(), location))
+ return match;
+ }
+ return null;
+ }
+
+ public IArtifactRepository loadRepository(URL location, IProgressMonitor monitor) {
+ // TODO do some thing with the monitor
+ IArtifactRepository result = getRepository(location);
+ if (result != null)
+ return result;
+ String[] suffixes = getAllSuffixes();
+ for (int i = 0; i < suffixes.length; i++) {
+ result = loadRepository(location, suffixes[i]);
+ if (result != null) {
+ addRepository(result);
+ return result;
+ }
+ }
+ return null;
+ }
+
+ private IArtifactRepository loadRepository(URL location, String suffix) {
+ IExtension[] providers = findMatchingRepositoryExtensions(suffix);
+ // Loop over the candidates and return the first one that successfully loads
+ for (int i = 0; i < providers.length; i++)
+ try {
+ IArtifactRepositoryFactory factory = (IArtifactRepositoryFactory) createExecutableExtension(providers[i], EL_FACTORY);
+ if (factory != null)
+ return factory.load(location);
+ } catch (CoreException e) {
+ log("Unable to load repository: " + location, e); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ protected void log(String message, Throwable t) {
+ LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, t));
+ }
+
+ /*
+ * Add the given repository object to the preferences and save.
+ */
+ private void remember(IArtifactRepository repository) {
+ Preferences node = getPreferences().node(getKey(repository));
+ String value = repository.getDescription();
+ if (value != null)
+ node.put(KEY_DESCRIPTION, value);
+ value = repository.getName();
+ if (value != null)
+ node.put(KEY_NAME, value);
+ value = repository.getProvider();
+ if (value != null)
+ node.put(KEY_PROVIDER, value);
+ value = repository.getType();
+ if (value != null)
+ node.put(KEY_TYPE, value);
+ value = repository.getVersion();
+ if (value != null)
+ node.put(KEY_VERSION, value);
+ value = repository.getLocation().toExternalForm();
+ node.put(KEY_URL, value);
+ saveRepositoryList();
+ }
+
+ public void removeRepository(IArtifactRepository toRemove) {
+ if (toRemove != null)
+ repositories.remove(toRemove);
+ // remove the repository from the preferences
+ try {
+ forget(toRemove);
+ saveRepositoryList();
+ } catch (BackingStoreException e) {
+ log("Error saving preferences", e); //$NON-NLS-1$
+ }
+ }
+
+ /*
+ * Load the list of repositories from the preferences.
+ */
+ private void restoreFromPreferences() {
+ // restore the list of repositories from the preference store
+ Preferences node = getPreferences();
+ String[] children;
+ try {
+ children = node.childrenNames();
+ } catch (BackingStoreException e) {
+ log("Error restoring repositories from preferences", e); //$NON-NLS-1$
+ return;
+ }
+ for (int i = 0; i < children.length; i++) {
+ Preferences child = node.node(children[i]);
+ String url = child.get(KEY_URL, null);
+ if (url == null)
+ continue;
+ try {
+ IArtifactRepository repository = loadRepository(new URL(url), (IProgressMonitor) null);
+ // If we could not restore the repo then remove it from the preferences.
+ if (repository == null)
+ child.removeNode();
+ } catch (MalformedURLException e) {
+ log("Error while restoring repository: " + url, e); //$NON-NLS-1$
+ } catch (BackingStoreException e) {
+ log("Error restoring repositories from preferences", e); //$NON-NLS-1$
+ }
+ }
+ // now that we have loaded everything, remember them
+ saveRepositoryList();
+ }
+
+ private void restoreRepositories() {
+ repositories = new ArrayList();
+ // TODO while recreating, we may want to have proxies on repo instead of the real repo object to limit what is activated.
+ AgentLocation location = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName());
+ if (location == null)
+ // TODO should do something here since we are failing to restore.
+ return;
+ SimpleArtifactRepository cache = (SimpleArtifactRepository) createRepository(location.getArtifactRepositoryURL(), "download cache", "org.eclipse.equinox.prov.artifact.repository.simpleRepository"); //$NON-NLS-1$ //$NON-NLS-2$
+ cache.tagAsImplementation();
+
+ String locationString = Activator.getContext().getProperty("eclipse.prov.artifactRepository"); //$NON-NLS-1$
+ if (locationString != null) {
+ StringTokenizer tokenizer = new StringTokenizer(locationString, ","); //$NON-NLS-1$
+ while (tokenizer.hasMoreTokens()) {
+ try {
+ loadRepository(new URL(tokenizer.nextToken()), (IProgressMonitor) null);
+ } catch (MalformedURLException e) {
+ log("Error while restoring repository " + locationString, e); //$NON-NLS-1$
+ }
+ }
+ }
+ // restore the persisted list of repositories
+ restoreFromPreferences();
+ }
+
+ /*
+ * Save the list of repositories to the file-system.
+ */
+ private void saveRepositoryList() {
+ try {
+ getPreferences().flush();
+ } catch (BackingStoreException e) {
+ log("Error while saving repositories in preferences", e); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRequest.java
new file mode 100644
index 000000000..e13519131
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ArtifactRequest.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.prov.artifact.repository.*;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+/**
+ * Base class for all requests on an {@link IArtifactRepository}.
+ */
+public abstract class ArtifactRequest implements IArtifactRequest {
+ protected IArtifactKey artifact;
+ protected String resolvedKey;
+ protected IArtifactRepository source;
+ protected IStatus result;
+ protected IArtifactDescriptor descriptor;
+
+ public ArtifactRequest(IArtifactKey key) {
+ artifact = key;
+ // TODO do we need to make this configurable? for now set default request handler to ECF
+ }
+
+ public IArtifactKey getArtifactKey() {
+ return artifact;
+ }
+
+ public IArtifactDescriptor getArtifactDescriptor() {
+ return descriptor;
+ }
+
+ /**
+ * Returns the result of the previous call to {@link #perform(IProgressMonitor)},
+ * or <code>null</code> if perform has never been called.
+ *
+ * @return The result of the previous perform call.
+ */
+ public IStatus getResult() {
+ return result;
+ }
+
+ protected IArtifactRepository getSourceRepository() {
+ return source;
+ }
+
+ /**
+ * Performs the artifact request, and sets the result status.
+ *
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting is not desired
+ */
+ abstract public void perform(IProgressMonitor monitor);
+
+ /**
+ * Sets the descriptor to use when processing this request.
+ *
+ * @param value The descriptor to use when processing this request
+ */
+ public void setDescriptor(IArtifactDescriptor value) {
+ if (!value.getArtifactKey().equals(artifact))
+ throw new IllegalArgumentException("Descriptor's key must match the request's key"); //$NON-NLS-1$
+ descriptor = value;
+ if (artifact == null)
+ artifact = value.getArtifactKey();
+ }
+
+ /**
+ * Sets the result of an invocation of {@link #perform(IProgressMonitor)}.
+ * This method is called by subclasses to set the result status for
+ * this request.
+ *
+ * @param value The result status
+ */
+ protected void setResult(IStatus value) {
+ result = value;
+ }
+
+ public void setSourceRepository(IArtifactRepository value) {
+ source = value;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ECFTransport.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ECFTransport.java
new file mode 100644
index 000000000..f5c9f7674
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/ECFTransport.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation Stefan Liebig -
+ * random tweaks
+ ******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.eclipse.core.runtime.*;
+import org.eclipse.ecf.filetransfer.*;
+import org.eclipse.ecf.filetransfer.events.*;
+import org.eclipse.ecf.filetransfer.identity.FileCreateException;
+import org.eclipse.ecf.filetransfer.identity.FileIDFactory;
+import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory;
+import org.eclipse.equinox.prov.artifact.repository.Transport;
+import org.eclipse.equinox.prov.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.prov.core.helpers.LogHelper;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A request handler that implements file transfer using ECF API.
+ */
+public class ECFTransport extends Transport {
+
+ /**
+ * The singleton handler instance.
+ */
+ private static ECFTransport instance;
+
+ private final ServiceTracker retrievalFactoryTracker;
+
+ /**
+ * Returns an initialized instance of ECFHandler
+ */
+ public static synchronized ECFTransport getInstance() {
+ if (instance == null) {
+ instance = new ECFTransport();
+ }
+ return instance;
+ }
+
+ /**
+ * Private to avoid client instantiation.
+ */
+ private ECFTransport() {
+ retrievalFactoryTracker = new ServiceTracker(Activator.getContext(), IRetrieveFileTransferFactory.class.getName(), null);
+ retrievalFactoryTracker.open();
+ }
+
+ protected IStatus convertToStatus(Exception failure) {
+ if (failure == null)
+ return Status.OK_STATUS;
+ if (failure instanceof UserCancelledException)
+ return new Status(IStatus.CANCEL, Activator.ID, failure.getMessage(), failure);
+ return new Status(IStatus.ERROR, Activator.ID, "error during transfer", failure);
+ }
+
+ public IStatus download(String toDownload, OutputStream target, IProgressMonitor monitor) {
+ IRetrieveFileTransferFactory factory = (IRetrieveFileTransferFactory) retrievalFactoryTracker.getService();
+ if (factory == null)
+ return new Status(IStatus.ERROR, Activator.ID, "ECF Transfer manager not available");
+ return transfer(factory.newInstance(), toDownload, target, monitor);
+ }
+
+ private IStatus transfer(final IRetrieveFileTransferContainerAdapter retrievalContainer, final String toDownload, final OutputStream target, final IProgressMonitor monitor) {
+ final IStatus[] result = new IStatus[1];
+ IFileTransferListener listener = new IFileTransferListener() {
+ public void handleTransferEvent(IFileTransferEvent event) {
+ if (event instanceof IIncomingFileTransferReceiveStartEvent) {
+ IIncomingFileTransferReceiveStartEvent rse = (IIncomingFileTransferReceiveStartEvent) event;
+ try {
+ if (target != null) {
+ rse.receive(target);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (event instanceof IIncomingFileTransferReceiveDataEvent) {
+ IIncomingFileTransfer source = ((IIncomingFileTransferReceiveDataEvent) event).getSource();
+ monitor.subTask("Transferring " + source.getID().getName() + " (" + (int) (source.getPercentComplete() * 100) + "% complete)");
+ if (monitor.isCanceled())
+ source.cancel();
+ }
+ if (event instanceof IIncomingFileTransferReceiveDoneEvent) {
+ IStatus status = convertToStatus(((IIncomingFileTransferReceiveDoneEvent) event).getException());
+ synchronized (result) {
+ result[0] = status;;
+ result.notify();
+ }
+ }
+ }
+ };
+
+ try {
+ retrievalContainer.sendRetrieveRequest(FileIDFactory.getDefault().createFileID(retrievalContainer.getRetrieveNamespace(), toDownload), listener, null);
+ } catch (IncomingFileTransferException e) {
+ return new Status(IStatus.ERROR, Activator.ID, "error during transfer", e);
+ } catch (FileCreateException e) {
+ return new Status(IStatus.ERROR, Activator.ID, "error during transfer - could not create file", e);
+ }
+ synchronized (result) {
+ while (result[0] == null) {
+ boolean logged = false;
+ try {
+ result.wait();
+ } catch (InterruptedException e) {
+ if (!logged)
+ LogHelper.log(new Status(IStatus.WARNING, Activator.ID, "Unexpected interrupt while waiting on ECF transfer", e)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ if (!(target instanceof ProcessingStep))
+ return result[0];
+ IStatus stepStatus = ((ProcessingStep) target).getStatus(true);
+ IStatus[] combinedList = new IStatus[stepStatus.getChildren().length + 1];
+ combinedList[0] = result[0];
+ System.arraycopy(stepStatus.getChildren(), 0, combinedList, 1, stepStatus.getChildren().length);
+ int code = result[0].getCode() > stepStatus.getCode() ? result[0].getCode() : stepStatus.getCode();
+ return new MultiStatus(Activator.ID, code, combinedList, "Problems occurred while downloading " + toDownload, null);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/FileDownloadRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/FileDownloadRequest.java
new file mode 100644
index 000000000..104d95879
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/FileDownloadRequest.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import java.io.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+public class FileDownloadRequest extends ArtifactRequest {
+ public static FileDownloadRequest[] NO_REQUEST = new FileDownloadRequest[0];
+
+ private File destination; //The fully qualified path where the file should be written
+
+ public FileDownloadRequest(IArtifactKey downloadKey, IPath downloadPath) {
+ super(downloadKey);
+ destination = destination;
+ }
+
+ public void perform(IProgressMonitor monitor) {
+ try {
+ OutputStream destinationStream = null;
+ try {
+ destinationStream = new BufferedOutputStream(new FileOutputStream(destination));
+ setResult(source.getArtifact(descriptor, destinationStream, null));
+ } finally {
+ if (destinationStream != null)
+ destinationStream.close();
+ }
+ } catch (IOException e) {
+ setResult(new Status(IStatus.ERROR, Activator.ID, "Error downloading " + descriptor + " to " + destination, e));
+ };
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/MirrorRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/MirrorRequest.java
new file mode 100644
index 000000000..af383462b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/MirrorRequest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.prov.artifact.repository.IArtifactDescriptor;
+import org.eclipse.equinox.prov.artifact.repository.IWritableArtifactRepository;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+public class MirrorRequest extends ArtifactRequest {
+ private IWritableArtifactRepository target;
+
+ public MirrorRequest(IArtifactKey key, IWritableArtifactRepository targetRepository) {
+ super(key);
+ target = targetRepository;
+ }
+
+ public void perform(IProgressMonitor monitor) {
+ monitor.subTask("Downloading " + getArtifactKey().getId());
+ // Do we already have the artifact in the target?
+ if (target.contains(getArtifactKey())) {
+ setResult(new Status(IStatus.OK, Activator.ID, "The artifact is already available in the repo."));
+ return;
+ }
+
+ // if the request does not have a descriptor then try to fill one in by getting
+ // the list of all and randomly picking the first one.
+ if (descriptor == null) {
+ IArtifactDescriptor[] descriptors = source.getArtifactDescriptors(getArtifactKey());
+ if (descriptors.length > 0)
+ descriptor = descriptors[0];
+ }
+
+ // if the descriptor is not set now then the repo does not have the requested artifact
+ if (descriptor == null) {
+ setResult(new Status(IStatus.ERROR, Activator.ID, "Artifact requested can't be found:" + getArtifactKey()));
+ return;
+ }
+
+ // Get the output stream to store the artifact
+ OutputStream destination = target.getOutputStream(getArtifactDescriptor());
+ if (destination == null) {
+ setResult(new Status(IStatus.ERROR, Activator.ID, "Can't get an output stream to " + target + " to store " + getArtifactKey()));
+ return;
+ }
+
+ // Do the actual transfer
+ try {
+ setResult(source.getArtifact(descriptor, destination, monitor));
+ return;
+ } finally {
+ try {
+ destination.close();
+ } catch (IOException e) {
+ setResult(new Status(IStatus.ERROR, Activator.ID, "Error closing the output stream for " + getArtifactKey() + "on repo " + target.getLocation(), e));
+ }
+ }
+ }
+
+ public String toString() {
+ return "Mirrroring: " + getArtifactKey() + " into " + target;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SignatureVerifier.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SignatureVerifier.java
new file mode 100644
index 000000000..113f388fa
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SignatureVerifier.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright (c) 2007 compeople AG and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* compeople AG (Stefan Liebig) - initial API and implementation
+* IBM - continuing development
+*******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import java.io.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.prov.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.prov.core.helpers.FileUtils;
+import org.eclipse.equinox.prov.core.helpers.ServiceHelper;
+import org.eclipse.osgi.internal.provisional.verifier.CertificateVerifier;
+import org.eclipse.osgi.internal.provisional.verifier.CertificateVerifierFactory;
+
+/**
+ * The Pack200Unpacker expects an input containing ".jar.pack.gz" data.
+ */
+public class SignatureVerifier extends ProcessingStep {
+ private File inputFile;
+ private OutputStream tempStream;
+
+ public boolean areRequirementsSatisfied() {
+ return true;
+ }
+
+ public void write(int b) throws IOException {
+ getOutputStream().write(b);
+ }
+
+ private OutputStream getOutputStream() throws IOException {
+ if (tempStream != null)
+ return tempStream;
+ // store input stream in temporary file
+ inputFile = File.createTempFile("signatureFile", ".jar");
+ tempStream = new BufferedOutputStream(new FileOutputStream(inputFile));
+ return tempStream;
+ }
+
+ private void verify() throws IOException {
+ BufferedInputStream resultStream = null;
+ try {
+ if (tempStream == null)
+ // hmmm, no one wrote to this stream so there is nothing to pass on
+ return;
+ // Ok, so there is content, close the tempStream
+ tempStream.close();
+
+ CertificateVerifierFactory verifierFactory = (CertificateVerifierFactory) ServiceHelper.getService(Activator.getContext(), CertificateVerifierFactory.class.getName());
+ CertificateVerifier verifier = verifierFactory.getVerifier(inputFile);
+ if (verifier.verifyContent().length > 0)
+ status = new Status(IStatus.ERROR, "plugin id", "signature verification failure");
+ else
+ status = Status.OK_STATUS;
+ // now write the content to the final destination
+ resultStream = new BufferedInputStream(new FileInputStream(inputFile));
+ FileUtils.copyStream(resultStream, true, destination, false);
+ resultStream = null;
+ } finally {
+ if (inputFile != null)
+ inputFile.delete();
+ if (resultStream != null)
+ resultStream.close();
+ }
+ }
+
+ public void close() throws IOException {
+ // When we go to close we must have seen all the content we are going to see
+ // So before closing, verify and write the result to the destination
+ verify();
+ super.close();
+ }
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SimpleArtifactRepository.java
new file mode 100644
index 000000000..556d8d969
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SimpleArtifactRepository.java
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.prov.artifact.repository.*;
+import org.eclipse.equinox.prov.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.prov.artifact.repository.processing.ProcessingStepHandler;
+import org.eclipse.equinox.prov.core.helpers.MultiStatus;
+import org.eclipse.equinox.prov.core.repository.AbstractRepository;
+import org.eclipse.equinox.prov.core.repository.IRepositoryInfo;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+public class SimpleArtifactRepository extends AbstractRepository implements IWritableArtifactRepository {
+
+ static final private String CONTENT_FILENAME = "artifacts.xml"; //$NON-NLS-1$
+ static final private String REPOSITORY_TYPE = SimpleArtifactRepository.class.getName();
+ static final private Integer REPOSITORY_VERSION = new Integer(1);
+ static final public String[][] DEFAULT_MAPPING_RULES = { {"(& (namespace=eclipse) (classifier=plugin))", "${repoUrl}/plugins/${id}_${version}.jar"}, //$NON-NLS-1$//$NON-NLS-2$
+ {"(& (namespace=eclipse) (classifier=native))", "${repoUrl}/native/${id}_${version}"}, //$NON-NLS-1$ //$NON-NLS-2$
+ {"(& (namespace=eclipse) (classifier=feature))", "${repoUrl}/features/${id}_${version}.jar"}}; //$NON-NLS-1$//$NON-NLS-2$
+
+ transient private Mapper mapper = new Mapper();
+ protected String[][] mappingRules = DEFAULT_MAPPING_RULES;
+ protected Set artifactDescriptors = new HashSet();
+ private boolean signatureVerification = false;
+
+ public static URL getActualLocation(URL base) {
+ String spec = base.toExternalForm();
+ if (spec.endsWith(CONTENT_FILENAME))
+ return base;
+ if (spec.endsWith("/")) //$NON-NLS-1$
+ spec += CONTENT_FILENAME;
+ else
+ spec += "/" + CONTENT_FILENAME; //$NON-NLS-1$
+ try {
+ return new URL(spec);
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ }
+
+ public SimpleArtifactRepository(String repositoryName, URL location) {
+ super(repositoryName, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location);
+ mapper.initialize(Activator.getContext(), mappingRules);
+ }
+
+ private IStatus getArtifact(ArtifactRequest request, IProgressMonitor monitor) {
+ request.setSourceRepository(this);
+ request.perform(monitor);
+ return request.getResult();
+ }
+
+ public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
+ SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length);
+ try {
+ MultiStatus overallStatus = new MultiStatus();
+ for (int i = 0; i < requests.length; i++) {
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
+ overallStatus.add(getArtifact((ArtifactRequest) requests[i], subMonitor.newChild(1)));
+ }
+ return (monitor.isCanceled() ? Status.CANCEL_STATUS : overallStatus);
+ } finally {
+ subMonitor.done();
+ }
+ }
+
+ private String basicGetArtifactLocation(IArtifactDescriptor descriptor) {
+ return computeLocation(descriptor.getArtifactKey());
+ }
+
+ private String basicGetArtifactLocation(IArtifactKey key) {
+ boolean found = false;
+ for (Iterator iterator = artifactDescriptors.iterator(); iterator.hasNext();) {
+ IArtifactDescriptor desc = (IArtifactDescriptor) iterator.next();
+ if (desc.getArtifactKey().equals(key)) { //TODO This should probably be a lookup in the set
+ found = true;
+ break;
+ }
+ }
+ return (found ? computeLocation(key) : null);
+ }
+
+ String computeLocation(IArtifactKey key) {
+ return mapper.map(location.toExternalForm(), key.getNamespace(), key.getClassifier(), key.getId(), key.getVersion().toString());
+ }
+
+ public IArtifactKey[] getArtifactKeys() {
+ // there may be more descriptors than keys to collect up the unique keys
+ HashSet result = new HashSet(artifactDescriptors.size());
+ for (Iterator it = artifactDescriptors.iterator(); it.hasNext();)
+ result.add(((IArtifactDescriptor) it.next()).getArtifactKey());
+ return (IArtifactKey[]) result.toArray(new IArtifactKey[result.size()]);
+ }
+
+ public URI getArtifact(IArtifactKey key) {
+ String result = basicGetArtifactLocation(key);
+ return (result != null ? URI.create(result) : null);
+ // if (location == null)
+ // return null;
+ // try {
+ // URL url = new URL(location);
+ // return new URI(url.getProtocol(), url.getHost(), url.getPath(), url.getQuery());
+ // } catch (MalformedURLException e) {
+ // throw new IllegalArgumentException(e);
+ // } catch (URISyntaxException e) {
+ // throw new IllegalArgumentException(e);
+ // }
+ }
+
+ public String toString() {
+ return location.toExternalForm();
+ }
+
+ public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
+ ProcessingStepHandler handler = new ProcessingStepHandler();
+ try {
+ destination = addPostSteps(handler, descriptor, destination, monitor);
+ destination = handler.createAndLink(descriptor.getProcessingSteps(), descriptor, destination, monitor);
+ destination = addPreSteps(handler, descriptor, destination, monitor);
+ IStatus status = handler.validateSteps(destination);
+ if (status.getCode() == IStatus.OK || status.getCode() == IStatus.INFO)
+ return getTransport().download(basicGetArtifactLocation(descriptor), destination, monitor);
+ return status;
+ } finally {
+ try {
+ //don't close the underlying output stream - the caller will do that
+ if (destination instanceof ProcessingStep)
+ destination.close();
+ } catch (IOException e) {
+ return new Status(IStatus.ERROR, Activator.ID, "Error closing processing steps", e);
+ }
+ }
+ }
+
+ private OutputStream addPostSteps(ProcessingStepHandler handler, IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
+ ArrayList steps = new ArrayList();
+ if (signatureVerification)
+ steps.add(new SignatureVerifier());
+ // if (md5Verification)
+ // steps.add(new MD5Verifier(descriptor.getProperty(IArtifactDescriptor.ARTIFACT_MD5)));
+ if (steps.isEmpty())
+ return destination;
+ ProcessingStep[] stepArray = (ProcessingStep[]) steps.toArray(new ProcessingStep[steps.size()]);
+ // TODO should probably be using createAndLink here
+ return handler.link(stepArray, destination, monitor);
+ }
+
+ private OutputStream addPreSteps(ProcessingStepHandler handler, IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
+ ArrayList steps = new ArrayList();
+ // Add steps here if needed
+ if (steps.isEmpty())
+ return destination;
+ ProcessingStep[] stepArray = (ProcessingStep[]) steps.toArray(new ProcessingStep[steps.size()]);
+ // TODO should probably be using createAndLink here
+ return handler.link(stepArray, destination, monitor);
+ }
+
+ private Transport getTransport() {
+ return ECFTransport.getInstance();
+ }
+
+ public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
+ ArrayList result = new ArrayList();
+ for (Iterator iterator = artifactDescriptors.iterator(); iterator.hasNext();) {
+ IArtifactDescriptor descriptor = (IArtifactDescriptor) iterator.next();
+ if (descriptor.getArtifactKey().equals(key))
+ result.add(descriptor);
+ }
+ return (IArtifactDescriptor[]) result.toArray(new IArtifactDescriptor[result.size()]);
+ }
+
+ private class ArtifactOutputStream extends OutputStream {
+ private OutputStream destination;
+ private IArtifactDescriptor descriptor;
+ private long count = 0;
+
+ public ArtifactOutputStream(OutputStream os, IArtifactDescriptor descriptor) {
+ this.destination = os;
+ this.descriptor = descriptor;
+ }
+
+ public void write(int b) throws IOException {
+ destination.write(b);
+ count++;
+ }
+
+ public void write(byte[] b) throws IOException {
+ destination.write(b);
+ count += b.length;
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ destination.write(b, off, len);
+ count += len;
+ }
+
+ public void close() throws IOException {
+ // Write the artifact descriptor
+ destination.close();
+ ((ArtifactDescriptor) descriptor).setProperty(IArtifactDescriptor.DOWNLOAD_SIZE, Long.toString(count));
+ addDescriptor(descriptor);
+ }
+ }
+
+ public void addDescriptor(IArtifactDescriptor toAdd) {
+ // TODO: here we may want to ensure that the artifact has not been added concurrently
+ artifactDescriptors.add(toAdd);
+ save();
+ }
+
+ public void save() {
+ try {
+ FileOutputStream os = new FileOutputStream(getActualLocation(location).getFile());
+ ArtifactRepositoryIO.write(this, os);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public OutputStream getOutputStream(IArtifactDescriptor descriptor) {
+ // TODO we need a better way of distinguishing between errors and cases where
+ // the stuff just already exists
+ // Check if the artifact is already in this repository
+ if (contains(descriptor))
+ return null;
+
+ // Determine writing location
+ String location = computeLocation(descriptor.getArtifactKey());
+ if (location == null)
+ // TODO: Log an error, or throw an exception?
+ return null;
+
+ String file = null;
+ try {
+ file = new URL(location).getFile();
+ } catch (MalformedURLException e1) {
+ // This should not happen
+ }
+
+ File outputFile = new File(file);
+ if (outputFile.exists())
+ System.err.println("Artifact repository out of synch. Overwriting " + outputFile.getAbsoluteFile());
+
+ if (!outputFile.getParentFile().exists() && !outputFile.getParentFile().mkdirs())
+ // TODO: Log an error, or throw an exception?
+ return null;
+
+ try {
+ return new ArtifactOutputStream(new BufferedOutputStream(new FileOutputStream(file)), descriptor);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public boolean contains(IArtifactDescriptor descriptor) {
+ return artifactDescriptors.contains(descriptor);
+ }
+
+ public boolean contains(IArtifactKey key) {
+ for (Iterator iterator = artifactDescriptors.iterator(); iterator.hasNext();) {
+ IArtifactDescriptor descriptor = (IArtifactDescriptor) iterator.next();
+ if (descriptor.getArtifactKey().equals(key))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return the set of descriptors in this repository.
+ * <b>NOTE:</b> this is NOT part of the API
+ * @return the set of descriptors
+ */
+ public Set getDescriptors() {
+ return artifactDescriptors;
+ }
+
+ public String[][] getRules() {
+ return mappingRules;
+ }
+
+ public void setRules(String[][] rules) {
+ mappingRules = rules;
+ }
+
+ public void tagAsImplementation() {
+ properties.setProperty(IRepositoryInfo.IMPLEMENTATION_ONLY_KEY, Boolean.valueOf(true).toString());
+ }
+
+ public void removeAll() {
+ artifactDescriptors.clear();
+ save();
+ }
+
+ public void removeDescriptor(IArtifactDescriptor descriptor) {
+ artifactDescriptors.remove(descriptor);
+ save();
+ }
+
+ public void removeDescriptor(IArtifactKey key) {
+ ArrayList toRemove = new ArrayList();
+ for (Iterator iterator = artifactDescriptors.iterator(); iterator.hasNext();) {
+ IArtifactDescriptor descriptor = (IArtifactDescriptor) iterator.next();
+ if (descriptor.getArtifactKey().equals(key))
+ toRemove.add(descriptor);
+ }
+ artifactDescriptors.removeAll(toRemove);
+ save();
+ }
+
+ // use this method to setup any transient fields etc after the object has been restored from a stream
+ public void initializeAfterLoad(URL location) {
+ this.location = location;
+ if (mapper == null)
+ mapper = new Mapper();
+ mapper.initialize(Activator.getContext(), mappingRules);
+ }
+
+ public void setSignatureVerification(boolean value) {
+ signatureVerification = value;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SimpleArtifactRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SimpleArtifactRepositoryFactory.java
new file mode 100644
index 000000000..d7295b329
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/SimpleArtifactRepositoryFactory.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import java.io.*;
+import java.net.URL;
+import org.eclipse.equinox.prov.artifact.repository.IArtifactRepository;
+import org.eclipse.equinox.prov.artifact.repository.IArtifactRepositoryFactory;
+import org.eclipse.equinox.prov.core.repository.RepositoryCreationException;
+
+public class SimpleArtifactRepositoryFactory implements IArtifactRepositoryFactory {
+
+ public IArtifactRepository load(URL location) {
+ if (location == null)
+ return null;
+ try {
+ InputStream descriptorStream = null;
+ try {
+ descriptorStream = new BufferedInputStream(SimpleArtifactRepository.getActualLocation(location).openStream());
+ SimpleArtifactRepository result = (SimpleArtifactRepository) ArtifactRepositoryIO.read(descriptorStream);
+ result.initializeAfterLoad(location);
+ return result;
+ } catch (RepositoryCreationException e) {
+ // TODO Auto-generated catch block
+ return null;
+ } finally {
+ if (descriptorStream != null)
+ descriptorStream.close();
+ }
+ } catch (IOException e) {
+ }
+ return null;
+ }
+
+ public IArtifactRepository create(URL location, String name, String type) {
+ return new SimpleArtifactRepository(name, location);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/Unpack200Step.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/Unpack200Step.java
new file mode 100644
index 000000000..0750ef994
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/prov/artifact/repository/Unpack200Step.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+* Copyright (c) 2007 compeople AG and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* compeople AG (Stefan Liebig) - initial API and implementation
+* IBM - continuing development
+*******************************************************************************/
+package org.eclipse.equinox.internal.prov.artifact.repository;
+
+import java.io.*;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.jarprocessor.UnpackStep;
+import org.eclipse.equinox.internal.p2.jarprocessor.Utils;
+import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor;
+import org.eclipse.equinox.p2.jarprocessor.JarProcessorExecutor.Options;
+import org.eclipse.equinox.prov.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.prov.core.helpers.FileUtils;
+
+/**
+ * The Pack200Unpacker expects an input containing ".jar.pack.gz" data.
+ */
+public class Unpack200Step extends ProcessingStep {
+ private final static String PACKED_EXT = Utils.JAR_SUFFIX + Utils.PACKED_SUFFIX;
+
+ private File packed;
+ private OutputStream tempStream;
+
+ public boolean areRequirementsSatisfied() {
+ return UnpackStep.canUnpack();
+ }
+
+ public void write(int b) throws IOException {
+ OutputStream stream = getOutputStream();
+ stream.write(b);
+ }
+
+ private OutputStream getOutputStream() throws IOException {
+ if (tempStream != null)
+ return tempStream;
+ // store input stream in temporary file
+ packed = File.createTempFile("pack200", PACKED_EXT);
+ tempStream = new BufferedOutputStream(new FileOutputStream(packed));
+ return tempStream;
+ }
+
+ private void performUnpack() throws IOException {
+ BufferedInputStream unpackedStream = null;
+ File unpacked = null;
+ File workDir = null;
+ try {
+ if (tempStream == null)
+ // hmmm, no one wrote to this stream so there is nothing to pass on
+ return;
+ // Ok, so there is content, close the tempStream
+ tempStream.close();
+ // now create a temporary directory for the JarProcessor to work in
+ // TODO How to create a unique, temporary directory atomically?
+ workDir = File.createTempFile("work", "");
+ if (!workDir.delete())
+ throw new IOException("Could not delete file for creating temporary working dir.");
+ if (!workDir.mkdirs())
+ throw new IOException("Could not create temporary working dir.");
+
+ // unpack
+ Options options = new Options();
+ options.unpack = true;
+ options.processAll = true;
+ options.input = packed;
+ options.outputDir = workDir.getPath();
+ new JarProcessorExecutor().runJarProcessor(options);
+
+ // now write the unpacked content to our destination
+ String packedFileName = packed.getName();
+ unpacked = new File(workDir, packedFileName.substring(0, packedFileName.length() - Utils.PACKED_SUFFIX.length()));
+ unpackedStream = new BufferedInputStream(new FileInputStream(unpacked));
+ FileUtils.copyStream(unpackedStream, true, destination, false);
+ unpackedStream = null;
+ } finally {
+ if (packed != null)
+ packed.delete();
+ if (unpackedStream != null)
+ unpackedStream.close();
+ if (unpacked != null)
+ unpacked.delete();
+ if (workDir != null)
+ workDir.delete();
+ }
+ }
+
+ public void close() throws IOException {
+ // When we go to close we must have seen all the content we are going to see
+ // So before closing, run unpack and write the unpacked result to the destination
+ performUnpack();
+ super.close();
+ if (status == null)
+ status = Status.OK_STATUS;
+ }
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/ArtifactDescriptor.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/ArtifactDescriptor.java
new file mode 100644
index 000000000..e33e07269
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/ArtifactDescriptor.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import java.util.*;
+import org.eclipse.equinox.prov.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+/**
+ * This represents information about a given artifact stored on a particular byte server.
+ */
+public class ArtifactDescriptor implements IArtifactDescriptor {
+ private static int hashCode(Object[] array) {
+ int prime = 31;
+ if (array == null)
+ return 0;
+ int result = 1;
+ for (int index = 0; index < array.length; index++) {
+ result = prime * result + (array[index] == null ? 0 : array[index].hashCode());
+ }
+ return result;
+ }
+
+ protected IArtifactKey key; // The key associated with this artifact
+
+ // The list of post processing steps that must be applied one the artifact once it
+ // has been downloaded (e.g, unpack, then md5 checksum, then...)
+ protected ProcessingStepDescriptor[] processingSteps = null;
+
+ protected Map properties = new HashMap(2);
+
+ //QUESTION: Do we need any description or user readable name
+
+ public ArtifactDescriptor(IArtifactKey key) {
+ super();
+ this.key = key;
+ }
+
+ public IArtifactKey getArtifactKey() {
+ return key;
+ }
+
+ public String getProperty(String key) {
+ return (String) properties.get(key);
+ }
+
+ public void setProperty(String key, String value) {
+ properties.put(key, value);
+ }
+
+ public ProcessingStepDescriptor[] getProcessingSteps() {
+ return processingSteps;
+ }
+
+ public void setProcessingSteps(ProcessingStepDescriptor[] value) {
+ processingSteps = value;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ArtifactDescriptor other = (ArtifactDescriptor) obj;
+ if (key == null) {
+ if (other.key != null)
+ return false;
+ } else if (!key.equals(other.key))
+ return false;
+ if (!Arrays.equals(processingSteps, other.processingSteps))
+ return false;
+ if (properties == null) {
+ if (other.properties != null)
+ return false;
+ } else if (!properties.equals(other.properties))
+ return false;
+ return true;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ result = prime * result + ArtifactDescriptor.hashCode(processingSteps);
+ result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+ return result;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactDescriptor.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactDescriptor.java
new file mode 100644
index 000000000..0cc89ef71
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactDescriptor.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import org.eclipse.equinox.prov.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+public interface IArtifactDescriptor {
+
+ public static final String DOWNLOAD_SIZE = "download.size"; //$NON-NLS-1$
+ public static final String ARTIFACT_SIZE = "artifact.size"; //$NON-NLS-1$
+ public static final String DOWNLOAD_MD5 = "download.md5"; //$NON-NLS-1$
+ public static final String ARTIFACT_MD5 = "artifact.md5"; //$NON-NLS-1$
+
+ public abstract IArtifactKey getArtifactKey();
+
+ public abstract String getProperty(String key);
+
+ public abstract ProcessingStepDescriptor[] getProcessingSteps();
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepository.java
new file mode 100644
index 000000000..daf900aa1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepository.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import java.io.OutputStream;
+import java.net.URI;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.prov.core.repository.IRepositoryInfo;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+/**
+ * TODO: Convert to abstract class
+ */
+public interface IArtifactRepository extends IRepositoryInfo {
+ /**
+ * Returns true if this repository contains the given descriptor.
+ * @param descriptor the descriptor to query
+ * @return true if the given descriptor is already in this repository
+ */
+ public boolean contains(IArtifactDescriptor descriptor);
+
+ /**
+ * Returns true if this repository contains the given artifact key.
+ * @param key the key to query
+ * @return true if the given key is already in this repository
+ */
+ public boolean contains(IArtifactKey key);
+
+ /**
+ * Executes the given artifact requests on this byte server.
+ * @param requests The artifact requests
+ * @param monitor
+ * @return a status object that is <code>OK</code> if requests were
+ * processed successfully. Otherwise, a status indicating information,
+ * warnings, or errors that occurred while executing the artifact requests
+ */
+ public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor);
+
+ /**
+ * Return the set of artifact descriptors describing the ways that this repository
+ * can supply the artifact associated with the given artifact key
+ * @param key the artifact key to lookup
+ * @return the descriptors associated with the given key
+ */
+ public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key);
+
+ /**
+ * Return a stream containing the described artifact, or null if not available
+ */
+ public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor);
+
+ /**
+ * Returns the list of artifact keys managed by this repository
+ * @return list of artifact keys
+ */
+ public IArtifactKey[] getArtifactKeys();
+
+ // TODO move this to a local repo interface and change to return a file
+ /**
+ * Return a URI to the given key, or null if not available
+ */
+ public URI getArtifact(IArtifactKey key);
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepositoryFactory.java
new file mode 100644
index 000000000..b3d9dca07
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepositoryFactory.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import java.net.URL;
+
+public interface IArtifactRepositoryFactory {
+
+ public IArtifactRepository load(URL location);
+
+ public IArtifactRepository create(URL location, String name, String type);
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepositoryManager.java
new file mode 100644
index 000000000..ace98461d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRepositoryManager.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import java.net.URL;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+public interface IArtifactRepositoryManager {
+ public static final IArtifactRequest[] NO_ARTIFACT_REQUEST = new IArtifactRequest[0];
+
+ /**
+ * Return the list of artifact repositories known by this manager.
+ * @return the list of known repositories
+ */
+ public IArtifactRepository[] getKnownRepositories();
+
+ /**
+ * Add a repository at the given location. The location is expected to contain
+ * data that describes a valid artifact repository of a known type. If this manager
+ * already knows a repository at the given location then that repository is returned.
+ * @param location the location in which to look for a repository description
+ * @monitor
+ * @return a repository object for the given location or <code>null</code> if a repository
+ * could not be found or loaded.
+ */
+ public IArtifactRepository loadRepository(URL location, IProgressMonitor monitor);
+
+ /**
+ * Add the given repository to the set of repositories managed by this manager.
+ * @param repository the repository to add
+ */
+ public void addRepository(IArtifactRepository repository);
+
+ /**
+ * Return the artifact repository at the given location if known by this manager.
+ * Otherwise return <code>null</code>
+ * @param location the location of the repository to return
+ * @return the found repository
+ */
+ public IArtifactRepository getRepository(URL location);
+
+ /**
+ * Remove the given repository from this manager. Do nothing if the repository
+ * is not currently managed.
+ * @param toRemove the repository to remove
+ */
+ public void removeRepository(IArtifactRepository toRemove);
+
+ /**
+ * Creates and returns an artifact repository of the given type at the given location.
+ * If a repository already exists at that location <code>null</code> is returned.
+ * @param location the location for the new repository
+ * @param name the name of the new repo
+ * @param type the kind of repository to create
+ * @return the discovered or created repository
+ */
+ public IArtifactRepository createRepository(URL location, String name, String type);
+
+ /**
+ * Return a new request to download the given artifact and store it at the given destination.
+ * @param key the artifact to download
+ * @param destination the destination where the artifact will be stored
+ * @return the newly created request object
+ */
+ public IArtifactRequest createDownloadRequest(IArtifactKey key, IPath destination);
+
+ /**
+ * Return a new request to mirror the given artifact into the destination repository.
+ * @param key the artifact to mirror
+ * @param destination the destination where the artifact will be mirrored
+ * @return the newly created request object
+ */
+ public IArtifactRequest createMirrorRequest(IArtifactKey key, IWritableArtifactRepository destination);
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRequest.java
new file mode 100644
index 000000000..2a86946b4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IArtifactRequest.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.prov.artifact.repository.ArtifactRequest;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+/**
+ * This interface is not intended to be implemented by clients
+ */
+public interface IArtifactRequest {
+
+ public IArtifactKey getArtifactKey();
+
+ /**
+ * Returns the result of the previous call to {@link ArtifactRequest#perform(IProgressMonitor)},
+ * or <code>null</code> if perform has never been called.
+ *
+ * @return The result of the previous perform call.
+ */
+ public IStatus getResult();
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IWritableArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IWritableArtifactRepository.java
new file mode 100644
index 000000000..227c68ec5
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/IWritableArtifactRepository.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import java.io.OutputStream;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+
+// TODO consider having the add and remove methods take several keys/descriptors
+// to operate on at one time.
+
+public interface IWritableArtifactRepository extends IArtifactRepository {
+
+ /**
+ * Open an output stream to which a client can write the data for the given
+ * artifact descriptor.
+ * @param descriptor the descriptor describing the artifact data to be written to the
+ * resultant stream
+ * @return the stream to which the artifact content can be written
+ */
+ public OutputStream getOutputStream(IArtifactDescriptor descriptor);
+
+ /**
+ * Add the given descriptor to the set of descriptors in this repository. This is
+ * a relatively low-level operation that should be used only when the actual related
+ * content is in this repository and the given descriptor accurately describes
+ * that content.
+ * @param descriptor the descriptor to add.
+ */
+ public void addDescriptor(IArtifactDescriptor descriptor);
+
+ /**
+ * Remove the given descriptor from the set of descriptors in this repository.
+ * @param descriptor the descriptor to remove.
+ */
+ public void removeDescriptor(IArtifactDescriptor descriptor);
+
+ /**
+ * Remove the given key and all related descriptors from this repository.
+ * @param key the key to remove.
+ */
+ public void removeDescriptor(IArtifactKey key);
+
+ /**
+ * Remove the all key and descriptor information from this repository.
+ */
+ public void removeAll();
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/Mapper.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/Mapper.java
new file mode 100644
index 000000000..b84bff2ed
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/Mapper.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import org.osgi.framework.*;
+
+public class Mapper {
+ private Filter[] filters;
+ private String[] outputStrings;
+
+ private static final String REPOURL = "repoUrl";
+ private static final String NAMESPACE = "namespace";
+ private static final String CLASSIFIER = "classifier";
+ private static final String ID = "id";
+ private static final String VERSION = "version";
+
+ public Mapper() {
+ filters = new Filter[0];
+ outputStrings = new String[0];
+ }
+
+ /**
+ * mapping rule: LDAP filter --> output value
+ * the more specific filters should be given first.
+ */
+ public void initialize(BundleContext ctx, String[][] mappingRules) {
+ filters = new Filter[mappingRules.length];
+ outputStrings = new String[mappingRules.length];
+ for (int i = 0; i < mappingRules.length; i++) {
+ try {
+ filters[i] = ctx.createFilter(mappingRules[i][0]);
+ outputStrings[i] = mappingRules[i][1];
+ } catch (InvalidSyntaxException e) {
+ //TODO Neeed to process this
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public String map(String repoUrl, String namespace, String classifier, String id, String version) {
+ Dictionary values = new Hashtable(5);
+ if (repoUrl != null)
+ values.put(REPOURL, repoUrl);
+
+ if (namespace != null)
+ values.put(NAMESPACE, namespace);
+
+ if (classifier != null)
+ values.put(CLASSIFIER, classifier);
+
+ if (id != null)
+ values.put(ID, id);
+
+ if (version != null)
+ values.put(VERSION, version);
+
+ for (int i = 0; i < filters.length; i++) {
+ if (filters[i].match(values))
+ return doReplacement(outputStrings[i], repoUrl, namespace, classifier, id, version);
+ }
+ return null;
+ }
+
+ private String doReplacement(String pattern, String repoUrl, String namespace, String classifier, String id, String version) {
+
+ // currently our mapping rules assume the repo URL is not "/" terminated.
+ // This may be the case for repoURLs in the root of a URL space e.g. root of a jar file or file:/c:/
+ if (repoUrl.endsWith("/"))
+ repoUrl = repoUrl.substring(0, repoUrl.length() - 1);
+
+ StringBuffer output = new StringBuffer(pattern);
+ int index = 0;
+ while (index < output.length()) {
+ int beginning = output.indexOf("${", index);
+ if (beginning == -1)
+ return output.toString();
+
+ int end = output.indexOf("}", beginning);
+ if (end == -1)
+ return pattern;
+
+ String varName = output.substring(beginning + 2, end);
+ String varValue = null;
+ if (varName.equalsIgnoreCase(NAMESPACE)) {
+ varValue = namespace;
+ } else if (varName.equalsIgnoreCase(CLASSIFIER)) {
+ varValue = classifier;
+ } else if (varName.equalsIgnoreCase(ID)) {
+ varValue = id;
+ } else if (varName.equalsIgnoreCase(VERSION)) {
+ varValue = version;
+ } else if (varName.equalsIgnoreCase(REPOURL)) {
+ varValue = repoUrl;
+ }
+ if (varValue == null)
+ varValue = "";
+
+ output.replace(beginning, end + 1, varValue);
+ index = beginning + varValue.length();
+ }
+ return output.toString();
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < filters.length; i++) {
+ result.append(filters[i]).append('-').append('>').append(outputStrings[i]).append('\n');
+ }
+ return result.toString();
+ }
+
+ public String[][] serialize() {
+ String[][] result = new String[filters.length][2];
+ for (int i = 0; i < filters.length; i++) {
+ result[i][0] = filters[i].toString();
+ result[i][1] = outputStrings[i].toString();
+ }
+ return result;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/RepositoryDescriptor.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/RepositoryDescriptor.java
new file mode 100644
index 000000000..cb8a0378a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/RepositoryDescriptor.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import java.net.URI;
+import org.eclipse.equinox.prov.metadata.IArtifactKey;
+import org.osgi.framework.Version;
+
+public abstract class RepositoryDescriptor {
+ /**
+ * Return the type of repository described.
+ * @return the type of repository
+ */
+ public abstract String getType();
+
+ /**
+ * Return the version of the repository
+ * @return the version of the repository
+ */
+ public abstract Version getVersion();
+
+ /**
+ * The set of transports that can be used to download artifacts from this repository
+ * @return an array of
+ */
+ public abstract String[] getTransports();
+
+ public abstract IArtifactDescriptor getArtifact(IArtifactKey key);
+
+ public abstract URI getBaseURL(); //the url to be used as a base for download
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/Transport.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/Transport.java
new file mode 100644
index 000000000..c8ff18afe
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/Transport.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository;
+
+import java.io.OutputStream;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+public abstract class Transport {
+ public abstract IStatus download(String toDownload, OutputStream target, IProgressMonitor pm);
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStep.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStep.java
new file mode 100644
index 000000000..f6338eeaf
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStep.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+* Copyright (c) 2007 compeople AG and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* compeople AG (Stefan Liebig) - initial API and implementation
+* IBM Corporation - continuing development
+*******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository.processing;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.prov.artifact.repository.Activator;
+import org.eclipse.equinox.prov.artifact.repository.IArtifactDescriptor;
+
+/**
+ * ProcessingSteps process the data written to them and pass the resultant data on
+ * to a configured destination stream. Steps may monitor (e.g., count) the data, compute information
+ * about the data (e.g., checksum or hash) or transform the data (e.g., unpack200).
+ */
+public abstract class ProcessingStep extends OutputStream {
+ protected OutputStream destination;
+ protected IProgressMonitor monitor;
+ protected IStatus status = Status.OK_STATUS;
+
+ protected ProcessingStep() {
+ super();
+ }
+
+ /**
+ * Initialize this processing step according to the information in the given
+ * descriptor and context. After initialization, this step is ready for linking
+ * with other steps or output streams
+ * @param descriptor description of the step
+ * @param context the context in which the step is being used
+ */
+ public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
+ }
+
+ /**
+ * Link this step with the given output stream and configure the step to use the given
+ * progress monitor. After linking the step is ready to have data written to it.
+ * @param destination the stream into which to write the processed data
+ * @param monitor the progress monitor to use for reporting activity
+ */
+ public void link(OutputStream destination, IProgressMonitor monitor) {
+ this.destination = destination;
+ this.monitor = monitor;
+ }
+
+ /**
+ * Process the given byte and pass the result on to the configured destination stream
+ * @param b the byte being written
+ */
+ public void write(int b) throws IOException {
+ }
+
+ /**
+ * Flush any unwritten data from this stream.
+ */
+ public void flush() throws IOException {
+ super.flush();
+ if (destination != null)
+ destination.flush();
+ }
+
+ /**
+ * Close this stream and, if the configured destination is a ProcessingStep,
+ * close it as well. Typically a chain of steps terminates in a conventional
+ * output stream. Implementors of this method should ensure they set the
+ * status of the step.
+ */
+ public void close() throws IOException {
+ super.close();
+ if (destination instanceof ProcessingStep)
+ destination.close();
+ destination = null;
+ monitor = null;
+ }
+
+ /**
+ * Return the status of this step. The status will be <code>null</code> if the
+ * step has not yet executed. If the step has executed the returned status
+ * indicates the success or failure of the step.
+ * @param deep whether or not to aggregate the status of any linked steps
+ * @return the requested status
+ */
+ public IStatus getStatus(boolean deep) {
+ if (!deep)
+ return status;
+ ArrayList list = new ArrayList();
+ int severity = collectStatus(list);
+ if (severity == IStatus.OK)
+ return Status.OK_STATUS;
+ IStatus[] result = (IStatus[]) list.toArray(new IStatus[list.size()]);
+ return new MultiStatus(Activator.ID, severity, result, "Result of processing steps", null);
+ }
+
+ private int collectStatus(ArrayList list) {
+ list.add(status);
+ if (!(destination instanceof ProcessingStep))
+ return status.getSeverity();
+ int result = ((ProcessingStep) destination).collectStatus(list);
+ // TODO greater than test here is a little brittle but it is very unlikely that we will add
+ // a new status severity.
+ if (status.getSeverity() > result)
+ return status.getSeverity();
+ return result;
+
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStepDescriptor.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStepDescriptor.java
new file mode 100644
index 000000000..e79910ef0
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStepDescriptor.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+* Copyright (c) 2007 compeople AG and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* compeople AG (Stefan Liebig) - initial API and implementation
+*******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository.processing;
+
+/**
+ * The description of a processor step.
+ */
+public class ProcessingStepDescriptor {
+
+ private final String processorId; //the operation to be applied (e.g: unpack, md5, signature verification, etc.)
+ private final String data; //data requested for the processing (eg. expected checksum)
+ private final boolean required; //whether the step is optional or not
+
+ /**
+ * Create a processing step description.
+ *
+ * @param processorId
+ * @param data
+ * @param required
+ */
+ public ProcessingStepDescriptor(String processorId, String data, boolean required) {
+ super();
+ this.processorId = processorId;
+ this.data = data;
+ this.required = required;
+ }
+
+ public String getProcessorId() {
+ return processorId;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public boolean isRequired() {
+ return required;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((data == null) ? 0 : data.hashCode());
+ result = prime * result + ((processorId == null) ? 0 : processorId.hashCode());
+ result = prime * result + (required ? 1231 : 1237);
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof ProcessingStepDescriptor))
+ return false;
+ final ProcessingStepDescriptor other = (ProcessingStepDescriptor) obj;
+ if (data == null) {
+ if (other.data != null)
+ return false;
+ } else if (!data.equals(other.data))
+ return false;
+ if (processorId == null) {
+ if (other.processorId != null)
+ return false;
+ } else if (!processorId.equals(other.processorId))
+ return false;
+ if (required != other.required)
+ return false;
+ return true;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStepHandler.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStepHandler.java
new file mode 100644
index 000000000..e1777da14
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/prov/artifact/repository/processing/ProcessingStepHandler.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+* Copyright (c) 2007 compeople AG and others.
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* compeople AG (Stefan Liebig) - initial API and implementation
+* IBM - continuing development
+*******************************************************************************/
+package org.eclipse.equinox.prov.artifact.repository.processing;
+
+import java.io.OutputStream;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.prov.artifact.repository.Activator;
+import org.eclipse.equinox.prov.artifact.repository.IArtifactDescriptor;
+
+/**
+ * Creates processing step instances from extensions and executes them.
+ */
+public class ProcessingStepHandler {
+
+ public ProcessingStep[] create(ProcessingStepDescriptor[] descriptors, IArtifactDescriptor context) {
+ ProcessingStep[] result = new ProcessingStep[descriptors.length];
+ for (int i = 0; i < descriptors.length; i++)
+ result[i] = create(descriptors[i], context);
+ return result;
+ }
+
+ public ProcessingStep create(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
+ IExtensionRegistry registry = RegistryFactory.getRegistry();
+ IExtension extension = registry.getExtension("org.eclipse.equinox.prov.artifact.repository.processingSteps", descriptor.getProcessorId()); //$NON-NLS-1$
+ IConfigurationElement[] config = extension.getConfigurationElements();
+ Exception error = null;
+ try {
+ Object object = config[0].createExecutableExtension("class"); //$NON-NLS-1$
+ if (object instanceof ProcessingStep) {
+ ProcessingStep step = (ProcessingStep) object;
+ step.initialize(descriptor, context);
+ return step;
+ }
+ } catch (CoreException e) {
+ error = e;
+ }
+ int severity = descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO;
+ ProcessingStep result = new ProcessingStep() {};
+ result.status = new Status(severity, Activator.ID, "Could not instantiate step:" + descriptor.getProcessorId(), error);
+ return result;
+ }
+
+ public OutputStream createAndLink(ProcessingStepDescriptor[] descriptors, IArtifactDescriptor context, OutputStream output, IProgressMonitor monitor) {
+ if (descriptors == null)
+ return output;
+ ProcessingStep[] steps = create(descriptors, context);
+ return link(steps, output, monitor);
+ }
+
+ public OutputStream link(ProcessingStep[] steps, OutputStream output, IProgressMonitor monitor) {
+ OutputStream previous = output;
+ for (int i = steps.length - 1; i >= 0; i--) {
+ ProcessingStep step = steps[i];
+ step.link(previous, monitor);
+ previous = step;
+ }
+ return previous;
+ }
+
+ public IStatus validateSteps(OutputStream output) {
+ if (!(output instanceof ProcessingStep))
+ return Status.OK_STATUS;
+ return ((ProcessingStep) output).getStatus(true);
+ }
+}

Back to the top