Clarify overall project structure.
authorMathieu Baudier <mbaudier@argeo.org>
Mon, 15 Nov 2021 07:16:09 +0000 (08:16 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Mon, 15 Nov 2021 07:16:09 +0000 (08:16 +0100)
1869 files changed:
cms/org.argeo.slc.agent.jcr/.gitignore [deleted file]
cms/org.argeo.slc.agent.jcr/.project [deleted file]
cms/org.argeo.slc.agent.jcr/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml [deleted file]
cms/org.argeo.slc.agent.jcr/META-INF/spring/jcr.xml [deleted file]
cms/org.argeo.slc.agent.jcr/bnd.bnd [deleted file]
cms/org.argeo.slc.agent.jcr/build.properties [deleted file]
cms/org.argeo.slc.agent.jcr/pom.xml [deleted file]
cms/org.argeo.slc.agent/.gitignore [deleted file]
cms/org.argeo.slc.agent/.project [deleted file]
cms/org.argeo.slc.agent/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.agent/META-INF/spring/agent.xml [deleted file]
cms/org.argeo.slc.agent/META-INF/spring/osgi.xml [deleted file]
cms/org.argeo.slc.agent/agent.properties [deleted file]
cms/org.argeo.slc.agent/bnd.bnd [deleted file]
cms/org.argeo.slc.agent/build.properties [deleted file]
cms/org.argeo.slc.agent/pom.xml [deleted file]
cms/org.argeo.slc.api/.classpath [deleted file]
cms/org.argeo.slc.api/.gitignore [deleted file]
cms/org.argeo.slc.api/.project [deleted file]
cms/org.argeo.slc.api/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.api/bnd.bnd [deleted file]
cms/org.argeo.slc.api/build.properties [deleted file]
cms/org.argeo.slc.api/pom.xml [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/BasicNameVersion.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/Condition.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/DefaultCategoryNameVersion.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/DefaultNameVersion.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/ModuleSet.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/NameVersion.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/SlcException.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/SlcNames.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/SlcTypes.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/StreamReadable.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/UnsupportedException.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/attachment/Attachment.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsEnabled.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsStorage.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/build/Distribution.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/build/License.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/build/ModularDistribution.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/build/package.html [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployEnvironment.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystem.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystemManager.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/Deployment.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeploymentData.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DynamicRuntime.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/InstalledExecutables.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/ModularDeployedSystem.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/Module.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/ModuleDescriptor.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/ModulesManager.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/TargetData.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/VersioningDriver.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/deploy/package.html [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractExecutionValue.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractSpecAttribute.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionContext.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlow.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptor.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptorConverter.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModule.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModuleDescriptor.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesListener.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesManager.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionProcess.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionResources.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpec.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpecAttribute.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStack.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStackLevel.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStep.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/FlowConfigurationException.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/RealizedFlow.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/RefSpecAttribute.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/RefValue.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/RefValueChoice.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgent.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgentCli.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/package.html [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveAccessor.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveUtils.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveValue.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/slc.cnd [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/ExecutableTestRun.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/IncompatibleTestDataException.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/TestData.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/TestDataProvider.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/TestDefinition.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/TestResult.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/TestResultListener.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/TestResultPart.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/TestRun.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/TestRunAware.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/TestStatus.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/WritableTestRun.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/context/ContextAware.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/context/ParentContextAware.java [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/context/package.html [deleted file]
cms/org.argeo.slc.api/src/org/argeo/slc/test/package.html [deleted file]
cms/org.argeo.slc.client.rap/.classpath [deleted file]
cms/org.argeo.slc.client.rap/.gitignore [deleted file]
cms/org.argeo.slc.client.rap/.project [deleted file]
cms/org.argeo.slc.client.rap/.settings/org.eclipse.jdt.core.prefs [deleted file]
cms/org.argeo.slc.client.rap/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.client.rap/META-INF/spring/commands.xml [deleted file]
cms/org.argeo.slc.client.rap/META-INF/spring/jcr.xml [deleted file]
cms/org.argeo.slc.client.rap/META-INF/spring/osgi.xml [deleted file]
cms/org.argeo.slc.client.rap/bnd.bnd [deleted file]
cms/org.argeo.slc.client.rap/build.properties [deleted file]
cms/org.argeo.slc.client.rap/icons/slc_execution_perspective.gif [deleted file]
cms/org.argeo.slc.client.rap/plugin.xml [deleted file]
cms/org.argeo.slc.client.rap/pom.xml [deleted file]
cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/OpenJcrFileService.java [deleted file]
cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcRapPlugin.java [deleted file]
cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcSecureRap.java [deleted file]
cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFile.java [deleted file]
cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java [deleted file]
cms/org.argeo.slc.client.ui.dist/.classpath [deleted file]
cms/org.argeo.slc.client.ui.dist/.gitignore [deleted file]
cms/org.argeo.slc.client.ui.dist/.project [deleted file]
cms/org.argeo.slc.client.ui.dist/.settings/org.eclipse.jdt.core.prefs [deleted file]
cms/org.argeo.slc.client.ui.dist/.settings/org.eclipse.pde.core.prefs [deleted file]
cms/org.argeo.slc.client.ui.dist/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml [deleted file]
cms/org.argeo.slc.client.ui.dist/META-INF/spring/editors.xml [deleted file]
cms/org.argeo.slc.client.ui.dist/META-INF/spring/jcr.xml [deleted file]
cms/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml [deleted file]
cms/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml [deleted file]
cms/org.argeo.slc.client.ui.dist/bnd.bnd [deleted file]
cms/org.argeo.slc.client.ui.dist/build.properties [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/addItem.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/addRepo.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/artifactBase.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/artifactVersionBase.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/changeRights.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/checked.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/clear.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/distGrp.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/distGrpReadOnly.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/distribution_perspective.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/fetchRepo.png [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/file.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/help.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/homeRepo.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/modularDistributionVersion.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/more.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/more.png [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/normalize.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/package.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/packageBrowser.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/packages.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/publish.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/pview.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/refresh.png [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/removeItem.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/removeMark.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/repo.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/repoReadOnly.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/search.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/searchForm.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/search_decl_obj.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/showSize.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/sinfocenter_obj.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/unchecked.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/icons/wkspGroup.gif [deleted file]
cms/org.argeo.slc.client.ui.dist/plugin.xml [deleted file]
cms/org.argeo.slc.client.ui.dist/pom.xml [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/AnonymousDistributionPerspective.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistConstants.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistImages.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistPlugin.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistributionPerspective.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/BndProcess.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyLocalJavaWorkspace.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyWorkspace.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateLocalJavaWorkspace.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateWorkspace.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteArtifacts.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DoNothing.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/Fetch.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/MergeWorkspaces.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeDistribution.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenGenerateBinariesWizard.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenModuleEditor.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenWorkspaceEditor.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/PublishWorkspace.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshArtifactBrowser.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshDistributionsView.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RunInOsgi.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ShowSizeColumn.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/UnregisterRemoteRepo.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/package.html [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/AnonymousDistTreeContentProvider.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactLabelProvider.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactsTreeContentProvider.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistSessionFactory.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparator.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparer.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeDoubleClickListener.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeLabelProvider.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ArtifactVersionEditor.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDependencyPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDetailPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleRawPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspBrowserPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspEditorInput.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWorkspaceEditor.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionDetailPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionEditor.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionOverviewPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/RunInOsgiPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/WkspCategoryBaseListPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/DistParentElem.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionBaseElem.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionElem.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/RepoElem.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ArtifactsTableConfigurer.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/CommandHelpers.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistNodeViewerComparator.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistUiHelpers.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/HyperlinkAdapter.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/NameVersionComparator.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/VersionComparator.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AbstractQueryArtifactsView.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AnonymousDistributionsView.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/ArtifactsBrowser.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/DistributionsView.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/HelpView.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsForm.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsText.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryBundlesForm.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChangeRightsWizard.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChooseRightsPage.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/GenerateBinariesWizard.java [deleted file]
cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java [deleted file]
cms/org.argeo.slc.client.ui/.classpath [deleted file]
cms/org.argeo.slc.client.ui/.gitignore [deleted file]
cms/org.argeo.slc.client.ui/.project [deleted file]
cms/org.argeo.slc.client.ui/.settings/org.eclipse.jdt.core.prefs [deleted file]
cms/org.argeo.slc.client.ui/.settings/org.eclipse.pde.core.prefs [deleted file]
cms/org.argeo.slc.client.ui/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.client.ui/META-INF/spring/commands.xml [deleted file]
cms/org.argeo.slc.client.ui/META-INF/spring/controllers.xml [deleted file]
cms/org.argeo.slc.client.ui/META-INF/spring/editors.xml [deleted file]
cms/org.argeo.slc.client.ui/META-INF/spring/osgi.xml [deleted file]
cms/org.argeo.slc.client.ui/META-INF/spring/views.xml [deleted file]
cms/org.argeo.slc.client.ui/bnd.bnd [deleted file]
cms/org.argeo.slc.client.ui/build.properties [deleted file]
cms/org.argeo.slc.client.ui/icons/agent.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/agentFactory.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/archive.png [deleted file]
cms/org.argeo.slc.client.ui/icons/batch.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/choices.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/clear_batch.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/computer.png [deleted file]
cms/org.argeo.slc.client.ui/icons/edit_parameters.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/error.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/excel.png [deleted file]
cms/org.argeo.slc.client.ui/icons/executionError.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/executionPassed.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/executionSpec.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/executionSpecAttribute.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/executionSpecs.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/execution_module.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/failed.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/flow.png [deleted file]
cms/org.argeo.slc.client.ui/icons/folder.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/folder.png [deleted file]
cms/org.argeo.slc.client.ui/icons/kill.png [deleted file]
cms/org.argeo.slc.client.ui/icons/launch.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/module.png [deleted file]
cms/org.argeo.slc.client.ui/icons/module_stopped.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/myResult.png [deleted file]
cms/org.argeo.slc.client.ui/icons/passed.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/process_completed.png [deleted file]
cms/org.argeo.slc.client.ui/icons/process_details.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/process_error.png [deleted file]
cms/org.argeo.slc.client.ui/icons/process_running.png [deleted file]
cms/org.argeo.slc.client.ui/icons/process_scheduled.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/processes.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/processes.png [deleted file]
cms/org.argeo.slc.client.ui/icons/refresh.png [deleted file]
cms/org.argeo.slc.client.ui/icons/relaunch.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/removeAll.png [deleted file]
cms/org.argeo.slc.client.ui/icons/remove_one.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/rename.png [deleted file]
cms/org.argeo.slc.client.ui/icons/result_details.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/results.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/slc_execution_perspective.gif [deleted file]
cms/org.argeo.slc.client.ui/icons/system.png [deleted file]
cms/org.argeo.slc.client.ui/plugin.xml [deleted file]
cms/org.argeo.slc.client.ui/pom.xml [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/ClientUiPlugin.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcExecutionPerspective.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcImages.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcUiConstants.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/AddResultFolder.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/DeleteItems.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshJcrResultTreeView.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultFolder.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultNode.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RunSlcFlow.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/UpdateModule.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/controllers/ProcessController.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/decorators/ResultFailedDecorator.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInput.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInputFactory.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessLogPage.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ParentNodeFolder.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultFolder.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparator.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparer.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParent.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParentUtils.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/SingleResultNode.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/VirtualFolder.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeContentProvider.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java [deleted file]
cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/wizards/ConfirmOverwriteWizard.java [deleted file]
cms/org.argeo.slc.factory/.classpath [deleted file]
cms/org.argeo.slc.factory/.gitignore [deleted file]
cms/org.argeo.slc.factory/.project [deleted file]
cms/org.argeo.slc.factory/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.factory/bnd.bnd [deleted file]
cms/org.argeo.slc.factory/pom.xml [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmFactory.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmProxyService.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmRepository.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/AbstractRpmRepository.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/BuildInMock.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/CreateRpmDistribution.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ReleaseStaging.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmDistribution.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmFactoryImpl.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmPackageSet.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmSpecFile.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/StagingRpmRepository.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ThirdPartyRpmRepository.java [deleted file]
cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/YumListParser.java [deleted file]
cms/org.argeo.slc.jcr/.classpath [deleted file]
cms/org.argeo.slc.jcr/.gitignore [deleted file]
cms/org.argeo.slc.jcr/.project [deleted file]
cms/org.argeo.slc.jcr/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.jcr/bnd.bnd [deleted file]
cms/org.argeo.slc.jcr/build.properties [deleted file]
cms/org.argeo.slc.jcr/pom.xml [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrMetadataWriter.java [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrTestResult.java [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrConstants.java [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrResultUtils.java [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrUtils.java [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrAgent.java [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionProcess.java [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java [deleted file]
cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java [deleted file]
cms/org.argeo.slc.launcher/.classpath [deleted file]
cms/org.argeo.slc.launcher/.gitignore [deleted file]
cms/org.argeo.slc.launcher/.project [deleted file]
cms/org.argeo.slc.launcher/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.launcher/bnd.bnd [deleted file]
cms/org.argeo.slc.launcher/build.properties [deleted file]
cms/org.argeo.slc.launcher/pom.xml [deleted file]
cms/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java [deleted file]
cms/org.argeo.slc.launcher/src/org/argeo/slc/cli/jaas.config [deleted file]
cms/org.argeo.slc.launcher/src/org/argeo/slc/cli/log4j.properties [deleted file]
cms/org.argeo.slc.repo/.classpath [deleted file]
cms/org.argeo.slc.repo/.gitignore [deleted file]
cms/org.argeo.slc.repo/.project [deleted file]
cms/org.argeo.slc.repo/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.repo/bnd.bnd [deleted file]
cms/org.argeo.slc.repo/build.properties [deleted file]
cms/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/AetherUtilsTest.java [deleted file]
cms/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/pom.xml [deleted file]
cms/org.argeo.slc.repo/pom.xml [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactIndexer.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/FreeLicense.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/JarFileIndexer.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/JavaRepoManager.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/MavenProxyService.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexer.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexerVisitor.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiBundlesProvider.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiFactory.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/PdeSourcesIndexer.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoService.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoUtils.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmIndexer.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmRepoManager.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/SlcRepoManager.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/AbstractJcrRepoManager.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/JavaRepoManagerImpl.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RepoServiceImpl.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RpmRepoManagerImpl.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/SlcRepoManagerImpl.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/WorkspaceIndexer.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/AntPathMatcher.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/PathMatcher.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/apache-2.0.txt [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/bsd-3-clause.txt [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/cddl-1.0.txt [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/epl-1.0.txt [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-2.0.txt [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-3.0.txt [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-2.1.txt [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-3.0.txt [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/mit.txt [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/AetherUtils.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ArtifactIdComparator.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ConvertPoms_01_03.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/GenerateBinaries.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/IndexDistribution.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenProxyServiceImpl.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/Migration_01_03.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveSourcesProvider.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapperCNV.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ImportBundlesZip.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.6.profile [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.7.profile [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/MavenWrapper.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/NormalizeGroup.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ObrWrapper.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiProfile.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SourcesProvider.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SubArtifact.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/UriWrapper.java [deleted file]
cms/org.argeo.slc.repo/src/org/argeo/slc/repo/repo.cnd [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/AbstractRepositoryListener.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/ConfigurationProperties.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositoryCache.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositorySystemSession.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/DefaultSessionData.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryCache.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryEvent.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryListener.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystem.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystemSession.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/RequestTrace.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/SessionData.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/SyncContext.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/AbstractArtifact.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/Artifact.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactProperties.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactType.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactTypeRegistry.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifact.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifactType.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionContext.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformationContext.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformer.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManagement.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManager.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencySelector.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyTraverser.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/UnsolvableVersionConflictException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/VersionFilter.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeploymentException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DefaultDependencyNode.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/Dependency.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyCycle.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyFilter.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyNode.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyVisitor.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/Exclusion.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallationException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/AbstractMetadata.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/DefaultMetadata.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/MergeableMetadata.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/Metadata.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/ArtifactRepository.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/Authentication.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationContext.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationDigest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationSelector.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRegistration.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRegistration.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepository.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepositoryManager.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/MirrorSelector.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/NoLocalRepositoryManagerException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/Proxy.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/ProxySelector.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/RemoteRepository.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/RepositoryPolicy.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceReader.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceRepository.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicy.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicyRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResolutionException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResolutionException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicy.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicyRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResolutionException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRequest.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResolutionException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResult.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/AbstractTransferListener.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactNotFoundException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactTransferException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ChecksumFailureException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataNotFoundException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataTransferException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryConnectorException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryLayoutException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoTransporterException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/RepositoryOfflineException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferCancelledException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferEvent.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferListener.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferResource.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/package-info.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/version/InvalidVersionSpecificationException.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/version/Version.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionConstraint.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionRange.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionScheme.java [deleted file]
cms/org.argeo.slc.repo/src/org/eclipse/aether/version/package-info.java [deleted file]
cms/org.argeo.slc.runtime/.classpath [deleted file]
cms/org.argeo.slc.runtime/.gitignore [deleted file]
cms/org.argeo.slc.runtime/.project [deleted file]
cms/org.argeo.slc.runtime/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.runtime/bnd.bnd [deleted file]
cms/org.argeo.slc.runtime/build.properties [deleted file]
cms/org.argeo.slc.runtime/pom.xml [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/AbstractExecutionModulesManager.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgent.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgentCli.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionFlow.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionSpec.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionStack.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultProcess.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ExecutionThread.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/InstantiationManager.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThread.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThreadGroup.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/CloseTestResult.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/Echo.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/If.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/JvmProcess.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCall.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCallOutputListener.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestData.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestDefinition.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/ContextUtils.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleResultPart.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestResult.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestRun.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SlcTestUtils.java [deleted file]
cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java [deleted file]
cms/org.argeo.slc.server.repo/.gitignore [deleted file]
cms/org.argeo.slc.server.repo/.project [deleted file]
cms/org.argeo.slc.server.repo/.settings/org.eclipse.pde.core.prefs [deleted file]
cms/org.argeo.slc.server.repo/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.server.repo/META-INF/spring/jcr.xml [deleted file]
cms/org.argeo.slc.server.repo/META-INF/spring/repo-osgi.xml [deleted file]
cms/org.argeo.slc.server.repo/META-INF/spring/services.xml [deleted file]
cms/org.argeo.slc.server.repo/bnd.bnd [deleted file]
cms/org.argeo.slc.server.repo/build.properties [deleted file]
cms/org.argeo.slc.server.repo/pom.xml [deleted file]
cms/org.argeo.slc.server.repo/repo.properties [deleted file]
cms/org.argeo.slc.spring/.classpath [deleted file]
cms/org.argeo.slc.spring/.gitignore [deleted file]
cms/org.argeo.slc.spring/.project [deleted file]
cms/org.argeo.slc.spring/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.spring/META-INF/spring.handlers [deleted file]
cms/org.argeo.slc.spring/META-INF/spring.schemas [deleted file]
cms/org.argeo.slc.spring/bnd.bnd [deleted file]
cms/org.argeo.slc.spring/build.properties [deleted file]
cms/org.argeo.slc.spring/ext/test/log4j.properties [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/DefaultResourceSetTest.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/file1.txt [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/subdir/file2.txt [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/relativeResourceSet.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/AbstractExecutionFlowTestCase.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/BasicExecutionFlowTest.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/DefaultAgentCliTest.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ExceptionIfInitCalledTwice.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesSpringTest.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesTest.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ParameterRefTest.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/applicationContext.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-001.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-002.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-003.error.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-004.error.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/executionResources.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/imports.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMap.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMapMultipleFlow.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/minimal.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/multipleFlow.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/parameterRef.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.exec.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/specOverriding.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/SystemCallTest.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/systemCall.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/test.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/FlowNamespaceTest.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/advanced.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-001.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-002.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/containers.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/tests.xml [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/AbstractInternalSpringTestCase.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/ContextTest.java [deleted file]
cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/applicationContext.xml [deleted file]
cms/org.argeo.slc.spring/pom.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/ant/AntFlowGenerator.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/ant/AntRun.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentUploader.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/FileAttachmentsStorage.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/SimpleAttachment.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/ResourceDistribution.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionDistributionId.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionedResourceDistribution.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/package.html [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DefaultResourceSet.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DigestCheck.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/LocalFilesDeployment.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/MultiResourceSet.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/ResourceSet.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/SimpleExecutables.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/VersionedDirSync.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/package.html [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractExecutionFlowGenerator.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgent.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgentCli.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlow.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionAspect.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResources.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResourcesFactoryBean.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionScope.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/FileExecutionResources.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/MapExecutionContext.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/OsFileFactoryBean.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ParameterRef.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/SedFilteredResource.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/defaults.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ConsoleContextDescriber.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ContextDescriber.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/CompositeRunnableFactory.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/DefaultRunnableDataNode.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGenerator.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGeneratorSource.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCall.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlow.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlowDescriptor.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableDataNode.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableFactory.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/runtime.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/simple.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/specs.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/spring.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/CloseTestResult.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/Echo.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/If.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/JvmProcess.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MergedLists.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MethodCall.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/OverrideContextAware.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCall.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCallOutputListener.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/UploadAttachments.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/core.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/templates.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/utils.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/AsFlowDecorator.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ExecutionScopeDecorator.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowNamespaceHandler.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/NamespaceUtils.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ParamDecorator.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/DefaultContextTestData.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleContextAware.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleParentContextAware.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/package.html [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/package.html [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/spring.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundleRegister.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundlesManager.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/FileSystemBundleRegister.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/MultipleServiceExporterPostProcessor.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiBundle.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModule.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModulesManager.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionResources.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiRuntime.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/AbstractOsgiModularDistribution.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/BundleModularDistribution.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSite.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteCategory.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteFeature.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/deploy/OsgiResourceSet.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/execution.xml [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/AbstractSystemExecution.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/AuthenticatedApplicationContextInitialization.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AbstractSystemExecution.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AuthenticatedApplicationContextInitialization.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/SimpleRoleRegistration.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/BndWrapper.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/MavenWrapper.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/UriWrapper.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractExecutionFlowTestcase.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractOsgiRuntimeTestCase.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractSpringTestCase.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/ExecutionFlowDescriptorTestUtils.java [deleted file]
cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/UnitUtils.java [deleted file]
cms/org.argeo.slc.support/.classpath [deleted file]
cms/org.argeo.slc.support/.gitignore [deleted file]
cms/org.argeo.slc.support/.project [deleted file]
cms/org.argeo.slc.support/META-INF/.gitignore [deleted file]
cms/org.argeo.slc.support/bnd.bnd [deleted file]
cms/org.argeo.slc.support/ext/test/log4j.properties [deleted file]
cms/org.argeo.slc.support/ext/test/org/argeo/slc/diff/LineTokenizerTest.java [deleted file]
cms/org.argeo.slc.support/pom.xml [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/DataInterpreter.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/Diff.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssue.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssueKey.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffKey.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissing.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissingXml.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffNotMatched.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffPosition.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffResult.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/KeyColumnsDiff.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/LineTokenizer.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/RelatedFile.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/TableDiffPosition.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/Tolerance.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/ToleranceDiff.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/XPathDiffPosition.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/diff/package.html [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/AbstractJschTask.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/CallbackHandlerUserInfo.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/GetMachineId.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschContextSession.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschExecutor.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschMultiTasks.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/RemoteExec.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpFrom.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpTo.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SimpleUserInfo.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SshFilesDeployment.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SshShell.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SshTarget.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SwingUserInfo.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/jsch/jaas.cfg [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/jcr/JcrRepositoryBackup.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRedhatDeploymentData.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRpmDistribution.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DeployLxcContainer.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatDeploymentData.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatHostManager.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RpmDistribution.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/ScriptCall.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/SimpleLinuxHost.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-guest.sh [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-host.sh [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/redhat.xml [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/BuildInMock.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/CreateSrpm.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/ImportSrpm.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmBuildEnvironment.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmSpecFile.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxMachine.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxManager.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxNat.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxPortMapping.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/log4j/SlcExecutionAppender.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/mail/SendMail.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationDeployment.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationTargetData.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServer.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeployment.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeploymentData.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerManager.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerTargetData.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/SimpleHttpdApplication.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebApplication.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebServer.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/DbModel.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/JdbcAware.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/SimpleJdbcDatabase.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResource.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceFactory.java [deleted file]
cms/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceSet.java [deleted file]
cms/pom.xml
demo/modules/.gitignore [deleted file]
demo/modules/cnf/maven.bnd [deleted file]
demo/modules/org.argeo.slc.demo.ant/.gitignore [deleted file]
demo/modules/org.argeo.slc.demo.ant/.project [deleted file]
demo/modules/org.argeo.slc.demo.ant/.settings/org.eclipse.pde.core.prefs [deleted file]
demo/modules/org.argeo.slc.demo.ant/META-INF/.gitignore [deleted file]
demo/modules/org.argeo.slc.demo.ant/META-INF/spring/ant.xml [deleted file]
demo/modules/org.argeo.slc.demo.ant/META-INF/spring/flowGenerator.xml [deleted file]
demo/modules/org.argeo.slc.demo.ant/META-INF/spring/imports.xml [deleted file]
demo/modules/org.argeo.slc.demo.ant/META-INF/spring/osgi.xml [deleted file]
demo/modules/org.argeo.slc.demo.ant/ant/hello/build.xml [deleted file]
demo/modules/org.argeo.slc.demo.ant/bnd.bnd [deleted file]
demo/modules/org.argeo.slc.demo.ant/build.properties [deleted file]
demo/modules/org.argeo.slc.demo.ant/pom.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/.classpath [deleted file]
demo/modules/org.argeo.slc.demo.basic/.gitignore [deleted file]
demo/modules/org.argeo.slc.demo.basic/.project [deleted file]
demo/modules/org.argeo.slc.demo.basic/.settings/org.eclipse.pde.core.prefs [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/.gitignore [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/basic-001.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/basic-002.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/basic.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-001.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-002.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-001.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-002.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/imports.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/main.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/namespace.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/osgi.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/META-INF/spring/systemCall.xml [deleted file]
demo/modules/org.argeo.slc.demo.basic/bnd.bnd [deleted file]
demo/modules/org.argeo.slc.demo.basic/build.properties [deleted file]
demo/modules/org.argeo.slc.demo.basic/pom.xml [deleted file]
demo/modules/org.argeo.slc.demo.minimal/.gitignore [deleted file]
demo/modules/org.argeo.slc.demo.minimal/.project [deleted file]
demo/modules/org.argeo.slc.demo.minimal/.settings/org.eclipse.pde.core.prefs [deleted file]
demo/modules/org.argeo.slc.demo.minimal/META-INF/.gitignore [deleted file]
demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/common.xml [deleted file]
demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld-raw.xml [deleted file]
demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml [deleted file]
demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/osgi.xml [deleted file]
demo/modules/org.argeo.slc.demo.minimal/bnd.bnd [deleted file]
demo/modules/org.argeo.slc.demo.minimal/build.properties [deleted file]
demo/modules/org.argeo.slc.demo.minimal/pom.xml [deleted file]
demo/modules/pom.xml [deleted file]
demo/pom.xml [deleted file]
dep/org.argeo.slc.dep.backend/.gitignore [deleted file]
dep/org.argeo.slc.dep.backend/META-INF/.gitignore [deleted file]
dep/org.argeo.slc.dep.backend/bnd.bnd [deleted file]
dep/org.argeo.slc.dep.backend/p2.inf [deleted file]
dep/org.argeo.slc.dep.backend/pom.xml [deleted file]
dep/org.argeo.slc.dep.minimal/pom.xml
dep/org.argeo.slc.dep.spring.e4.rap/.gitignore [deleted file]
dep/org.argeo.slc.dep.spring.e4.rap/META-INF/.gitignore [deleted file]
dep/org.argeo.slc.dep.spring.e4.rap/bnd.bnd [deleted file]
dep/org.argeo.slc.dep.spring.e4.rap/pom.xml [deleted file]
dep/org.argeo.slc.dep.spring/.gitignore [deleted file]
dep/org.argeo.slc.dep.spring/META-INF/.gitignore [deleted file]
dep/org.argeo.slc.dep.spring/bnd.bnd [deleted file]
dep/org.argeo.slc.dep.spring/pom.xml [deleted file]
dep/pom.xml
dist/pom.xml
dist/slc-maven/.gitignore [deleted file]
dist/slc-maven/pom.xml [deleted file]
legacy/dep/cnf/maven.bnd [new file with mode: 0644]
legacy/dep/org.argeo.slc.dep.backend/.gitignore [new file with mode: 0644]
legacy/dep/org.argeo.slc.dep.backend/META-INF/.gitignore [new file with mode: 0644]
legacy/dep/org.argeo.slc.dep.backend/bnd.bnd [new file with mode: 0644]
legacy/dep/org.argeo.slc.dep.backend/p2.inf [new file with mode: 0644]
legacy/dep/org.argeo.slc.dep.backend/pom.xml [new file with mode: 0644]
legacy/dep/org.argeo.slc.dep.spring/.gitignore [new file with mode: 0644]
legacy/dep/org.argeo.slc.dep.spring/META-INF/.gitignore [new file with mode: 0644]
legacy/dep/org.argeo.slc.dep.spring/bnd.bnd [new file with mode: 0644]
legacy/dep/org.argeo.slc.dep.spring/pom.xml [new file with mode: 0644]
legacy/dep/pom.xml [new file with mode: 0644]
legacy/lib/.gitignore [new file with mode: 0644]
legacy/lib/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.agent.jcr/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.agent.jcr/.project [new file with mode: 0644]
legacy/org.argeo.slc.agent.jcr/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml [new file with mode: 0644]
legacy/org.argeo.slc.agent.jcr/META-INF/spring/jcr.xml [new file with mode: 0644]
legacy/org.argeo.slc.agent.jcr/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.agent.jcr/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.agent.jcr/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.agent/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.agent/.project [new file with mode: 0644]
legacy/org.argeo.slc.agent/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.agent/META-INF/spring/agent.xml [new file with mode: 0644]
legacy/org.argeo.slc.agent/META-INF/spring/osgi.xml [new file with mode: 0644]
legacy/org.argeo.slc.agent/agent.properties [new file with mode: 0644]
legacy/org.argeo.slc.agent/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.agent/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.agent/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/.classpath [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/.project [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/META-INF/spring/commands.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/META-INF/spring/jcr.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/META-INF/spring/osgi.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/icons/slc_execution_perspective.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/plugin.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/OpenJcrFileService.java [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcRapPlugin.java [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcSecureRap.java [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFile.java [new file with mode: 0644]
legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/.classpath [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/.project [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/META-INF/spring/editors.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/META-INF/spring/jcr.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/addItem.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/addRepo.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/artifactBase.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/artifactVersionBase.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/changeRights.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/checked.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/clear.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/distGrp.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/distGrpReadOnly.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/distribution_perspective.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/fetchRepo.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/file.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/help.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/homeRepo.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/modularDistributionVersion.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/more.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/more.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/normalize.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/package.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/packageBrowser.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/packages.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/publish.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/pview.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/refresh.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/removeItem.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/removeMark.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/repo.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/repoReadOnly.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/search.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/searchForm.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/search_decl_obj.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/showSize.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/sinfocenter_obj.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/unchecked.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/icons/wkspGroup.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/plugin.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/AnonymousDistributionPerspective.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistConstants.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistImages.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistPlugin.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistributionPerspective.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/BndProcess.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyLocalJavaWorkspace.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyWorkspace.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateLocalJavaWorkspace.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateWorkspace.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteArtifacts.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DoNothing.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/Fetch.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/MergeWorkspaces.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeDistribution.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenGenerateBinariesWizard.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenModuleEditor.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenWorkspaceEditor.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/PublishWorkspace.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshArtifactBrowser.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshDistributionsView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RunInOsgi.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ShowSizeColumn.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/UnregisterRemoteRepo.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/package.html [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/AnonymousDistTreeContentProvider.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactLabelProvider.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactsTreeContentProvider.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistSessionFactory.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparator.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparer.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeDoubleClickListener.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeLabelProvider.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ArtifactVersionEditor.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDependencyPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDetailPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleRawPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspBrowserPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspEditorInput.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWorkspaceEditor.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionDetailPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionEditor.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionOverviewPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/RunInOsgiPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/WkspCategoryBaseListPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/DistParentElem.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionBaseElem.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionElem.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/RepoElem.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ArtifactsTableConfigurer.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/CommandHelpers.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistNodeViewerComparator.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistUiHelpers.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/HyperlinkAdapter.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/NameVersionComparator.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/VersionComparator.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AbstractQueryArtifactsView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AnonymousDistributionsView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/ArtifactsBrowser.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/DistributionsView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/HelpView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsForm.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsText.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryBundlesForm.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChangeRightsWizard.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChooseRightsPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/GenerateBinariesWizard.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/.classpath [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/.project [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/META-INF/spring/commands.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/META-INF/spring/controllers.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/META-INF/spring/editors.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/META-INF/spring/osgi.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/META-INF/spring/views.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/agent.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/agentFactory.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/archive.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/batch.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/choices.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/clear_batch.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/computer.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/edit_parameters.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/error.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/excel.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/executionError.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/executionPassed.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/executionSpec.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/executionSpecAttribute.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/executionSpecs.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/execution_module.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/failed.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/flow.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/folder.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/folder.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/kill.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/launch.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/module.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/module_stopped.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/myResult.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/passed.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/process_completed.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/process_details.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/process_error.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/process_running.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/process_scheduled.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/processes.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/processes.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/refresh.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/relaunch.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/removeAll.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/remove_one.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/rename.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/result_details.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/results.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/slc_execution_perspective.gif [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/icons/system.png [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/plugin.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/ClientUiPlugin.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcExecutionPerspective.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcImages.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcUiConstants.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/AddResultFolder.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/DeleteItems.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshJcrResultTreeView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultFolder.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultNode.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RunSlcFlow.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/UpdateModule.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/controllers/ProcessController.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/decorators/ResultFailedDecorator.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInput.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInputFactory.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessLogPage.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ParentNodeFolder.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultFolder.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparator.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparer.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParent.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParentUtils.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/SingleResultNode.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/VirtualFolder.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeContentProvider.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java [new file with mode: 0644]
legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/wizards/ConfirmOverwriteWizard.java [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/.project [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/META-INF/spring/ant.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/META-INF/spring/flowGenerator.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/META-INF/spring/imports.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/META-INF/spring/osgi.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/ant/hello/build.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.demo.ant/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/.classpath [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/.project [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/basic-001.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/basic-002.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/basic.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-001.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-002.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-001.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-002.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/imports.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/main.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/namespace.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/osgi.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/META-INF/spring/systemCall.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.demo.basic/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/.project [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/META-INF/spring/common.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/META-INF/spring/helloworld-raw.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/META-INF/spring/osgi.xml [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.demo.minimal/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.launcher/.classpath [new file with mode: 0644]
legacy/org.argeo.slc.launcher/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.launcher/.project [new file with mode: 0644]
legacy/org.argeo.slc.launcher/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.launcher/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.launcher/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.launcher/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java [new file with mode: 0644]
legacy/org.argeo.slc.launcher/src/org/argeo/slc/cli/jaas.config [new file with mode: 0644]
legacy/org.argeo.slc.launcher/src/org/argeo/slc/cli/log4j.properties [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/.project [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/.settings/org.eclipse.pde.core.prefs [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/META-INF/spring/jcr.xml [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/META-INF/spring/repo-osgi.xml [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/META-INF/spring/services.xml [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.server.repo/repo.properties [new file with mode: 0644]
legacy/org.argeo.slc.spring/.classpath [new file with mode: 0644]
legacy/org.argeo.slc.spring/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.spring/.project [new file with mode: 0644]
legacy/org.argeo.slc.spring/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.spring/META-INF/spring.handlers [new file with mode: 0644]
legacy/org.argeo.slc.spring/META-INF/spring.schemas [new file with mode: 0644]
legacy/org.argeo.slc.spring/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.spring/build.properties [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/log4j.properties [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/DefaultResourceSetTest.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/file1.txt [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/subdir/file2.txt [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/relativeResourceSet.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/AbstractExecutionFlowTestCase.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/BasicExecutionFlowTest.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/DefaultAgentCliTest.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ExceptionIfInitCalledTwice.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesSpringTest.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesTest.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ParameterRefTest.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/applicationContext.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-001.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-002.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-003.error.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-004.error.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/executionResources.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/imports.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMap.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMapMultipleFlow.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/minimal.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/multipleFlow.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/parameterRef.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.exec.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/specOverriding.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/SystemCallTest.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/systemCall.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/test.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/FlowNamespaceTest.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/advanced.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-001.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-002.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/containers.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/tests.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/AbstractInternalSpringTestCase.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/ContextTest.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/applicationContext.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/ant/AntFlowGenerator.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/ant/AntRun.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentUploader.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/FileAttachmentsStorage.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/SimpleAttachment.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/ResourceDistribution.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionDistributionId.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionedResourceDistribution.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/package.html [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DefaultResourceSet.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DigestCheck.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/LocalFilesDeployment.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/MultiResourceSet.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/ResourceSet.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/SimpleExecutables.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/VersionedDirSync.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/package.html [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractExecutionFlowGenerator.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgent.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgentCli.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlow.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionAspect.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResources.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResourcesFactoryBean.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionScope.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/FileExecutionResources.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/MapExecutionContext.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/OsFileFactoryBean.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ParameterRef.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/SedFilteredResource.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/defaults.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ConsoleContextDescriber.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ContextDescriber.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/CompositeRunnableFactory.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/DefaultRunnableDataNode.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGenerator.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGeneratorSource.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCall.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlow.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlowDescriptor.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableDataNode.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableFactory.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/runtime.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/simple.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/specs.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/spring.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/CloseTestResult.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/Echo.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/If.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/JvmProcess.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MergedLists.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MethodCall.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/OverrideContextAware.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCall.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCallOutputListener.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/UploadAttachments.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/core.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/templates.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/utils.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/AsFlowDecorator.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ExecutionScopeDecorator.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowNamespaceHandler.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/NamespaceUtils.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ParamDecorator.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/DefaultContextTestData.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleContextAware.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleParentContextAware.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/package.html [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/package.html [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/spring.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundleRegister.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundlesManager.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/FileSystemBundleRegister.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/MultipleServiceExporterPostProcessor.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiBundle.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModule.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModulesManager.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionResources.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiRuntime.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/AbstractOsgiModularDistribution.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/BundleModularDistribution.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSite.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteCategory.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteFeature.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/deploy/OsgiResourceSet.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/execution.xml [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/AbstractSystemExecution.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/AuthenticatedApplicationContextInitialization.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AbstractSystemExecution.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AuthenticatedApplicationContextInitialization.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/SimpleRoleRegistration.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/BndWrapper.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/MavenWrapper.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/UriWrapper.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractExecutionFlowTestcase.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractOsgiRuntimeTestCase.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractSpringTestCase.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/ExecutionFlowDescriptorTestUtils.java [new file with mode: 0644]
legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/UnitUtils.java [new file with mode: 0644]
legacy/org.argeo.slc.support/.classpath [new file with mode: 0644]
legacy/org.argeo.slc.support/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.support/.project [new file with mode: 0644]
legacy/org.argeo.slc.support/META-INF/.gitignore [new file with mode: 0644]
legacy/org.argeo.slc.support/bnd.bnd [new file with mode: 0644]
legacy/org.argeo.slc.support/ext/test/log4j.properties [new file with mode: 0644]
legacy/org.argeo.slc.support/ext/test/org/argeo/slc/diff/LineTokenizerTest.java [new file with mode: 0644]
legacy/org.argeo.slc.support/pom.xml [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DataInterpreter.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/Diff.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssue.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssueKey.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffKey.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissing.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissingXml.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffNotMatched.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffPosition.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffResult.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/KeyColumnsDiff.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/LineTokenizer.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/RelatedFile.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/TableDiffPosition.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/Tolerance.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/ToleranceDiff.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/XPathDiffPosition.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/diff/package.html [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/AbstractJschTask.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/CallbackHandlerUserInfo.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/GetMachineId.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/JschContextSession.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/JschExecutor.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/JschMultiTasks.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/RemoteExec.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpFrom.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpTo.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SimpleUserInfo.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SshFilesDeployment.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SshShell.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SshTarget.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SwingUserInfo.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/jaas.cfg [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/jcr/JcrRepositoryBackup.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRedhatDeploymentData.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRpmDistribution.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DeployLxcContainer.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatDeploymentData.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatHostManager.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RpmDistribution.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/ScriptCall.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/SimpleLinuxHost.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-guest.sh [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-host.sh [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/redhat.xml [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/BuildInMock.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/CreateSrpm.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/ImportSrpm.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmBuildEnvironment.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmSpecFile.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxMachine.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxManager.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxNat.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxPortMapping.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/log4j/SlcExecutionAppender.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/mail/SendMail.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationDeployment.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationTargetData.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServer.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeployment.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeploymentData.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerManager.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerTargetData.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/SimpleHttpdApplication.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebApplication.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebServer.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/DbModel.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/JdbcAware.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/SimpleJdbcDatabase.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResource.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceFactory.java [new file with mode: 0644]
legacy/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceSet.java [new file with mode: 0644]
legacy/pom.xml
lib/.gitignore [deleted file]
lib/cnf/maven.bnd [deleted file]
lib/pom.xml [deleted file]
org.argeo.slc.api/.classpath [new file with mode: 0644]
org.argeo.slc.api/.gitignore [new file with mode: 0644]
org.argeo.slc.api/.project [new file with mode: 0644]
org.argeo.slc.api/META-INF/.gitignore [new file with mode: 0644]
org.argeo.slc.api/bnd.bnd [new file with mode: 0644]
org.argeo.slc.api/build.properties [new file with mode: 0644]
org.argeo.slc.api/pom.xml [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/BasicNameVersion.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/Condition.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/DefaultCategoryNameVersion.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/DefaultNameVersion.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/ModuleSet.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/NameVersion.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/SlcException.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/SlcNames.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/SlcTypes.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/StreamReadable.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/UnsupportedException.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/attachment/Attachment.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsEnabled.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsStorage.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/build/Distribution.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/build/License.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/build/ModularDistribution.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/build/package.html [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/DeployEnvironment.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystem.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystemManager.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/Deployment.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/DeploymentData.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/DynamicRuntime.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/InstalledExecutables.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/ModularDeployedSystem.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/Module.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/ModuleDescriptor.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/ModulesManager.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/TargetData.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/VersioningDriver.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/deploy/package.html [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/AbstractExecutionValue.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/AbstractSpecAttribute.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionContext.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlow.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptor.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptorConverter.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModule.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModuleDescriptor.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesListener.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesManager.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionProcess.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionResources.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpec.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpecAttribute.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStack.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStackLevel.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStep.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/FlowConfigurationException.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/RealizedFlow.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/RefSpecAttribute.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/RefValue.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/RefValueChoice.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgent.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgentCli.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/package.html [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveAccessor.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveUtils.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveValue.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/slc.cnd [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/ExecutableTestRun.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/IncompatibleTestDataException.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/TestData.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/TestDataProvider.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/TestDefinition.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/TestResult.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/TestResultListener.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/TestResultPart.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/TestRun.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/TestRunAware.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/TestStatus.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/WritableTestRun.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/context/ContextAware.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/context/ParentContextAware.java [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/context/package.html [new file with mode: 0644]
org.argeo.slc.api/src/org/argeo/slc/test/package.html [new file with mode: 0644]
org.argeo.slc.factory/.classpath [new file with mode: 0644]
org.argeo.slc.factory/.gitignore [new file with mode: 0644]
org.argeo.slc.factory/.project [new file with mode: 0644]
org.argeo.slc.factory/META-INF/.gitignore [new file with mode: 0644]
org.argeo.slc.factory/bnd.bnd [new file with mode: 0644]
org.argeo.slc.factory/pom.xml [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmFactory.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmProxyService.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmRepository.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/AbstractRpmRepository.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/BuildInMock.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/CreateRpmDistribution.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ReleaseStaging.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmDistribution.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmFactoryImpl.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmPackageSet.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmSpecFile.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/StagingRpmRepository.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ThirdPartyRpmRepository.java [new file with mode: 0644]
org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/YumListParser.java [new file with mode: 0644]
org.argeo.slc.jcr/.classpath [new file with mode: 0644]
org.argeo.slc.jcr/.gitignore [new file with mode: 0644]
org.argeo.slc.jcr/.project [new file with mode: 0644]
org.argeo.slc.jcr/META-INF/.gitignore [new file with mode: 0644]
org.argeo.slc.jcr/bnd.bnd [new file with mode: 0644]
org.argeo.slc.jcr/build.properties [new file with mode: 0644]
org.argeo.slc.jcr/pom.xml [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrMetadataWriter.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrTestResult.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrConstants.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrResultUtils.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrUtils.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrAgent.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionProcess.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java [new file with mode: 0644]
org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java [new file with mode: 0644]
org.argeo.slc.repo/.classpath [new file with mode: 0644]
org.argeo.slc.repo/.gitignore [new file with mode: 0644]
org.argeo.slc.repo/.project [new file with mode: 0644]
org.argeo.slc.repo/META-INF/.gitignore [new file with mode: 0644]
org.argeo.slc.repo/bnd.bnd [new file with mode: 0644]
org.argeo.slc.repo/build.properties [new file with mode: 0644]
org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/AetherUtilsTest.java [new file with mode: 0644]
org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/pom.xml [new file with mode: 0644]
org.argeo.slc.repo/pom.xml [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactIndexer.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/FreeLicense.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/JarFileIndexer.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/JavaRepoManager.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/MavenProxyService.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexer.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexerVisitor.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiBundlesProvider.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiFactory.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/PdeSourcesIndexer.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/RepoService.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/RepoUtils.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/RpmIndexer.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/RpmRepoManager.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/SlcRepoManager.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/core/AbstractJcrRepoManager.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/core/JavaRepoManagerImpl.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/core/RepoServiceImpl.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/core/RpmRepoManagerImpl.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/core/SlcRepoManagerImpl.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/core/WorkspaceIndexer.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/AntPathMatcher.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/PathMatcher.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/license/apache-2.0.txt [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/license/bsd-3-clause.txt [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/license/cddl-1.0.txt [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/license/epl-1.0.txt [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-2.0.txt [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-3.0.txt [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-2.1.txt [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-3.0.txt [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/license/mit.txt [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/maven/AetherUtils.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ArtifactIdComparator.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ConvertPoms_01_03.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/maven/GenerateBinaries.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/maven/IndexDistribution.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenProxyServiceImpl.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/maven/Migration_01_03.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveSourcesProvider.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapperCNV.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ImportBundlesZip.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.6.profile [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.7.profile [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/MavenWrapper.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/NormalizeGroup.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ObrWrapper.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiProfile.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SourcesProvider.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SubArtifact.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/UriWrapper.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/argeo/slc/repo/repo.cnd [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/AbstractRepositoryListener.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/ConfigurationProperties.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositoryCache.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositorySystemSession.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/DefaultSessionData.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/RepositoryCache.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/RepositoryEvent.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/RepositoryException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/RepositoryListener.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystem.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystemSession.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/RequestTrace.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/SessionData.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/SyncContext.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/artifact/AbstractArtifact.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/artifact/Artifact.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactProperties.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactType.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactTypeRegistry.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifact.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifactType.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/artifact/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionContext.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformationContext.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformer.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManagement.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManager.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencySelector.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyTraverser.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/UnsolvableVersionConflictException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/VersionFilter.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/collection/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeploymentException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/deployment/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/graph/DefaultDependencyNode.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/graph/Dependency.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyCycle.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyFilter.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyNode.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyVisitor.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/graph/Exclusion.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/graph/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallationException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/installation/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/metadata/AbstractMetadata.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/metadata/DefaultMetadata.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/metadata/MergeableMetadata.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/metadata/Metadata.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/metadata/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/ArtifactRepository.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/Authentication.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationContext.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationDigest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationSelector.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRegistration.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRegistration.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepository.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepositoryManager.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/MirrorSelector.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/NoLocalRepositoryManagerException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/Proxy.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/ProxySelector.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/RemoteRepository.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/RepositoryPolicy.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceReader.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceRepository.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/repository/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicy.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicyRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResolutionException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResolutionException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicy.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicyRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResolutionException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRequest.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResolutionException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResult.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/resolution/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/AbstractTransferListener.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactNotFoundException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactTransferException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/ChecksumFailureException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataNotFoundException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataTransferException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryConnectorException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryLayoutException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoTransporterException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/RepositoryOfflineException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferCancelledException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferEvent.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferListener.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferResource.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/transfer/package-info.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/version/InvalidVersionSpecificationException.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/version/Version.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/version/VersionConstraint.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/version/VersionRange.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/version/VersionScheme.java [new file with mode: 0644]
org.argeo.slc.repo/src/org/eclipse/aether/version/package-info.java [new file with mode: 0644]
org.argeo.slc.runtime/.classpath [new file with mode: 0644]
org.argeo.slc.runtime/.gitignore [new file with mode: 0644]
org.argeo.slc.runtime/.project [new file with mode: 0644]
org.argeo.slc.runtime/META-INF/.gitignore [new file with mode: 0644]
org.argeo.slc.runtime/bnd.bnd [new file with mode: 0644]
org.argeo.slc.runtime/build.properties [new file with mode: 0644]
org.argeo.slc.runtime/pom.xml [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/AbstractExecutionModulesManager.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgent.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgentCli.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionFlow.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionSpec.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionStack.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultProcess.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/ExecutionThread.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/InstantiationManager.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThread.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThreadGroup.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/CloseTestResult.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/Echo.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/If.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/JvmProcess.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCall.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCallOutputListener.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestData.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestDefinition.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/ContextUtils.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleResultPart.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestResult.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestRun.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SlcTestUtils.java [new file with mode: 0644]
org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java [new file with mode: 0644]
pom.xml

diff --git a/cms/org.argeo.slc.agent.jcr/.gitignore b/cms/org.argeo.slc.agent.jcr/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/cms/org.argeo.slc.agent.jcr/.project b/cms/org.argeo.slc.agent.jcr/.project
deleted file mode 100644 (file)
index 5aa7b5c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.agent.jcr</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <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>
-       </natures>
-</projectDescription>
diff --git a/cms/org.argeo.slc.agent.jcr/META-INF/.gitignore b/cms/org.argeo.slc.agent.jcr/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml b/cms/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml
deleted file mode 100644 (file)
index 848879f..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xmlns:util="http://www.springframework.org/schema/util"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/util\r
-       http://www.springframework.org/schema/util/spring-util-2.5.xsd">\r
-\r
-       <!-- REFERENCES -->\r
-       <reference id="repository" interface="javax.jcr.Repository"\r
-               filter="(cn=slc)" />\r
-\r
-<!--   <reference id="authenticationManager" -->\r
-<!--           interface="org.springframework.security.authentication.AuthenticationManager" /> -->\r
-\r
-       <reference id="modulesManager"\r
-               interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
-\r
-       <!-- SERVICES -->\r
-<!--   <service ref="attachmentUploader" interface="org.argeo.slc.core.attachment.AttachmentUploader" /> -->\r
-\r
-       <service interface="org.argeo.slc.execution.ExecutionModulesListener"\r
-               ref="executionModulesListener" />\r
-\r
-       <service ref="agent" interface="org.argeo.slc.execution.SlcAgent" />\r
-       <service ref="agentCli" interface="org.argeo.slc.execution.SlcAgentCli" />\r
-\r
-       <service ref="fileSystemManager" interface="org.apache.commons.vfs2.FileSystemManager" />\r
-</beans:beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.agent.jcr/META-INF/spring/jcr.xml b/cms/org.argeo.slc.agent.jcr/META-INF/spring/jcr.xml
deleted file mode 100644 (file)
index b15866d..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <bean id="agent" class="org.argeo.slc.jcr.execution.JcrAgent"\r
-               init-method="init" destroy-method="destroy">\r
-               <property name="defaultModulePrefix" value="org.argeo.slc.lib" />\r
-               <property name="repository" ref="repository" />\r
-               <property name="modulesManager" ref="modulesManager" />\r
-       </bean>\r
-\r
-       <bean id="agentCli" class="org.argeo.slc.core.execution.DefaultAgentCli">\r
-               <property name="agent" ref="agent" />\r
-<!--           <property name="authenticationManager" ref="authenticationManager" /> -->\r
-       </bean>\r
-\r
-       <bean id="executionModulesListener" class="org.argeo.slc.jcr.execution.JcrExecutionModulesListener"\r
-               init-method="init" destroy-method="destroy">\r
-               <property name="agent" ref="agent" />\r
-               <property name="repository" ref="repository" />\r
-               <property name="modulesManager" ref="modulesManager" />\r
-       </bean>\r
-\r
-       <!-- Thread-bound session is used when multiple threads with various authentication \r
-               will call the component -->\r
-<!--   <bean id="session" class="org.argeo.security.jcr.SecureThreadBoundSession"> -->\r
-<!--           <property name="repository" ref="repository" /> -->\r
-<!--   </bean> -->\r
-\r
-<!--   <bean id="attachmentUploader" class="org.argeo.slc.jcr.execution.JcrAttachmentUploader"> -->\r
-<!--   </bean> -->\r
-\r
-\r
-       <bean\r
-               class="org.argeo.slc.spring.AuthenticatedApplicationContextInitialization">\r
-       </bean>\r
-\r
-\r
-       <bean name="fileSystemManager" class="org.apache.commons.vfs2.impl.StandardFileSystemManager"\r
-               init-method="init" destroy-method="close" />\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.agent.jcr/bnd.bnd b/cms/org.argeo.slc.agent.jcr/bnd.bnd
deleted file mode 100644 (file)
index 00566cc..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-Import-Package: org.argeo.slc.jcr,\
-org.argeo.security.jackrabbit,\
-org.apache.commons.vfs2.provider.bzip2,\
-org.apache.commons.vfs2.provider.compressed,\
-org.apache.commons.vfs2.provider.ftp,\
-org.apache.commons.vfs2.provider.ftps,\
-org.apache.commons.vfs2.provider.gzip,\
-org.apache.commons.vfs2.provider.http,\
-org.apache.commons.vfs2.provider.https,\
-org.apache.commons.vfs2.provider.jar,\
-org.apache.commons.vfs2.provider.local,\
-org.apache.commons.vfs2.provider.ram,\
-org.apache.commons.vfs2.provider.res,\
-org.apache.commons.vfs2.provider.sftp,\
-org.apache.commons.vfs2.provider.tar,\
-org.apache.commons.vfs2.provider.url,\
-org.apache.commons.vfs2.provider.temp,\
-org.apache.commons.vfs2.provider.webdav,\
-org.apache.commons.vfs2.provider.zip,\
-org.osgi.*;version=0.0.0,\
-*
diff --git a/cms/org.argeo.slc.agent.jcr/build.properties b/cms/org.argeo.slc.agent.jcr/build.properties
deleted file mode 100644 (file)
index 7594fab..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-bin.includes = META-INF/,\
-               .
diff --git a/cms/org.argeo.slc.agent.jcr/pom.xml b/cms/org.argeo.slc.agent.jcr/pom.xml
deleted file mode 100644 (file)
index 3ce1ff9..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.agent.jcr</artifactId>
-       <name>SLC Agent JCR</name>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.agent/.gitignore b/cms/org.argeo.slc.agent/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/cms/org.argeo.slc.agent/.project b/cms/org.argeo.slc.agent/.project
deleted file mode 100644 (file)
index f167854..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.agent</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <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>
-       </natures>
-</projectDescription>
diff --git a/cms/org.argeo.slc.agent/META-INF/.gitignore b/cms/org.argeo.slc.agent/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.agent/META-INF/spring/agent.xml b/cms/org.argeo.slc.agent/META-INF/spring/agent.xml
deleted file mode 100644 (file)
index 1f8ca96..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <bean\r
-               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">\r
-               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />\r
-               <property name="locations">\r
-                       <value>osgibundle:agent.properties</value>\r
-               </property>\r
-       </bean>\r
-\r
-       <!-- Manager -->\r
-       <bean id="modulesManager" class="org.argeo.slc.osgi.OsgiExecutionModulesManager"\r
-               init-method="init" destroy-method="destroy">\r
-               <property name="bundlesManager" ref="bundlesManager" />\r
-       </bean>\r
-\r
-       <bean id="bundlesManager" class="org.argeo.slc.osgi.BundlesManager">\r
-               <property name="defaultTimeout" value="${slc.agent.osgi.defaultTimeout}" />\r
-       </bean>\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.agent/META-INF/spring/osgi.xml b/cms/org.argeo.slc.agent/META-INF/spring/osgi.xml
deleted file mode 100644 (file)
index 79d933c..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xmlns:util="http://www.springframework.org/schema/util"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <!-- REFERENCES -->\r
-       <!-- No <set> so that the equals methods are not called -->\r
-       <list id="executionContexts" interface="org.argeo.slc.execution.ExecutionContext"\r
-               cardinality="0..N">\r
-               <listener ref="modulesManager" bind-method="register"\r
-                       unbind-method="unregister" />\r
-       </list>\r
-\r
-       <list id="executionFlows" interface="org.argeo.slc.execution.ExecutionFlow"\r
-               cardinality="0..N">\r
-               <listener ref="modulesManager" bind-method="register"\r
-                       unbind-method="unregister" />\r
-       </list>\r
-\r
-       <list id="executionModulesListeners" interface="org.argeo.slc.execution.ExecutionModulesListener"\r
-               cardinality="0..N">\r
-               <listener ref="modulesManager" bind-method="register"\r
-                       unbind-method="unregister" />\r
-       </list>\r
-\r
-       <list id="executionFlowDescriptorConverters"\r
-               interface="org.argeo.slc.execution.ExecutionFlowDescriptorConverter"\r
-               cardinality="0..N">\r
-               <listener ref="modulesManager" />\r
-       </list>\r
-       <reference id="userTransaction" interface="javax.transaction.UserTransaction" />\r
-       <reference id="userAdmin" interface="org.osgi.service.useradmin.UserAdmin" />\r
-\r
-       <!-- SERVICES -->\r
-       <service ref="modulesManager" interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
-\r
-       <!-- LABEL -->\r
-<!--   <beans:bean class="org.argeo.cms.spring.osgi.OsgiModuleLabel"> -->\r
-<!--           <beans:property name="bundleContext" ref="bundleContext" /> -->\r
-<!--   </beans:bean> -->\r
-\r
-       <!-- ROLES -->\r
-<!--   <reference id="userAdminService" interface="org.argeo.security.UserAdminService" /> -->\r
-\r
-       <beans:bean class="org.argeo.maintenance.SimpleRoleRegistration"\r
-               init-method="run">\r
-               <beans:property name="role" value="org.argeo.slc.user" />\r
-               <beans:property name="userAdmin" ref="userAdmin" />\r
-               <beans:property name="userTransaction" ref="userTransaction" />\r
-<!--           <beans:property name="userAdminService" ref="userAdminService" /> -->\r
-       </beans:bean>\r
-</beans:beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.agent/agent.properties b/cms/org.argeo.slc.agent/agent.properties
deleted file mode 100644 (file)
index 4767d7c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-slc.agent.osgi.defaultTimeout=60000
diff --git a/cms/org.argeo.slc.agent/bnd.bnd b/cms/org.argeo.slc.agent/bnd.bnd
deleted file mode 100644 (file)
index 7f2410c..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Import-Package: org.osgi.*;version=0.0.0,\
-*
\ No newline at end of file
diff --git a/cms/org.argeo.slc.agent/build.properties b/cms/org.argeo.slc.agent/build.properties
deleted file mode 100644 (file)
index 7594fab..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-bin.includes = META-INF/,\
-               .
diff --git a/cms/org.argeo.slc.agent/pom.xml b/cms/org.argeo.slc.agent/pom.xml
deleted file mode 100644 (file)
index ffa15ab..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.agent</artifactId>
-       <name>SLC Agent</name>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.api/.classpath b/cms/org.argeo.slc.api/.classpath
deleted file mode 100644 (file)
index bc86c42..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" output="target/classes" path="src"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/cms/org.argeo.slc.api/.gitignore b/cms/org.argeo.slc.api/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/cms/org.argeo.slc.api/.project b/cms/org.argeo.slc.api/.project
deleted file mode 100644 (file)
index 301fef6..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.api</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.jdt.core.javanature</nature>
-               <nature>org.eclipse.pde.PluginNature</nature>
-       </natures>
-</projectDescription>
diff --git a/cms/org.argeo.slc.api/META-INF/.gitignore b/cms/org.argeo.slc.api/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.api/bnd.bnd b/cms/org.argeo.slc.api/bnd.bnd
deleted file mode 100644 (file)
index c3bac59..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Require-Capability: cms.datamodel;filter:="(name=ldap)",\
- cms.datamodel;filter:="(name=argeo)"
-
-Provide-Capability: cms.datamodel;name=slc;cnd=/org/argeo/slc/slc.cnd
diff --git a/cms/org.argeo.slc.api/build.properties b/cms/org.argeo.slc.api/build.properties
deleted file mode 100644 (file)
index 07891d9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-bin.includes = META-INF/,.\r
-source..=src/\r
diff --git a/cms/org.argeo.slc.api/pom.xml b/cms/org.argeo.slc.api/pom.xml
deleted file mode 100644 (file)
index a58999b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.api</artifactId>
-       <name>SLC API</name>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/BasicNameVersion.java b/cms/org.argeo.slc.api/src/org/argeo/slc/BasicNameVersion.java
deleted file mode 100644 (file)
index 61ed5eb..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.argeo.slc;
-
-import java.io.Serializable;
-
-/** @deprecated use {@link DefaultNameVersion} instead. */
-@Deprecated
-public class BasicNameVersion extends DefaultNameVersion implements
-               Serializable {
-       private static final long serialVersionUID = -5127304279136195127L;
-
-       public BasicNameVersion() {
-       }
-
-       /** Interprets string in OSGi-like format my.module.name;version=0.0.0 */
-       public BasicNameVersion(String nameVersion) {
-               int index = nameVersion.indexOf(";version=");
-               if (index < 0) {
-                       setName(nameVersion);
-                       setVersion(null);
-               } else {
-                       setName(nameVersion.substring(0, index));
-                       setVersion(nameVersion.substring(index + ";version=".length()));
-               }
-       }
-
-       public BasicNameVersion(String name, String version) {
-               super(name, version);
-       }
-
-       public BasicNameVersion(NameVersion nameVersion) {
-               super(nameVersion);
-       }
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java b/cms/org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java
deleted file mode 100644 (file)
index b335996..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.argeo.slc;
-
-/**
- * Adds a dimension to {@link NameVersion} by adding an arbitrary category (e.g.
- * Maven groupId, yum repository ID, etc.)
- */
-public interface CategoryNameVersion extends NameVersion {
-       /** The category of the component. */
-       String getCategory();
-
-       static CategoryNameVersion parseCategoryNameVersion(String str) {
-               if (str == null || "".equals(str.trim()))
-                       throw new IllegalArgumentException("At least one character required.");
-               String[] arr = str.trim().split(":");
-               if (arr.length > 3)
-                       throw new IllegalArgumentException(str + " does not respect the [category]:[name]:[version] pattern");
-               DefaultCategoryNameVersion res = new DefaultCategoryNameVersion();
-               res.setCategory(arr[0]);
-               if (arr.length > 1)
-                       res.setName(arr[1]);
-               if (arr.length > 2)
-                       res.setVersion(arr[2]);
-               return res;
-       }
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/Condition.java b/cms/org.argeo.slc.api/src/org/argeo/slc/Condition.java
deleted file mode 100644 (file)
index f476961..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.argeo.slc;
-
-/** Binary check on an arbitrary object. */
-public interface Condition<T> {
-       /**
-        * Checks the condition.
-        * 
-        * @return true, if the condition is verified, false if not.
-        */
-       public Boolean check(T obj);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/DefaultCategoryNameVersion.java b/cms/org.argeo.slc.api/src/org/argeo/slc/DefaultCategoryNameVersion.java
deleted file mode 100644 (file)
index 6506599..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.argeo.slc;
-
-/** Canonical implementation of {@link CategoryNameVersion} */
-public class DefaultCategoryNameVersion extends DefaultNameVersion implements CategoryNameVersion {
-       private String category;
-
-       public DefaultCategoryNameVersion() {
-       }
-
-       public DefaultCategoryNameVersion(String category, String name, String version) {
-               super(name, version);
-               this.category = category;
-       }
-
-       public DefaultCategoryNameVersion(String category, NameVersion nameVersion) {
-               super(nameVersion);
-               this.category = category;
-       }
-
-       @Override
-       public String getCategory() {
-               return category;
-       }
-
-       public void setCategory(String category) {
-               this.category = category;
-       }
-
-       @Override
-       public String toString() {
-               return category + ":" + super.toString();
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/DefaultNameVersion.java b/cms/org.argeo.slc.api/src/org/argeo/slc/DefaultNameVersion.java
deleted file mode 100644 (file)
index 61cc66e..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.argeo.slc;
-
-
-/** Canonical implementation of {@link NameVersion} */
-public class DefaultNameVersion implements NameVersion,
-               Comparable<NameVersion> {
-       private String name;
-       private String version;
-
-       public DefaultNameVersion() {
-       }
-
-       /** Interprets string in OSGi-like format my.module.name;version=0.0.0 */
-       public DefaultNameVersion(String nameVersion) {
-               int index = nameVersion.indexOf(";version=");
-               if (index < 0) {
-                       setName(nameVersion);
-                       setVersion(null);
-               } else {
-                       setName(nameVersion.substring(0, index));
-                       setVersion(nameVersion.substring(index + ";version=".length()));
-               }
-       }
-
-       public DefaultNameVersion(String name, String version) {
-               this.name = name;
-               this.version = version;
-       }
-
-       public DefaultNameVersion(NameVersion nameVersion) {
-               this.name = nameVersion.getName();
-               this.version = nameVersion.getVersion();
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       public void setVersion(String version) {
-               this.version = version;
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               if (obj instanceof NameVersion) {
-                       NameVersion nameVersion = (NameVersion) obj;
-                       return name.equals(nameVersion.getName())
-                                       && version.equals(nameVersion.getVersion());
-               } else
-                       return false;
-       }
-
-       @Override
-       public int hashCode() {
-               return name.hashCode();
-       }
-
-       @Override
-       public String toString() {
-               return name + ":" + version;
-       }
-
-       public int compareTo(NameVersion o) {
-               if (o.getName().equals(name))
-                       return version.compareTo(o.getVersion());
-               else
-                       return name.compareTo(o.getName());
-       }
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/ModuleSet.java b/cms/org.argeo.slc.api/src/org/argeo/slc/ModuleSet.java
deleted file mode 100644 (file)
index fd125a2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc;
-
-import java.util.Iterator;
-
-/** A set of {@link NameVersion}. */
-public interface ModuleSet {
-       Iterator<? extends NameVersion> nameVersions();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/NameVersion.java b/cms/org.argeo.slc.api/src/org/argeo/slc/NameVersion.java
deleted file mode 100644 (file)
index 1906049..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.argeo.slc;
-
-/**
- * Abstraction of a name / version pair, typically used as coordinates for a
- * software module either deployed or packaged as an archive.
- */
-public interface NameVersion {
-       /** The name of the component. */
-       public String getName();
-
-       /** The version of the component. */
-       public String getVersion();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java b/cms/org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java
deleted file mode 100644 (file)
index 7da9708..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.argeo.slc;
-
-/** Constants useful across all SLC components */
-public interface SlcConstants {
-       /** Read-write role. */
-       public final static String ROLE_SLC = "cn=org.argeo.slc.user,ou=roles,ou=node";
-
-       /** Read only unlogged user */
-       public final static String USER_ANONYMOUS = "anonymous";
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/SlcException.java b/cms/org.argeo.slc.api/src/org/argeo/slc/SlcException.java
deleted file mode 100644 (file)
index d2e5e2b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.argeo.slc;
-
-/** Basis for all SLC exceptions. This is an unchecked exception. */
-public class SlcException extends RuntimeException {
-       private static final long serialVersionUID = 6373738619304106445L;
-
-       /** Constructor. */
-       public SlcException(String message) {
-               super(message);
-       }
-
-       /** Constructor. */
-       public SlcException(String message, Throwable e) {
-               super(message, e);
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/SlcNames.java b/cms/org.argeo.slc.api/src/org/argeo/slc/SlcNames.java
deleted file mode 100644 (file)
index 557d479..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.argeo.slc;
-
-/** JCR names used by SLC */
-public interface SlcNames {
-       public final static String SLC_ = "slc:";
-
-       /*
-        * GENERAL
-        */
-       public final static String SLC_UUID = "slc:uuid";
-       public final static String SLC_STATUS = "slc:status";
-       // generic name for result parts of a given test result (slc:testResult)
-       // note that corresponding nodes can be retrieved using
-       // myTestResultNode.getNodes(SLC_RESULT_PART+"*") method
-       public final static String SLC_RESULT_PART = "slc:resultPart";
-       // Fixed name of the child node of a slc:testResult of type
-       // slc:check that aggregate status of all result parts of a given test
-       // result
-       public final static String SLC_AGGREGATED_STATUS = "slc:aggregatedStatus";
-
-       public final static String SLC_TYPE = "slc:type";
-       public final static String SLC_NAME = "slc:name";
-       public final static String SLC_VERSION = "slc:version";
-       public final static String SLC_CATEGORY = "slc:category";
-       public final static String SLC_VALUE = "slc:value";
-       public final static String SLC_ADDRESS = "slc:address";
-       public final static String SLC_METADATA = "slc:metadata";
-
-       public final static String SLC_TIMESTAMP = "slc:timestamp";
-       public final static String SLC_STARTED = "slc:started";
-       public final static String SLC_COMPLETED = "slc:completed";
-
-       public final static String SLC_VM = "slc:vm";
-       /*
-        * SLC RUNTIME
-        */
-       // execution
-       public final static String SLC_SPEC = "slc:spec";
-       public final static String SLC_EXECUTION_SPECS = "slc:executionSpecs";
-       public final static String SLC_FLOW = "slc:flow";
-       public final static String SLC_LOG = "slc:log";
-       public final static String SLC_AGENTS = "slc:agents";
-
-       // spec attribute
-       public final static String SLC_IS_IMMUTABLE = "slc:isImmutable";
-       public final static String SLC_IS_CONSTANT = "slc:isConstant";
-       public final static String SLC_IS_HIDDEN = "slc:isHidden";
-
-       // base directories
-       public final static String SLC_SYSTEM = "slc:system";
-       public final static String SLC_RESULTS = "slc:results";
-       public final static String SLC_MY_RESULTS = "slc:myResults";
-       public final static String SLC_PROCESSES = "slc:processes";
-
-       // result
-       public final static String SLC_SUCCESS = "slc:success";
-       public final static String SLC_MESSAGE = "slc:message";
-       public final static String SLC_TAG = "slc:tag";
-       public final static String SLC_ERROR_MESSAGE = "slc:errorMessage";
-       public final static String SLC_TEST_CASE = "slc:testCase";
-       public final static String SLC_TEST_CASE_TYPE = "slc:testCaseType";
-
-       // diff result
-       public final static String SLC_SUMMARY = "slc:summary";
-       public final static String SLC_ISSUES = "slc:issues";
-
-       /*
-        * SLC REPO
-        */
-       // shared
-       public final static String SLC_URL = "slc:url";
-       public final static String SLC_OPTIONAL = "slc:optional";
-       public final static String SLC_AS_STRING = "slc:asString";
-
-       // origin
-       public final static String SLC_ORIGIN = "slc:origin";
-       public final static String SLC_PROXY = "slc:proxy";
-
-       // slc:artifact
-       public final static String SLC_ARTIFACT_ID = "slc:artifactId";
-       public final static String SLC_GROUP_ID = "slc:groupId";
-       public final static String SLC_GROUP_BASE_ID = "slc:groupBaseId";
-       public final static String SLC_ARTIFACT_VERSION = "slc:artifactVersion";
-       public final static String SLC_ARTIFACT_EXTENSION = "slc:artifactExtension";
-       public final static String SLC_ARTIFACT_CLASSIFIER = "slc:artifactClassifier";
-
-       // slc:jarArtifact
-       public final static String SLC_MANIFEST = "slc:manifest";
-
-       // shared OSGi
-       public final static String SLC_SYMBOLIC_NAME = "slc:symbolic-name";
-       public final static String SLC_BUNDLE_VERSION = "slc:bundle-version";
-
-       // slc:osgiBaseVersion
-       public final static String SLC_MAJOR = "slc:major";
-       public final static String SLC_MINOR = "slc:minor";
-       public final static String SLC_MICRO = "slc:micro";
-       // slc:osgiVersion
-       public final static String SLC_QUALIFIER = "slc:qualifier";
-
-       // slc:exportedPackage
-       public final static String SLC_USES = "slc:uses";
-
-       // slc:modularDistribution
-       public final static String SLC_MODULES = "slc:modules";
-
-       // RPM
-       // slc:rpm
-       public final static String SLC_RPM_VERSION = "slc:rpmVersion";
-       public final static String SLC_RPM_RELEASE = "slc:rpmRelease";
-       public final static String SLC_RPM_ARCH = "slc:rpmArch";
-       public final static String SLC_RPM_ARCHIVE_SIZE = "slc:rpmArchiveSize";
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/SlcTypes.java b/cms/org.argeo.slc.api/src/org/argeo/slc/SlcTypes.java
deleted file mode 100644 (file)
index e0b86e6..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.argeo.slc;
-
-/** JCR node types used by SLC */
-public interface SlcTypes {
-
-       public final static String SLC_NAME_VERSION = "slc:nameVersion";
-       public final static String SLC_CATEGORIZED_NAME_VERSION = "slc:categorizedNameVersion";
-
-       public final static String SLC_AGENT_FACTORY = "slc:agentFactory";
-       public final static String SLC_AGENT = "slc:agent";
-       public final static String SLC_MODULE = "slc:module";
-       public final static String SLC_EXECUTION_MODULE = "slc:executionModule";
-       public final static String SLC_EXECUTION_SPEC = "slc:executionSpec";
-       public final static String SLC_EXECUTION_FLOW = "slc:executionFlow";
-       public final static String SLC_PROCESS = "slc:process";
-       public final static String SLC_REALIZED_FLOW = "slc:realizedFlow";
-
-       public final static String SLC_EXECUTION_SPEC_ATTRIBUTE = "slc:executionSpecAttribute";
-       public final static String SLC_PRIMITIVE_SPEC_ATTRIBUTE = "slc:primitiveSpecAttribute";
-       public final static String SLC_REF_SPEC_ATTRIBUTE = "slc:refSpecAttribute";
-
-       public final static String SLC_TEST_RESULT = "slc:testResult";
-       public final static String SLC_CHECK = "slc:check";
-       public final static String SLC_PROPERTY = "slc:property";
-       public final static String SLC_DIFF_RESULT = "slc:diffResult";
-
-       // Node types used for user defined and managed result UI tree
-       public final static String SLC_MY_RESULT_ROOT_FOLDER = "slc:myResultRootFolder";
-       public final static String SLC_RESULT_FOLDER = "slc:resultFolder";
-
-       // Log levels
-       public final static String SLC_LOG_ENTRY = "slc:logEntry";
-       public final static String SLC_LOG_TRACE = "slc:logTrace";
-       public final static String SLC_LOG_DEBUG = "slc:logDebug";
-       public final static String SLC_LOG_INFO = "slc:logInfo";
-       public final static String SLC_LOG_WARNING = "slc:logWarning";
-       public final static String SLC_LOG_ERROR = "slc:logError";
-
-       /*
-        * REPO
-        */
-       public final static String SLC_ARTIFACT = "slc:artifact";
-       public final static String SLC_ARTIFACT_VERSION_BASE = "slc:artifactVersion";
-       public final static String SLC_ARTIFACT_BASE = "slc:artifactBase";
-       public final static String SLC_GROUP_BASE = "slc:groupBase";
-       public final static String SLC_JAR_FILE = "slc:jarFile";
-       public final static String SLC_BUNDLE_ARTIFACT = "slc:bundleArtifact";
-       public final static String SLC_OSGI_VERSION = "slc:osgiVersion";
-       public final static String SLC_JAVA_PACKAGE = "slc:javaPackage";
-       public final static String SLC_EXPORTED_PACKAGE = "slc:exportedPackage";
-       public final static String SLC_IMPORTED_PACKAGE = "slc:importedPackage";
-       public final static String SLC_DYNAMIC_IMPORTED_PACKAGE = "slc:dynamicImportedPackage";
-       public final static String SLC_REQUIRED_BUNDLE = "slc:requiredBundle";
-       public final static String SLC_FRAGMENT_HOST = "slc:fragmentHost";
-
-       // Distribution management
-       // public final static String SLC_CATEGORY = "slc:category";
-       public final static String SLC_MODULAR_DISTRIBUTION_BASE = "slc:modularDistributionBase";
-       public final static String SLC_MODULAR_DISTRIBUTION = "slc:modularDistribution";
-       public final static String SLC_MODULE_COORDINATES = "slc:moduleCoordinates";
-
-       // origin
-       public final static String SLC_KNOWN_ORIGIN = "slc:knownOrigin";
-       public final static String SLC_PROXIED = "slc:proxied";
-
-       // rpm
-       public final static String SLC_RPM = "slc:rpm";
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/StreamReadable.java b/cms/org.argeo.slc.api/src/org/argeo/slc/StreamReadable.java
deleted file mode 100644 (file)
index f1bef22..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc;
-
-import java.io.InputStream;
-
-public interface StreamReadable {
-       public InputStream getInputStream();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/UnsupportedException.java b/cms/org.argeo.slc.api/src/org/argeo/slc/UnsupportedException.java
deleted file mode 100644 (file)
index aa050e3..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.argeo.slc;
-
-/** Exception for unsupported features or actions. */
-public class UnsupportedException extends SlcException {
-       static final long serialVersionUID = 1l;
-
-       /** Action not supported. */
-       public UnsupportedException() {
-               this("Action not supported");
-       }
-
-       /** Constructor with a message. */
-       public UnsupportedException(String message) {
-               super(message);
-       }
-
-       /**
-        * Constructor generating a message.
-        * 
-        * @param nature
-        *            the nature of the unsupported object
-        * @param obj
-        *            the object itself (its class name will be used in message)
-        */
-       public UnsupportedException(String nature, Object obj) {
-               super("Unsupported " + nature + ": "
-                               + (obj != null ? obj.getClass() : "[object is null]"));
-       }
-
-       /**
-        * Constructor generating a message.
-        * 
-        * @param nature
-        *            the nature of the unsupported object
-        * @param clss
-        *            the class itself (will be used in message)
-        */
-       public UnsupportedException(String nature, Class<?> clss) {
-               super("Unsupported " + nature + ": " + clss);
-       }
-
-       /**
-        * Constructor generating a message.
-        * 
-        * @param nature
-        *            the nature of the unsupported object
-        * @param value
-        *            the problematic value itself
-        */
-       public UnsupportedException(String nature, String value) {
-               super("Unsupported " + nature + ": " + value);
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/attachment/Attachment.java b/cms/org.argeo.slc.api/src/org/argeo/slc/attachment/Attachment.java
deleted file mode 100644 (file)
index 6573251..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.argeo.slc.attachment;
-
-public interface Attachment {
-       public String getUuid();
-
-       public void setUuid(String uuid);
-
-       public String getName();
-
-       public String getContentType();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsEnabled.java b/cms/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsEnabled.java
deleted file mode 100644 (file)
index 0b44e5b..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.attachment;
-
-public interface AttachmentsEnabled {
-       public void addAttachment(Attachment attachment);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsStorage.java b/cms/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsStorage.java
deleted file mode 100644 (file)
index 48cd0e6..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.attachment;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public interface AttachmentsStorage {
-       public void retrieveAttachment(Attachment attachment,
-                       OutputStream outputStream);
-
-       /** Does NOT close the provided input stream. */
-       public void storeAttachment(Attachment attachment, InputStream inputStream);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/build/Distribution.java b/cms/org.argeo.slc.api/src/org/argeo/slc/build/Distribution.java
deleted file mode 100644 (file)
index b438a8f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.build;\r
-\r
-/** A packaged software component */\r
-public interface Distribution {\r
-       public String getDistributionId();\r
-\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/build/License.java b/cms/org.argeo.slc.api/src/org/argeo/slc/build/License.java
deleted file mode 100644 (file)
index d115f45..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.build;
-
-/** A software license */
-public interface License {
-       public String getName();
-
-       public String getUri();
-
-       public String getLink();
-
-       public String getText();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/build/ModularDistribution.java b/cms/org.argeo.slc.api/src/org/argeo/slc/build/ModularDistribution.java
deleted file mode 100644 (file)
index 3c7f625..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.argeo.slc.build;
-
-import org.argeo.slc.ModuleSet;
-import org.argeo.slc.NameVersion;
-
-/**
- * A distribution of modules, that is components that can be identified by a
- * name / version couple.
- * 
- * @see NameVersion
- */
-public interface ModularDistribution extends Distribution, NameVersion,
-               ModuleSet {
-       public Distribution getModuleDistribution(String moduleName,
-                       String moduleVersion);
-
-       /** A descriptor such as P2, OBR or yum metadata. */
-       public Object getModulesDescriptor(String descriptorType);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/build/package.html b/cms/org.argeo.slc.api/src/org/argeo/slc/build/package.html
deleted file mode 100644 (file)
index 5da2052..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-SLC Build: building of software systems.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployEnvironment.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployEnvironment.java
deleted file mode 100644 (file)
index dd47369..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.argeo.slc.deploy;
-
-import java.io.File;
-import java.util.Map;
-
-public interface DeployEnvironment {
-       public void unpackTo(Object packg, File targetLocation,
-                       Map<String, String> filter);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystem.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystem.java
deleted file mode 100644 (file)
index be28154..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.argeo.slc.deploy;\r
-\r
-import org.argeo.slc.build.Distribution;\r
-\r
-/** An instance of a software system. */\r
-public interface DeployedSystem extends TargetData {\r
-       /** Unique ID for this system instance. */\r
-       public String getDeployedSystemId();\r
-\r
-       /** Underlying packages */\r
-       public Distribution getDistribution();\r
-\r
-       /** Data required to initialize the instance (e.g. DB dump, etc.). */\r
-       public DeploymentData getDeploymentData();\r
-\r
-       /** Resources required by the system (ports, disk location, etc.) */\r
-       public TargetData getTargetData();\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystemManager.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystemManager.java
deleted file mode 100644 (file)
index 411bcb6..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.deploy;
-
-public interface DeployedSystemManager<T extends DeployedSystem> {
-       public void setDeployedSystem(T deployedSystem);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/Deployment.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/Deployment.java
deleted file mode 100644 (file)
index 74be42a..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.argeo.slc.deploy;\r
-\r
-import org.argeo.slc.build.Distribution;\r
-\r
-public interface Deployment extends Runnable{\r
-       public DeployedSystem getDeployedSystem();\r
-\r
-       public void setTargetData(TargetData targetData);\r
-\r
-       public void setDeploymentData(DeploymentData deploymentData);\r
-\r
-       public void setDistribution(Distribution distribution);\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeploymentData.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DeploymentData.java
deleted file mode 100644 (file)
index 18e63f8..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.deploy;\r
-\r
-public interface DeploymentData {\r
-\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DynamicRuntime.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/DynamicRuntime.java
deleted file mode 100644 (file)
index ed29ce2..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.argeo.slc.deploy;
-
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.build.Distribution;
-
-public interface DynamicRuntime<M extends Module> extends
-               ModularDeployedSystem<M> {
-       public void shutdown();
-
-       public M installModule(Distribution distribution);
-
-       public void uninstallModule(NameVersion nameVersion);
-
-       public void updateModule(NameVersion nameVersion);
-
-       public void startModule(NameVersion nameVersion);
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/InstalledExecutables.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/InstalledExecutables.java
deleted file mode 100644 (file)
index 2d65a71..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.deploy;
-
-public interface InstalledExecutables extends DeployedSystem {
-       public String getExecutablePath(String key);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/ModularDeployedSystem.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/ModularDeployedSystem.java
deleted file mode 100644 (file)
index 18fd4fe..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc.deploy;
-
-import java.util.List;
-
-public interface ModularDeployedSystem<M extends Module> extends DeployedSystem {
-       /** List the underlying deployed modules (in real time) */
-       public List<M> listModules();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/Module.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/Module.java
deleted file mode 100644 (file)
index 10973c9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.deploy;
-
-import org.argeo.slc.NameVersion;
-
-/**
- * Represents a deployed module of a broader deployed system. A module is
- * uniquely identifiable via a name / version.
- */
-public interface Module extends DeployedSystem, NameVersion {
-       /** A serializable stateless description of the module */
-       public ModuleDescriptor getModuleDescriptor();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/ModuleDescriptor.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/ModuleDescriptor.java
deleted file mode 100644 (file)
index f1d6642..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.argeo.slc.deploy;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.DefaultNameVersion;
-
-/** The description of a versioned module. */
-public class ModuleDescriptor extends DefaultNameVersion implements Serializable {
-       private static final long serialVersionUID = 4310820315478645419L;
-       private String title;
-       private String description;
-       private Map<String, String> metadata = new HashMap<String, String>();
-       private Boolean started = false;
-
-       public String getTitle() {
-               return title;
-       }
-
-       public void setTitle(String title) {
-               this.title = title;
-       }
-
-       public String getDescription() {
-               return description;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-
-       /** @deprecated use {@link #getTitle()} instead */
-       public String getLabel() {
-               return title;
-       }
-
-       /** @deprecated use {@link #setTitle(String)} instead */
-       public void setLabel(String label) {
-               this.title = label;
-       }
-
-       public Map<String, String> getMetadata() {
-               return metadata;
-       }
-
-       public void setMetadata(Map<String, String> metadata) {
-               this.metadata = metadata;
-       }
-
-       public Boolean getStarted() {
-               return started;
-       }
-
-       public void setStarted(Boolean started) {
-               this.started = started;
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/ModulesManager.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/ModulesManager.java
deleted file mode 100644 (file)
index 1288592..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.argeo.slc.deploy;
-
-import java.util.List;
-
-import org.argeo.slc.NameVersion;
-
-/** Provides access to deployed modules */
-public interface ModulesManager {
-       /** @return a full fledged module descriptor. */
-       public ModuleDescriptor getModuleDescriptor(String moduleName,
-                       String version);
-
-       /**
-        * @return a list of minimal module descriptors of the deployed modules
-        */
-       public List<ModuleDescriptor> listModules();
-
-       /** Synchronously upgrades the module referenced by this name version */
-       public void upgrade(NameVersion nameVersion);
-
-       /** Starts the module */
-       public void start(NameVersion nameVersion);
-
-       /** Stops the module */
-       public void stop(NameVersion nameVersion);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/TargetData.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/TargetData.java
deleted file mode 100644 (file)
index f1c7e7d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.deploy;\r
-\r
-public interface TargetData {\r
-\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/VersioningDriver.java b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/VersioningDriver.java
deleted file mode 100644 (file)
index dba5797..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.argeo.slc.deploy;\r
-\r
-import java.io.File;\r
-import java.io.OutputStream;\r
-import java.util.List;\r
-\r
-/** Abstracts common versioning operations */\r
-public interface VersioningDriver {\r
-       public void getFileFromRepository(String repositoryBaseUrl,\r
-                       String location, OutputStream out);\r
-\r
-       public List<String> getChangedPaths(File repositoryRoot, Long revision);\r
-\r
-       public String getRepositoryRoot(String repositoryUrl);\r
-\r
-       public String getRelativePath(String repositoryUrl);\r
-\r
-       public void updateToHead(File fileOrDir);\r
-\r
-       public void importFileOrDir(String repositoryUrl, File fileOrDir);\r
-\r
-       /**\r
-        * Checks out or update this versioned directory\r
-        * \r
-        * @return true if the content has changed, false otherwise\r
-        */\r
-       public Boolean checkout(String repositoryUrl, File destDir,\r
-                       Boolean recursive);\r
-\r
-       public void createRepository(String filePath);\r
-\r
-       public void commit(File fileOrDir, String commitMessage);\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/package.html b/cms/org.argeo.slc.api/src/org/argeo/slc/deploy/package.html
deleted file mode 100644 (file)
index f3a4c5b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-SLC Deploy: deployment of software systems.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractExecutionValue.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractExecutionValue.java
deleted file mode 100644 (file)
index 7f63626..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.io.Serializable;
-
-/** Value to be used by an execution */
-public abstract class AbstractExecutionValue implements Serializable {
-       private static final long serialVersionUID = 1558444746120706961L;
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractSpecAttribute.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractSpecAttribute.java
deleted file mode 100644 (file)
index d720db6..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.io.Serializable;
-
-/** Canonical implementation of the execution spec attribute booleans. */
-public abstract class AbstractSpecAttribute implements ExecutionSpecAttribute,
-               Serializable {
-       private static final long serialVersionUID = 6494963738891709440L;
-       private Boolean isImmutable = false;
-       private Boolean isConstant = false;
-       private Boolean isHidden = false;
-
-       private String description;
-
-       /** Has to be set at instantiation */
-       public Boolean getIsImmutable() {
-               return isImmutable;
-       }
-
-       public void setIsImmutable(Boolean isImmutable) {
-               this.isImmutable = isImmutable;
-       }
-
-       /** Cannot be overridden at runtime */
-       public Boolean getIsConstant() {
-               return isConstant;
-       }
-
-       public void setIsConstant(Boolean isConstant) {
-               this.isConstant = isConstant;
-       }
-
-       /** Should not be shown to the end user */
-       public Boolean getIsHidden() {
-               return isHidden;
-       }
-
-       public void setIsHidden(Boolean isHidden) {
-               this.isHidden = isHidden;
-       }
-
-       /*
-        * DEPRECATED
-        */
-       /** @deprecated use {@link #getIsImmutable()} instead */
-       public Boolean getIsParameter() {
-               return isImmutable;
-       }
-
-       /** @deprecated use {@link #getIsConstant()} instead */
-       public Boolean getIsFrozen() {
-               return isConstant;
-       }
-
-       /** @deprecated use {@link #setIsImmutable(Boolean)} instead */
-       public void setIsParameter(Boolean isParameter) {
-               this.isImmutable = isParameter;
-       }
-
-       /** @deprecated use {@link #setIsConstant(Boolean)} instead */
-       public void setIsFrozen(Boolean isFrozen) {
-               this.isConstant = isFrozen;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-
-       public String getDescription() {
-               return description;
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionContext.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionContext.java
deleted file mode 100644 (file)
index 46c448f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.argeo.slc.execution;\r
-\r
-/** Variables or references attached to an execution (typically thread bounded).*/\r
-public interface ExecutionContext {\r
-       public final static String VAR_EXECUTION_CONTEXT_ID = "slcVar.executionContext.id";\r
-       public final static String VAR_EXECUTION_CONTEXT_CREATION_DATE = "slcVar.executionContext.creationDate";\r
-       public final static String VAR_FLOW_ID = "slcVar.flow.id";\r
-       public final static String VAR_FLOW_NAME = "slcVar.flow.name";\r
-\r
-       public String getUuid();\r
-\r
-       /** @return the variable value, or <code>null</code> if not found. */\r
-       public Object getVariable(String key);\r
-\r
-       public void setVariable(String key, Object value);\r
-       \r
-       public void beforeFlow(ExecutionFlow executionFlow);\r
-       \r
-       public void afterFlow(ExecutionFlow executionFlow);\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlow.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlow.java
deleted file mode 100644 (file)
index 7dd3a74..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.util.Iterator;
-
-/** Abstraction of an execution that can be identified and configured. */
-public interface ExecutionFlow extends Runnable {
-       /** Retrieve an immutable parameter */
-       public Object getParameter(String key);
-
-       /** Whether this immutable parameter is set */
-       public Boolean isSetAsParameter(String key);
-
-       /** The specifications of the execution flow. */
-       public ExecutionSpec getExecutionSpec();
-
-       /**
-        * List sub-runnables that would be executed if run() method would be
-        * called.
-        */
-       public Iterator<Runnable> runnables();
-
-       /**
-        * If there is one and only one runnable wrapped return it, throw an
-        * exception otherwise.
-        */
-       public Runnable getRunnable();
-
-       /**
-        * The name of this execution flow. Can contains '/' which will be
-        * interpreted by UIs as a hierarchy;
-        */
-       public String getName();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptor.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptor.java
deleted file mode 100644 (file)
index d38bb85..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 
- * Implements both archetype and implementation of a given process.
- * 
- * At specification time, <code>executionSpec</code> represents the spec of the
- * parameters accepted by the process, with, among others: type, default value
- * and, optionally, possible values for each parameter. Thus ExecutionSpec might
- * be a huge object. Note that when marshalling only a reference to a specific
- * ExecutionSpec is stored in the XML to optimize performance and avoid
- * redundancy between various ExecutionFlowDesciptor that might have the same
- * ExecutionSpec.
- * 
- * At runtime, we build a RealizedFlow which references an
- * ExecutionFlowDescriptor. As it happens AFTER marshalling / unmarshalling
- * process, the ExecutionSpec is null but we manage to retrieve the
- * ExecutionSpec and store it in the RealizedFlow, whereas set values of the
- * parameters are stored in the <code>values</code> map.
- * 
- * Generally, values object are either a <code>PrimitiveAccessor</code> or a
- * <code>RefValue</code> but can be other objects.
- */
-public class ExecutionFlowDescriptor implements Serializable, Cloneable {
-       private static final long serialVersionUID = 7101944857038041216L;
-       private String name;
-       private String description;
-       private String path;
-       private Map<String, Object> values;
-       private ExecutionSpec executionSpec;
-
-       public ExecutionFlowDescriptor() {
-       }
-
-       public ExecutionFlowDescriptor(String name, String description,
-                       Map<String, Object> values, ExecutionSpec executionSpec) {
-               this.name = name;
-               this.values = values;
-               this.executionSpec = executionSpec;
-       }
-
-       /** The referenced {@link ExecutionSpec} is NOT cloned. */
-       @Override
-       protected Object clone() throws CloneNotSupportedException {
-               return new ExecutionFlowDescriptor(name, description,
-                               new HashMap<String, Object>(values), executionSpec);
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       /**
-        * @deprecated will be removed in SLC 2.x, the path should be the part of
-        *             the name with '/'
-        */
-       public String getPath() {
-               return path;
-       }
-
-       /**
-        * @deprecated will be removed in SLC 2.0, the path should be the part of
-        *             the name with '/'
-        */
-       public void setPath(String path) {
-               this.path = path;
-       }
-
-       public Map<String, Object> getValues() {
-               return values;
-       }
-
-       public ExecutionSpec getExecutionSpec() {
-               return executionSpec;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public void setValues(Map<String, Object> values) {
-               this.values = values;
-       }
-
-       public void setExecutionSpec(ExecutionSpec executionSpec) {
-               this.executionSpec = executionSpec;
-       }
-
-       public String getDescription() {
-               return description;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               if (obj instanceof ExecutionFlowDescriptor)
-                       return name.equals(((ExecutionFlowDescriptor) obj).getName());
-               return false;
-       }
-
-       @Override
-       public int hashCode() {
-               return name.hashCode();
-       }
-
-       @Override
-       public String toString() {
-               return (path != null && !path.trim().equals("") ? path + "/" : "")
-                               + name;
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptorConverter.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptorConverter.java
deleted file mode 100644 (file)
index 13ff638..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.util.Map;
-
-/**
- * Maps back and forth between {@link ExecutionFlowDescriptor} and
- * {@link ExecutionFlow}
- */
-public interface ExecutionFlowDescriptorConverter {
-       public Map<String, Object> convertValues(
-                       ExecutionFlowDescriptor executionFlowDescriptor);
-
-       public void addFlowsToDescriptor(ExecutionModuleDescriptor md,
-                       Map<String, ExecutionFlow> executionFlows);
-
-       public ExecutionFlowDescriptor getExecutionFlowDescriptor(
-                       ExecutionFlow executionFlow);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModule.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModule.java
deleted file mode 100644 (file)
index 11021f6..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.execution;
-
-@Deprecated
-public interface ExecutionModule {
-/*     public String getName();
-
-       public String getVersion();
-       
-       public ExecutionModuleDescriptor getDescriptor();
-
-       public void execute(ExecutionFlowDescriptor descriptor);*/
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModuleDescriptor.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModuleDescriptor.java
deleted file mode 100644 (file)
index cad6efb..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.deploy.ModuleDescriptor;
-
-/** Describes the information required to launch a flow */
-public class ExecutionModuleDescriptor extends ModuleDescriptor {
-       /** Metadata header identifying an SLC execution module */
-       public final static String SLC_EXECUTION_MODULE = "SLC-ExecutionModule";
-
-       private static final long serialVersionUID = -2394473464513029512L;
-       private List<ExecutionSpec> executionSpecs = new ArrayList<ExecutionSpec>();
-       private List<ExecutionFlowDescriptor> executionFlows = new ArrayList<ExecutionFlowDescriptor>();
-
-       public List<ExecutionSpec> getExecutionSpecs() {
-               return executionSpecs;
-       }
-
-       public List<ExecutionFlowDescriptor> getExecutionFlows() {
-               return executionFlows;
-       }
-
-       /**
-        * Returns a new {@link ExecutionModuleDescriptor} that can be used to build
-        * a {@link RealizedFlow}.
-        */
-       public ExecutionFlowDescriptor cloneFlowDescriptor(String name) {
-               ExecutionFlowDescriptor res = null;
-               for (ExecutionFlowDescriptor efd : executionFlows) {
-                       if (efd.getName().equals(name)
-                                       || ("/" + efd.getName()).equals(name)) {
-                               try {
-                                       res = (ExecutionFlowDescriptor) efd.clone();
-                               } catch (CloneNotSupportedException e) {
-                                       throw new SlcException("Cannot clone " + efd, e);
-                               }
-                       }
-               }
-               if (res == null)
-                       throw new SlcException("Flow " + name + " not found.");
-               return res;
-       }
-
-       public RealizedFlow asRealizedFlow(String flow, Map<String, Object> values) {
-               RealizedFlow realizedFlow = new RealizedFlow();
-               realizedFlow.setFlowDescriptor(cloneFlowDescriptor(flow));
-               realizedFlow.setModuleName(getName());
-               realizedFlow.setModuleVersion(getVersion());
-               realizedFlow.getFlowDescriptor().getValues().putAll(values);
-               return realizedFlow;
-       }
-
-       public void setExecutionSpecs(List<ExecutionSpec> executionSpecs) {
-               this.executionSpecs = executionSpecs;
-       }
-
-       public void setExecutionFlows(List<ExecutionFlowDescriptor> executionFlows) {
-               this.executionFlows = executionFlows;
-       }
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesListener.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesListener.java
deleted file mode 100644 (file)
index aa0b16d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.argeo.slc.execution;
-
-import org.argeo.slc.deploy.ModuleDescriptor;
-
-/** Listen to events on execution modules. */
-public interface ExecutionModulesListener {
-       public void executionModuleAdded(ModuleDescriptor moduleDescriptor);
-
-       public void executionModuleRemoved(ModuleDescriptor moduleDescriptor);
-
-       public void executionFlowAdded(ModuleDescriptor moduleDescriptor,
-                       ExecutionFlowDescriptor executionFlowDescriptor);
-
-       public void executionFlowRemoved(ModuleDescriptor moduleDescriptor,
-                       ExecutionFlowDescriptor executionFlowDescriptor);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesManager.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesManager.java
deleted file mode 100644 (file)
index 1cedd12..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.util.List;
-
-import org.argeo.slc.deploy.ModulesManager;
-
-/** Provides access to the execution modules */
-public interface ExecutionModulesManager extends ModulesManager {
-       /** Used to filter event notified to an execution notifier. */
-       public static String SLC_PROCESS_ID = "slc.process.id";
-
-       /** Unique launch module */
-       public static String UNIQUE_LAUNCH_MODULE_PROPERTY = "slc.launch.module";
-
-       /** Unique launch flow */
-       public static String UNIQUE_LAUNCH_FLOW_PROPERTY = "slc.launch.flow";
-
-       /** @return a full fledged module descriptor. */
-       public ExecutionModuleDescriptor getExecutionModuleDescriptor(
-                       String moduleName, String version);
-
-       /**
-        * @return a list of minimal execution module descriptors (only the module
-        *         meta data, not the flows)
-        */
-       public List<ExecutionModuleDescriptor> listExecutionModules();
-
-       /** Synchronously finds and executes an {@link ExecutionFlow}. */
-       public void execute(RealizedFlow realizedFlow);
-
-       // /** Notify of a status update status of the {@link ExecutionProcess} */
-//      public void dispatchUpdateStatus(ExecutionProcess process,
-//      String oldStatus, String newStatus);
-       //
-       // /** Notify that a step was added in an {@link ExecutionProcess} */
-       // public void dispatchAddSteps(ExecutionProcess process,
-       // List<ExecutionStep> steps);
-       //
-       // /**
-       // * Register a notifier which will be notified based on the provided
-       // * properties.
-       // */
-       // public void registerProcessNotifier(ExecutionProcessNotifier notifier,
-       // Map<String, String> properties);
-       //
-       // /** Unregisters a notifier */
-       // public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
-       // Map<String, String> properties);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionProcess.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionProcess.java
deleted file mode 100644 (file)
index d894e1c..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.util.List;
-
-/**
- * A process is the functional representation of a combination of executions.
- * While an execution is the actual java code running, a process exists before,
- * during and after the execution actually took place, providing an entry point
- * for the definition of executions, their monitoring (e.g. logging) and
- * tracking. A process can be distributed or parallelized. <br/>
- * NEW => INITIALIZED => SCHEDULED => RUNNING<br/>
- * RUNNING => {COMPLETED | ERROR | KILLED}<br/>
- * {COMPLETED | ERROR | KILLED} => PURGED<br/>
- * UNKOWN : this is a bug if this status occurs<br/>
- */
-public interface ExecutionProcess {
-       /** The process is not yet usable. */
-       public final static String NEW = "NEW";
-       /** The process is usable but not yet scheduled to run. */
-       public final static String INITIALIZED = "INITIALIZED";
-       /** The process is usable and scheduled to run, but not yet running. */
-       public final static String SCHEDULED = "SCHEDULED";
-       /** The process is currently running. */
-       public final static String RUNNING = "RUNNING";
-       /** The process has properly completed. */
-       public final static String COMPLETED = "COMPLETED";
-       /** The process failed because of an unexpected error. */
-       public final static String ERROR = "ERROR";
-       /** The process was killed explicitly or through a crash. */
-       public final static String KILLED = "KILLED";
-       /** The status cannot be retrieved (probably because of unexpected errors). */
-       public final static String UNKOWN = "UNKOWN";
-
-       /**
-        * Only a reference to the process has been kept, all monitoring data such
-        * as logs have been purged.
-        */
-       public final static String PURGED = "PURGED";
-
-       /** The UUID of this process. */
-       public String getUuid();
-
-       /** The current status of this process. */
-       public String getStatus();
-
-       /** Sets the current status of this process */
-       public void setStatus(String status);
-
-       public void addSteps(List<ExecutionStep> steps);
-
-       public List<RealizedFlow> getRealizedFlows();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionResources.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionResources.java
deleted file mode 100644 (file)
index 9ddbca9..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.io.File;
-import java.nio.file.Path;
-
-/** Provides write access to resources during execution */
-public interface ExecutionResources {
-       /** The base directory where this execution can write */
-       public File getWritableBaseDir();
-
-       /** Allocates a local file in the writable area and return it as a resource. */
-       public Path getWritableResource(String relativePath);
-
-       /**
-        * Allocates a local file in the writable area and return it as a fully
-        * qualified OS path.
-        */
-       public String getWritableOsPath(String relativePath);
-
-       /**
-        * Allocates a local file in the writable area and return it as a {@link File}.
-        */
-       public File getWritableOsFile(String relativePath);
-
-       /**
-        * Returns the resource as a file path. If the resource is not writable it is
-        * copied as a file in the writable area and the path to this local file is
-        * returned.
-        */
-       public String getAsOsPath(Path resource, Boolean overwrite);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpec.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpec.java
deleted file mode 100644 (file)
index 0037b6d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.util.Map;
-
-/**
- * The class implementing this interface defines the map of attributes that are
- * necessary for the corresponding ExecutionFlow.
- */
-public interface ExecutionSpec {
-       /**
-        * The name for an internal spec (for backward compatibility where a
-        * non-null name is expected)
-        */
-       public final static String INTERNAL_NAME = "__SLC_EXECUTION_SPEC_INTERNAL";
-
-       /**
-        * The name identifying the execution spec within its application context.
-        * Can be null. An execution spec can be referenced only if its name is not
-        * null or different from {@link #INTERNAL_NAME}
-        */
-       public String getName();
-
-       /** An optional description. Can be null. */
-       public String getDescription();
-
-       /** The attributes managed by this execution spec */
-       public Map<String, ExecutionSpecAttribute> getAttributes();
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpecAttribute.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpecAttribute.java
deleted file mode 100644 (file)
index 39f87d9..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.argeo.slc.execution;
-
-/**
- * Possible attribute of an execution flow.
- * 
- * There are mainly two implementations :<br>
- * + Primitive attributes (no predefined choice, the end user must compute a
- * String, a Float, an Integer...)<br>
- * + RefSpecAttribute which enable two things<br>
- * ++ a reference to another object of the application context<br>
- * ++ the display of some choices among which the end user can choose.<br>
- * 
- * @see org.argeo.slc.core.execution.PrimitiveSpecAttribute
- * @see org.argeo.slc.core.execution.RefSpecAttribute
- * @see org.argeo.slc.core.execution.PrimitiveUtils : this class offers some
- *      helper, among others to cast the various type of primitive attribute.
- */
-public interface ExecutionSpecAttribute {
-       /**
-        * Whether this attribute has to be set at instantiation of the flow and
-        * cannot be modified afterwards. If the attribute is not immutable (that
-        * is, this method returns false), it can be set at execution time.
-        */
-       public Boolean getIsImmutable();
-
-       /**
-        * Whether this attribute must be explicitly set and cannot be modified.
-        * This attribute is then basically a constant within a given application
-        * context. {@link #getValue()} cannot return null if the attribute is a
-        * constant.
-        */
-       public Boolean getIsConstant();
-
-       /** Whether this attribute will be hidden to end users. */
-       public Boolean getIsHidden();
-
-       /**
-        * The default value for this attribute. Can be null, except if
-        * {@link #getIsFrozen()} is <code>true</code>, in which case it represents
-        * the constant value of this attribute.
-        */
-       public Object getValue();
-
-       /** Description of this attribute, can be null */
-       public String getDescription();
-
-       /** @deprecated use {@link #getIsImmutable()} instead */
-       public Boolean getIsParameter();
-
-       /** @deprecated use {@link #getIsConstant()} instead */
-       public Boolean getIsFrozen();
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStack.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStack.java
deleted file mode 100644 (file)
index 0a15e33..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.argeo.slc.execution;
-
-/** Deal with nested level of executions using different variables. */
-public interface ExecutionStack {
-       /**
-        * @param name
-        * @return null if no object is found
-        */
-       public Object findScopedObject(String name);
-
-       public void addScopedObject(String name, Object obj);
-
-       public void enterFlow(ExecutionFlow executionFlow);
-
-       /** @return internal stack level UUID. */
-       public String getCurrentStackLevelUuid();
-
-       public Integer getStackSize();
-
-       public void leaveFlow(ExecutionFlow executionFlow);
-
-       Object findLocalVariable(String key);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStackLevel.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStackLevel.java
deleted file mode 100644 (file)
index 790404b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.util.Map;
-
-public interface ExecutionStackLevel {
-       public ExecutionFlow getExecutionFlow();
-
-       public Map<String, Object> getScopedObjects();
-
-       public String getUuid();
-
-       public Map<String, Object> getLocalVariables();
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStep.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStep.java
deleted file mode 100644 (file)
index 47c6918..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.argeo.slc.execution;\r
-\r
-import java.io.Serializable;\r
-import java.util.Date;\r
-\r
-/**\r
- * An atomic step to be notified in during an {@link ExecutionProcess}. Can be a\r
- * log or the start/end of a phase, etc.\r
- */\r
-public class ExecutionStep implements Serializable {\r
-       private static final long serialVersionUID = 798640526532912161L;\r
-\r
-       public final static String PHASE_START = "PHASE_START";\r
-       public final static String PHASE_END = "PHASE_END";\r
-       public final static String ERROR = "ERROR";\r
-       public final static String WARNING = "WARNING";\r
-       public final static String INFO = "INFO";\r
-       public final static String DEBUG = "DEBUG";\r
-       public final static String TRACE = "TRACE";\r
-\r
-       /** @deprecated */\r
-       public final static String START = "START";\r
-       /** @deprecated */\r
-       public final static String END = "END";\r
-\r
-       // TODO make the fields final and private when we don't need POJO support\r
-       // anymore (that\r
-       // is when SlcExecutionStep is removed)\r
-       protected String type;\r
-       protected String thread;\r
-       protected Date timestamp;\r
-       protected String log;\r
-\r
-       private String location;\r
-\r
-       /** Empty constructor */\r
-       public ExecutionStep() {\r
-               Thread currentThread = Thread.currentThread();\r
-               thread = currentThread.getName();\r
-       }\r
-\r
-       /** Creates a step at the current date */\r
-       public ExecutionStep(String location, String type, String log) {\r
-               this(location, new Date(), type, log);\r
-       }\r
-\r
-       /** Creates a step of the given type. */\r
-       public ExecutionStep(String location, Date timestamp, String type,\r
-                       String log) {\r
-               this(location, timestamp, type, log, Thread.currentThread().getName());\r
-       }\r
-\r
-       public ExecutionStep(String location, Date timestamp, String type,\r
-                       String log, String thread) {\r
-               this.location = location;\r
-               this.type = type;\r
-               this.timestamp = timestamp;\r
-               this.thread = thread;\r
-               this.log = addLog(log);\r
-       }\r
-\r
-       public String getType() {\r
-               return type;\r
-       }\r
-\r
-       public Date getTimestamp() {\r
-               return timestamp;\r
-       }\r
-\r
-       public String getThread() {\r
-               return thread;\r
-       }\r
-\r
-       /**\r
-        * Return the string that should be stored in the log field. Can be null if\r
-        * another mechanism is used to store log lines.\r
-        */\r
-       protected String addLog(String log) {\r
-               return log;\r
-       }\r
-\r
-       public String getLog() {\r
-               return log;\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               return "Execution step, thread=" + thread + ", type=" + type;\r
-       }\r
-\r
-       /** Typically the logging category */\r
-       public String getLocation() {\r
-               return location;\r
-       }\r
-\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/FlowConfigurationException.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/FlowConfigurationException.java
deleted file mode 100644 (file)
index d476483..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.execution;
-
-import org.argeo.slc.SlcException;
-
-/** The stack trace of such exceptions does not need to be displayed */
-public class FlowConfigurationException extends SlcException {
-       private static final long serialVersionUID = 8456260596346797321L;
-
-       public FlowConfigurationException(String message) {
-               super(message);
-       }
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/RealizedFlow.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/RealizedFlow.java
deleted file mode 100644 (file)
index c1290a9..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-
-/** A fully configured execution flow, ready to be executed. */
-public class RealizedFlow implements Serializable {
-       private static final long serialVersionUID = 1L;
-
-       private String moduleName;
-       private String moduleVersion;
-       private ExecutionFlowDescriptor flowDescriptor;
-
-       public String getModuleName() {
-               return moduleName;
-       }
-
-       public void setModuleName(String moduleName) {
-               this.moduleName = moduleName;
-       }
-
-       public NameVersion getModuleNameVersion() {
-               return new DefaultNameVersion(getModuleName(), getModuleVersion());
-       }
-
-       public String getModuleVersion() {
-               return moduleVersion;
-       }
-
-       public void setModuleVersion(String moduleVersion) {
-               this.moduleVersion = moduleVersion;
-       }
-
-       public ExecutionFlowDescriptor getFlowDescriptor() {
-               return flowDescriptor;
-       }
-
-       public void setFlowDescriptor(ExecutionFlowDescriptor flowDescriptor) {
-               this.flowDescriptor = flowDescriptor;
-       }
-
-       /** Create a simple realized flow */
-       public static RealizedFlow create(String module, String version,
-                       String flowName, Map<String, String> args) {
-               final RealizedFlow realizedFlow = new RealizedFlow();
-               realizedFlow.setModuleName(module);
-               // TODO deal with version
-               if (version == null)
-                       version = "0.0.0";
-               realizedFlow.setModuleVersion(version);
-               ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
-               efd.setName(flowName);
-
-               // arguments
-               if (args != null && args.size() > 0) {
-                       Map<String, Object> values = new HashMap<String, Object>();
-                       for (String key : args.keySet()) {
-                               String value = args.get(key);
-                               values.put(key, value);
-                       }
-                       efd.setValues(values);
-               }
-
-               realizedFlow.setFlowDescriptor(efd);
-               return realizedFlow;
-       }
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/RefSpecAttribute.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/RefSpecAttribute.java
deleted file mode 100644 (file)
index b9bded0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.util.List;
-
-/** A spec attribute whose value is a reference to a full fledged object. */
-public class RefSpecAttribute extends AbstractSpecAttribute implements
-               Cloneable {
-       private static final long serialVersionUID = -3427797452955753574L;
-       private transient Class<?> targetClass = String.class;
-       /** Read only. */
-       private String targetClassName;
-       private transient Object value = null;
-
-       /** List to be chosen from */
-       private List<RefValueChoice> choices = null;
-
-       public Object getValue() {
-               return value;
-       }
-
-       public void setValue(Object value) {
-               this.value = value;
-       }
-
-       /** Default is {@link String} */
-       public Class<?> getTargetClass() {
-               return targetClass;
-       }
-
-       public void setTargetClass(Class<?> targetClass) {
-               this.targetClass = targetClass;
-               this.targetClassName = targetClass.getName();
-       }
-
-       public String getTargetClassName() {
-               return targetClassName;
-       }
-
-       /** @return can be null */
-       public List<RefValueChoice> getChoices() {
-               return choices;
-       }
-
-       public void setChoices(List<RefValueChoice> choices) {
-               this.choices = choices;
-       }
-
-       @Override
-       protected Object clone() throws CloneNotSupportedException {
-               RefSpecAttribute rsa = new RefSpecAttribute();
-               rsa.setTargetClass(targetClass);
-               rsa.setChoices(choices);
-               return rsa;
-       }
-
-       @Override
-       public String toString() {
-               return "Ref spec attribute [" + targetClass + "]"
-                               + (value != null ? "=" + value : "");
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/RefValue.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/RefValue.java
deleted file mode 100644 (file)
index 02be2a6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.argeo.slc.execution;
-
-/** Reference value to be used by an execution */
-public class RefValue extends AbstractExecutionValue {
-       private static final long serialVersionUID = -8951231456757181687L;
-       private String ref;
-       private String type;
-
-       public RefValue() {
-       }
-
-       public RefValue(String ref) {
-               super();
-               this.ref = ref;
-       }
-
-       public String getRef() {
-               return ref;
-       }
-
-       public void setRef(String ref) {
-               this.ref = ref;
-       }
-
-       public String getType() {
-               return type;
-       }
-
-       public void setType(String type) {
-               this.type = type;
-       }
-
-       @Override
-       public String toString() {
-               return "Ref Value [" + type + "=" + ref + "]";
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/RefValueChoice.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/RefValueChoice.java
deleted file mode 100644 (file)
index c4c403e..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.io.Serializable;
-
-/** A choice of ref value to be shown to the end user. */
-public class RefValueChoice implements Serializable {
-       private static final long serialVersionUID = -1133645722307507774L;
-       private String name;
-       private String description;
-
-       public RefValueChoice() {
-       }
-
-       public RefValueChoice(String name, String description) {
-               this.name = name;
-               this.description = description;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public String getDescription() {
-               return description;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgent.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgent.java
deleted file mode 100644 (file)
index 039724f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.argeo.slc.execution;
-
-import java.net.URI;
-import java.util.List;
-
-/**
- * A local agent can run SLC processes. It is responsible for creating their
- * threads and integrating them with various UIs. It typically wraps
- * {@link ExecutionModulesManager} which is used to run flows synchronously at a
- * lower level.
- */
-public interface SlcAgent {
-       /** Agent unique identifier */
-       public String getAgentUuid();
-
-       /** Execute / take part to this process */
-       public void process(ExecutionProcess process);
-
-       /**
-        * Asynchronously processes the flows defined as URIs, or interpret a single
-        * UUID URN as a scheduled or template process.
-        * 
-        * @return the UUID of the process launched.
-        */
-       public String process(List<URI> uris);
-
-       /** Kills this process */
-       public void kill(String processUuid);
-
-       /**
-        * Wait for this process to finish. returns immediately if it does not
-        * exist.
-        * 
-        * @param millis
-        *            can be null
-        */
-       public void waitFor(String processUuid, Long millis);
-
-       /**
-        * Describe all the flows provided by this execution module. Typically
-        * called in order to build a realized flow.
-        */
-       public ExecutionModuleDescriptor getExecutionModuleDescriptor(
-                       String moduleName, String version);
-
-       /** List all execution modules which can be processed by this agent. */
-       public List<ExecutionModuleDescriptor> listExecutionModuleDescriptors();
-
-       /** @return true if still alive. */
-       public boolean ping();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgentCli.java b/cms/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgentCli.java
deleted file mode 100644 (file)
index 497d110..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.argeo.slc.execution;
-
-/**
- * Interpret a command line and run it in the underlying agent, with the proper
- * authentication.
- */
-public interface SlcAgentCli {
-       /**
-        * Synchronously executes.
-        * 
-        * @return the UUID of the process
-        */
-       public String process(String[] args);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/package.html b/cms/org.argeo.slc.api/src/org/argeo/slc/package.html
deleted file mode 100644 (file)
index db808c8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-Common classes of teh SLC framework.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveAccessor.java b/cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveAccessor.java
deleted file mode 100644 (file)
index b3f87ba..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.argeo.slc.primitive;
-
-/** Abstraction of access to primitive values */
-public interface PrimitiveAccessor {
-       public final static String TYPE_STRING = "string";
-       /**
-        * As of Argeo 1, passwords are NOT stored encrypted, just hidden in the UI,
-        * but stored in plain text in JCR. Use keyring instead.
-        */
-       public final static String TYPE_PASSWORD = "password";
-       public final static String TYPE_INTEGER = "integer";
-       public final static String TYPE_LONG = "long";
-       public final static String TYPE_FLOAT = "float";
-       public final static String TYPE_DOUBLE = "double";
-       public final static String TYPE_BOOLEAN = "boolean";
-
-       public String getType();
-
-       public Object getValue();
-
-       public void setValue(Object value);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java b/cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java
deleted file mode 100644 (file)
index cc3ee67..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.argeo.slc.primitive;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.AbstractSpecAttribute;
-
-/**
- * A spec attribute wrapping a primitive value.
- * 
- * @see PrimitiveAccessor
- */
-public class PrimitiveSpecAttribute extends AbstractSpecAttribute implements
-               PrimitiveAccessor {
-       private static final long serialVersionUID = -566676381839825483L;
-       private String type = "string";
-       private Object value = null;
-
-       public PrimitiveSpecAttribute() {
-       }
-
-       public PrimitiveSpecAttribute(String type, Object value) {
-               this.type = type;
-               this.value = value;
-       }
-
-       public Object getValue() {
-               return value;
-       }
-
-       public void setValue(Object value) {
-               this.value = value;
-       }
-
-       public String getType() {
-               return type;
-       }
-
-       public void setType(String type) {
-               // check whether type is recognized.
-               if (PrimitiveUtils.typeAsClass(type) == null)
-                       throw new SlcException("Unrecognized type " + type);
-               this.type = type;
-
-       }
-
-       @Override
-       public String toString() {
-               return "Primitive spec attribute [" + type + "]"
-                               + (value != null ? "=" + value : "");
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveUtils.java b/cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveUtils.java
deleted file mode 100644 (file)
index 679e808..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.argeo.slc.primitive;
-
-/** Converts to and from primitive types. */
-public class PrimitiveUtils {
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_STRING} instead
-        */
-       public final static String TYPE_STRING = PrimitiveAccessor.TYPE_STRING;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_INTEGER} instead
-        */
-       public final static String TYPE_INTEGER = PrimitiveAccessor.TYPE_INTEGER;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_LONG} instead
-        */
-       public final static String TYPE_LONG = PrimitiveAccessor.TYPE_LONG;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_FLOAT} instead
-        */
-       public final static String TYPE_FLOAT = PrimitiveAccessor.TYPE_FLOAT;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_DOUBLE} instead
-        */
-       public final static String TYPE_DOUBLE = PrimitiveAccessor.TYPE_DOUBLE;
-       /**
-        * @deprecated Use {@link PrimitiveAccessor#TYPE_BOOLEAN} instead
-        */
-       public final static String TYPE_BOOLEAN = PrimitiveAccessor.TYPE_BOOLEAN;
-
-       private PrimitiveUtils() {
-
-       }
-
-       /** @return the class or null if the provided type is not a primitive */
-       public static Class<?> typeAsClass(String type) {
-               if (PrimitiveAccessor.TYPE_STRING.equals(type))
-                       return String.class;
-               else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type))
-                       return char[].class;
-               else if (PrimitiveAccessor.TYPE_INTEGER.equals(type))
-                       return Integer.class;
-               else if (PrimitiveAccessor.TYPE_LONG.equals(type))
-                       return Long.class;
-               else if (PrimitiveAccessor.TYPE_FLOAT.equals(type))
-                       return Float.class;
-               else if (PrimitiveAccessor.TYPE_DOUBLE.equals(type))
-                       return Double.class;
-               else if (PrimitiveAccessor.TYPE_BOOLEAN.equals(type))
-                       return Boolean.class;
-               else
-                       return null;
-       }
-
-       /** @return the type or null if the provided class is not a primitive */
-       public static String classAsType(Class<?> clss) {
-               if (String.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_STRING;
-               else if (char[].class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_PASSWORD;
-               else if (Integer.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_INTEGER;
-               else if (Long.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_LONG;
-               else if (Float.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_FLOAT;
-               else if (Double.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_DOUBLE;
-               else if (Boolean.class.isAssignableFrom(clss))
-                       return PrimitiveAccessor.TYPE_BOOLEAN;
-               else
-                       return null;
-       }
-
-       /** Parse string as an object. Passwords are returned as String.*/
-       public static Object convert(String type, String str) {
-               if (PrimitiveAccessor.TYPE_STRING.equals(type)) {
-                       return str;
-               } else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) {
-                       return str;
-               } else if (PrimitiveAccessor.TYPE_INTEGER.equals(type)) {
-                       return (Integer.parseInt(str));
-               } else if (PrimitiveAccessor.TYPE_LONG.equals(type)) {
-                       return (Long.parseLong(str));
-               } else if (PrimitiveAccessor.TYPE_FLOAT.equals(type)) {
-                       return (Float.parseFloat(str));
-               } else if (PrimitiveAccessor.TYPE_DOUBLE.equals(type)) {
-                       return (Double.parseDouble(str));
-               } else if (PrimitiveAccessor.TYPE_BOOLEAN.equals(type)) {
-                       return (Boolean.parseBoolean(str));
-               } else {
-                       return str;
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveValue.java b/cms/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveValue.java
deleted file mode 100644 (file)
index 0c2bf23..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.argeo.slc.primitive;
-
-import org.argeo.slc.execution.AbstractExecutionValue;
-
-/** Primitive value to be used by an execution. */
-public class PrimitiveValue extends AbstractExecutionValue implements
-               PrimitiveAccessor {
-       private static final long serialVersionUID = 533414290998374166L;
-
-       private String type;
-
-       private Object value;
-
-       public PrimitiveValue() {
-       }
-
-       public PrimitiveValue(String type, Object value) {
-               super();
-               this.type = type;
-               this.value = value;
-       }
-
-       public String getType() {
-               return type;
-       }
-
-       public void setType(String type) {
-               this.type = type;
-       }
-
-       public Object getValue() {
-               return value;
-       }
-
-       public void setValue(Object value) {
-               this.value = value;
-       }
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/slc.cnd b/cms/org.argeo.slc.api/src/org/argeo/slc/slc.cnd
deleted file mode 100644 (file)
index ed4a160..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-<slc = 'http://www.argeo.org/ns/slc'>
-
-// COMMON
-[slc:nameVersion] > nt:base
-mixin
-- slc:name (STRING) m
-- slc:version (STRING) m
-
-[slc:categorizedNameVersion] > slc:nameVersion
-mixin
-// define as mandatory?
-- slc:category (STRING)
-
-// AGENT
-[slc:agentFactory] > nt:unstructured, mix:title
-+ * (slc:agent)
-
-[slc:agent] > nt:unstructured, mix:title
-+ * (slc:module)
-
-[slc:module] > slc:nameVersion, mix:title
-mixin
-
-[slc:activableModule] > slc:module
-mixin
-
-[slc:executionModule] > slc:activableModule
-mixin
-
-[slc:executionSpec] > nt:unstructured, mix:referenceable, mix:title
-- slc:name (STRING) m
-+ * (slc:executionSpecAttribute) *
-
-[slc:executionSpecAttribute] > nt:base
-mixin abstract
-- slc:isImmutable (BOOLEAN) 
-- slc:isConstant (BOOLEAN) 
-- slc:isHidden (BOOLEAN) 
-
-[slc:primitiveSpecAttribute] > slc:executionSpecAttribute
-mixin
-- slc:type (STRING) 
-- slc:value (UNDEFINED)
-
-[slc:refSpecAttribute] > slc:executionSpecAttribute
-orderable
-mixin
-// typically a class name
-- slc:type (STRING)
-- slc:value (UNDEFINED)
-+ * (mix:title)
-
-[slc:executionFlow] > nt:unstructured, mix:title
-- slc:name (STRING) ! m
-// if the execution spec is a referenceable node
-- slc:spec (REFERENCE)
-// if the execution spec is internal (without name)
-+ * (slc:executionSpecAttribute) *
-
-// PROCESS
-[slc:process] > nt:unstructured, mix:created, mix:lastModified
-orderable
-- slc:uuid (STRING) ! m
-- slc:status (STRING) m
-+ slc:flow (slc:realizedFlow)
-+ slc:log
-
-// The first part of the relative path is the thread name, rest is location
-[slc:logEntry] > nt:unstructured
-abstract
-- slc:message (STRING) !
-- slc:timestamp (STRING)
-
-// Log levels are set via types.
-// Querying one level also queries the higher levels thanks to the inheritance
-// e.g. 'select * from [slc:logWarn]' also returns errors 
-[slc:logTrace] > slc:logEntry
-
-[slc:logDebug] > slc:logTrace
-
-[slc:logInfo] > slc:logDebug
-
-[slc:logWarning] > slc:logInfo
-
-[slc:logError] > slc:logWarning
-
-[slc:realizedFlow] > nt:base
-orderable
-mixin
-// the name of the flow
-// - slc:flow (STRING)
-// the name of the execution spec
-// - slc:spec (STRING)
-- slc:started (DATE)
-- slc:completed (DATE)
-//- slc:status (STRING)
-+ slc:address (nt:address)
-+ slc:flow (slc:realizedFlow) *
-// the realized execution spec attributes
-+ * (slc:executionSpecAttribute) *
-
-// RESULT
-[slc:testResult] > nt:unstructured, mix:created, mix:lastModified
-- slc:uuid (STRING) ! m
-- slc:testCase (STRING)
-- slc:completed (DATE)
-// Helper to keep a centralize place to have testResultStatus
-// when adding more than one result part to a given testResult 
-+ slc:aggregatedStatus (slc:check)
-// DEPRECATED - FOR COMPATIBILITY - DO NOT USE
-+ slc:testStatus (slc:check)
-
-[slc:diffResult] > slc:testResult
-+ slc:summary
-+ slc:issues
-
-[slc:resultFolder] > nt:unstructured
-+ slc:folderStatus (slc:check)
-+ * (slc:resultFolder) *
-+ * (slc:testResult) *
-
-// base node for user defined and managed result tree
-// simplify UI management
-[slc:myResultRootFolder] > nt:unstructured
-+ * (slc:resultFolder) *
-+ * (slc:testResult) *
-
-[slc:check] > nt:unstructured
-// true for PASSED, false for FAILED or ERROR
-- slc:success (BOOLEAN) ! m
-- slc:message (STRING)
-// ERROR if set, the check could not be performed because of an unexpected exception
-- slc:errorMessage (STRING)
-// to ease transition with legacy approach
-+ * (slc:property) *
-
-[slc:property] > nt:unstructured
-- slc:name (STRING) ! m
-- slc:value (STRING) m
-
-//
-// DISTRIBUTION
-//
-
-// AETHER
-[slc:artifact] > mix:referenceable, mix:created, mix:lastModified
-mixin
-- slc:artifactId (STRING) m
-- slc:groupId (STRING) m
-- slc:artifactVersion (STRING) m
-- slc:artifactExtension (STRING) m
-- slc:artifactClassifier (STRING) ='' m a
-
-[slc:artifactVersion] > mix:referenceable, mix:created, mix:lastModified, mix:title
-mixin
-- slc:artifactId (STRING) m
-- slc:groupId (STRING) m
-- slc:artifactVersion (STRING) m
-
-[slc:artifactBase] > mix:referenceable, mix:created, mix:lastModified
-mixin
-- slc:artifactId (STRING) m
-- slc:groupId (STRING) m
-
-[slc:groupBase] > mix:referenceable, mix:created, mix:lastModified
-mixin
-// it is possible to have groupBase being artifact base (e.g. org.argeo.commons.basic)
-// so using groupId would conflict 
-- slc:groupBaseId (STRING) m
-
-[slc:modularDistributionBase]
-mixin
-
-[slc:modularDistribution] 
-mixin
-+ slc:modules (nt:unstructured) m
-
-[slc:moduleCoordinates] > nt:unstructured
-- slc:category (STRING)
-- slc:name (STRING)
-- slc:version (STRING)
-
-// ORIGINS
-[slc:knownOrigin] > nt:base
-mixin
-+ slc:origin (nt:address)
-
-[slc:proxied] > nt:address
-- slc:proxy (REFERENCE)
-
-// JAVA
-[slc:jarFile] > mix:referenceable
-mixin
-- 'slc:manifest' (BINARY) m
-- 'slc:Manifest-Version' (STRING)
-- 'slc:Signature-Version' (STRING)
-- 'slc:Class-Path'  (STRING)
-- 'slc:Main-Class' (STRING)
-- 'slc:Extension-Name' (STRING)
-- 'slc:Implementation-Version' (STRING)
-- 'slc:Implementation-Vendor' (STRING)
-- 'slc:Implementation-Vendor-Id' (STRING)
-- 'slc:Implementation-URL' (STRING)
-- 'slc:Specification-Title' (STRING)
-- 'slc:Specification-Version' (STRING)
-- 'slc:Specification-Vendor' (STRING)
-- 'slc:Sealed' (STRING)
-
-// OSGi
-// see http://www.osgi.org/Specifications/Reference
-
-[slc:javaPackage] > mix:referenceable
-- slc:name (STRING) primary m
-
-[slc:osgiBaseVersion] > mix:referenceable
-- slc:asString (STRING) primary m
-- slc:major (LONG) m
-- slc:minor (LONG) m
-- slc:micro (LONG) m
-
-[slc:osgiVersion] > slc:osgiBaseVersion
-- slc:qualifier (STRING)
-
-[slc:exportedPackage] > slc:javaPackage
-+ slc:uses (slc:javaPackage) multiple
-+ slc:version (slc:osgiVersion)
-
-[slc:importedPackage] > slc:javaPackage
-- slc:version (STRING) ='0.0.0' m a
-- slc:optional (BOOLEAN) ='false' m a
-
-[slc:dynamicImportedPackage] > slc:javaPackage
-- slc:version (STRING) ='0.0.0' m a
-- slc:optional (BOOLEAN) ='false' m a
-
-[slc:requiredBundle] > mix:referenceable
-- 'slc:symbolic-name' (STRING) primary m
-- 'slc:bundle-version' (STRING) ='0.0.0' m a
-- slc:optional (BOOLEAN) ='false' m a
-
-[slc:fragmentHost] > mix:referenceable
-- 'slc:symbolic-name' (STRING) m
-- 'slc:bundle-version' (STRING) ='0.0.0' m a
-
-[slc:bundleNativeCode] > mix:referenceable
-- slc:path (STRING) primary m
-- slc:osname (STRING)
-- slc:processor (STRING)
-
-// see http://www.osgi.org/Specifications/ReferenceHeaders
-[slc:bundle] > mix:referenceable
-mixin
-- 'slc:symbolic-name' (STRING) primary m
-- 'slc:bundle-version' (STRING) m
-- 'slc:Bundle-SymbolicName' (STRING) m
-- 'slc:Bundle-Name' (STRING)
-- 'slc:Bundle-Description' (STRING)
-- 'slc:Bundle-ManifestVersion' (STRING)
-- 'slc:Bundle-Category' (STRING)
-- 'slc:Bundle-ActivationPolicy' (STRING)
-- 'slc:Bundle-Copyright' (STRING)
-- 'slc:Bundle-Vendor' (STRING)
-- 'slc:Bundle-License' (STRING)
-- 'slc:Bundle-DocURL' (STRING)
-- 'slc:Bundle-ContactAddress' (STRING)
-- 'slc:Bundle-Activator' (STRING)
-- 'slc:Bundle-UpdateLocation' (STRING)
-- 'slc:Bundle-Localization' (STRING)
-- 'slc:Bundle-ClassPath' (STRING) *
-// see http://wiki.eclipse.org/EE  < 'OSGi/Minimum-1.0','OSGi/Minimum-1.1','CDC-1.0/Foundation-1.0','CDC-1.1/Foundation-1.1','JRE-1.1','J2SE-1.2','J2SE-1.3','J2SE-1.4','J2SE-1.5','JavaSE-1.6','JavaSE-1.7'
-- 'slc:Bundle-RequiredExecutionEnvironment' (STRING) *
-+ 'slc:Bundle-Version' (slc:osgiVersion) m
-+ 'slc:Fragment-Host' (slc:fragmentHost)
-+ 'slc:Import-Package' (slc:importedPackage) multiple
-+ 'slc:Export-Package' (slc:exportedPackage) multiple
-+ 'slc:Require-Bundle' (slc:requiredBundle) multiple
-+ 'slc:Bundle-NativeCode' (slc:bundleNativeCode) multiple
-+ 'slc:DynamicImport-Package' (slc:dynamicImportedPackage) multiple
-
-[slc:bundleArtifact] > slc:artifact,slc:jarFile,slc:bundle
-mixin
-
-// RPM
-[slc:rpm] > mix:referenceable, mix:created, mix:lastModified, mix:title
-mixin
-- slc:name (STRING)
-- slc:version (STRING)
-- slc:rpmVersion (STRING)
-- slc:rpmRelease (STRING)
-- slc:rpmArch (STRING)
-- slc:rpmArchiveSize (STRING)
-// TYPO - TO BE REMOVED
-- slc:rpmArchivaeSize (STRING)
-
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/ExecutableTestRun.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/ExecutableTestRun.java
deleted file mode 100644 (file)
index f18196a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.test;\r
-\r
-\r
-/** A test run that can be executed */\r
-public interface ExecutableTestRun extends TestRun, Runnable {\r
-\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/IncompatibleTestDataException.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/IncompatibleTestDataException.java
deleted file mode 100644 (file)
index de5d900..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.argeo.slc.test;\r
-\r
-import org.argeo.slc.SlcException;\r
-\r
-/**\r
- * Exception to throw when a test definition cannot interpret the provided test\r
- * data.\r
- */\r
-public class IncompatibleTestDataException extends SlcException {\r
-       static final long serialVersionUID = 1l;\r
-\r
-       public IncompatibleTestDataException(TestData testData,\r
-                       TestDefinition testDefinition) {\r
-               super("TestData " + testData.getClass()\r
-                               + " is not compatible with TestDefinition "\r
-                               + testDefinition.getClass());\r
-       }\r
-\r
-       public IncompatibleTestDataException(TestRun testRun) {\r
-               super("TestData " + ((TestData) testRun.getTestData()).getClass()\r
-                               + " is not compatible with TestDefinition "\r
-                               + ((TestDefinition) testRun.getTestDefinition()).getClass());\r
-       }\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestData.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestData.java
deleted file mode 100644 (file)
index 47973ad..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.argeo.slc.test;\r
-\r
-/**\r
- * Any data required by a test in order to run: configuration, expected,\r
- * reached, etc.\r
- */\r
-public interface TestData {\r
-\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestDataProvider.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestDataProvider.java
deleted file mode 100644 (file)
index 754a3df..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.test;\r
-\r
-public interface TestDataProvider {\r
-       public <T extends TestData> T getTestData(Class<T> clss, String key);\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestDefinition.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestDefinition.java
deleted file mode 100644 (file)
index c7bfeac..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.argeo.slc.test;\r
-\r
-/**\r
- * The programmatic definition of a test, which will be associated with\r
- * transient objects within a test run.\r
- */\r
-public interface TestDefinition extends TestStatus {\r
-       /** Performs the test. */\r
-       public void execute(TestRun testRun);\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestResult.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestResult.java
deleted file mode 100644 (file)
index 767b286..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.argeo.slc.test;
-
-import java.util.Date;
-import java.util.Map;
-
-/** The result of a test */
-public interface TestResult extends TestStatus, TestRunAware {
-       public String getUuid();
-
-       /** Adds a part of the result. */
-       public void addResultPart(TestResultPart part);
-
-       /**
-        * Marks that the collection of test results is completed and free the
-        * related resources (also closing listeners).
-        */
-       public void close();
-
-       /**
-        * The date when this test result was closed. Can be null, which means the
-        * result is not closed.
-        */
-       public Date getCloseDate();
-
-       /** Additional arbitrary meta data */
-       public Map<String, String> getAttributes();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestResultListener.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestResultListener.java
deleted file mode 100644 (file)
index c2ad8ed..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.argeo.slc.test;
-
-/** Listener to the operations on a test result. */
-public interface TestResultListener<T extends TestResult> {
-       /** Notified when a part was added to a test result. */
-       public void resultPartAdded(T testResult, TestResultPart testResultPart);
-
-       /** Stops listening and release the related resources. */
-       public void close(T testResult);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestResultPart.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestResultPart.java
deleted file mode 100644 (file)
index ec984f9..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.argeo.slc.test;
-
-/**
- * Part of a test result.
- * 
- * @see TestResult
- */
-public interface TestResultPart {
-       /** The status, as defined in {@link TestStatus}. */
-       public Integer getStatus();
-
-       /** The related message. */
-       public String getMessage();
-
-       /** The underlying <code>Exception</code>. Can be null. */
-       public String getExceptionMessage();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestRun.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestRun.java
deleted file mode 100644 (file)
index a3e8aeb..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.argeo.slc.test;
-
-import org.argeo.slc.deploy.DeployedSystem;
-
-/** The actual run of a test */
-public interface TestRun {
-       /** Gets UUID */
-       public String getUuid();
-
-       /** Gets the related test definition. */
-       public <T extends TestDefinition> T getTestDefinition();
-
-       /** Gets the related test data */
-       public <T extends TestData> T getTestData();
-
-       /** Gets the related deployed system. */
-       public <T extends DeployedSystem> T getDeployedSystem();
-
-       /** Gets the related result where to record results. */
-       public <T extends TestResult> T getTestResult();
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestRunAware.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestRunAware.java
deleted file mode 100644 (file)
index 5458559..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc.test;
-
-/** Allows a test run to notify other objects. */
-public interface TestRunAware {
-       /** Notifies the current test run. */
-       public void notifyTestRun(TestRun testRun);
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestStatus.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/TestStatus.java
deleted file mode 100644 (file)
index a5e10d3..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.argeo.slc.test;
-
-/**
- * Simple statuses. Ordering of the flags can be relied upon in aggregation: if
- * one element is failed, the aggregation is failed. Is one element is in ERROR,
- * the aggregation is in ERROR.
- * <p>
- * <ul>
- * <li>{@link #PASSED}: the test succeeded</li>
- * <li>{@link #FAILED}: the test could run, but did not reach the expected
- * result</li>
- * <li>{@link #ERROR}: an error during the test run prevented to get a
- * significant information on the tested system.</li>
- * </ul>
- * </p>
- */
-public interface TestStatus {
-       /** The flag for a passed test: 0 */
-       public final static Integer PASSED = 0;
-       /** The flag for a failed test: 1 */
-       public final static Integer FAILED = 1;
-       /**
-        * The flag for a test which could not properly run because of an error
-        * (there is no feedback on the behavior of the tested component): 2
-        */
-       public final static Integer ERROR = 2;
-       public final static String STATUSSTR_PASSED = "PASSED";
-       public final static String STATUSSTR_FAILED = "FAILED";
-       public final static String STATUSSTR_ERROR = "ERROR";
-
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/WritableTestRun.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/WritableTestRun.java
deleted file mode 100644 (file)
index 1a2ab23..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.argeo.slc.test;
-
-import org.argeo.slc.deploy.DeployedSystem;
-
-/** Test run whose various components can be externally set. */
-public interface WritableTestRun extends ExecutableTestRun {
-       public void setDeployedSystem(DeployedSystem deployedSystem);
-
-       public void setTestData(TestData testData);
-
-       public void setTestDefinition(TestDefinition testDefinition);
-
-       public void setTestResult(TestResult testResult);
-}
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/context/ContextAware.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/context/ContextAware.java
deleted file mode 100644 (file)
index d2cd86f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.argeo.slc.test.context;\r
-\r
-import java.util.Map;\r
-\r
-/** Access to an SLC test context that is, maps of reached and expected values. */\r
-public interface ContextAware {\r
-       public final static String DEFAULT_SKIP_FLAG = "!";\r
-       public final static String DEFAULT_ANY_FLAG = "*";\r
-\r
-       /** Retrieves reached values. */\r
-       public Map<String, Object> getValues();\r
-\r
-       /** Set reached values. */\r
-       public void setValues(Map<String, Object> values);\r
-\r
-       /** Retrieves expected values. */\r
-       public Map<String, Object> getExpectedValues();\r
-\r
-       public String getContextSkipFlag();\r
-\r
-       public String getContextAnyFlag();\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/context/ParentContextAware.java b/cms/org.argeo.slc.api/src/org/argeo/slc/test/context/ParentContextAware.java
deleted file mode 100644 (file)
index b4044f7..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.argeo.slc.test.context;\r
-\r
-import java.util.Collection;\r
-\r
-public interface ParentContextAware extends ContextAware {\r
-       public Collection<ContextAware> getChildContexts();\r
-\r
-       public void addChildContext(ContextAware contextAware);\r
-}\r
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/context/package.html b/cms/org.argeo.slc.api/src/org/argeo/slc/test/context/package.html
deleted file mode 100644 (file)
index cd08d63..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-Context variables to be passed between parts of tests.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.api/src/org/argeo/slc/test/package.html b/cms/org.argeo.slc.api/src/org/argeo/slc/test/package.html
deleted file mode 100644 (file)
index c70d2d1..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-SLC Test: test of software systems.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.rap/.classpath b/cms/org.argeo.slc.client.rap/.classpath
deleted file mode 100644 (file)
index 06bea94..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
-       <classpathentry kind="output" path="target/classes"/>
-</classpath>
diff --git a/cms/org.argeo.slc.client.rap/.gitignore b/cms/org.argeo.slc.client.rap/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/cms/org.argeo.slc.client.rap/.project b/cms/org.argeo.slc.client.rap/.project
deleted file mode 100644 (file)
index 9b82af4..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<projectDescription>\r
-       <name>org.argeo.slc.client.rap</name>\r
-       <comment></comment>\r
-       <projects>\r
-       </projects>\r
-       <buildSpec>\r
-               <buildCommand>\r
-                       <name>org.eclipse.jdt.core.javabuilder</name>\r
-                       <arguments>\r
-                       </arguments>\r
-               </buildCommand>\r
-               <buildCommand>\r
-                       <name>org.eclipse.pde.ManifestBuilder</name>\r
-                       <arguments>\r
-                       </arguments>\r
-               </buildCommand>\r
-               <buildCommand>\r
-                       <name>org.eclipse.pde.SchemaBuilder</name>\r
-                       <arguments>\r
-                       </arguments>\r
-               </buildCommand>\r
-       </buildSpec>\r
-       <natures>\r
-               <nature>org.eclipse.pde.PluginNature</nature>\r
-               <nature>org.eclipse.jdt.core.javanature</nature>\r
-       </natures>\r
-</projectDescription>\r
diff --git a/cms/org.argeo.slc.client.rap/.settings/org.eclipse.jdt.core.prefs b/cms/org.argeo.slc.client.rap/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index 8b45224..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#Thu Apr 14 17:49:18 CEST 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/cms/org.argeo.slc.client.rap/META-INF/.gitignore b/cms/org.argeo.slc.client.rap/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.client.rap/META-INF/spring/commands.xml b/cms/org.argeo.slc.client.rap/META-INF/spring/commands.xml
deleted file mode 100644 (file)
index f19c551..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-       <!-- RAP Specific open JCR file service -->
-       <!-- <bean id="openJcrFileService" class="org.argeo.slc.client.rap.OpenJcrFileService" -->
-       <!-- scope="prototype" init-method="init" destroy-method="destroy"> -->
-       <!-- <property name="repoService" ref="repoService" /> -->
-       <!-- <property name="repositoryFactory" ref="repositoryFactory" /> -->
-       <!-- <property name="keyring" ref="keyring" /> -->
-       <!-- <property name="nodeRepository" ref="nodeRepository" /> -->
-       <!-- </bean> -->
-
-       <bean id="org.argeo.slc.client.rap.openJcrFile" class="org.argeo.slc.client.ui.specific.OpenJcrFile"
-               scope="prototype">
-               <property name="repoService" ref="repoService" />
-       </bean>
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.rap/META-INF/spring/jcr.xml b/cms/org.argeo.slc.client.rap/META-INF/spring/jcr.xml
deleted file mode 100644 (file)
index 4a35de6..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
-       xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
-       <bean id="repoService" class="org.argeo.slc.repo.core.RepoServiceImpl">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-</beans>
diff --git a/cms/org.argeo.slc.client.rap/META-INF/spring/osgi.xml b/cms/org.argeo.slc.client.rap/META-INF/spring/osgi.xml
deleted file mode 100644 (file)
index 6c76546..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans\r
-       xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xmlns:osgi="http://www.springframework.org/schema/osgi"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
-       osgi:default-timeout="30000">\r
-\r
-       <beans:description>SLC UI RAP</beans:description>\r
-\r
-       <reference id="nodeRepository"\r
-       interface="javax.jcr.Repository" />\r
-       <reference id="repositoryFactory"\r
-               interface="javax.jcr.RepositoryFactory" />\r
-       <reference id="keyring"\r
-               interface="org.argeo.api.security.CryptoKeyring" />\r
-</beans:beans>\r
diff --git a/cms/org.argeo.slc.client.rap/bnd.bnd b/cms/org.argeo.slc.client.rap/bnd.bnd
deleted file mode 100644 (file)
index 7b46665..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-Bundle-SymbolicName: org.argeo.slc.client.rap;singleton=true
-Bundle-ActivationPolicy: lazy
-Bundle-Activator: org.argeo.slc.client.rap.SlcRapPlugin
-Require-Bundle: org.eclipse.ui;resolution:=optional,\
-org.eclipse.core.runtime,\
-org.eclipse.rap.ui;resolution:=optional,\
-org.eclipse.rap.ui.workbench;resolution:=optional
-
-Import-Package: javax.jcr.nodetype,\
-javax.servlet,\
-javax.servlet.http,\
-org.argeo.eclipse.spring,\
-org.argeo.slc.repo.core,\
-org.argeo.cms.ui.util,\
-*
-                                                       
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.rap/build.properties b/cms/org.argeo.slc.client.rap/build.properties
deleted file mode 100644 (file)
index 5dd830c..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-source.. = src/main/java/\r
-output.. = target/classes/\r
-bin.includes = plugin.xml,\\r
-               META-INF/,\\r
-               .\r
diff --git a/cms/org.argeo.slc.client.rap/icons/slc_execution_perspective.gif b/cms/org.argeo.slc.client.rap/icons/slc_execution_perspective.gif
deleted file mode 100644 (file)
index b8ca14a..0000000
Binary files a/cms/org.argeo.slc.client.rap/icons/slc_execution_perspective.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.rap/plugin.xml b/cms/org.argeo.slc.client.rap/plugin.xml
deleted file mode 100644 (file)
index b0639cc..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<?eclipse version="3.6"?>\r
-<plugin>\r
-       <extension\r
-               point="org.eclipse.rap.ui.entrypoint">\r
-               <entrypoint\r
-                       id="org.argeo.slc.client.rap.slcSecureRap"\r
-                       class="org.argeo.slc.client.rap.SlcSecureRap"\r
-                       path="/slc">\r
-               </entrypoint>\r
-       </extension>\r
-   \r
-       <!-- COMMANDS  --> \r
-       <extension\r
-        point="org.eclipse.ui.commands">\r
-               <command\r
-                       id="org.argeo.slc.client.rap.openJcrFile"\r
-                       defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"\r
-                       name="Open Workspace Editor">\r
-                       <commandParameter\r
-                               id="param.repoNodePath"\r
-                               name="Repo node path">\r
-                       </commandParameter>\r
-                       <commandParameter\r
-                               id="param.repoUri"\r
-                               name="Repo URI">\r
-                       </commandParameter>\r
-                       <commandParameter\r
-                               id="param.workspaceName"\r
-                               name="Workspace name">\r
-                       </commandParameter>\r
-                       <commandParameter\r
-                               id="param.filePath"\r
-                               name="File Path">\r
-                       </commandParameter>\r
-       </command>\r
-       </extension>\r
-</plugin>\r
diff --git a/cms/org.argeo.slc.client.rap/pom.xml b/cms/org.argeo.slc.client.rap/pom.xml
deleted file mode 100644 (file)
index b603796..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.client.rap</artifactId>
-       <name>SLC Client RAP</name>
-       <packaging>jar</packaging>
-       <dependencies>
-               <!-- SLC -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.repo</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Argeo common distribution for Secured UI -->
-               <dependency>
-                       <groupId>org.argeo.slc.legacy.commons</groupId>
-                       <artifactId>org.argeo.cms.ui.workbench.rap</artifactId>
-                       <version>${version.argeo-commons-legacy}</version>
-               </dependency>
-
-               <!-- RAP workbench -->
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>argeo-tp-rap-e3</artifactId>
-                       <version>${version.argeo-tp}</version>
-                       <type>pom</type>
-                       <scope>provided</scope>
-               </dependency>
-
-       </dependencies>
-</project>
diff --git a/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/OpenJcrFileService.java b/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/OpenJcrFileService.java
deleted file mode 100644 (file)
index 1a1f1dc..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.argeo.slc.client.rap;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-//import org.eclipse.rap.rwt.service.IServiceHandler;
-
-/**
- * Basic Default service handler that retrieves a file from a NT_FILE JCR node
- * and launch the download.
- */
-public class OpenJcrFileService {//implements IServiceHandler {
-
-       /* DEPENDENCY INJECTION */
-       final private Node fileNode;
-
-       public OpenJcrFileService(Node fileNode) {
-               this.fileNode = fileNode;
-       }
-
-       public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
-               // Get the file content
-               byte[] download = getFileAsByteArray();
-
-               // Send the file in the response
-               //HttpServletResponse response = RWT.getResponse();
-               response.setContentType("application/octet-stream");
-               response.setContentLength(download.length);
-               String contentDisposition = null;
-               try {
-                       contentDisposition = "attachment; filename=\""
-                                       + JcrUtils.lastPathElement(fileNode.getPath()) + "\"";
-               } catch (RepositoryException e) {
-                       throw new SlcException("Error while getting file Path " + fileNode,
-                                       e);
-               }
-               response.setHeader("Content-Disposition", contentDisposition);
-
-               try {
-                       response.getOutputStream().write(download);
-               } catch (IOException ioe) {
-                       throw new SlcException("Error while writing the file " + fileNode
-                                       + " to the servlet response", ioe);
-               }
-       }
-
-       protected byte[] getFileAsByteArray() {
-
-               Session businessSession = null;
-               try {
-                       boolean isValid = true;
-                       Node child = null;
-                       if (!fileNode.isNodeType(NodeType.NT_FILE))
-                               isValid = false;
-                       else {
-                               child = fileNode.getNode(Property.JCR_CONTENT);
-                               if (!(child.isNodeType(NodeType.NT_RESOURCE) || child
-                                               .hasProperty(Property.JCR_DATA)))
-                                       isValid = false;
-                       }
-
-                       if (!isValid)
-                               return null;
-
-                       byte[] ba = null;
-                       InputStream fis = null;
-                       try {
-                               fis = (InputStream) child.getProperty(Property.JCR_DATA)
-                                               .getBinary().getStream();
-                               ba = IOUtils.toByteArray(fis);
-                       } catch (Exception e) {
-                               throw new SlcException("Stream error while opening file "
-                                               + fileNode, e);
-                       } finally {
-                               IOUtils.closeQuietly(fis);
-                       }
-                       return ba;
-
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unexpected error while "
-                                       + "opening file node " + fileNode, e);
-               } finally {
-                       JcrUtils.logoutQuietly(businessSession);
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcRapPlugin.java b/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcRapPlugin.java
deleted file mode 100644 (file)
index e23ea74..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.argeo.slc.client.rap;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- * 
- * Enable life-cycle management of RAP specific services
- */
-public class SlcRapPlugin extends AbstractUIPlugin {
-
-       // The plug-in ID
-       public static final String PLUGIN_ID = "org.argeo.slc.client.rap"; //$NON-NLS-1$
-
-       // The shared instance
-       private static SlcRapPlugin plugin;
-
-       /**
-        * The constructor
-        */
-       public SlcRapPlugin() {
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
-        * )
-        */
-       public void start(BundleContext context) throws Exception {
-               super.start(context);
-               plugin = this;
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see
-        * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
-        * )
-        */
-       public void stop(BundleContext context) throws Exception {
-               plugin = null;
-               super.stop(context);
-       }
-
-       /**
-        * Returns the shared instance
-        * 
-        * @return the shared instance
-        */
-       public static SlcRapPlugin getDefault() {
-               return plugin;
-       }
-
-       /**
-        * Returns an image descriptor for the image file at the given plug-in
-        * relative path
-        * 
-        * @param path
-        *            the path
-        * @return the image descriptor
-        */
-       public static ImageDescriptor getImageDescriptor(String path) {
-               return imageDescriptorFromPlugin(PLUGIN_ID, path);
-       }
-
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcSecureRap.java b/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcSecureRap.java
deleted file mode 100644 (file)
index ddd7753..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.argeo.slc.client.rap;
-
-import org.argeo.cms.ui.workbench.rap.RapWindowAdvisor;
-import org.argeo.cms.ui.workbench.rap.RapWorkbenchAdvisor;
-import org.argeo.cms.ui.workbench.rap.RapWorkbenchLogin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.application.WorkbenchWindowAdvisor;
-
-/**
- * This class controls all aspects of the application's execution and is
- * contributed through the plugin.xml.
- */
-public class SlcSecureRap extends RapWorkbenchLogin {
-
-       @Override
-       protected RapWorkbenchAdvisor createRapWorkbenchAdvisor(
-                       final String username) {
-               return new RapWorkbenchAdvisor(username) {
-                       @Override
-                       public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
-                                       IWorkbenchWindowConfigurer configurer) {
-                               return new SlcRapWorkbenchWindowAdvisor(configurer, username);
-                       }
-
-               };
-       }
-
-       /** Workaround for resize issue */
-       class SlcRapWorkbenchWindowAdvisor extends RapWindowAdvisor {
-
-               public SlcRapWorkbenchWindowAdvisor(
-                               IWorkbenchWindowConfigurer configurer, String username) {
-                       super(configurer, username);
-               }
-
-               public void preWindowOpen() {
-                       IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
-                       configurer.setShowCoolBar(true);
-                       configurer.setShowMenuBar(false);
-                       configurer.setShowStatusLine(false);
-                       configurer.setShowPerspectiveBar(true);
-                       configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
-                       // Full screen, see
-                       // http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02697.html
-                       configurer.setShellStyle(SWT.NO_TRIM);
-                       Rectangle bounds = Display.getCurrent().getBounds();
-                       configurer.setInitialSize(new Point(bounds.width, bounds.height));
-               }
-
-               @Override
-               public void postWindowCreate() {
-                       Shell shell = getWindowConfigurer().getWindow().getShell();
-                       shell.setMaximized(true);
-               }
-
-               @Override
-               public void postWindowOpen() {
-                       String defaultPerspective = getWindowConfigurer()
-                                       .getWorkbenchConfigurer().getWorkbench()
-                                       .getPerspectiveRegistry().getDefaultPerspective();
-                       if (defaultPerspective == null) {
-                               IWorkbenchWindow window = getWindowConfigurer().getWindow();
-                               if (window == null)
-                                       return;
-
-                               IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
-                                               .create(window);
-                               openPerspectiveDialogAction.run();
-                       }
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFile.java b/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFile.java
deleted file mode 100644 (file)
index 8876a15..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.argeo.slc.client.ui.specific;
-
-import java.net.URL;
-import java.util.UUID;
-
-import javax.jcr.Node;
-import javax.jcr.Session;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.rap.OpenJcrFileService;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.rap.rwt.RWT;
-//import org.eclipse.rap.rwt.service.IServiceHandler;
-//import org.eclipse.rap.rwt.service.IServiceManager;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Rap specific command handler to open a file retrieved from a distant JCR
- * Repository. It creates and register a service instantiated with the
- * corresponding JCR node, forwards the request, and un register the service on
- * dispose
- * 
- * This command and the corresponding service are specific for RAP version [1.3,
- * 2)
- */
-public class OpenJcrFile extends AbstractHandler {
-
-       // Use (new OpenJcrFileCmdId()).getCmdId() instead.
-       // public final String ID = SlcRapPlugin.PLUGIN_ID + ".openJcrFile";
-       
-       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
-       public final static String PARAM_REPO_URI = "param.repoUri";
-       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
-       public final static String PARAM_FILE_PATH = "param.filePath";
-
-       private RepoService repoService;
-       private String currentServiceId;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
-               String repoUri = event.getParameter(PARAM_REPO_URI);
-               String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
-               String filePath = event.getParameter(PARAM_FILE_PATH);
-
-               // TODO sanity check
-               if (filePath == null || "".equals(filePath.trim()))
-                       return null;
-               Session businessSession = null;
-               try {
-                       businessSession = repoService.getRemoteSession(repoNodePath,
-                                       repoUri, wkspName);
-                       Node result = businessSession.getNode(filePath);
-
-                       // Create a temporary service. No better solution has been found
-                       // yet.
-                       currentServiceId = UUID.randomUUID().toString();
-                       OpenJcrFileService ojfs = new OpenJcrFileService(result);
-                       // FIXME replace it
-//                     IServiceManager manager = RWT.getServiceManager();
-//                     manager.registerServiceHandler(currentServiceId, ojfs);
-                       String urlStr = createFullDownloadUrl(currentServiceId);
-                       URL url = new URL(urlStr);
-                       PlatformUI.getWorkbench().getBrowserSupport()
-                                       .createBrowser("DownloadDialog").openURL(url);
-               } catch (Exception e) {
-                       throw new SlcException("Unable to open Jcr File for path "
-                                       + filePath, e);
-               }
-
-               return null;
-       }
-
-       @Override
-       public void dispose() {
-//             IServiceManager manager = RWT.getServiceManager();
-//             manager.unregisterServiceHandler(currentServiceId);
-               super.dispose();
-       }
-
-       private String createFullDownloadUrl(String serviceId) {
-               StringBuilder url = new StringBuilder();
-               url.append(RWT.getRequest().getRequestURL());
-
-               StringBuilder params = new StringBuilder();
-               params.append("?");
-               // FIXME commented out so that it builds
-               //params.append(IServiceHandler.REQUEST_PARAM).append("=");
-               params.append(serviceId);
-               String encodedURL = RWT.getResponse().encodeURL(params.toString());
-               url.append(encodedURL);
-               return url.toString();
-       }
-
-       /* Dependency Injection */
-       public void setRepoService(RepoService repoService) {
-               this.repoService = repoService;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java b/cms/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java
deleted file mode 100644 (file)
index a4e0d83..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.argeo.slc.client.ui.specific;
-
-import org.argeo.slc.client.rap.SlcRapPlugin;
-
-/**
- * Workaround a single sourcing problem:
- * 
- * final static variable are imported at compilation time (we build against RCP)
- * and we still must have a different ID (the prefix must be the PLUGIN ID) for
- * RAP and RCP in order to be able to inject beans in the corresponding commands 
- */
-public class OpenJcrFileCmdId {
-
-       public String getCmdId() {
-               return SlcRapPlugin.PLUGIN_ID + ".openJcrFile";
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/.classpath b/cms/org.argeo.slc.client.ui.dist/.classpath
deleted file mode 100644 (file)
index 120e381..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="output" path="target/classes"/>
-</classpath>
diff --git a/cms/org.argeo.slc.client.ui.dist/.gitignore b/cms/org.argeo.slc.client.ui.dist/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/cms/org.argeo.slc.client.ui.dist/.project b/cms/org.argeo.slc.client.ui.dist/.project
deleted file mode 100644 (file)
index 30b71ed..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.client.ui.dist</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/cms/org.argeo.slc.client.ui.dist/.settings/org.eclipse.jdt.core.prefs b/cms/org.argeo.slc.client.ui.dist/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index 7c5d419..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#Wed Dec 08 08:27:02 CET 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/cms/org.argeo.slc.client.ui.dist/.settings/org.eclipse.pde.core.prefs b/cms/org.argeo.slc.client.ui.dist/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644 (file)
index 0e2e537..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#Wed Dec 08 08:27:02 CET 2010
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
diff --git a/cms/org.argeo.slc.client.ui.dist/META-INF/.gitignore b/cms/org.argeo.slc.client.ui.dist/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml b/cms/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml
deleted file mode 100644 (file)
index a9eb9af..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-       <!-- DISTRIBUTIONS MANAGEMENT -->
-       <bean id="normalizeDistribution"
-               class="org.argeo.slc.client.ui.dist.commands.NormalizeDistribution">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="openModuleEditor" class="org.argeo.slc.client.ui.dist.commands.OpenModuleEditor"
-               scope="prototype">
-               <property name="repoService" ref="repoService" />
-       </bean>
-
-       <!-- REPOSITORY MANAGEMENT -->
-       <bean id="registerRepository"
-               class="org.argeo.slc.client.ui.dist.commands.RegisterRepository">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="unregisterRemoteRepo"
-               class="org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo"
-               scope="prototype">
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="displayRepoInformation"
-               class="org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation"
-               scope="prototype">
-               <property name="repoService" ref="repoService" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-
-       <!-- WORKSPACE MANAGEMENT -->
-       <bean id="openWorkspaceEditor"
-               class="org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor"
-               scope="prototype">
-               <property name="localRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="fetch" class="org.argeo.slc.client.ui.dist.commands.Fetch"
-               scope="prototype">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="manageWorkspaceAuth"
-               class="org.argeo.slc.client.ui.dist.commands.ManageWorkspaceAuth"
-               scope="prototype">
-               <property name="repository" ref="javaRepository" />
-       </bean>
-
-       <bean id="publishWorkspace" class="org.argeo.slc.client.ui.dist.commands.PublishWorkspace">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="normalizeWorkspace"
-               class="org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="openGenerateBinariesWizard"
-               class="org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard">
-               <property name="repoService" ref="repoService" />
-       </bean>
-
-       <!-- WORKSPACE CRUD -->
-       <bean id="createWorkspace" class="org.argeo.slc.client.ui.dist.commands.CreateWorkspace">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="copyWorkspace" class="org.argeo.slc.client.ui.dist.commands.CopyWorkspace">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="copyLocalJavaWorkspace"
-               class="org.argeo.slc.client.ui.dist.commands.CopyLocalJavaWorkspace">
-               <property name="javaRepoManager">
-                       <bean factory-bean="slcRepoManager" factory-method="getJavaRepoManager" />
-               </property>
-               <property name="javaRepository" ref="javaRepository" />
-       </bean>
-
-       <bean id="createLocalJavaWorkspace"
-               class="org.argeo.slc.client.ui.dist.commands.CreateLocalJavaWorkspace">
-               <property name="javaRepoManager">
-                       <bean factory-bean="slcRepoManager" factory-method="getJavaRepoManager" />
-               </property>
-       </bean>
-
-       <bean id="mergeWorkspaces" class="org.argeo.slc.client.ui.dist.commands.MergeWorkspaces">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="deleteWorkspace" class="org.argeo.slc.client.ui.dist.commands.DeleteWorkspace">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <!-- ADVANCED -->
-       <bean id="runInOsgi" class="org.argeo.slc.client.ui.dist.commands.RunInOsgi"
-               scope="prototype">
-               <property name="repository" ref="javaRepository" />
-       </bean>
-
-       <!-- LEGACY -->
-       <!-- <bean id="org.argeo.slc.client.ui.dist.openGenericJcrQueryEditor" class="org.argeo.eclipse.ui.jcr.commands.OpenGenericJcrQueryEditor" 
-               scope="prototype"> <property name="editorId" value="org.argeo.slc.client.ui.dist.genericJcrQueryEditor" 
-               /> </bean> -->
-       <bean id="refreshDistributionsView"
-               class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionsView"
-               scope="prototype">
-       </bean>
-
-       <bean id="org.argeo.slc.client.ui.dist.deleteArtifacts" class="org.argeo.slc.client.ui.dist.commands.DeleteArtifacts"
-               scope="prototype">
-       </bean>
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/META-INF/spring/editors.xml b/cms/org.argeo.slc.client.ui.dist/META-INF/spring/editors.xml
deleted file mode 100644 (file)
index 23632d5..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
-       xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
-       <bean id="distWorkspaceEditor"
-               class="org.argeo.slc.client.ui.dist.editors.DistWorkspaceEditor"
-               scope="prototype">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="localRepository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="artifactVersionEditor"
-               class="org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor"
-               scope="prototype">
-               <property name="repoService" ref="repoService" />
-       </bean>
-
-       <bean id="modularDistVersionEditor"
-               class="org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor"
-               scope="prototype">
-               <property name="repoService" ref="repoService" />
-       </bean>
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/META-INF/spring/jcr.xml b/cms/org.argeo.slc.client.ui.dist/META-INF/spring/jcr.xml
deleted file mode 100644 (file)
index 6b21f8e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
-       xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
-       <bean id="repoService" class="org.argeo.slc.repo.core.RepoServiceImpl">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="nodeRepository" ref="nodeRepository" />
-       </bean>
-
-       <!-- For the record <property name="session"> <bean factory-bean="repository" 
-               factory-method="login" /> </property> -->
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml b/cms/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml
deleted file mode 100644 (file)
index 324c66f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xmlns:osgi="http://www.springframework.org/schema/osgi"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
-       osgi:default-timeout="30000">\r
-\r
-       <reference id="javaRepository" interface="javax.jcr.Repository"\r
-               filter="(cn=java)" />\r
-\r
-       <reference id="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
-       <reference id="keyring" interface="org.argeo.api.security.CryptoKeyring" />\r
-\r
-       <reference id="nodeRepository" interface="javax.jcr.Repository"\r
-               filter="(cn=ego)" />\r
-\r
-       <reference id="slcRepoManager" interface="org.argeo.slc.repo.SlcRepoManager" />\r
-</beans:beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml b/cms/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml
deleted file mode 100644 (file)
index 73eeaef..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:util="http://www.springframework.org/schema/util"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd 
-        http://www.springframework.org/schema/util 
-        http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
-       <!-- Views -->
-<!--   <bean id="artifactsBrowser" class="org.argeo.slc.client.ui.dist.views.ArtifactsBrowser" -->
-<!--           scope="prototype"> -->
-<!--           <property name="jcrSession" ref="slcSession" /> -->
-<!--   </bean> -->
-<!--   <bean id="queryArtifactsForm" class="org.argeo.slc.client.ui.dist.views.QueryArtifactsForm" -->
-<!--           scope="prototype"> -->
-<!--           <property name="session" ref="slcSession" /> -->
-<!--           <property name="columnProperties"> -->
-<!--                   <list> -->
-<!--                           <value>slc:artifactVersion.jcr:uuid</value> -->
-<!--                           <value>slc:artifactVersion.slc:groupId</value> -->
-<!--                           <value>slc:artifactVersion.slc:artifactId</value> -->
-<!--                           <value>slc:artifactVersion.slc:artifactVersion</value> -->
-<!--                   </list> -->
-<!--           </property> -->
-<!--   </bean> -->
-<!--   <bean id="queryBundlesForm" class="org.argeo.slc.client.ui.dist.views.QueryBundlesForm" -->
-<!--           scope="prototype"> -->
-<!--           <property name="session" ref="slcSession" /> -->
-<!--           <property name="columnProperties"> -->
-<!--                   <list> -->
-<!--                           <value>slc:artifactVersion.jcr:uuid</value> -->
-<!--                           <value>slc:bundleArtifact.slc:symbolic-name</value> -->
-<!--                           <value>slc:artifactVersion.slc:groupId</value> -->
-<!--                           <value>slc:bundleArtifact.slc:bundle-version</value> -->
-<!--                           <value>slc:bundleArtifact.slc:Fragment-Host</value> -->
-<!--                   </list> -->
-<!--           </property> -->
-<!--   </bean> -->
-
-<!--   <bean id="queryArtifactsText" class="org.argeo.slc.client.ui.dist.views.QueryArtifactsText" -->
-<!--           scope="prototype"> -->
-<!--           <property name="session" ref="slcSession" /> -->
-<!--   </bean> -->
-
-       <bean id="distributionsView" class="org.argeo.slc.client.ui.dist.views.DistributionsView"
-               scope="prototype">
-               <!-- <property name="repositoryFactory" ref="repositoryFactory" /> -->
-               <!-- <property name="keyring" ref="keyring" /> -->
-               <property name="nodeRepository" ref="nodeRepository" />
-               <property name="treeContentProvider" ref="distTreeContentProvider" />
-       </bean>
-
-       <!-- Corresponding content provider -->
-       <bean id="distTreeContentProvider"
-               class="org.argeo.slc.client.ui.dist.controllers.DistTreeContentProvider"
-               scope="prototype">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-       </bean>
-
-       <!-- ANONYMOUS DISTRIBUTION VIEW -->
-       <bean id="anonymousDistributionsView"
-               class="org.argeo.slc.client.ui.dist.views.AnonymousDistributionsView"
-               scope="prototype">
-               <property name="treeContentProvider" ref="anonymousDistTreeContentProvider" />
-       </bean>
-
-       <!-- Corresponding content provider -->
-       <bean id="anonymousDistTreeContentProvider"
-               class="org.argeo.slc.client.ui.dist.controllers.AnonymousDistTreeContentProvider"
-               scope="prototype">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-       </bean>
-
-       <!-- <bean id="distributionPerspective" class="org.argeo.slc.client.ui.dist.DistributionPerspective" 
-               scope="prototype"> <property name="repositoryFactory" ref="repositoryFactory" 
-               /> <property name="nodeRepository" ref="nodeRepository" /> </bean> -->
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/bnd.bnd b/cms/org.argeo.slc.client.ui.dist/bnd.bnd
deleted file mode 100644 (file)
index c2eeb87..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-Bundle-SymbolicName: org.argeo.slc.client.ui.dist;singleton=true
-Bundle-ActivationPolicy: lazy
-Require-Bundle: org.eclipse.ui;resolution:=optional,\
-org.eclipse.core.runtime,\
-org.eclipse.rap.ui;resolution:=optional,\
-org.eclipse.rap.ui.workbench;resolution:=optional
-
-Bundle-Activator: org.argeo.slc.client.ui.dist.DistPlugin
-Import-Package: org.argeo.eclipse.spring,\
-javax.jcr.nodetype,\
-javax.jcr.security,\
-aQute.lib.*;resolution:=optional,\
-org.osgi.*;version=0.0.0,\
-*
-                                                       
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/build.properties b/cms/org.argeo.slc.client.ui.dist/build.properties
deleted file mode 100644 (file)
index 34d2e4d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
-               .
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/addItem.gif b/cms/org.argeo.slc.client.ui.dist/icons/addItem.gif
deleted file mode 100644 (file)
index a5ac28d..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/addItem.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/addRepo.gif b/cms/org.argeo.slc.client.ui.dist/icons/addRepo.gif
deleted file mode 100644 (file)
index b4832fc..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/addRepo.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/artifactBase.gif b/cms/org.argeo.slc.client.ui.dist/icons/artifactBase.gif
deleted file mode 100644 (file)
index fca9c53..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/artifactBase.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/artifactVersionBase.gif b/cms/org.argeo.slc.client.ui.dist/icons/artifactVersionBase.gif
deleted file mode 100644 (file)
index c026f01..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/artifactVersionBase.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/changeRights.gif b/cms/org.argeo.slc.client.ui.dist/icons/changeRights.gif
deleted file mode 100644 (file)
index a6b251f..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/changeRights.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/checked.gif b/cms/org.argeo.slc.client.ui.dist/icons/checked.gif
deleted file mode 100644 (file)
index 00da14e..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/checked.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/clear.gif b/cms/org.argeo.slc.client.ui.dist/icons/clear.gif
deleted file mode 100644 (file)
index cbb71be..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/clear.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/distGrp.gif b/cms/org.argeo.slc.client.ui.dist/icons/distGrp.gif
deleted file mode 100644 (file)
index 0470e15..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/distGrp.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/distGrpReadOnly.gif b/cms/org.argeo.slc.client.ui.dist/icons/distGrpReadOnly.gif
deleted file mode 100644 (file)
index ae98299..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/distGrpReadOnly.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/distribution_perspective.gif b/cms/org.argeo.slc.client.ui.dist/icons/distribution_perspective.gif
deleted file mode 100644 (file)
index 955d5e8..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/distribution_perspective.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/fetchRepo.png b/cms/org.argeo.slc.client.ui.dist/icons/fetchRepo.png
deleted file mode 100644 (file)
index 195659f..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/fetchRepo.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/file.gif b/cms/org.argeo.slc.client.ui.dist/icons/file.gif
deleted file mode 100644 (file)
index ef30288..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/file.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/help.gif b/cms/org.argeo.slc.client.ui.dist/icons/help.gif
deleted file mode 100644 (file)
index ca1b1e7..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/help.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/homeRepo.gif b/cms/org.argeo.slc.client.ui.dist/icons/homeRepo.gif
deleted file mode 100644 (file)
index 4472e8c..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/homeRepo.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/modularDistributionVersion.gif b/cms/org.argeo.slc.client.ui.dist/icons/modularDistributionVersion.gif
deleted file mode 100644 (file)
index 22f78af..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/modularDistributionVersion.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/more.gif b/cms/org.argeo.slc.client.ui.dist/icons/more.gif
deleted file mode 100644 (file)
index 57ad089..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/more.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/more.png b/cms/org.argeo.slc.client.ui.dist/icons/more.png
deleted file mode 100644 (file)
index 1252a14..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/more.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/normalize.gif b/cms/org.argeo.slc.client.ui.dist/icons/normalize.gif
deleted file mode 100644 (file)
index b8ca14a..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/normalize.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/package.gif b/cms/org.argeo.slc.client.ui.dist/icons/package.gif
deleted file mode 100644 (file)
index 131c28d..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/package.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/packageBrowser.gif b/cms/org.argeo.slc.client.ui.dist/icons/packageBrowser.gif
deleted file mode 100644 (file)
index 983932f..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/packageBrowser.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/packages.gif b/cms/org.argeo.slc.client.ui.dist/icons/packages.gif
deleted file mode 100644 (file)
index 22f78af..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/packages.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/publish.gif b/cms/org.argeo.slc.client.ui.dist/icons/publish.gif
deleted file mode 100644 (file)
index ec6cca4..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/publish.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/pview.gif b/cms/org.argeo.slc.client.ui.dist/icons/pview.gif
deleted file mode 100644 (file)
index 4aa54a6..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/pview.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/refresh.png b/cms/org.argeo.slc.client.ui.dist/icons/refresh.png
deleted file mode 100644 (file)
index a3884fb..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/refresh.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/removeItem.gif b/cms/org.argeo.slc.client.ui.dist/icons/removeItem.gif
deleted file mode 100644 (file)
index 2b88506..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/removeItem.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/removeMark.gif b/cms/org.argeo.slc.client.ui.dist/icons/removeMark.gif
deleted file mode 100644 (file)
index d766177..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/removeMark.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/repo.gif b/cms/org.argeo.slc.client.ui.dist/icons/repo.gif
deleted file mode 100644 (file)
index c13bea1..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/repo.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/repoReadOnly.gif b/cms/org.argeo.slc.client.ui.dist/icons/repoReadOnly.gif
deleted file mode 100644 (file)
index a076324..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/repoReadOnly.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif b/cms/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif
deleted file mode 100644 (file)
index 2df4b45..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/search.gif b/cms/org.argeo.slc.client.ui.dist/icons/search.gif
deleted file mode 100644 (file)
index d540a01..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/search.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/searchForm.gif b/cms/org.argeo.slc.client.ui.dist/icons/searchForm.gif
deleted file mode 100644 (file)
index cbbb3af..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/searchForm.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/search_decl_obj.gif b/cms/org.argeo.slc.client.ui.dist/icons/search_decl_obj.gif
deleted file mode 100644 (file)
index f31a02a..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/search_decl_obj.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/showSize.gif b/cms/org.argeo.slc.client.ui.dist/icons/showSize.gif
deleted file mode 100644 (file)
index 2df4b45..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/showSize.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/sinfocenter_obj.gif b/cms/org.argeo.slc.client.ui.dist/icons/sinfocenter_obj.gif
deleted file mode 100644 (file)
index b867103..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/sinfocenter_obj.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/unchecked.gif b/cms/org.argeo.slc.client.ui.dist/icons/unchecked.gif
deleted file mode 100644 (file)
index 7aa131a..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/unchecked.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/icons/wkspGroup.gif b/cms/org.argeo.slc.client.ui.dist/icons/wkspGroup.gif
deleted file mode 100644 (file)
index 79b22b7..0000000
Binary files a/cms/org.argeo.slc.client.ui.dist/icons/wkspGroup.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui.dist/plugin.xml b/cms/org.argeo.slc.client.ui.dist/plugin.xml
deleted file mode 100644 (file)
index 4d42d75..0000000
+++ /dev/null
@@ -1,492 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-       <!-- PERSPECTIVES --> 
-       <extension
-               point="org.eclipse.ui.perspectives">
-               <perspective
-            name="SLC Factory"
-            class="org.argeo.slc.client.ui.dist.DistributionPerspective"
-            id="org.argeo.slc.client.ui.dist.distributionPerspective"
-            icon="icons/distribution_perspective.gif">
-               </perspective>
-               <perspective
-            name="SLC Distribution"
-            class="org.argeo.slc.client.ui.dist.AnonymousDistributionPerspective"
-            id="org.argeo.slc.client.ui.dist.anonymousDistributionPerspective"
-            icon="icons/repo.gif">
-               </perspective>
-   </extension>
-   <!-- VIEWS -->
-   <extension
-               point="org.eclipse.ui.views">
-               <view
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            id="org.argeo.slc.client.ui.dist.distributionsView"
-            icon="icons/search.gif"
-            name="Distributions">
-               </view>
-               <view
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            id="org.argeo.slc.client.ui.dist.anonymousDistributionsView"
-            icon="icons/search.gif"
-            name="Public Repository">
-               </view>
-               <view
-            class="org.argeo.slc.client.ui.dist.views.HelpView"
-            id="org.argeo.slc.client.ui.dist.helpView"
-            icon="icons/help.gif"
-            name="About">
-               </view>
-               <!--
-               <view
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            id="org.argeo.slc.client.ui.dist.artifactsBrowser"
-            icon="icons/packageBrowser.gif"
-            name="Artifacts browser">
-               </view>
-               <view
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            id="org.argeo.slc.client.ui.dist.queryArtifactsForm"
-            icon="icons/searchForm.gif"
-            name="Artifacts Form">
-               </view>
-               <view
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            id="org.argeo.slc.client.ui.dist.queryBundlesForm"
-            icon="icons/searchForm.gif"
-                       name="Bundles Form">
-               </view>
-               <view
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            id="org.argeo.slc.client.ui.dist.queryArtifactsText"
-            icon="icons/search.gif"
-            name="Query builder">
-               </view>
-               -->
-               <view
-                name="Progress View"
-                icon="icons/pview.gif"
-                category="org.eclipse.ui"
-                class="org.eclipse.ui.ExtensionFactory:progressView"
-                id="org.eclipse.ui.views.ProgressView">
-               </view>
-       </extension>
-       <!-- EDITORS -->
-       <extension
-               point="org.eclipse.ui.editors">
-               <!-- <editor
-                       class="org.argeo.slc.client.ui.dist.editors.GenericBundleEditor"
-                       id="org.argeo.slc.client.ui.dist.genericBundleEditor"
-                       name="Bundle editor"
-                       icon="icons/artifactVersionBase.gif"
-                       default="false">
-               </editor> -->
-               <editor
-                       class="org.argeo.eclipse.spring.SpringExtensionFactory"
-                       id="org.argeo.slc.client.ui.dist.artifactVersionEditor"
-                       name="Artifact Version Editor"
-                       icon="icons/artifactVersionBase.gif"
-                       default="false">
-               </editor>
-               <editor
-                       class="org.argeo.eclipse.spring.SpringExtensionFactory"
-                       id="org.argeo.slc.client.ui.dist.modularDistVersionEditor"
-                       name="Modular Distribution Version Editor"
-                       icon="icons/modularDistributionVersion.gif"
-                       default="false">
-               </editor>
-               <editor
-                       class="org.argeo.eclipse.spring.SpringExtensionFactory"
-                       id="org.argeo.slc.client.ui.dist.distWorkspaceEditor"
-                       name="Distribution workspace editor"
-                       icon="icons/distribution_perspective.gif"
-                       default="false">
-               </editor>
-       </extension>
-
-    <!-- COMMANDS  --> 
-       <extension
-         point="org.eclipse.ui.commands">
-               
-               <!-- Distribution Managemnt -->
-               <command
-            id="org.argeo.slc.client.ui.dist.normalizeDistribution"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Normalize Distribution">
-                       <commandParameter
-                               id="workspaceName"
-                               name="Workspace name">
-                       </commandParameter>
-                       <commandParameter
-                               id="targetRepoPath"
-                               name="Target repo node path">
-                       </commandParameter>
-       </command>
-       
-       <command
-            id="org.argeo.slc.client.ui.dist.openModuleEditor"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Open Workspace Editor">
-                       <commandParameter
-                               id="param.repoNodePath"
-                               name="Repo node path">
-                       </commandParameter>
-                       <commandParameter
-                               id="param.repoUri"
-                               name="Repo URI">
-                       </commandParameter>
-                       <commandParameter
-                               id="param.workspaceName"
-                               name="Workspace name">
-                       </commandParameter>
-                       <commandParameter
-                               id="param.modulePath"
-                               name="Module path name">
-                       </commandParameter>
-       </command>
-       
-       <!-- Repository Management --> 
-       <command
-            id="org.argeo.slc.client.ui.dist.registerRepository"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Add Repository">
-       </command>
-       <command
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            id="org.argeo.slc.client.ui.dist.unregisterRemoteRepo"
-            name="Unregister remote repository">
-            <commandParameter
-                       id="org.argeo.slc.client.ui.dist.repoNodePath"
-                       name="Remote Repo path">
-                       </commandParameter>
-       </command>
-               <command
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            id="org.argeo.slc.client.ui.dist.displayRepoInformation"
-            name="Display repository information">
-       </command>
-       
-       <!-- Workspace Management -->
-               <command
-            id="org.argeo.slc.client.ui.dist.openWorkspaceEditor"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Open Workspace Editor">
-                       <commandParameter
-                               id="param.repoNodePath"
-                               name="Repo node path">
-                       </commandParameter>
-                       <commandParameter
-                               id="param.repoUri"
-                               name="Repo URI">
-                       </commandParameter>
-                       <commandParameter
-                               id="param.workspaceName"
-                               name="Workspace name">
-                       </commandParameter>
-       </command>
-       <command
-            id="org.argeo.slc.client.ui.dist.fetch"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Fetch repository">
-            <commandParameter
-                       id="targetRepoPath"
-                       name="Target repo uri">
-                       </commandParameter>
-       </command>
-       
-       <!-- <command
-            defaultHandler="org.argeo.slc.client.ui.dist.commands.MarkAsRelevantCategory"
-            id="org.argeo.slc.client.ui.dist.markAsRelevantCategory"
-            name="Mark as relevant category">
-       </command> --> 
-       
-       <command
-            id="org.argeo.slc.client.ui.dist.openGenerateBinariesWizard"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Generate Binaries...">
-            <commandParameter
-                               id="param.repoNodePath"
-                               name="Repo node path">
-                       </commandParameter>
-                       <commandParameter
-                               id="param.workspaceName"
-                               name="Workspace name">
-                       </commandParameter>
-                       <commandParameter
-                               id="param.modulePath"
-                               name="Module path name">
-                       </commandParameter>
-       </command>
-       
-       <command
-            id="org.argeo.slc.client.ui.dist.normalizeWorkspace"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Normalize Workspace">
-                       <commandParameter
-                               id="workspaceName"
-                               name="Workspace name">
-                       </commandParameter>
-                       <commandParameter
-                               id="targetRepoPath"
-                               name="Target repo node path">
-                       </commandParameter>
-       </command>
-       <command
-            id="org.argeo.slc.client.ui.dist.manageWorkspaceAuth"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Manage workspace authorizations">
-            <commandParameter
-                       id="org.argeo.slc.client.ui.dist.workspaceName"
-                       name="Workspace Name">
-                       </commandParameter>
-       </command>
-
-       <command
-            id="org.argeo.slc.client.ui.dist.publishWorkspace"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Publish selected workspace">
-                       <commandParameter
-                               id="workspaceName"
-                               name="Workspace name">
-                       </commandParameter>
-                       <commandParameter
-                               id="targetRepoPath"
-                               name="Target repo node path">
-                       </commandParameter>
-       </command>
-       
-               <command
-            id="org.argeo.slc.client.ui.dist.mergeWorkspaces"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Copy chosen Workspace">
-            <commandParameter
-                       id="srcWkspName"
-                       name="Source Workspace Name">
-                       </commandParameter>
-          <commandParameter
-                       id="srcRepoPath"
-                       name="Source Repo Node path ">
-                       </commandParameter>
-           <commandParameter
-                       id="targetWkspName"
-                       name="Target Workspace Name">
-                       </commandParameter>
-            <commandParameter
-                       id="targetRepoPath"
-                       name="Target repo node path">
-                       </commandParameter>
-       </command>
-       
-       <!-- Workspaces CRUD --> 
-               <!-- Generic new and copy workspace -->
-               <command
-            id="org.argeo.slc.client.ui.dist.createWorkspace"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Create Workspace">
-            <commandParameter
-                       id="workspacePrefix"
-                       name="Workspace prefix">
-                       </commandParameter>
-            <commandParameter
-                       id="targetRepoPath"
-                       name="Target repo node path">
-                       </commandParameter>
-       </command>
-       <command
-            id="org.argeo.slc.client.ui.dist.copyWorkspace"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Copy chosen Workspace">
-            <commandParameter
-                       id="srcWkspName"
-                       name="Source Workspace Name">
-                       </commandParameter>
-            <commandParameter
-                       id="targetRepoPath"
-                       name="Target repo node path">
-                       </commandParameter>
-       </command>
-       <!-- Specific for local java workspaces --> 
-       <command
-            id="org.argeo.slc.client.ui.dist.createLocalJavaWorkspace"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Create Local Java Workspace">
-            <commandParameter
-                       id="workspacePrefix"
-                       name="Workspace prefix">
-                       </commandParameter>
-       </command>
-               <command
-            id="org.argeo.slc.client.ui.dist.copyLocalJavaWorkspace"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Copy chosen local Java Workspace">
-            <commandParameter
-                       id="srcWkspName"
-                       name="Source Workspace Name">
-                       </commandParameter>
-       </command>
-               
-               <!-- Not terminated delete command - does not really work -->
-       <command
-                       id="org.argeo.slc.client.ui.dist.deleteWorkspace"
-                       defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-                       name="Delete chosen Workspace">
-                       <commandParameter
-                               id="workspaceName"
-                               name="Workspace name">
-                       </commandParameter>
-                       <commandParameter
-                               id="targetRepoPath"
-                               name="Target repo node path">
-                       </commandParameter>
-       </command>
-       
-               <!-- Advanced commands --> 
-               <command
-            id="org.argeo.slc.client.ui.dist.doNothing"
-            defaultHandler="org.argeo.slc.client.ui.dist.commands.DoNothing"
-            name="Advanced">
-       </command>
-               <command
-            id="org.argeo.slc.client.ui.dist.runInOsgi"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Run in OSGi">
-            <commandParameter
-                       id="workspaceName"
-                       name="Workspace Name">
-                       </commandParameter>
-            <commandParameter
-                  id="modulePath"
-                  name="Module Path"
-                  optional="true">
-            </commandParameter>
-       </command>
-       <command
-            id="org.argeo.slc.client.ui.dist.refreshDistributionsView"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Refresh Distributions View">
-       </command>
-               
-               <!-- Legacy -->
-               <command
-            defaultHandler="org.argeo.slc.client.ui.dist.commands.RefreshArtifactBrowser"
-            id="org.argeo.slc.client.ui.dist.refreshArtifactBrowser"
-            name="Refresh Artifact Browser">
-       </command>
-               
-       <command
-            defaultHandler="org.argeo.slc.client.ui.dist.commands.ShowSizeColumn"
-            id="org.argeo.slc.client.ui.dist.showSizeColumn"
-            name="Show size column">
-            <state 
-                               id="org.argeo.slc.client.ui.dist.showSizeColumn.toggleState">
-                               <class class="org.eclipse.jface.commands.ToggleState"> 
-                                       <parameter
-                                               name="default"
-                                       value="true" />
-                               </class>
-                       </state>
-       </command>
-       <command
-            id="org.argeo.slc.client.ui.dist.deleteArtifacts"
-            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Remove selected artifacts">
-       </command>
-    </extension>
-    
-       <!-- MENU CONTRIBUTIONS --> 
-       <extension
-         id="menu:org.eclipse.ui.main.menu"
-         point="org.eclipse.ui.menus">
-               <!-- Distributions view tool bar --> 
-               <menuContribution
-               locationURI="toolbar:org.argeo.slc.client.ui.dist.distributionsView">
-            <command
-               commandId="org.argeo.slc.client.ui.dist.registerRepository"
-                icon="icons/addRepo.gif"
-                label="Register repository"
-                tooltip="Register a remote repository">
-            </command>
-             <command
-                commandId="org.argeo.slc.client.ui.dist.doNothing"
-                 id="org.argeo.slc.client.ui.dist.advancedMenu"
-                 icon="icons/more.gif"
-                 tooltip="Access to advanced commands"
-                 style="pulldown">
-           </command>
-        </menuContribution>
-               <menuContribution locationURI="menu:org.argeo.slc.client.ui.dist.advancedMenu">
-               <command
-                               commandId="org.argeo.slc.client.ui.dist.refreshDistributionsView"
-                               icon="icons/refresh.png"
-                               label="Refresh"
-                               tooltip="Force the full refresh of the distribution tree (close all open connections)">
-                       </command>
-            <!-- <command
-               commandId="org.argeo.slc.client.ui.dist.runInOSGi"
-                icon="icons/showSize.gif"
-                label="Run in OSGi"
-                tooltip="Run in a spearate OSGi runtime">
-            </command>
-            -->
-               </menuContribution>
-               <!-- Anonymous distribution view toolbar -->             
-        <menuContribution
-               locationURI="toolbar:org.argeo.slc.client.ui.dist.anonymousDistributionsView">
-            <command
-               commandId="org.argeo.slc.client.ui.dist.refreshDistributionsView"
-                icon="icons/refresh.png"
-                label="Refresh"
-                tooltip="Force the full refresh of the distribution tree (close all open connections)">
-            </command>
-        </menuContribution>
-        <!-- Artifact Browser Tool bar --> 
-               <menuContribution
-               locationURI="toolbar:org.argeo.slc.client.ui.dist.artifactsBrowser">
-            <command
-               commandId="org.argeo.slc.client.ui.dist.showSizeColumn"
-                icon="icons/showSize.gif"
-                style="toggle" 
-                label="Show sizes"
-                tooltip="Warning: showing size column might reduce overall browser reactivity">
-            </command>
-                       <command
-               commandId="org.argeo.slc.client.ui.dist.refreshArtifactBrowser"
-                icon="icons/refresh.png"
-                       label="Refresh"
-                tooltip="Refresh the whole browser">
-            </command>
-        </menuContribution>
-        <!-- Queries --> 
-               <!-- <menuContribution
-                allPopups="false"
-                locationURI="menu:org.eclipse.ui.main.menu?after=edit">
-               <menu label="Queries"
-              mnemonic="Queries"
-              id="org.argeo.slc.client.ui.dist.queryMenu">
-                <command
-                      commandId="org.argeo.slc.client.ui.dist.openGenericJcrQueryEditor"
-                      disabledIcon="icons/saveDisabled.gif"
-                      icon="icons/results.gif"
-                      label="JCR Query"
-                      style="push"
-                      tooltip="Open JCR query editor">
-                </command>
-             </menu>
-          </menuContribution> -->
-       </extension>
-       <extension
-           point="org.eclipse.ui.activities">
-        <!-- TODO: find a way to exclude evrything -->
-        <activityPatternBinding
-              activityId="org.argeo.slc.client.ui.slcActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.slc.client.ui.dist/org.argeo.slc.client.ui.dist.distributionPerspective">
-        </activityPatternBinding>
-        <activityPatternBinding
-              activityId="org.argeo.security.ui.adminActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.slc.client.ui.dist/org.argeo.slc.client.ui.dist.distributionPerspective">
-        </activityPatternBinding>
-     </extension>
-</plugin>
diff --git a/cms/org.argeo.slc.client.ui.dist/pom.xml b/cms/org.argeo.slc.client.ui.dist/pom.xml
deleted file mode 100644 (file)
index b71f0f5..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.client.ui.dist</artifactId>
-       <name>SLC Client UI Distribution</name>
-       <packaging>jar</packaging>
-       <dependencies>
-               <!-- Commons UI -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.eclipse.ui</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc.legacy.commons</groupId>
-                       <artifactId>org.argeo.cms.ui.workbench</artifactId>
-                       <version>${version.argeo-commons-legacy}</version>
-               </dependency>
-
-
-               <!-- SLC repo -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.api</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.repo</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.spring</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.server.repo</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Argeo Base dependencies -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.core</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-
-               <!-- RAP workbench -->
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>argeo-tp-rap-e3</artifactId>
-                       <version>${version.argeo-tp}</version>
-                       <type>pom</type>
-                       <scope>provided</scope>
-               </dependency>
-
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/AnonymousDistributionPerspective.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/AnonymousDistributionPerspective.java
deleted file mode 100644 (file)
index e2418a8..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.argeo.slc.client.ui.dist;
-
-import org.argeo.slc.client.ui.dist.views.AnonymousDistributionsView;
-import org.argeo.slc.client.ui.dist.views.HelpView;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Simple default perspective that presents public repositories */
-public class AnonymousDistributionPerspective implements IPerspectiveFactory {
-
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".anonymousDistributionPerspective";
-
-       public void createInitialLayout(IPageLayout layout) {
-               String editorArea = layout.getEditorArea();
-               layout.setEditorAreaVisible(true);
-               layout.setFixed(false);
-
-               IFolderLayout main = layout.createFolder("main", IPageLayout.LEFT,
-                               0.3f, editorArea);
-               main.addView(AnonymousDistributionsView.ID);
-               main.addView(HelpView.ID);
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistConstants.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistConstants.java
deleted file mode 100644 (file)
index 10e5f6a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.argeo.slc.client.ui.dist;
-
-import org.argeo.slc.SlcNames;
-import org.osgi.framework.Constants;
-
-/** Constants used across the application. */
-public interface DistConstants {
-
-       /*
-        * MISCEALLENEOUS
-        */
-       public final static String DATE_TIME_FORMAT = "MM/dd/yyyy, HH:mm";
-       public final static String DATE_FORMAT = "MM/dd/yyyy";
-       // this should be directly retrieved from JCR APIs once we have solved the
-       // problem of the translation of name space to shortcut, typically
-       // {http://www.jcp.org/jcr/1.0} to jcr:
-       public final static String JCR_IDENTIFIER = "jcr:uuid";
-       public final static String JCR_MIXIN_TYPES = "jcr:mixinTypes";
-
-       // FIXME: should be defined in SlcNames
-       public final static String SLC_BUNDLE_NAME = SlcNames.SLC_
-                       + Constants.BUNDLE_NAME;
-       public final static String SLC_BUNDLE_LICENCE = SlcNames.SLC_
-                       + "Bundle-License";
-       public final static String SLC_BUNDLE_VENDOR = SlcNames.SLC_
-                       + Constants.BUNDLE_VENDOR;
-
-       public final static String SLC_BUNDLE_DESCRIPTION = SlcNames.SLC_
-                       + Constants.BUNDLE_DESCRIPTION;
-
-       public final String DEFAULT_PUBLIC_REPOSITORY_URI = "vm:///java";
-
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistImages.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistImages.java
deleted file mode 100644 (file)
index 9f5cba1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.argeo.slc.client.ui.dist;
-
-import org.eclipse.swt.graphics.Image;
-
-/** Shared icons. */
-public class DistImages {
-
-       public final static Image IMG_ARTIFACT_BASE = DistPlugin
-                       .getImageDescriptor("icons/artifactBase.gif").createImage();
-       public final static Image IMG_PACKAGE = DistPlugin.getImageDescriptor(
-                       "icons/package.gif").createImage();
-       public final static Image IMG_BUNDLE = DistPlugin.getImageDescriptor(
-                       "icons/packages.gif").createImage();
-       public final static Image IMG_ARTIFACT_VERSION_BASE = DistPlugin
-                       .getImageDescriptor("icons/artifactVersionBase.gif").createImage();
-       public final static Image IMG_FILE = DistPlugin.getImageDescriptor(
-                       "icons/file.gif").createImage();
-
-       /* WORKSPACES */
-       public final static Image IMG_WKSP = DistPlugin.getImageDescriptor(
-                       "icons/distribution_perspective.gif").createImage();
-
-       /* REPOSITORIES */
-       public final static Image IMG_REPO = DistPlugin.getImageDescriptor(
-                       "icons/repo.gif").createImage();
-       public final static Image IMG_HOME_REPO = DistPlugin.getImageDescriptor(
-                       "icons/homeRepo.gif").createImage();
-       public final static Image IMG_REPO_READONLY = DistPlugin
-                       .getImageDescriptor("icons/repoReadOnly.gif").createImage();
-       public final static Image IMG_ADD_REPO = DistPlugin.getImageDescriptor(
-                       "icons/addRepo.gif").createImage();
-       public final static Image IMG_REMOVE_REPO = DistPlugin.getImageDescriptor(
-                       "icons/artifactBase.gif").createImage();
-       public final static Image IMG_FETCH_REPO = DistPlugin.getImageDescriptor(
-                       "icons/fetchRepo.png").createImage();
-
-       /* DISTRIBUTIONS */
-       public final static Image IMG_WKSP_GROUP = DistPlugin.getImageDescriptor(
-                       "icons/wkspGroup.gif").createImage();
-       public final static Image IMG_DISTGRP = DistPlugin.getImageDescriptor(
-                       "icons/distGrp.gif").createImage();
-       public final static Image IMG_DISTGRP_READONLY = DistPlugin
-                       .getImageDescriptor("icons/distGrpReadOnly.gif").createImage();
-
-       public final static Image IMG_MODULAR_DIST_BASE = DistPlugin
-                       .getImageDescriptor("icons/packages.gif").createImage();
-       public final static Image IMG_MODULAR_DIST_VERSION = DistPlugin
-                       .getImageDescriptor("icons/packages.gif").createImage();
-
-       public final static Image IMG_GROUP_BASE = DistPlugin.getImageDescriptor(
-                       "icons/packages.gif").createImage();
-
-       /* Various */
-       public final static Image CHECKED = DistPlugin.getImageDescriptor(
-                       "icons/checked.gif").createImage();
-       public final static Image UNCHECKED = DistPlugin.getImageDescriptor(
-                       "icons/unchecked.gif").createImage();
-       public final static Image IMG_CLEAR = DistPlugin.getImageDescriptor(
-                       "icons/clear.gif").createImage();
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistPlugin.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistPlugin.java
deleted file mode 100644 (file)
index b85fcba..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.argeo.slc.client.ui.dist;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/** Default activator for the distribution bundle */
-public class DistPlugin extends AbstractUIPlugin {
-       public final static String PLUGIN_ID = "org.argeo.slc.client.ui.dist";
-
-       private static DistPlugin plugin;
-
-       public void start(BundleContext context) throws Exception {
-               super.start(context);
-               plugin = this;
-       }
-
-       public static DistPlugin getDefault() {
-               return plugin;
-       }
-
-       public static ImageDescriptor getImageDescriptor(String path) {
-               return imageDescriptorFromPlugin(PLUGIN_ID, path);
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistributionPerspective.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistributionPerspective.java
deleted file mode 100644 (file)
index cedc2eb..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.argeo.slc.client.ui.dist;
-
-import org.argeo.slc.client.ui.dist.views.DistributionsView;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Manage a set of software repositories */
-public class DistributionPerspective implements IPerspectiveFactory {
-
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".distributionPerspective";
-
-       public void createInitialLayout(IPageLayout layout) {
-               String editorArea = layout.getEditorArea();
-               layout.setEditorAreaVisible(true);
-               layout.setFixed(false);
-
-               IFolderLayout main = layout.createFolder("main", IPageLayout.LEFT,
-                               0.3f, editorArea);
-               main.addView(DistributionsView.ID);
-               IFolderLayout bottom = layout.createFolder("bottom",
-                               IPageLayout.BOTTOM, 0.75f, editorArea);
-               bottom.addView("org.eclipse.ui.views.ProgressView");
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/BndProcess.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/BndProcess.java
deleted file mode 100644 (file)
index 2573496..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.jar.Manifest;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-import aQute.bnd.osgi.Builder;
-import aQute.bnd.osgi.Constants;
-import aQute.bnd.osgi.Jar;
-
-public class BndProcess extends AbstractHandler implements Constants {
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               try {
-                       Builder b = new Builder();
-                       b.setProperty(EXPORT_PACKAGE, "org.osgi.framework");
-                       b.setProperty(PRIVATE_PACKAGE, "*");
-                       b.addClasspath(new File(
-                                       "/home/mbaudier/.m2/repository/org/eclipse/osgi/org.eclipse.osgi/3.6.1/org.eclipse.osgi-3.6.1.jar"));
-
-                       Jar jar = b.build();
-                       Manifest m = jar.getManifest();
-                       jar.write(new File(b.getBsn() + ".jar"));
-               } catch (IOException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } catch (Exception e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-
-               return null;
-       }
-
-       public static void main(String[] args) {
-               try {
-                       new BndProcess().execute(null);
-               } catch (ExecutionException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyLocalJavaWorkspace.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyLocalJavaWorkspace.java
deleted file mode 100644 (file)
index 7d26f90..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.JavaRepoManager;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Create a copy of the chosen workspace in the local Java repository using a
- * JavaRepoManager.
- */
-public class CopyLocalJavaWorkspace extends AbstractHandler {
-       private static final Log log = LogFactory
-                       .getLog(CopyLocalJavaWorkspace.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".copyLocalJavaWorkspace";
-       public final static String DEFAULT_LABEL = "Copy Java Workspace...";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/addItem.gif");
-
-       public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
-
-       // DEPENDENCY INJECTION
-       private Repository javaRepository;
-       private JavaRepoManager javaRepoManager;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               String wkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
-
-               InputDialog inputDialog = new InputDialog(HandlerUtil
-                               .getActiveWorkbenchWindow(event).getShell(),
-                               "New copy of workspace " + wkspName,
-                               "Choose a name for the workspace to create", "", null);
-               int result = inputDialog.open();
-               if (result == Window.OK) {
-                       String newWorkspaceName = inputDialog.getValue();
-
-                       if (newWorkspaceName == null || newWorkspaceName.trim().equals("")
-                                       || newWorkspaceName.trim().equals(wkspName.trim())) {
-                               ErrorDialog
-                                               .openError(HandlerUtil.getActiveShell(event),
-                                                               "Non valid workspace name", newWorkspaceName
-                                                                               + " is not a valid workspace name.",
-                                                               new Status(IStatus.ERROR, "not valid", 0,
-                                                                               "Error", null));
-                               return null;
-                       }
-                       Job copyWkspJob = new CopyWkspJob(javaRepoManager, javaRepository,
-                                       wkspName, newWorkspaceName, HandlerUtil
-                                                       .getActiveWorkbenchWindow(event).getShell()
-                                                       .getDisplay());
-                       copyWkspJob.setUser(true);
-                       copyWkspJob.schedule();
-               }
-               return null;
-       }
-
-       private static class CopyWkspJob extends PrivilegedJob {
-
-               private JavaRepoManager javaRepoManager;
-               private Repository javaRepository;
-               private String srcWkspName;
-               private String targetWkspName;
-               private Display display;
-
-               public CopyWkspJob(JavaRepoManager javaRepoManager,
-                               Repository javaRepository, String srcWkspName,
-                               String targetWkspName, Display display) {
-                       super("Duplicate workspace");
-                       this.javaRepoManager = javaRepoManager;
-                       this.javaRepository = javaRepository;
-                       this.srcWkspName = srcWkspName;
-                       this.targetWkspName = targetWkspName;
-                       this.display = display;
-               }
-
-               @Override
-               protected IStatus doRun(IProgressMonitor progressMonitor) {
-                       long begin = System.currentTimeMillis();
-
-                       JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
-                       monitor.beginTask("Copy workspace", -1);
-                       monitor.subTask("Copying nodes");
-
-                       Session srcSession = null;
-                       Session targetSession = null;
-                       try {
-                               // Initialize source
-                               srcSession = javaRepository.login(srcWkspName);
-                               Node srcRootNode = srcSession.getRootNode();
-
-                               // Create the workspace -
-                               // FIXME will throw an error if workspace already exists
-                               javaRepoManager.createWorkspace(targetWkspName);
-                               targetSession = javaRepository.login(targetWkspName);
-                               Node newRootNode = targetSession.getRootNode();
-
-                               RepoUtils.copy(srcRootNode, newRootNode, monitor);
-                               targetSession.save();
-                               JcrUtils.addPrivilege(targetSession, "/",
-                                               SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
-                               monitor.worked(1);
-
-                               display.asyncExec(new Runnable() {
-                                       public void run() {
-                                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
-                                       }
-                               });
-
-                       } catch (RepositoryException re) {
-                               throw new SlcException(
-                                               "Unexpected error while creating the new workspace.",
-                                               re);
-                       } finally {
-                               JcrUtils.logoutQuietly(srcSession);
-                               JcrUtils.logoutQuietly(targetSession);
-                       }
-
-                       monitor.done();
-                       long duration = (System.currentTimeMillis() - begin) / 1000;// in
-                                                                                                                                               // s
-                       if (log.isDebugEnabled())
-                               log.debug("Duplicated local java workspace " + srcWkspName
-                                               + " to workspace " + targetWkspName + " in "
-                                               + (duration / 60) + "min " + (duration % 60) + "s");
-                       return Status.OK_STATUS;
-               }
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setJavaRepository(Repository javaRepository) {
-               this.javaRepository = javaRepository;
-       }
-
-       public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
-               this.javaRepoManager = javaRepoManager;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyWorkspace.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyWorkspace.java
deleted file mode 100644 (file)
index 4abdfab..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Create a copy of the chosen workspace in a remote repository */
-public class CopyWorkspace extends AbstractHandler {
-       private static final Log log = LogFactory.getLog(CopyWorkspace.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".copyWorkspace";
-       public final static String DEFAULT_LABEL = "Duplicate...";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/addItem.gif");
-
-       public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
-       // DEPENDENCY INJECTION
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       private Repository nodeRepository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
-               String wkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
-
-               InputDialog inputDialog = new InputDialog(HandlerUtil
-                               .getActiveWorkbenchWindow(event).getShell(),
-                               "New copy of workspace " + wkspName,
-                               "Choose a name for the workspace to create", "", null);
-               int result = inputDialog.open();
-               if (result == Window.OK) {
-                       String newWorkspaceName = inputDialog.getValue();
-
-                       if (newWorkspaceName == null || newWorkspaceName.trim().equals("")
-                                       || newWorkspaceName.trim().equals(wkspName.trim())) {
-                               ErrorDialog
-                                               .openError(HandlerUtil.getActiveShell(event),
-                                                               "Non valid workspace name", newWorkspaceName
-                                                                               + " is not a valid workspace name.",
-                                                               new Status(IStatus.ERROR, "not valid", 0,
-                                                                               "Error", null));
-                               return null;
-                       }
-                       Job copyWkspJob = new CopyWkspJob(repositoryFactory, keyring,
-                                       nodeRepository, targetRepoPath, wkspName, newWorkspaceName,
-                                       HandlerUtil.getActiveWorkbenchWindow(event).getShell()
-                                                       .getDisplay());
-                       copyWkspJob.setUser(true);
-                       copyWkspJob.schedule();
-               }
-               return null;
-       }
-
-       private static class CopyWkspJob extends PrivilegedJob {
-
-               private RepositoryFactory repositoryFactory;
-               private Keyring keyring;
-               private Repository localRepository;
-               private String targetRepoPath;
-               private String srcWkspName;
-               private String targetWkspName;
-               private Display display;
-
-               public CopyWkspJob(RepositoryFactory repositoryFactory,
-                               Keyring keyring, Repository localRepository,
-                               String targetRepoPath, String srcWkspName,
-                               String targetWkspName, Display display) {
-                       super("Duplicate workspace");
-                       this.repositoryFactory = repositoryFactory;
-                       this.keyring = keyring;
-                       this.localRepository = localRepository;
-                       this.targetRepoPath = targetRepoPath;
-                       this.srcWkspName = srcWkspName;
-                       this.targetWkspName = targetWkspName;
-                       this.display = display;
-               }
-
-               @Override
-               protected IStatus doRun(IProgressMonitor progressMonitor) {
-                       long begin = System.currentTimeMillis();
-
-                       JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
-                       monitor.beginTask("Copy workspace", -1);
-                       monitor.subTask("Copying nodes");
-
-                       Session nodeSession = null;
-                       Session srcSession = null;
-                       Session newSession = null;
-                       try {
-                               nodeSession = localRepository.login();
-                               Node repoNode = nodeSession.getNode(targetRepoPath);
-                               Repository repository = RepoUtils.getRepository(
-                                               repositoryFactory, keyring, repoNode);
-                               Credentials credentials = RepoUtils.getRepositoryCredentials(
-                                               keyring, repoNode);
-
-                               srcSession = repository.login(credentials, srcWkspName);
-
-                               // Create the workspace
-                               srcSession.getWorkspace().createWorkspace(targetWkspName);
-                               Node srcRootNode = srcSession.getRootNode();
-                               // log in the newly created workspace
-                               newSession = repository.login(credentials, targetWkspName);
-                               Node newRootNode = newSession.getRootNode();
-                               RepoUtils.copy(srcRootNode, newRootNode, monitor);
-                               newSession.save();
-                               JcrUtils.addPrivilege(newSession, "/", SlcConstants.ROLE_SLC,
-                                               Privilege.JCR_ALL);
-
-                               display.asyncExec(new Runnable() {
-                                       public void run() {
-                                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
-                                       }
-                               });
-                               monitor.worked(1);
-
-                       } catch (RepositoryException re) {
-                               throw new SlcException(
-                                               "Unexpected error while creating the new workspace.",
-                                               re);
-                       } finally {
-                               JcrUtils.logoutQuietly(newSession);
-                               JcrUtils.logoutQuietly(srcSession);
-                               JcrUtils.logoutQuietly(nodeSession);
-                       }
-
-                       monitor.done();
-                       long duration = (System.currentTimeMillis() - begin) / 1000;// in
-                                                                                                                                               // s
-                       if (log.isDebugEnabled())
-                               log.debug("Created workspace " + targetWkspName + " in "
-                                               + (duration / 60) + "min " + (duration % 60) + "s");
-                       return Status.OK_STATUS;
-               }
-
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateLocalJavaWorkspace.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateLocalJavaWorkspace.java
deleted file mode 100644 (file)
index dd15ecf..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.JavaRepoManager;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Create a new empty workspace in the default local java repository */
-public class CreateLocalJavaWorkspace extends AbstractHandler {
-       private static final Log log = LogFactory
-                       .getLog(CreateLocalJavaWorkspace.class);
-
-       // Exposes commands meta-info
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".createLocalJavaWorkspace";
-       public final static String DEFAULT_LABEL = "Create local Java workspace...";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/addItem.gif");
-
-       // Parameters
-       public final static String PARAM_WORKSPACE_PREFIX = "workspacePrefix";
-
-       /* DEPENDENCY INJECTION */
-       private JavaRepoManager javaRepoManager;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               String prefix = event.getParameter(PARAM_WORKSPACE_PREFIX);
-               // TODO : add an input validator
-               InputDialog inputDialog = new InputDialog(HandlerUtil
-                               .getActiveWorkbenchWindow(event).getShell(), "Workspace name?",
-                               "Choose a name for the workspace to create",
-                               prefix == null ? "" : prefix + "-", null);
-               int result = inputDialog.open();
-
-               String enteredName = inputDialog.getValue();
-               final String legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
-               char[] arr = enteredName.toUpperCase().toCharArray();
-               int count = 0;
-               for (int i = 0; i < arr.length; i++) {
-                       if (legalChars.indexOf(arr[i]) == -1)
-                               count = count + 7;
-                       else
-                               count++;
-               }
-
-               if (count > 60) {
-                       ErrorFeedback.show("Workspace name '" + enteredName
-                                       + "' is too long or contains"
-                                       + " too many special characters such as '.' or '-'.");
-                       return null;
-               }
-
-               String workspaceName = enteredName;
-               // Canceled by user
-               if (result == Dialog.CANCEL || workspaceName == null
-                               || "".equals(workspaceName.trim()))
-                       return null;
-
-               // FIXME will throw an exception if this workspace name is already used.
-               javaRepoManager.createWorkspace(workspaceName);
-
-               CommandHelpers.callCommand(RefreshDistributionsView.ID);
-               if (log.isTraceEnabled())
-                       log.trace("WORKSPACE " + workspaceName + " CREATED");
-
-               return null;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
-               this.javaRepoManager = javaRepoManager;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateWorkspace.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateWorkspace.java
deleted file mode 100644 (file)
index 9934c86..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Create a new empty workspace in a remote repository */
-public class CreateWorkspace extends AbstractHandler {
-       private static final Log log = LogFactory.getLog(CreateWorkspace.class);
-
-       // Exposes commands meta-info
-       public final static String ID = DistPlugin.PLUGIN_ID + ".createWorkspace";
-       public final static String DEFAULT_LABEL = "Create workspace...";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/addItem.gif");
-
-       // Parameters
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-       public final static String PARAM_WORKSPACE_PREFIX = "workspacePrefix";
-
-       // DEPENDENCY INJECTION
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       private Repository nodeRepository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
-               String prefix = event.getParameter(PARAM_WORKSPACE_PREFIX);
-
-               Session nodeSession = null;
-               Session session = null;
-               try {
-                       nodeSession = nodeRepository.login();
-                       Node repoNode = nodeSession.getNode(targetRepoPath);
-                       Repository repository = RepoUtils.getRepository(repositoryFactory,
-                                       keyring, repoNode);
-                       Credentials credentials = RepoUtils.getRepositoryCredentials(
-                                       keyring, repoNode);
-
-                       // TODO : add an input validator
-                       InputDialog inputDialog = new InputDialog(HandlerUtil
-                                       .getActiveWorkbenchWindow(event).getShell(),
-                                       "Workspace name?",
-                                       "Choose a name for the workspace to create",
-                                       prefix == null ? "" : prefix + "-", null);
-                       int result = inputDialog.open();
-
-                       String enteredName = inputDialog.getValue();
-
-                       final String legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
-                       char[] arr = enteredName.toUpperCase().toCharArray();
-                       int count = 0;
-                       for (int i = 0; i < arr.length; i++) {
-                               if (legalChars.indexOf(arr[i]) == -1)
-                                       count = count + 7;
-                               else
-                                       count++;
-                       }
-
-                       if (log.isTraceEnabled())
-                               log.trace("Translated workspace name length: " + count
-                                               + " (name: " + enteredName + " )");
-
-                       if (count > 60) {
-                               ErrorFeedback.show("Workspace name '" + enteredName
-                                               + "' is too long or contains"
-                                               + " too many special characters such as '.' or '-'.");
-                               return null;
-                       }
-
-                       String workspaceName = enteredName;
-
-                       // Canceled by user
-                       if (result == Dialog.CANCEL || workspaceName == null
-                                       || "".equals(workspaceName.trim()))
-                               return null;
-
-                       session = repository.login(credentials);
-                       session.getWorkspace().createWorkspace(workspaceName);
-                       JcrUtils.logoutQuietly(session);
-                       // init new workspace
-                       session = repository.login(credentials, workspaceName);
-                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
-                                       Privilege.JCR_ALL);
-                       CommandHelpers.callCommand(RefreshDistributionsView.ID);
-                       if (log.isTraceEnabled())
-                               log.trace("WORKSPACE " + workspaceName + " CREATED");
-
-               } catch (RepositoryException re) {
-                       ErrorFeedback.show(
-                                       "Unexpected error while creating the new workspace.", re);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-                       JcrUtils.logoutQuietly(nodeSession);
-               }
-               return null;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteArtifacts.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteArtifacts.java
deleted file mode 100644 (file)
index 4caf2b5..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import java.util.Iterator;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Delete chosen artifacts from the current workspace */
-public class DeleteArtifacts extends AbstractHandler {
-       // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".deleteArtifacts";
-       public final static String DEFAULT_LABEL = "Delete selected items";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/removeItem.gif");
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               try {
-                       IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
-
-                       if (activePart instanceof IEditorPart) {
-                               ISelection selector = ((IEditorPart) activePart)
-                                               .getEditorSite().getSelectionProvider().getSelection();
-                               if (selector != null
-                                               && selector instanceof IStructuredSelection) {
-                                       Iterator<?> it = ((IStructuredSelection) selector)
-                                                       .iterator();
-
-                                       String msg = "Your are about to definitively remove the "
-                                                       + ((IStructuredSelection) selector).size()
-                                                       + " selected artifacts.\n"
-                                                       + "Are you sure you want to proceed?";
-
-                                       boolean result = MessageDialog.openConfirm(DistPlugin
-                                                       .getDefault().getWorkbench().getDisplay()
-                                                       .getActiveShell(), "Confirm Deletion", msg);
-
-                                       if (result) {
-                                               while (it.hasNext()) {
-                                                       Node node = (Node) it.next();
-                                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
-                                                               // we remove the artifactVersion, that is the
-                                                               // parent
-                                                               node.getParent().remove();
-                                                               node.getSession().save();
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-                       // CommandHelpers.callCommand(RefreshDistributionOverviewPage.ID);
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while deleting artifacts.", re);
-               }
-               return null;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java
deleted file mode 100644 (file)
index 4707fc0..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/**
- * Delete chosen workspace in the current repository.
- * 
- * Due to current version of JackRabbit, it only cleans it for the time being,
- * removing all nodes of type {@code NodeType.NT_FOLDER} and
- * {@code NodeType.NT_UNSTRUCTURED}
- */
-public class DeleteWorkspace extends AbstractHandler {
-       // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".deleteWorkspace";
-       public final static String DEFAULT_LABEL = "Clear";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/removeItem.gif");
-
-       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
-       // DEPENDENCY INJECTION
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       private Repository nodeRepository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
-               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
-
-               Session nodeSession = null;
-               Session session = null;
-               try {
-                       nodeSession = nodeRepository.login();
-                       Node repoNode = nodeSession.getNode(targetRepoPath);
-                       Repository repository = RepoUtils.getRepository(repositoryFactory,
-                                       keyring, repoNode);
-                       Credentials credentials = RepoUtils.getRepositoryCredentials(
-                                       keyring, repoNode);
-
-                       String msg = "Your are about to completely delete workspace ["
-                                       + workspaceName + "].\n Do you really want to proceed?";
-                       boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
-                                       .getWorkbench().getDisplay().getActiveShell(),
-                                       "Confirm workspace deletion", msg);
-
-                       if (result) {
-                               // msg =
-                               // "There is no possible turning back, are your REALLY sure you want to proceed ?";
-                               msg = "WARNING: \nCurrent Jackrabbit version used does "
-                                               + "not support workspace deletion.\n"
-                                               + "Thus, the workspace will only be cleaned so "
-                                               + "that you can launch fetch process again.\n\n"
-                                               + "Do you still want to proceed?";
-                               result = MessageDialog.openConfirm(DistPlugin.getDefault()
-                                               .getWorkbench().getDisplay().getActiveShell(),
-                                               "Confirm workspace deletion", msg);
-                       }
-
-                       if (result) {
-                               session = repository.login(credentials, workspaceName);
-                               // TODO use this with a newer version of Jackrabbit
-                               // Workspace wsp = session.getWorkspace();
-                               // wsp.deleteWorkspace(workspaceName);
-                               NodeIterator nit = session.getRootNode().getNodes();
-                               while (nit.hasNext()) {
-                                       Node node = nit.nextNode();
-                                       if (node.isNodeType(NodeType.NT_FOLDER)
-                                                       || node.isNodeType(NodeType.NT_UNSTRUCTURED)) {
-                                               // String path = node.getPath();
-                                               node.remove();
-                                               session.save();
-                                       }
-                               }
-                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while deleting workspace ["
-                                                       + workspaceName + "].", re);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-                       JcrUtils.logoutQuietly(nodeSession);
-               }
-               return null;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java
deleted file mode 100644 (file)
index 38e4367..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Open a dialog that displays various information on the current repository.
- */
-public class DisplayRepoInformation extends AbstractHandler {
-       public final static String ID = DistPlugin.PLUGIN_ID + ".displayRepoInformation";
-       public final static String DEFAULT_LABEL = "Information";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/help.gif");
-
-       /* DEPENDENCY INJECTION */
-       private RepoService repoService;
-       private Repository nodeRepository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               IStructuredSelection iss = (IStructuredSelection) HandlerUtil
-                               .getActiveSite(event).getSelectionProvider().getSelection();
-               if (iss.getFirstElement() instanceof RepoElem) {
-                       RepoElem re = (RepoElem) iss.getFirstElement();
-
-                       Session defaultSession = null;
-                       try {
-                               defaultSession = repoService.getRemoteSession(re.getRepoNodePath(),
-                                               re.getUri(), null);
-
-                               InformationDialog inputDialog = new InformationDialog(
-                                               HandlerUtil.getActiveSite(event).getShell());
-                               inputDialog.create();
-                               // TODO add more information.
-                               inputDialog.loginTxt.setText(defaultSession.getUserID());
-                               inputDialog.nameTxt.setText(re.getLabel());
-                               inputDialog.uriTxt.setText(re.getUri());
-                               inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
-
-                               inputDialog.open();
-                               // } catch (RepositoryException e) {
-                               // throw new SlcException("Unexpected error while "
-                               // + "getting repository information.", e);
-                       } finally {
-                               JcrUtils.logoutQuietly(defaultSession);
-                       }
-               }
-               return null;
-       }
-
-       private class InformationDialog extends Dialog {
-               Text nameTxt;
-               Text uriTxt;
-               Text loginTxt;
-               Button readOnlyBtn;
-
-               @Override
-               protected void createButtonsForButtonBar(Composite parent) {
-                       // No Cancel button
-                       createButton(parent, IDialogConstants.OK_ID, "OK", true);
-               }
-
-               public InformationDialog(Shell parentShell) {
-                       super(parentShell);
-               }
-
-               protected Point getInitialSize() {
-                       return new Point(500, 250);
-               }
-
-               protected Control createDialogArea(Composite parent) {
-                       Composite dialogarea = (Composite) super.createDialogArea(parent);
-                       dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
-                                       true));
-                       Composite composite = new Composite(dialogarea, SWT.NONE);
-                       GridLayout layout = new GridLayout(2, false);
-                       layout.horizontalSpacing = 15;
-                       composite.setLayout(layout);
-                       GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
-                       composite.setLayoutData(gd);
-
-                       nameTxt = createLT(composite, "Name");
-                       uriTxt = createLT(composite, "URI");
-                       loginTxt = createLT(composite, "Logged as");
-                       readOnlyBtn = createLC(composite, "Read only");
-                       parent.pack();
-                       return composite;
-               }
-
-               /** Creates label and text. */
-               protected Text createLT(Composite parent, String label) {
-                       new Label(parent, SWT.RIGHT).setText(label);
-                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.NONE);
-                       text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-                       text.setEditable(false);
-                       return text;
-               }
-
-               /** Creates label and check. */
-               protected Button createLC(Composite parent, String label) {
-                       new Label(parent, SWT.RIGHT).setText(label);
-                       Button check = new Button(parent, SWT.CHECK);
-                       check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-                       check.setEnabled(false);
-                       return check;
-               }
-
-               protected void configureShell(Shell shell) {
-                       super.configureShell(shell);
-                       shell.setText("Repository information");
-               }
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setRepoService(RepoService repoService) {
-               this.repoService = repoService;
-       }
-
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DoNothing.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DoNothing.java
deleted file mode 100644 (file)
index 2a9307a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Util command used to enable sub menus in various toolbars. Does nothing */
-public class DoNothing extends AbstractHandler {
-       public final static String ID = DistPlugin.PLUGIN_ID + ".doNothing";
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               return null;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/Fetch.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/Fetch.java
deleted file mode 100644 (file)
index 39a9274..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.client.ui.dist.wizards.FetchWizard;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Wrap a {@code RepoSync} as an Eclipse command. Open a wizard that enable
- * definition of the fetch process parameters
- */
-public class Fetch extends AbstractHandler {
-       // private final static Log log = LogFactory.getLog(Fetch.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".fetch";
-       public final static String DEFAULT_LABEL = "Fetch...";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/fetchRepo.png");
-
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
-       // DEPENDENCY INJECTION
-       private Keyring keyring;
-       private RepositoryFactory repositoryFactory;
-       private Repository nodeRepository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               Session currSession = null;
-               try {
-                       // Target Repository
-                       String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
-                       currSession = nodeRepository.login();
-                       Node targetRepoNode = currSession.getNode(targetRepoPath);
-
-                       FetchWizard wizard = new FetchWizard(keyring, repositoryFactory,
-                                       nodeRepository);
-                       wizard.setTargetRepoNode(targetRepoNode);
-                       WizardDialog dialog = new WizardDialog(
-                                       HandlerUtil.getActiveShell(event), wizard);
-
-                       int result = dialog.open();
-                       if (result == Dialog.OK)
-                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
-                       return null;
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unable te retrieve repo node from path", e);
-               } finally {
-                       JcrUtils.logoutQuietly(currSession);
-               }
-       }
-
-       // DEPENDENCY INJECTION
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-
-       public void setNodeRepository(Repository repository) {
-               this.nodeRepository = repository;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java
deleted file mode 100644 (file)
index 24e43cb..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.wizards.ChangeRightsWizard;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Open a dialog to manage rights on the current workspace's root node */
-public class ManageWorkspaceAuth extends AbstractHandler {
-       // private static final Log log =
-       // LogFactory.getLog(ManageWorkspaceAuth.class);
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".manageWorkspaceAuth";
-       public final static String DEFAULT_LABEL = "Manage Rights";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/changeRights.gif");
-
-       public final static String PARAM_WORKSPACE_NAME = DistPlugin.PLUGIN_ID
-                       + ".workspaceName";
-
-       /* DEPENDENCY INJECTION */
-       private Repository repository;
-       private Session session;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
-               try {
-                       session = repository.login(workspaceName);
-                       ChangeRightsWizard wizard = new ChangeRightsWizard(session);
-                       WizardDialog dialog = new WizardDialog(
-                                       HandlerUtil.getActiveShell(event), wizard);
-                       dialog.open();
-                       return null;
-               } catch (RepositoryException re) {
-                       throw new SlcException("Cannot log in the repository "
-                                       + repository + " in workspace " + workspaceName, re);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/MergeWorkspaces.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/MergeWorkspaces.java
deleted file mode 100644 (file)
index 70c3d7a..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryResult;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-
-/** Merge two workspaces */
-public class MergeWorkspaces extends AbstractHandler {
-       private final static Log log = LogFactory.getLog(MergeWorkspaces.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".mergeWorkspaces";
-       public final static String DEFAULT_LABEL = "Merge";
-
-       public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
-       public final static String PARAM_SOURCE_REPO_PATH = "srcRepoPath";
-       public final static String PARAM_TARGET_WORKSPACE_NAME = "targetWkspName";
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
-       // DEPENDENCY INJECTION
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       private Repository nodeRepository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
-               String targetWkspName = event.getParameter(PARAM_TARGET_WORKSPACE_NAME);
-               String sourceRepoPath = event.getParameter(PARAM_SOURCE_REPO_PATH);
-               String sourceWkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
-
-               Session nodeSession = null;
-               try {
-                       nodeSession = nodeRepository.login();
-                       Node srcRepoNode = nodeSession.getNode(sourceRepoPath);
-                       Repository srcRepository = RepoUtils.getRepository(repositoryFactory, keyring, srcRepoNode);
-                       Credentials srcCredentials = RepoUtils.getRepositoryCredentials(keyring, srcRepoNode);
-
-                       Node targetRepoNode = nodeSession.getNode(targetRepoPath);
-                       Repository targetRepository = RepoUtils.getRepository(repositoryFactory, keyring, targetRepoNode);
-                       Credentials targetCredentials = RepoUtils.getRepositoryCredentials(keyring, targetRepoNode);
-
-                       // String msg = "Are you sure you want to merge distribution ["
-                       // + sourceWkspName + "] in distribution [" + targetWkspName
-                       // + "] ?";
-                       //
-                       // boolean result = MessageDialog.openConfirm(
-                       // HandlerUtil.getActiveShell(event), "Confirm Merge", msg);
-
-                       // if (result) {
-                       // Open sessions here since the background thread
-                       // won't necessarily be authenticated.
-                       // Job should close the sessions.
-                       Session sourceSession = srcRepository.login(srcCredentials, sourceWkspName);
-                       Session targetSession;
-                       try {
-                               targetSession = targetRepository.login(targetCredentials, targetWkspName);
-                       } catch (NoSuchWorkspaceException e) {
-                               Session defaultSession = targetRepository.login(targetCredentials);
-                               try {
-                                       defaultSession.getWorkspace().createWorkspace(targetWkspName);
-                               } catch (Exception e1) {
-                                       throw new SlcException("Cannot create new workspace " + targetWkspName, e);
-                               } finally {
-                                       JcrUtils.logoutQuietly(defaultSession);
-                               }
-                               targetSession = targetRepository.login(targetCredentials, targetWkspName);
-                       }
-
-                       Job workspaceMergeJob = new WorkspaceMergeJob(sourceSession, targetSession);
-                       workspaceMergeJob.setUser(true);
-                       workspaceMergeJob.schedule();
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unexpected error while merging workspaces.", re);
-               } finally {
-                       JcrUtils.logoutQuietly(nodeSession);
-               }
-               return null;
-       }
-
-       private static class WorkspaceMergeJob extends Job {
-               private Session sourceSession;
-               private Session targetSession;
-
-               public WorkspaceMergeJob(Session sourceSession, Session targetSession) {
-                       super("Workspace merge");
-                       this.sourceSession = sourceSession;
-                       this.targetSession = targetSession;
-               }
-
-               @Override
-               protected IStatus run(IProgressMonitor eclipseMonitor) {
-                       long begin = System.currentTimeMillis();
-                       try {
-                               Query countQuery = sourceSession.getWorkspace().getQueryManager()
-                                               .createQuery("select file from [nt:file] as file", Query.JCR_SQL2);
-                               QueryResult result = countQuery.execute();
-                               Long expectedCount = result.getNodes().getSize();
-                               if (log.isDebugEnabled())
-                                       log.debug("Will copy " + expectedCount + " files...");
-
-                               JcrMonitor monitor = new EclipseJcrMonitor(eclipseMonitor);
-                               eclipseMonitor.beginTask("Copy files", expectedCount.intValue());
-
-                               Long count = JcrUtils.copyFiles(sourceSession.getRootNode(), targetSession.getRootNode(), true, monitor,
-                                               true);
-
-                               monitor.done();
-                               long duration = (System.currentTimeMillis() - begin) / 1000;// in
-                                                                                                                                                       // s
-                               if (log.isDebugEnabled())
-                                       log.debug("Copied " + count + " files in " + (duration / 60) + "min " + (duration % 60) + "s");
-
-                               return Status.OK_STATUS;
-                       } catch (RepositoryException e) {
-                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID, "Cannot merge", e);
-                       } finally {
-                               JcrUtils.logoutQuietly(sourceSession);
-                               JcrUtils.logoutQuietly(targetSession);
-                       }
-               }
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeDistribution.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeDistribution.java
deleted file mode 100644 (file)
index e35b9bc..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Binary;
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryResult;
-import javax.jcr.util.TraversingItemVisitor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.ArtifactIndexer;
-import org.argeo.slc.repo.JarFileIndexer;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.maven.AetherUtils;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.argeo.slc.repo.osgi.NormalizeGroup;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Legacy - Make sure than Maven and OSGi metadata are consistent */
-public class NormalizeDistribution extends AbstractHandler implements SlcNames {
-       private final static Log log = LogFactory
-                       .getLog(NormalizeDistribution.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".normalizeDistribution";
-       public final static String DEFAULT_LABEL = "Legacy Normalization...";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/normalize.gif");
-
-       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
-       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
-
-       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
-       private JarFileIndexer jarFileIndexer = new JarFileIndexer();
-
-       // DEPENDENCY INJECTION
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       private Repository nodeRepository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
-               String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
-
-               Session nodeSession = null;
-               NormalizeJob job;
-               try {
-
-                       NormalizationDialog dialog = new NormalizationDialog(
-                                       HandlerUtil.getActiveShell(event));
-                       if (dialog.open() != Dialog.OK)
-                               return null;
-
-                       nodeSession = nodeRepository.login();
-                       Node repoNode = nodeSession.getNode(targetRepoPath);
-                       Repository repository = RepoUtils.getRepository(repositoryFactory,
-                                       keyring, repoNode);
-                       Credentials credentials = RepoUtils.getRepositoryCredentials(
-                                       keyring, repoNode);
-
-                       String version = dialog.getVersion();
-                       Boolean overridePoms = dialog.getOverridePoms();
-
-                       job = new NormalizeJob(repository.login(credentials, wkspName),
-                                       version, overridePoms);
-                       job.setUser(true);
-                       job.schedule();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot normalize " + wkspName, e);
-               } finally {
-                       JcrUtils.logoutQuietly(nodeSession);
-               }
-               return null;
-       }
-
-       protected void packageSourcesAsPdeSource(Node sourcesNode) {
-               Binary origBinary = null;
-               Binary osgiBinary = null;
-               try {
-                       Session session = sourcesNode.getSession();
-                       Artifact sourcesArtifact = AetherUtils.convertPathToArtifact(
-                                       sourcesNode.getPath(), null);
-
-                       // read name version from manifest
-                       Artifact osgiArtifact = new DefaultArtifact(
-                                       sourcesArtifact.getGroupId(),
-                                       sourcesArtifact.getArtifactId(),
-                                       sourcesArtifact.getExtension(),
-                                       sourcesArtifact.getVersion());
-                       String osgiPath = MavenConventionsUtils.artifactPath(
-                                       artifactBasePath, osgiArtifact);
-                       osgiBinary = session.getNode(osgiPath).getNode(Node.JCR_CONTENT)
-                                       .getProperty(Property.JCR_DATA).getBinary();
-
-                       NameVersion nameVersion = RepoUtils.readNameVersion(osgiBinary
-                                       .getStream());
-
-                       // create PDe sources artifact
-                       Artifact pdeSourceArtifact = new DefaultArtifact(
-                                       sourcesArtifact.getGroupId(),
-                                       sourcesArtifact.getArtifactId() + ".source",
-                                       sourcesArtifact.getExtension(),
-                                       sourcesArtifact.getVersion());
-                       String targetSourceParentPath = MavenConventionsUtils
-                                       .artifactParentPath(artifactBasePath, pdeSourceArtifact);
-                       String targetSourceFileName = MavenConventionsUtils
-                                       .artifactFileName(pdeSourceArtifact);
-                       String targetSourceJarPath = targetSourceParentPath + '/'
-                                       + targetSourceFileName;
-
-                       Node targetSourceParentNode = JcrUtils.mkfolders(session,
-                                       targetSourceParentPath);
-                       origBinary = sourcesNode.getNode(Node.JCR_CONTENT)
-                                       .getProperty(Property.JCR_DATA).getBinary();
-                       byte[] targetJarBytes = RepoUtils.packageAsPdeSource(
-                                       origBinary.getStream(), nameVersion);
-                       JcrUtils.copyBytesAsFile(targetSourceParentNode,
-                                       targetSourceFileName, targetJarBytes);
-
-                       // reindex
-                       Node targetSourceJarNode = session.getNode(targetSourceJarPath);
-                       artifactIndexer.index(targetSourceJarNode);
-                       jarFileIndexer.index(targetSourceJarNode);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot add PDE sources for " + sourcesNode,
-                                       e);
-               } finally {
-                       JcrUtils.closeQuietly(origBinary);
-                       JcrUtils.closeQuietly(osgiBinary);
-               }
-
-       }
-
-       private class NormalizeJob extends Job {
-               private Session session;
-               private String version;
-               private Boolean overridePoms;
-
-               public NormalizeJob(Session session, String version,
-                               Boolean overridePoms) {
-                       super("Normalize Distribution");
-                       this.session = session;
-                       this.version = version;
-                       this.overridePoms = overridePoms;
-               }
-
-               @Override
-               protected IStatus run(IProgressMonitor progressMonitor) {
-
-                       try {
-                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
-                               // normalize artifacts
-                               Query countQuery = session
-                                               .getWorkspace()
-                                               .getQueryManager()
-                                               .createQuery("select file from [nt:file] as file",
-                                                               Query.JCR_SQL2);
-                               QueryResult result = countQuery.execute();
-                               Long expectedCount = result.getNodes().getSize();
-                               monitor.beginTask("Normalize artifacts of "
-                                               + session.getWorkspace().getName(),
-                                               expectedCount.intValue());
-                               NormalizingTraverser tiv = new NormalizingTraverser(monitor);
-                               session.getNode(artifactBasePath).accept(tiv);
-
-                               // normalize groups
-                               Query groupQuery = session
-                                               .getWorkspace()
-                                               .getQueryManager()
-                                               .createQuery(
-                                                               "select group from [" + SlcTypes.SLC_GROUP_BASE
-                                                                               + "] as group", Query.JCR_SQL2);
-                               NodeIterator groups = groupQuery.execute().getNodes();
-                               monitor.beginTask("Normalize groups of "
-                                               + session.getWorkspace().getName(),
-                                               (int) groups.getSize());
-                               while (groups.hasNext()) {
-                                       NormalizeGroup.processGroupNode(groups.nextNode(), version,
-                                                       overridePoms, monitor);
-                               }
-                       } catch (Exception e) {
-                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
-                                               "Cannot normalize distribution "
-                                                               + session.getWorkspace().getName(), e);
-                       } finally {
-                               JcrUtils.logoutQuietly(session);
-                       }
-                       return Status.OK_STATUS;
-               }
-
-       }
-
-       private class NormalizingTraverser extends TraversingItemVisitor {
-               JcrMonitor monitor;
-
-               public NormalizingTraverser(JcrMonitor monitor) {
-                       super();
-                       this.monitor = monitor;
-               }
-
-               @Override
-               protected void entering(Property property, int level)
-                               throws RepositoryException {
-               }
-
-               @Override
-               protected void entering(Node node, int level)
-                               throws RepositoryException {
-                       if (node.isNodeType(NodeType.NT_FILE)) {
-                               if (node.getName().endsWith("-sources.jar")) {
-                                       monitor.subTask(node.getName());
-                                       packageSourcesAsPdeSource(node);
-                                       node.getSession().save();
-                                       monitor.worked(1);
-                                       if (log.isDebugEnabled())
-                                               log.debug("Processed source artifact " + node.getPath());
-                               } else if (node.getName().endsWith(".jar")) {
-                                       if (jarFileIndexer.support(node.getPath()))
-                                               if (artifactIndexer.support(node.getPath())) {
-                                                       monitor.subTask(node.getName());
-                                                       artifactIndexer.index(node);
-                                                       jarFileIndexer.index(node);
-                                                       node.getSession().save();
-                                                       monitor.worked(1);
-                                                       if (log.isDebugEnabled())
-                                                               log.debug("Processed artifact "
-                                                                               + node.getPath());
-                                               }
-                               } else {
-                                       monitor.worked(1);
-                               }
-                       }
-               }
-
-               @Override
-               protected void leaving(Property property, int level)
-                               throws RepositoryException {
-               }
-
-               @Override
-               protected void leaving(Node node, int level) throws RepositoryException {
-               }
-
-       }
-
-       public class NormalizationDialog extends TitleAreaDialog {
-               private static final long serialVersionUID = -3103886455862638580L;
-
-               private Text versionT;
-               private String version;
-               private Button overridePomsC;
-               private Boolean overridePoms;
-
-               public NormalizationDialog(Shell parentShell) {
-                       super(parentShell);
-               }
-
-               protected Point getInitialSize() {
-                       return new Point(300, 250);
-               }
-
-               protected Control createDialogArea(Composite parent) {
-                       Composite dialogarea = (Composite) super.createDialogArea(parent);
-                       dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
-                                       true));
-                       Composite composite = new Composite(dialogarea, SWT.NONE);
-                       composite.setLayout(new GridLayout(2, false));
-                       composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
-                                       false));
-                       versionT = createLT(composite, "Version");
-                       overridePomsC = createLC(composite, "Override POMs");
-                       setMessage("Configure normalization", IMessageProvider.NONE);
-
-                       parent.pack();
-                       return composite;
-               }
-
-               @Override
-               protected void okPressed() {
-                       version = versionT.getText();
-                       overridePoms = overridePomsC.getSelection();
-                       super.okPressed();
-               }
-
-               /** Creates label and text. */
-               protected Text createLT(Composite parent, String label) {
-                       new Label(parent, SWT.NONE).setText(label);
-                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER
-                                       | SWT.NONE);
-                       text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-                       return text;
-               }
-
-               /** Creates label and check. */
-               protected Button createLC(Composite parent, String label) {
-                       new Label(parent, SWT.NONE).setText(label);
-                       Button check = new Button(parent, SWT.CHECK);
-                       check.setSelection(false);
-                       check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-                       return check;
-               }
-
-               protected void configureShell(Shell shell) {
-                       super.configureShell(shell);
-                       shell.setText("Normalize...");
-               }
-
-               public String getVersion() {
-                       return version;
-               }
-
-               public Boolean getOverridePoms() {
-                       return overridePoms;
-               }
-
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java
deleted file mode 100644 (file)
index e5ed4d4..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryResult;
-import javax.jcr.util.TraversingItemVisitor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.ArtifactIndexer;
-import org.argeo.slc.repo.JarFileIndexer;
-import org.argeo.slc.repo.ModularDistributionIndexer;
-import org.argeo.slc.repo.PdeSourcesIndexer;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/**
- * Force the indexing of a given workspace by making sure than Maven and OSGi
- * metadata are consistent. This mechanism normally relies on JCR Listeners but
- * must sometimes be triggered manually
- */
-public class NormalizeWorkspace extends AbstractHandler implements SlcNames {
-       private final static Log log = LogFactory.getLog(NormalizeWorkspace.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".normalizeWorkspace";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin.getImageDescriptor("icons/normalize.gif");
-
-       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
-       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
-
-       // DEPENDENCY INJECTION
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       private Repository repository;
-
-       // Relevant default node indexers
-       private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer();
-       // WARNING Order is important: must be called in the following order.
-       private ModularDistributionIndexer modularDistributionIndexer = new ModularDistributionIndexer();
-       private JarFileIndexer jarFileIndexer = new JarFileIndexer();
-       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
-               String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
-
-               Session currSession = null;
-               NormalizeJob job;
-               try {
-                       String msg = "Your are about to normalize workspace: " + wkspName
-                                       + ".\nThis will index OSGi bundles and Maven artifacts, "
-                                       + "it will also convert Maven sources to PDE Sources if needed.\n"
-                                       + "Note that no information will be overwritten: " + "all existing information are kept."
-                                       + "\n\n Do you really want to proceed ?";
-
-                       if (!MessageDialog.openConfirm(DistPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(),
-                                       "Confirm workspace normalization", msg))
-                               return null;
-
-                       currSession = repository.login();
-                       Node repoNode = currSession.getNode(targetRepoPath);
-                       Repository repository = RepoUtils.getRepository(repositoryFactory, keyring, repoNode);
-                       Credentials credentials = RepoUtils.getRepositoryCredentials(keyring, repoNode);
-
-                       job = new NormalizeJob(repository.login(credentials, wkspName));
-                       job.setUser(true);
-                       job.schedule();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot normalize " + wkspName, e);
-               } finally {
-                       JcrUtils.logoutQuietly(currSession);
-               }
-               return null;
-       }
-
-       private class NormalizeJob extends Job {
-               private Session session;
-
-               public NormalizeJob(Session session) {
-                       super("Normalize Distribution");
-                       this.session = session;
-               }
-
-               @Override
-               protected IStatus run(IProgressMonitor progressMonitor) {
-                       try {
-                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
-                               // Normalize artifacts
-                               Query countQuery = session.getWorkspace().getQueryManager()
-                                               .createQuery("select file from [nt:file] as file", Query.JCR_SQL2);
-                               QueryResult result = countQuery.execute();
-                               Long expectedCount = result.getNodes().getSize();
-                               monitor.beginTask("Normalize artifacts of " + session.getWorkspace().getName(),
-                                               expectedCount.intValue());
-                               NormalizingTraverser tiv = new NormalizingTraverser(monitor);
-                               Node artifactBaseNode = session.getNode(artifactBasePath);
-                               artifactBaseNode.accept(tiv);
-                       } catch (Exception e) {
-                               log.error("Error normalizing workspace " + session.getWorkspace().getName() + ": " + e.getMessage());
-                               if (log.isErrorEnabled())
-                                       e.printStackTrace();
-                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
-                                               "Cannot normalize distribution " + session.getWorkspace().getName(), e);
-                       } finally {
-                               JcrUtils.logoutQuietly(session);
-                       }
-                       return Status.OK_STATUS;
-               }
-       }
-
-       private class NormalizingTraverser extends TraversingItemVisitor {
-               JcrMonitor monitor;
-
-               public NormalizingTraverser(JcrMonitor monitor) {
-                       super();
-                       this.monitor = monitor;
-               }
-
-               @Override
-               protected void entering(Property property, int level) throws RepositoryException {
-               }
-
-               @Override
-               protected void entering(Node node, int level) throws RepositoryException {
-                       if (node.getPath().startsWith(RepoConstants.DIST_DOWNLOAD_BASEPATH))
-                               return;
-
-                       if (node.isNodeType(NodeType.NT_FILE)) {
-                               if (node.getName().endsWith("-sources.jar")) {
-                                       monitor.subTask(node.getName());
-                                       pdeSourceIndexer.index(node);
-                                       node.getSession().save();
-                                       monitor.worked(1);
-                                       if (log.isDebugEnabled())
-                                               log.debug("Processed source artifact " + node.getPath());
-                               } else if (node.getName().endsWith("-javadoc.jar")) {
-                                       if (log.isDebugEnabled())
-                                               log.debug("Skip indexing of Javadoc jar " + node.getPath());
-                               } else if (node.getName().endsWith(".jar")) {
-                                       if (jarFileIndexer.support(node.getPath()))
-                                               if (artifactIndexer.support(node.getPath())) {
-                                                       monitor.subTask(node.getName());
-                                                       modularDistributionIndexer.index(node);
-                                                       jarFileIndexer.index(node);
-                                                       artifactIndexer.index(node);
-                                                       if (node.getSession().hasPendingChanges()) {
-                                                               node.getSession().save();
-                                                               if (log.isDebugEnabled())
-                                                                       log.debug("Processed jar artifact " + node.getPath());
-                                                       }
-                                                       monitor.worked(1);
-                                               }
-                               } else if (node.getName().endsWith(".pom")) {
-                                       // Removed: we do not support binaries concept anymore.
-                                       // if (distBundleIndexer.support(node.getPath()))
-                                       // distBundleIndexer.index(node);
-                                       if (artifactIndexer.support(node.getPath()))
-                                               artifactIndexer.index(node);
-                                       if (node.getSession().hasPendingChanges()) {
-                                               node.getSession().save();
-                                               if (log.isDebugEnabled())
-                                                       log.debug("Processed pom artifact " + node.getPath());
-                                       }
-                                       monitor.worked(1);
-                               } else {
-                                       monitor.worked(1);
-                               }
-                       }
-               }
-
-               @Override
-               protected void leaving(Property property, int level) throws RepositoryException {
-               }
-
-               @Override
-               protected void leaving(Node node, int level) throws RepositoryException {
-               }
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setNodeRepository(Repository nodeRepository) {
-               this.repository = nodeRepository;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenGenerateBinariesWizard.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenGenerateBinariesWizard.java
deleted file mode 100644 (file)
index c1b6c12..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.client.ui.dist.wizards.GenerateBinariesWizard;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Open a {@code GenerateBinariesWizard} wizard for the selected node */
-public class OpenGenerateBinariesWizard extends AbstractHandler {
-       // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".openGenerateBinariesWizard";
-       public final static String DEFAULT_LABEL = "Generate Aether Index";
-       public final static ImageDescriptor DEFAULT_ICON = null;
-
-       /* DEPENDENCY INJECTION */
-       private RepoService repoService;
-
-       // Absolute Coordinates of the current group node
-       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
-       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
-       public final static String PARAM_MODULE_PATH = "param.modulePath";
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
-                               .getActiveWorkbenchWindow().getActivePage().getActivePart();
-
-               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
-               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
-               String modulePath = event.getParameter(PARAM_MODULE_PATH);
-
-               GenerateBinariesWizard wizard = new GenerateBinariesWizard(repoService,
-                               repoNodePath, workspaceName, modulePath);
-
-               WizardDialog dialog = new WizardDialog(
-                               HandlerUtil.getActiveShell(event), wizard);
-               int result = dialog.open();
-
-               if (result == Dialog.OK
-                               && (activePart instanceof RefreshDistributionsView))
-                       CommandHelpers.callCommand(RefreshDistributionsView.ID);
-
-               return null;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setRepoService(RepoService repoService) {
-               this.repoService = repoService;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenModuleEditor.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenModuleEditor.java
deleted file mode 100644 (file)
index bf07e49..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor;
-import org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor;
-import org.argeo.slc.client.ui.dist.editors.ModuleEditorInput;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Open the relevant editor for a given module node of a given repository
- * workspace. For the time being, modules can be artifacts or
- * modularDistributions
- */
-public class OpenModuleEditor extends AbstractHandler {
-       public final static String ID = DistPlugin.PLUGIN_ID + ".openModuleEditor";
-       public final static String DEFAULT_LABEL = "Open relevant editor";
-
-       // use local node repo and repository factory to retrieve and log to
-       // relevant repository
-       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
-       // use URI and repository factory to retrieve and ANONYMOUSLY log in
-       // relevant repository
-       public final static String PARAM_REPO_URI = "param.repoUri";
-       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
-       public final static String PARAM_MODULE_PATH = "param.modulePath";
-
-       /* DEPENDENCY INJECTION */
-       private RepoService repoService;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
-               String repoUri = event.getParameter(PARAM_REPO_URI);
-               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
-               String modulePath = event.getParameter(PARAM_MODULE_PATH);
-
-               Session businessSession = null;
-               try {
-                       businessSession = repoService.getRemoteSession(repoNodePath,
-                                       repoUri, workspaceName);
-
-                       Node module = businessSession.getNode(modulePath);
-                       ModuleEditorInput mei = new ModuleEditorInput(repoNodePath,
-                                       repoUri, workspaceName, modulePath);
-
-                       // Choose correct editor based on its mixin
-                       if (module.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION))
-                               HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
-                                               .openEditor(mei, ModularDistVersionEditor.ID);
-                       else
-                               HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
-                                               .openEditor(mei, ArtifactVersionEditor.ID);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unexpected error while "
-                                       + "getting repoNode info for repoNode at path "
-                                       + repoNodePath, e);
-               } catch (PartInitException e) {
-                       throw new SlcException("Unexpected error while "
-                                       + "opening editor for workspace " + workspaceName
-                                       + " with URI " + repoUri + " and repoNode at path "
-                                       + repoNodePath, e);
-               } finally {
-                       JcrUtils.logoutQuietly(businessSession);
-               }
-               return null;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setRepoService(RepoService repoService) {
-               this.repoService = repoService;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenWorkspaceEditor.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenWorkspaceEditor.java
deleted file mode 100644 (file)
index cf25b83..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.cms.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.editors.DistWkspEditorInput;
-import org.argeo.slc.client.ui.dist.editors.DistWorkspaceEditor;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Open a distribution workspace editor for a given workspace in a repository
- */
-public class OpenWorkspaceEditor extends AbstractHandler {
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".openWorkspaceEditor";
-       public final static String DEFAULT_LABEL = "Open editor";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/distribution_perspective.gif");
-
-       // Use local node repo and repository factory to retrieve and log to
-       // relevant repository
-       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
-       // Use URI and repository factory to retrieve and ANONYMOUSLY log in
-       // relevant repository
-       public final static String PARAM_REPO_URI = "param.repoUri";
-       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
-
-       /* DEPENDENCY INJECTION */
-       private Repository localRepository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
-               String repoUri = event.getParameter(PARAM_REPO_URI);
-               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
-
-               Session defaultSession = null;
-               if (repoNodePath != null && repoUri == null) {
-                       try {
-                               defaultSession = localRepository.login();
-                               if (defaultSession.nodeExists(repoNodePath)) {
-                                       Node repoNode = defaultSession.getNode(repoNodePath);
-                                       repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
-                                                       .getString();
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Unexpected error while "
-                                               + "getting repoNode at path " + repoNodePath, e);
-                       } finally {
-                               JcrUtils.logoutQuietly(defaultSession);
-                       }
-               }
-
-               DistWkspEditorInput wei = new DistWkspEditorInput(repoNodePath,
-                               repoUri, workspaceName);
-               try {
-                       HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
-                                       .openEditor(wei, DistWorkspaceEditor.ID);
-               } catch (PartInitException e) {
-                       throw new SlcException("Unexpected error while "
-                                       + "opening editor for workspace " + workspaceName
-                                       + " with URI " + repoUri + " and repoNode at path "
-                                       + repoNodePath, e);
-               }
-               return null;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setLocalRepository(Repository localRepository) {
-               this.localRepository = localRepository;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/PublishWorkspace.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/PublishWorkspace.java
deleted file mode 100644 (file)
index 9c868cd..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/** Publish the current workspace by giving READ_ONLY rights to anonymous */
-public class PublishWorkspace extends AbstractHandler {
-       // private static final Log log = LogFactory.getLog(PublishWorkspace.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".publishWorkspace";
-       public final static String DEFAULT_LABEL = "Make Public";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/publish.gif");
-
-       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
-       // DEPENDENCY INJECTION
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       private Repository nodeRepository;
-
-       private String publicRole = SlcConstants.USER_ANONYMOUS;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
-               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
-
-               Session nodeSession = null;
-               Session session = null;
-
-               try {
-                       nodeSession = nodeRepository.login();
-                       Node repoNode = nodeSession.getNode(targetRepoPath);
-                       Repository repository = RepoUtils.getRepository(repositoryFactory,
-                                       keyring, repoNode);
-                       Credentials credentials = RepoUtils.getRepositoryCredentials(
-                                       keyring, repoNode);
-
-                       String msg = "Are you sure you want to publish this distribution: "
-                                       + workspaceName + " ?";
-                       boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
-                                       .getWorkbench().getDisplay().getActiveShell(),
-                                       "Confirm publication", msg);
-
-                       if (result) {
-                               session = repository.login(credentials, workspaceName);
-                               JcrUtils.addPrivilege(session, "/", publicRole,
-                                               Privilege.JCR_READ);
-                               session.save();
-                               JcrUtils.logoutQuietly(session);
-                               // CommandHelpers.callCommand(RefreshDistributionsView.ID);
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while publishing workspace "
-                                                       + workspaceName, re);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-                       JcrUtils.logoutQuietly(nodeSession);
-               }
-               return null;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshArtifactBrowser.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshArtifactBrowser.java
deleted file mode 100644 (file)
index f9d9f18..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.views.ArtifactsBrowser;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Force the refresh of the artifact browser view */
-public class RefreshArtifactBrowser extends AbstractHandler {
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               ArtifactsBrowser view = (ArtifactsBrowser) HandlerUtil
-                               .getActiveWorkbenchWindow(event).getActivePage()
-                               .findView(ArtifactsBrowser.ID);
-               view.refresh(null);
-               return null;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshDistributionsView.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshDistributionsView.java
deleted file mode 100644 (file)
index e03ab48..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.views.AnonymousDistributionsView;
-import org.argeo.slc.client.ui.dist.views.DistributionsView;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPart;
-
-/** Force refresh of the Distributions View */
-public class RefreshDistributionsView extends AbstractHandler {
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".refreshDistributionsView";
-       public final static String DEFAULT_LABEL = "Refresh the distribution view";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/refresh.png");
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
-                               .getActiveWorkbenchWindow().getActivePage().getActivePart();
-               if (activePart instanceof DistributionsView)
-                       ((DistributionsView) activePart).refresh();
-               else if (activePart instanceof AnonymousDistributionsView)
-                       ((AnonymousDistributionsView) activePart).refresh();
-               return null;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java
deleted file mode 100644 (file)
index f09fd17..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryFactory;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.client.ui.dist.wizards.RegisterRepoWizard;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Register a remote repository by creating a node in the current local node. */
-public class RegisterRepository extends AbstractHandler implements ArgeoNames,
-               SlcNames {
-
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".registerRepository";
-       public final static String DEFAULT_LABEL = "Register a repository...";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/addRepo.gif");
-
-       /* DEPENDENCY INJECTION */
-       private RepositoryFactory repositoryFactory;
-       private Repository nodeRepository;
-       private Keyring keyring;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               RegisterRepoWizard wizard = new RegisterRepoWizard(keyring,
-                               repositoryFactory, nodeRepository);
-               WizardDialog dialog = new WizardDialog(
-                               HandlerUtil.getActiveShell(event), wizard);
-               int result = dialog.open();
-               if (result == Dialog.OK)
-                       CommandHelpers.callCommand(RefreshDistributionsView.ID);
-               return null;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RunInOsgi.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RunInOsgi.java
deleted file mode 100644 (file)
index fc336f6..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.net.URL;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.core.execution.tasks.JvmProcess;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/** <b>UNDER DEVELOPMENT</b>. Download and prepare an OSGi runtime */
-public class RunInOsgi extends AbstractHandler implements SlcNames {
-       private final static Log log = LogFactory.getLog(RunInOsgi.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".runInOsgi";
-       public final static String DEFAULT_LABEL = "Run in OSGi";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
-                       .getImageDescriptor("icons/runInOsgi.gif");
-
-       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
-       public final static String PARAM_MODULE_PATH = "modulePath";
-
-       /* DEPENDENCY INJECTION */
-       private Repository repository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               String workspace = event.getParameter(PARAM_WORKSPACE_NAME);
-               String modulePath = event.getParameter(PARAM_MODULE_PATH);
-               String port = System.getProperty("argeo.server.port.http");
-               // String localMavenBase = System.getProperty("user.home")
-               // + "/.m2/repository";
-
-               InputStream jarStream = null;
-               OutputStream out = null;
-               Writer writer = null;
-               Session session = null;
-               try {
-                       // Bundle distPluginBundle = DistPlugin.getDefault().getBundle();
-                       // File baseDir = distPluginBundle.getBundleContext().getDataFile(
-                       // "runInOSGi");
-                       File baseDir = new File(System.getProperty("java.io.tmpdir")
-                                       + "/runInOSGi-" + System.getProperty("user.name"));
-                       if (baseDir.exists())
-                               FileUtils.deleteDirectory(baseDir);
-                       File libDir = new File(baseDir, "lib");
-                       libDir.mkdirs();
-                       File confDir = new File(baseDir, "configuration");
-                       confDir.mkdirs();
-                       File dataDir = new File(baseDir, "data");
-                       dataDir.mkdirs();
-
-                       session = repository.login(workspace);
-
-                       // NodeIterator bundles = listBundleArtifacts(session);
-                       // if (log.isDebugEnabled())
-                       // log.debug("## Copying to " + libDir);
-                       //
-                       // File equinoxJar = null;
-                       // List<File> files = new ArrayList<File>();
-                       // bundles: while (bundles.hasNext()) {
-                       // Node bundleNode = bundles.nextNode();
-                       // String symbolicName = JcrUtils.get(bundleNode,
-                       // SLC_SYMBOLIC_NAME);
-                       //
-                       // // skip sources
-                       // if (symbolicName.endsWith(".source"))
-                       // continue bundles;
-                       // // skip eclipse
-                       // if (symbolicName.startsWith("org.eclipse")
-                       // && !symbolicName.equals("org.eclipse.osgi"))
-                       // continue bundles;
-                       // if (symbolicName.equals("org.polymap.openlayers.rap.widget"))
-                       // continue bundles;
-                       //
-                       // File targetFile = new File(libDir, bundleNode.getName());
-                       // out = new FileOutputStream(targetFile);
-                       // jarStream = bundleNode.getNode(Node.JCR_CONTENT)
-                       // .getProperty(Property.JCR_DATA).getBinary().getStream();
-                       // IOUtils.copy(jarStream, out);
-                       // if (symbolicName.equals("org.eclipse.osgi"))
-                       // equinoxJar = targetFile;
-                       // else
-                       // files.add(targetFile);
-                       // if (log.isDebugEnabled())
-                       // log.debug("Copied " + targetFile.getName());
-                       //
-                       // IOUtils.closeQuietly(out);
-                       // IOUtils.closeQuietly(jarStream);
-                       // }
-                       //
-                       // StringBuffer osgiBundles = new StringBuffer("osgi.bundles=");
-                       // for (int i = 0; i < files.size(); i++) {
-                       // if (i != 0)
-                       // osgiBundles.append(',');
-                       // osgiBundles.append(files.get(i).getName());
-                       // }
-
-                       String equinoxJar = null;
-
-                       Node distModule = session.getNode(modulePath);
-                       NodeIterator coordinates = distModule.getNode(SLC_MODULES)
-                                       .getNodes();
-                       StringBuilder conf = new StringBuilder(1024 * 1024);
-                       conf.append("osgi.clean=true\n");
-                       conf.append("osgi.console=7777\n");
-                       // conf.append("osgi.console.enable.builtin=true\n");
-
-                       conf.append("osgi.bundles=");
-                       coords: while (coordinates.hasNext()) {
-                               Node coord = coordinates.nextNode();
-                               // String category =
-                               // coord.getProperty(SLC_CATEGORY).getString();
-                               String name = coord.getProperty(SLC_NAME).getString();
-                               String version = coord.getProperty(SLC_VERSION).getString();
-                               Artifact artifact = RepoUtils.asArtifact(coord);
-                               String path = MavenConventionsUtils.artifactPath("", artifact);
-                               String url = "http://localhost:" + port + "/data/public/java/"
-                                               + workspace + path;
-                               if (log.isDebugEnabled())
-                                       log.debug(url);
-                               File f = new File(libDir, name + "-" + version + ".jar");
-                               FileUtils.copyURLToFile(new URL(url), f);
-                               if (name.equals("org.eclipse.osgi")) {
-                                       // File f = new File(localMavenBase + path);
-                                       // if (!f.exists())
-                                       // FileUtils.copyURLToFile(new URL(url), f);
-                                       equinoxJar = f.getCanonicalPath();
-                                       continue coords;
-                               }
-                               conf.append(f.getName());
-                               if (coordinates.hasNext())
-                                       conf.append(",\\\n");
-                       }
-
-                       File confIni = new File(confDir, "config.ini");
-                       writer = new FileWriter(confIni);
-                       writer.write(conf.toString());
-                       IOUtils.closeQuietly(writer);
-
-                       // Map<String, String> configuration = new HashMap<String,
-                       // String>();
-                       // configuration.put("osgi.configuration.area",
-                       // confDir.getCanonicalPath());
-                       // configuration.put("osgi.instance.area",
-                       // dataDir.getCanonicalPath());
-                       // // Do clean
-                       // configuration.put("osgi.clean", "true");
-
-                       JvmProcess osgiRuntime = new JvmProcess();
-                       osgiRuntime.setExecDir(baseDir.getCanonicalPath());
-                       if (equinoxJar == null)
-                               throw new SlcException("Cannot find OSGi runtime.");
-                       osgiRuntime.setMainJar(equinoxJar);
-                       osgiRuntime.arg("-configuration", confDir.getCanonicalPath()).arg(
-                                       "-data", dataDir.getCanonicalPath());
-                       // .arg("-console", "7777").arg("-clean");
-                       osgiRuntime.setLogCommand(true);
-                       osgiRuntime.afterPropertiesSet();
-                       Job job = new RunInOsgiJob(osgiRuntime);
-                       job.schedule();
-                       // osgiRuntime.run();
-
-                       // Map<String, String> configuration = new HashMap<String,
-                       // String>();
-                       // configuration.put("osgi.configuration.area",
-                       // confDir.getCanonicalPath());
-                       // configuration.put("osgi.instance.area",
-                       // dataDir.getCanonicalPath());
-                       // // Do clean
-                       // configuration.put("osgi.clean", "true");
-                       // ServiceLoader<FrameworkFactory> ff = ServiceLoader
-                       // .load(FrameworkFactory.class);
-                       // FrameworkFactory frameworkFactory = ff.iterator().next();
-                       // Framework framework =
-                       // frameworkFactory.newFramework(configuration);
-                       // framework.start();
-                       // BundleContext testBundleContext = framework.getBundleContext();
-
-                       // for (int i = 0; i < files.size(); i++) {
-                       // testBundleContext.installBundle("file://"
-                       // + files.get(i).getCanonicalPath());
-                       // }
-                       //
-                       // Bundle[] testBundles = testBundleContext.getBundles();
-                       // for (Bundle bundle : testBundles) {
-                       // if (log.isDebugEnabled())
-                       // log.debug(bundle.getSymbolicName() + " "
-                       // + bundle.getVersion());
-                       // }
-
-               } catch (Exception e) {
-                       ErrorFeedback.show("Cannot run in OSGi", e);
-               } finally {
-                       IOUtils.closeQuietly(jarStream);
-                       IOUtils.closeQuietly(out);
-                       IOUtils.closeQuietly(writer);
-                       JcrUtils.logoutQuietly(session);
-               }
-
-               return null;
-       }
-
-       // private NodeIterator listBundleArtifacts(Session session)
-       // throws RepositoryException {
-
-       // QueryManager queryManager = session.getWorkspace().getQueryManager();
-       // QueryObjectModelFactory factory = queryManager.getQOMFactory();
-       //
-       // final String bundleArtifactsSelector = "bundleArtifacts";
-       // Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
-       // bundleArtifactsSelector);
-       //
-       // Ordering order = factory.ascending(factory.propertyValue(
-       // bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
-       // Ordering[] orderings = { order };
-       //
-       // QueryObjectModel query = factory.createQuery(source, null, orderings,
-       // null);
-       //
-       // QueryResult result = query.execute();
-       // return result.getNodes();
-       // }
-
-       private class RunInOsgiJob extends Job {
-               final JvmProcess osgiRuntime;
-
-               public RunInOsgiJob(JvmProcess osgiRuntime) {
-                       super("OSGi Test");
-                       this.osgiRuntime = osgiRuntime;
-               }
-
-               @Override
-               protected IStatus run(IProgressMonitor monitor) {
-                       osgiRuntime.setSynchronous(false);
-                       osgiRuntime.run();
-                       while (!monitor.isCanceled()) {
-                               try {
-                                       Thread.sleep(500);
-                               } catch (InterruptedException e) {
-                                       // silent
-                               }
-
-                               if (monitor.isCanceled()) {
-                                       osgiRuntime.kill();
-                                       return Status.CANCEL_STATUS;
-                               }
-                               if (!osgiRuntime.isRunning())
-                                       break;
-                       }
-                       return Status.OK_STATUS;
-               }
-
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ShowSizeColumn.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ShowSizeColumn.java
deleted file mode 100644 (file)
index 3486dbf..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.views.ArtifactsBrowser;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.State;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Change visible state of the ArtifactBrower size column */
-public class ShowSizeColumn extends AbstractHandler {
-       public final static String ID = DistPlugin.PLUGIN_ID + ".showSizeColumn";
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               ArtifactsBrowser view = (ArtifactsBrowser) HandlerUtil
-                               .getActiveWorkbenchWindow(event).getActivePage()
-                               .findView(ArtifactsBrowser.ID);
-
-               ICommandService service = (ICommandService) PlatformUI.getWorkbench()
-                               .getService(ICommandService.class);
-               Command command = service.getCommand(ID);
-               State state = command.getState(ID + ".toggleState");
-
-               boolean wasVisible = (Boolean) state.getValue();
-               view.setSizeVisible(!wasVisible);
-               state.setValue(!wasVisible);
-               return null;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/UnregisterRemoteRepo.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/UnregisterRemoteRepo.java
deleted file mode 100644 (file)
index 8ff0e4a..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/**
- * Un-register a remote repository by deleting the corresponding RepoNode from
- * the node Repository. It does not affect the repository instance
- */
-public class UnregisterRemoteRepo extends AbstractHandler {
-       // private static final Log log = LogFactory
-       // .getLog(UnregisterRemoteRepo.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".unregisterRemoteRepo";
-       public final static String DEFAULT_LABEL = "Unregister";
-       public final static ImageDescriptor DEFAULT_ICON = DistPlugin.getImageDescriptor("icons/removeItem.gif");
-
-       public final static String PARAM_REPO_PATH = DistPlugin.PLUGIN_ID + ".repoNodePath";
-
-       // DEPENCY INJECTION
-       private Repository nodeRepository;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               Session session = null;
-               String repoPath = event.getParameter(PARAM_REPO_PATH);
-               if (repoPath == null)
-                       return null;
-
-               try {
-                       session = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
-                       Node rNode = session.getNode(repoPath);
-                       if (rNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
-
-                               String alias = rNode.getProperty(Property.JCR_TITLE).getString();
-                               String msg = "Your are about to unregister remote repository: " + alias + "\n"
-                                               + "Are you sure you want to proceed ?";
-
-                               boolean result = MessageDialog.openConfirm(
-                                               DistPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(), "Confirm Delete", msg);
-
-                               if (result) {
-                                       rNode.remove();
-                                       session.save();
-                               }
-                               CommandUtils.callCommand(RefreshDistributionsView.ID);
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unexpected error while unregistering remote repository.", e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-               return null;
-       }
-
-       // DEPENCY INJECTION
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/package.html b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/package.html
deleted file mode 100644 (file)
index fa91751..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<head></head>
-<body>
-Eclipse commands wrapping Runnable objects define in non-ui specific code.
-</body>
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/AnonymousDistTreeContentProvider.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/AnonymousDistTreeContentProvider.java
deleted file mode 100644 (file)
index 465faf4..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.argeo.slc.client.ui.dist.controllers;
-
-import javax.jcr.RepositoryFactory;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Enable browsing in local public slc distribution repositories. For the time
- * being, it supports only one repository at a time. Repository factory must be
- * injected
- */
-public class AnonymousDistTreeContentProvider implements ITreeContentProvider {
-       private static final long serialVersionUID = -4149180221319229128L;
-
-       // List<RepoElem> repositories = new ArrayList<RepoElem>();
-       private RepoElem publicRepo;
-
-       private RepositoryFactory repositoryFactory;
-
-       /**
-        * @param input
-        *            the URI to the public repository to browse
-        */
-       public Object[] getElements(Object input) {
-               String uri = (String) input;
-               publicRepo = new RepoElem(repositoryFactory, uri,
-                               "Argeo Public Repository");
-               // force connection and creation of the children UI object
-               publicRepo.login();
-               return publicRepo.getChildren();
-       }
-
-       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-       }
-
-       // @Override
-       public Object[] getChildren(Object parentElement) {
-               if (parentElement instanceof TreeParent)
-                       return ((TreeParent) parentElement).getChildren();
-               else
-                       return null;
-       }
-
-       // @Override
-       public Object getParent(Object element) {
-               if (element instanceof TreeParent)
-                       return ((TreeParent) element).getParent();
-               return null;
-       }
-
-       // @Override
-       public boolean hasChildren(Object element) {
-               if (element instanceof TreeParent)
-                       return ((TreeParent) element).hasChildren();
-               else
-                       return false;
-       }
-
-       public void dispose() {
-               publicRepo.dispose();
-       }
-
-       /*
-        * DEPENDENCY INJECTION
-        */
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactLabelProvider.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactLabelProvider.java
deleted file mode 100644 (file)
index 197921e..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.argeo.slc.client.ui.dist.controllers;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.swt.graphics.Image;
-
-/** Retrieve artifact information to be displayed in an artifact tree or table */
-public class ArtifactLabelProvider extends ColumnLabelProvider implements
-               DistConstants, SlcTypes {
-       private static final long serialVersionUID = 8672622174076959016L;
-
-       // To be able to change column order easily
-       public static final int COLUMN_TREE = 0;
-       public static final int COLUMN_DATE = 1;
-       public static final int COLUMN_SIZE = 2;
-
-       // Utils
-       protected static DateFormat timeFormatter = new SimpleDateFormat(
-                       DATE_TIME_FORMAT);
-
-       public void update(ViewerCell cell) {
-               int colIndex = cell.getColumnIndex();
-               Object element = cell.getElement();
-               cell.setText(getColumnText(element, colIndex));
-               if (element instanceof Node && colIndex == 0) {
-                       Node node = (Node) element;
-                       try {
-                               if (node.isNodeType(SLC_ARTIFACT_BASE))
-                                       cell.setImage(DistImages.IMG_ARTIFACT_BASE);
-                               else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE))
-                                       cell.setImage(DistImages.IMG_ARTIFACT_VERSION_BASE);
-                       } catch (RepositoryException e) {
-                               // Silent
-                       }
-               }
-       }
-
-       @Override
-       public Image getImage(Object element) {
-
-               if (element instanceof Node) {
-                       Node node = (Node) element;
-                       try {
-                               if (node.isNodeType(SLC_ARTIFACT_BASE)) {
-                                       return DistImages.IMG_ARTIFACT_BASE;
-                               } else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) {
-                                       return DistImages.IMG_ARTIFACT_VERSION_BASE;
-                               }
-                       } catch (RepositoryException e) {
-                               // Silent
-                       }
-               }
-               return null;
-       }
-
-       public String getColumnText(Object element, int columnIndex) {
-               try {
-                       if (element instanceof Node) {
-                               Node node = (Node) element;
-                               switch (columnIndex) {
-                               case COLUMN_TREE:
-                                       return node.getName();
-                               case COLUMN_SIZE:
-                                       long size = JcrUtils.getNodeApproxSize(node) / 1024;
-                                       if (size > 1024)
-                                               return size / 1024 + " MB";
-                                       else
-                                               return size + " KB";
-                               case COLUMN_DATE:
-                                       if (node.hasProperty(Property.JCR_LAST_MODIFIED))
-                                               return timeFormatter.format(node
-                                                               .getProperty(Property.JCR_LAST_MODIFIED)
-                                                               .getDate().getTime());
-                                       else
-                                               return null;
-                               }
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexepected error while getting property values", re);
-               }
-               return null;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactsTreeContentProvider.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactsTreeContentProvider.java
deleted file mode 100644 (file)
index 5559b44..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.argeo.slc.client.ui.dist.controllers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.jcr.util.JcrItemsComparator;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/** Enable specific browsing of an artifact tree */
-public class ArtifactsTreeContentProvider implements ITreeContentProvider,
-               SlcTypes {
-       private static final long serialVersionUID = -8097817288192073987L;
-
-       // Utils
-       private boolean sortChildren = true;
-       private JcrItemsComparator itemComparator = new JcrItemsComparator();
-
-       public Object[] getElements(Object parent) {
-               return getChildren(parent);
-       }
-
-       public Object getParent(Object child) {
-               return null;
-       }
-
-       public Object[] getChildren(Object parent) {
-               Object[] elements = null;
-               try {
-                       if (parent instanceof Node) {
-                               Node node = (Node) parent;
-                               NodeIterator ni = node.getNodes();
-                               List<Node> nodesList = new ArrayList<Node>();
-                               while (ni.hasNext()) {
-                                       nodesList.add(ni.nextNode());
-                               }
-                               if (sortChildren) {
-                                       Node[] arr = (Node[]) nodesList.toArray(new Node[nodesList
-                                                       .size()]);
-                                       Arrays.sort(arr, itemComparator);
-                                       return arr;
-                               } else
-                                       return nodesList.toArray();
-
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException(
-                                       "Unexpected exception while listing node properties", e);
-               }
-               return elements;
-       }
-
-       public boolean hasChildren(Object parent) {
-               try {
-                       if (parent instanceof Node) {
-                               Node curNode = (Node) parent;
-                               // We manually stop digging at this level
-                               if (curNode.isNodeType(SLC_ARTIFACT_VERSION_BASE))
-                                       return false;
-                               else if (curNode.hasNodes())
-                                       return true;
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException(
-                                       "Unexpected exception while checking if property is multiple",
-                                       e);
-               }
-               return false;
-       }
-
-       public void setSortChildren(boolean sortChildren) {
-               this.sortChildren = sortChildren;
-       }
-
-       public boolean getSortChildren() {
-               return sortChildren;
-       }
-
-       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-       }
-
-       public void dispose() {
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistSessionFactory.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistSessionFactory.java
deleted file mode 100644 (file)
index 52c5374..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.argeo.slc.client.ui.dist.controllers;
-
-import javax.jcr.Credentials;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.RepoUtils;
-
-/**
- * Provide shortcuts to retrieve sessions, repositories and workspaces that are
- * persisted in the current user node using path only.
- */
-public class DistSessionFactory {
-
-       /* DEPENDENCY INJECTION */
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       private Repository nodeRepository;
-
-       /**
-        * Returns a new session on the given workspace. This session *must* be
-        * disposed by the caller. If the workspace does not exist and
-        * createIfNeeded==true, tries to create it
-        * 
-        * */
-       public Session getSessionFromWorkspacePath(String path,
-                       boolean createIfNeeded) {
-               Session nodeSession = null;
-               try {
-                       nodeSession = nodeRepository.login();
-                       Node localWksp = nodeSession.getNode(path);
-                       Repository repository = RepoUtils.getRepository(repositoryFactory,
-                                       keyring, localWksp.getParent());
-                       Credentials credentials = RepoUtils.getRepositoryCredentials(
-                                       keyring, localWksp.getParent());
-
-                       String wkspName = JcrUtils.lastPathElement(path);
-                       Session session = null;
-                       try {
-                               session = repository.login(credentials, wkspName);
-                       } catch (NoSuchWorkspaceException e) {
-                               if (createIfNeeded) {
-                                       Session defaultSession = repository.login(credentials);
-                                       try {
-                                               defaultSession.getWorkspace().createWorkspace(wkspName);
-                                       } catch (Exception e1) {
-                                               throw new SlcException("Cannot create new workspace "
-                                                               + wkspName, e);
-                                       } finally {
-                                               JcrUtils.logoutQuietly(defaultSession);
-                                       }
-                                       session = repository.login(credentials, wkspName);
-                               } else
-                                       throw new SlcException("Workspace" + wkspName
-                                                       + "does not exists and should not be created", e);
-                       }
-                       return session;
-               } catch (RepositoryException e) {
-                       throw new SlcException("cannot create session" + " for workspace "
-                                       + path, e);
-               } finally {
-                       JcrUtils.logoutQuietly(nodeSession);
-               }
-       }
-
-       /*
-        * DEPENDENCY INJECTION
-        */
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-
-       public void setRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparator.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparator.java
deleted file mode 100644 (file)
index c788ebc..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.argeo.slc.client.ui.dist.controllers;
-
-import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
-import org.argeo.slc.client.ui.dist.utils.NameVersionComparator;
-import org.argeo.slc.client.ui.dist.utils.VersionComparator;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-
-/** Specific comparator to enhance Distribution tree browsers */
-public class DistTreeComparator extends ViewerComparator {
-       private static final long serialVersionUID = -7386716562202568704L;
-
-       private VersionComparator vc = new VersionComparator();
-       private NameVersionComparator nvc = new NameVersionComparator();
-
-       public int category(Object element) {
-               if (element instanceof RepoElem)
-                       if (((RepoElem) element).inHome())
-                               // Home repository always first
-                               return 2;
-                       else
-                               return 5;
-               else if (element instanceof WkspGroupElem)
-                       return 10;
-               else if (element instanceof WorkspaceElem)
-                       return 15;
-               else
-                       return 20;
-       }
-
-       public int compare(Viewer viewer, Object e1, Object e2) {
-               int cat1 = category(e1);
-               int cat2 = category(e2);
-
-               if (cat1 != cat2) {
-                       return cat1 - cat2;
-               }
-
-               String s1, s2;
-
-               if (e1 instanceof DistParentElem) {
-                       s1 = ((DistParentElem) e1).getName();
-                       s2 = ((DistParentElem) e2).getName();
-               } else {
-                       s1 = e1.toString();
-                       s2 = e2.toString();
-               }
-
-               if (e1 instanceof WorkspaceElem)
-                       // Reverse order for nameversions
-                       return nvc.compare(viewer, s2, s1);
-               else if (e1 instanceof ModularDistVersionElem)
-                       // Reverse order for versions
-                       return vc.compare(viewer, s2, s1);
-               else
-                       return s1.compareTo(s2);
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparer.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparer.java
deleted file mode 100644 (file)
index 5c6b9de..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.argeo.slc.client.ui.dist.controllers;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.eclipse.jface.viewers.IElementComparer;
-
-/** Compares two elements of the Distribution tree */
-public class DistTreeComparer implements IElementComparer {
-
-       public int hashCode(Object element) {
-               if (element instanceof TreeParent)
-                       return ((TreeParent) element).hashCode();
-               else
-
-                       return element.getClass().toString().hashCode();
-       }
-
-       public boolean equals(Object elementA, Object elementB) {
-               if (!(elementA instanceof TreeParent)
-                               || !(elementB instanceof TreeParent)) {
-                       return elementA == null ? elementB == null : elementA
-                                       .equals(elementB);
-               } else {
-                       TreeParent tpA = ((TreeParent) elementA);
-                       TreeParent tpB = ((TreeParent) elementB);
-                       return tpA.compareTo(tpB) == 0;
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java
deleted file mode 100644 (file)
index b7e25d1..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.argeo.slc.client.ui.dist.controllers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Enables browsing in local and remote SLC software repositories. Keyring and
- * repository factory must be injected
- */
-public class DistTreeContentProvider implements ITreeContentProvider {
-       private static final long serialVersionUID = -7640840211717811421L;
-
-       /* DEPENDENCY INJECTION */
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-
-       // Context
-       private Session nodeSession;
-       List<RepoElem> repositories = new ArrayList<RepoElem>();
-
-       public Object[] getElements(Object input) {
-               Repository nodeRepository = (Repository) input;
-               try {
-                       if (nodeSession != null)
-                               dispose();
-                       nodeSession = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
-
-                       String reposPath = NodeUtils.getUserHome(nodeSession).getPath() + RepoConstants.REPOSITORIES_BASE_PATH;
-
-                       if (!nodeSession.itemExists(reposPath))
-                               initializeModel(nodeSession);
-
-                       NodeIterator repos = nodeSession.getNode(reposPath).getNodes();
-                       while (repos.hasNext()) {
-                               Node repoNode = repos.nextNode();
-                               if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
-                                       String label = repoNode.isNodeType(NodeType.MIX_TITLE)
-                                                       ? repoNode.getProperty(Property.JCR_TITLE).getString()
-                                                       : repoNode.getName();
-                                       repositories.add(new RepoElem(repositoryFactory, keyring, repoNode, label));
-                               }
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot get base elements", e);
-               }
-               return repositories.toArray();
-       }
-
-       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-       }
-
-       // @Override
-       public Object[] getChildren(Object parentElement) {
-               if (parentElement instanceof TreeParent)
-                       return ((TreeParent) parentElement).getChildren();
-               else
-                       return null;
-       }
-
-       // @Override
-       public Object getParent(Object element) {
-               if (element instanceof TreeParent)
-                       return ((TreeParent) element).getParent();
-               return null;
-       }
-
-       // @Override
-       public boolean hasChildren(Object element) {
-               if (element instanceof TreeParent)
-                       return ((TreeParent) element).hasChildren();
-               else
-                       return false;
-       }
-
-       public void dispose() {
-               for (RepoElem repoElem : repositories)
-                       repoElem.dispose();
-               repositories = new ArrayList<RepoElem>();
-               JcrUtils.logoutQuietly(nodeSession);
-       }
-
-       private void initializeModel(Session nodeSession) {
-               try {
-                       Node homeNode = NodeUtils.getUserHome(nodeSession);
-                       if (homeNode == null) // anonymous
-                               throw new SlcException("User must be authenticated.");
-
-                       // make sure base directory is available
-                       Node repos = JcrUtils.mkdirs(homeNode, RepoConstants.REPOSITORIES_BASE_PATH, null);
-                       if (nodeSession.hasPendingChanges())
-                               nodeSession.save();
-
-                       // register default local java repository
-                       String alias = RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS;
-                       Repository javaRepository = NodeUtils.getRepositoryByAlias(repositoryFactory, alias);
-                       if (javaRepository != null) {
-                               if (!repos.hasNode(alias)) {
-                                       Node repoNode = repos.addNode(alias, ArgeoTypes.ARGEO_REMOTE_REPOSITORY);
-                                       repoNode.setProperty(ArgeoNames.ARGEO_URI, "vm:///" + alias);
-                                       repoNode.addMixin(NodeType.MIX_TITLE);
-                                       repoNode.setProperty(Property.JCR_TITLE, RepoConstants.DEFAULT_JAVA_REPOSITORY_LABEL);
-                                       nodeSession.save();
-                               }
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot initialize model", e);
-               }
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeDoubleClickListener.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeDoubleClickListener.java
deleted file mode 100644 (file)
index 2461d3a..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.argeo.slc.client.ui.dist.controllers;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-
-/** Listen to double-clicks on the distributions view tree. */
-public class DistTreeDoubleClickListener implements IDoubleClickListener {
-
-       private TreeViewer treeViewer;
-
-       public DistTreeDoubleClickListener(TreeViewer treeViewer) {
-               this.treeViewer = treeViewer;
-       }
-
-       public void doubleClick(DoubleClickEvent event) {
-               if (event.getSelection() == null || event.getSelection().isEmpty())
-                       return;
-               Object obj = ((IStructuredSelection) event.getSelection())
-                               .getFirstElement();
-
-               if (obj instanceof RepoElem) {
-                       RepoElem rpNode = (RepoElem) obj;
-                       if (!rpNode.isConnected()) {
-                               rpNode.login();
-                               treeViewer.refresh(obj);
-                       }
-               } else if (obj instanceof WorkspaceElem) {
-                       WorkspaceElem we = (WorkspaceElem) obj;
-                       RepoElem repoElem = we.getRepoElem();
-                       Map<String, String> params = new HashMap<String, String>();
-                       params.put(OpenWorkspaceEditor.PARAM_REPO_NODE_PATH,
-                                       repoElem.getRepoNodePath());
-                       params.put(OpenWorkspaceEditor.PARAM_REPO_URI, repoElem.getUri());
-                       params.put(OpenWorkspaceEditor.PARAM_WORKSPACE_NAME,
-                                       we.getWorkspaceName());
-                       CommandUtils.callCommand(OpenWorkspaceEditor.ID, params);
-
-               } else if (obj instanceof ModularDistVersionElem) {
-                       ModularDistVersionElem modDistElem = (ModularDistVersionElem) obj;
-                       WorkspaceElem wkspElem = modDistElem.getWorkspaceElem();
-                       Node moduleNode = modDistElem.getModularDistVersionNode();
-                       RepoElem repoElem = wkspElem.getRepoElem();
-                       Map<String, String> params = new HashMap<String, String>();
-                       params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
-                                       repoElem.getRepoNodePath());
-                       params.put(OpenModuleEditor.PARAM_REPO_URI, repoElem.getUri());
-                       params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
-                                       wkspElem.getWorkspaceName());
-                       try {
-                               params.put(OpenModuleEditor.PARAM_MODULE_PATH,
-                                               moduleNode.getPath());
-                       } catch (RepositoryException re) {
-                               throw new SlcException("Cannot get path for node " + moduleNode
-                                               + " while setting parameters for "
-                                               + "command OpenModuleEditor", re);
-                       }
-                       CommandUtils.callCommand(OpenModuleEditor.ID, params);
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeLabelProvider.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeLabelProvider.java
deleted file mode 100644 (file)
index 661c987..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.argeo.slc.client.ui.dist.controllers;
-
-import org.argeo.cms.ui.jcr.JcrImages;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/** Manage icons and labels for the Distributions tree browser */
-public class DistTreeLabelProvider extends ColumnLabelProvider {
-       private static final long serialVersionUID = -7889294105284404373L;
-
-       @Override
-       public String getText(Object element) {
-               if (element instanceof DistParentElem)
-                       return ((DistParentElem) element).getName();
-               else
-                       return element.toString();
-       }
-
-       @Override
-       public Image getImage(Object element) {
-               if (element instanceof RepoElem) {
-                       RepoElem re = ((RepoElem) element);
-                       if (re.inHome())
-                               return DistImages.IMG_HOME_REPO;
-                       else if (re.isConnected())
-                               return JcrImages.REPOSITORY_CONNECTED;
-                       else
-                               return JcrImages.REPOSITORY_DISCONNECTED;
-               } else if (element instanceof WorkspaceElem) {
-                       return JcrImages.WORKSPACE_CONNECTED;
-               } else if (element instanceof WkspGroupElem)
-                       return DistImages.IMG_WKSP_GROUP;
-               // else if (element instanceof GroupBaseElem)
-               // return DistImages.IMG_GROUP_BASE;
-               else if (element instanceof ModularDistVersionBaseElem)
-                       return DistImages.IMG_MODULAR_DIST_BASE;
-               else if (element instanceof ModularDistVersionElem)
-                       return DistImages.IMG_MODULAR_DIST_VERSION;
-               return super.getImage(element);
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ArtifactVersionEditor.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ArtifactVersionEditor.java
deleted file mode 100644 (file)
index 4853fe2..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/** Artifact editor in a multiple repository environment */
-public class ArtifactVersionEditor extends FormEditor implements SlcNames {
-       private static final long serialVersionUID = 1109872666962757000L;
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".artifactVersionEditor";
-
-       /* DEPENDENCY INJECTION */
-       private RepoService repoService;
-
-       // Business Objects
-       private Session businessSession;
-       private Node artifact;
-
-       private ModuleEditorInput editorInput;
-
-       @Override
-       public void init(IEditorSite site, IEditorInput input)
-                       throws PartInitException {
-               editorInput = (ModuleEditorInput) input;
-               businessSession = repoService.getRemoteSession(
-                               editorInput.getRepoNodePath(), editorInput.getUri(),
-                               editorInput.getWorkspaceName());
-               try {
-                       artifact = businessSession.getNode(editorInput.getModulePath());
-               } catch (RepositoryException e) {
-                       throw new PartInitException(
-                                       "Unable to initialise editor for artifact "
-                                                       + editorInput.getModulePath() + " in workspace "
-                                                       + editorInput.getWorkspaceName(), e);
-               }
-               super.init(site, input);
-       }
-
-       /** Override to provide a specific part name */
-       protected String getFormattedName() {
-               try {
-                       String partName = null;
-                       if (artifact.hasProperty(SLC_ARTIFACT_ID))
-                               partName = artifact.getProperty(SLC_ARTIFACT_ID).getString();
-                       else
-                               partName = artifact.getName();
-
-                       if (partName.length() > 10) {
-                               partName = "..." + partName.substring(partName.length() - 10);
-                       }
-                       return partName;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "unable to get slc:artifactId Property for node "
-                                                       + artifact, re);
-               }
-       }
-
-       @Override
-       protected void addPages() {
-               setPartName(getFormattedName());
-
-               try {
-                       addPage(new BundleDetailPage(this, "Details ", artifact));
-                       addPage(new BundleDependencyPage(this, "Dependencies ", artifact));
-                       addPage(new BundleRawPage(this, "Raw Meta-Data ", artifact));
-               } catch (PartInitException e) {
-                       throw new SlcException("Cannot add distribution editor pages", e);
-               }
-
-       }
-
-       @Override
-       public void doSave(IProgressMonitor arg0) {
-       }
-
-       @Override
-       public void dispose() {
-               JcrUtils.logoutQuietly(businessSession);
-               super.dispose();
-       }
-
-       @Override
-       public void doSaveAs() {
-       }
-
-       @Override
-       public boolean isSaveAsAllowed() {
-               return false;
-       }
-
-       protected RepoService getRepoService() {
-               return repoService;
-       }
-
-       protected Node getArtifact() {
-               return artifact;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setRepoService(RepoService repoService) {
-               this.repoService = repoService;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDependencyPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDependencyPage.java
deleted file mode 100644 (file)
index 938710d..0000000
+++ /dev/null
@@ -1,458 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * Present main information of a given OSGI bundle
- */
-public class BundleDependencyPage extends FormPage implements SlcNames {
-       // private final static Log log =
-       // LogFactory.getLog(ArtifactDetailsPage.class);
-
-       // Main business Objects
-       private Node currBundle;
-
-       // This page widgets
-       private FormToolkit toolkit;
-
-       public BundleDependencyPage(FormEditor editor, String title,
-                       Node currentNode) {
-               super(editor, "id", title);
-               this.currBundle = currentNode;
-       }
-
-       protected void createFormContent(IManagedForm managedForm) {
-               ScrolledForm form = managedForm.getForm();
-               toolkit = managedForm.getToolkit();
-               try {
-                       if (currBundle.hasProperty(DistConstants.SLC_BUNDLE_NAME))
-                               form.setText(currBundle.getProperty(
-                                               DistConstants.SLC_BUNDLE_NAME).getString());
-                       Composite body = form.getBody();
-                       GridLayout layout = new GridLayout(1, false);
-                       layout.horizontalSpacing = layout.marginWidth = 0;
-                       layout.verticalSpacing = layout.marginHeight = 0;
-                       body.setLayout(layout);
-
-                       Composite part = toolkit.createComposite(body);
-                       createExportPackageSection(part);
-                       GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
-                       gd.heightHint = 180;
-                       part.setLayoutData(gd);
-
-                       part = toolkit.createComposite(body);
-                       createImportPackageSection(part);
-                       gd = new GridData(SWT.FILL, SWT.FILL, true, true);
-                       // gd.heightHint = 200;
-                       part.setLayoutData(gd);
-
-                       part = toolkit.createComposite(body);
-                       createReqBundleSection(part);
-                       gd = new GridData(SWT.FILL, SWT.FILL, true, true);
-                       part.setLayoutData(gd);
-
-                       managedForm.reflow(true);
-
-               } catch (RepositoryException e) {
-                       throw new SlcException("unexpected error "
-                                       + "while creating bundle details page");
-               }
-       }
-
-       // Workaround to add an artificial level to the export package browser
-       private class LevelElem {
-               private String label;
-               private Object parent;
-
-               public LevelElem(String label, Object parent) {
-                       this.label = label;
-                       this.parent = parent;
-               }
-
-               public String toString() {
-                       return label;
-               }
-
-               public Object getParent() {
-                       return parent;
-               }
-       }
-
-       /** Export Package Section */
-       private void createExportPackageSection(Composite parent)
-                       throws RepositoryException {
-               parent.setLayout(new GridLayout());
-
-               // Define the TableViewer
-
-               Section section = addSection(parent, "Export packages");
-               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-               TreeViewer viewer = new TreeViewer(section, SWT.H_SCROLL | SWT.V_SCROLL
-                               | SWT.BORDER);
-               final Tree tree = viewer.getTree();
-               tree.setHeaderVisible(false);
-               tree.setLinesVisible(true);
-               tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-               TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.FILL);
-               col.getColumn().setWidth(400);
-
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = 1376400790495130862L;
-
-                       @Override
-                       public String getText(Object element) {
-                               if (element instanceof Node)
-                                       return JcrUtils.get((Node) element, SlcNames.SLC_NAME);
-                               else
-                                       return element.toString();
-                       }
-
-                       @Override
-                       public Image getImage(Object element) {
-                               if (element instanceof Node) {
-                                       try {
-                                               Node node = (Node) element;
-                                               if (node.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE))
-                                                       return DistImages.IMG_PACKAGE;
-                                       } catch (RepositoryException e) {
-                                               throw new SlcException("Error retriving "
-                                                               + "image for the labelProvider", e);
-                                       }
-                               }
-                               return null;
-                       }
-               });
-
-               viewer.setContentProvider(new ITreeContentProvider() {
-                       private static final long serialVersionUID = 1898086304761992568L;
-
-                       public void dispose() {
-                       }
-
-                       public void inputChanged(Viewer viewer, Object oldInput,
-                                       Object newInput) {
-                       }
-
-                       public Object[] getElements(Object inputElement) {
-                               try {
-                                       List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
-                                                       currBundle, SlcTypes.SLC_EXPORTED_PACKAGE,
-                                                       SlcNames.SLC_NAME));
-                                       return nodes.toArray();
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot list children Nodes", e);
-                               }
-                       }
-
-                       public Object[] getChildren(Object parentElement) {
-                               // Only 2 levels for the time being
-                               try {
-                                       if (parentElement instanceof LevelElem) {
-                                               Node node = (Node) ((LevelElem) parentElement)
-                                                               .getParent();
-                                               List<Node> nodes = JcrUtils
-                                                               .nodeIteratorToList(listNodes(node,
-                                                                               SlcTypes.SLC_JAVA_PACKAGE,
-                                                                               SlcNames.SLC_NAME));
-                                               return nodes.toArray();
-                                       } else if (parentElement instanceof Node) {
-                                               Node pNode = (Node) parentElement;
-                                               if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
-                                                       if (listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
-                                                                       SlcNames.SLC_NAME).getSize() > 0) {
-                                                               Object[] result = { new LevelElem("uses", pNode) };
-                                                               return result;
-                                                       }
-                                               }
-                                       }
-                                       return null;
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot list children Nodes", e);
-                               }
-                       }
-
-                       public Object getParent(Object element) {
-                               // useless
-                               return null;
-                       }
-
-                       public boolean hasChildren(Object element) {
-                               try {
-                                       if (element instanceof LevelElem)
-                                               return true;
-                                       else {
-                                               Node pNode = (Node) element;
-                                               if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
-                                                       return listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
-                                                                       SlcNames.SLC_NAME).getSize() > 0;
-                                               }
-                                       }
-                                       return false;
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot check children Nodes", e);
-                               }
-                       }
-               });
-
-               section.setClient(tree);
-               viewer.setInput("Initialize");
-               // work around a display problem : the tree table has only a few lines
-               // when the tree is not expended
-               // viewer.expandToLevel(2);
-       }
-
-       /** Import Package Section */
-       private void createImportPackageSection(Composite parent)
-                       throws RepositoryException {
-               parent.setLayout(new GridLayout());
-
-               // Define the TableViewer
-               // toolkit.createLabel(parent, "Import packages", SWT.NONE).setFont(
-               // EclipseUiUtils.getBoldFont(parent));
-
-               Section section = addSection(parent, "Import packages");
-               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               TableViewer viewer = new TableViewer(section, SWT.H_SCROLL
-                               | SWT.V_SCROLL | SWT.BORDER);
-
-               final Table table = viewer.getTable();
-               table.setHeaderVisible(true);
-               table.setLinesVisible(true);
-               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-               // Name
-               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(350);
-               col.getColumn().setText("Name");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = -7836022945221936898L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_NAME);
-                       }
-
-                       public Image getImage(Object element) {
-                               return DistImages.IMG_PACKAGE;
-                       }
-
-               });
-
-               // Version
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(100);
-               col.getColumn().setText("Version");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = -8277731617775091641L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_VERSION);
-                       }
-               });
-
-               // Optional
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(100);
-               col.getColumn().setText("Optional");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = -2388533169594840688L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_OPTIONAL);
-                       }
-               });
-
-               viewer.setContentProvider(new TableContentProvider(
-                               SlcTypes.SLC_IMPORTED_PACKAGE, SLC_NAME));
-               section.setClient(table);
-               viewer.setInput("Initialize");
-       }
-
-       /** Required Bundle Section */
-       private void createReqBundleSection(Composite parent)
-                       throws RepositoryException {
-               parent.setLayout(new GridLayout());
-
-               // Define the TableViewer
-               Section section = addSection(parent, "Required bundles");
-               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-               // toolkit.createLabel(parent, "Required bundles", SWT.NONE).setFont(
-               // EclipseUiUtils.getBoldFont(parent));
-               TableViewer viewer = new TableViewer(section, SWT.H_SCROLL
-                               | SWT.V_SCROLL | SWT.BORDER);
-
-               final Table table = viewer.getTable();
-               table.setHeaderVisible(true);
-               table.setLinesVisible(true);
-               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-               // Name
-               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(300);
-               col.getColumn().setText("Name");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = 4423640365819800247L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
-                       }
-
-                       @Override
-                       public Image getImage(Object element) {
-                               return DistImages.IMG_BUNDLE;
-                       }
-               });
-
-               // Version
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(140);
-               col.getColumn().setText("Version");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = 1898477425996646270L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
-                       }
-               });
-
-               // Optional
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(100);
-               col.getColumn().setText("Optional");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = -7029999152302445581L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_OPTIONAL);
-                       }
-               });
-
-               viewer.setContentProvider(new TableContentProvider(
-                               SlcTypes.SLC_REQUIRED_BUNDLE, SLC_SYMBOLIC_NAME));
-               section.setClient(table);
-               viewer.setInput("Initialize");
-       }
-
-       /**
-        * Build repository request
-        * 
-        * FIXME Workaround for remote repository, the path to bundleartifact (for
-        * instance
-        * .../org/argeo/slc/org.argeo.slc.client.ui.dist/1.1.12/org.argeo.slc
-        * .client.ui.dist-1.1.12/ ) is not valid for method factory.childNode(); it
-        * fails parsing the "1.1.12" part, trying to cast it as a BigDecimal
-        * 
-        * */
-       private NodeIterator listNodes(Node parent, String nodeType, String orderBy)
-                       throws RepositoryException {
-               // QueryManager queryManager = currBundle.getSession().getWorkspace()
-               // .getQueryManager();
-               // QueryObjectModelFactory factory = queryManager.getQOMFactory();
-               //
-               // final String nodeSelector = "nodes";
-               // Selector source = factory.selector(nodeType, nodeSelector);
-               //
-               // Constraint childOf = factory.childNode(nodeSelector,
-               // parent.getPath());
-               //
-               // Ordering order =
-               // factory.ascending(factory.propertyValue(nodeSelector,
-               // orderBy));
-               // Ordering[] orderings = { order };
-               //
-               // QueryObjectModel query = factory.createQuery(source, childOf,
-               // orderings, null);
-               //
-               // QueryResult result = query.execute();
-
-               String pattern = null;
-               if (SlcTypes.SLC_EXPORTED_PACKAGE.equals(nodeType))
-                       pattern = "slc:Export-Package*";
-               else if (SlcTypes.SLC_JAVA_PACKAGE.equals(nodeType))
-                       pattern = "slc:uses*";
-               else if (SlcTypes.SLC_IMPORTED_PACKAGE.equals(nodeType))
-                       pattern = "slc:Import-Package*";
-               else if (SlcTypes.SLC_REQUIRED_BUNDLE.equals(nodeType))
-                       pattern = "slc:Require-Bundle*";
-
-               return parent.getNodes(pattern);
-       }
-
-       private class TableContentProvider implements IStructuredContentProvider {
-               private static final long serialVersionUID = 4133284637336320455L;
-               private String nodeType;
-               private String orderBy;
-
-               TableContentProvider(String nodeType, String orderBy) {
-                       this.nodeType = nodeType;
-                       this.orderBy = orderBy;
-               }
-
-               public void dispose() {
-               }
-
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-               }
-
-               public Object[] getElements(Object arg0) {
-                       try {
-                               List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
-                                               currBundle, nodeType, orderBy));
-                               return nodes.toArray();
-                       } catch (RepositoryException e) {
-                               ErrorFeedback.show("Cannot list children Nodes", e);
-                               return null;
-                       }
-               }
-       }
-
-       /* HELPERS */
-       private Section addSection(Composite parent, String title) {
-               Section section = toolkit.createSection(parent, Section.TITLE_BAR);
-               section.setText(title);
-               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               return section;
-       }
-
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDetailPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDetailPage.java
deleted file mode 100644 (file)
index c300af1..0000000
+++ /dev/null
@@ -1,503 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.net.URL;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.build.License;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.utils.HyperlinkAdapter;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.browser.IWebBrowser;
-import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-
-/** Show details for a given bundle. */
-public class BundleDetailPage extends FormPage implements SlcNames {
-       private final static Log log = LogFactory.getLog(BundleDetailPage.class);
-
-       final static String PAGE_ID = "BundleDetailPage";
-
-       // Business Objects
-       private Node bundle;
-
-       // This page widgets
-       private FormToolkit tk;
-
-       public BundleDetailPage(FormEditor formEditor, String title, Node bundle) {
-               super(formEditor, PAGE_ID, title);
-               this.bundle = bundle;
-       }
-
-       @Override
-       protected void createFormContent(IManagedForm managedForm) {
-               // General settings for this page
-               ScrolledForm form = managedForm.getForm();
-               tk = managedForm.getToolkit();
-               Composite body = form.getBody();
-
-               GridLayout layout = new GridLayout(1, false);
-               layout.marginWidth = 5;
-               layout.marginRight = 15;
-               layout.verticalSpacing = 0;
-               body.setLayout(layout);
-               try {
-                       form.setText(bundle.hasProperty(SlcNames.SLC_SYMBOLIC_NAME) ? bundle
-                                       .getProperty(SlcNames.SLC_SYMBOLIC_NAME).getString() : "");
-                       form.setMessage(bundle
-                                       .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? bundle
-                                       .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
-                                       .getString() : "", IMessageProvider.NONE);
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unable to get bundle name for node "
-                                       + bundle, re);
-               }
-
-               // Main layout
-               Composite header = tk.createComposite(body);
-               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               populateHeaderPart(header);
-
-               Composite mavenSnipet = tk.createComposite(body);
-               mavenSnipet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               populateMavenSnippetPart(mavenSnipet);
-       }
-
-       private void populateHeaderPart(Composite parent) {
-               GridLayout layout = new GridLayout(6, false);
-               // layout.marginWidth = layout.horizontalSpacing = layout.marginHeight =
-               // 0;
-               layout.horizontalSpacing = 10;
-               parent.setLayout(layout);
-               try {
-                       // 1st Line: Category, name version
-                       createLT(parent, "Category",
-                                       bundle.hasProperty(SlcNames.SLC_GROUP_ID) ? bundle
-                                                       .getProperty(SlcNames.SLC_GROUP_ID).getString()
-                                                       : "");
-                       createLT(parent, "Name",
-                                       bundle.hasProperty(SlcNames.SLC_ARTIFACT_ID) ? bundle
-                                                       .getProperty(SlcNames.SLC_ARTIFACT_ID).getString()
-                                                       : "");
-                       createLT(parent, "Version",
-                                       bundle.hasProperty(SlcNames.SLC_ARTIFACT_VERSION) ? bundle
-                                                       .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
-                                                       .getString() : "");
-
-                       // 3rd Line: Vendor, licence, sources
-                       createLT(
-                                       parent,
-                                       "Vendor",
-                                       bundle.hasProperty(DistConstants.SLC_BUNDLE_VENDOR) ? bundle
-                                                       .getProperty(DistConstants.SLC_BUNDLE_VENDOR)
-                                                       .getString() : "N/A");
-
-                       createLicencesLink(parent, "Licence",
-                                       DistConstants.SLC_BUNDLE_LICENCE);
-                       addSourceLink(parent);
-
-                       // 2nd Line: The Jar itself and the Manifest
-                       createJarLink(parent);
-                       createManifestLink(parent);
-
-                       // Last line
-                       createPomLink(parent);
-
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unable to get bundle name for node "
-                                       + bundle, re);
-               }
-
-       }
-
-       private void populateMavenSnippetPart(Composite parent) {
-               GridLayout layout = new GridLayout(1, false);
-               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
-               parent.setLayout(layout);
-
-               Section section = tk.createSection(parent, Section.TITLE_BAR
-                               | Section.DESCRIPTION);
-               section.setText("Maven");
-               section.setDescription("Add the below tag to your Artifact pom dependencies");
-               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               Text snippetTxt = createMavenSnippet(section);
-               section.setClient(snippetTxt);
-       }
-
-       // /////////////////////
-       // HELPERS
-
-       private Text createLT(Composite parent, String labelValue, String textValue) {
-               Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
-               // label.setFont(EclipseUiUtils.getBoldFont(parent));
-               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-               // Add a trailing space to workaround a display glitch in RAP 1.3
-               Text text = new Text(parent, SWT.LEFT);
-               text.setText(textValue + " ");
-               text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-               text.setEditable(false);
-               return text;
-       }
-
-       private void createLicencesLink(Composite parent, String label,
-                       String jcrPropName) throws RepositoryException {
-               tk.createLabel(parent, label, SWT.NONE);
-               if (bundle.hasProperty(jcrPropName)) {
-
-                       String licenceLinkVal = bundle.getProperty(jcrPropName).getString();
-
-                       // FIXME Hack until license generation is done cleanly
-                       // Problem is with description that contains a "," like
-                       // "Apache License, Version 2"
-                       String[] licenceVals;
-                       if (licenceLinkVal.contains("description="))
-                               licenceVals = new String[] { licenceLinkVal };
-                       else
-                               // multiple license, form non-regenerated manifests
-                               licenceVals = licenceLinkVal.split(", ");
-
-                       Composite body = tk.createComposite(parent);
-                       body.setLayout(new RowLayout(SWT.WRAP));
-
-                       for (final String value : licenceVals) {
-                               final License currLicense = parseLicenseString(value);
-
-                               Hyperlink link = tk.createHyperlink(body,
-                                               currLicense.getName(), SWT.NONE);
-                               link.addHyperlinkListener(new HyperlinkAdapter() {
-                                       @Override
-                                       public void linkActivated(HyperlinkEvent e) {
-                                               try {
-                                                       IWorkbenchBrowserSupport browserSupport = PlatformUI
-                                                                       .getWorkbench().getBrowserSupport();
-                                                       IWebBrowser browser = browserSupport
-                                                                       .createBrowser(
-                                                                                       IWorkbenchBrowserSupport.LOCATION_BAR
-                                                                                                       | IWorkbenchBrowserSupport.NAVIGATION_BAR,
-                                                                                       "SLC Distribution browser",
-                                                                                       "SLC Distribution browser",
-                                                                                       "A tool tip");
-                                                       browser.openURL(new URL(currLicense.getUri()));
-                                               } catch (Exception ex) {
-                                                       throw new SlcException("error opening browser", ex); //$NON-NLS-1$
-                                               }
-                                       }
-                               });
-                       }
-               } else
-                       tk.createLabel(parent, "N/A", SWT.NONE);
-       }
-
-       // TODO this must be moved to a better place once the standard has been
-       // defined
-       // Enable licence encoding in a single JCR Value
-       private final static String LICENSE_SEPARATOR = ";";
-       // The human readable name of the licence
-       private final static String LICENSE_NAME = "description";
-       // A link on the internet with some more info on this licence
-       private final static String LICENSE_LINK = "link";
-
-       private License parseLicenseString(String licenseStr) {
-               String uri = null, name = null, link = null, text = null;
-               // TODO enhance this
-               String[] values = licenseStr.split(LICENSE_SEPARATOR);
-               for (String value : values) {
-                       if (value.startsWith(LICENSE_NAME))
-                               name = value.substring(LICENSE_NAME.length() + 1); // +1 for the
-                                                                                                                                       // '='
-                       else if (value.startsWith(LICENSE_LINK))
-                               link = value.substring(LICENSE_LINK.length() + 1);
-                       else if (uri == null)
-                               uri = value;
-                       // TODO manage text
-               }
-               return new SimpleLicense(name, uri, link, text);
-       }
-
-       class SimpleLicense implements License {
-               private final String name;
-               private final String uri;
-               private final String link;
-               private final String text;
-
-               public SimpleLicense(String name, String uri, String link, String text) {
-                       if (uri == null)
-                               throw new SlcException(
-                                               "Cannot manage a licence with a null URI ");
-                       this.uri = uri;
-
-                       this.name = name;
-                       this.link = link;
-                       this.text = text;
-               }
-
-               public String getUri() {
-                       return uri;
-               }
-
-               public String getText() {
-                       return text;
-               }
-
-               public String getName() {
-                       return name != null ? name : uri;
-               }
-
-               public String getLink() {
-                       return link;
-               }
-       }
-
-       private void createJarLink(Composite parent) throws RepositoryException {
-               Label label = tk.createLabel(parent, "Jar", SWT.RIGHT);
-               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
-               Composite body = tk.createComposite(parent);
-               RowLayout rl = new RowLayout(SWT.HORIZONTAL);
-               rl.spacing = 6;
-               body.setLayout(rl);
-               body.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
-
-               Hyperlink jarLink = tk
-                               .createHyperlink(body, bundle.getName(), SWT.NONE);
-               jarLink.addHyperlinkListener(new OpenFileLinkListener(bundle.getPath()));
-
-               // Corresponding check sums
-
-               String name = bundle.getName() + ".md5";
-               if (bundle.getParent().hasNode(name)) {
-                       Node md5 = bundle.getParent().getNode(name);
-                       Hyperlink md5Link = tk.createHyperlink(body, "MD5", SWT.NONE);
-                       md5Link.addHyperlinkListener(new OpenFileLinkListener(md5.getPath()));
-               }
-
-               name = bundle.getName() + ".sha1";
-               if (bundle.getParent().hasNode(name)) {
-                       Node sha1 = bundle.getParent().getNode(name);
-                       Hyperlink sha1Link = tk.createHyperlink(body, "SHA1", SWT.NONE);
-                       sha1Link.addHyperlinkListener(new OpenFileLinkListener(sha1
-                                       .getPath()));
-               }
-       }
-
-       private void createPomLink(Composite parent) throws RepositoryException {
-               Label label = tk.createLabel(parent, "Pom", SWT.RIGHT);
-               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
-               String name = bundle.getName().substring(0,
-                               bundle.getName().length() - "jar".length())
-                               + "pom";
-
-               if (bundle.getParent().hasNode(name)) {
-                       Node pom = bundle.getParent().getNode(name);
-
-                       Composite body = tk.createComposite(parent);
-                       RowLayout rl = new RowLayout(SWT.HORIZONTAL);
-                       rl.spacing = 6;
-                       body.setLayout(rl);
-                       body.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
-                                       3, 1));
-
-                       Hyperlink pomLink = tk.createHyperlink(body, "pom.xml", SWT.NONE);
-                       pomLink.addHyperlinkListener(new OpenFileLinkListener(pom.getPath()));
-
-                       // Corresponding check sums
-                       name = pom.getName() + ".md5";
-                       if (pom.getParent().hasNode(name)) {
-                               Node md5 = pom.getParent().getNode(name);
-                               Hyperlink md5Link = tk.createHyperlink(body, "MD5", SWT.NONE);
-                               md5Link.addHyperlinkListener(new OpenFileLinkListener(md5
-                                               .getPath()));
-                       }
-
-                       name = pom.getName() + ".sha1";
-                       if (pom.getParent().hasNode(name)) {
-                               Node sha1 = pom.getParent().getNode(name);
-                               Hyperlink sha1Link = tk.createHyperlink(body, "SHA1", SWT.NONE);
-                               sha1Link.addHyperlinkListener(new OpenFileLinkListener(sha1
-                                               .getPath()));
-                       }
-               } else
-                       tk.createLabel(parent, "N/A", SWT.NONE);
-       }
-
-       private void createManifestLink(Composite parent)
-                       throws RepositoryException {
-               tk.createLabel(parent, "Manifest", SWT.NONE);
-               // Hyperlink link =
-               // TODO fix this when file download has been implemented for the
-               // manifest
-               tk.createHyperlink(parent, "MANIFEST.MF", SWT.NONE);
-               // link.addHyperlinkListener(new
-               // OpenFileLinkListener(bundle.getPath()));
-       }
-
-       // private void createHyperlink(Composite parent, String label,
-       // String jcrPropName) throws RepositoryException {
-       // tk.createLabel(parent, label, SWT.NONE);
-       // if (bundle.hasProperty(jcrPropName)) {
-       // final Hyperlink link = tk.createHyperlink(parent, bundle
-       // .getProperty(jcrPropName).getString(), SWT.NONE);
-       // link.addHyperlinkListener(new AbstractHyperlinkListener() {
-       // @Override
-       // public void linkActivated(HyperlinkEvent e) {
-       // try {
-       // IWorkbenchBrowserSupport browserSupport = PlatformUI
-       // .getWorkbench().getBrowserSupport();
-       // IWebBrowser browser = browserSupport
-       // .createBrowser(
-       // IWorkbenchBrowserSupport.LOCATION_BAR
-       // | IWorkbenchBrowserSupport.NAVIGATION_BAR,
-       // "SLC Distribution browser",
-       // "SLC Distribution browser",
-       // "A tool tip");
-       // browser.openURL(new URL(link.getText()));
-       // } catch (Exception ex) {
-       //                                              throw new SlcException("error opening browser", ex); //$NON-NLS-1$
-       // }
-       // }
-       // });
-       // } else
-       // tk.createLabel(parent, "N/A", SWT.NONE);
-       // }
-
-       // helper to check if sources are available
-       private void addSourceLink(Composite parent) {
-               try {
-                       String srcPath = RepoUtils.relatedPdeSourcePath(
-                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, bundle);
-                       if (!bundle.getSession().nodeExists(srcPath)) {
-                               createLT(parent, "Sources", "N/A");
-                       } else {
-                               final Node sourcesNode = bundle.getSession().getNode(srcPath);
-
-                               String srcName = null;
-                               if (sourcesNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME))
-                                       srcName = sourcesNode.getProperty(
-                                                       SlcNames.SLC_SYMBOLIC_NAME).getString();
-                               else
-                                       srcName = sourcesNode.getName();
-                               Label label = tk.createLabel(parent, "Sources", SWT.RIGHT);
-                               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
-                                               false));
-                               final Hyperlink link = tk.createHyperlink(parent, srcName,
-                                               SWT.NONE);
-                               link.addHyperlinkListener(new OpenFileLinkListener(sourcesNode
-                                               .getPath()));
-
-                               // {
-                               // @Override
-                               // public void linkActivated(HyperlinkEvent e) {
-                               // try {
-                               // ModuleEditorInput editorInput = (ModuleEditorInput)
-                               // getEditorInput();
-                               // Map<String, String> params = new HashMap<String, String>();
-                               // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
-                               // editorInput.getRepoNodePath());
-                               // params.put(OpenJcrFile.PARAM_REPO_URI,
-                               // editorInput.getUri());
-                               // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
-                               // editorInput.getWorkspaceName());
-                               // params.put(OpenJcrFile.PARAM_FILE_PATH,
-                               // );
-                               // CommandUtils.callCommand(OpenJcrFile.ID, params);
-                               // } catch (Exception ex) {
-                               //                                                      throw new SlcException("error opening browser", ex); //$NON-NLS-1$
-                               // }
-                               // }
-                               // });
-
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unable to configure sources link for "
-                                       + bundle, e);
-               }
-       }
-
-       private class OpenFileLinkListener extends HyperlinkAdapter {
-               final private String path;
-
-               public OpenFileLinkListener(String path) {
-                       this.path = path;
-               }
-
-               @Override
-               public void linkActivated(HyperlinkEvent e) {
-                       log.warn("File download must be implemented. Cannot provide access to "
-                                       + path);
-
-                       // try {
-                       // ModuleEditorInput editorInput = (ModuleEditorInput)
-                       // getEditorInput();
-                       // Map<String, String> params = new HashMap<String, String>();
-                       // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
-                       // editorInput.getRepoNodePath());
-                       // params.put(OpenJcrFile.PARAM_REPO_URI, editorInput.getUri());
-                       // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
-                       // editorInput.getWorkspaceName());
-                       // params.put(OpenJcrFile.PARAM_FILE_PATH, path);
-                       //
-                       // String cmdId = (new OpenJcrFileCmdId()).getCmdId();
-                       // if (log.isTraceEnabled())
-                       // log.debug("Retrieved openFile Cmd ID: " + cmdId);
-                       // CommandUtils.callCommand(cmdId, params);
-                       // } catch (Exception ex) {
-                       //                              throw new SlcException("error opening browser", ex); //$NON-NLS-1$
-                       // }
-               }
-       }
-
-       /** Creates a text area with corresponding maven snippet */
-       private Text createMavenSnippet(Composite parent) {
-               Text mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP);
-               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               gd.heightHint = 100;
-               mavenSnippet.setLayoutData(gd);
-               mavenSnippet.setText(generateXmlSnippet());
-               return mavenSnippet;
-       }
-
-       private String generateXmlSnippet() {
-               try {
-                       StringBuffer sb = new StringBuffer();
-                       sb.append("<dependency>\n");
-                       sb.append("\t<groupId>");
-                       sb.append(bundle.getProperty(SLC_GROUP_ID).getString());
-                       sb.append("</groupId>\n");
-                       sb.append("\t<artifactId>");
-                       sb.append(bundle.getProperty(SLC_ARTIFACT_ID).getString());
-                       sb.append("</artifactId>\n");
-                       sb.append("\t<version>");
-                       sb.append(bundle.getProperty(SLC_ARTIFACT_VERSION).getString());
-                       sb.append("</version>\n");
-                       sb.append("</dependency>");
-                       return sb.toString();
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "unexpected error while generating maven snippet");
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleRawPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleRawPage.java
deleted file mode 100644 (file)
index 0ac7e4e..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.utils.DistUiHelpers;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/** List all properties of current bundle as a tree */
-public class BundleRawPage extends FormPage implements SlcNames, SlcTypes {
-       // private final static Log log =
-       // LogFactory.getLog(ArtifactDetailsPage.class);
-
-       // Main business Objects
-       private Node currBundle;
-
-       // This page widgets
-       private TreeViewer complexTree;
-
-       public BundleRawPage(FormEditor editor, String title, Node currentNode) {
-               super(editor, "id", title);
-               this.currBundle = currentNode;
-       }
-
-       protected void createFormContent(IManagedForm managedForm) {
-               ScrolledForm form = managedForm.getForm();
-               GridLayout layout = new GridLayout(1, false);
-               layout.marginWidth = 5;
-               form.getBody().setLayout(layout);
-               createViewer(form.getBody());
-       }
-
-       private void createViewer(Composite parent) {
-
-               // Create the viewer
-               int style = SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION;
-               Tree tree = new Tree(parent, style);
-               GridData gd = new GridData(GridData.FILL_BOTH);
-               gd.grabExcessHorizontalSpace = true;
-               gd.grabExcessVerticalSpace = true;
-               tree.setLayoutData(gd);
-               createColumn(tree, "Attribute", SWT.LEFT, 200);
-               createColumn(tree, "Value", SWT.LEFT, 200);
-               tree.setLinesVisible(true);
-               tree.setHeaderVisible(true);
-
-               complexTree = new TreeViewer(tree);
-               complexTree.setContentProvider(new TreeContentProvider());
-               complexTree.setLabelProvider(new TreeLabelProvider());
-
-               // Initialize
-               complexTree.setInput(currBundle);
-               // result.expandAll();
-               complexTree.expandToLevel(2);
-
-       }
-
-       private static TreeColumn createColumn(Tree parent, String name, int style,
-                       int width) {
-               TreeColumn result = new TreeColumn(parent, style);
-               result.setText(name);
-               result.setWidth(width);
-               result.setMoveable(true);
-               result.setResizable(true);
-               return result;
-       }
-
-       // View specific object
-       private class ViewSpecificItems {
-               private String key;
-               private Object value;
-               private boolean isFolder;
-               private Node curNode;
-
-               public ViewSpecificItems(String key, Object value, boolean isFolder) {
-                       this.key = key;
-                       this.value = value;
-                       this.isFolder = isFolder;
-               }
-
-               public String getKey() {
-                       return key;
-               }
-
-               public void setNode(Node node) {
-                       this.curNode = node;
-               }
-
-               public Node getNode() {
-                       return curNode;
-               }
-
-               public Object getValue() {
-                       return value;
-               }
-
-               public boolean isFolder() {
-                       return isFolder;
-               }
-
-       }
-
-       // providers
-       private class TreeLabelProvider extends ColumnLabelProvider implements
-                       SlcTypes, SlcNames {
-               private static final long serialVersionUID = -6385445983392621937L;
-
-               public void update(ViewerCell cell) {
-                       try {
-
-                               int colIndex = cell.getColumnIndex();
-                               Object element = cell.getElement();
-                               if (element instanceof Property) {
-                                       Property prop = (Property) element;
-                                       if (colIndex == 0)
-                                               cell.setText(DistUiHelpers.getLabelJcrName(prop
-                                                               .getName()));
-                                       else if (colIndex == 1)
-                                               cell.setText(DistUiHelpers.formatValueAsString(prop
-                                                               .getValue()));
-
-                               } else if (element instanceof ViewSpecificItems) {
-                                       if (colIndex == 0)
-                                               cell.setText(((ViewSpecificItems) element).getKey());
-                                       else if (colIndex == 1)
-                                               cell.setText(DistUiHelpers
-                                                               .formatAsString(((ViewSpecificItems) element)
-                                                                               .getValue()));
-
-                               } else if (element instanceof Node) {
-                                       Node node = (Node) element;
-                                       if (colIndex == 0) {
-                                               if (node.isNodeType(NodeType.NT_FILE)) {
-                                                       cell.setImage(DistImages.IMG_FILE);
-                                                       cell.setText(node.getName());
-                                               } else if (node.isNodeType(SLC_IMPORTED_PACKAGE))
-                                                       cell.setText("Import package");
-                                               else if (node.isNodeType(SLC_EXPORTED_PACKAGE))
-                                                       cell.setText("Export package");
-
-                                       } else if (colIndex == 1) {
-                                               if (node.isNodeType(SLC_ARTIFACT)) {
-                                                       StringBuffer sb = new StringBuffer("");
-                                                       if (node.hasProperty(SLC_ARTIFACT_CLASSIFIER)) {
-                                                               sb.append(node.getProperty(
-                                                                               SLC_ARTIFACT_CLASSIFIER).getString());
-                                                               sb.append(" ");
-                                                       }
-                                                       if (node.hasProperty(SLC_ARTIFACT_EXTENSION))
-                                                               sb.append(node.getProperty(
-                                                                               SLC_ARTIFACT_EXTENSION).getString());
-                                                       cell.setText(sb.toString());
-                                               } else if (node.isNodeType(SLC_IMPORTED_PACKAGE)
-                                                               || node.isNodeType(SLC_EXPORTED_PACKAGE))
-                                                       cell.setText(node.getProperty(SLC_NAME).getString());
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "unexpected error while getting artifact information",
-                                               e);
-                       }
-               }
-       }
-
-       private class TreeContentProvider implements ITreeContentProvider {
-               private static final long serialVersionUID = -4315686158836938052L;
-
-               public Object[] getElements(Object parent) {
-                       List<Object> elements = new ArrayList<Object>();
-
-                       try {
-                               Node node = (Node) parent;
-                               elements = new ArrayList<Object>();
-
-                               // Maven coordinates
-//                             elements.add(node.getProperty(SLC_GROUP_ID));
-//                             elements.add(node.getProperty(SLC_ARTIFACT_ID));
-//                             elements.add(node.getProperty(SLC_ARTIFACT_VERSION));
-
-                               // Meta information
-                               // boolean gotSource = false;
-                               // // TODO: implement this check
-                               // elements.add(new ViewSpecificItems("Sources available",
-                               // gotSource));
-
-                               // Jars
-                               NodeIterator ni = node.getNodes();
-                               while (ni.hasNext()) {
-                                       Node child = ni.nextNode();
-                                       if (child.isNodeType(SLC_ARTIFACT)) {
-                                               // we skip sha1 files for the time being.
-                                               elements.add(child);
-                                       }
-                               }
-
-                               // Properties
-                               PropertyIterator pi = node.getProperties();
-                               while (pi.hasNext()) {
-                                       Property curProp = pi.nextProperty();
-                                       if (!curProp.getName().startsWith("jcr:")
-                                                       && !curProp.isMultiple())
-                                               elements.add(curProp);
-                               }
-
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "Unexpected exception while listing node properties", e);
-                       }
-                       return elements.toArray();
-               }
-
-               public Object getParent(Object child) {
-                       return null;
-               }
-
-               public Object[] getChildren(Object parent) {
-                       Object[] result = null;
-                       try {
-                               if (parent instanceof Property) {
-                                       Property prop = (Property) parent;
-                                       if (prop.isMultiple()) {
-                                               Value[] values = prop.getValues();
-                                               return values;
-                                       }
-                               } else if (parent instanceof Node) {
-                                       Node node = (Node) parent;
-                                       if (node.hasNodes()) {
-                                               List<Object> elements = new ArrayList<Object>();
-                                               PropertyIterator pi = node.getProperties();
-                                               while (pi.hasNext()) {
-                                                       Property curProp = pi.nextProperty();
-                                                       if (!curProp.getName().startsWith("jcr:")
-                                                                       && !curProp.isMultiple())
-                                                               elements.add(curProp);
-                                               }
-
-                                               NodeIterator ni = node.getNodes();
-                                               while (ni.hasNext()) {
-                                                       Node curNode = ni.nextNode();
-                                                       if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
-                                                                       || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
-                                                               ViewSpecificItems vsi = new ViewSpecificItems(
-                                                                               "Bundle dependencies", "", true);
-                                                               vsi.setNode(node);
-                                                               elements.add(vsi);
-                                                               break;
-                                                       }
-                                               }
-                                               return elements.toArray();
-                                       }
-                               } else if (parent instanceof ViewSpecificItems
-                                               && ((ViewSpecificItems) parent).isFolder()) {
-                                       NodeIterator ni = ((ViewSpecificItems) parent).getNode()
-                                                       .getNodes();
-                                       List<Node> elements = new ArrayList<Node>();
-                                       while (ni.hasNext()) {
-                                               Node curNode = ni.nextNode();
-                                               if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
-                                                               || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
-                                                       elements.add(curNode);
-                                               }
-                                       }
-                                       return elements.toArray();
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "Unexpected error getting multiple values property.", e);
-                       }
-                       return result;
-               }
-
-               public boolean hasChildren(Object parent) {
-                       try {
-                               if (parent instanceof Property
-                                               && ((Property) parent).isMultiple()) {
-                                       return true;
-                               } else if (parent instanceof Node && ((Node) parent).hasNodes()
-                                               && ((Node) parent).isNodeType(SLC_BUNDLE_ARTIFACT)) {
-                                       return true;
-                               } else if (parent instanceof ViewSpecificItems
-                                               && ((ViewSpecificItems) parent).isFolder()) {
-                                       return true;
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "Unexpected exception while checking if property is multiple",
-                                               e);
-                       }
-                       return false;
-               }
-
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-               }
-
-               public void dispose() {
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspBrowserPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspBrowserPage.java
deleted file mode 100644 (file)
index e377b53..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Ordering;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Expose Maven artifacts of a given workspace as a tree. Artifacts are grouped
- * by Maven group.
- */
-public class DistWkspBrowserPage extends FormPage implements DistConstants,
-               RepoConstants {
-       // private final static Log log = LogFactory
-       // .getLog(ArtifactsBrowserPage.class);
-
-       final static String PAGE_ID = "artifactsBrowserPage";
-
-       // Business object
-       private Session session;
-
-       // This page widgets
-       private TreeViewer artifactTreeViewer;
-
-       public DistWkspBrowserPage(FormEditor editor, String title, Session session) {
-               super(editor, PAGE_ID, title);
-               this.session = session;
-       }
-
-       @Override
-       protected void createFormContent(IManagedForm managedForm) {
-               try {
-                       ScrolledForm form = managedForm.getForm();
-                       Composite parent = form.getBody();
-                       parent.setLayout(new FillLayout());
-                       createMavenBrowserPart(parent);
-                       getEditor().getSite().setSelectionProvider(artifactTreeViewer);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot create artifact browser page", e);
-               }
-       }
-
-       /** Aether specific browser for the current workspace */
-       private void createMavenBrowserPart(Composite parent)
-                       throws RepositoryException {
-
-               int style = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL
-                               | SWT.FULL_SELECTION | SWT.BORDER;
-               
-               Tree tree = new Tree(parent, style);
-               createColumn(tree, "Maven browser", SWT.LEFT, 450);
-               tree.setLinesVisible(true);
-               tree.setHeaderVisible(true);
-
-               artifactTreeViewer = new TreeViewer(tree);
-
-               artifactTreeViewer.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = 2648269889876058461L;
-
-                       @Override
-                       public String getText(Object element) {
-                               Node node = (Node) element;
-                               try {
-                                       if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
-                                               return JcrUtils.get((Node) element,
-                                                               SlcNames.SLC_GROUP_BASE_ID);
-                                       else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
-                                               return JcrUtils.get((Node) element,
-                                                               SlcNames.SLC_ARTIFACT_ID);
-                                       else
-                                               return node.getName();
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot browse artifacts", e);
-                               }
-                       }
-
-                       @Override
-                       public Image getImage(Object element) {
-                               Node node = (Node) element;
-                               try {
-
-                                       if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
-                                               return DistImages.IMG_GROUP_BASE;
-                                       else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
-                                               return DistImages.IMG_ARTIFACT_BASE;
-                                       else if (node
-                                                       .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE))
-                                               return DistImages.IMG_ARTIFACT_VERSION_BASE;
-                                       else
-                                               return null;
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot get images for artifacts", e);
-                               }
-                       }
-               });
-
-               artifactTreeViewer.setContentProvider(new ITreeContentProvider() {
-                       private static final long serialVersionUID = -2381555428857519326L;
-
-                       public void dispose() {
-                       }
-
-                       public void inputChanged(Viewer viewer, Object oldInput,
-                                       Object newInput) {
-                       }
-
-                       public Object[] getElements(Object inputElement) {
-                               try {
-                                       List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
-                                                       SlcTypes.SLC_GROUP_BASE, SlcNames.SLC_NAME));
-                                       return nodes.toArray();
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot list children Nodes", e);
-                               }
-                       }
-
-                       public Object[] getChildren(Object parentElement) {
-                               // Only 3 levels for the time being
-                               try {
-                                       Node pNode = (Node) parentElement;
-                                       if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)) {
-                                               return getArtifactBase(pNode,
-                                                               SlcTypes.SLC_ARTIFACT_BASE);
-                                       } else if (pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
-                                               return getArtifactBase(pNode,
-                                                               SlcTypes.SLC_ARTIFACT_VERSION_BASE);
-                                       }
-                                       return null;
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot list children Nodes", e);
-                               }
-                       }
-
-                       // Helper to get children because current version of Jackrabbit is
-                       // buggy in remote
-                       private Object[] getArtifactBase(Node parent, String nodeType)
-                                       throws RepositoryException {
-                               List<Node> nodes = new ArrayList<Node>();
-                               NodeIterator ni = parent.getNodes();
-                               while (ni.hasNext()) {
-                                       Node node = ni.nextNode();
-                                       if (node.isNodeType(nodeType))
-                                               nodes.add(node);
-                               }
-                               return nodes.toArray();
-                       }
-
-                       public Object getParent(Object element) {
-                               return null;
-                       }
-
-                       public boolean hasChildren(Object element) {
-                               try {
-                                       Node pNode = (Node) element;
-                                       if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)
-                                                       || pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
-                                               // might return true even if there is no "valid" child
-                                               return pNode.hasNodes();
-                                       } else
-                                               return false;
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot check children Nodes", e);
-                               }
-                       }
-               });
-
-               artifactTreeViewer.addDoubleClickListener(new DoubleClickListener());
-
-               artifactTreeViewer.setInput("Initialize");
-       }
-
-       private class DoubleClickListener implements IDoubleClickListener {
-
-               public void doubleClick(DoubleClickEvent event) {
-                       Object obj = ((IStructuredSelection) event.getSelection())
-                                       .getFirstElement();
-                       if (obj instanceof Node) {
-                               Node node = (Node) obj;
-                               try {
-                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
-                                               NodeIterator nit = node.getNodes();
-                                               while (nit.hasNext()) {
-                                                       Node curr = nit.nextNode();
-                                                       if (curr.isNodeType(SlcTypes.SLC_ARTIFACT)) {
-                                                               node = curr;
-                                                               break;
-                                                       }
-                                               }
-                                       }
-
-                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
-                                               DistWkspEditorInput dwip = (DistWkspEditorInput) getEditorInput();
-                                               Map<String, String> params = new HashMap<String, String>();
-                                               params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
-                                                               dwip.getRepoNodePath());
-                                               params.put(OpenModuleEditor.PARAM_REPO_URI,
-                                                               dwip.getUri());
-                                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
-                                                               dwip.getWorkspaceName());
-                                               String path = node.getPath();
-                                               params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
-                                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
-                                       }
-                               } catch (RepositoryException re) {
-                                       throw new SlcException("Cannot get path for node " + node
-                                                       + " while setting parameters for "
-                                                       + "command OpenModuleEditor", re);
-                               }
-
-                       }
-               }
-       }
-
-       private static TreeColumn createColumn(Tree parent, String name, int style,
-                       int width) {
-               TreeColumn result = new TreeColumn(parent, style);
-               result.setText(name);
-               result.setWidth(width);
-               result.setMoveable(true);
-               result.setResizable(true);
-               return result;
-       }
-
-       private NodeIterator listNodes(String nodeType, String orderBy)
-                       throws RepositoryException {
-               QueryManager queryManager = session.getWorkspace().getQueryManager();
-               QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
-               final String nodeSelector = "nodes";
-               Selector source = factory.selector(nodeType, nodeSelector);
-
-               Ordering order = factory.ascending(factory.propertyValue(nodeSelector,
-                               orderBy));
-               Ordering[] orderings = { order };
-
-               QueryObjectModel query = factory.createQuery(source, null, orderings,
-                               null);
-
-               QueryResult result = query.execute();
-
-               return result.getNodes();
-       }
-
-       
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspEditorInput.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspEditorInput.java
deleted file mode 100644 (file)
index 5929706..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/** An editor input pointing to a distribution workspace */
-public class DistWkspEditorInput implements IEditorInput, SlcNames {
-
-       // Injected
-       // private RepositoryFactory repositoryFactory;
-       // private Keyring keyring;
-       // private Node repoNode;
-       private String repoNodePath;
-       private String uri;
-
-       // Local variables
-       private String workspaceName;
-
-       // public WorkspaceEditorInput(RepositoryFactory repositoryFactory,
-       // Keyring keyring, Repository localRepository, Node repoNode,
-       // String uri) {
-       // // this.repositoryFactory = repositoryFactory;
-       // // this.keyring = keyring;
-       // this.localRepository = localRepository;
-       // // this.repoNode= repoNode;
-       // this.uri = uri;
-       //
-       // }
-
-       /** uri and workspace name cannot be null */
-       public DistWkspEditorInput(String repoNodePath, String uri,
-                       String workspaceName) {
-               if (workspaceName == null)
-                       throw new SlcException("Workspace name cannot be null");
-               if (uri == null)
-                       throw new SlcException("URI for repository cannot be null");
-               this.repoNodePath = repoNodePath;
-               this.workspaceName = workspaceName;
-               this.uri = uri;
-       }
-
-       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-               return null;
-       }
-
-       public boolean exists() {
-               return true;
-       }
-
-       public ImageDescriptor getImageDescriptor() {
-               return null;
-       }
-
-       // Dummy compulsory methods
-       public String getToolTipText() {
-               return "Editor for workspace " + workspaceName
-                               + " in repository of URI " + uri;
-       }
-
-       public String getName() {
-               return workspaceName + "@" + uri;
-       }
-
-       public IPersistableElement getPersistable() {
-               return null;
-       }
-
-       public boolean equals(Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (!(obj instanceof DistWkspEditorInput))
-                       return false;
-
-               DistWkspEditorInput other = (DistWkspEditorInput) obj;
-
-               if (!workspaceName.equals(other.getWorkspaceName()))
-                       return false;
-               if (!uri.equals(other.getUri()))
-                       return false;
-
-               if (repoNodePath == null)
-                       return other.getRepoNodePath() == null;
-               else
-                       return repoNodePath.equals(other.getRepoNodePath());
-       }
-
-       public String getUri() {
-               return uri;
-       }
-
-       public String getWorkspaceName() {
-               return workspaceName;
-       }
-
-       public String getRepoNodePath() {
-               return repoNodePath;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java
deleted file mode 100644 (file)
index 1a959a5..0000000
+++ /dev/null
@@ -1,515 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.Ordering;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-import javax.jcr.query.qom.StaticOperand;
-
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.commands.DeleteArtifacts;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-
-/** Show all bundles contained in a given workspace as filter-able table */
-public class DistWkspSearchPage extends FormPage implements SlcNames {
-       // final private static Log log = LogFactory
-       // .getLog(DistributionOverviewPage.class);
-
-       final static String PAGE_ID = "distributionOverviewPage";
-
-       // Business Objects
-       private Session session;
-
-       // This page widgets
-       private DistWorkspaceEditor formEditor;
-       private FormToolkit tk;
-
-       private DistNodeViewerComparator comparator;
-       private TableViewer viewer;
-
-       // private Composite header;
-       private Text artifactTxt;
-       private final static String FILTER_HELP_MSG = "Filter criterion, separated by a space";
-
-       public DistWkspSearchPage(DistWorkspaceEditor formEditor, String title,
-                       Session session) {
-               super(formEditor, PAGE_ID, title);
-               this.formEditor = formEditor;
-               this.session = session;
-       }
-
-       private void asynchronousRefresh() {
-               RefreshJob job = new RefreshJob(artifactTxt.getText(), viewer,
-                               getSite().getShell().getDisplay());
-               job.setUser(true);
-               job.schedule();
-       }
-
-       private class RefreshJob extends PrivilegedJob {
-               private TableViewer viewer;
-               private String filter;
-               private Display display;
-
-               public RefreshJob(String filter, TableViewer viewer, Display display) {
-                       super("Get bundle list");
-                       this.filter = filter;
-                       this.viewer = viewer;
-                       this.display = display;
-               }
-
-               @Override
-               protected IStatus doRun(IProgressMonitor progressMonitor) {
-                       try {
-                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
-                               monitor.beginTask("Getting bundle list", -1);
-                               final List<Node> result = JcrUtils
-                                               .nodeIteratorToList(listBundleArtifacts(session, filter));
-
-                               display.asyncExec(new Runnable() {
-                                       public void run() {
-                                               viewer.setInput(result);
-                                       }
-                               });
-                       } catch (Exception e) {
-                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
-                                               "Cannot get bundle list", e);
-                       }
-                       return Status.OK_STATUS;
-               }
-       }
-
-       @Override
-       protected void createFormContent(IManagedForm managedForm) {
-               ScrolledForm form = managedForm.getForm();
-               tk = managedForm.getToolkit();
-
-               // Main Layout
-               GridLayout layout = new GridLayout(1, false);
-               Composite body = form.getBody();
-               body.setLayout(layout);
-
-               // Meta info about current workspace
-               Composite header = tk.createComposite(body);
-               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               createHeaderPart(form, header);
-
-               Composite modules = tk.createComposite(body);
-               modules.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               populateModuleSection(modules);
-       }
-
-       private void createHeaderPart(ScrolledForm form, Composite parent) {
-               GridLayout layout = new GridLayout(4, false);
-               // layout.marginWidth = layout.marginHeight = layout.verticalSpacing =
-               // 0;
-               // layout.horizontalSpacing = 2;
-               parent.setLayout(layout);
-
-               String wkspName = ((DistWkspEditorInput) getEditorInput())
-                               .getWorkspaceName();
-               wkspName = wkspName.replaceAll("-", " ");
-               form.setText(wkspName);
-
-               String repoAlias = "";
-               Node repoNode = ((DistWorkspaceEditor) getEditor()).getRepoNode();
-               if (repoNode != null)
-                       try {
-                               repoAlias = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
-                                               .getProperty(Property.JCR_TITLE).getString() : repoNode
-                                               .getName();
-                       } catch (RepositoryException e1) {
-                               throw new SlcException("Unable to get repository alias ", e1);
-                       }
-               else
-                       repoAlias = " - ";
-
-               createLT(parent, "Repository alias", repoAlias);
-               createLT(parent, "URI",
-                               ((DistWkspEditorInput) getEditorInput()).getUri());
-       }
-
-       private void populateModuleSection(Composite parent) {
-               GridLayout layout = new GridLayout(1, false);
-               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
-               parent.setLayout(layout);
-
-               Section section = tk.createSection(parent, Section.TITLE_BAR
-                               | Section.DESCRIPTION);
-               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-               section.setText("Artifacts");
-               section.setDescription("Search among all artifacts that are referenced in the current workspace");
-               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-               Composite body = tk.createComposite(section);
-               layout = new GridLayout(1, false);
-               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
-               body.setLayout(new GridLayout());
-
-               // Filter
-               Composite filter = tk.createComposite(body);
-               filter.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               createFilterPart(filter);
-
-               // Table
-               Composite tableCmp = tk.createComposite(body);
-               tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               createTableViewer(tableCmp);
-
-               section.setClient(body);
-       }
-
-       /** Build repository request */
-       private NodeIterator listBundleArtifacts(Session session, String filter)
-                       throws RepositoryException {
-               QueryManager queryManager = session.getWorkspace().getQueryManager();
-               QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
-               final String bundleArtifactsSelector = "bundleArtifacts";
-               Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
-                               bundleArtifactsSelector);
-
-               // Create a dynamic operand for each property on which we want to filter
-               DynamicOperand symbNameDO = factory.propertyValue(
-                               source.getSelectorName(), SlcNames.SLC_SYMBOLIC_NAME);
-               DynamicOperand versionDO = factory.propertyValue(
-                               source.getSelectorName(), SlcNames.SLC_BUNDLE_VERSION);
-               DynamicOperand nameDO = factory.propertyValue(source.getSelectorName(),
-                               DistConstants.SLC_BUNDLE_NAME);
-
-               // Default Constraint: no source artifacts
-               Constraint defaultC = factory.not(factory.comparison(
-                               symbNameDO,
-                               QueryObjectModelFactory.JCR_OPERATOR_LIKE,
-                               factory.literal(session.getValueFactory().createValue(
-                                               "%.source"))));
-
-               // Build constraints based the textArea content
-               if (filter != null && !"".equals(filter.trim())) {
-                       // Parse the String
-                       String[] strs = filter.trim().split(" ");
-                       for (String token : strs) {
-                               token = token.replace('*', '%');
-                               StaticOperand so = factory.literal(session.getValueFactory()
-                                               .createValue("%" + token + "%"));
-
-                               Constraint currC = factory.comparison(symbNameDO,
-                                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
-                               currC = factory.or(currC, factory.comparison(versionDO,
-                                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
-                               currC = factory.or(currC, factory.comparison(nameDO,
-                                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
-
-                               defaultC = factory.and(defaultC, currC);
-                       }
-               }
-
-               Ordering order = factory.descending(factory.propertyValue(
-                               bundleArtifactsSelector, SlcNames.SLC_BUNDLE_VERSION));
-               Ordering order2 = factory.ascending(factory.propertyValue(
-                               bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
-               Ordering[] orderings = { order, order2 };
-
-               QueryObjectModel query = factory.createQuery(source, defaultC,
-                               orderings, null);
-
-               QueryResult result = query.execute();
-               return result.getNodes();
-
-       }
-
-       private Text createLT(Composite parent, String labelValue, String textValue) {
-               Label label = new Label(parent, SWT.RIGHT);
-               label.setText(labelValue);
-               // label.setFont(EclipseUiUtils.getBoldFont(parent));
-               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
-               // Add a trailing space to workaround a display glitch in RAP 1.3
-               Text text = new Text(parent, SWT.LEFT); // | SWT.BORDER
-               text.setText(textValue + " ");
-               text.setEditable(false);
-               return text;
-       }
-
-       private void createFilterPart(Composite parent) {
-               GridLayout layout = new GridLayout();
-               layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
-               layout.horizontalSpacing = 5;
-               parent.setLayout(layout);
-
-               // Text Area to filter
-               artifactTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
-                               | SWT.SEARCH | SWT.CANCEL);
-               artifactTxt.setMessage(FILTER_HELP_MSG);
-               GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
-               gd.grabExcessHorizontalSpace = true;
-               artifactTxt.setLayoutData(gd);
-               artifactTxt.addModifyListener(new ModifyListener() {
-                       private static final long serialVersionUID = -2422321852703208573L;
-
-                       public void modifyText(ModifyEvent event) {
-                               if ("".equals(artifactTxt.getText().trim()))
-                                       asynchronousRefresh();
-                               else
-                                       refreshFilteredList();
-                       }
-               });
-       }
-
-       private void refreshFilteredList() {
-               List<Node> nodes;
-               try {
-                       nodes = JcrUtils.nodeIteratorToList(listBundleArtifacts(session,
-                                       artifactTxt.getText()));
-                       viewer.setInput(nodes);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unable to list bundles", e);
-               }
-       }
-
-       private void createTableViewer(Composite parent) {
-               parent.setLayout(new FillLayout());
-               // helpers to enable sorting by column
-               List<String> propertiesList = new ArrayList<String>();
-               List<Integer> propertyTypesList = new ArrayList<Integer>();
-
-               // Define the TableViewer
-               viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
-                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
-
-               // Name
-               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(300);
-               col.getColumn().setText("Name");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = -760226161605987538L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element,
-                                               DistConstants.SLC_BUNDLE_NAME);
-                       }
-               });
-               col.getColumn().addSelectionListener(getSelectionAdapter(0));
-               propertiesList.add(DistConstants.SLC_BUNDLE_NAME);
-               propertyTypesList.add(PropertyType.STRING);
-
-               // Symbolic name
-               col = new TableViewerColumn(viewer, SWT.V_SCROLL);
-               col.getColumn().setWidth(300);
-               col.getColumn().setText("Symbolic Name");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = 4431447542158431355L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
-                       }
-               });
-               col.getColumn().addSelectionListener(getSelectionAdapter(1));
-               propertiesList.add(SLC_SYMBOLIC_NAME);
-               propertyTypesList.add(PropertyType.STRING);
-
-               // Version
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(130);
-               col.getColumn().setText("Version");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = -5616215547236158504L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
-                       }
-               });
-               col.getColumn().addSelectionListener(getSelectionAdapter(2));
-               propertiesList.add(SLC_BUNDLE_VERSION);
-               propertyTypesList.add(DistNodeViewerComparator.VERSION_TYPE);
-
-               final Table table = viewer.getTable();
-               table.setHeaderVisible(true);
-               table.setLinesVisible(true);
-
-               viewer.setContentProvider(new DistributionsContentProvider());
-               getSite().setSelectionProvider(viewer);
-
-               comparator = new DistNodeViewerComparator(2,
-                               DistNodeViewerComparator.ASCENDING, propertiesList,
-                               propertyTypesList);
-               viewer.setComparator(comparator);
-
-               // Context Menu
-               MenuManager menuManager = new MenuManager();
-               Menu menu = menuManager.createContextMenu(viewer.getTable());
-               menuManager.addMenuListener(new IMenuListener() {
-                       private static final long serialVersionUID = -3886983092940055195L;
-
-                       public void menuAboutToShow(IMenuManager manager) {
-                               contextMenuAboutToShow(manager);
-                       }
-               });
-               viewer.getTable().setMenu(menu);
-               getSite().registerContextMenu(menuManager, viewer);
-
-               // Double click
-               viewer.addDoubleClickListener(new DoubleClickListener());
-       }
-
-       @Override
-       public void setFocus() {
-               viewer.getTable().setFocus();
-       }
-
-       /** force refresh of the artifact list */
-       public void refresh() {
-               asynchronousRefresh();
-       }
-
-       /** Programmatically configure the context menu */
-       protected void contextMenuAboutToShow(IMenuManager menuManager) {
-               IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
-                               .getActiveWorkbenchWindow();
-               // Build conditions
-               // Delete selected artifacts
-               CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
-                               DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
-                               true);
-       }
-
-       private SelectionAdapter getSelectionAdapter(final int index) {
-               SelectionAdapter selectionAdapter = new SelectionAdapter() {
-                       private static final long serialVersionUID = 5515884441510882460L;
-
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               Table table = viewer.getTable();
-                               comparator.setColumn(index);
-                               int dir = table.getSortDirection();
-                               if (table.getSortColumn() == table.getColumn(index)) {
-                                       dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
-                               } else {
-                                       dir = SWT.DOWN;
-                               }
-                               table.setSortDirection(dir);
-                               table.setSortColumn(table.getColumn(index));
-                               viewer.refresh();
-                       }
-               };
-               return selectionAdapter;
-       }
-
-       /* LOCAL CLASSES */
-       private class DistributionsContentProvider implements
-                       IStructuredContentProvider {
-               private static final long serialVersionUID = -635451814876234147L;
-
-               // we keep a cache of the Nodes in the content provider to be able to
-               // manage long request
-               private List<Node> nodes;
-
-               public void dispose() {
-               }
-
-               // We expect a list of nodes as a new input
-               @SuppressWarnings("unchecked")
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-                       nodes = (List<Node>) newInput;
-               }
-
-               public Object[] getElements(Object arg0) {
-                       return nodes.toArray();
-               }
-       }
-
-       private class DoubleClickListener implements IDoubleClickListener {
-
-               public void doubleClick(DoubleClickEvent event) {
-                       Object obj = ((IStructuredSelection) event.getSelection())
-                                       .getFirstElement();
-                       if (obj instanceof Node) {
-                               Node node = (Node) obj;
-                               try {
-                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
-                                               DistWkspEditorInput dwip = (DistWkspEditorInput) formEditor
-                                                               .getEditorInput();
-                                               Map<String, String> params = new HashMap<String, String>();
-                                               params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
-                                                               dwip.getRepoNodePath());
-                                               params.put(OpenModuleEditor.PARAM_REPO_URI,
-                                                               dwip.getUri());
-                                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
-                                                               dwip.getWorkspaceName());
-                                               String path = node.getPath();
-                                               params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
-                                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
-                                       }
-                               } catch (RepositoryException re) {
-                                       throw new SlcException("Cannot get path for node " + node
-                                                       + " while setting parameters for "
-                                                       + "command OpenModuleEditor", re);
-                               }
-
-                       }
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWorkspaceEditor.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWorkspaceEditor.java
deleted file mode 100644 (file)
index 3f8f98d..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/** Browse, analyse and modify a workspace containing software distributions */
-public class DistWorkspaceEditor extends FormEditor implements SlcNames {
-       private static final long serialVersionUID = 5373719580281643675L;
-
-       // private final static Log log =
-       // LogFactory.getLog(DistributionEditor.class);
-       public final static String ID = DistPlugin.PLUGIN_ID + ".distWorkspaceEditor";
-
-       /* DEPENDENCY INJECTION */
-       private RepositoryFactory repositoryFactory;
-       private Repository localRepository;
-       private Keyring keyring;
-
-       // Business objects
-       private Node repoNode;
-       // Session that provides the node in the home of the local repository
-       private Session localSession = null;
-       // The business Session on optionally remote repository
-       private Session businessSession;
-       private DistWkspEditorInput editorInput;
-
-       @Override
-       public void init(IEditorSite site, IEditorInput input)
-                       throws PartInitException {
-               editorInput = (DistWkspEditorInput) input;
-               try {
-                       localSession = localRepository.login();
-                       if (editorInput.getRepoNodePath() != null
-                                       && localSession.nodeExists(editorInput.getRepoNodePath()))
-                               repoNode = localSession.getNode(editorInput.getRepoNodePath());
-
-                       businessSession = RepoUtils.getRemoteSession(
-                                       repositoryFactory, keyring, repoNode, editorInput.getUri(),
-                                       editorInput.getWorkspaceName());
-               } catch (RepositoryException e) {
-                       throw new PartInitException("Cannot log to workspace "
-                                       + editorInput.getName(), e);
-               }
-               setPartName(editorInput.getWorkspaceName());
-               super.init(site, input);
-       }
-
-       @Override
-       protected void addPages() {
-               try {
-                       addPage(new DistWkspSearchPage(this, "Details ", businessSession));
-                       addPage(new DistWkspBrowserPage(this, "Maven ", businessSession));
-                       addPage(new WkspCategoryBaseListPage(this, "Groups ",
-                                       businessSession));
-               } catch (PartInitException e) {
-                       throw new SlcException("Cannot add distribution editor pages", e);
-               }
-       }
-
-       @Override
-       public void doSave(IProgressMonitor arg0) {
-       }
-
-       @Override
-       public void dispose() {
-               JcrUtils.logoutQuietly(businessSession);
-               JcrUtils.logoutQuietly(localSession);
-               super.dispose();
-       }
-
-       @Override
-       public void doSaveAs() {
-       }
-
-       @Override
-       public boolean isSaveAsAllowed() {
-               return false;
-       }
-
-       protected Node getRepoNode() {
-               return repoNode;
-       }
-
-       protected Session getSession() {
-               return businessSession;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-
-       public void setLocalRepository(Repository localRepository) {
-               this.localRepository = localRepository;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionDetailPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionDetailPage.java
deleted file mode 100644 (file)
index 0b9f9a3..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-
-/** Show the details for a given bundle. */
-public class ModularDistVersionDetailPage extends FormPage implements SlcNames {
-
-       final static String PAGE_ID = "ModularDistVersionDetailPage";
-
-       // Business Objects
-       private Node modularDistVersion;
-
-       // This page widgets
-       private FormToolkit tk;
-
-       public ModularDistVersionDetailPage(FormEditor formEditor, String title,
-                       Node modularDistVersion) {
-               super(formEditor, PAGE_ID, title);
-               this.modularDistVersion = modularDistVersion;
-       }
-
-       @Override
-       protected void createFormContent(IManagedForm managedForm) {
-               // General settings for this page
-               ScrolledForm form = managedForm.getForm();
-               tk = managedForm.getToolkit();
-               Composite body = form.getBody();
-
-               GridLayout layout = new GridLayout(1, false);
-               layout.marginWidth = 5;
-               layout.marginRight = 15;
-               layout.verticalSpacing = 0;
-               body.setLayout(layout);
-               try {
-                       form.setText(modularDistVersion.hasProperty(SLC_NAME) ? modularDistVersion
-                                       .getProperty(SLC_NAME).getString() : "");
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unable to get slc:name for node "
-                                       + modularDistVersion, re);
-               }
-
-               // Main layout
-               Composite mavenSnipet = tk.createComposite(body);
-               mavenSnipet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               populateMavenSnippetPart(mavenSnipet);
-       }
-
-       private void populateMavenSnippetPart(Composite parent) {
-               GridLayout layout = new GridLayout(1, false);
-               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
-               parent.setLayout(layout);
-
-               Section section = tk.createSection(parent, Section.TITLE_BAR
-                               | Section.DESCRIPTION);
-               section.setText("Maven");
-               section.setDescription("In order to rely on the versions defined by this distribution, "
-                               + "add the below tag to the dependency management of your parent pom.");
-               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               Text snippetTxt = createMavenSnippet(section);
-               section.setClient(snippetTxt);
-       }
-
-       // /////////////////////
-       // HELPERS
-       /** Creates a text area with corresponding maven snippet */
-       private Text createMavenSnippet(Composite parent) {
-               Text mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP);
-               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               gd.heightHint = 100;
-               mavenSnippet.setLayoutData(gd);
-               mavenSnippet.setText(generateXmlSnippet());
-               mavenSnippet.setEditable(false);
-               return mavenSnippet;
-       }
-
-       private String generateXmlSnippet() {
-               try {
-                       StringBuffer sb = new StringBuffer();
-                       sb.append("<dependency>\n");
-                       sb.append("\t<groupId>");
-                       sb.append(modularDistVersion.getProperty(SLC_GROUP_ID).getString());
-                       sb.append("</groupId>\n");
-                       sb.append("\t<artifactId>");
-                       sb.append(modularDistVersion.getProperty(SLC_ARTIFACT_ID)
-                                       .getString());
-                       sb.append("</artifactId>\n");
-                       sb.append("\t<version>");
-                       sb.append(modularDistVersion.getProperty(SLC_ARTIFACT_VERSION)
-                                       .getString());
-                       sb.append("</version>\n");
-                       sb.append("\t<type>pom</type>\n");
-                       sb.append("\t<scope>import</scope>\n");
-                       sb.append("</dependency>");
-                       return sb.toString();
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "unexpected error while generating maven snippet");
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionEditor.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionEditor.java
deleted file mode 100644 (file)
index cdb15ea..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-
-/**
- * Manage a modular distribution version contained in a specific workspace of a
- * repository
- */
-public class ModularDistVersionEditor extends ArtifactVersionEditor {
-       private static final long serialVersionUID = -2223542780164288554L;
-
-       // private final static Log log =
-       // LogFactory.getLog(ModularDistVersionEditor.class);
-       public final static String ID = DistPlugin.PLUGIN_ID + ".modularDistVersionEditor";
-
-       @Override
-       public void init(IEditorSite site, IEditorInput input)
-                       throws PartInitException {
-               super.init(site, input);
-       }
-
-       @Override
-       protected void addPages() {
-               setPartName(getFormattedName());
-               try {
-                       addPage(new ModularDistVersionOverviewPage(this, "Modules ",
-                                       getArtifact()));
-                       addPage(new RunInOsgiPage(this, "Run as OSGi ", getArtifact()));
-                       addPage(new ModularDistVersionDetailPage(this, "Details",
-                                       getArtifact()));
-               } catch (PartInitException e) {
-                       throw new SlcException("Cannot add distribution editor pages", e);
-               }
-       }
-
-       protected String getFormattedName() {
-               try {
-                       String partName = null;
-                       if (getArtifact().hasProperty(SLC_NAME))
-                               partName = getArtifact().getProperty(SLC_NAME).getString();
-                       else
-                               partName = getArtifact().getName();
-
-                       if (partName.length() > 10) {
-                               partName = "..." + partName.substring(partName.length() - 10);
-                       }
-                       return partName;
-               } catch (RepositoryException re) {
-                       throw new SlcException("unable to get slc:name property for node "
-                                       + getArtifact(), re);
-               }
-       }
-
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionOverviewPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionOverviewPage.java
deleted file mode 100644 (file)
index d3ab885..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-import javax.jcr.query.qom.StaticOperand;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
-import org.argeo.slc.client.ui.dist.utils.HyperlinkAdapter;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.browser.IWebBrowser;
-import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Show all modules contained in a given modular distribution as filter-able
- * table
- */
-public class ModularDistVersionOverviewPage extends FormPage implements
-               SlcNames {
-
-       private final static Log log = LogFactory
-                       .getLog(ModularDistVersionOverviewPage.class);
-
-       final static String PAGE_ID = "ModularDistVersionOverviewPage";
-
-       // Business Objects
-       private Node modularDistribution;
-       // private Node modularDistributionBase;
-
-       // This page widgets
-       private DistNodeViewerComparator comparator;
-       private TableViewer viewer;
-       private FormToolkit tk;
-       private Text filterTxt;
-       private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
-
-       public ModularDistVersionOverviewPage(FormEditor formEditor, String title,
-                       Node modularDistribution) {
-               super(formEditor, PAGE_ID, title);
-               this.modularDistribution = modularDistribution;
-       }
-
-       @Override
-       protected void createFormContent(IManagedForm managedForm) {
-               // General settings for this page
-               ScrolledForm form = managedForm.getForm();
-               tk = managedForm.getToolkit();
-               Composite body = form.getBody();
-
-               GridLayout layout = new GridLayout(1, false);
-               layout.marginWidth = 5;
-               layout.marginRight = 15;
-               layout.verticalSpacing = 0;
-               body.setLayout(layout);
-               try {
-                       form.setText(modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
-                                       .getProperty(SlcNames.SLC_NAME).getString() : "");
-                       form.setMessage(
-                                       modularDistribution
-                                                       .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? modularDistribution
-                                                       .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
-                                                       .getString() : "", IMessageProvider.NONE);
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unable to get bundle name for node "
-                                       + modularDistribution, re);
-               }
-
-               // Main layout
-               Composite header = tk.createComposite(body);
-               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               populateHeaderPart(header);
-
-               Composite moduleTablePart = tk.createComposite(body);
-               moduleTablePart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
-                               true));
-               populateModuleTablePart(moduleTablePart);
-       }
-
-       private void populateHeaderPart(Composite parent) {
-               GridLayout layout = new GridLayout(6, false);
-               layout.horizontalSpacing = 10;
-               parent.setLayout(layout);
-               try {
-                       // 1st Line: Category, name version
-                       createLT(
-                                       parent,
-                                       "Category",
-                                       modularDistribution.hasProperty(SlcNames.SLC_CATEGORY) ? modularDistribution
-                                                       .getProperty(SlcNames.SLC_CATEGORY).getString()
-                                                       : "");
-                       createLT(
-                                       parent,
-                                       "Name",
-                                       modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
-                                                       .getProperty(SlcNames.SLC_NAME).getString() : "");
-                       createLT(
-                                       parent,
-                                       "Version",
-                                       modularDistribution.hasProperty(SlcNames.SLC_VERSION) ? modularDistribution
-                                                       .getProperty(SlcNames.SLC_VERSION).getString() : "");
-
-                       // 2nd Line: Vendor, licence, sources
-                       createLT(
-                                       parent,
-                                       "Vendor",
-                                       modularDistribution
-                                                       .hasProperty(DistConstants.SLC_BUNDLE_VENDOR) ? modularDistribution
-                                                       .getProperty(DistConstants.SLC_BUNDLE_VENDOR)
-                                                       .getString() : "N/A");
-
-                       createHyperlink(parent, "Licence", DistConstants.SLC_BUNDLE_LICENCE);
-                       addSourceSourcesLink(parent);
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unable to get bundle name for node "
-                                       + modularDistribution, re);
-               }
-
-       }
-
-       private Text createLT(Composite parent, String labelValue, String textValue) {
-               Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
-               // label.setFont(EclipseUiUtils.getBoldFont(parent));
-               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
-               // Add a trailing space to workaround a display glitch in RAP 1.3
-               Text text = new Text(parent, SWT.LEFT);
-               text.setText(textValue + " ");
-               text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-               text.setEditable(false);
-               return text;
-       }
-
-       private void createHyperlink(Composite parent, String label,
-                       String jcrPropName) throws RepositoryException {
-               tk.createLabel(parent, label, SWT.NONE);
-               if (modularDistribution.hasProperty(jcrPropName)) {
-                       final Hyperlink link = tk.createHyperlink(parent,
-                                       modularDistribution.getProperty(jcrPropName).getString(),
-                                       SWT.NONE);
-                       link.addHyperlinkListener(new HyperlinkAdapter() {
-                               @Override
-                               public void linkActivated(HyperlinkEvent e) {
-                                       try {
-                                               IWorkbenchBrowserSupport browserSupport = PlatformUI
-                                                               .getWorkbench().getBrowserSupport();
-                                               IWebBrowser browser = browserSupport
-                                                               .createBrowser(
-                                                                               IWorkbenchBrowserSupport.LOCATION_BAR
-                                                                                               | IWorkbenchBrowserSupport.NAVIGATION_BAR,
-                                                                               "SLC Distribution browser",
-                                                                               "SLC Distribution browser",
-                                                                               "A tool tip");
-                                               browser.openURL(new URL(link.getText()));
-                                       } catch (Exception ex) {
-                                               throw new SlcException("error opening browser", ex); //$NON-NLS-1$
-                                       }
-                               }
-                       });
-               } else
-                       tk.createLabel(parent, "N/A", SWT.NONE);
-       }
-
-       // helper to check if sources are available
-       private void addSourceSourcesLink(Composite parent) {
-               try {
-                       String srcPath = RepoUtils.relatedPdeSourcePath(
-                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH,
-                                       modularDistribution);
-                       if (!modularDistribution.getSession().nodeExists(srcPath)) {
-                               createLT(parent, "Sources", "N/A");
-                       } else {
-                               final Node sourcesNode = modularDistribution.getSession()
-                                               .getNode(srcPath);
-
-                               String srcName = null;
-                               if (sourcesNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME))
-                                       srcName = sourcesNode.getProperty(
-                                                       SlcNames.SLC_SYMBOLIC_NAME).getString();
-                               else
-                                       srcName = sourcesNode.getName();
-                               Label label = tk.createLabel(parent, "Sources", SWT.RIGHT);
-                               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
-                                               false));
-                               Hyperlink link = tk.createHyperlink(parent, srcName, SWT.NONE);
-                               link.addHyperlinkListener(new OpenFileLinkListener(sourcesNode
-                                               .getPath()));
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unable to configure sources link for "
-                                       + modularDistribution, e);
-               }
-       }
-
-       private class OpenFileLinkListener extends HyperlinkAdapter {
-               final private String path;
-
-               public OpenFileLinkListener(String path) {
-                       this.path = path;
-               }
-
-               @Override
-               public void linkActivated(HyperlinkEvent e) {
-                       log.warn("File download must be implemented. Cannot provide access to "
-                                       + path);
-
-                       // try {
-                       // ModuleEditorInput editorInput = (ModuleEditorInput)
-                       // getEditorInput();
-                       // Map<String, String> params = new HashMap<String, String>();
-                       // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
-                       // editorInput.getRepoNodePath());
-                       // params.put(OpenJcrFile.PARAM_REPO_URI, editorInput.getUri());
-                       // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
-                       // editorInput.getWorkspaceName());
-                       // params.put(OpenJcrFile.PARAM_FILE_PATH, path);
-                       //
-                       // String cmdId = (new OpenJcrFileCmdId()).getCmdId();
-                       // CommandUtils.callCommand(cmdId, params);
-                       // } catch (Exception ex) {
-                       //                              throw new SlcException("error opening browser", ex); //$NON-NLS-1$
-                       // }
-               }
-       }
-
-       private void populateModuleTablePart(Composite parent) {
-               GridLayout layout = new GridLayout(1, false);
-               layout.marginWidth = layout.horizontalSpacing = 0;
-               layout.verticalSpacing = 5;
-               layout.marginTop = 15;
-               parent.setLayout(layout);
-               // A sub title
-               Label label = tk.createLabel(parent,
-                               "Modules included in the current distribution", SWT.NONE);
-               label.setFont(EclipseUiUtils.getBoldFont(parent));
-
-               // Add the filter section
-               Composite filterPart = tk.createComposite(parent);
-               filterPart.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               createFilterPart(filterPart);
-
-               // Add the table
-               Composite tablePart = tk.createComposite(parent);
-               tablePart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               createTableViewer(tablePart);
-               // populate it on first pass.
-               refresh();
-       }
-
-       private void createFilterPart(Composite parent) {
-               GridLayout layout = new GridLayout(2, false);
-               layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
-               layout.horizontalSpacing = 5;
-               parent.setLayout(layout);
-
-               // Text Area to filter
-               filterTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
-                               | SWT.SEARCH | SWT.CANCEL);
-               filterTxt.setMessage(FILTER_HELP_MSG);
-               filterTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-               filterTxt.addModifyListener(new ModifyListener() {
-                       private static final long serialVersionUID = -276152321986407726L;
-
-                       public void modifyText(ModifyEvent event) {
-                               refresh();
-                       }
-               });
-
-               Button resetBtn = tk.createButton(parent, null, SWT.PUSH);
-               resetBtn.setImage(DistImages.IMG_CLEAR);
-               resetBtn.addSelectionListener(new SelectionAdapter() {
-                       private static final long serialVersionUID = -3549303742841670919L;
-
-                       public void widgetSelected(SelectionEvent e) {
-                               filterTxt.setText("");
-                               filterTxt.setMessage(FILTER_HELP_MSG);
-                       }
-               });
-       }
-
-       private void createTableViewer(Composite parent) {
-               parent.setLayout(new FillLayout());
-               // helpers to enable sorting by column
-               List<String> propertiesList = new ArrayList<String>();
-               List<Integer> propertyTypesList = new ArrayList<Integer>();
-
-               // Define the TableViewer
-               viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
-                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
-
-               // Name
-               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(220);
-               col.getColumn().setText("Category");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = 5875398301711336875L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SlcNames.SLC_CATEGORY);
-                       }
-               });
-               col.getColumn().addSelectionListener(getSelectionAdapter(0));
-               propertiesList.add(SlcNames.SLC_CATEGORY);
-               propertyTypesList.add(PropertyType.STRING);
-
-               // Symbolic name
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(220);
-               col.getColumn().setText("Name");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = 3880240676256465072L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_NAME);
-                       }
-               });
-               col.getColumn().addSelectionListener(getSelectionAdapter(1));
-               propertiesList.add(SLC_NAME);
-               propertyTypesList.add(PropertyType.STRING);
-
-               // Version
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(160);
-               col.getColumn().setText("Version");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = -4706438113850571784L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_VERSION);
-                       }
-               });
-               col.getColumn().addSelectionListener(getSelectionAdapter(2));
-               propertiesList.add(SLC_VERSION);
-               propertyTypesList.add(DistNodeViewerComparator.VERSION_TYPE);
-
-               // Exists in workspace
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(160);
-               col.getColumn().setText("Exists in workspace");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = 8190063212920414300L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return getRealizedModule((Node) element) != null ? "Yes" : "No";
-                               // return JcrUtils.get((Node) element, SLC_VERSION);
-                       }
-               });
-               // col.getColumn().addSelectionListener(getSelectionAdapter(2));
-               // propertiesList.add(SLC_VERSION);
-               // propertyTypesList.add(PropertyType.STRING);
-
-               final Table table = viewer.getTable();
-               table.setHeaderVisible(true);
-               table.setLinesVisible(true);
-
-               viewer.setContentProvider(new DistributionsContentProvider());
-               getSite().setSelectionProvider(viewer);
-
-               comparator = new DistNodeViewerComparator(2,
-                               DistNodeViewerComparator.ASCENDING, propertiesList,
-                               propertyTypesList);
-               viewer.setComparator(comparator);
-
-               // // Context Menu
-               // MenuManager menuManager = new MenuManager();
-               // Menu menu = menuManager.createContextMenu(viewer.getTable());
-               // menuManager.addMenuListener(new IMenuListener() {
-               // public void menuAboutToShow(IMenuManager manager) {
-               // contextMenuAboutToShow(manager);
-               // }
-               // });
-               // viewer.getTable().setMenu(menu);
-               // getSite().registerContextMenu(menuManager, viewer);
-
-               // Double click
-               viewer.addDoubleClickListener(new DoubleClickListener());
-       }
-
-       private Node getRealizedModule(Node moduleCoordinates) {
-               try {
-                       String category = JcrUtils.get(moduleCoordinates, SLC_CATEGORY);
-                       String name = JcrUtils.get(moduleCoordinates, SLC_NAME);
-                       String version = JcrUtils.get(moduleCoordinates, SLC_VERSION);
-                       Artifact artifact = new DefaultArtifact(category + ":" + name + ":"
-                                       + version);
-                       String parentPath = MavenConventionsUtils.artifactParentPath(
-                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, artifact);
-
-                       Session session = modularDistribution.getSession();
-                       if (session.nodeExists(parentPath)) {
-                               Node parent = session.getNode(parentPath);
-                               NodeIterator nit = parent.getNodes();
-                               while (nit.hasNext()) {
-                                       Node currN = nit.nextNode();
-                                       if (currN.isNodeType(SlcTypes.SLC_ARTIFACT))
-                                               return currN;
-                               }
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "unable to retrieve realized module with coordinates "
-                                                       + moduleCoordinates, re);
-               }
-               return null;
-       }
-
-       private void refresh() {
-               final List<Node> result = JcrUtils
-                               .nodeIteratorToList(listBundleArtifacts());
-               viewer.setInput(result);
-       }
-
-       /** Build repository request */
-       private NodeIterator listBundleArtifacts() {
-               try {
-                       Session session = modularDistribution.getSession();
-                       QueryManager queryManager = session.getWorkspace()
-                                       .getQueryManager();
-                       QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
-                       Selector source = factory.selector(SlcTypes.SLC_MODULE_COORDINATES,
-                                       SlcTypes.SLC_MODULE_COORDINATES);
-
-                       // Create a dynamic operand for each property on which we want to
-                       // filter
-                       DynamicOperand catDO = factory.propertyValue(
-                                       source.getSelectorName(), SlcNames.SLC_CATEGORY);
-                       DynamicOperand nameDO = factory.propertyValue(
-                                       source.getSelectorName(), SlcNames.SLC_NAME);
-                       DynamicOperand versionDO = factory.propertyValue(
-                                       source.getSelectorName(), SlcNames.SLC_VERSION);
-
-                       String path = modularDistribution.getPath() + "/"
-                                       + SlcNames.SLC_MODULES;
-
-                       // Default Constraint: correct children
-                       Constraint defaultC = factory.descendantNode(
-                                       source.getSelectorName(), path);
-
-                       String filter = filterTxt.getText();
-
-                       // Build constraints based the textArea content
-                       if (filter != null && !"".equals(filter.trim())) {
-                               // Parse the String
-                               String[] strs = filter.trim().split(" ");
-                               for (String token : strs) {
-                                       token = token.replace('*', '%');
-                                       StaticOperand so = factory.literal(session
-                                                       .getValueFactory().createValue("%" + token + "%"));
-
-                                       Constraint currC = factory.comparison(catDO,
-                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
-                                       currC = factory.or(currC, factory.comparison(versionDO,
-                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
-                                       currC = factory.or(currC, factory.comparison(nameDO,
-                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
-
-                                       defaultC = factory.and(defaultC, currC);
-                               }
-                       }
-
-                       QueryObjectModel query = factory.createQuery(source, defaultC,
-                                       null, null);
-                       QueryResult result = query.execute();
-                       return result.getNodes();
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unable to refresh module list for node "
-                                       + modularDistribution, re);
-               }
-       }
-
-       @Override
-       public void setFocus() {
-               viewer.getTable().setFocus();
-       }
-
-       // /** Programmatically configure the context menu */
-       // protected void contextMenuAboutToShow(IMenuManager menuManager) {
-       // IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
-       // .getActiveWorkbenchWindow();
-       // // Build conditions
-       // // Delete selected artifacts
-       // // CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
-       // // DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
-       // // true);
-       // }
-
-       private SelectionAdapter getSelectionAdapter(final int index) {
-               SelectionAdapter selectionAdapter = new SelectionAdapter() {
-                       private static final long serialVersionUID = 1260801795934660840L;
-
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               Table table = viewer.getTable();
-                               comparator.setColumn(index);
-                               int dir = table.getSortDirection();
-                               if (table.getSortColumn() == table.getColumn(index)) {
-                                       dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
-                               } else {
-                                       dir = SWT.DOWN;
-                               }
-                               table.setSortDirection(dir);
-                               table.setSortColumn(table.getColumn(index));
-                               viewer.refresh();
-                       }
-               };
-               return selectionAdapter;
-       }
-
-       /* LOCAL CLASSES */
-       private class DistributionsContentProvider implements
-                       IStructuredContentProvider {
-               private static final long serialVersionUID = 8385338190908823791L;
-               // we keep a cache of the Nodes in the content provider to be able to
-               // manage long request
-               private List<Node> nodes;
-
-               public void dispose() {
-               }
-
-               // We expect a list of nodes as a new input
-               @SuppressWarnings("unchecked")
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-                       nodes = (List<Node>) newInput;
-               }
-
-               public Object[] getElements(Object arg0) {
-                       return nodes.toArray();
-               }
-       }
-
-       private class DoubleClickListener implements IDoubleClickListener {
-
-               public void doubleClick(DoubleClickEvent event) {
-                       Object obj = ((IStructuredSelection) event.getSelection())
-                                       .getFirstElement();
-                       if (obj instanceof Node) {
-                               Node node = (Node) obj;
-                               try {
-                                       if (node.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
-                                               Node realizedModule = getRealizedModule(node);
-                                               if (realizedModule != null) {
-                                                       ModuleEditorInput dwip = (ModuleEditorInput) getEditorInput();
-                                                       Map<String, String> params = new HashMap<String, String>();
-                                                       params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
-                                                                       dwip.getRepoNodePath());
-                                                       params.put(OpenModuleEditor.PARAM_REPO_URI,
-                                                                       dwip.getUri());
-                                                       params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
-                                                                       dwip.getWorkspaceName());
-                                                       String path = realizedModule.getPath();
-                                                       params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
-                                                       CommandUtils.callCommand(OpenModuleEditor.ID,
-                                                                       params);
-                                               }
-                                       }
-                               } catch (RepositoryException re) {
-                                       throw new SlcException("Cannot get path for node " + node
-                                                       + " while setting parameters for "
-                                                       + "command OpenModuleEditor", re);
-                               }
-                       }
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java
deleted file mode 100644 (file)
index 52d7a20..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/** Editor input for a JCR node object in a multi-repository environment */
-public class ModuleEditorInput implements IEditorInput, SlcNames {
-
-       // Define relevant workspace on a given repository
-       private String repoNodePath;
-       private String uri;
-       private String workspaceName;
-       private String modulePath;
-
-       public ModuleEditorInput(String repoNodePath, String uri,
-                       String workspaceName, String artifactPath) {
-               if (workspaceName == null)
-                       throw new SlcException("Workspace name cannot be null");
-               if (uri == null && repoNodePath == null)
-                       throw new SlcException("Define at least one of the 2 "
-                                       + "parameters URI or Repo Node Path");
-               if (artifactPath == null)
-                       throw new SlcException("Module path cannot be null");
-               this.repoNodePath = repoNodePath;
-               this.uri = uri;
-               this.workspaceName = workspaceName;
-               this.modulePath = artifactPath;
-       }
-
-       public String getModulePath() {
-               return modulePath;
-       }
-
-       public String getWorkspaceName() {
-               return workspaceName;
-       }
-
-       public String getRepoNodePath() {
-               return repoNodePath;
-       }
-
-       public String getUri() {
-               return uri;
-       }
-
-       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-               return null;
-       }
-
-       public boolean exists() {
-               return true;
-       }
-
-       public ImageDescriptor getImageDescriptor() {
-               return null;
-       }
-
-       // Dummy compulsory methods
-       public String getToolTipText() {
-               return getModulePath();
-       }
-
-       public String getName() {
-               return JcrUtils.lastPathElement(modulePath);
-       }
-
-       public IPersistableElement getPersistable() {
-               return null;
-       }
-
-       /**
-        * equals method based on coordinates
-        */
-       public boolean equals(Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (getClass() != obj.getClass())
-                       return false;
-
-               ModuleEditorInput other = (ModuleEditorInput) obj;
-
-               if (!modulePath.equals(other.getModulePath()))
-                       return false;
-               if (!workspaceName.equals(other.getWorkspaceName()))
-                       return false;
-
-               if (uri == null && other.getUri() != null
-                               || !uri.equals(other.getUri()))
-                       return false;
-
-               if (repoNodePath == null && other.getRepoNodePath() != null
-                               || !repoNodePath.equals(other.getRepoNodePath()))
-                       return false;
-
-               return true;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/RunInOsgiPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/RunInOsgiPage.java
deleted file mode 100644 (file)
index 5e11e77..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Enable launch of the current distribution in a separate osgi run time.
- * Display also a console to interract with the launched runtime
- */
-public class RunInOsgiPage extends FormPage implements SlcNames {
-
-       final static String PAGE_ID = "RunInOsgiPage";
-
-       // Business Objects
-       private Node modularDistribution;
-
-       // This page widgets
-       private Button launchBtn;
-       private Text consoleTxt;
-
-       private FormToolkit tk;
-
-       public RunInOsgiPage(FormEditor formEditor, String title,
-                       Node modularDistribution) {
-               super(formEditor, PAGE_ID, title);
-               this.modularDistribution = modularDistribution;
-       }
-
-       @Override
-       protected void createFormContent(IManagedForm managedForm) {
-               ScrolledForm form = managedForm.getForm();
-               tk = managedForm.getToolkit();
-               // Main Layout
-               Composite body = form.getBody();
-               GridLayout layout = new GridLayout();
-               layout.marginTop = layout.marginWidth = 0;
-               body.setLayout(layout);
-
-               // The header
-               Composite header = tk.createComposite(body);
-               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               createHeaderPart(header);
-
-               // The console
-               Composite console = tk.createComposite(body);
-               console.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               createConsolePart(console);
-               body.layout();
-       }
-
-       private void createHeaderPart(Composite parent) {
-               GridLayout layout = new GridLayout();
-               parent.setLayout(layout);
-
-               // Text Area to filter
-               launchBtn = tk.createButton(parent, " Launch ", SWT.PUSH);
-               launchBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
-
-               launchBtn.addSelectionListener(new SelectionAdapter() {
-                       private static final long serialVersionUID = -1633658484882130602L;
-
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               super.widgetSelected(e);
-                               throw new SlcException("Implement this");
-                       }
-               });
-       }
-
-       private void createConsolePart(Composite parent) {
-               parent.setLayout(new GridLayout());
-               consoleTxt = tk.createText(parent, "OSGi > ", SWT.MULTI | SWT.WRAP
-                               | SWT.BORDER);
-               consoleTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-       }
-
-       @Override
-       public void setFocus() {
-               launchBtn.setFocus();
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/WkspCategoryBaseListPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/WkspCategoryBaseListPage.java
deleted file mode 100644 (file)
index a482e9d..0000000
+++ /dev/null
@@ -1,492 +0,0 @@
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.observation.Event;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-import javax.jcr.query.qom.StaticOperand;
-
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Show all category base (currently only Aether group base) contained in a
- * given workspace as filter-able table. Enable to definition of which of them
- * should be managed as modular distribution
- */
-public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
-
-       final static String PAGE_ID = "WkspCategoryBaseListPage";
-
-       // Business Objects
-       private Session session;
-
-       // This page widgets
-       private DistNodeViewerComparator comparator;
-       private TableViewer viewer;
-       private FormToolkit tk;
-       private Text filterTxt;
-       private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
-
-       // Observes changes
-       // private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE
-       // };
-       // private CategoryObserver categoriesObserver;
-
-       public WkspCategoryBaseListPage(FormEditor formEditor, String title,
-                       Session session) {
-               super(formEditor, PAGE_ID, title);
-               this.session = session;
-       }
-
-       @Override
-       protected void createFormContent(IManagedForm managedForm) {
-               ScrolledForm form = managedForm.getForm();
-               tk = managedForm.getToolkit();
-
-               form.setText("Define Relevant Categories");
-               form.setMessage("Choose in the below list "
-                               + "the categories that can be used as base for "
-                               + "modular distributions maintained via the current workspace",
-                               IMessageProvider.NONE);
-
-               // Main Layout
-               GridLayout layout = new GridLayout(1, false);
-               Composite body = form.getBody();
-               body.setLayout(layout);
-
-               // filter section
-               Composite header = tk.createComposite(body);
-               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               createFilterPart(header);
-
-               // the table
-               Composite tableCmp = tk.createComposite(body);
-               tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               createTableViewer(tableCmp);
-
-               // categoriesObserver = new CategoryObserver(viewer.getTable()
-               // .getDisplay());
-               // try {
-               // ObservationManager observationManager = session.getWorkspace()
-               // .getObservationManager();
-               // // FIXME Will not be notified if empty result is deleted
-               // observationManager.addEventListener(categoriesObserver,
-               // Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
-               // false);
-               // } catch (RepositoryException e) {
-               // throw new SlcException("Cannot register listeners", e);
-               // }
-
-               refresh();
-       }
-
-       private void refresh() {
-               final List<Node> result = JcrUtils.nodeIteratorToList(listGroupBase());
-               viewer.setInput(result);
-       }
-
-       /** Build repository request */
-       private NodeIterator listGroupBase() {
-               try {
-                       QueryManager queryManager = session.getWorkspace()
-                                       .getQueryManager();
-                       QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
-                       Selector source = factory.selector(SlcTypes.SLC_GROUP_BASE,
-                                       SlcTypes.SLC_MODULE_COORDINATES);
-
-                       // Create a dynamic operand for each property on which we want to
-                       // filter
-                       DynamicOperand catDO = factory.propertyValue(
-                                       source.getSelectorName(), SlcNames.SLC_CATEGORY);
-                       DynamicOperand nameDO = factory.propertyValue(
-                                       source.getSelectorName(), SlcNames.SLC_NAME);
-
-                       String filter = filterTxt.getText();
-
-                       Constraint defaultC = null;
-                       // Build constraints based the textArea content
-                       if (filter != null && !"".equals(filter.trim())) {
-                               // Parse the String
-                               String[] strs = filter.trim().split(" ");
-                               for (String token : strs) {
-                                       token = token.replace('*', '%');
-                                       StaticOperand so = factory.literal(session
-                                                       .getValueFactory().createValue("%" + token + "%"));
-
-                                       Constraint currC = factory.comparison(catDO,
-                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
-                                       currC = factory.or(currC, factory.comparison(nameDO,
-                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
-
-                                       if (defaultC == null)
-                                               defaultC = currC;
-                                       else
-                                               defaultC = factory.and(defaultC, currC);
-                               }
-                       }
-
-                       QueryObjectModel query = factory.createQuery(source, defaultC,
-                                       null, null);
-                       QueryResult result = query.execute();
-                       return result.getNodes();
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unable to refresh group list for workspace "
-                                                       + getEditorInput().getName(), re);
-               }
-       }
-
-       private void createFilterPart(Composite parent) {
-               GridLayout layout = new GridLayout(2, false);
-               layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
-               layout.horizontalSpacing = 5;
-               parent.setLayout(layout);
-
-               // Text Area to filter
-               filterTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
-                               | SWT.SEARCH | SWT.CANCEL);
-               filterTxt.setMessage(FILTER_HELP_MSG);
-               filterTxt.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-               filterTxt.addModifyListener(new ModifyListener() {
-                       private static final long serialVersionUID = 8727389523069041623L;
-
-                       public void modifyText(ModifyEvent event) {
-                               refresh();
-                       }
-               });
-
-               Button resetBtn = tk.createButton(parent, null, SWT.PUSH);
-               resetBtn.setImage(DistImages.IMG_REPO_READONLY);
-               resetBtn.addSelectionListener(new SelectionAdapter() {
-                       private static final long serialVersionUID = -6523538838444581321L;
-
-                       public void widgetSelected(SelectionEvent e) {
-                               resetFilter();
-                       }
-               });
-       }
-
-       private void resetFilter() {
-               filterTxt.setText("");
-               filterTxt.setMessage(FILTER_HELP_MSG);
-       }
-
-       private void createTableViewer(Composite parent) {
-               parent.setLayout(new FillLayout());
-               // helpers to enable sorting by column
-               List<String> propertiesList = new ArrayList<String>();
-               List<Integer> propertyTypesList = new ArrayList<Integer>();
-
-               // Define the TableViewer
-               viewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
-                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
-
-               TableViewerColumn col;
-               // Name
-               // TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
-               // col.getColumn().setWidth(220);
-               // col.getColumn().setText("Category");
-               // col.setLabelProvider(new ColumnLabelProvider() {
-               // @Override
-               // public String getText(Object element) {
-               // return JcrUtils.get((Node) element, SlcNames.SLC_CATEGORY);
-               // }
-               // });
-               // col.getColumn().addSelectionListener(getSelectionAdapter(0));
-               // propertiesList.add(SlcNames.SLC_CATEGORY);
-               // propertyTypesList.add(PropertyType.STRING);
-
-               // Group base name
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(220);
-               col.getColumn().setText("Group Name");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = 6186787928630825293L;
-
-                       @Override
-                       public String getText(Object element) {
-                               return JcrUtils.get((Node) element, SLC_GROUP_BASE_ID);
-                       }
-               });
-               col.getColumn().addSelectionListener(getSelectionAdapter(0));
-               propertiesList.add(SLC_GROUP_BASE_ID);
-               propertyTypesList.add(PropertyType.STRING);
-
-               // Version
-               col = new TableViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(80);
-               col.getColumn().setText("Has binaries");
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       private static final long serialVersionUID = -2017377132642062464L;
-
-                       @Override
-                       public String getText(Object element) {
-                               try {
-                                       Node currNode = (Node) element;
-
-                                       return currNode.hasNode(RepoConstants.BINARIES_ARTIFACT_ID) ? "Yes"
-                                                       : "No";
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("unable to check type of node "
-                                                       + element, e);
-                               }
-                       }
-               });
-               // col.getColumn().addSelectionListener(getSelectionAdapter(2));
-               // propertiesList.add(SLC_VERSION);
-               // propertyTypesList.add(PropertyType.STRING);
-
-               final Table table = viewer.getTable();
-               table.setHeaderVisible(true);
-               table.setLinesVisible(true);
-
-               viewer.setContentProvider(new DistributionsContentProvider());
-               getSite().setSelectionProvider(viewer);
-
-               comparator = new DistNodeViewerComparator(0,
-                               DistNodeViewerComparator.ASCENDING, propertiesList,
-                               propertyTypesList);
-               viewer.setComparator(comparator);
-
-               // Context Menu
-               MenuManager menuManager = new MenuManager();
-               Menu menu = menuManager.createContextMenu(viewer.getTable());
-               menuManager.addMenuListener(new IMenuListener() {
-                       private static final long serialVersionUID = 739004528695501335L;
-
-                       public void menuAboutToShow(IMenuManager manager) {
-                               contextMenuAboutToShow(manager);
-                       }
-               });
-               viewer.getTable().setMenu(menu);
-               getSite().registerContextMenu(menuManager, viewer);
-
-               // Double click
-               viewer.addDoubleClickListener(new DoubleClickListener());
-       }
-
-       @Override
-       public void setFocus() {
-               viewer.getTable().setFocus();
-       }
-
-       /** Programmatically configure the context menu */
-       protected void contextMenuAboutToShow(IMenuManager menuManager) {
-               IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
-                               .getActiveWorkbenchWindow();
-               // Build conditions
-               // Mark as category base
-               Object firstElement = ((IStructuredSelection) viewer.getSelection())
-                               .getFirstElement();
-               Node currSelected = (Node) firstElement;
-
-               DistWkspEditorInput input = (DistWkspEditorInput) getEditorInput();
-
-               Map<String, String> params = new HashMap<String, String>();
-               params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
-                               input.getRepoNodePath());
-               try {
-                       params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
-                                       currSelected.getPath());
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unable to get path for " + currSelected, e);
-               }
-               params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
-                               input.getWorkspaceName());
-
-               CommandUtils.refreshParameterizedCommand(menuManager, window,
-                               OpenGenerateBinariesWizard.ID,
-                               OpenGenerateBinariesWizard.DEFAULT_LABEL,
-                               OpenGenerateBinariesWizard.DEFAULT_ICON, true, params);
-
-               // boolean isRelevant = false;
-               // try {
-               // isRelevant = currSelected.isNodeType(SlcTypes.SLC_CATEGORY);
-               // boolean canEdit = currSelected.canAddMixin(SlcTypes.SLC_CATEGORY);
-               //
-               // } catch (RepositoryException e) {
-               // throw new SlcException("unable to check type of node "
-               // + firstElement, e);
-               // }
-               // // Add
-               // if (isRelevant) {// Remove
-               // CommandUtils.refreshCommand(menuManager, window,
-               // MarkAsRelevantCategory.ID,
-               // MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
-               // MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
-               // } else {
-               // CommandUtils.refreshCommand(menuManager, window,
-               // MarkAsRelevantCategory.ID,
-               // MarkAsRelevantCategory.DEFAULT_LABEL,
-               // MarkAsRelevantCategory.DEFAULT_ICON, true);
-               // }
-       }
-
-       private SelectionAdapter getSelectionAdapter(final int index) {
-               SelectionAdapter selectionAdapter = new SelectionAdapter() {
-                       private static final long serialVersionUID = -1723894288128081757L;
-
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               Table table = viewer.getTable();
-                               comparator.setColumn(index);
-                               int dir = table.getSortDirection();
-                               if (table.getSortColumn() == table.getColumn(index)) {
-                                       dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
-                               } else {
-                                       dir = SWT.DOWN;
-                               }
-                               table.setSortDirection(dir);
-                               table.setSortColumn(table.getColumn(index));
-                               viewer.refresh();
-                       }
-               };
-               return selectionAdapter;
-       }
-
-       /* LOCAL CLASSES */
-       private class DistributionsContentProvider implements
-                       IStructuredContentProvider {
-               private static final long serialVersionUID = -5939763615620837492L;
-
-               // we keep a cache of the Nodes in the content provider to be able to
-               // manage long request
-               private List<Node> nodes;
-
-               public void dispose() {
-               }
-
-               // We expect a list of nodes as a new input
-               @SuppressWarnings("unchecked")
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-                       nodes = (List<Node>) newInput;
-               }
-
-               public Object[] getElements(Object arg0) {
-                       return nodes.toArray();
-               }
-       }
-
-       private class DoubleClickListener implements IDoubleClickListener {
-
-               public void doubleClick(DoubleClickEvent event) {
-                       Object obj = ((IStructuredSelection) event.getSelection())
-                                       .getFirstElement();
-                       if (obj instanceof Node) {
-                               Node node = (Node) obj;
-                               try {
-                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
-                                               DistWkspEditorInput dwip = (DistWkspEditorInput) getEditorInput();
-                                               Map<String, String> params = new HashMap<String, String>();
-                                               params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
-                                                               dwip.getRepoNodePath());
-                                               params.put(OpenModuleEditor.PARAM_REPO_URI,
-                                                               dwip.getUri());
-                                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
-                                                               dwip.getWorkspaceName());
-                                               String path = node.getPath();
-                                               params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
-                                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
-                                       }
-                               } catch (RepositoryException re) {
-                                       throw new SlcException("Cannot get path for node " + node
-                                                       + " while setting parameters for "
-                                                       + "command OpenModuleEditor", re);
-                               }
-
-                       }
-               }
-       }
-
-       class CategoryObserver extends AsyncUiEventListener {
-
-               public CategoryObserver(Display display) {
-                       super(display);
-               }
-
-               @Override
-               protected Boolean willProcessInUiThread(List<Event> events)
-                               throws RepositoryException {
-                       for (Event event : events) {
-                               String path = event.getPath();
-                               if (JcrUtils.lastPathElement(path).equals(
-                                               DistConstants.JCR_MIXIN_TYPES))
-                                       return true;
-                       }
-                       return false;
-               }
-
-               protected void onEventInUiThread(List<Event> events)
-                               throws RepositoryException {
-                       if (getLog().isTraceEnabled())
-                               getLog().trace("Refresh table");
-                       viewer.refresh();
-               }
-       }
-
-       @Override
-       public void setActive(boolean active) {
-               super.setActive(active);
-               if (active) {
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/DistParentElem.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/DistParentElem.java
deleted file mode 100644 (file)
index fe960b4..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.argeo.slc.client.ui.dist.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.argeo.eclipse.ui.TreeParent;
-
-/** Common super class for all tree elements of the Distributions View */
-public abstract class DistParentElem extends TreeParent {
-       protected final static Character VERSION_SEP = '-';
-
-       protected static final List<String> ARGEO_SYSTEM_WKSP;
-       static {
-               List<String> tmpList = new ArrayList<String>();
-               tmpList.add("main");
-               tmpList.add("proxy");
-               tmpList.add("security");
-               tmpList.add("localrepo");
-               ARGEO_SYSTEM_WKSP = Collections.unmodifiableList(tmpList);
-       }
-
-       private boolean inHome = false;
-       private boolean isReadOnly = false;
-
-       public DistParentElem(String name, boolean inHome, boolean isReadOnly) {
-               super(name);
-               this.inHome = inHome;
-               this.isReadOnly = isReadOnly;
-       }
-
-       public DistParentElem(String name) {
-               super(name);
-       }
-
-       // public abstract String getLabel();
-       //
-       // public abstract Object[] getChildren();
-       //
-       // public boolean hasChildren() {
-       // return true;
-       // }
-       //
-       // public void dispose() {
-       // }
-
-       public void setInHome(boolean inHome) {
-               this.inHome = inHome;
-       }
-
-       public void setReadOnly(boolean isReadOnly) {
-               this.isReadOnly = isReadOnly;
-       }
-
-       public boolean inHome() {
-               return inHome;
-       }
-
-       public boolean isReadOnly() {
-               return isReadOnly;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java
deleted file mode 100644 (file)
index 2b9a8fe..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.argeo.slc.client.ui.dist.model;
-
-/**
- * Abstract a node of type slc:groupBase that gathers a set of artifacts that
- * have the same group ID
- */
-public class GroupBaseElem extends DistParentElem {
-       // private WorkspaceElem wkspElem;
-       private String groupId;
-
-       public GroupBaseElem(WorkspaceElem wkspElem, String groupId) {
-               super(groupId, wkspElem.inHome(), wkspElem.isReadOnly());
-
-               setParent(wkspElem);
-               // this.wkspElem = wkspElem;
-               this.groupId = groupId;
-       }
-
-       public Object[] getChildren() {
-               return null;
-       }
-
-       public String getLabel() {
-               return groupId;
-       }
-
-       // public String toString() {
-       // return getLabel();
-       // }
-
-       // public void dispose() {
-       // }
-
-       public WorkspaceElem getWorkspaceElem() {
-               return (WorkspaceElem) getParent();
-       }
-
-       public String getGroupId() {
-               return getName();
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionBaseElem.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionBaseElem.java
deleted file mode 100644 (file)
index 4ee0b59..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/**
- * Abstract the base of a given modular distribution set i.e. the parent of all
- * versions of a given modular distribution
- */
-public class ModularDistVersionBaseElem extends DistParentElem {
-
-       // final static public String AETHER_CATEGORY_BASE = "categoryBase";
-       final static public String AETHER_BINARIES_TYPE = "binaries";
-       final static public String AETHER_DEP_TYPE = "dep";
-       private String type;
-       private Node modularDistVersionBase;
-
-       public ModularDistVersionBaseElem(WorkspaceElem wkspElem, String name,
-                       Node modularDistVersionBase, String type) {
-               super(name, wkspElem.inHome(), wkspElem.isReadOnly());
-               setParent(wkspElem);
-               this.modularDistVersionBase = modularDistVersionBase;
-               this.type = type;
-       }
-
-       public Node getModularDistBase() {
-               // // TODO clean this
-               // if (type.equals(AETHER_CATEGORY_BASE))
-               // return modularDistVersionBase;
-               // else
-               try {
-                       return modularDistVersionBase.getParent();
-               } catch (RepositoryException e) {
-                       throw new SlcException("unable to get parent node for "
-                                       + modularDistVersionBase, e);
-               }
-       }
-
-       public WorkspaceElem getWkspElem() {
-               return (WorkspaceElem) getParent();
-       }
-
-       /**
-        * Override normal behaviour to initialise children only when first
-        * requested
-        */
-       @Override
-       public synchronized boolean hasChildren() {
-               if (isLoaded()) {
-                       return super.hasChildren();
-               } else {
-                       return true;
-               }
-       };
-
-       /**
-        * Override normal behaviour to initialise children only when first
-        * requested
-        */
-       @Override
-       public synchronized Object[] getChildren() {
-               if (isLoaded()) {
-                       return super.getChildren();
-               } else {
-                       try {
-                               NodeIterator ni = getDistVersions();
-                               while (ni != null && ni.hasNext()) {
-                                       Node curNode = ni.nextNode();
-                                       if (curNode.hasProperty(SlcNames.SLC_ARTIFACT_VERSION))
-                                               addChild(new ModularDistVersionElem(this, curNode
-                                                               .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
-                                                               .getString(), curNode));
-                               }
-                               return super.getChildren();
-                       } catch (RepositoryException re) {
-                               throw new SlcException("Unable to retrieve children for "
-                                               + modularDistVersionBase, re);
-                       }
-               }
-       }
-
-       private NodeIterator getDistVersions() {
-               try {
-                       // if (AETHER_CATEGORY_BASE.equals(type))
-                       // return null;
-
-                       QueryManager queryManager = modularDistVersionBase.getSession()
-                                       .getWorkspace().getQueryManager();
-                       QueryObjectModelFactory factory = queryManager.getQOMFactory();
-                       Selector source = factory.selector(
-                                       SlcTypes.SLC_MODULAR_DISTRIBUTION,
-                                       SlcTypes.SLC_MODULAR_DISTRIBUTION);
-                       Constraint constraint = factory.descendantNode(
-                                       source.getSelectorName(), modularDistVersionBase.getPath());
-                       // Ordering order = factory.descending(factory.propertyValue(
-                       // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
-                       // Ordering[] orderings = { order };
-                       QueryObjectModel query = factory.createQuery(source, constraint,
-                                       null, null);
-                       QueryResult queryResult = query.execute();
-                       return queryResult.getNodes();
-               } catch (RepositoryException e) {
-                       throw new SlcException(
-                                       "Unable to version for modular distribution: " + getName(),
-                                       e);
-               }
-       }
-
-       public String getType() {
-               return type;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionElem.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionElem.java
deleted file mode 100644 (file)
index 23c7578..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.Node;
-
-/**
- * Abstract a node of type slc:modularDistribution that has a child node that
- * lists the modules contained in the current distribution
- */
-public class ModularDistVersionElem extends DistParentElem {
-       private final Node modularDistVersionNode;
-
-       public ModularDistVersionElem(ModularDistVersionBaseElem modularDistGroupElem,
-                       String version, Node modularDistVersionNode) {
-               super(version, modularDistGroupElem.inHome(), modularDistGroupElem
-                               .isReadOnly());
-               setParent(modularDistGroupElem);
-               this.modularDistVersionNode = modularDistVersionNode;
-       }
-
-       public Object[] getChildren() {
-               return null;
-       }
-
-       public String getLabel() {
-               return getName();
-       }
-
-       public WorkspaceElem getWorkspaceElem() {
-               return (WorkspaceElem) getParent().getParent();
-       }
-
-       public Node getModularDistVersionNode() {
-               return modularDistVersionNode;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/RepoElem.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/RepoElem.java
deleted file mode 100644 (file)
index 8ae8e8b..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-package org.argeo.slc.client.ui.dist.model;
-
-import java.security.AccessControlException;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-
-/**
- * Abstract a repository. It might be persisted by a node in the current user
- * home Node or just an URI and a label if user is anonymous
- */
-public class RepoElem extends DistParentElem {
-       // private final static Log log = LogFactory.getLog(RepoElem.class);
-
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       private Credentials credentials;
-       private Session defaultSession = null;
-
-       // Defines current repo
-       private Node repoNode = null;
-       private String label;
-       private String uri;
-
-       private Repository repository;
-
-       /**
-        * Creates a RepoElement for anonymous user. The {@code RepositoryFactory}
-        * is used to enable lazy initialisation
-        */
-       public RepoElem(RepositoryFactory repoFactory, String uri, String label) {
-               super(label);
-               this.repositoryFactory = repoFactory;
-               this.uri = uri;
-               this.label = label;
-       }
-
-       /**
-        * Creates a RepoElement for an authenticated user. The
-        * {@code RepositoryFactory} and {@code Keyring} are used to enable lazy
-        * initialisation
-        * 
-        */
-       public RepoElem(RepositoryFactory repoFactory, Keyring keyring, Node repoNode, String alias) {
-               super(alias);
-               this.label = alias;
-               // label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
-               // .getProperty(Property.JCR_TITLE).getString() : repoNode
-               // .getName();
-               this.repoNode = repoNode;
-               this.repositoryFactory = repoFactory;
-               this.keyring = keyring;
-               try {
-                       // Initialize this repo information
-                       setInHome(RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS.equals(repoNode.getName()));
-                       if (inHome())
-                               // Directly log and retrieve children for local repository
-                               login();
-                       else
-                               setReadOnly(!repoNode.hasNode(ArgeoNames.ARGEO_PASSWORD));
-                       uri = JcrUtils.get(repoNode, ArgeoNames.ARGEO_URI);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unable to " + "initialize repo element", e);
-               }
-       }
-
-       /** Effective login. Does nothing if the session is already there. */
-       public void login() {
-               if (isConnected())
-                       return;
-
-               if (repository == null)
-                       if (repoNode == null)
-                               // Anonymous
-                               repository = NodeUtils.getRepositoryByUri(repositoryFactory, uri);
-                       else {
-                               repository = RepoUtils.getRepository(repositoryFactory, keyring, repoNode);
-                               credentials = RepoUtils.getRepositoryCredentials(keyring, repoNode);
-                       }
-
-               try {
-                       // FIXME make it more generic
-                       String defaultWorkspace = NodeConstants.SYS_WORKSPACE;
-                       defaultSession = repository.login(credentials, defaultWorkspace);
-                       refreshChildren();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot login repository " + label + " with credential " + credentials, e);
-               }
-       }
-
-       protected void refreshChildren() {
-               try {
-                       // TODO also remove deleted children (only adds for the time being
-                       String[] workspaceNames = defaultSession.getWorkspace().getAccessibleWorkspaceNames();
-                       buildWksp: for (String workspaceName : workspaceNames) {
-                               if (!isWorkspaceVisible(workspaceName))
-                                       continue buildWksp;
-
-                               String prefix = getPrefix(workspaceName);
-                               if (getChildByName(prefix) == null) {
-                                       WkspGroupElem wkspGpElem = new WkspGroupElem(RepoElem.this, prefix);
-                                       addChild(wkspGpElem);
-                               }
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot list workspaces for " + repoNode, e);
-               }
-       }
-
-       @Override
-       public synchronized void dispose() {
-               JcrUtils.logoutQuietly(defaultSession);
-               super.dispose();
-       }
-
-       private String getPrefix(String workspaceName) {
-               // Here is the tricks - we rely on a "hard coded" convention
-               // Workspace name should be like: name-major.minor
-               if (workspaceName.lastIndexOf(VERSION_SEP) > 0)
-                       return workspaceName.substring(0, workspaceName.lastIndexOf(VERSION_SEP));
-               else
-                       return workspaceName;
-       }
-
-       /* Exposes this to the children workspace group */
-       protected boolean isWorkspaceVisible(String wkspName) {
-               Boolean result = true;
-               if (ARGEO_SYSTEM_WKSP.contains(wkspName))
-                       return false;
-               // Add a supplementary check to hide workspace that are not
-               // public to anonymous user
-               if (repoNode == null) {
-                       Session tmpSession = null;
-                       try {
-                               tmpSession = repository.login(wkspName);
-                               try {
-                                       tmpSession.checkPermission("/", "read");
-                               } catch (AccessControlException e) {
-                                       result = false;
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot list workspaces for anonymous user", e);
-                       } finally {
-                               JcrUtils.logoutQuietly(tmpSession);
-                       }
-               }
-               return result;
-       }
-
-       /**
-        * Actual call to the
-        * {@link Repository#login(javax.jcr.Credentials, String)} method. To be
-        * overridden.
-        * 
-        * Creates a new session with correct credentials using the information
-        * contained in the corresponding repo node. It provides all UI children
-        * elements an unique entry point to retrieve a new Session. Caller must
-        * close the session when it is not in use anymore.
-        * 
-        */
-       protected Session repositoryLogin(String workspaceName) {
-               try {
-                       if (workspaceName == null)
-                               workspaceName = NodeConstants.SYS_WORKSPACE;// FIXME make it more generic
-                       return repository.login(credentials, workspaceName);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot login repository " + label + " with credential " + credentials, e);
-               }
-       }
-
-       public Boolean isConnected() {
-               if (defaultSession != null && defaultSession.isLive())
-                       return true;
-               else
-                       return false;
-       }
-
-       /** Exposes URI to the current repository */
-       public String getUri() {
-               return uri;
-       }
-
-       public String getRepoNodePath() {
-               if (repoNode == null)
-                       return null;
-               else
-                       try {
-                               return repoNode.getPath();
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get node path for repository " + label, e);
-                       }
-       }
-
-       /**
-        * Exposes the local repoNode that completely define a connection to a
-        * repository (including a set of credentials). Might return null in case of
-        * an anonymous user
-        */
-       protected Node getRepoNode() {
-               return repoNode;
-       }
-
-       protected Repository getRepository() {
-               return repository;
-       }
-
-       protected Credentials getCredentials() {
-               return credentials;
-       }
-
-       // META INFO
-       public String getDescription() {
-               String desc = label;
-               if (repoNode != null)
-                       desc = label + " (" + uri + ")";
-               return desc;
-       }
-
-       public String getLabel() {
-               return label;
-       }
-
-       public String toString() {
-               return repoNode != null ? repoNode.toString() : label;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java
deleted file mode 100644 (file)
index 0c10777..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-
-/**
- * Abstract set of similar workspaces, that is a bunch of workspaces with same
- * prefix.
- */
-public class WkspGroupElem extends DistParentElem {
-
-       private Session defaultSession;
-
-       public WkspGroupElem(RepoElem repoElem, String prefix) {
-               super(prefix, repoElem.inHome(), repoElem.isReadOnly());
-               setParent(repoElem);
-               // Directly adds children upon creation
-               try {
-                       defaultSession = repoElem.repositoryLogin(null);
-                       String[] wkpNames = defaultSession.getWorkspace()
-                                       .getAccessibleWorkspaceNames();
-                       for (String wkpName : wkpNames) {
-                               if (prefix.equals(getPrefix(wkpName))
-                               // if (wkpName.startsWith(prefix)
-                                               && repoElem.isWorkspaceVisible(wkpName))
-                                       addChild(new WorkspaceElem(WkspGroupElem.this, repoElem,
-                                                       wkpName));
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot retrieve workspace names", e);
-               }
-       }
-
-       // FIXME - we rely on a "hard coded" convention : Workspace name must have
-       // this format: name-major.minor
-       // We might expose this method as static public, to be used among others by
-       // the RepoElem parent objects when building its children
-       private String getPrefix(String workspaceName) {
-               if (workspaceName.lastIndexOf(VERSION_SEP) > 0)
-                       return workspaceName.substring(0,
-                                       workspaceName.lastIndexOf(VERSION_SEP));
-               else
-                       return workspaceName;
-       }
-
-       public void dispose() {
-               JcrUtils.logoutQuietly(defaultSession);
-               super.dispose();
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java
deleted file mode 100644 (file)
index 4c78511..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.InvalidQueryException;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/** Abstract a workspace that contains a software distribution */
-public class WorkspaceElem extends DistParentElem {
-       private final RepoElem repoElem;
-       private String workspaceName;
-       private Session currSession;
-
-       public WorkspaceElem(WkspGroupElem parent, RepoElem repoElem,
-                       String workspaceName) {
-               super(workspaceName, repoElem.inHome(), repoElem.isReadOnly());
-               this.repoElem = repoElem;
-               this.workspaceName = workspaceName;
-               setParent(parent);
-       }
-
-       public String getWorkspaceName() {
-               return workspaceName;
-       }
-
-       public RepoElem getRepoElem() {
-               return repoElem;
-       }
-
-       public Boolean isConnected() {
-               if (currSession != null && currSession.isLive())
-                       return true;
-               else
-                       return false;
-       }
-
-       public void login() {
-               currSession = repoElem.repositoryLogin(getName());
-       }
-
-       /** Utility to create a new Session with correct credential in this context */
-       public Session getNewSession() {
-               return repoElem.repositoryLogin(getName());
-       }
-
-       public boolean hasChildren() {
-               try {
-                       if (isConnected())
-                               return currSession.getRootNode().hasNodes();
-                       else
-                               return true;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while checking children node existence",
-                                       re);
-               }
-       }
-
-       /** Override normal behaviour to initialize display of the workspace */
-       @Override
-       public synchronized Object[] getChildren() {
-               if (isLoaded()) {
-                       return super.getChildren();
-               } else {
-                       // initialize current object
-                       try {
-                               // Lazy connect the first time we retrieve children
-                               if (currSession == null)
-                                       login();
-
-                               // Retrieve already existing distribution
-
-                               // Use QOM rather than SQL2 - it seems more robust for remoting
-                               // with JCR 2.2 (might also be some model refresh issue with the
-                               // remoting)
-                               QueryManager queryManager = currSession.getWorkspace()
-                                               .getQueryManager();
-                               QueryObjectModelFactory factory = queryManager.getQOMFactory();
-                               Selector selector = factory.selector(
-                                               SlcTypes.SLC_MODULAR_DISTRIBUTION,
-                                               SlcTypes.SLC_MODULAR_DISTRIBUTION);
-                               // Curiously this works...
-                               // Selector selector = factory.selector(
-                               // SlcTypes.SLC_JAR_FILE,
-                               // SlcTypes.SLC_JAR_FILE);
-
-                               QueryObjectModel query = factory.createQuery(selector, null,
-                                               null, null);
-
-                               // Query groupQuery = currSession
-                               // .getWorkspace()
-                               // .getQueryManager()
-                               // .createQuery(
-                               // "select * from ["
-                               // + SlcTypes.SLC_MODULAR_DISTRIBUTION
-                               // + "]", Query.JCR_SQL2);
-                               NodeIterator distributions = null;
-                               try {
-                                       distributions = query.execute().getNodes();
-                               } catch (InvalidQueryException iqe) {
-                                       // For legacy only does not throw an exception while
-                                       // browsing
-                                       // legacy repositories that does not know
-                                       // SLC_MODULAR_DISTRIBUTION type
-                               }
-                               distribs: while (distributions != null
-                                               && distributions.hasNext()) {
-                                       Node currDist = distributions.nextNode();
-                                       Node distBase = currDist.getParent().getParent();
-                                       if (!distBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
-                                               continue distribs;
-                                       String groupId = distBase
-                                                       .getProperty(SlcNames.SLC_GROUP_ID).getString();
-                                       String artifactId = distBase.getProperty(
-                                                       SlcNames.SLC_ARTIFACT_ID).getString();
-
-                                       String name;
-                                       String type;
-                                       if (ModularDistVersionBaseElem.AETHER_BINARIES_TYPE
-                                                       .equals(artifactId)) {
-                                               name = groupId;
-                                               type = ModularDistVersionBaseElem.AETHER_BINARIES_TYPE;
-                                       } else {
-                                               name = artifactId;
-                                               type = ModularDistVersionBaseElem.AETHER_DEP_TYPE;
-                                       }
-                                       if (getChildByName(name) == null)
-                                               addChild(new ModularDistVersionBaseElem(
-                                                               WorkspaceElem.this, name, distBase, type));
-                               }
-                               return super.getChildren();
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "Cannot initialize WorkspaceNode UI object."
-                                                               + getName(), e);
-                       }
-               }
-       }
-
-       @Override
-       public synchronized void dispose() {
-               JcrUtils.logoutQuietly(currSession);
-               super.dispose();
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ArtifactsTableConfigurer.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ArtifactsTableConfigurer.java
deleted file mode 100644 (file)
index dcdfc93..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-package org.argeo.slc.client.ui.dist.utils;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.query.Row;
-
-import org.argeo.eclipse.ui.GenericTableComparator;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.TableColumn;
-
-/**
- * Centralizes and factorizes useful methods to create and manage tables that
- * display artifacts for both editors and views.
- */
-public class ArtifactsTableConfigurer implements SlcNames, SlcTypes,
-               DistConstants {
-       // private final static Log log = LogFactory
-       // .getLog(ArtifactsTableConfigurer.class);
-       // Used in the comparator to be able to retrieve the value from a row
-       // knowing the corresponding column index.
-       private Map<Integer, String> indexToName = new HashMap<Integer, String>();
-
-       private CurrentTableComparator comparator;
-       private TableViewer viewer;
-
-       protected DateFormat timeFormatter = new SimpleDateFormat(DATE_TIME_FORMAT);
-
-       /**
-        * Create and initialize the table configurer.
-        */
-       public ArtifactsTableConfigurer(TableViewer viewer,
-                       int defaultSortColumnIndex, int direction) {
-               this.viewer = viewer;
-               comparator = new CurrentTableComparator(defaultSortColumnIndex,
-                               direction);
-       }
-
-       public GenericTableComparator getComparator() {
-               return comparator;
-       }
-
-       /**
-        * Configure column width and header label depending on the value that will
-        * be displayed in the current column.
-        * 
-        * @param jcrColumnName
-        * @param column
-        * @param columnIndex
-        */
-       public void configureColumn(String jcrColumnName, TableViewerColumn column,
-                       int columnIndex) {
-
-               if (columnIndex != -1
-                               && getSelectionAdapter(column.getColumn(), columnIndex) != null) {
-                       column.getColumn().addSelectionListener(
-                                       getSelectionAdapter(column.getColumn(), columnIndex));
-                       indexToName.put(new Integer(columnIndex), jcrColumnName);
-               }
-               Object[] objs = DistUiHelpers
-                               .getLabelAndDefaultValueWidth(jcrColumnName);
-               column.getColumn().setWidth((Integer) objs[1]);
-               column.getColumn().setText((String) objs[0]);
-       }
-
-       /**
-        * Might be used by client classes to sort the table with based on selected
-        * columns.
-        * 
-        * @param column
-        * @param index
-        * @return
-        */
-       public SelectionAdapter getSelectionAdapter(final TableColumn column,
-                       final int index) {
-
-               // A comparator must be define
-               if (comparator == null)
-                       return null;
-
-               SelectionAdapter selectionAdapter = new SelectionAdapter() {
-                       private static final long serialVersionUID = 5239138629878556374L;
-
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-
-                               try {
-
-                                       comparator.setColumn(index);
-                                       int dir = viewer.getTable().getSortDirection();
-                                       if (viewer.getTable().getSortColumn() == column) {
-                                               dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
-                                       } else {
-
-                                               dir = SWT.DOWN;
-                                       }
-                                       viewer.getTable().setSortDirection(dir);
-                                       viewer.getTable().setSortColumn(column);
-                                       viewer.refresh();
-                               } catch (Exception exc) {
-                                       exc.printStackTrace();
-                               }
-                       }
-               };
-               return selectionAdapter;
-       }
-
-       /**
-        * provides a label provider that returns the content of a specific cell.
-        * Specific treatment is done for some columns when the query returns a code
-        * that must be translated to the corresponding value at display time.
-        */
-       public ColumnLabelProvider getLabelProvider(final String columnName) {
-               boolean test = false;
-
-               if (test) {
-                       return new ColumnLabelProvider() {
-                               private static final long serialVersionUID = 7996387354459551737L;
-
-                               public String getText(Object element) {
-                                       return null;
-                               }
-
-                               public Image getImage(Object element) {
-                                       return null;
-                               }
-                       };
-               } else
-                       return new ColumnLabelProvider() {
-                               private static final long serialVersionUID = 6746632988975282759L;
-
-                               public String getText(Object element) {
-                                       Row row = (Row) element;
-                                       try {
-                                               return row.getValue(columnName).getString();
-                                       } catch (RepositoryException e) {
-                                               throw new SlcException("Cannot display row " + row, e);
-                                       }
-                               }
-
-                               public Image getImage(Object element) {
-                                       return null;
-                               }
-                       };
-       }
-
-       /** Implements comparator for various types of Artifact Table row */
-       private class CurrentTableComparator extends GenericTableComparator {
-               private static final long serialVersionUID = -4737460932326339442L;
-
-               public CurrentTableComparator(int colIndex, int direction) {
-                       super(colIndex, direction);
-               }
-
-               @Override
-               public int compare(Viewer viewer, Object e1, Object e2) {
-                       int rc = 0;
-
-                       if (e1 instanceof Row) {
-                               try {
-
-                                       Value v1 = ((Row) e1).getValue(indexToName
-                                                       .get(propertyIndex));
-                                       Value v2 = ((Row) e2).getValue(indexToName
-                                                       .get(propertyIndex));
-
-                                       if (v1.getType() == PropertyType.STRING)
-                                               rc = v1.getString().compareTo(v2.getString());
-                                       else if (v1.getType() == PropertyType.DATE)
-                                               rc = v1.getDate().compareTo(v2.getDate());
-                                       else
-                                               throw new SlcException("comparator for object type "
-                                                               + v1.getType() + " is not yet implemented");
-                               } catch (Exception e) {
-                                       throw new SlcException("rows cannot be compared ", e);
-                               }
-                       } else
-                               throw new SlcException("Unsupported row type");
-                       // If descending order, flip the direction
-                       if (direction == DESCENDING) {
-                               rc = -rc;
-                       }
-                       return rc;
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/CommandHelpers.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/CommandHelpers.java
deleted file mode 100644 (file)
index e1134c6..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.argeo.slc.client.ui.dist.utils;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.Parameterization;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.menus.CommandContributionItem;
-import org.eclipse.ui.menus.CommandContributionItemParameter;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * Centralizes useful methods to manage command updates
- */
-public class CommandHelpers {
-
-       /**
-        * Refresh the given command. 
-        */
-       public static void refreshCommand(IMenuManager menuManager,
-                       IServiceLocator locator, String cmdId, String label, String iconPath,
-                       boolean showCommand) {
-               IContributionItem ici = menuManager.find(cmdId);
-               if (ici != null)
-                       menuManager.remove(ici);
-
-               if (showCommand) {
-                       // Set Params
-                       CommandContributionItemParameter contributionItemParameter = new CommandContributionItemParameter(
-                                       locator, null, cmdId, SWT.PUSH);
-                       contributionItemParameter.label = label;
-                       contributionItemParameter.icon = DistPlugin.getImageDescriptor(iconPath);
-                       CommandContributionItem cci = new CommandContributionItem(
-                                       contributionItemParameter);
-                       cci.setId(cmdId);
-                       menuManager.add(cci);
-               }
-       }
-
-       /**
-        * Refresh the given command and optionally corresponding parameters.
-        * 
-        * @param menuManager
-        * @param locator
-        * @param cmdId
-        * @param label
-        * @param showCommand
-        *            Command must be explicitly removed from the context menu at
-        *            each refresh setting this to false.
-        * @param params
-        *            maps a paramId with a String value
-        */
-       public static void refreshParameterizedCommand(IMenuManager menuManager,
-                       IServiceLocator locator, String cmdId, String label, String iconPath,
-                       boolean showCommand, Map<String, String> params) {
-               IContributionItem ici = menuManager.find(cmdId);
-               if (ici != null)
-                       menuManager.remove(ici);
-               
-               if (showCommand) {
-                       // Set Params
-                       CommandContributionItemParameter contributionItemParameter = new CommandContributionItemParameter(
-                                       locator, null, cmdId, SWT.PUSH);
-                       contributionItemParameter.label = label;
-                       contributionItemParameter.icon = DistPlugin.getImageDescriptor(iconPath);
-
-                       if (params != null)
-                               contributionItemParameter.parameters = params;
-
-                       CommandContributionItem cci = new CommandContributionItem(
-                                       contributionItemParameter);
-                       cci.setId(cmdId);
-                       menuManager.add(cci);
-               }
-       }
-
-       /** Helper to call a command without parameter easily */
-       public static void callCommand(String commandID) {
-               callCommand(commandID, null);
-       }
-
-       /** Helper to call a command with a single parameter easily */
-       public static void callCommand(String commandID, String parameterID,
-                       String parameterValue) {
-               Map<String, String> params = new HashMap<String, String>();
-               params.put(parameterID, parameterValue);
-               callCommand(commandID, params);
-       }
-
-       /**
-        * Helper to call a command with a map of parameters easily
-        * 
-        * @param paramMap
-        *            a map that links various commands ids with corresponding
-        *            String values.
-        */
-       public static void callCommand(String commandID,
-                       Map<String, String> paramMap) {
-               try {
-                       IWorkbench iw = DistPlugin.getDefault().getWorkbench();
-                       IHandlerService handlerService = (IHandlerService) iw
-                                       .getService(IHandlerService.class);
-                       ICommandService cmdService = (ICommandService) iw
-                                       .getActiveWorkbenchWindow().getService(
-                                                       ICommandService.class);
-                       Command cmd = cmdService.getCommand(commandID);
-
-                       ArrayList<Parameterization> parameters = null;
-                       ParameterizedCommand pc; 
-
-                       if (paramMap != null) {
-                               // Set parameters of the command to launch :
-                               parameters = new ArrayList<Parameterization>();
-                               Parameterization parameterization;
-                               for (String id : paramMap.keySet()) {
-                                       parameterization = new Parameterization(
-                                                       cmd.getParameter(id), paramMap.get(id));
-                                       parameters.add(parameterization);
-                               }
-                               pc = new ParameterizedCommand(cmd,
-                                               parameters.toArray(new Parameterization[parameters.size()]));
-                       } else 
-                               pc = new ParameterizedCommand(cmd, null);
-                       
-                       // build the parameterized command
-                       // execute the command
-                       handlerService.executeCommand(pc, null);
-               } catch (Exception e) {
-                       throw new SlcException(
-                                       "Unexepected exception while opening node editor", e);
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistNodeViewerComparator.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistNodeViewerComparator.java
deleted file mode 100644 (file)
index 1411996..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-package org.argeo.slc.client.ui.dist.utils;
-
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.GenericTableComparator;
-import org.argeo.slc.SlcException;
-import org.eclipse.jface.viewers.Viewer;
-
-/** Add ability to order by name version and version */
-public class DistNodeViewerComparator extends GenericTableComparator {
-       private static final long serialVersionUID = -5966120108210992211L;
-
-       private final static Log log = LogFactory
-                       .getLog(DistNodeViewerComparator.class);
-
-       // Jcr property type goes to 12
-       public final static int NAME_VERSION_TYPE = 100;
-       public final static int VERSION_TYPE = 101;
-
-       protected List<String> propertiesList;
-       protected List<Integer> propertyTypesList;
-       protected Integer propertyType;
-       protected String property;
-
-       private NameVersionComparator nvc = new NameVersionComparator();
-       private VersionComparator vc = new VersionComparator();
-
-       public DistNodeViewerComparator(int defaultColIndex, int defaultDirection,
-                       List<String> propertiesList, List<Integer> propertyTypesList) {
-               super(defaultColIndex, defaultDirection);
-               this.propertiesList = propertiesList;
-               this.propertyTypesList = propertyTypesList;
-               this.propertyIndex = defaultColIndex;
-               this.propertyType = propertyTypesList.get(defaultColIndex);
-               this.property = propertiesList.get(defaultColIndex);
-               setColumn(defaultColIndex);
-       }
-
-       @Override
-       public int compare(Viewer viewer, Object e1, Object e2) {
-               int rc = 0;
-               long lc = 0;
-
-               try {
-                       Node n1 = (Node) e1;
-                       Node n2 = (Node) e2;
-
-                       Value v1 = null;
-                       Value v2 = null;
-                       if (n1.hasProperty(property))
-                               v1 = n1.getProperty(property).getValue();
-                       if (n2.hasProperty(property))
-                               v2 = n2.getProperty(property).getValue();
-
-                       if (v2 == null && v1 == null)
-                               return 0;
-                       else if (v2 == null)
-                               return -1;
-                       else if (v1 == null)
-                               return 1;
-
-                       switch (propertyType) {
-                       case NAME_VERSION_TYPE:
-                               rc = nvc.compare(viewer, v1.getString(), v2.getString());
-                               break;
-                       case VERSION_TYPE:
-                               rc = vc.compare(viewer, v1.getString(), v2.getString());
-                               break;
-                       case PropertyType.STRING:
-                               rc = v1.getString().compareTo(v2.getString());
-                               break;
-                       case PropertyType.BOOLEAN:
-                               boolean b1 = v1.getBoolean();
-                               boolean b2 = v2.getBoolean();
-                               if (b1 == b2)
-                                       rc = 0;
-                               else
-                                       // we assume true is greater than false
-                                       rc = b1 ? 1 : -1;
-                               break;
-                       case PropertyType.DATE:
-                               Calendar c1 = v1.getDate();
-                               Calendar c2 = v2.getDate();
-                               if (c1 == null || c2 == null)
-                                       log.trace("undefined date");
-                               lc = c1.getTimeInMillis() - c2.getTimeInMillis();
-                               if (lc < Integer.MIN_VALUE)
-                                       // rc = Integer.MIN_VALUE;
-                                       rc = -1;
-                               else if (lc > Integer.MAX_VALUE)
-                                       // rc = Integer.MAX_VALUE;
-                                       rc = 1;
-                               else
-                                       rc = (int) lc;
-                               break;
-                       case PropertyType.LONG:
-                               long l1;
-                               long l2;
-                               // FIXME sometimes an empty string is set instead of the id
-                               try {
-                                       l1 = v1.getLong();
-                               } catch (ValueFormatException ve) {
-                                       l1 = 0;
-                               }
-                               try {
-                                       l2 = v2.getLong();
-                               } catch (ValueFormatException ve) {
-                                       l2 = 0;
-                               }
-
-                               lc = l1 - l2;
-                               if (lc < Integer.MIN_VALUE)
-                                       // rc = Integer.MIN_VALUE;
-                                       rc = -1;
-                               else if (lc > Integer.MAX_VALUE)
-                                       // rc = Integer.MAX_VALUE;
-                                       rc = 1;
-                               else
-                                       rc = (int) lc;
-                               break;
-                       case PropertyType.DECIMAL:
-                               BigDecimal bd1 = v1.getDecimal();
-                               BigDecimal bd2 = v2.getDecimal();
-                               rc = bd1.compareTo(bd2);
-                               break;
-                       default:
-                               throw new SlcException(
-                                               "Unimplemented comparaison for PropertyType "
-                                                               + propertyType);
-                       }
-
-                       // If descending order, flip the direction
-                       if (direction == DESCENDING) {
-                               rc = -rc;
-                       }
-
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unexpected error "
-                                       + "while comparing nodes", re);
-               }
-               return rc;
-       }
-
-       @Override
-       public void setColumn(int column) {
-               if (column == this.propertyIndex) {
-                       // Same column as last sort; toggle the direction
-                       direction = 1 - direction;
-               } else {
-                       // New column; do a descending sort
-                       this.propertyIndex = column;
-                       this.propertyType = propertyTypesList.get(column);
-                       this.property = propertiesList.get(column);
-                       direction = ASCENDING;
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistUiHelpers.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistUiHelpers.java
deleted file mode 100644 (file)
index b53fe01..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.argeo.slc.client.ui.dist.utils;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-
-public class DistUiHelpers implements DistConstants, SlcTypes, SlcNames {
-       private final static Log log = LogFactory.getLog(DistUiHelpers.class);
-       private final static DateFormat df = new SimpleDateFormat(DATE_TIME_FORMAT);
-
-       /**
-        * Returns a user-friendly label for a given jcr property name. If the
-        * corresponding mapping is not found, the input String is returned. If
-        * input String is null "(No name)" is returned
-        */
-       public static String getLabelJcrName(String jcrName) {
-               return (String) getLabelAndDefaultValueWidth(jcrName)[0];
-       }
-
-       /**
-        * Returns a label ( (String) object[0] )and default value width ( (int)
-        * object[1] ) for a given property name
-        */
-       public static Object[] getLabelAndDefaultValueWidth(String propertyName) {
-               // to avoid npe :
-               if (propertyName == null)
-                       return new Object[] { "(No name)", 60 };
-
-               // ArtifactId
-               if (propertyName.equals(SLC_ARTIFACT + "." + SLC_ARTIFACT_ID)
-                               || propertyName.equals(SLC_ARTIFACT_BASE + "."
-                                               + SLC_ARTIFACT_ID)
-                               || propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
-                                               + SLC_ARTIFACT_ID)
-                               || propertyName.equals(SLC_ARTIFACT_ID)) {
-                       return new Object[] { "Artifact ID", 200 };
-               } // GroupId
-               else if (propertyName.equals(SLC_ARTIFACT + "." + SLC_GROUP_ID)
-                               || propertyName.equals(SLC_ARTIFACT_BASE + "." + SLC_GROUP_ID)
-                               || propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
-                                               + SLC_GROUP_ID) || propertyName.equals(SLC_GROUP_ID)) {
-                       return new Object[] { "Group ID", 120 };
-               } // Version
-               else if (propertyName.equals(SLC_ARTIFACT + "." + SLC_ARTIFACT_VERSION)
-                               || propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
-                                               + SLC_ARTIFACT_VERSION)
-                               || propertyName.equals(SLC_ARTIFACT_VERSION)) {
-                       return new Object[] { "Version", 60 };
-               } else if (propertyName.equals(SLC_ARTIFACT + "."
-                               + SLC_ARTIFACT_CLASSIFIER)
-                               || propertyName.equals(SLC_ARTIFACT_CLASSIFIER)) {
-                       return new Object[] { "Classifier", 60 };
-               } else if (propertyName.equals(SLC_ARTIFACT + "."
-                               + SLC_ARTIFACT_EXTENSION)
-                               || propertyName.equals(SLC_ARTIFACT_EXTENSION)) {
-                       return new Object[] { "Type", 40 };
-               } else if (propertyName.equals(SLC_BUNDLE_ARTIFACT + "."
-                               + SLC_SYMBOLIC_NAME)
-                               || propertyName.equals(SLC_SYMBOLIC_NAME)) {
-                       return new Object[] { "Symbolic name", 180 };
-               } else if (propertyName.equals(SLC_BUNDLE_ARTIFACT + "."
-                               + SLC_BUNDLE_VERSION)
-                               || propertyName.equals(SLC_BUNDLE_VERSION)) {
-                       return new Object[] { "Bundle version", 120 };
-               } else if (propertyName
-                               .equals(SLC_BUNDLE_ARTIFACT + "." + SLC_MANIFEST)
-                               || propertyName.equals(SLC_MANIFEST)) {
-                       return new Object[] { "Manifest", 60 };
-               } // TODO remove hard coded strings
-               else if (propertyName.equals("slc:Bundle-ManifestVersion")) {
-                       return new Object[] { "Bundle Manifest Version", 60 };
-               } else if (propertyName.equals("slc:Manifest-Version")) {
-                       return new Object[] { "Manifest Version", 60 };
-               } else if (propertyName.equals("slc:Bundle-Vendor")) {
-                       return new Object[] { "Bundle Vendor", 60 };
-               } else if (propertyName.equals("slc:Bundle-SymbolicName")) {
-                       return new Object[] { "Bundle symbolic name", 60 };
-               } else if (propertyName.equals("slc:Bundle-Name")) {
-                       return new Object[] { "Bundle name", 60 };
-               } else if (propertyName.equals("slc:Bundle-DocURL")) {
-                       return new Object[] { "Doc URL", 120 };
-               } else if (propertyName.equals("slc:Bundle-Licence")) {
-                       return new Object[] { "Bundle licence", 120 };
-               } else if (propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
-                               + JCR_IDENTIFIER)) {
-                       return new Object[] { "UUID", 0 };
-               } else {
-                       if (log.isTraceEnabled())
-                               log.trace("No Column label provider defined for property: ["
-                                               + propertyName + "]");
-                       return new Object[] { propertyName, 60 };
-               }
-       }
-
-       public static String formatValueAsString(Value value) {
-               try {
-                       String strValue;
-
-                       if (value.getType() == PropertyType.BINARY)
-                               strValue = "<binary>";
-                       else if (value.getType() == PropertyType.DATE)
-                               strValue = df.format(value.getDate().getTime());
-                       else
-                               strValue = value.getString();
-                       return strValue;
-               } catch (RepositoryException e) {
-                       throw new SlcException("unexpected error while formatting value",
-                                       e);
-               }
-       }
-
-       public static String formatAsString(Object value) {
-               String strValue;
-               if (value instanceof Calendar)
-                       strValue = df.format(((Calendar) value).getTime());
-               else
-                       strValue = value.toString();
-               return strValue;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/HyperlinkAdapter.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/HyperlinkAdapter.java
deleted file mode 100644 (file)
index 13d71f8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.argeo.slc.client.ui.dist.utils;
-
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
-
-/** Convenience class to reduce the number of methods to implement */
-public abstract class HyperlinkAdapter implements IHyperlinkListener {
-
-       public void linkEntered(HyperlinkEvent e) {
-       }
-
-       public void linkExited(HyperlinkEvent e) {
-       }
-
-       /** Must be overriden **/
-       public abstract void linkActivated(HyperlinkEvent e);
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/NameVersionComparator.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/NameVersionComparator.java
deleted file mode 100644 (file)
index 0c4903f..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.argeo.slc.client.ui.dist.utils;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-
-/**
- * Enable comparison of two names version string with form org.argeo.slc-1.2.x.
- * with following rules and assumptions:
- * <ul>
- * <li>
- * Names are ordered using Lexicographical order</li>
- * <li>
- * Version are parsed and compared segment by segment; doing best effort to
- * convert major, minor and micro to integer and compare them as such (to have
- * 0.1 < 0.9 < 0.10 not 0.1 < 0.10 < 0.9).</li>
- * <li>Version should not contain any dash (-), version segments should be
- * separated by dots (.)</li>
- * </ul>
- */
-
-public class NameVersionComparator extends ViewerComparator {
-       private static final long serialVersionUID = 8290130681918221197L;
-       
-       private VersionComparator vc = new VersionComparator();
-
-       @Override
-       public int category(Object element) {
-               if (element instanceof String) {
-                       int lastInd = ((String) element).lastIndexOf('-');
-                       if (lastInd > 0)
-                               return 10;
-               }
-               // unvalid names always last
-               return 5;
-       }
-
-       @Override
-       public int compare(Viewer viewer, Object e1, Object e2) {
-               int cat1 = category(e1);
-               int cat2 = category(e2);
-
-               if (cat1 != cat2) {
-                       return cat1 - cat2;
-               }
-
-               int result = 0;
-
-               String s1, s2;
-
-               if (e1 instanceof TreeParent) {
-                       s1 = ((TreeParent) e1).getName();
-                       s2 = ((TreeParent) e2).getName();
-               } else {
-                       s1 = e1.toString();
-                       s2 = e2.toString();
-               }
-
-               int i1 = s1.lastIndexOf('-');
-               int i2 = s2.lastIndexOf('-');
-
-               // Specific cases, unvalid Strings
-               if (i1 < 0)
-                       if (i2 < 0)
-                               return s1.compareTo(s2);
-                       else
-                               return 1;
-               else if (i2 < 0)
-                       return -1;
-
-               String aName = s1.substring(0, s1.lastIndexOf('-'));
-               String aVersion = s1.substring(s1.lastIndexOf('-'));
-
-               String bName = s2.substring(0, s2.lastIndexOf('-'));
-               String bVersion = s2.substring(s2.lastIndexOf('-'));
-
-               result = aName.compareTo(bName);
-               if (result != 0)
-                       return result;
-               else
-                       return vc.compare(viewer, aVersion, bVersion);
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/VersionComparator.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/VersionComparator.java
deleted file mode 100644 (file)
index 34aff22..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.argeo.slc.client.ui.dist.utils;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-
-/**
- * Enable comparison of two version string with form "1.2.5.qualifier" with
- * following rules and assumptions:
- * <ul>
- * <li>
- * Version are parsed and compared segment by segment; doing best effort to
- * convert major, minor and micro to integer and compare them as such (to have
- * 0.1 < 0.9 < 0.10 not 0.1 < 0.10 < 0.9).</li>
- * <li>Version should not contain any dash (-), version segments should be
- * separated by dots (.)</li>
- * </ul>
- */
-
-public class VersionComparator extends ViewerComparator {
-       private static final long serialVersionUID = 3760077835650538982L;
-
-       @Override
-       public int compare(Viewer viewer, Object e1, Object e2) {
-               String s1 = (String) e1;
-               String s2 = (String) e2;
-               return compareVersion(s1, s2);
-       }
-
-       /**
-        * Enable comparison of two versions of the form
-        * "major.minor.micro.qualifier". We assume the separator is always a "."
-        * and make best effort to convert major, minor and micro to int.
-        */
-       private int compareVersion(String v1, String v2) {
-               String[] t1 = v1.split("\\.");
-               String[] t2 = v2.split("\\.");
-
-               for (int i = 0; i < t1.length && i < t2.length; i++) {
-                       int result = compareToken(t1[i], t2[i]);
-                       if (result != 0)
-                               return result;
-               }
-               if (t1.length > t2.length)
-                       return 1;
-               else if (t1.length < t2.length)
-                       return -1;
-               else
-                       return 0;
-       }
-
-       private int compareToken(String t1, String t2) {
-               if (t1 == null && t2 == null)
-                       return 0;
-               else if (t1 == null)
-                       return -1;
-               else if (t2 == null)
-                       return 1;
-
-               Integer i1 = null, i2 = null;
-               try {
-                       i1 = new Integer(t1);
-                       i2 = new Integer(t2);
-               } catch (NumberFormatException nfe) {
-                       // the format is not valid we silently compare as String
-                       return t1.compareTo(t2);
-               }
-               return i1.compareTo(i2);
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java
deleted file mode 100644 (file)
index 8faa891..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.argeo.slc.client.ui.dist.utils;
-
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TreeColumn;
-
-/** Useful methods to manage table to display nodes list. */
-public class ViewerUtils {
-
-       /**
-        * Creates a basic column for the given table. For the time being, we do not
-        * support moveable columns.
-        */
-       public static TableColumn createColumn(Table parent, String name,
-                       int style, int width) {
-               TableColumn result = new TableColumn(parent, style);
-               result.setText(name);
-               result.setWidth(width);
-               result.setResizable(true);
-               return result;
-       }
-
-       /**
-        * Creates a TableViewerColumn for the given viewer. For the time being, we
-        * do not support moveable columns.
-        */
-       public static TableViewerColumn createTableViewerColumn(TableViewer parent,
-                       String name, int style, int width) {
-               TableViewerColumn tvc = new TableViewerColumn(parent, style);
-               final TableColumn column = tvc.getColumn();
-               column.setText(name);
-               column.setWidth(width);
-               column.setResizable(true);
-               return tvc;
-       }
-
-       /**
-        * Creates a TreeViewerColumn for the given viewer. For the time being, we
-        * do not support moveable columns.
-        */
-       public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent,
-                       String name, int style, int width) {
-               TreeViewerColumn tvc = new TreeViewerColumn(parent, style);
-               final TreeColumn column = tvc.getColumn();
-               column.setText(name);
-               column.setWidth(width);
-               column.setResizable(true);
-               return tvc;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AbstractQueryArtifactsView.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AbstractQueryArtifactsView.java
deleted file mode 100644 (file)
index e6552eb..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-package org.argeo.slc.client.ui.dist.views;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.Row;
-import javax.jcr.query.RowIterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.GenericTableComparator;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.utils.ArtifactsTableConfigurer;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.part.ViewPart;
-
-/** Factorizes useful methods to build a query view in a sashForm */
-public abstract class AbstractQueryArtifactsView extends ViewPart implements
-               SlcTypes {
-       private static final Log log = LogFactory
-                       .getLog(AbstractQueryArtifactsView.class);
-
-       // shortcuts
-       final protected static String SAVB = "[" + SLC_ARTIFACT_VERSION_BASE + "]";
-       final protected static String SBA = "[" + SLC_BUNDLE_ARTIFACT + "]";
-       final protected static String SIP = "[" + SLC_IMPORTED_PACKAGE + "]";
-       final protected static String SEP = "[" + SLC_EXPORTED_PACKAGE + "]";
-
-       /* DEPENDENCY INJECTION */
-       private Session session;
-       private List<String> columnProperties;
-
-       // This page widgets
-       private TableViewer viewer;
-       private List<TableViewerColumn> tableViewerColumns = new ArrayList<TableViewerColumn>();
-       private ArtifactsTableConfigurer tableConfigurer;
-       private GenericTableComparator comparator;
-
-       // to be set by client to display all columns
-       private boolean displayAllColumns = false;
-
-       protected void createResultPart(Composite parent) {
-               viewer = new TableViewer(parent);
-               Table table = viewer.getTable();
-               table.getParent().setLayout(new GridLayout(1, false));
-               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               viewer.getTable().setHeaderVisible(true);
-               viewer.getTable().setLinesVisible(true);
-
-               viewer.setLabelProvider(new ViewLabelProvider());
-               viewer.setContentProvider(new ViewContentProvider());
-               // viewer.addDoubleClickListener(new GenericDoubleClickListener());
-
-               tableConfigurer = new ArtifactsTableConfigurer(viewer, 1,
-                               GenericTableComparator.DESCENDING);
-
-               comparator = tableConfigurer.getComparator();
-               viewer.setComparator(comparator);
-       }
-
-       protected void executeQuery(String statement) {
-               try {
-                       Calendar stStamp = new GregorianCalendar();
-                       if (log.isDebugEnabled()) {
-                               log.debug("Executed query: " + statement);
-                       }
-                       QueryResult qr = session.getWorkspace().getQueryManager()
-                                       .createQuery(statement, Query.JCR_SQL2).execute();
-
-                       if (log.isDebugEnabled()) {
-                               Calendar enStamp = new GregorianCalendar();
-                               long duration = enStamp.getTimeInMillis()
-                                               - stStamp.getTimeInMillis();
-                               log.debug("Query executed in : " + duration / 1000 + "s.");
-                       }
-
-                       // remove previous columns
-                       for (TableViewerColumn tvc : tableViewerColumns)
-                               tvc.getColumn().dispose();
-
-                       // If a pre(-defined list of columns has been injected, we use it,
-                       // otherwise we display all results of the resultSet
-                       if (!displayAllColumns && columnProperties != null) {
-                               int i = 0;
-
-                               Iterator<String> it = columnProperties.iterator();
-                               while (it.hasNext()) {
-                                       String columnName = it.next();
-
-                                       TableViewerColumn tvc = new TableViewerColumn(viewer,
-                                                       SWT.NONE);
-                                       tableConfigurer.configureColumn(columnName, tvc, i);
-                                       tvc.setLabelProvider(tableConfigurer
-                                                       .getLabelProvider(columnName));
-                                       tableViewerColumns.add(tvc);
-                                       i++;
-                               }
-                       } else {
-                               int i = 0;
-                               for (final String columnName : qr.getColumnNames()) {
-                                       TableViewerColumn tvc = new TableViewerColumn(viewer,
-                                                       SWT.NONE);
-                                       // Small hack to remove prefix from the column name
-                                       // String tmpStr = columnName.substring(columnName
-                                       // .lastIndexOf(".") + 1);
-                                       tableConfigurer.configureColumn(columnName, tvc, i);
-                                       tvc.setLabelProvider(tableConfigurer
-                                                       .getLabelProvider(columnName));
-                                       tableViewerColumns.add(tvc);
-                                       i++;
-                               }
-                       }
-                       // We must create a local list because query result can be read only
-                       // once.
-                       try {
-                               List<Row> rows = new ArrayList<Row>();
-                               RowIterator rit = qr.getRows();
-                               while (rit.hasNext()) {
-                                       rows.add(rit.nextRow());
-                               }
-                               viewer.setInput(rows);
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot read query result", e);
-                       }
-
-               } catch (RepositoryException e) {
-                       ErrorDialog.openError(null, "Error", "Cannot execute JCR query: "
-                                       + statement, new Status(IStatus.ERROR,
-                                       "org.argeo.eclipse.ui.jcr", e.getMessage()));
-               }
-       }
-
-       /**
-        * Client must use this method to display all columns of the result set
-        * instead of a limited predifined and injected set
-        **/
-       public void displayAllColumns(boolean flag) {
-               displayAllColumns = flag;
-       }
-
-       // Can be overridden by subclasses.
-       protected String generateSelectStatement() {
-               StringBuffer sb = new StringBuffer("select " + SAVB + ".* ");
-               return sb.toString();
-       }
-
-       protected String generateFromStatement() {
-               StringBuffer sb = new StringBuffer(" from ");
-               sb.append(SAVB);
-               sb.append(" ");
-               return sb.toString();
-       }
-
-       // Providers
-       protected class ViewContentProvider implements IStructuredContentProvider {
-               private static final long serialVersionUID = 5286293288979552056L;
-
-               public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
-               }
-
-               public void dispose() {
-               }
-
-               @SuppressWarnings("unchecked")
-               public Object[] getElements(Object obj) {
-                       return ((List<String[]>) obj).toArray();
-               }
-       }
-
-       protected class ViewLabelProvider extends LabelProvider implements
-                       ITableLabelProvider {
-               private static final long serialVersionUID = -2407263563879116348L;
-
-               public String getColumnText(Object obj, int index) {
-                       if (!(obj instanceof String[]))
-                               return "Object is not properly formatted ";
-
-                       String[] value = (String[]) obj;
-
-                       return value[index];
-               }
-
-               public Image getColumnImage(Object obj, int index) {
-                       return null;
-               }
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setSession(Session session) {
-               this.session = session;
-       }
-
-       public void setColumnProperties(List<String> columnProperties) {
-               this.columnProperties = columnProperties;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AnonymousDistributionsView.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AnonymousDistributionsView.java
deleted file mode 100644 (file)
index b511c4e..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.cms.ArgeoNames;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeComparator;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Browse, manipulate and manage distributions accross multiple repositories
- * (like fetch, merge, publish, etc.).
- */
-public class AnonymousDistributionsView extends ViewPart implements SlcNames,
-               ArgeoNames {
-       // private final static Log log = LogFactory
-       // .getLog(AnonymousDistributionsView.class);
-       public final static String ID = DistPlugin.PLUGIN_ID
-                       + ".anonymousDistributionsView";
-
-       /* DEPENDENCY INJECTION */
-       private ITreeContentProvider treeContentProvider;
-
-       // This view widgets
-       private TreeViewer viewer;
-
-       @Override
-       public void createPartControl(Composite parent) {
-               // Define the TableViewer
-               viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
-                               | SWT.FULL_SELECTION | SWT.BORDER);
-
-               TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(400);
-               col.setLabelProvider(new DistTreeLabelProvider());
-
-               final Tree tree = viewer.getTree();
-               tree.setHeaderVisible(false);
-               tree.setLinesVisible(false);
-
-               // viewer.setContentProvider(new DistTreeContentProvider());
-               viewer.setContentProvider(treeContentProvider);
-               viewer.addDoubleClickListener(new DistTreeDoubleClickListener(viewer));
-               viewer.setComparator(new DistTreeComparator());
-
-               // Initialize
-               refresh();
-       }
-
-       /**
-        * Force refresh of the whole view
-        */
-       public void refresh() {
-               Object[] ee = viewer.getExpandedElements();
-               viewer.setInput(DistConstants.DEFAULT_PUBLIC_REPOSITORY_URI);
-               // viewer.expandToLevel(2);
-               viewer.setExpandedElements(ee);
-       }
-
-       @Override
-       public void setFocus() {
-               viewer.getTree().setFocus();
-       }
-
-       /*
-        * DEPENDENCY INJECTION
-        */
-       public void setTreeContentProvider(ITreeContentProvider treeContentProvider) {
-               this.treeContentProvider = treeContentProvider;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/ArtifactsBrowser.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/ArtifactsBrowser.java
deleted file mode 100644 (file)
index 9eef477..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-package org.argeo.slc.client.ui.dist.views;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.controllers.ArtifactsTreeContentProvider;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Basic View to browse a maven based repository.
- * 
- * By Default size of the various bundles is not computed but it can be
- * activated the view command.
- */
-
-public class ArtifactsBrowser extends ViewPart implements DistConstants,
-               RepoConstants {
-       // private final static Log log = LogFactory.getLog(ArtifactsBrowser.class);
-       public final static String ID = DistPlugin.PLUGIN_ID + ".artifactsBrowser";
-
-       /* DEPENDENCY INJECTION */
-       private Session jcrSession;
-
-       // Business objects
-       private Node rootNode;
-
-       // This page widgets
-       private TreeViewer artifactTreeViewer;
-       private boolean isSizeVisible = false;
-
-       // To be able to configure columns easily
-       public static final int COLUMN_TREE = 0;
-       public static final int COLUMN_DATE = 1;
-       public static final int COLUMN_SIZE = 2;
-       private static final int SIZE_COL_WIDTH = 55;
-
-       @Override
-       public void createPartControl(Composite parent) {
-               // Enable the different parts to fill the whole page when the tab is
-               // maximized
-               parent.setLayout(new FillLayout());
-               artifactTreeViewer = createArtifactsTreeViewer(parent);
-
-               // context menu : it is completely defined in the plugin.xml file.
-               // Nothing in the context menu for the time being
-               // MenuManager menuManager = new MenuManager();
-               // Menu menu =
-               // menuManager.createContextMenu(artifactTreeViewer.getTree());
-               // artifactTreeViewer.getTree().setMenu(menu);
-               // getSite().registerContextMenu(menuManager, artifactTreeViewer);
-
-               getSite().setSelectionProvider(artifactTreeViewer);
-               // packagesViewer.setComparer(new NodeViewerComparer());
-
-               // Model initialisation
-               if (jcrSession != null) {
-                       try {
-                               rootNode = jcrSession.getNode(DEFAULT_ARTIFACTS_BASE_PATH);
-                               artifactTreeViewer.setInput(rootNode);
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot load base artifact nodes", e);
-                       }
-               }
-       }
-
-       protected TreeViewer createArtifactsTreeViewer(Composite parent) {
-               int style = SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION;
-               Tree tree = new Tree(parent, style);
-               createColumn(tree, "Artifacts", SWT.LEFT, 300);
-               createColumn(tree, "Date created", SWT.LEFT, 105);
-               createColumn(tree, "Size", SWT.RIGHT, 0);
-               tree.setLinesVisible(true);
-               tree.setHeaderVisible(true);
-
-               TreeViewer viewer = new TreeViewer(tree);
-
-               viewer.setContentProvider(new ArtifactsTreeContentProvider());
-               viewer.setLabelProvider(new ArtifactLabelProvider());
-               viewer.addSelectionChangedListener(new ArtifactTreeSelectionListener());
-               // viewer.addDoubleClickListener(new GenericDoubleClickListener());
-               viewer.setInput(rootNode);
-
-               return viewer;
-       }
-
-       private static TreeColumn createColumn(Tree parent, String name, int style,
-                       int width) {
-               TreeColumn result = new TreeColumn(parent, style);
-               result.setText(name);
-               result.setWidth(width);
-               result.setMoveable(true);
-               result.setResizable(true);
-               return result;
-       }
-
-       protected TreeViewer getArtifactTreeViewer() {
-               return artifactTreeViewer;
-       }
-
-       @Override
-       public void setFocus() {
-               // TODO Auto-generated method stub
-
-       }
-
-       /**
-        * Refresh the given element of the tree browser. If null is passed as a
-        * parameter, it refreshes the whole tree
-        */
-       public void refresh(Object element) {
-               if (element == null) {
-                       artifactTreeViewer.refresh(rootNode);
-               } else
-                       artifactTreeViewer.refresh(element);
-       }
-
-       /** Returns wether size column is visible or not */
-       public boolean isSizeVisible() {
-               return isSizeVisible;
-       }
-
-       /** Sets the visibility of the size column */
-       public void setSizeVisible(boolean visible) {
-               if (isSizeVisible == visible)
-                       return; // nothing has changed
-               else
-                       isSizeVisible = visible;
-
-               if (visible) {
-                       artifactTreeViewer.getTree().getColumn(COLUMN_SIZE)
-                                       .setWidth(SIZE_COL_WIDTH);
-               } else {
-                       // we just hide the column, we don't refresh the whole tree.
-                       artifactTreeViewer.getTree().getColumn(COLUMN_SIZE).setWidth(0);
-               }
-       }
-
-       private class ArtifactLabelProvider extends ColumnLabelProvider implements
-                       DistConstants, SlcTypes {
-               private static final long serialVersionUID = 7516705499556141806L;
-
-               // Utils
-               protected DateFormat timeFormatter = new SimpleDateFormat(
-                               DATE_TIME_FORMAT);
-
-               public void update(ViewerCell cell) {
-                       int colIndex = cell.getColumnIndex();
-                       Object element = cell.getElement();
-                       cell.setText(getColumnText(element, colIndex));
-
-                       if (element instanceof Node && colIndex == 0) {
-                               Node node = (Node) element;
-                               try {
-                                       if (node.isNodeType(SLC_ARTIFACT_BASE))
-                                               cell.setImage(DistImages.IMG_ARTIFACT_BASE);
-                                       else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE))
-                                               cell.setImage(DistImages.IMG_ARTIFACT_VERSION_BASE);
-                               } catch (RepositoryException e) {
-                                       // Silent
-                               }
-                       }
-               }
-
-               @Override
-               public Image getImage(Object element) {
-
-                       if (element instanceof Node) {
-                               Node node = (Node) element;
-                               try {
-                                       if (node.isNodeType(SLC_ARTIFACT_BASE)) {
-                                               return DistImages.IMG_ARTIFACT_BASE;
-                                       } else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) {
-                                               return DistImages.IMG_ARTIFACT_VERSION_BASE;
-                                       }
-                               } catch (RepositoryException e) {
-                                       // Silent
-                               }
-                       }
-                       return null;
-               }
-
-               public String getColumnText(Object element, int columnIndex) {
-                       try {
-                               if (element instanceof Node) {
-                                       Node node = (Node) element;
-                                       switch (columnIndex) {
-                                       case COLUMN_TREE:
-                                               return node.getName();
-                                       case COLUMN_SIZE:
-                                               if (isSizeVisible) {
-                                                       long size = JcrUtils.getNodeApproxSize(node) / 1024;
-                                                       if (size > 1024)
-                                                               return size / 1024 + " MB";
-                                                       else
-                                                               return size + " KB";
-                                               } else
-                                                       return "";
-                                       case COLUMN_DATE:
-                                               if (node.hasProperty(Property.JCR_CREATED))
-                                                       return timeFormatter.format(node
-                                                                       .getProperty(Property.JCR_CREATED)
-                                                                       .getDate().getTime());
-                                               else
-                                                       return null;
-                                       }
-                               }
-                       } catch (RepositoryException re) {
-                               throw new SlcException(
-                                               "Unexepected error while getting property values", re);
-                       }
-                       return null;
-               }
-
-               // private String formatValueAsString(Value value) {
-               // // TODO enhance this method
-               // try {
-               // String strValue;
-               //
-               // if (value.getType() == PropertyType.BINARY)
-               // strValue = "<binary>";
-               // else if (value.getType() == PropertyType.DATE)
-               // strValue = timeFormatter.format(value.getDate().getTime());
-               // else
-               // strValue = value.getString();
-               // return strValue;
-               // } catch (RepositoryException e) {
-               // throw new SlcException(
-               // "unexpected error while formatting value", e);
-               // }
-               // }
-       }
-
-       private class ArtifactTreeSelectionListener implements
-                       ISelectionChangedListener {
-
-               public void selectionChanged(SelectionChangedEvent event) {
-                       ISelection selection = event.getSelection();
-                       if (selection != null && selection instanceof IStructuredSelection) {
-                               IStructuredSelection iss = (IStructuredSelection) selection;
-                               if (iss.size() == 1) {
-                                       artifactTreeViewer.refresh(iss.getFirstElement());
-                               }
-                       }
-
-               }
-
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setJcrSession(Session jcrSession) {
-               this.jcrSession = jcrSession;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/DistributionsView.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/DistributionsView.java
deleted file mode 100644 (file)
index ffebf6a..0000000
+++ /dev/null
@@ -1,370 +0,0 @@
-package org.argeo.slc.client.ui.dist.views;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.commands.CopyLocalJavaWorkspace;
-import org.argeo.slc.client.ui.dist.commands.CopyWorkspace;
-import org.argeo.slc.client.ui.dist.commands.CreateLocalJavaWorkspace;
-import org.argeo.slc.client.ui.dist.commands.CreateWorkspace;
-import org.argeo.slc.client.ui.dist.commands.DeleteWorkspace;
-import org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation;
-import org.argeo.slc.client.ui.dist.commands.Fetch;
-import org.argeo.slc.client.ui.dist.commands.NormalizeDistribution;
-import org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace;
-import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
-import org.argeo.slc.client.ui.dist.commands.PublishWorkspace;
-import org.argeo.slc.client.ui.dist.commands.RegisterRepository;
-import org.argeo.slc.client.ui.dist.commands.RunInOsgi;
-import org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeComparator;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeComparer;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeContentProvider;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
-import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Browse, manipulate and manage distributions across multiple repositories
- * (like fetch, merge, publish, etc.).
- */
-public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames {
-       // private final static Log log =
-       // LogFactory.getLog(DistributionsView.class);
-
-       public final static String ID = DistPlugin.PLUGIN_ID + ".distributionsView";
-
-       /* DEPENDENCY INJECTION */
-       private Repository nodeRepository;
-       private DistTreeContentProvider treeContentProvider;
-
-       private TreeViewer viewer;
-
-       @Override
-       public void createPartControl(Composite parent) {
-               // Define the TableViewer
-               viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
-                               | SWT.FULL_SELECTION | SWT.BORDER);
-
-               TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.NONE);
-               col.getColumn().setWidth(400);
-               col.setLabelProvider(new DistTreeLabelProvider());
-
-               final Tree tree = viewer.getTree();
-               tree.setHeaderVisible(false);
-               tree.setLinesVisible(false);
-
-               // viewer.setContentProvider(new DistTreeContentProvider());
-               viewer.setContentProvider(treeContentProvider);
-               viewer.addDoubleClickListener(new DistTreeDoubleClickListener(viewer));
-               viewer.setComparer(new DistTreeComparer());
-               viewer.setComparator(new DistTreeComparator());
-
-               @SuppressWarnings("unused")
-               ViewerComparator vc = viewer.getComparator();
-
-               // Enable retrieving current tree selected items from outside the view
-               getSite().setSelectionProvider(viewer);
-
-               MenuManager menuManager = new MenuManager();
-               Menu menu = menuManager.createContextMenu(viewer.getTree());
-               menuManager.addMenuListener(new IMenuListener() {
-                       private static final long serialVersionUID = -1454108001335038652L;
-
-                       public void menuAboutToShow(IMenuManager manager) {
-                               contextMenuAboutToShow(manager);
-                       }
-               });
-               viewer.getTree().setMenu(menu);
-               getSite().registerContextMenu(menuManager, viewer);
-
-               // Initialize
-               refresh();
-       }
-
-       /** Programatically configure the context menu */
-       protected void contextMenuAboutToShow(IMenuManager menuManager) {
-               IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
-                               .getActiveWorkbenchWindow();
-
-               // Most of the implemented commands support only one selected
-               // element
-               boolean singleElement = ((IStructuredSelection) viewer.getSelection())
-                               .size() == 1;
-               // Get Current selected item :
-               Object firstElement = ((IStructuredSelection) viewer.getSelection())
-                               .getFirstElement();
-
-               try {
-
-                       if (firstElement instanceof TreeParent
-                                       || firstElement instanceof DistParentElem) {
-
-                               String targetRepoPath = null, workspaceName = null, workspacePrefix = null;
-                               String modularDistBasePath = null;
-                               String modularDistPath = null;
-                               // String targetRepoUri = null;
-                               // Build conditions depending on element type
-                               boolean isDistribElem = false, isModularDistVersionBaseElem = false, isRepoElem = false, isDistribGroupElem = false;
-                               boolean isLocal = false, isReadOnly = true;
-
-                               RepoElem re = null;
-
-                               if (firstElement instanceof RepoElem) {
-                                       re = (RepoElem) firstElement;
-                                       isRepoElem = true;
-                                       isLocal = re.inHome();
-                                       isReadOnly = re.isReadOnly();
-                               } else if (firstElement instanceof WkspGroupElem) {
-                                       WkspGroupElem wge = (WkspGroupElem) firstElement;
-                                       isReadOnly = wge.isReadOnly();
-                                       isDistribGroupElem = true;
-                                       re = (RepoElem) wge.getParent();
-                                       workspacePrefix = wge.getName();
-                               } else if (firstElement instanceof WorkspaceElem) {
-                                       WorkspaceElem we = (WorkspaceElem) firstElement;
-                                       re = we.getRepoElem();
-                                       isDistribElem = true;
-                                       isReadOnly = we.isReadOnly();
-                                       workspaceName = we.getWorkspaceName();
-                                       isLocal = we.inHome();
-                               } else if (firstElement instanceof ModularDistVersionBaseElem) {
-                                       ModularDistVersionBaseElem mdbe = (ModularDistVersionBaseElem) firstElement;
-                                       isModularDistVersionBaseElem = true;
-                                       re = mdbe.getWkspElem().getRepoElem();
-                                       isLocal = re.inHome();
-                                       isReadOnly = re.isReadOnly();
-                                       workspaceName = mdbe.getWkspElem().getWorkspaceName();
-                                       modularDistBasePath = mdbe.getModularDistBase().getPath();
-                               } else if (firstElement instanceof ModularDistVersionElem) {
-                                       ModularDistVersionElem mdbe = (ModularDistVersionElem) firstElement;
-                                       re = mdbe.getWorkspaceElem().getRepoElem();
-                                       isLocal = re.inHome();
-                                       isReadOnly = re.isReadOnly();
-                                       workspaceName = mdbe.getWorkspaceElem().getWorkspaceName();
-                                       modularDistPath = mdbe.getModularDistVersionNode()
-                                                       .getPath();
-                               }
-
-                               if (re != null) {
-                                       targetRepoPath = re.getRepoNodePath();
-                               }
-
-                               // Display repo info
-                               CommandUtils.refreshCommand(menuManager, window,
-                                               DisplayRepoInformation.ID,
-                                               DisplayRepoInformation.DEFAULT_LABEL,
-                                               DisplayRepoInformation.DEFAULT_ICON, isRepoElem
-                                                               && singleElement);
-
-                               // create workspace
-                               Map<String, String> params = new HashMap<String, String>();
-                               params.put(CreateWorkspace.PARAM_TARGET_REPO_PATH,
-                                               targetRepoPath);
-                               params.put(CreateWorkspace.PARAM_WORKSPACE_PREFIX,
-                                               workspacePrefix);
-                               CommandUtils.refreshParameterizedCommand(menuManager, window,
-                                               CreateWorkspace.ID, CreateWorkspace.DEFAULT_LABEL,
-                                               CreateWorkspace.DEFAULT_ICON,
-                                               (isRepoElem || isDistribGroupElem) && singleElement
-                                                               && !isReadOnly && !isLocal, params);
-
-                               // TODO Manage the case where it is not a java workspace
-                               params = new HashMap<String, String>();
-                               params.put(CreateLocalJavaWorkspace.PARAM_WORKSPACE_PREFIX,
-                                               workspacePrefix);
-                               CommandUtils.refreshParameterizedCommand(menuManager, window,
-                                               CreateLocalJavaWorkspace.ID,
-                                               CreateLocalJavaWorkspace.DEFAULT_LABEL,
-                                               CreateLocalJavaWorkspace.DEFAULT_ICON,
-                                               (isRepoElem || isDistribGroupElem) && singleElement
-                                                               && !isReadOnly && isLocal, params);
-
-                               // Register a remote repository
-                               CommandUtils.refreshCommand(menuManager, window,
-                                               RegisterRepository.ID,
-                                               RegisterRepository.DEFAULT_LABEL,
-                                               RegisterRepository.DEFAULT_ICON, isRepoElem
-                                                               && singleElement);
-
-                               // Unregister a remote repository
-                               params = new HashMap<String, String>();
-                               params.put(UnregisterRemoteRepo.PARAM_REPO_PATH, targetRepoPath);
-                               CommandUtils.refreshParameterizedCommand(menuManager, window,
-                                               UnregisterRemoteRepo.ID,
-                                               UnregisterRemoteRepo.DEFAULT_LABEL,
-                                               UnregisterRemoteRepo.DEFAULT_ICON, isRepoElem
-                                                               && !isLocal && singleElement, params);
-
-                               // Fetch repository
-                               params = new HashMap<String, String>();
-                               params.put(Fetch.PARAM_TARGET_REPO_PATH, targetRepoPath);
-                               CommandUtils.refreshParameterizedCommand(menuManager, window,
-                                               Fetch.ID, Fetch.DEFAULT_LABEL, Fetch.DEFAULT_ICON,
-                                               isRepoElem && isLocal && singleElement && !isReadOnly,
-                                               params);
-
-                               // Normalize workspace
-                               params = new HashMap<String, String>();
-                               params.put(NormalizeWorkspace.PARAM_TARGET_REPO_PATH,
-                                               targetRepoPath);
-                               params.put(NormalizeWorkspace.PARAM_WORKSPACE_NAME,
-                                               workspaceName);
-
-                               CommandUtils.refreshParameterizedCommand(menuManager, window,
-                                               NormalizeWorkspace.ID, "Normalize...",
-                                               NormalizeWorkspace.DEFAULT_ICON, isDistribElem
-                                                               && singleElement && !isReadOnly, params);
-
-                               // Copy workspace
-                               params = new HashMap<String, String>();
-                               params.put(CopyWorkspace.PARAM_TARGET_REPO_PATH, targetRepoPath);
-                               params.put(CopyWorkspace.PARAM_SOURCE_WORKSPACE_NAME,
-                                               workspaceName);
-                               CommandUtils.refreshParameterizedCommand(menuManager, window,
-                                               CopyWorkspace.ID, CopyWorkspace.DEFAULT_LABEL,
-                                               CopyWorkspace.DEFAULT_ICON, isDistribElem
-                                                               && singleElement && !isLocal, params);
-
-                               params = new HashMap<String, String>();
-                               params.put(CopyLocalJavaWorkspace.PARAM_SOURCE_WORKSPACE_NAME,
-                                               workspaceName);
-                               CommandUtils.refreshParameterizedCommand(menuManager, window,
-                                               CopyLocalJavaWorkspace.ID,
-                                               CopyLocalJavaWorkspace.DEFAULT_LABEL,
-                                               CopyLocalJavaWorkspace.DEFAULT_ICON, isDistribElem
-                                                               && singleElement && isLocal, params);
-
-                               // Clear Workspace
-                               params = new HashMap<String, String>();
-                               params.put(DeleteWorkspace.PARAM_TARGET_REPO_PATH,
-                                               targetRepoPath);
-                               params.put(DeleteWorkspace.PARAM_WORKSPACE_NAME, workspaceName);
-                               CommandUtils.refreshParameterizedCommand(menuManager, window,
-                                               DeleteWorkspace.ID, DeleteWorkspace.DEFAULT_LABEL,
-                                               DeleteWorkspace.DEFAULT_ICON, isDistribElem
-                                                               && singleElement && !isReadOnly, params);
-
-                               // Advanced submenu
-                               MenuManager submenu = new MenuManager("Advanced",
-                                               DistPlugin.PLUGIN_ID + ".advancedSubmenu");
-                               IContributionItem ici = menuManager.find(DistPlugin.PLUGIN_ID
-                                               + ".advancedSubmenu");
-                               if (ici != null)
-                                       menuManager.remove(ici);
-
-                               // Publish workspace
-                               params = new HashMap<String, String>();
-                               params.put(PublishWorkspace.PARAM_TARGET_REPO_PATH,
-                                               targetRepoPath);
-                               params.put(PublishWorkspace.PARAM_WORKSPACE_NAME, workspaceName);
-                               CommandUtils.refreshParameterizedCommand(submenu, window,
-                                               PublishWorkspace.ID, PublishWorkspace.DEFAULT_LABEL,
-                                               PublishWorkspace.DEFAULT_ICON, isDistribElem
-                                                               && singleElement && !isReadOnly, params);
-
-                               // Normalize distribution (Legacy)
-                               params = new HashMap<String, String>();
-                               params.put(NormalizeDistribution.PARAM_TARGET_REPO_PATH,
-                                               targetRepoPath);
-                               params.put(NormalizeDistribution.PARAM_WORKSPACE_NAME,
-                                               workspaceName);
-                               CommandUtils.refreshParameterizedCommand(submenu, window,
-                                               NormalizeDistribution.ID,
-                                               NormalizeDistribution.DEFAULT_LABEL,
-                                               NormalizeDistribution.DEFAULT_ICON, isDistribElem
-                                                               && singleElement && !isReadOnly, params);
-
-                               // Run in OSGi
-                               params = new HashMap<String, String>();
-                               params.put(RunInOsgi.PARAM_MODULE_PATH, modularDistPath);
-                               params.put(RunInOsgi.PARAM_WORKSPACE_NAME, workspaceName);
-                               CommandUtils.refreshParameterizedCommand(submenu, window,
-                                               RunInOsgi.ID, RunInOsgi.DEFAULT_LABEL,
-                                               RunInOsgi.DEFAULT_ICON, modularDistPath != null
-                                                               && singleElement && isLocal, params);
-
-                               // Open generate binaries
-                               params = new HashMap<String, String>();
-                               params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
-                                               targetRepoPath);
-                               params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
-                                               modularDistBasePath);
-                               params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
-                                               workspaceName);
-
-                               CommandUtils.refreshParameterizedCommand(submenu, window,
-                                               OpenGenerateBinariesWizard.ID,
-                                               OpenGenerateBinariesWizard.DEFAULT_LABEL,
-                                               OpenGenerateBinariesWizard.DEFAULT_ICON,
-                                               isModularDistVersionBaseElem && !isReadOnly, params);
-
-                               if (submenu.getSize() > 0)
-                                       menuManager.add(submenu);
-
-                               // // Manage workspace authorizations
-                               // params = new HashMap<String, String>();
-                               // params.put(ManageWorkspaceAuth.PARAM_WORKSPACE_NAME, wsName);
-                               // CommandHelpers.refreshParameterizedCommand(menuManager,
-                               // window,
-                               // ManageWorkspaceAuth.ID, ManageWorkspaceAuth.DEFAULT_LABEL,
-                               // ManageWorkspaceAuth.DEFAULT_ICON_PATH, isDistribElem
-                               // && singleElement && !isReadOnly, params);
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("unexpected errror while "
-                                       + "building context menu for element " + firstElement, e);
-               }
-       }
-
-       @Override
-       public void setFocus() {
-               viewer.getTree().setFocus();
-       }
-
-       /**
-        * Force refresh of the whole view
-        */
-       public void refresh() {
-               viewer.setInput(nodeRepository);
-               viewer.expandToLevel(2);
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-
-       public void setTreeContentProvider(
-                       DistTreeContentProvider treeContentProvider) {
-               this.treeContentProvider = treeContentProvider;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/HelpView.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/HelpView.java
deleted file mode 100644 (file)
index 105f36d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-
-/** Display some info about the distribution */
-public class HelpView extends ViewPart {
-       public final static String ID = DistPlugin.PLUGIN_ID + ".helpView";
-
-       @Override
-       public void createPartControl(Composite parent) {
-               parent.setLayout(new GridLayout(2, false));
-               Browser browser = new Browser(parent, SWT.NONE);
-               browser.setUrl("/repo/howto.html");
-               browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
-       }
-
-       /** Force refresh of the whole view */
-       public void refresh() {
-       }
-
-       @Override
-       public void setFocus() {
-       }
-
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsForm.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsForm.java
deleted file mode 100644 (file)
index 9ce41d4..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/** Query SLC Repo to get some artifacts given some predefined parameters */
-public class QueryArtifactsForm extends AbstractQueryArtifactsView implements
-               SlcNames {
-       // private static final Log log = LogFactory.getLog(QueryArtifactsForm.class);
-       public static final String ID = DistPlugin.PLUGIN_ID + ".queryArtifactsForm";
-
-       // widgets
-       private Button executeBtn;
-       private Text groupId;
-       private Text artifactId;
-       private Text version;
-       private SashForm sashForm;
-
-       private Composite top, bottom;
-
-       @Override
-       public void createPartControl(Composite parent) {
-
-               sashForm = new SashForm(parent, SWT.VERTICAL);
-               sashForm.setSashWidth(4);
-               // Enable the different parts to fill the whole page when the tab is
-               // maximized
-               sashForm.setLayout(new FillLayout());
-
-               top = new Composite(sashForm, SWT.NONE);
-               top.setLayout(new GridLayout(1, false));
-
-               bottom = new Composite(sashForm, SWT.NONE);
-               bottom.setLayout(new GridLayout(1, false));
-
-               sashForm.setWeights(new int[] { 25, 75 });
-
-               createQueryForm(top);
-               createResultPart(bottom);
-       }
-
-       public void createQueryForm(Composite parent) {
-               Label lbl;
-               GridData gd;
-
-               GridLayout gl = new GridLayout(2, false);
-               gl.marginTop = 5;
-               parent.setLayout(gl);
-
-               // lbl = new Label(parent, SWT.SINGLE);
-               // lbl.setText("Query by coordinates");
-               // gd = new GridData();
-               // gd.horizontalSpan = 2;
-               // lbl.setLayoutData(gd);
-
-               // Group ID
-               lbl = new Label(parent, SWT.SINGLE);
-               lbl.setText("Group ID");
-               groupId = new Text(parent, SWT.SINGLE | SWT.BORDER);
-               gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               groupId.setLayoutData(gd);
-
-               // Artifact ID
-               lbl = new Label(parent, SWT.SINGLE);
-               lbl.setText("Artifact ID");
-               artifactId = new Text(parent, SWT.SINGLE | SWT.BORDER);
-               gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               artifactId.setLayoutData(gd);
-
-               // Version
-               lbl = new Label(parent, SWT.SINGLE);
-               lbl.setText("Version");
-               version = new Text(parent, SWT.SINGLE | SWT.BORDER);
-               gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               version.setLayoutData(gd);
-
-               executeBtn = new Button(parent, SWT.PUSH);
-               executeBtn.setText("Search");
-               gd = new GridData();
-               gd.horizontalSpan = 2;
-               executeBtn.setLayoutData(gd);
-
-               Listener executeListener = new Listener() {
-                       private static final long serialVersionUID = 7161585477628774129L;
-
-                       public void handleEvent(Event event) {
-                               refreshQuery();
-                       }
-               };
-               executeBtn.addListener(SWT.Selection, executeListener);
-       }
-
-       public void refreshQuery() {
-               String queryStr = generateSelectStatement() + generateFromStatement()
-                               + generateWhereStatement();
-               executeQuery(queryStr);
-               bottom.layout();
-               sashForm.layout();
-       }
-
-       private String generateWhereStatement() {
-               try {
-                       boolean hasFirstClause = false;
-                       StringBuffer sb = new StringBuffer(" where ");
-
-                       if (groupId.getText() != null
-                                       && !groupId.getText().trim().equals("")) {
-                               sb.append("[" + SLC_GROUP_ID + "] like '"
-                                               + groupId.getText().replace('*', '%') + "'");
-                               hasFirstClause = true;
-                       }
-
-                       if (artifactId.getText() != null
-                                       && !artifactId.getText().trim().equals("")) {
-                               if (hasFirstClause)
-                                       sb.append(" AND ");
-                               sb.append("[" + SLC_ARTIFACT_ID + "] like '"
-                                               + artifactId.getText().replace('*', '%') + "'");
-                               hasFirstClause = true;
-                       }
-
-                       if (version.getText() != null
-                                       && !version.getText().trim().equals("")) {
-                               if (hasFirstClause)
-                                       sb.append(" AND ");
-                               sb.append("[" + SLC_ARTIFACT_VERSION + "] like '"
-                                               + version.getText().replace('*', '%') + "'");
-                       }
-
-                       return sb.toString();
-               } catch (Exception e) {
-                       throw new SlcException(
-                                       "Cannot generate where statement to get artifacts", e);
-               }
-       }
-
-       @Override
-       public void setFocus() {
-               executeBtn.setFocus();
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsText.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsText.java
deleted file mode 100644 (file)
index 3b0be10..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/** Query SLC Repo to get some artifacts with a JCR SQL 2 request. */
-public class QueryArtifactsText extends AbstractQueryArtifactsView implements
-               SlcNames {
-       // private static final Log log =
-       // LogFactory.getLog(QueryArtifactsText.class);
-       public static final String ID = DistPlugin.PLUGIN_ID + ".queryArtifactsText";
-
-       // widgets
-       private Button executeBtn;
-       private Text queryText;
-       private SashForm sashForm;
-
-       private Composite top, bottom;
-
-       @Override
-       public void createPartControl(Composite parent) {
-
-               sashForm = new SashForm(parent, SWT.VERTICAL);
-               sashForm.setSashWidth(4);
-               // Enable the different parts to fill the whole page when the tab is
-               // maximized
-               sashForm.setLayout(new FillLayout());
-
-               top = new Composite(sashForm, SWT.NONE);
-               top.setLayout(new GridLayout(1, false));
-
-               bottom = new Composite(sashForm, SWT.NONE);
-               bottom.setLayout(new GridLayout(1, false));
-
-               sashForm.setWeights(new int[] { 25, 75 });
-
-               createQueryForm(top);
-               createResultPart(bottom);
-       }
-
-       public void createQueryForm(Composite parent) {
-               Label lbl;
-               GridData gd;
-
-               GridLayout gl = new GridLayout(2, false);
-               gl.marginTop = 5;
-               parent.setLayout(gl);
-
-               lbl = new Label(parent, SWT.SINGLE);
-               lbl.setText("Enter a JCR:SQL2 Query");
-
-               executeBtn = new Button(parent, SWT.PUSH);
-               executeBtn.setText("Search");
-
-               queryText = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.BORDER);
-               gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               gd.heightHint = 100;
-               gd.horizontalSpan = 2;
-               queryText.setLayoutData(gd);
-
-               String query = generateSelectStatement() + generateFromStatement()
-                               + generateWhereStatement();
-               queryText.setText(query);
-
-               Listener executeListener = new Listener() {
-                       private static final long serialVersionUID = -5028331930076117569L;
-
-                       public void handleEvent(Event event) {
-                               refreshQuery();
-                       }
-               };
-               executeBtn.addListener(SWT.Selection, executeListener);
-       }
-
-       public void refreshQuery() {
-               String queryStr = queryText.getText();
-               executeQuery(queryStr);
-               bottom.layout();
-               sashForm.layout();
-       }
-
-       private String generateWhereStatement() {
-               StringBuffer sb = new StringBuffer(" where ");
-               return sb.toString();
-       }
-
-       @Override
-       public void setFocus() {
-               executeBtn.setFocus();
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryBundlesForm.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryBundlesForm.java
deleted file mode 100644 (file)
index c4980d5..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/** Query SLC Repo to get some artifacts given some predefined parameters */
-public class QueryBundlesForm extends AbstractQueryArtifactsView implements
-               SlcNames, SlcTypes {
-       // private static final Log log = LogFactory.getLog(QueryBundlesForm.class);
-       public static final String ID = DistPlugin.PLUGIN_ID + ".queryBundlesForm";
-
-       // widgets
-       private Button executeBtn;
-       private Text symbolicName;
-       private Text importedPackage;
-       private Text exportedPackage;
-       private SashForm sashForm;
-
-       private Composite top, bottom;
-
-       @Override
-       public void createPartControl(Composite parent) {
-
-               sashForm = new SashForm(parent, SWT.VERTICAL);
-               sashForm.setSashWidth(4);
-               // Enable the different parts to fill the whole page when the tab is
-               // maximized
-               sashForm.setLayout(new FillLayout());
-
-               top = new Composite(sashForm, SWT.NONE);
-               top.setLayout(new GridLayout(1, false));
-
-               bottom = new Composite(sashForm, SWT.NONE);
-               bottom.setLayout(new GridLayout(1, false));
-
-               sashForm.setWeights(new int[] { 25, 75 });
-
-               createQueryForm(top);
-               createResultPart(bottom);
-       }
-
-       public void createQueryForm(Composite parent) {
-               Label lbl;
-               GridData gd;
-
-               GridLayout gl = new GridLayout(2, false);
-               gl.marginTop = 5;
-               parent.setLayout(gl);
-
-               // Bundle Name
-               lbl = new Label(parent, SWT.SINGLE);
-               lbl.setText("Symbolic name");
-               symbolicName = new Text(parent, SWT.SINGLE | SWT.BORDER);
-               gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               symbolicName.setLayoutData(gd);
-
-               // imported package
-               lbl = new Label(parent, SWT.SINGLE);
-               lbl.setText("Imported package");
-               importedPackage = new Text(parent, SWT.SINGLE | SWT.BORDER);
-               gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               importedPackage.setLayoutData(gd);
-
-               // exported package
-               lbl = new Label(parent, SWT.SINGLE);
-               lbl.setText("Exported package");
-               exportedPackage = new Text(parent, SWT.SINGLE | SWT.BORDER);
-               gd = new GridData(GridData.FILL_HORIZONTAL);
-               gd.grabExcessHorizontalSpace = true;
-               exportedPackage.setLayoutData(gd);
-
-               executeBtn = new Button(parent, SWT.PUSH);
-               executeBtn.setText("Search");
-               gd = new GridData();
-               gd.horizontalSpan = 2;
-               executeBtn.setLayoutData(gd);
-
-               Listener executeListener = new Listener() {
-                       private static final long serialVersionUID = 6267263421349073712L;
-
-                       public void handleEvent(Event event) {
-                               refreshQuery();
-                       }
-               };
-               executeBtn.addListener(SWT.Selection, executeListener);
-       }
-
-       public void refreshQuery() {
-               String queryStr = generateStatement();
-               executeQuery(queryStr);
-               bottom.layout();
-               sashForm.layout();
-       }
-
-       private String generateStatement() {
-               try {
-                       // shortcuts
-                       boolean hasFirstClause = false;
-                       boolean ipClause = importedPackage.getText() != null
-                                       && !importedPackage.getText().trim().equals("");
-                       boolean epClause = exportedPackage.getText() != null
-                                       && !exportedPackage.getText().trim().equals("");
-
-                       StringBuffer sb = new StringBuffer();
-                       // Select
-                       sb.append("select " + SBA + ".*, " + SAVB + ".* ");
-                       sb.append(" from " + SAVB);
-
-                       // join
-                       sb.append(" inner join ");
-                       sb.append(SBA);
-                       sb.append(" on isdescendantnode(" + SBA + ", " + SAVB + ") ");
-                       if (ipClause) {
-                               sb.append(" inner join ");
-                               sb.append(SIP);
-                               sb.append(" on isdescendantnode(" + SIP + ", " + SBA + ") ");
-                       }
-
-                       if (epClause) {
-                               sb.append(" inner join ");
-                               sb.append(SEP);
-                               sb.append(" on isdescendantnode(" + SEP + ", " + SBA + ") ");
-                       }
-
-                       // where
-                       sb.append(" where ");
-                       if (symbolicName.getText() != null
-                                       && !symbolicName.getText().trim().equals("")) {
-                               sb.append(SBA + ".[" + SLC_SYMBOLIC_NAME + "] like '"
-                                               + symbolicName.getText().replace('*', '%') + "'");
-                               hasFirstClause = true;
-                       }
-
-                       if (ipClause) {
-                               if (hasFirstClause)
-                                       sb.append(" AND ");
-                               sb.append(SIP + ".[" + SLC_NAME + "] like '"
-                                               + importedPackage.getText().replace('*', '%') + "'");
-                               hasFirstClause = true;
-                       }
-
-                       if (epClause) {
-                               if (hasFirstClause)
-                                       sb.append(" AND ");
-                               sb.append(SEP + ".[" + SLC_NAME + "] like '"
-                                               + exportedPackage.getText().replace('*', '%') + "'");
-                       }
-                       return sb.toString();
-               } catch (Exception e) {
-                       throw new SlcException(
-                                       "Cannot generate where statement to get artifacts", e);
-               }
-       }
-
-       @Override
-       public void setFocus() {
-               executeBtn.setFocus();
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChangeRightsWizard.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChangeRightsWizard.java
deleted file mode 100644 (file)
index 9dce9a0..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.argeo.slc.client.ui.dist.wizards;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.eclipse.jface.wizard.Wizard;
-
-/**
- * Small wizard to manage authorizations on the root node of the current
- * workspace
- */
-public class ChangeRightsWizard extends Wizard {
-
-       private Session currentSession;
-
-       // This page widget
-       private ChooseRightsPage page;
-
-       public ChangeRightsWizard(Session currentSession) {
-               super();
-               this.currentSession = currentSession;
-       }
-
-       @Override
-       public void addPages() {
-               try {
-                       page = new ChooseRightsPage();
-                       addPage(page);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot add page to wizard ", e);
-               }
-       }
-
-       @Override
-       public boolean performFinish() {
-               if (!canFinish())
-                       return false;
-               try {
-                       JcrUtils.addPrivilege(currentSession, "/", page.getGroupName(),
-                                       page.getAuthTypeStr());
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while setting privileges", re);
-               }
-               return true;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChooseRightsPage.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChooseRightsPage.java
deleted file mode 100644 (file)
index fcd4097..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.argeo.slc.client.ui.dist.wizards;
-
-import javax.jcr.security.Privilege;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-public class ChooseRightsPage extends WizardPage implements ModifyListener {
-       private static final long serialVersionUID = 3016024222014878781L;
-
-       // This page widget
-       private Text groupNameTxt;
-       private Combo authorizationCmb;
-
-       // Define acceptable chars for the technical name
-       // private static Pattern p = Pattern.compile("^[A-Za-z0-9]+$");
-
-       // USABLE SHORTCUTS
-       protected final static String[] validAuthType = { Privilege.JCR_READ,
-                       Privilege.JCR_WRITE, Privilege.JCR_ALL };
-
-       public ChooseRightsPage() {
-               super("Main");
-               setTitle("Manage authorizations on the current workspace");
-       }
-
-       public void createControl(Composite parent) {
-               // specify subject
-               Composite composite = new Composite(parent, SWT.NONE);
-               composite.setLayout(new GridLayout(2, false));
-               Label lbl = new Label(composite, SWT.LEAD);
-               lbl.setText("Group or user name (no blank, no special chars)");
-               lbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-               groupNameTxt = new Text(composite, SWT.LEAD | SWT.BORDER);
-               groupNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
-                               false));
-               if (groupNameTxt != null)
-                       groupNameTxt.addModifyListener(this);
-
-               // Choose rigths
-               new Label(composite, SWT.NONE).setText("Choose corresponding rights");
-               authorizationCmb = new Combo(composite, SWT.BORDER | SWT.V_SCROLL);
-               authorizationCmb.setItems(validAuthType);
-               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-               authorizationCmb.setLayoutData(gd);
-
-               authorizationCmb.select(0);
-
-               // Compulsory
-               setControl(composite);
-       }
-
-       protected String getGroupName() {
-               return groupNameTxt.getText();
-       }
-
-       protected String getAuthTypeStr() {
-               return authorizationCmb.getItem(authorizationCmb.getSelectionIndex());
-       }
-
-       // private static boolean match(String s) {
-       // return p.matcher(s).matches();
-       // }
-
-       public void modifyText(ModifyEvent event) {
-               String message = checkComplete();
-               if (message != null)
-                       setMessage(message, WizardPage.ERROR);
-               else {
-                       setMessage("Complete", WizardPage.INFORMATION);
-                       setPageComplete(true);
-               }
-       }
-
-       /** @return error message or null if complete */
-       protected String checkComplete() {
-               String groupStr = groupNameTxt.getText();
-               if (groupStr == null || "".equals(groupStr))
-                       return "Please enter the name of the corresponding group.";
-               // Remove regexp check for the time being.
-               // else if (!match(groupStr))
-               // return
-               // "Please use only alphanumerical chars for the short technical name.";
-               return null;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java
deleted file mode 100644 (file)
index 888478d..0000000
+++ /dev/null
@@ -1,671 +0,0 @@
-package org.argeo.slc.client.ui.dist.wizards;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.ViewerUtils;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoSync;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Defines parameters for the fetch process and run it using a {@link RepoSync}
- * object.
- */
-public class FetchWizard extends Wizard {
-       // private final static Log log = LogFactory.getLog(FetchWizard.class);
-
-       // Business objects
-       private Keyring keyring;
-       private RepositoryFactory repositoryFactory;
-       private Session currSession;
-       private Node targetRepoNode, sourceRepoNode;
-
-       private List<WkspObject> selectedWorkspaces = new ArrayList<WkspObject>();
-
-       // The pages
-       private ChooseWkspPage chooseWkspPage;
-       private RecapPage recapPage;
-
-       // Cache the advanced pages
-       private Map<WkspObject, AdvancedFetchPage> advancedPages = new HashMap<FetchWizard.WkspObject, FetchWizard.AdvancedFetchPage>();
-
-       // Controls with parameters
-       private Button filesOnlyBtn;
-       private Button advancedBtn;
-       private CheckboxTableViewer wkspViewer;
-
-       public FetchWizard(Keyring keyring, RepositoryFactory repositoryFactory,
-                       Repository nodeRepository) {
-               super();
-               this.keyring = keyring;
-               this.repositoryFactory = repositoryFactory;
-               try {
-                       currSession = nodeRepository.login();
-               } catch (RepositoryException e) {
-                       throw new SlcException(
-                                       "Unexpected error while initializing fetch wizard", e);
-               }
-       }
-
-       @Override
-       public void dispose() {
-               JcrUtils.logoutQuietly(currSession);
-               super.dispose();
-       }
-
-       @Override
-       public void addPages() {
-               try {
-                       chooseWkspPage = new ChooseWkspPage();
-                       addPage(chooseWkspPage);
-                       recapPage = new RecapPage();
-                       addPage(recapPage);
-                       setWindowTitle("Define Fetch Procedure");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot add page to wizard ", e);
-               }
-       }
-
-       @Override
-       public boolean performFinish() {
-               if (!canFinish())
-                       return false;
-               try {
-                       // Target Repository
-                       String targetRepoUri = targetRepoNode.getProperty(
-                                       ArgeoNames.ARGEO_URI).getString();
-                       Repository targetRepo = RepoUtils.getRepository(repositoryFactory,
-                                       keyring, targetRepoNode);
-                       Credentials targetCredentials = RepoUtils.getRepositoryCredentials(
-                                       keyring, targetRepoNode);
-
-                       // Source Repository
-                       String sourceRepoUri = sourceRepoNode.getProperty(
-                                       ArgeoNames.ARGEO_URI).getString();
-                       Repository sourceRepo = RepoUtils.getRepository(repositoryFactory,
-                                       keyring, sourceRepoNode);
-                       Credentials sourceCredentials = RepoUtils.getRepositoryCredentials(
-                                       keyring, sourceRepoNode);
-
-                       String msg = "Your are about to fetch data from repository: \n\t"
-                                       + sourceRepoUri + "\ninto target repository: \n\t"
-                                       + targetRepoUri + "\nDo you really want to proceed ?";
-
-                       boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
-                                       .getWorkbench().getDisplay().getActiveShell(),
-                                       "Confirm Fetch Launch", msg);
-
-                       if (result) {
-                               RepoSync repoSync = new RepoSync(sourceRepo, sourceCredentials,
-                                               targetRepo, targetCredentials);
-                               repoSync.setTargetRepoUri(targetRepoUri);
-                               repoSync.setSourceRepoUri(sourceRepoUri);
-
-                               // Specify workspaces to synchronise
-                               Map<String, String> wksps = new HashMap<String, String>();
-                               for (Object obj : wkspViewer.getCheckedElements()) {
-                                       WkspObject stn = (WkspObject) obj;
-                                       wksps.put(stn.srcName, stn.targetName);
-                               }
-                               repoSync.setWkspMap(wksps);
-
-                               // Set the import files only option
-                               repoSync.setFilesOnly(filesOnlyBtn.getSelection());
-                               FetchJob job = new FetchJob(repoSync);
-                               job.setUser(true);
-                               job.schedule();
-                       }
-               } catch (Exception e) {
-                       throw new SlcException(
-                                       "Unexpected error while launching the fetch", e);
-               }
-               return true;
-       }
-
-       // ///////////////////////////////
-       // ////// THE PAGES
-
-       private class ChooseWkspPage extends WizardPage {
-               private static final long serialVersionUID = 211336700788047638L;
-
-               private Map<String, Node> sourceReposMap;
-               private Combo chooseSourceRepoCmb;
-
-               public ChooseWkspPage() {
-                       super("Main");
-                       setTitle("Choose workspaces to fetch");
-                       setDescription("Check 'advanced fetch' box to "
-                                       + "rename workspaces and fine tune the process");
-
-                       // Initialise with registered Repositories
-                       sourceReposMap = getSourceRepoUris();
-               }
-
-               public void createControl(Composite parent) {
-                       Composite composite = new Composite(parent, SWT.NO_FOCUS);
-                       composite.setLayout(new GridLayout(2, false));
-
-                       // Choose source repository combo
-                       new Label(composite, SWT.NONE)
-                                       .setText("Choose a source repository");
-                       chooseSourceRepoCmb = new Combo(composite, SWT.BORDER
-                                       | SWT.V_SCROLL);
-                       chooseSourceRepoCmb.setItems(sourceReposMap.keySet().toArray(
-                                       new String[sourceReposMap.size()]));
-                       GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-                       chooseSourceRepoCmb.setLayoutData(gd);
-
-                       // Check boxes
-                       final Button selectAllBtn = new Button(composite, SWT.CHECK);
-                       selectAllBtn.setText("Select/Unselect all");
-
-                       advancedBtn = new Button(composite, SWT.CHECK);
-                       advancedBtn.setText("Advanced fetch");
-                       advancedBtn.setToolTipText("Check this for further "
-                                       + "parameterization of the fetch process");
-
-                       // Workspace table
-                       Table table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL
-                                       | SWT.BORDER | SWT.CHECK);
-                       gd = new GridData(SWT.FILL, SWT.FILL, true, true);
-                       gd.horizontalSpan = 2;
-                       table.setLayoutData(gd);
-                       configureWkspTable(table);
-
-                       // Import only files
-                       filesOnlyBtn = new Button(composite, SWT.CHECK | SWT.WRAP);
-                       filesOnlyBtn
-                                       .setText("Import only files (faster, a normalized action should be launched once done)");
-                       filesOnlyBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
-                                       false, 2, 1));
-
-                       // Listeners
-                       selectAllBtn.addSelectionListener(new SelectionAdapter() {
-                               private static final long serialVersionUID = -2071840477444152170L;
-
-                               public void widgetSelected(SelectionEvent e) {
-                                       wkspViewer.setAllChecked(selectAllBtn.getSelection());
-                                       getContainer().updateButtons();
-                               }
-                       });
-
-                       // advancedBtn.addSelectionListener(new SelectionAdapter() {
-                       // public void widgetSelected(SelectionEvent e) {
-                       // if (advancedBtn.getSelection()){
-                       //
-                       // }
-                       // wkspViewer.setAllChecked();
-                       // }
-                       // });
-
-                       chooseSourceRepoCmb.addModifyListener(new ModifyListener() {
-                               private static final long serialVersionUID = 932462568382594523L;
-
-                               public void modifyText(ModifyEvent e) {
-                                       String chosenUri = chooseSourceRepoCmb
-                                                       .getItem(chooseSourceRepoCmb.getSelectionIndex());
-                                       sourceRepoNode = sourceReposMap.get(chosenUri);
-                                       wkspViewer.setInput(sourceRepoNode);
-                               }
-                       });
-
-                       wkspViewer.addCheckStateListener(new ICheckStateListener() {
-                               public void checkStateChanged(CheckStateChangedEvent event) {
-                                       getContainer().updateButtons();
-                               }
-                       });
-
-                       // Initialise to first available repo
-                       if (chooseSourceRepoCmb.getItemCount() > 0)
-                               chooseSourceRepoCmb.select(0);
-
-                       // Compulsory
-                       setControl(composite);
-               }
-
-               @Override
-               public boolean isPageComplete() {
-                       return wkspViewer.getCheckedElements().length != 0;
-               }
-
-               @Override
-               public IWizardPage getNextPage() {
-                       // WARNING: page are added and never removed.
-                       if (advancedBtn.getSelection()
-                                       && wkspViewer.getCheckedElements().length != 0) {
-                               IWizardPage toReturn = null;
-                               for (Object obj : wkspViewer.getCheckedElements()) {
-                                       WkspObject curr = (WkspObject) obj;
-                                       // currSelecteds.add(curr);
-                                       AdvancedFetchPage page;
-                                       if (!advancedPages.containsKey(curr)) {
-                                               page = new AdvancedFetchPage(curr.srcName, curr);
-                                               addPage(page);
-                                               advancedPages.put(curr, page);
-                                       } else
-                                               page = advancedPages.get(curr);
-                                       if (toReturn == null)
-                                               toReturn = page;
-                               }
-                               return toReturn;
-                       } else {
-                               return recapPage;
-                       }
-               }
-
-               // Configure the workspace table
-               private void configureWkspTable(Table table) {
-                       table.setLinesVisible(true);
-                       table.setHeaderVisible(true);
-                       wkspViewer = new CheckboxTableViewer(table);
-
-                       // WORKSPACE COLUMNS
-                       TableViewerColumn column = ViewerUtils.createTableViewerColumn(
-                                       wkspViewer, "Source names", SWT.NONE, 250);
-                       column.setLabelProvider(new ColumnLabelProvider() {
-                               private static final long serialVersionUID = 5906079281065061967L;
-
-                               @Override
-                               public String getText(Object element) {
-                                       return ((WkspObject) element).srcName;
-                               }
-                       });
-
-                       // column = ViewerUtils.createTableViewerColumn(wkspViewer, "Size",
-                       // SWT.NONE, 250);
-                       // column.setLabelProvider(new ColumnLabelProvider() {
-                       // @Override
-                       // public String getText(Object element) {
-                       // return ((WkspObject) element).getFormattedSize();
-                       // }
-                       // });
-
-                       wkspViewer.setContentProvider(new WkspContentProvider());
-                       // A basic comparator
-                       wkspViewer.setComparator(new ViewerComparator());
-               }
-       }
-
-       private class AdvancedFetchPage extends WizardPage {
-               private static final long serialVersionUID = 1109183561920445169L;
-
-               private final WkspObject currentWorkspace;
-
-               private Text targetNameTxt;
-
-               protected AdvancedFetchPage(String pageName, WkspObject currentWorkspace) {
-                       super(pageName);
-                       this.currentWorkspace = currentWorkspace;
-               }
-
-               @Override
-               public void setVisible(boolean visible) {
-                       super.setVisible(visible);
-                       if (visible) {
-                               String msg = "Define advanced parameters to fetch workspace "
-                                               + currentWorkspace.srcName;
-                               setMessage(msg);
-                               targetNameTxt.setText(currentWorkspace.targetName);
-                       }
-                       // else
-                       // currentWorkspace.targetName = targetNameTxt.getText();
-               }
-
-               public void createControl(Composite parent) {
-                       Composite body = new Composite(parent, SWT.NO_FOCUS);
-                       body.setLayout(new GridLayout(2, false));
-                       new Label(body, SWT.NONE).setText("Choose a new name");
-                       targetNameTxt = new Text(body, SWT.BORDER);
-                       targetNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
-                                       true, false));
-                       setControl(body);
-               }
-
-               protected WkspObject getWorkspaceObject() {
-                       currentWorkspace.targetName = targetNameTxt.getText();
-                       return currentWorkspace;
-               }
-
-               @Override
-               public IWizardPage getNextPage() {
-                       // WARNING: page are added and never removed.
-                       // IWizardPage toReturn = null;
-                       // IWizardPage[] pages = ((Wizard) getContainer()).getPages();
-                       Object[] selected = wkspViewer.getCheckedElements();
-                       for (int i = 0; i < selected.length - 1; i++) {
-                               WkspObject curr = (WkspObject) selected[i];
-                               if (curr.equals(currentWorkspace))
-                                       return advancedPages.get((WkspObject) selected[i + 1]);
-                       }
-                       return recapPage;
-               }
-       }
-
-       private class RecapPage extends WizardPage {
-               private static final long serialVersionUID = -7064862323304300989L;
-               private TableViewer recapViewer;
-
-               public RecapPage() {
-                       super("Validate and launch");
-                       setTitle("Validate and launch");
-               }
-
-               @Override
-               public boolean isPageComplete() {
-                       return isCurrentPage();
-               }
-
-               public IWizardPage getNextPage() {
-                       // always last....
-                       return null;
-               }
-
-               @Override
-               public void setVisible(boolean visible) {
-                       super.setVisible(visible);
-                       if (visible) {
-                               try {
-                                       String targetRepoUri = targetRepoNode.getProperty(
-                                                       ArgeoNames.ARGEO_URI).getString();
-                                       String sourceRepoUri = sourceRepoNode.getProperty(
-                                                       ArgeoNames.ARGEO_URI).getString();
-
-                                       String msg = "Fetch data from: " + sourceRepoUri
-                                                       + "\ninto target repository: " + targetRepoUri;
-                                       // + "\nDo you really want to proceed ?";
-                                       setMessage(msg);
-
-                                       // update values that will be used for the fetch
-                                       selectedWorkspaces.clear();
-
-                                       for (Object obj : wkspViewer.getCheckedElements()) {
-                                               WkspObject curr = (WkspObject) obj;
-
-                                               if (advancedBtn.getSelection()) {
-                                                       AdvancedFetchPage page = advancedPages.get(curr);
-                                                       selectedWorkspaces.add(page.getWorkspaceObject());
-                                               } else
-                                                       selectedWorkspaces.add(curr);
-                                       }
-                                       recapViewer.setInput(selectedWorkspaces);
-                                       recapViewer.refresh();
-
-                               } catch (RepositoryException re) {
-                                       throw new SlcException("Unable to get repositories URIs",
-                                                       re);
-                               }
-                       }
-               }
-
-               public void createControl(Composite parent) {
-                       Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL
-                                       | SWT.BORDER);
-                       table.setLinesVisible(true);
-                       table.setHeaderVisible(true);
-                       recapViewer = new TableViewer(table);
-
-                       // WORKSPACE COLUMNS
-                       TableViewerColumn column = ViewerUtils.createTableViewerColumn(
-                                       recapViewer, "Sources", SWT.NONE, 250);
-                       column.setLabelProvider(new ColumnLabelProvider() {
-                               private static final long serialVersionUID = 3913459002502680377L;
-
-                               @Override
-                               public String getText(Object element) {
-                                       return ((WkspObject) element).srcName;
-                               }
-                       });
-
-                       column = ViewerUtils.createTableViewerColumn(recapViewer,
-                                       "targets", SWT.NONE, 250);
-                       column.setLabelProvider(new ColumnLabelProvider() {
-                               private static final long serialVersionUID = -517920072332563632L;
-
-                               @Override
-                               public String getText(Object element) {
-                                       return ((WkspObject) element).targetName;
-                               }
-                       });
-
-                       recapViewer.setContentProvider(new IStructuredContentProvider() {
-                               private static final long serialVersionUID = 4926999891003040865L;
-
-                               public void inputChanged(Viewer viewer, Object oldInput,
-                                               Object newInput) {
-                                       // TODO Auto-generated method stub
-                               }
-
-                               public void dispose() {
-                               }
-
-                               public Object[] getElements(Object inputElement) {
-                                       return selectedWorkspaces.toArray();
-                               }
-                       });
-
-                       // A basic comparator
-                       recapViewer.setComparator(new ViewerComparator());
-                       setControl(table);
-               }
-       }
-
-       /**
-        * Define the privileged job that will be run asynchronously to accomplish
-        * the sync
-        */
-       private class FetchJob extends PrivilegedJob {
-               private RepoSync repoSync;
-
-               public FetchJob(RepoSync repoSync) {
-                       super("Fetch");
-                       this.repoSync = repoSync;
-               }
-
-               @Override
-               protected IStatus doRun(IProgressMonitor progressMonitor) {
-                       try {
-                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
-                               repoSync.setMonitor(monitor);
-                               repoSync.run();
-                       } catch (Exception e) {
-                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
-                                               "Cannot fetch repository", e);
-                       }
-                       return Status.OK_STATUS;
-               }
-       }
-
-       // ///////////////////////
-       // Local classes
-       private class WkspObject {
-               protected final String srcName;
-               protected String targetName;
-
-               protected WkspObject(String srcName) {
-                       this.srcName = srcName;
-                       this.targetName = srcName;
-               }
-
-               @Override
-               public String toString() {
-                       return "[" + srcName + " to " + targetName + "]";
-               }
-       }
-
-       // private class WkspComparator extends ViewerComparator {
-       //
-       // }
-
-       private class WkspContentProvider implements IStructuredContentProvider {
-               private static final long serialVersionUID = -925058051598536307L;
-               // caches current repo
-               private Node currSourceNodeRepo;
-               private Repository currSourceRepo;
-               private Credentials currSourceCred;
-
-               private List<WkspObject> workspaces = new ArrayList<WkspObject>();
-
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-                       if (newInput != null && newInput instanceof Node) {
-                               Session session = null;
-                               try {
-                                       Node newRepoNode = (Node) newInput;
-                                       if (currSourceNodeRepo == null
-                                                       || !newRepoNode.getPath().equals(
-                                                                       currSourceNodeRepo.getPath())) {
-
-                                               // update cache
-                                               currSourceNodeRepo = newRepoNode;
-                                               currSourceRepo = RepoUtils.getRepository(
-                                                               repositoryFactory, keyring, currSourceNodeRepo);
-                                               currSourceCred = RepoUtils.getRepositoryCredentials(
-                                                               keyring, currSourceNodeRepo);
-
-                                               // reset workspace list
-                                               wkspViewer.setAllChecked(false);
-                                               workspaces.clear();
-                                               // FIXME make it more generic
-                                               session = currSourceRepo.login(currSourceCred,RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
-                                               // remove unvalid elements
-                                               for (String name : session.getWorkspace()
-                                                               .getAccessibleWorkspaceNames())
-                                                       // TODO implement a cleaner way to filter
-                                                       // workspaces out
-                                                       if (name.lastIndexOf('-') > 0) {
-                                                               WkspObject currWksp = new WkspObject(name);
-                                                               // compute wkspace size
-                                                               // TODO implement this
-                                                               // Session currSession = null;
-                                                               // try {
-                                                               // currSession = currSourceRepo.login(
-                                                               // currSourceCred, name);
-                                                               // currWksp.size = JcrUtils
-                                                               // .getNodeApproxSize(currSession
-                                                               // .getNode("/"));
-                                                               //
-                                                               // } catch (RepositoryException re) {
-                                                               // log.warn(
-                                                               // "unable to compute size of workspace "
-                                                               // + name, re);
-                                                               // } finally {
-                                                               // JcrUtils.logoutQuietly(currSession);
-                                                               // }
-                                                               workspaces.add(currWksp);
-                                                       }
-                                       }
-
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Unexpected error while "
-                                                       + "initializing fetch wizard", e);
-                               } finally {
-                                       JcrUtils.logoutQuietly(session);
-                               }
-                               viewer.refresh();
-                       }
-               }
-
-               public void dispose() {
-               }
-
-               public Object[] getElements(Object obj) {
-                       return workspaces.toArray();
-               }
-       }
-
-       // ////////////////////////////
-       // // Helpers
-
-       // populate available source repo list
-       private Map<String, Node> getSourceRepoUris() {
-               try {
-                       Node repoList = currSession.getNode(NodeUtils.getUserHome(
-                                       currSession).getPath()
-                                       + RepoConstants.REPOSITORIES_BASE_PATH);
-
-                       String targetRepoUri = null;
-                       if (targetRepoNode != null) {
-                               targetRepoUri = targetRepoNode
-                                               .getProperty(ArgeoNames.ARGEO_URI).getString();
-                       }
-                       NodeIterator ni = repoList.getNodes();
-                       // List<String> sourceRepoNames = new ArrayList<String>();
-                       // // caches a map of the source repo nodes with their URI as a key
-                       // // to ease further processing
-                       Map<String, Node> sourceReposMap = new HashMap<String, Node>();
-                       while (ni.hasNext()) {
-                               Node currNode = ni.nextNode();
-                               if (currNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
-                                       String currUri = currNode.getProperty(ArgeoNames.ARGEO_URI)
-                                                       .getString();
-                                       if (targetRepoUri == null || !targetRepoUri.equals(currUri)) {
-                                               sourceReposMap.put(currUri, currNode);
-                                               // sourceRepoNames.add(currUri);
-                                       }
-                               }
-                       }
-                       return sourceReposMap;
-                       // sourceRepoNames.toArray(new String[sourceRepoNames
-                       // .size()]);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Error while getting repo aliases", e);
-               }
-       }
-
-       public void setTargetRepoNode(Node targetRepoNode) {
-               this.targetRepoNode = targetRepoNode;
-       }
-
-       public void setSourceRepoNode(Node sourceRepoNode) {
-               this.sourceRepoNode = sourceRepoNode;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/GenerateBinariesWizard.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/GenerateBinariesWizard.java
deleted file mode 100644 (file)
index 1f353e0..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-package org.argeo.slc.client.ui.dist.wizards;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.ViewerUtils;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoService;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.maven.GenerateBinaries;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Define parameters to asynchronously generate binaries, sources and sdk pom
- * artifacts for this group using a {@link GenerateBinaries} runnable
- */
-public class GenerateBinariesWizard extends Wizard {
-       private final static Log log = LogFactory
-                       .getLog(GenerateBinariesWizard.class);
-
-       // Business objects
-       private final RepoService repoService;
-       private final String repoNodePath;
-       private String wkspName;
-       private String groupNodePath;
-
-       // The pages
-       private RecapPage recapPage;
-
-       // Controls with parameters
-       private Text versionTxt;
-       private Text latestVersionTxt;
-       private Text highestArtifactVersionTxt;
-
-       public GenerateBinariesWizard(RepoService repoService, String repoNodePath,
-                       String wkspName, String groupNodePath) {
-               super();
-               this.repoService = repoService;
-               this.repoNodePath = repoNodePath;
-               this.wkspName = wkspName;
-               this.groupNodePath = groupNodePath;
-       }
-
-       @Override
-       public void dispose() {
-               super.dispose();
-       }
-
-       @Override
-       public void addPages() {
-               try {
-                       recapPage = new RecapPage();
-                       addPage(recapPage);
-                       setWindowTitle("Define Binary Generation Procedure");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot add page to wizard ", e);
-               }
-       }
-
-       @Override
-       public boolean performFinish() {
-               if (!canFinish())
-                       return false;
-               try {
-                       String msg = "Your are about to generate binaries, sources and sdk "
-                                       + "pom artifacts for this group, "
-                                       + "do you really want to proceed ?";
-
-                       boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
-                                       .getWorkbench().getDisplay().getActiveShell(),
-                                       "Confirm Launch", msg);
-
-                       if (result) {
-                               GenerateBinaryJob job = new GenerateBinaryJob(repoService,
-                                               repoNodePath, wkspName, groupNodePath,
-                                               versionTxt.getText());
-                               job.setUser(true);
-                               job.schedule();
-                       }
-               } catch (Exception e) {
-                       throw new SlcException(
-                                       "Unexpected error while launching the fetch", e);
-               }
-               return true;
-       }
-
-       // ///////////////////////////////
-       // ////// THE PAGES
-       private class RecapPage extends WizardPage {
-               private static final long serialVersionUID = 904196417910874087L;
-               private TableViewer recapViewer;
-
-               public RecapPage() {
-                       super("Define parameters and launch");
-                       setTitle("Define parameters and launch");
-               }
-
-               @Override
-               public boolean isPageComplete() {
-                       return isCurrentPage();
-               }
-
-               public IWizardPage getNextPage() {
-                       return null; // always last
-               }
-
-               private void refreshValues() {
-                       Session session = null;
-                       try {
-                               session = repoService.getRemoteSession(repoNodePath, null,
-                                               wkspName);
-                               Node groupNode = session.getNode(groupNodePath);
-                               GenerateBinaries gb = GenerateBinaries.preProcessGroupNode(
-                                               groupNode, null);
-
-                               List<Artifact> binaries = new ArrayList<Artifact>();
-                               binaries.addAll(gb.getBinaries());
-
-                               Artifact highestVersion = gb.getHighestArtifactVersion();
-                               if (highestVersion != null)
-                                       highestArtifactVersionTxt.setText(highestVersion
-                                                       .getBaseVersion());
-
-                               if (groupNode.hasNode(RepoConstants.BINARIES_ARTIFACT_ID)) {
-                                       Node binaryNode = groupNode
-                                                       .getNode(RepoConstants.BINARIES_ARTIFACT_ID);
-                                       Artifact currHighestVersion = null;
-                                       for (NodeIterator ni = binaryNode.getNodes(); ni.hasNext();) {
-                                               Node currN = ni.nextNode();
-                                               if (currN
-                                                               .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
-                                                       Artifact currVersion = RepoUtils.asArtifact(currN);
-
-                                                       if (currHighestVersion == null
-                                                                       || currVersion.getBaseVersion()
-                                                                                       .compareTo(
-                                                                                                       currHighestVersion
-                                                                                                                       .getBaseVersion()) > 0)
-                                                               currHighestVersion = currVersion;
-                                               }
-                                       }
-                                       if (currHighestVersion != null)
-                                               latestVersionTxt.setText(currHighestVersion
-                                                               .getBaseVersion());
-                               }
-                               recapViewer.setInput(binaries);
-                               recapViewer.refresh();
-                       } catch (RepositoryException re) {
-                               throw new SlcException("Unable to get repositories URIs", re);
-                       } finally {
-                               JcrUtils.logoutQuietly(session);
-                       }
-               }
-
-               public void createControl(Composite parent) {
-                       setMessage("Configure Maven Indexing", IMessageProvider.NONE);
-
-                       Composite composite = new Composite(parent, SWT.NO_FOCUS);
-                       composite.setLayout(new GridLayout(2, false));
-
-                       versionTxt = createLT(composite, "Version");
-                       versionTxt
-                                       .setToolTipText("Enter a version for the new Modular Distribution");
-
-                       latestVersionTxt = createLT(composite, "Latest version");
-                       latestVersionTxt.setEditable(false);
-                       latestVersionTxt
-                                       .setToolTipText("The actual latest version of this modular distribution");
-
-                       highestArtifactVersionTxt = createLT(composite,
-                                       "Highest version in current category");
-                       highestArtifactVersionTxt.setEditable(false);
-                       highestArtifactVersionTxt
-                                       .setToolTipText("The highest version among all version of the below listed modules.");
-
-                       // Creates the table
-                       Table table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL
-                                       | SWT.BORDER);
-                       table.setLinesVisible(true);
-                       table.setHeaderVisible(true);
-                       table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2,
-                                       1));
-                       recapViewer = new TableViewer(table);
-
-                       TableViewerColumn column = ViewerUtils.createTableViewerColumn(
-                                       recapViewer, "Name", SWT.NONE, 250);
-                       column.setLabelProvider(new ColumnLabelProvider() {
-                               private static final long serialVersionUID = -9145709097621022043L;
-
-                               @Override
-                               public String getText(Object element) {
-                                       return ((Artifact) element).getArtifactId();
-                               }
-                       });
-
-                       column = ViewerUtils.createTableViewerColumn(recapViewer,
-                                       "Version", SWT.NONE, 250);
-                       column.setLabelProvider(new ColumnLabelProvider() {
-                               private static final long serialVersionUID = 5524185741667651628L;
-
-                               @Override
-                               public String getText(Object element) {
-                                       return ((Artifact) element).getBaseVersion();
-                               }
-                       });
-
-                       recapViewer.setContentProvider(new IStructuredContentProvider() {
-                               private static final long serialVersionUID = -4579434453554442858L;
-
-                               
-                               List<Artifact> artifacts;
-
-                               @SuppressWarnings("unchecked")
-                               public void inputChanged(Viewer viewer, Object oldInput,
-                                               Object newInput) {
-                                       artifacts = (List<Artifact>) newInput;
-                                       if (artifacts != null)
-                                               recapViewer.refresh();
-                               }
-
-                               public void dispose() {
-                               }
-
-                               public Object[] getElements(Object inputElement) {
-                                       return artifacts == null ? null : artifacts.toArray();
-                               }
-                       });
-
-                       // A basic comparator
-                       recapViewer.setComparator(new ViewerComparator());
-                       refreshValues();
-                       setControl(composite);
-               }
-       }
-
-       /**
-        * Define the privileged job that will be run asynchronously generate
-        * corresponding artifacts
-        */
-       private class GenerateBinaryJob extends PrivilegedJob {
-
-               private final RepoService repoService;
-               private final String repoNodePath;
-               private final String wkspName;
-               private final String groupNodePath;
-               private final String version;
-
-               public GenerateBinaryJob(RepoService repoService, String repoNodePath,
-                               String wkspName, String groupNodePath, String version) {
-                       super("Fetch");
-                       this.version = version;
-                       this.repoService = repoService;
-                       this.repoNodePath = repoNodePath;
-                       this.wkspName = wkspName;
-                       this.groupNodePath = groupNodePath;
-               }
-
-               @Override
-               protected IStatus doRun(IProgressMonitor progressMonitor) {
-                       Session session = null;
-                       try {
-                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
-                               session = repoService.getRemoteSession(repoNodePath, null,
-                                               wkspName);
-                               Node groupBaseNode = session.getNode(groupNodePath);
-                               GenerateBinaries.processGroupNode(groupBaseNode, version,
-                                               monitor);
-                       } catch (Exception e) {
-                               if (log.isDebugEnabled())
-                                       e.printStackTrace();
-                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
-                                               "Cannot normalize group", e);
-                       } finally {
-                               JcrUtils.logoutQuietly(session);
-                       }
-                       return Status.OK_STATUS;
-               }
-       }
-
-       // ////////////////////////////
-       // // Helpers
-       /** Creates label and text. */
-       protected Text createLT(Composite parent, String label) {
-               new Label(parent, SWT.NONE).setText(label);
-               Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER
-                               | SWT.NONE);
-               text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               return text;
-       }
-
-       /** Creates label and check. */
-       protected Button createLC(Composite parent, String label) {
-               new Label(parent, SWT.NONE).setText(label);
-               Button check = new Button(parent, SWT.CHECK);
-               check.setSelection(false);
-               check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               return check;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java
deleted file mode 100644 (file)
index 75a8015..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-package org.argeo.slc.client.ui.dist.wizards;
-
-import java.net.URI;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * 
- * Registers a new remote repository in the current Node.
- * 
- */
-public class RegisterRepoWizard extends Wizard {
-
-       // Business objects
-       private Keyring keyring;
-       private RepositoryFactory repositoryFactory;
-       private Repository nodeRepository;
-
-       // Pages
-       private DefineModelPage page;
-
-       // Widgets of model page
-       private Text name;
-       private Text uri;
-       private Text username;
-       private Text password;
-       private Button saveInKeyring;
-
-       // Default values
-       private final static String DEFAULT_NAME = "Argeo Public Repository";
-       private final static String DEFAULT_URI = "https://forge.argeo.org/jcr/java";
-       private final static String DEFAULT_USER_NAME = "anonymous";
-       private final static boolean DEFAULT_ANONYMOUS = true;
-
-       public RegisterRepoWizard(Keyring keyring, RepositoryFactory repositoryFactory, Repository nodeRepository) {
-               super();
-               this.keyring = keyring;
-               this.repositoryFactory = repositoryFactory;
-               this.nodeRepository = nodeRepository;
-       }
-
-       @Override
-       public void addPages() {
-               try {
-                       page = new DefineModelPage();
-                       addPage(page);
-                       setWindowTitle("Register a new remote repository");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot add page to wizard ", e);
-               }
-       }
-
-       @Override
-       public boolean performFinish() {
-               if (!canFinish())
-                       return false;
-
-               Session nodeSession = null;
-               try {
-                       nodeSession = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
-                       String reposPath = NodeUtils.getUserHome(nodeSession).getPath() + RepoConstants.REPOSITORIES_BASE_PATH;
-
-                       Node repos = nodeSession.getNode(reposPath);
-                       String repoNodeName = JcrUtils.replaceInvalidChars(name.getText());
-                       if (repos.hasNode(repoNodeName))
-                               throw new SlcException("There is already a remote repository named " + repoNodeName);
-
-                       // check if the same URI has already been registered
-                       NodeIterator ni = repos.getNodes();
-                       while (ni.hasNext()) {
-                               Node node = ni.nextNode();
-                               if (node.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY) && node.hasProperty(ArgeoNames.ARGEO_URI)
-                                               && node.getProperty(ArgeoNames.ARGEO_URI).getString().equals(uri.getText()))
-                                       throw new SlcException("This URI " + uri.getText() + " is already registered, "
-                                                       + "for the time being, only one instance of a single "
-                                                       + "repository at a time is implemented.");
-                       }
-
-                       Node repoNode = repos.addNode(repoNodeName, ArgeoTypes.ARGEO_REMOTE_REPOSITORY);
-                       repoNode.setProperty(ArgeoNames.ARGEO_URI, uri.getText());
-                       repoNode.setProperty(ArgeoNames.ARGEO_USER_ID, username.getText());
-                       repoNode.addMixin(NodeType.MIX_TITLE);
-                       repoNode.setProperty(Property.JCR_TITLE, name.getText());
-                       nodeSession.save();
-                       if (saveInKeyring.getSelection()) {
-                               String pwdPath = repoNode.getPath() + '/' + ArgeoNames.ARGEO_PASSWORD;
-                               keyring.set(pwdPath, password.getText().toCharArray());
-                               nodeSession.save();
-                       }
-                       MessageDialog.openInformation(getShell(), "Repository Added",
-                                       "Remote repository " + uri.getText() + "' added");
-               } catch (Exception e) {
-                       ErrorFeedback.show("Cannot add remote repository", e);
-               } finally {
-                       JcrUtils.logoutQuietly(nodeSession);
-               }
-               return true;
-       }
-
-       private class DefineModelPage extends WizardPage {
-               private static final long serialVersionUID = 874386824101995060L;
-
-               public DefineModelPage() {
-                       super("Main");
-                       setTitle("Fill information to register a repository");
-               }
-
-               public void createControl(Composite parent) {
-
-                       // main layout
-                       Composite composite = new Composite(parent, SWT.NONE);
-                       composite.setLayout(new GridLayout(2, false));
-                       composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
-                       // Create various fields
-                       // setMessage("Login to remote repository", IMessageProvider.NONE);
-                       name = createLT(composite, "Name", DEFAULT_NAME);
-                       uri = createLT(composite, "URI", DEFAULT_URI);
-
-                       final Button anonymousLogin = createLC(composite, "Log as anonymous", true);
-                       anonymousLogin.addSelectionListener(new SelectionListener() {
-                               private static final long serialVersionUID = 4874716406036981039L;
-
-                               public void widgetSelected(SelectionEvent e) {
-                                       if (anonymousLogin.getSelection()) {
-                                               username.setText(DEFAULT_USER_NAME);
-                                               password.setText("");
-                                               username.setEnabled(false);
-                                               password.setEnabled(false);
-                                       } else {
-                                               username.setText("");
-                                               password.setText("");
-                                               username.setEnabled(true);
-                                               password.setEnabled(true);
-                                       }
-                               }
-
-                               public void widgetDefaultSelected(SelectionEvent e) {
-                               }
-                       });
-
-                       username = createLT(composite, "User", DEFAULT_USER_NAME);
-                       password = createLP(composite, "Password");
-                       saveInKeyring = createLC(composite, "Remember password", false);
-
-                       if (DEFAULT_ANONYMOUS) {
-                               username.setEnabled(false);
-                               password.setEnabled(false);
-                       }
-
-                       Button test = createButton(composite, "Test");
-                       GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1);
-                       gd.widthHint = 140;
-                       test.setLayoutData(gd);
-
-                       test.addSelectionListener(new SelectionAdapter() {
-                               private static final long serialVersionUID = -4034851916548656293L;
-
-                               public void widgetSelected(SelectionEvent arg0) {
-                                       testConnection();
-                               }
-                       });
-
-                       // Compulsory
-                       setControl(composite);
-               }
-
-               /** Creates label and text. */
-               protected Text createLT(Composite parent, String label, String initial) {
-                       new Label(parent, SWT.RIGHT).setText(label);
-                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
-                       text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
-                       text.setText(initial);
-                       return text;
-               }
-
-               /** Creates label and check. */
-               protected Button createLC(Composite parent, String label, Boolean initial) {
-                       new Label(parent, SWT.RIGHT).setText(label);
-                       Button check = new Button(parent, SWT.CHECK);
-                       check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-                       check.setSelection(initial);
-                       return check;
-               }
-
-               /** Creates a button with a label. */
-               protected Button createButton(Composite parent, String label) {
-                       Button button = new Button(parent, SWT.PUSH);
-                       button.setText(label);
-                       button.setFont(JFaceResources.getDialogFont());
-                       setButtonLayoutData(button);
-                       return button;
-               }
-
-               /** Creates label and password field */
-               protected Text createLP(Composite parent, String label) {
-                       new Label(parent, SWT.NONE).setText(label);
-                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER | SWT.PASSWORD);
-                       text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-                       return text;
-               }
-
-       }
-
-       void testConnection() {
-               Session session = null;
-               try {
-                       if (uri.getText().startsWith("http")) {// http, https
-                               URI checkedUri = new URI(uri.getText());
-                               String checkedUriStr = checkedUri.toString();
-                               Repository repository = NodeUtils.getRepositoryByUri(repositoryFactory, checkedUriStr);
-                               if (username.getText().trim().equals("")) {// anonymous
-                                       session = repository.login(RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
-                               } else {
-                                       char[] pwd = password.getTextChars();
-                                       SimpleCredentials sc = new SimpleCredentials(username.getText(), pwd);
-                                       session = repository.login(sc, RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
-                               }
-                       } else {// alias
-                               Repository repository = NodeUtils.getRepositoryByAlias(repositoryFactory, uri.getText());
-                               session = repository.login();
-                       }
-                       MessageDialog.openInformation(getShell(), "Success", "Connection to '" + uri.getText() + "' successful");
-               } catch (Exception e) {
-                       ErrorFeedback.show("Connection test failed for " + uri.getText(), e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/.classpath b/cms/org.argeo.slc.client.ui/.classpath
deleted file mode 100644 (file)
index 120e381..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="output" path="target/classes"/>
-</classpath>
diff --git a/cms/org.argeo.slc.client.ui/.gitignore b/cms/org.argeo.slc.client.ui/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/cms/org.argeo.slc.client.ui/.project b/cms/org.argeo.slc.client.ui/.project
deleted file mode 100644 (file)
index ed71a2e..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.client.ui</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/cms/org.argeo.slc.client.ui/.settings/org.eclipse.jdt.core.prefs b/cms/org.argeo.slc.client.ui/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index 95d6b05..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#Wed Aug 04 16:31:36 CEST 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/cms/org.argeo.slc.client.ui/.settings/org.eclipse.pde.core.prefs b/cms/org.argeo.slc.client.ui/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644 (file)
index 31cbfae..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tue Jul 27 14:24:51 CEST 2010
-eclipse.preferences.version=1
-resolve.requirebundle=false
diff --git a/cms/org.argeo.slc.client.ui/META-INF/.gitignore b/cms/org.argeo.slc.client.ui/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.client.ui/META-INF/spring/commands.xml b/cms/org.argeo.slc.client.ui/META-INF/spring/commands.xml
deleted file mode 100644 (file)
index 6ed132d..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-       <bean id="updateModule"
-               class="org.argeo.slc.client.ui.commands.UpdateModule"
-               scope="prototype">
-               <property name="modulesManager" ref="modulesManager"/>
-       </bean>
-<!--   <bean name="runSlc/Flow" -->
-<!--           class="org.argeo.slc.client.ui.commands.RunSlcFlow" -->
-<!--           scope="prototype"> -->
-<!--           <property name="modulesManager" ref="modulesManager"/> -->
-<!--   </bean> -->
-
-       <!-- Result list view commands-->
-<!--   <bean id="org.argeo.slc.client.ui.refreshResultList" -->
-<!--           class="org.argeo.slc.client.ui.commands.ResultListViewRefreshHandler" -->
-<!--           scope="prototype"> -->
-<!--   </bean> -->
-
-<!--   <bean id="org.argeo.slc.client.ui.removeSelectedResultFromResultList" -->
-<!--           class="org.argeo.slc.client.ui.commands.RemoveSelectedResultFromResultList" -->
-<!--           scope="prototype"> -->
-<!--   </bean> -->
-
-
-<!--   <bean id="org.argeo.slc.client.ui.refreshExecutionModulesView" -->
-<!--           class="org.argeo.slc.client.ui.commands.ExecutionModulesViewRefreshHandler" -->
-<!--           scope="prototype"> -->
-<!--   </bean> -->
-<!--   <bean id="org.argeo.slc.client.ui.refreshProcessList" -->
-<!--           class="org.argeo.slc.client.ui.commands.ProcessListViewRefreshHandler" -->
-<!--           scope="prototype"> -->
-<!--   </bean> -->
-<!--   <bean id="org.argeo.slc.client.ui.displayProcessDetails" -->
-<!--           class="org.argeo.slc.client.ui.commands.ProcessDetailsDisplayHandler" -->
-<!--           scope="prototype"> -->
-<!--   </bean> -->
-<!--   <bean id="org.argeo.slc.client.ui.displayResultDetails" -->
-<!--           class="org.argeo.slc.client.ui.commands.ResultDetailsDisplayHandler" -->
-<!--           scope="prototype"> -->
-<!--   </bean> -->
-<!--   <bean id="org.argeo.slc.client.ui.launchBatch" class="org.argeo.slc.client.ui.commands.LaunchBatchHandler" -->
-<!--           scope="prototype"> -->
-<!--   </bean> -->
-<!--   <bean id="org.argeo.slc.client.ui.removeSelectedFromBatch" -->
-<!--           class="org.argeo.slc.client.ui.commands.RemoveSelectedProcessFromBatchHandler" -->
-<!--           scope="prototype"> -->
-<!--   </bean> -->
-<!--   <bean id="org.argeo.slc.client.ui.clearBatch" class="org.argeo.slc.client.ui.commands.ClearBatchHandler" -->
-<!--           scope="prototype"> -->
-<!--   </bean> -->
-<!--   <bean id="org.argeo.slc.client.ui.manageBundles" class="org.argeo.slc.client.ui.commands.ManageBundlesHandler" -->
-<!--           scope="prototype"> -->
-<!--   </bean>  -->
-</beans>
diff --git a/cms/org.argeo.slc.client.ui/META-INF/spring/controllers.xml b/cms/org.argeo.slc.client.ui/META-INF/spring/controllers.xml
deleted file mode 100644 (file)
index 774b9da..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-       <bean id="processController" class="org.argeo.slc.client.ui.controllers.ProcessController">
-               <property name="agent" ref="agent" />
-       </bean>
-</beans>
diff --git a/cms/org.argeo.slc.client.ui/META-INF/spring/editors.xml b/cms/org.argeo.slc.client.ui/META-INF/spring/editors.xml
deleted file mode 100644 (file)
index fd98808..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-       <bean id="processEditor" class="org.argeo.slc.client.ui.editors.ProcessEditor"
-               scope="prototype">
-               <property name="processController" ref="processController" />
-               <property name="modulesManager" ref="modulesManager" />
-               <property name="repository" ref="repository" />
-       </bean>
-</beans>
diff --git a/cms/org.argeo.slc.client.ui/META-INF/spring/osgi.xml b/cms/org.argeo.slc.client.ui/META-INF/spring/osgi.xml
deleted file mode 100644 (file)
index 79eb6bc..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xmlns:osgi="http://www.springframework.org/schema/osgi"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
-       osgi:default-timeout="30000">\r
-\r
-       <beans:description>SLC UI</beans:description>\r
-\r
-       <!-- REFERENCES -->\r
-       <reference id="repository" interface="javax.jcr.Repository"\r
-               filter="(cn=ego)" />\r
-\r
-       <reference id="agent" interface="org.argeo.slc.execution.SlcAgent" />\r
-\r
-       <reference id="modulesManager"\r
-               interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
-</beans:beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/META-INF/spring/views.xml b/cms/org.argeo.slc.client.ui/META-INF/spring/views.xml
deleted file mode 100644 (file)
index eca8f68..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-       <bean id="jcrExecutionModulesView" class="org.argeo.slc.client.ui.views.JcrExecutionModulesView"
-               scope="prototype">
-               <property name="repository" ref="repository" />
-               <property name="modulesManager" ref="modulesManager" />
-       </bean>
-
-       <bean id="jcrProcessListView" class="org.argeo.slc.client.ui.views.JcrProcessListView"
-               scope="prototype">
-               <property name="repository" ref="repository" />
-       </bean>
-
-       <bean id="jcrResultListView" class="org.argeo.slc.client.ui.views.JcrResultListView"
-               scope="prototype">
-               <property name="repository" ref="repository" />
-       </bean>
-
-       <bean id="jcrResultTreeView" class="org.argeo.slc.client.ui.views.JcrResultTreeView"
-               scope="prototype">
-               <property name="repository" ref="repository" />
-       </bean>
-
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/bnd.bnd b/cms/org.argeo.slc.client.ui/bnd.bnd
deleted file mode 100644 (file)
index d24c331..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-Bundle-SymbolicName: org.argeo.slc.client.ui;singleton=true
-Bundle-ActivationPolicy: lazy
-Require-Bundle: org.eclipse.ui;resolution:=optional,\
-org.eclipse.core.runtime,\
-org.eclipse.rap.ui;resolution:=optional,\
-org.eclipse.rap.ui.workbench;resolution:=optional
-
-Bundle-Activator: org.argeo.slc.client.ui.ClientUiPlugin
-Import-Package: org.argeo.eclipse.spring,\
-org.argeo.api,\
-org.eclipse.core.runtime,\
-org.osgi.*;version=0.0.0,\
-*
diff --git a/cms/org.argeo.slc.client.ui/build.properties b/cms/org.argeo.slc.client.ui/build.properties
deleted file mode 100644 (file)
index 54c55c6..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-source.. = src
-bin.includes = plugin.xml,\
-               META-INF/,\
-               .,\
-               icons/
diff --git a/cms/org.argeo.slc.client.ui/icons/agent.gif b/cms/org.argeo.slc.client.ui/icons/agent.gif
deleted file mode 100644 (file)
index 0a1fa96..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/agent.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/agentFactory.gif b/cms/org.argeo.slc.client.ui/icons/agentFactory.gif
deleted file mode 100644 (file)
index b51ae39..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/agentFactory.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/archive.png b/cms/org.argeo.slc.client.ui/icons/archive.png
deleted file mode 100644 (file)
index fb36f36..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/archive.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/batch.gif b/cms/org.argeo.slc.client.ui/icons/batch.gif
deleted file mode 100644 (file)
index b8ca14a..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/batch.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/choices.gif b/cms/org.argeo.slc.client.ui/icons/choices.gif
deleted file mode 100644 (file)
index da2f577..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/choices.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/clear_batch.gif b/cms/org.argeo.slc.client.ui/icons/clear_batch.gif
deleted file mode 100644 (file)
index 28a3785..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/clear_batch.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/computer.png b/cms/org.argeo.slc.client.ui/icons/computer.png
deleted file mode 100644 (file)
index ff64b84..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/computer.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/edit_parameters.gif b/cms/org.argeo.slc.client.ui/icons/edit_parameters.gif
deleted file mode 100644 (file)
index 94eedf6..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/edit_parameters.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/error.gif b/cms/org.argeo.slc.client.ui/icons/error.gif
deleted file mode 100644 (file)
index 64b4384..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/error.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/excel.png b/cms/org.argeo.slc.client.ui/icons/excel.png
deleted file mode 100644 (file)
index eb6158e..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/excel.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/executionError.gif b/cms/org.argeo.slc.client.ui/icons/executionError.gif
deleted file mode 100644 (file)
index e861399..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/executionError.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/executionPassed.gif b/cms/org.argeo.slc.client.ui/icons/executionPassed.gif
deleted file mode 100644 (file)
index 20fc2f2..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/executionPassed.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/executionSpec.gif b/cms/org.argeo.slc.client.ui/icons/executionSpec.gif
deleted file mode 100644 (file)
index 1ff93cb..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/executionSpec.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/executionSpecAttribute.gif b/cms/org.argeo.slc.client.ui/icons/executionSpecAttribute.gif
deleted file mode 100644 (file)
index bee687c..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/executionSpecAttribute.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/executionSpecs.gif b/cms/org.argeo.slc.client.ui/icons/executionSpecs.gif
deleted file mode 100644 (file)
index 0b63124..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/executionSpecs.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/execution_module.gif b/cms/org.argeo.slc.client.ui/icons/execution_module.gif
deleted file mode 100644 (file)
index 983932f..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/execution_module.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/failed.gif b/cms/org.argeo.slc.client.ui/icons/failed.gif
deleted file mode 100644 (file)
index 3e9d893..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/failed.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/flow.png b/cms/org.argeo.slc.client.ui/icons/flow.png
deleted file mode 100644 (file)
index 114193f..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/flow.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/folder.gif b/cms/org.argeo.slc.client.ui/icons/folder.gif
deleted file mode 100644 (file)
index 42e027c..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/folder.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/folder.png b/cms/org.argeo.slc.client.ui/icons/folder.png
deleted file mode 100644 (file)
index 6937ed4..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/folder.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/kill.png b/cms/org.argeo.slc.client.ui/icons/kill.png
deleted file mode 100644 (file)
index cfbf9d1..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/kill.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/launch.gif b/cms/org.argeo.slc.client.ui/icons/launch.gif
deleted file mode 100644 (file)
index ec477ea..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/launch.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/module.png b/cms/org.argeo.slc.client.ui/icons/module.png
deleted file mode 100644 (file)
index 0afea5b..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/module.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/module_stopped.gif b/cms/org.argeo.slc.client.ui/icons/module_stopped.gif
deleted file mode 100644 (file)
index c88284a..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/module_stopped.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/myResult.png b/cms/org.argeo.slc.client.ui/icons/myResult.png
deleted file mode 100644 (file)
index 93053b7..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/myResult.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/passed.gif b/cms/org.argeo.slc.client.ui/icons/passed.gif
deleted file mode 100644 (file)
index 23c97f0..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/passed.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/process_completed.png b/cms/org.argeo.slc.client.ui/icons/process_completed.png
deleted file mode 100644 (file)
index 0ad64e7..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/process_completed.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/process_details.gif b/cms/org.argeo.slc.client.ui/icons/process_details.gif
deleted file mode 100644 (file)
index c81630a..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/process_details.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/process_error.png b/cms/org.argeo.slc.client.ui/icons/process_error.png
deleted file mode 100644 (file)
index e66c98e..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/process_error.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/process_running.png b/cms/org.argeo.slc.client.ui/icons/process_running.png
deleted file mode 100644 (file)
index 471c091..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/process_running.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/process_scheduled.gif b/cms/org.argeo.slc.client.ui/icons/process_scheduled.gif
deleted file mode 100644 (file)
index b7f03d5..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/process_scheduled.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/processes.gif b/cms/org.argeo.slc.client.ui/icons/processes.gif
deleted file mode 100644 (file)
index 364c0e7..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/processes.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/processes.png b/cms/org.argeo.slc.client.ui/icons/processes.png
deleted file mode 100644 (file)
index 364c0e7..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/processes.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/refresh.png b/cms/org.argeo.slc.client.ui/icons/refresh.png
deleted file mode 100644 (file)
index a3884fb..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/refresh.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/relaunch.gif b/cms/org.argeo.slc.client.ui/icons/relaunch.gif
deleted file mode 100644 (file)
index 8f943a8..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/relaunch.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/removeAll.png b/cms/org.argeo.slc.client.ui/icons/removeAll.png
deleted file mode 100644 (file)
index 73053c4..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/removeAll.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/remove_one.gif b/cms/org.argeo.slc.client.ui/icons/remove_one.gif
deleted file mode 100644 (file)
index 2cd9c54..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/remove_one.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/rename.png b/cms/org.argeo.slc.client.ui/icons/rename.png
deleted file mode 100644 (file)
index a388417..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/rename.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/result_details.gif b/cms/org.argeo.slc.client.ui/icons/result_details.gif
deleted file mode 100644 (file)
index 4017f6d..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/result_details.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/results.gif b/cms/org.argeo.slc.client.ui/icons/results.gif
deleted file mode 100644 (file)
index 0dc862c..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/results.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/slc_execution_perspective.gif b/cms/org.argeo.slc.client.ui/icons/slc_execution_perspective.gif
deleted file mode 100644 (file)
index b8ca14a..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/slc_execution_perspective.gif and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/icons/system.png b/cms/org.argeo.slc.client.ui/icons/system.png
deleted file mode 100644 (file)
index 71f44d0..0000000
Binary files a/cms/org.argeo.slc.client.ui/icons/system.png and /dev/null differ
diff --git a/cms/org.argeo.slc.client.ui/plugin.xml b/cms/org.argeo.slc.client.ui/plugin.xml
deleted file mode 100644 (file)
index b446629..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
-       <!-- Views --> 
-   <extension
-         point="org.eclipse.ui.views">
-          <view
-                id="org.argeo.slc.client.ui.jcrExecutionModulesView"
-                class="org.argeo.eclipse.spring.SpringExtensionFactory"
-                icon="icons/execution_module.gif"
-                name="Execution"
-                restorable="true">
-          </view>
-          <view
-                id="org.argeo.slc.client.ui.jcrResultListView"
-                class="org.argeo.eclipse.spring.SpringExtensionFactory"
-                icon="icons/results.gif"
-                name="Results"
-                restorable="true">
-          </view>
-          <view
-                id="org.argeo.slc.client.ui.jcrResultTreeView"
-                class="org.argeo.eclipse.spring.SpringExtensionFactory"
-                icon="icons/results.gif"
-                name="Results"
-                restorable="true">
-          </view>
-          <view
-                id="org.argeo.slc.client.ui.jcrProcessListView"
-                class="org.argeo.eclipse.spring.SpringExtensionFactory"
-                name="Processes"
-                icon="icons/processes.gif"
-                restorable="true">
-          </view>
-   </extension>
-       
-       <!-- Commands definitions --> 
-       <extension
-       point="org.eclipse.ui.commands">
-               <command
-               defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-               id="org.argeo.slc.client.ui.updateModule"
-               name="Update Module">
-           </command>
-           
-           <!-- Commands that do not need dependency injection --> 
-           <command
-               defaultHandler="org.argeo.slc.client.ui.commands.AddResultFolder"
-               id="org.argeo.slc.client.ui.addResultFolder"
-               name="Add result folder">
-           </command>
-           <command
-               id="org.argeo.slc.client.ui.deleteItems"
-            defaultHandler="org.argeo.slc.client.ui.commands.DeleteItems"
-            name="Delete selected item(s)">
-       </command>
-           <command
-               defaultHandler="org.argeo.slc.client.ui.commands.RenameResultFolder"
-               id="org.argeo.slc.client.ui.renameResultFolder"
-               name="Rename folder">
-           </command>
-           <command
-               defaultHandler="org.argeo.slc.client.ui.commands.RenameResultNode"
-               id="org.argeo.slc.client.ui.renameResultNode"
-               name="Rename result">
-           </command>
-           <command
-               defaultHandler="org.argeo.slc.client.ui.commands.RefreshJcrResultTreeView"
-               id="org.argeo.slc.client.ui.refreshJcrResultTreeView"
-               name="Refresh">
-               <commandParameter
-                       id="org.argeo.slc.client.ui.param.refreshType"
-                       name="Refresh type">
-                       </commandParameter>
-           </command>
-    </extension>
-   
-       <!-- Menu definitions -->
-       <extension
-       id="menu:org.eclipse.ui.main.menu"
-        point="org.eclipse.ui.menus">
-               <menuContribution
-               locationURI="toolbar:org.argeo.slc.client.ui.jcrExecutionModulesView">
-                       <command
-                               commandId="org.argeo.slc.client.ui.updateModule"
-                               icon="icons/refresh.png"
-                               label="Update module"
-                               tooltip="Update module">
-                       </command>
-               </menuContribution>   
-       </extension>
-   <extension
-         point="org.eclipse.ui.perspectives">
-      <perspective
-            class="org.argeo.slc.client.ui.SlcExecutionPerspective"
-            icon="icons/slc_execution_perspective.gif"
-            id="org.argeo.slc.client.ui.slcExecutionPerspective"
-            name="SLC Execution">
-      </perspective>
-   </extension>
-   <extension
-         point="org.eclipse.ui.editors">
-      <editor
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            default="false"
-            icon="icons/batch.gif"
-            id="org.argeo.slc.client.ui.processEditor"
-            name="Process">
-      </editor>
-   </extension>
-   <extension
-         point="org.eclipse.ui.elementFactories">
-      <factory
-            class="org.argeo.slc.client.ui.editors.ProcessEditorInputFactory"
-            id="org.argeo.slc.client.ui.processEditorInputFactory">
-      </factory>
-   </extension>
-   <extension
-           point="org.eclipse.ui.activities">
-     </extension>
-  <extension
-           point="org.eclipse.ui.activities">
-        <activity
-              description="SLC users"
-              id="org.argeo.slc.client.ui.slcActivity"
-              name="SLC">
-                 <enabledWhen>
-                   <with variable="roles">
-                     <iterate ifEmpty="false" operator="or">
-                       <equals value="cn=org.argeo.slc.user,ou=roles,ou=node" />
-                     </iterate>
-                   </with>
-                 </enabledWhen>
-        </activity>
-        <!-- TODO: find a way to exclude evrything -->
-        <activityPatternBinding
-              activityId="org.argeo.slc.client.ui.slcActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.slc.client.ui/org.argeo.slc.client.ui.slcExecutionPerspective">
-        </activityPatternBinding>
-        <activityPatternBinding
-              activityId="org.argeo.security.ui.adminActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.slc.client.ui/org.argeo.slc.client.ui.slcExecutionPerspective">
-        </activityPatternBinding>
-        <activityPatternBinding
-              activityId="org.argeo.security.ui.adminActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.jcr.ui.explorer/org.argeo.jcr.ui.explorer.perspective">
-        </activityPatternBinding>
-        <activityPatternBinding
-              activityId="org.argeo.security.ui.adminActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.security.ui/org.argeo.security.ui.userHomePerspective">
-        </activityPatternBinding>
-  </extension>
-</plugin>
diff --git a/cms/org.argeo.slc.client.ui/pom.xml b/cms/org.argeo.slc.client.ui/pom.xml
deleted file mode 100644 (file)
index 919b0b7..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.client.ui</artifactId>
-       <name>SLC Client UI</name>
-       <packaging>jar</packaging>
-       <dependencies>
-               <!-- SLC -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.spring</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Argeo Commons -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.api</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.eclipse.ui</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.eclipse.ui.rap</artifactId>
-                       <version>${version.argeo-commons}</version>
-                       <scope>provided</scope>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc.legacy.commons</groupId>
-                       <artifactId>org.argeo.cms.ui.workbench</artifactId>
-                       <version>${version.argeo-commons-legacy}</version>
-               </dependency>
-
-               <!-- RAP workbench -->
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>argeo-tp-rap-e3</artifactId>
-                       <version>${version.argeo-tp}</version>
-                       <type>pom</type>
-                       <scope>provided</scope>
-               </dependency>
-
-       </dependencies>
-</project>
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/ClientUiPlugin.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/ClientUiPlugin.java
deleted file mode 100644 (file)
index abf62a0..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.argeo.slc.client.ui;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.BasicNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.deploy.ModulesManager;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/** The activator class controls the plug-in life cycle */
-public class ClientUiPlugin extends AbstractUIPlugin implements SlcNames {
-       public static final String ID = "org.argeo.slc.client.ui";
-       private static ClientUiPlugin plugin;
-
-       public void start(BundleContext context) throws Exception {
-               super.start(context);
-               plugin = this;
-       }
-
-       public void stop(BundleContext context) throws Exception {
-               plugin = null;
-               super.stop(context);
-       }
-
-       public static ClientUiPlugin getDefault() {
-               return plugin;
-       }
-
-       /** Creates the image */
-       public static Image img(String path) {
-               return getImageDescriptor(path).createImage();
-       }
-
-       public static ImageDescriptor getImageDescriptor(String path) {
-               return imageDescriptorFromPlugin(ID, path);
-       }
-
-       /** Start execution module if it was stopped and vice-versa */
-       public static void startStopExecutionModule(
-                       final ModulesManager modulesManager, Node node) {
-               try {
-                       if (!node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE))
-                               throw new SlcException(node + " is not an execution module");
-
-                       String name = node.getProperty(SLC_NAME).getString();
-                       String version = node.getProperty(SLC_VERSION).getString();
-                       final NameVersion nameVersion = new BasicNameVersion(name, version);
-                       Boolean started = node.getProperty(SLC_STARTED).getBoolean();
-
-                       Job job;
-                       if (started) {
-                               job = new Job("Stop " + nameVersion) {
-                                       protected IStatus run(IProgressMonitor monitor) {
-                                               monitor.beginTask("Stop " + nameVersion, 1);
-                                               modulesManager.stop(nameVersion);
-                                               monitor.worked(1);
-                                               return Status.OK_STATUS;
-                                       }
-
-                                       protected void canceling() {
-                                               getThread().interrupt();
-                                               super.canceling();
-                                       }
-                               };
-                       } else {
-                               job = new Job("Start " + nameVersion) {
-                                       protected IStatus run(IProgressMonitor monitor) {
-                                               monitor.beginTask("Start " + nameVersion, 1);
-                                               modulesManager.start(nameVersion);
-                                               monitor.worked(1);
-                                               return Status.OK_STATUS;
-                                       }
-
-                                       protected void canceling() {
-                                               getThread().interrupt();
-                                               super.canceling();
-                                       }
-                               };
-                       }
-                       job.setUser(true);
-                       job.schedule();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot start " + node, e);
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcExecutionPerspective.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcExecutionPerspective.java
deleted file mode 100644 (file)
index 7e9cc52..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.argeo.slc.client.ui;
-
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Perspective to manage SLC execution flows. */
-public class SlcExecutionPerspective implements IPerspectiveFactory {
-
-       public void createInitialLayout(IPageLayout layout) {
-               String editorArea = layout.getEditorArea();
-               layout.setEditorAreaVisible(true);
-               layout.setFixed(false);
-
-               IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
-                               0.35f, editorArea);
-               left.addView(ClientUiPlugin.ID + ".jcrExecutionModulesView");
-               // left.addView(ClientUiPlugin.ID + ".jcrResultListView");
-               left.addView(ClientUiPlugin.ID + ".jcrResultTreeView");
-               // Sleak view for SWT resource debugging
-               // left.addView("org.eclipse.swt.tools.views.SleakView");
-
-               IFolderLayout bottom = layout.createFolder("bottom",
-                               IPageLayout.BOTTOM, 0.65f, editorArea);
-//             BOTTOM.ADDVIEW(SECURITYUIPLUGIN.PLUGIN_ID + ".LOGVIEW");
-               bottom.addView(ClientUiPlugin.ID + ".jcrProcessListView");
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcImages.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcImages.java
deleted file mode 100644 (file)
index c93ec9b..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.argeo.slc.client.ui;
-
-import static org.argeo.slc.client.ui.ClientUiPlugin.getImageDescriptor;
-import static org.argeo.slc.client.ui.ClientUiPlugin.img;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-
-/** Shared images. */
-public class SlcImages {
-       public final static Image AGENT = img("icons/agent.gif");
-       public final static Image AGENT_FACTORY = img("icons/agentFactory.gif");
-       public final static Image MODULE = img("icons/module.png");
-       public final static Image MODULE_STOPPED = img("icons/module_stopped.gif");
-       public final static Image FOLDER = img("icons/folder.gif");
-       public final static Image MY_RESULTS_FOLDER = img("icons/myResult.png");
-       public final static Image RENAME = img("icons/rename.png");
-       public final static Image FLOW = img("icons/flow.png");
-       public final static Image PROCESSES = img("icons/processes.gif");
-       public final static Image PASSED = img("icons/passed.gif");
-       public final static Image ERROR = img("icons/error.gif");
-       public final static Image LAUNCH = img("icons/launch.gif");
-       public final static Image RELAUNCH = img("icons/relaunch.gif");
-       public final static Image KILL = img("icons/kill.png");
-       public final static Image REMOVE_ONE = img("icons/remove_one.gif");
-       public final static Image REMOVE_ALL = img("icons/removeAll.png");
-       public final static Image EXECUTION_SPECS = img("icons/executionSpecs.gif");
-       public final static Image EXECUTION_SPEC = img("icons/executionSpec.gif");
-       public final static Image EXECUTION_SPEC_ATTRIBUTE = img("icons/executionSpecAttribute.gif");
-       public final static Image CHOICES = img("icons/choices.gif");
-       public final static Image PROCESS_ERROR = img("icons/process_error.png");
-       public final static Image PROCESS_SCHEDULED = img("icons/process_scheduled.gif");
-       public final static Image PROCESS_RUNNING = img("icons/process_running.png");
-       public final static Image PROCESS_COMPLETED = img("icons/process_completed.png");
-
-       // Decorators
-       public final static ImageDescriptor EXECUTION_ERROR = getImageDescriptor("icons/executionError.gif");
-       public final static ImageDescriptor EXECUTION_PASSED = getImageDescriptor("icons/executionPassed.gif");
-
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcUiConstants.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcUiConstants.java
deleted file mode 100644 (file)
index 27d05d6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.argeo.slc.client.ui;
-
-/** SLC UI common constants */
-public interface SlcUiConstants {
-
-       /*
-        * Labels
-        */
-       public final static String DEFAULT_MY_RESULTS_FOLDER_LABEL = "My Results";
-       
-       /*
-        * MISCEALLENEOUS
-        */
-       public final static String DEFAULT_DISPLAY_DATE_TIME_FORMAT = "yyyy-MM-dd, HH:mm:ss";
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/AddResultFolder.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/AddResultFolder.java
deleted file mode 100644 (file)
index 5cc8b65..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.argeo.slc.client.ui.commands;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.eclipse.ui.dialogs.SingleValue;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.ParentNodeFolder;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Add a new SlcType.SLC_RESULT_FOLDER node to the current user "my result"
- * tree. This handler is only intended to bu used with JcrResultTreeView and its
- * descendants.
- */
-
-public class AddResultFolder extends AbstractHandler {
-       public final static String ID = ClientUiPlugin.ID + ".addResultFolder";
-       public final static String DEFAULT_ICON_REL_PATH = "icons/addFolder.gif";
-       public final static String DEFAULT_LABEL = "Add folder...";
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               IStructuredSelection selection = (IStructuredSelection) HandlerUtil
-                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
-
-               // Sanity check, already done when populating the corresponding popup
-               // menu.
-               if (selection != null && selection.size() == 1) {
-                       Object obj = selection.getFirstElement();
-                       try {
-                               Node parentNode = null;
-                               if (obj instanceof ResultFolder) {
-                                       ResultFolder rf = (ResultFolder) obj;
-                                       parentNode = rf.getNode();
-                               } else if (obj instanceof ParentNodeFolder) {
-                                       Node node = ((ParentNodeFolder) obj).getNode();
-                                       if (node.getPath().startsWith(
-                                                       SlcJcrResultUtils.getMyResultsBasePath(node
-                                                                       .getSession())))
-                                               parentNode = node;
-                               }
-
-                               if (parentNode != null) {
-                                       String folderName = SingleValue.ask("Folder name",
-                                                       "Enter folder name");
-                                       if (folderName != null) {
-                                               if (folderName.contains("/")) {
-                                                       ErrorFeedback
-                                                                       .show("Folder names can't contain a '/'.");
-                                                       return null;
-                                               }
-
-                                               String absPath = parentNode.getPath() + "/"
-                                                               + folderName;
-                                               SlcJcrResultUtils.createResultFolderNode(
-                                                               parentNode.getSession(), absPath);
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "Unexpected exception while creating result folder", e);
-                       }
-               } else {
-                       ErrorFeedback.show("Can only add file folder to a node");
-               }
-               return null;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/DeleteItems.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/DeleteItems.java
deleted file mode 100644 (file)
index 7401667..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.argeo.slc.client.ui.commands;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.model.ResultParentUtils;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Deletes one or many results */
-public class DeleteItems extends AbstractHandler {
-       public final static String ID = ClientUiPlugin.ID + ".deleteItems";
-       public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
-                       .getImageDescriptor("icons/removeAll.png");
-       public final static String DEFAULT_LABEL = "Delete selected item(s)";
-
-       public Object execute(final ExecutionEvent event) throws ExecutionException {
-               final ISelection selection = HandlerUtil
-                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
-
-               // confirmation
-               StringBuilder buf = new StringBuilder("");
-               Iterator<?> lst = ((IStructuredSelection) selection).iterator();
-               while (lst.hasNext()) {
-                       Object obj = lst.next();
-                       if (obj instanceof ResultParent) {
-                               ResultParent rp = ((ResultParent) obj);
-                               buf.append(rp.getName()).append(", ");
-                       }
-               }
-
-               String msg = "Nothing to delete";
-               // remove last separator
-               if (buf.lastIndexOf(", ") > -1) {
-                       msg = "Do you want to delete following objects (and their children): "
-                                       + buf.substring(0, buf.lastIndexOf(", ")) + "?";
-               }
-               Boolean ok = MessageDialog.openConfirm(
-                               HandlerUtil.getActiveShell(event), "Confirm deletion", msg);
-
-               if (!ok)
-                       return null;
-
-               Job job = new Job("Delete results") {
-                       @Override
-                       protected IStatus run(IProgressMonitor monitor) {
-                               if (selection != null
-                                               && selection instanceof IStructuredSelection) {
-                                       Map<String, Node> nodes = new HashMap<String, Node>();
-                                       Iterator<?> it = ((IStructuredSelection) selection)
-                                                       .iterator();
-                                       Object obj = null;
-                                       try {
-
-                                               while (it.hasNext()) {
-                                                       obj = it.next();
-                                                       if (obj instanceof ResultFolder) {
-                                                               Node node = ((ResultFolder) obj).getNode();
-                                                               nodes.put(node.getPath(), node);
-                                                       } else if (obj instanceof SingleResultNode) {
-                                                               Node node = ((SingleResultNode) obj).getNode();
-                                                               nodes.put(node.getPath(), node);
-                                                       }
-                                               }
-                                               if (!nodes.isEmpty()) {
-                                                       Session session = null;
-                                                       monitor.beginTask("Delete results", nodes.size());
-                                                       for (String path : nodes.keySet()) {
-                                                               if (session == null)
-                                                                       session = nodes.get(path).getSession();
-
-                                                               // check if the item has not already been
-                                                               // deleted while deleting one of its ancestor
-                                                               if (session.itemExists(path)) {
-                                                                       Node parent = nodes.get(path).getParent();
-                                                                       nodes.get(path).remove();
-                                                                       ResultParentUtils.updatePassedStatus(
-                                                                                       parent, true);
-                                                               }
-                                                               monitor.worked(1);
-                                                       }
-                                                       session.save();
-                                               }
-
-                                       } catch (RepositoryException e) {
-                                               throw new SlcException(
-                                                               "Unexpected error while deleteting node(s)", e);
-                                       }
-                                       monitor.done();
-                               }
-                               return Status.OK_STATUS;
-                       }
-
-               };
-               job.setUser(true);
-               job.schedule();
-               return null;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshJcrResultTreeView.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshJcrResultTreeView.java
deleted file mode 100644 (file)
index fdfa852..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.argeo.slc.client.ui.commands;
-
-import java.util.Iterator;
-
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.views.JcrResultTreeView;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Force refresh the ResultTreeView. This command is only intended to be called
- * by either the toolbar menu of the view or by the popup menu. Refresh due to
- * data changes must be triggered by Observers
- */
-public class RefreshJcrResultTreeView extends AbstractHandler {
-       public final static String ID = ClientUiPlugin.ID
-                       + ".refreshJcrResultTreeView";
-       public final static String PARAM_REFRESH_TYPE = ClientUiPlugin.ID
-                       + ".param.refreshType";
-       public final static String PARAM_REFRESH_TYPE_FULL = "fullRefresh";
-       public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
-       .getImageDescriptor("icons/refresh.png");
-       public final static String DEFAULT_LABEL = "Refresh selected";
-
-       public Object execute(final ExecutionEvent event) throws ExecutionException {
-               String refreshType = event.getParameter(PARAM_REFRESH_TYPE);
-               JcrResultTreeView view = (JcrResultTreeView) HandlerUtil
-                               .getActiveWorkbenchWindow(event).getActivePage()
-                               .getActivePart();
-
-               // force full refresh without preserving selection from the tool bar
-               if (PARAM_REFRESH_TYPE_FULL.equals(refreshType))
-                       view.refresh(null);
-               else {
-                       IStructuredSelection selection = (IStructuredSelection) HandlerUtil
-                                       .getActiveWorkbenchWindow(event).getActivePage()
-                                       .getSelection();
-                       @SuppressWarnings("rawtypes")
-                       Iterator it = selection.iterator();
-                       while (it.hasNext()) {
-                               Object obj = it.next();
-                               if (obj instanceof ResultParent) {
-                                       view.refresh((ResultParent) obj);
-                               }
-                       }
-               }
-               return null;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultFolder.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultFolder.java
deleted file mode 100644 (file)
index bbab7d7..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.argeo.slc.client.ui.commands;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.eclipse.ui.dialogs.SingleValue;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Rename a node of type SlcType.SLC_RESULT_FOLDER by moving it.
- */
-
-public class RenameResultFolder extends AbstractHandler {
-       public final static String ID = ClientUiPlugin.ID + ".renameResultFolder";
-       public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
-                       .getImageDescriptor("icons/rename.png");
-       public final static String DEFAULT_LABEL = "Rename...";
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               IStructuredSelection selection = (IStructuredSelection) HandlerUtil
-                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
-
-               // Sanity check, already done when populating the corresponding popup
-               // menu.
-               if (selection != null && selection.size() == 1) {
-                       Object obj = selection.getFirstElement();
-                       try {
-                               if (obj instanceof ResultFolder) {
-                                       ResultFolder rf = (ResultFolder) obj;
-                                       Node sourceNode = rf.getNode();
-                                       String folderName = SingleValue.ask("Rename folder",
-                                                       "Enter a new folder name");
-                                       if (folderName != null) {
-                                               String sourcePath = sourceNode.getPath();
-                                               String targetPath = JcrUtils.parentPath(sourcePath)
-                                                               + "/" + folderName;
-                                               Session session = sourceNode.getSession();
-                                               session.move(sourcePath, targetPath);
-                                               session.save();
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "Unexpected exception while refactoring result folder",
-                                               e);
-                       }
-               }
-               return null;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultNode.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultNode.java
deleted file mode 100644 (file)
index d9717cc..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.argeo.slc.client.ui.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.eclipse.ui.dialogs.SingleValue;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Rename a node of type SlcType.SLC_RESULT_FOLDER by moving it.
- */
-
-public class RenameResultNode extends AbstractHandler {
-       public final static String ID = ClientUiPlugin.ID + ".renameResultNode";
-       public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
-                       .getImageDescriptor("icons/rename.png");
-       public final static String DEFAULT_LABEL = "Rename result";
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               IStructuredSelection selection = (IStructuredSelection) HandlerUtil
-                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
-
-               // Sanity check, already done when populating the corresponding popup
-               // menu.
-               if (selection != null && selection.size() == 1) {
-                       Object obj = selection.getFirstElement();
-                       try {
-                               if (obj instanceof SingleResultNode) {
-                                       SingleResultNode rf = (SingleResultNode) obj;
-                                       Node sourceNode = rf.getNode();
-                                       String folderName = SingleValue.ask("Rename result",
-                                                       "Enter a new result name");
-                                       if (folderName != null) {
-
-                                               if (sourceNode.getParent().hasNode(folderName)) {
-                                                       MessageDialog
-                                                                       .openError(Display.getDefault()
-                                                                                       .getActiveShell(), "Error",
-                                                                                       "Another object with the same name already exists.");
-                                                       return null;
-                                               }
-
-                                               String sourcePath = sourceNode.getPath();
-                                               String targetPath = JcrUtils.parentPath(sourcePath)
-                                                               + "/" + folderName;
-                                               Session session = sourceNode.getSession();
-                                               session.move(sourcePath, targetPath);
-                                               session.getNode(targetPath).setProperty(
-                                                               Property.JCR_TITLE, folderName);
-                                               session.save();
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "Unexpected exception while refactoring result folder",
-                                               e);
-                       }
-               }
-               return null;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RunSlcFlow.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RunSlcFlow.java
deleted file mode 100644 (file)
index 5e70dfb..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.argeo.slc.client.ui.commands;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.RealizedFlow;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IParameter;
-
-@Deprecated
-public class RunSlcFlow extends AbstractHandler {
-       private ExecutionModulesManager modulesManager;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               try {
-                       Command command = event.getCommand();
-                       String name = command.getName();
-                       String module = name.substring(0, name.indexOf(':'));
-                       String flowName = name.substring(name.indexOf(':') + 1);
-
-                       final RealizedFlow realizedFlow = new RealizedFlow();
-                       realizedFlow.setModuleName(module);
-                       // FIXME deal with version
-                       String version = "0.0.0";
-                       realizedFlow.setModuleVersion(version);
-                       ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
-                       efd.setName(flowName);
-
-                       Map<String, Object> values = new HashMap<String, Object>();
-                       if (command.getParameters() != null) {
-                               for (IParameter param : command.getParameters()) {
-                                       String argName = param.getId();
-                                       // FIXME make it safer
-                                       Object value = param.getValues().getParameterValues()
-                                                       .values().iterator().next();
-                                       values.put(argName, value);
-                               }
-                               efd.setValues(values);
-                       }
-                       realizedFlow.setFlowDescriptor(efd);
-                       // new Thread("SLC Flow " + name + " from Eclipse command "
-                       // + command.getId()) {
-                       // public void run() {
-                       modulesManager.start(realizedFlow.getModuleNameVersion());
-                       modulesManager.execute(realizedFlow);
-                       // }
-                       // }.start();
-                       return null;
-               } catch (Exception e) {
-                       throw new SlcException("Could not execute command "
-                                       + event.getCommand() + " as SLC flow", e);
-               }
-       }
-
-       public void setModulesManager(
-                       ExecutionModulesManager executionModulesManager) {
-               this.modulesManager = executionModulesManager;
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/UpdateModule.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/UpdateModule.java
deleted file mode 100644 (file)
index 7cf8509..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.argeo.slc.client.ui.commands;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jcr.Node;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.BasicNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.deploy.ModulesManager;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Deletes one or many results */
-public class UpdateModule extends AbstractHandler {
-       private final static Log log = LogFactory.getLog(UpdateModule.class);
-
-       private ModulesManager modulesManager;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               final ISelection selection = HandlerUtil
-                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
-               if (selection != null && selection instanceof IStructuredSelection) {
-                       UpdateJob job = new UpdateJob(selection);
-                       job.setUser(true);
-                       job.schedule();
-               }
-               return null;
-       }
-
-       private class UpdateJob extends Job {
-               private final IStructuredSelection selection;
-
-               public UpdateJob(ISelection selection) {
-                       super("Update modules");
-                       this.selection = ((IStructuredSelection) selection);
-               }
-
-               @Override
-               protected IStatus run(IProgressMonitor monitor) {
-                       Iterator<?> it = selection.iterator();
-                       Object obj = null;
-                       try {
-                               Map<String, Node> nodes = new HashMap<String, Node>();
-                               nodes: while (it.hasNext()) {
-                                       obj = it.next();
-                                       if (obj instanceof Node) {
-                                               Node node = (Node) obj;
-                                               Node executionModuleNode = null;
-                                               while (executionModuleNode == null) {
-                                                       if (node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) {
-                                                               executionModuleNode = node;
-                                                       }
-                                                       node = node.getParent();
-                                                       if (node.getPath().equals("/"))// root
-                                                               continue nodes;
-                                               }
-
-                                               if (!nodes.containsKey(executionModuleNode.getPath()))
-                                                       nodes.put(executionModuleNode.getPath(),
-                                                                       executionModuleNode);
-                                       }
-                               }
-
-                               monitor.beginTask("Update modules", nodes.size());
-                               for (Node executionModuleNode : nodes.values()) {
-                                       monitor.subTask("Update " + executionModuleNode.getName());
-                                       NameVersion nameVersion = new BasicNameVersion(
-                                                       executionModuleNode.getProperty(SlcNames.SLC_NAME)
-                                                                       .getString(), executionModuleNode
-                                                                       .getProperty(SlcNames.SLC_VERSION)
-                                                                       .getString());
-                                       modulesManager.upgrade(nameVersion);
-                                       monitor.worked(1);
-                                       log.info("Module " + nameVersion + " updated");
-                                       if (monitor.isCanceled())
-                                               return Status.CANCEL_STATUS;
-                               }
-                               return Status.OK_STATUS;
-                       } catch (Exception e) {
-                               throw new SlcException("Cannot update module " + obj, e);
-                               // return Status.CANCEL_STATUS;
-                       }
-               }
-
-               @Override
-               protected void canceling() {
-                       getThread().interrupt();
-                       super.canceling();
-               }
-
-       }
-
-       public void setModulesManager(ModulesManager modulesManager) {
-               this.modulesManager = modulesManager;
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/controllers/ProcessController.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/controllers/ProcessController.java
deleted file mode 100644 (file)
index 4a660ad..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-package org.argeo.slc.client.ui.controllers;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.execution.SlcAgent;
-import org.argeo.slc.jcr.execution.JcrExecutionProcess;
-
-/**
- * We use a separate class (not in UI components) so that it can be a singleton
- * in an application context.
- */
-public class ProcessController {
-       // private final static Log log =
-       // LogFactory.getLog(ProcessController.class);
-       // private Map<String, SlcAgentFactory> agentFactories = new HashMap<String,
-       // SlcAgentFactory>();
-
-       private SlcAgent agent;
-
-       public ExecutionProcess process(Node processNode) {
-               JcrExecutionProcess process = new JcrExecutionProcess(processNode);
-               try {
-                       SlcAgent slcAgent = findAgent(processNode);
-                       if (slcAgent == null)
-                               throw new SlcException("Cannot find agent for " + processNode);
-                       slcAgent.process(process);
-                       return process;
-               } catch (Exception e) {
-                       if (!process.getStatus().equals(ExecutionProcess.ERROR))
-                               process.setStatus(ExecutionProcess.ERROR);
-                       throw new SlcException("Cannot execute " + processNode, e);
-               }
-       }
-
-       public void kill(Node processNode) {
-               JcrExecutionProcess process = new JcrExecutionProcess(processNode);
-               try {
-                       SlcAgent slcAgent = findAgent(processNode);
-                       if (slcAgent == null)
-                               throw new SlcException("Cannot find agent for " + processNode);
-                       slcAgent.kill(process.getUuid());
-               } catch (Exception e) {
-                       if (!process.getStatus().equals(ExecutionProcess.ERROR))
-                               process.setStatus(ExecutionProcess.ERROR);
-                       throw new SlcException("Cannot execute " + processNode, e);
-               }
-       }
-
-       /** Always return the default runtime agent */
-       protected SlcAgent findAgent(Node processNode) throws RepositoryException {
-               // we currently only deal with single agents
-               // Node realizedFlowNode = processNode.getNode(SlcNames.SLC_FLOW);
-               // NodeIterator nit = realizedFlowNode.getNodes();
-               // if (nit.hasNext()) {
-               // // TODO find a better way to determine which agent to use
-               // // currently we check the agent of the first registered flow
-               // Node firstRealizedFlow = nit.nextNode();
-               // // we assume there is an nt:address
-               // String firstFlowPath = firstRealizedFlow
-               // .getNode(SlcNames.SLC_ADDRESS)
-               // .getProperty(Property.JCR_PATH).getString();
-               // Node flowNode = processNode.getSession().getNode(firstFlowPath);
-               // String agentFactoryPath = SlcJcrUtils
-               // .flowAgentFactoryPath(firstFlowPath);
-               // if (!agentFactories.containsKey(agentFactoryPath))
-               // throw new SlcException("No agent factory registered under "
-               // + agentFactoryPath);
-               // SlcAgentFactory agentFactory = agentFactories.get(agentFactoryPath);
-               // Node agentNode = ((Node) flowNode
-               // .getAncestor(SlcJcrUtils.AGENT_FACTORY_DEPTH + 1));
-               // String agentUuid = agentNode.getProperty(SlcNames.SLC_UUID)
-               // .getString();
-               //
-               // // process
-               // return agentFactory.getAgent(agentUuid);
-               // }
-
-               return agent;
-       }
-
-       public void setAgent(SlcAgent agent) {
-               this.agent = agent;
-       }
-
-       // public synchronized void register(SlcAgentFactory agentFactory,
-       // Map<String, String> properties) {
-       // String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
-       // if (log.isDebugEnabled())
-       // log.debug("Agent factory registered under " + path);
-       // agentFactories.put(path, agentFactory);
-       // }
-       //
-       // public synchronized void unregister(SlcAgentFactory agentFactory,
-       // Map<String, String> properties) {
-       // String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
-       // if (log.isDebugEnabled())
-       // log.debug("Agent factory unregistered from " + path);
-       // agentFactories.remove(path);
-       // }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/decorators/ResultFailedDecorator.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/decorators/ResultFailedDecorator.java
deleted file mode 100644 (file)
index 9d91cc5..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.argeo.slc.client.ui.decorators;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.client.ui.SlcUiConstants;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DecorationOverlayIcon;
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-
-/** Dynamically decorates the results tree. */
-public class ResultFailedDecorator extends LabelProvider implements
-               ILabelDecorator {
-
-       // FIXME why not use? org.eclipse.jface.viewers.DecoratingLabelProvider
-
-       // private final static Log log = LogFactory
-       // .getLog(ResultFailedDecorator.class);
-
-       private final static DateFormat dateFormat = new SimpleDateFormat(
-                       SlcUiConstants.DEFAULT_DISPLAY_DATE_TIME_FORMAT);
-
-       // hack for SWT resource leak
-       // see http://www.eclipse.org/articles/swt-design-2/swt-design-2.html
-       // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=181215
-       private final Image passedFolder;
-       private final Image failedFolder;
-       private final Image failedSingleResult;
-       private final Image errorSingleResult;
-       private final Image passedSingleResult;
-
-       public ResultFailedDecorator() {
-               super();
-               ImageDescriptor failedDesc = ClientUiPlugin.getDefault().getWorkbench()
-                               .getSharedImages()
-                               .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR);
-               failedFolder = new DecorationOverlayIcon(SlcImages.FOLDER, failedDesc,
-                               IDecoration.TOP_LEFT).createImage();
-               passedFolder = new DecorationOverlayIcon(SlcImages.FOLDER,
-                               SlcImages.EXECUTION_PASSED, IDecoration.TOP_LEFT).createImage();
-               failedSingleResult = new DecorationOverlayIcon(
-                               SlcImages.PROCESS_COMPLETED, failedDesc, IDecoration.TOP_LEFT)
-                               .createImage();
-               errorSingleResult = new DecorationOverlayIcon(
-                               SlcImages.PROCESS_COMPLETED, SlcImages.EXECUTION_ERROR,
-                               IDecoration.TOP_LEFT).createImage();
-               passedSingleResult = new DecorationOverlayIcon(
-                               SlcImages.PROCESS_COMPLETED, SlcImages.EXECUTION_PASSED,
-                               IDecoration.TOP_LEFT).createImage();
-       }
-
-       // Method to decorate Image
-       public Image decorateImage(Image image, Object object) {
-
-               // This method returns an annotated image or null if the
-               // image need not be decorated. Returning a null image
-               // decorates resource icon with basic decorations provided
-               // by Eclipse
-               if (object instanceof ResultParent) {
-                       if (((ResultParent) object).isPassed()) {
-                               if (object instanceof SingleResultNode)
-                                       return passedSingleResult;
-                               else if (object instanceof ResultFolder)
-                                       return passedFolder;
-                               else
-                                       return null;
-                       } else {
-                               // ImageDescriptor desc = ClientUiPlugin.getDefault()
-                               // .getWorkbench().getSharedImages()
-                               // .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR);
-                               // DecorationOverlayIcon decoratedImage = new
-                               // DecorationOverlayIcon(
-                               // image, desc, IDecoration.TOP_LEFT);
-                               // return decoratedImage.createImage();
-                               if (object instanceof SingleResultNode) {
-                                       SingleResultNode srn = (SingleResultNode) object;
-                                       boolean isError = false;
-                                       try {
-                                               isError = srn.getNode()
-                                                               .getNode(SlcNames.SLC_AGGREGATED_STATUS)
-                                                               .hasProperty(SlcNames.SLC_ERROR_MESSAGE);
-                                       } catch (RepositoryException re) {
-                                               // Silent node might not exist
-                                       }
-                                       if (isError)
-                                               return errorSingleResult;
-                                       else
-                                               return failedSingleResult;
-
-                               } else
-                                       return failedFolder;
-                       }
-               }
-               return null;
-       }
-
-       // Method to decorate Text
-       public String decorateText(String label, Object object) {
-               if (object instanceof SingleResultNode) {
-                       SingleResultNode srNode = (SingleResultNode) object;
-                       Node node = srNode.getNode();
-                       String decoration = null;
-                       try {
-                               if (node.hasProperty(SlcNames.SLC_COMPLETED))
-                                       decoration = dateFormat.format(node
-                                                       .getProperty(SlcNames.SLC_COMPLETED).getDate()
-                                                       .getTime());
-                       } catch (RepositoryException re) {
-                               throw new SlcException(
-                                               "Unexpected error defining text decoration for result",
-                                               re);
-                       }
-                       return label + " [" + decoration + "]";
-               } else
-                       return null;
-       }
-
-       @Override
-       public void dispose() {
-               failedFolder.dispose();
-               failedSingleResult.dispose();
-               super.dispose();
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java
deleted file mode 100644 (file)
index 7c3d532..0000000
+++ /dev/null
@@ -1,804 +0,0 @@
-package org.argeo.slc.client.ui.editors;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.jcr.LoginException;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.argeo.slc.primitive.PrimitiveAccessor;
-import org.argeo.slc.primitive.PrimitiveUtils;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnViewer;
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowData;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.forms.AbstractFormPart;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/** Definition of the process. */
-public class ProcessBuilderPage extends FormPage implements SlcNames {
-       // private final static Log log =
-       // LogFactory.getLog(ProcessBuilderPage.class);
-
-       public final static String ID = "processBuilderPage";
-
-       /** To be displayed in empty lists */
-       final static String NONE = "<none>";
-
-       private Node processNode;
-       private Session agentSession;
-
-       private TreeViewer flowsViewer;
-       private TableViewer valuesViewer;
-       private Label statusLabel;
-       private Button run;
-       private Button remove;
-       private Button clear;
-
-       private AbstractFormPart formPart;
-       private EventListener statusObserver;
-
-       public ProcessBuilderPage(ProcessEditor editor, Node processNode) {
-               super(editor, ID, "Definition");
-               this.processNode = processNode;
-               try {
-                       this.agentSession = processNode.getSession().getRepository().login();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot open agent session", e);
-               }
-       }
-
-       @Override
-       protected void createFormContent(IManagedForm mf) {
-               try {
-                       ScrolledForm form = mf.getForm();
-                       form.setExpandHorizontal(true);
-                       form.setExpandVertical(true);
-                       form.setText("Process " + processNode.getName());
-                       GridLayout mainLayout = new GridLayout(1, true);
-                       form.getBody().setLayout(mainLayout);
-
-                       createControls(form.getBody());
-                       createBuilder(form.getBody());
-
-                       // form
-                       formPart = new AbstractFormPart() {
-
-                       };
-                       getManagedForm().addPart(formPart);
-
-                       // observation
-                       statusObserver = new AsyncUiEventListener(form.getDisplay()) {
-                               protected void onEventInUiThread(List<Event> events) {
-                                       statusChanged();
-                               }
-                       };
-                       ObservationManager observationManager = processNode.getSession().getWorkspace().getObservationManager();
-                       observationManager.addEventListener(statusObserver, Event.PROPERTY_CHANGED, processNode.getPath(), true,
-                                       null, null, false);
-
-                       // make sure all controls are in line with status
-                       statusChanged();
-
-                       // add initial flows
-                       addInitialFlows();
-
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot create form content", e);
-               }
-       }
-
-       protected void createControls(Composite parent) {
-               FormToolkit tk = getManagedForm().getToolkit();
-
-               Composite controls = tk.createComposite(parent);
-               controls.setLayout(new RowLayout());
-               controls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
-               run = tk.createButton(controls, null, SWT.PUSH);
-               run.setToolTipText("Run");
-               run.setImage(SlcImages.LAUNCH);
-               run.addSelectionListener(new SelectionListener() {
-                       public void widgetSelected(SelectionEvent e) {
-                               if (isFinished(getProcessStatus())) {
-                                       ((ProcessEditor) getEditor()).relaunch();
-                               } else if (isRunning(getProcessStatus())) {
-                                       ((ProcessEditor) getEditor()).kill();
-                               } else {
-                                       ((ProcessEditor) getEditor()).process();
-                               }
-                       }
-
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                               widgetSelected(e);
-                       }
-               });
-
-               remove = tk.createButton(controls, null, SWT.PUSH);
-               remove.setImage(SlcImages.REMOVE_ONE);
-               remove.setToolTipText("Remove selected flows");
-               remove.addSelectionListener(new SelectionListener() {
-                       public void widgetSelected(SelectionEvent e) {
-                               removeSelectedFlows();
-                       }
-
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                               widgetSelected(e);
-                       }
-               });
-
-               clear = tk.createButton(controls, null, SWT.PUSH);
-               clear.setImage(SlcImages.REMOVE_ALL);
-               clear.setToolTipText("Clear all flows");
-               clear.addSelectionListener(new SelectionListener() {
-                       public void widgetSelected(SelectionEvent e) {
-                               removeAllFlows();
-                       }
-
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                               widgetSelected(e);
-                       }
-               });
-
-               Composite statusComposite = tk.createComposite(controls);
-               RowData rowData = new RowData();
-               rowData.width = 100;
-               rowData.height = 16;
-               statusComposite.setLayoutData(rowData);
-               statusComposite.setLayout(new FillLayout());
-               statusLabel = tk.createLabel(statusComposite, getProcessStatus());
-
-       }
-
-       protected void createBuilder(Composite parent) {
-               FormToolkit tk = getManagedForm().getToolkit();
-               SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
-               sashForm.setSashWidth(4);
-               GridData sahFormGd = new GridData(SWT.FILL, SWT.FILL, true, true);
-               sahFormGd.widthHint = 400;
-               sashForm.setLayoutData(sahFormGd);
-
-               Composite flowsComposite = tk.createComposite(sashForm);
-               flowsComposite.setLayout(new GridLayout(1, false));
-
-               flowsViewer = new TreeViewer(flowsComposite);
-               flowsViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               flowsViewer.setLabelProvider(new FlowsLabelProvider());
-               flowsViewer.setContentProvider(new FlowsContentProvider());
-               flowsViewer.addSelectionChangedListener(new FlowsSelectionListener());
-
-               int operations = DND.DROP_COPY | DND.DROP_MOVE;
-               Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
-               flowsViewer.addDropSupport(operations, tt, new FlowsDropListener(flowsViewer));
-
-               // Context menu
-               addContextMenu();
-
-               flowsViewer.setInput(getEditorSite());
-               flowsViewer.setInput(processNode);
-
-               Composite valuesComposite = tk.createComposite(sashForm);
-               valuesComposite.setLayout(new GridLayout(1, false));
-
-               valuesViewer = new TableViewer(valuesComposite);
-               GridData valuedGd = new GridData(SWT.FILL, SWT.FILL, true, true);
-               // valuedGd.widthHint = 200;
-               valuesViewer.getTable().setLayoutData(valuedGd);
-               valuesViewer.getTable().setHeaderVisible(true);
-
-               valuesViewer.setContentProvider(new ValuesContentProvider());
-               initializeValuesViewer(valuesViewer);
-               sashForm.setWeights(getWeights());
-               valuesViewer.setInput(getEditorSite());
-       }
-
-       /** Creates the columns of the values viewer */
-       protected void initializeValuesViewer(TableViewer viewer) {
-               String[] titles = { "Name", "Value" };
-               int[] bounds = { 200, 100 };
-
-               for (int i = 0; i < titles.length; i++) {
-                       TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
-                       column.getColumn().setText(titles[i]);
-                       column.getColumn().setWidth(bounds[i]);
-                       column.getColumn().setResizable(true);
-                       column.getColumn().setMoveable(true);
-                       if (i == 0) {
-                               column.setLabelProvider(new ColumnLabelProvider() {
-                                       public String getText(Object element) {
-                                               try {
-                                                       Node specAttrNode = (Node) element;
-                                                       return specAttrNode.getName();
-                                               } catch (RepositoryException e) {
-                                                       throw new SlcException("Cannot get value", e);
-                                               }
-                                       }
-                               });
-                       } else if (i == 1) {
-                               column.setLabelProvider(new ColumnLabelProvider() {
-                                       public String getText(Object element) {
-                                               return getAttributeSpecText((Node) element);
-                                       }
-                               });
-                               column.setEditingSupport(new ValuesEditingSupport(viewer));
-                       }
-
-               }
-               Table table = viewer.getTable();
-               table.setHeaderVisible(false);
-               table.setLinesVisible(true);
-       }
-
-       protected int[] getWeights() {
-               return new int[] { 50, 50 };
-       }
-
-       /*
-        * CONTROLLERS
-        */
-       /** Reflects a status change */
-       protected void statusChanged() {
-               String status = getProcessStatus();
-               statusLabel.setText(status);
-               Boolean isEditable = isEditable(status);
-               run.setEnabled(status.equals(ExecutionProcess.RUNNING) || isEditable);
-               remove.setEnabled(isEditable);
-               clear.setEnabled(isEditable);
-               // flowsViewer.getTree().setEnabled(isEditable);
-               if (status.equals(ExecutionProcess.RUNNING)) {
-                       run.setEnabled(true);
-                       run.setImage(SlcImages.KILL);
-                       run.setToolTipText("Kill");
-               } else if (isFinished(status)) {
-                       run.setEnabled(true);
-                       run.setImage(SlcImages.RELAUNCH);
-                       run.setToolTipText("Relaunch");
-               }
-
-               if (flowsViewer != null)
-                       flowsViewer.refresh();
-       }
-
-       /** Adds initial flows from the editor input if any */
-       protected void addInitialFlows() {
-               for (String path : ((ProcessEditorInput) getEditorInput()).getInitialFlowPaths()) {
-                       addFlow(path);
-               }
-       }
-
-       /**
-        * Adds a new flow.
-        * 
-        * @param path the path of the flow
-        */
-       protected void addFlow(String path) {
-               try {
-                       Node flowNode = agentSession.getNode(path);
-                       Node realizedFlowNode = processNode.getNode(SLC_FLOW).addNode(SLC_FLOW);
-                       realizedFlowNode.setProperty(SLC_NAME, flowNode.getProperty(SLC_NAME).getString());
-                       realizedFlowNode.addMixin(SlcTypes.SLC_REALIZED_FLOW);
-                       Node address = realizedFlowNode.addNode(SLC_ADDRESS, NodeType.NT_ADDRESS);
-                       address.setProperty(Property.JCR_PATH, path);
-
-                       // copy spec attributes
-                       Node specAttrsBase;
-                       if (flowNode.hasProperty(SLC_SPEC)) {
-                               Node executionSpecNode = flowNode.getProperty(SLC_SPEC).getNode();
-                               specAttrsBase = executionSpecNode;
-                               String executionSpecName = executionSpecNode.getProperty(SLC_NAME).getString();
-                               realizedFlowNode.setProperty(SLC_SPEC, executionSpecName);
-                       } else
-                               specAttrsBase = flowNode;
-
-                       specAttrs: for (NodeIterator nit = specAttrsBase.getNodes(); nit.hasNext();) {
-                               Node specAttrNode = nit.nextNode();
-                               String attrName = specAttrNode.getName();
-                               if (!specAttrNode.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
-                                       continue specAttrs;
-                               Node realizedAttrNode = realizedFlowNode.addNode(specAttrNode.getName());
-                               JcrUtils.copy(specAttrNode, realizedAttrNode);
-
-                               // override with flow value
-                               if (flowNode.hasNode(attrName)) {
-                                       // assuming this is a primitive
-                                       Node attrNode = flowNode.getNode(attrName);
-                                       if (attrNode.hasProperty(SLC_VALUE))
-                                               realizedAttrNode.setProperty(SLC_VALUE, attrNode.getProperty(SLC_VALUE).getValue());
-                               }
-                       }
-
-                       // Part title
-                       StringBuilder editorTitle = new StringBuilder();
-                       NodeIterator it = realizedFlowNode.getParent().getNodes(SLC_FLOW);
-                       while (it.hasNext()) {
-                               Node rFlowNode = it.nextNode();
-                               String name = rFlowNode.getProperty(SLC_NAME).getString();
-                               editorTitle.append(name).append(' ');
-                       }
-                       ((ProcessEditor) getEditor()).setEditorTitle(editorTitle.toString());
-
-                       flowsViewer.refresh();
-                       formPart.markDirty();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot add flow " + path, e);
-               }
-       }
-
-       @SuppressWarnings("unchecked")
-       protected void removeSelectedFlows() {
-               if (!flowsViewer.getSelection().isEmpty()) {
-                       Iterator<Object> it = ((StructuredSelection) flowsViewer.getSelection()).iterator();
-                       while (it.hasNext()) {
-                               Node node = (Node) it.next();
-                               try {
-                                       node.remove();
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot remove " + node, e);
-                               }
-                       }
-                       flowsViewer.refresh();
-                       formPart.markDirty();
-               }
-       }
-
-       protected void removeAllFlows() {
-               try {
-                       for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit.hasNext();) {
-                               nit.nextNode().remove();
-                       }
-                       flowsViewer.refresh();
-                       formPart.markDirty();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot remove flows from " + processNode, e);
-               }
-       }
-
-       public void commit(Boolean onSave) {
-               if (onSave)
-                       statusLabel.setText(getProcessStatus());
-               formPart.commit(onSave);
-       }
-
-       /*
-        * STATE
-        */
-       protected String getProcessStatus() {
-               try {
-                       return processNode.getProperty(SLC_STATUS).getString();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot retrieve status for " + processNode, e);
-               }
-       }
-
-       /** Optimization so that we don't call the node each time */
-       protected static Boolean isEditable(String status) {
-               return status.equals(ExecutionProcess.NEW) || status.equals(ExecutionProcess.INITIALIZED);
-       }
-
-       protected static Boolean isFinished(String status) {
-               return status.equals(ExecutionProcess.COMPLETED) || status.equals(ExecutionProcess.ERROR)
-                               || status.equals(ExecutionProcess.KILLED);
-       }
-
-       protected static Boolean isRunning(String status) {
-               return status.equals(ExecutionProcess.RUNNING);
-       }
-
-       /*
-        * LIFECYCLE
-        */
-       @Override
-       public void dispose() {
-               JcrUtils.unregisterQuietly(processNode, statusObserver);
-               JcrUtils.logoutQuietly(agentSession);
-               super.dispose();
-       }
-
-       /*
-        * UTILITIES
-        */
-       protected static String getAttributeSpecText(Node specAttrNode) {
-               try {
-                       if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
-                               if (!specAttrNode.hasProperty(SLC_VALUE))
-                                       return "";
-                               String type = specAttrNode.getProperty(SLC_TYPE).getString();
-                               if (PrimitiveAccessor.TYPE_PASSWORD.equals(type))
-                                       return "****************";
-                               Object value = PrimitiveUtils.convert(type, specAttrNode.getProperty(SLC_VALUE).getString());
-                               return value.toString();
-                       } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
-                               if (specAttrNode.hasProperty(SLC_VALUE)) {
-                                       int value = (int) specAttrNode.getProperty(SLC_VALUE).getLong();
-                                       NodeIterator children = specAttrNode.getNodes();
-                                       int index = 0;
-                                       while (children.hasNext()) {
-                                               Node child = children.nextNode();
-                                               if (index == value)
-                                                       return child.getProperty(Property.JCR_TITLE).getString();
-                                               index++;
-                                       }
-                                       throw new SlcException("No child node with index " + value + " for spec attribute " + specAttrNode);
-                               } else
-                                       return "";
-                       }
-                       throw new SlcException("Unsupported type for spec attribute " + specAttrNode);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot get value", e);
-               }
-       }
-
-       /*
-        * FLOWS SUBCLASSES
-        */
-       class FlowsContentProvider implements ITreeContentProvider {
-               public Object[] getElements(Object obj) {
-                       if (!(obj instanceof Node))
-                               return new Object[0];
-
-                       try {
-                               Node node = (Node) obj;
-                               List<Node> children = new ArrayList<Node>();
-                               for (NodeIterator nit = node.getNode(SLC_FLOW).getNodes(); nit.hasNext();) {
-                                       Node flowNode = nit.nextNode();
-                                       children.add(flowNode);
-                               }
-                               return children.toArray();
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot list flows of " + obj, e);
-                       }
-               }
-
-               public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
-               }
-
-               public void dispose() {
-               }
-
-               public Object[] getChildren(Object parentElement) {
-                       // no children for the time being
-                       return null;
-               }
-
-               public Object getParent(Object element) {
-                       return null;
-               }
-
-               public boolean hasChildren(Object element) {
-                       return false;
-               }
-
-       }
-
-       static class FlowsLabelProvider extends ColumnLabelProvider {
-               @Override
-               public String getText(Object element) {
-                       Node node = (Node) element;
-                       try {
-                               if (node.isNodeType(SlcTypes.SLC_REALIZED_FLOW)) {
-                                       if (node.hasNode(SLC_ADDRESS)) {
-                                               String path = node.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString();
-                                               String executionModuleName = SlcJcrUtils.moduleName(path);
-                                               // Node executionModuleNode = node.getSession().getNode(
-                                               // SlcJcrUtils.modulePath(path));
-                                               // String executionModuleName = executionModuleNode
-                                               // .getProperty(SLC_NAME).getString();
-                                               return executionModuleName + ":" + SlcJcrUtils.flowRelativePath(path);
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot display " + element, e);
-                       }
-                       return super.getText(element);
-               }
-
-               @Override
-               public Image getImage(Object element) {
-                       Node node = (Node) element;
-                       try {
-                               if (node.isNodeType(SlcTypes.SLC_REALIZED_FLOW)) {
-                                       if (node.hasProperty(SLC_STATUS)) {
-                                               String status = node.getProperty(SLC_STATUS).getString();
-                                               // TODO: factorize with process view ?
-                                               if (status.equals(ExecutionProcess.RUNNING))
-                                                       return SlcImages.PROCESS_RUNNING;
-                                               else if (status.equals(ExecutionProcess.ERROR) || status.equals(ExecutionProcess.KILLED))
-                                                       return SlcImages.PROCESS_ERROR;
-                                               else if (status.equals(ExecutionProcess.COMPLETED))
-                                                       return SlcImages.PROCESS_COMPLETED;
-                                       }
-                                       return SlcImages.FLOW;
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot display " + element, e);
-                       }
-                       return super.getImage(element);
-               }
-
-       }
-
-       /** Parameter view is updated each time a new line is selected */
-       class FlowsSelectionListener implements ISelectionChangedListener {
-               public void selectionChanged(SelectionChangedEvent evt) {
-                       if (evt.getSelection().isEmpty()) {
-                               valuesViewer.setInput(getEditorSite());
-                               return;
-                       }
-                       Node realizedFlowNode = (Node) ((IStructuredSelection) evt.getSelection()).getFirstElement();
-                       valuesViewer.setInput(realizedFlowNode);
-               }
-       }
-
-       /**
-        * Add a context menu that call private methods. It only relies on selected
-        * item(s) not on parameter that are passed in the menuAboutToShow method
-        **/
-       private void addContextMenu() {
-               Menu menu = new Menu(flowsViewer.getControl());
-
-               MenuItem removeItems = new MenuItem(menu, SWT.PUSH);
-               removeItems.addSelectionListener(new SelectionListener() {
-
-                       public void widgetSelected(SelectionEvent e) {
-                               removeSelectedFlows();
-                       }
-
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-               });
-               removeItems.setText("Remove selected flow(s)");
-
-               MenuItem removeAllItems = new MenuItem(menu, SWT.PUSH);
-               removeAllItems.addSelectionListener(new SelectionListener() {
-
-                       public void widgetSelected(SelectionEvent e) {
-                               removeAllFlows();
-                       }
-
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-               });
-               removeAllItems.setText("Remove all flows");
-               flowsViewer.getTree().setMenu(menu);
-       }
-
-       /** Manages drop event. */
-       class FlowsDropListener extends ViewerDropAdapter {
-
-               public FlowsDropListener(Viewer viewer) {
-                       super(viewer);
-               }
-
-               @Override
-               public boolean performDrop(Object data) {
-
-                       // Parse the received String, paths are separated with a carriage
-                       // return
-                       String[] paths = data.toString().split(new String("\n"));
-                       SortedSet<String> resultPaths = new TreeSet<String>();
-                       for (String path : paths) {
-                               try {
-                                       // either a node or a whole directory can have been dragged
-                                       QueryManager qm = processNode.getSession().getWorkspace().getQueryManager();
-                                       String statement = "SELECT * FROM [" + SlcTypes.SLC_EXECUTION_FLOW + "] WHERE ISDESCENDANTNODE(['"
-                                                       + path + "']) OR ISSAMENODE(['" + path + "'])";
-                                       Query query = qm.createQuery(statement, Query.JCR_SQL2);
-
-                                       // order paths
-                                       for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
-                                               String currPath = nit.nextNode().getPath();
-                                               // do not add twice a same flow
-                                               if (!resultPaths.contains(currPath))
-                                                       resultPaths.add(currPath);
-                                       }
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot query flows under " + path, e);
-                               }
-                       }
-                       for (String p : resultPaths) {
-                               addFlow(p);
-                       }
-                       return true;
-
-               }
-
-               @Override
-               public boolean validateDrop(Object target, int operation, TransferData transferType) {
-                       return isEditable(getProcessStatus());
-               }
-       }
-
-       /*
-        * VALUES SUBCLASSES
-        */
-       static class ValuesContentProvider implements IStructuredContentProvider {
-
-               public Object[] getElements(Object inputElement) {
-                       if (!(inputElement instanceof Node))
-                               return new Object[0];
-
-                       try {
-                               Node realizedFlowNode = (Node) inputElement;
-                               List<Node> specAttributes = new ArrayList<Node>();
-                               specAttrs: for (NodeIterator nit = realizedFlowNode.getNodes(); nit.hasNext();) {
-                                       Node specAttrNode = nit.nextNode();
-                                       if (!specAttrNode.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
-                                               continue specAttrs;
-                                       // workaround to enable hiding of necessary but unusable
-                                       // flow parameters
-                                       else if (specAttrNode.hasProperty(SlcNames.SLC_IS_HIDDEN)
-                                                       && specAttrNode.getProperty(SlcNames.SLC_IS_HIDDEN).getBoolean())
-                                               continue specAttrs;
-                                       specAttributes.add(specAttrNode);
-                               }
-                               return specAttributes.toArray();
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get elements", e);
-                       }
-               }
-
-               public void dispose() {
-               }
-
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-               }
-       }
-
-       class ValuesEditingSupport extends EditingSupport {
-               private final TableViewer tableViewer;
-
-               public ValuesEditingSupport(ColumnViewer viewer) {
-                       super(viewer);
-                       tableViewer = (TableViewer) viewer;
-               }
-
-               @Override
-               protected CellEditor getCellEditor(Object element) {
-                       try {
-                               Node specAttrNode = (Node) element;
-                               if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
-                                       String type = specAttrNode.getProperty(SLC_TYPE).getString();
-                                       if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) {
-                                               return new TextCellEditor(tableViewer.getTable(), SWT.PASSWORD);
-                                       } else {
-                                               return new TextCellEditor(tableViewer.getTable());
-                                       }
-                               } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
-                                       NodeIterator children = specAttrNode.getNodes();
-                                       ArrayList<String> items = new ArrayList<String>();
-                                       while (children.hasNext()) {
-                                               Node child = children.nextNode();
-                                               if (child.isNodeType(NodeType.MIX_TITLE))
-                                                       items.add(child.getProperty(Property.JCR_TITLE).getString());
-                                       }
-                                       return new ComboBoxCellEditor(tableViewer.getTable(), items.toArray(new String[items.size()]));
-                               }
-                               return null;
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get cell editor", e);
-                       }
-               }
-
-               @Override
-               protected boolean canEdit(Object element) {
-                       try {
-                               Node specAttrNode = (Node) element;
-                               Boolean cannotEdit = specAttrNode.getProperty(SLC_IS_IMMUTABLE).getBoolean()
-                                               || specAttrNode.getProperty(SLC_IS_CONSTANT).getBoolean();
-                               return !cannotEdit && isSupportedAttributeType(specAttrNode);
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot check whether " + element + " is editable", e);
-                       }
-               }
-
-               /**
-                * Supports {@link SlcTypes#SLC_PRIMITIVE_SPEC_ATTRIBUTE} and
-                * {@link SlcTypes#SLC_REF_SPEC_ATTRIBUTE}
-                */
-               protected boolean isSupportedAttributeType(Node specAttrNode) throws RepositoryException {
-                       return specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)
-                                       || specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE);
-               }
-
-               @Override
-               protected Object getValue(Object element) {
-                       Node specAttrNode = (Node) element;
-                       try {
-                               if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
-                                       if (!specAttrNode.hasProperty(SLC_VALUE))
-                                               return NONE;
-                                       String type = specAttrNode.getProperty(SLC_TYPE).getString();
-                                       // TODO optimize based on data type?
-                                       Object value = PrimitiveUtils.convert(type, specAttrNode.getProperty(SLC_VALUE).getString());
-                                       return value.toString();
-                               } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
-                                       if (!specAttrNode.hasProperty(SLC_VALUE))
-                                               return 0;
-                                       // return the index of the sub node as set by setValue()
-                                       // in the future we may manage references as well
-                                       return (int) specAttrNode.getProperty(SLC_VALUE).getLong();
-                               }
-                               throw new SlcException("Unsupported type for spec attribute " + specAttrNode);
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get value for " + element, e);
-                       }
-               }
-
-               @Override
-               protected void setValue(Object element, Object value) {
-                       try {
-                               Node specAttrNode = (Node) element;
-                               if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
-                                       String type = specAttrNode.getProperty(SLC_TYPE).getString();
-                                       SlcJcrUtils.setPrimitiveAsProperty(specAttrNode, SLC_VALUE, type, value);
-                                       valuesViewer.refresh();
-                                       formPart.markDirty();
-                               } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
-                                       specAttrNode.setProperty(SLC_VALUE, ((Integer) value).longValue());
-                                       valuesViewer.refresh();
-                                       formPart.markDirty();
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get celle editor", e);
-                       }
-               }
-
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java
deleted file mode 100644 (file)
index 38db84a..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-package org.argeo.slc.client.ui.editors;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.controllers.ProcessController;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.rap.rwt.service.ServerPushSession;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/** Editor for an execution process. */
-public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames {
-       private static final long serialVersionUID = 509589737739132467L;
-
-       public final static String ID = ClientUiPlugin.ID + ".processEditor";
-
-       private Repository repository;
-       private Session homeSession;
-       private Session agentSession;
-       private Node processNode;
-       private ProcessController processController;
-       private ServerPushSession pushSession;
-
-       private ProcessBuilderPage builderPage;
-
-       private ExecutionModulesManager modulesManager;
-
-       @Override
-       public void init(IEditorSite site, IEditorInput input) throws PartInitException {
-               super.init(site, input);
-               pushSession = new ServerPushSession();
-               pushSession.start();
-               try {
-                       homeSession = repository.login(NodeConstants.HOME_WORKSPACE);
-                       agentSession = repository.login();
-               } catch (RepositoryException e1) {
-                       throw new SlcException("Cannot log in to repository");
-               }
-
-               ProcessEditorInput pei = (ProcessEditorInput) input;
-               String processPath = pei.getProcessPath();
-               try {
-                       if (processPath != null) {
-                               if (!homeSession.itemExists(processPath))
-                                       throw new SlcException("Process " + processPath + " does not exist");
-                               processNode = homeSession.getNode(processPath);
-                       } else {// new
-                               processNode = newProcessNode(pei);
-                       }
-                       setPartName(processNode.getName());
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot initialize editor for " + pei, e);
-               }
-
-       }
-
-       protected Node newProcessNode(ProcessEditorInput pei) throws RepositoryException {
-               String uuid = UUID.randomUUID().toString();
-               String processPath = SlcJcrUtils.createExecutionProcessPath(homeSession, uuid);
-               Node processNode = JcrUtils.mkdirs(homeSession, processPath, SLC_PROCESS);
-               processNode.setProperty(SLC_UUID, uuid);
-               processNode.setProperty(SLC_STATUS, ExecutionProcess.NEW);
-               Node processFlow = processNode.addNode(SLC_FLOW);
-               processFlow.addMixin(SLC_REALIZED_FLOW);
-               return processNode;
-       }
-
-       @Override
-       public boolean isDirty() {
-               if (getProcessStatus().equals(ExecutionProcess.NEW))
-                       return true;
-               return super.isDirty();
-       }
-
-       protected String getProcessStatus() {
-               try {
-                       return processNode.getProperty(SLC_STATUS).getString();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot retrieve status for " + processNode, e);
-               }
-       }
-
-       @Override
-       public void dispose() {
-               JcrUtils.logoutQuietly(homeSession);
-               JcrUtils.logoutQuietly(agentSession);
-               if (pushSession != null)
-                       pushSession.stop();
-               super.dispose();
-       }
-
-       /** Actually runs the process. */
-       void process() {
-               // the modifications have to be saved before execution
-               try {
-                       processNode.setProperty(SLC_STATUS, ExecutionProcess.SCHEDULED);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot update status of " + processNode, e);
-               }
-
-               // save
-               doSave(null);
-
-               try {
-                       // make sure modules are started for all nodes
-                       for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit.hasNext();) {
-                               Node flowNode = nit.nextNode();
-                               try {
-                                       String flowDefPath = flowNode.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString();
-                                       Node executionModuleNode = agentSession.getNode(SlcJcrUtils.modulePath(flowDefPath));
-                                       if (!executionModuleNode.getProperty(SLC_STARTED).getBoolean())
-                                               ClientUiPlugin.startStopExecutionModule(modulesManager, executionModuleNode);
-                               } catch (Exception e) {
-                                       ErrorFeedback.show("Cannot start execution module related to " + flowNode, e);
-                               }
-                       }
-
-                       // Actually process
-                       ExecutionProcess process = processController.process(processNode);
-                       Map<String, String> properties = new HashMap<String, String>();
-                       properties.put(ExecutionModulesManager.SLC_PROCESS_ID, process.getUuid());
-                       // modulesManager.registerProcessNotifier(this, properties);
-               } catch (Exception e) {
-                       ErrorFeedback.show("Execution of " + processNode + " failed", e);
-               }
-       }
-
-       void kill() {
-               processController.kill(processNode);
-       }
-
-       /** Opens a new editor with a copy of this process */
-       void relaunch() {
-               try {
-                       Node duplicatedNode = duplicateProcess();
-                       IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-                       activePage.openEditor(new ProcessEditorInput(duplicatedNode.getPath()), ProcessEditor.ID);
-                       close(false);
-               } catch (Exception e1) {
-                       throw new SlcException("Cannot relaunch " + processNode, e1);
-               }
-       }
-
-       /** Duplicates the process */
-       protected Node duplicateProcess() {
-               try {
-                       Session session = processNode.getSession();
-                       String uuid = UUID.randomUUID().toString();
-                       String destPath = SlcJcrUtils.createExecutionProcessPath(session, uuid);
-                       Node newNode = JcrUtils.mkdirs(session, destPath, SlcTypes.SLC_PROCESS);
-
-                       Node rootRealizedFlowNode = newNode.addNode(SLC_FLOW);
-                       // copy node
-                       JcrUtils.copy(processNode.getNode(SLC_FLOW), rootRealizedFlowNode);
-
-                       newNode.setProperty(SLC_UUID, uuid);
-                       newNode.setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
-
-                       // reset realized flow status
-                       // we just manage one level for the time being
-                       NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW);
-                       while (nit.hasNext()) {
-                               nit.nextNode().setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
-                       }
-
-                       session.save();
-                       return newNode;
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot duplicate process", e);
-               }
-       }
-
-       @Override
-       protected void addPages() {
-               try {
-                       builderPage = new ProcessBuilderPage(this, processNode);
-                       addPage(builderPage);
-                       firePropertyChange(PROP_DIRTY);
-               } catch (PartInitException e) {
-                       throw new SlcException("Cannot add pages", e);
-               }
-
-       }
-
-       @Override
-       public void doSave(IProgressMonitor monitor) {
-               try {
-                       String status = processNode.getProperty(SLC_STATUS).getString();
-                       if (status.equals(ExecutionProcess.NEW))
-                               processNode.setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
-                       homeSession.save();
-                       builderPage.commit(true);
-                       editorDirtyStateChanged();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot save " + processNode, e);
-                       // } finally {
-                       // JcrUtils.discardQuietly(session);
-               }
-       }
-
-       public void setEditorTitle(String title) {
-               setPartName(title);
-       }
-
-       @Override
-       public void doSaveAs() {
-       }
-
-       @Override
-       public boolean isSaveAsAllowed() {
-               return false;
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setProcessController(ProcessController processController) {
-               this.processController = processController;
-       }
-
-       public void setModulesManager(ExecutionModulesManager modulesManager) {
-               this.modulesManager = modulesManager;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInput.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInput.java
deleted file mode 100644 (file)
index f93af3f..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.argeo.slc.client.ui.editors;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPersistableElement;
-
-public class ProcessEditorInput implements IEditorInput, IPersistableElement {
-       private String processPath;
-       private List<String> initialFlowPaths = new ArrayList<String>();
-       private Boolean launchImmediately = false;
-
-       /** New empty process */
-       public ProcessEditorInput() {
-       }
-
-       /** New process with some flows */
-       public ProcessEditorInput(List<String> initialFlowPaths,
-                       Boolean launchImmediately) {
-               this.initialFlowPaths = initialFlowPaths;
-               this.launchImmediately = launchImmediately;
-       }
-
-       /** Existing process */
-       public ProcessEditorInput(String processPath) {
-               this.processPath = processPath;
-       }
-
-       @SuppressWarnings("rawtypes")
-       public Object getAdapter(Class arg0) {
-               return null;
-       }
-
-       public boolean exists() {
-               return processPath != null;
-       }
-
-       public ImageDescriptor getImageDescriptor() {
-               return null;
-       }
-
-       public String getName() {
-               return processPath != null ? processPath : "<new process>";
-       }
-
-       public IPersistableElement getPersistable() {
-               return this;
-       }
-
-       public String getToolTipText() {
-               return "";
-       }
-
-       public void saveState(IMemento memento) {
-               memento.putString("processPath", processPath);
-       }
-
-       public String getFactoryId() {
-               return ProcessEditorInputFactory.ID;
-       }
-
-       public String getProcessPath() {
-               return processPath;
-       }
-
-       public List<String> getInitialFlowPaths() {
-               return initialFlowPaths;
-       }
-
-       public Boolean getLaunchImmediately() {
-               return launchImmediately;
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               if (!(obj instanceof ProcessEditorInput))
-                       return false;
-               ProcessEditorInput pei = (ProcessEditorInput) obj;
-               if (processPath != null && pei.processPath != null)
-                       return processPath.equals(pei.processPath);
-               return false;
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInputFactory.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInputFactory.java
deleted file mode 100644 (file)
index b5a5d70..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.argeo.slc.client.ui.editors;
-
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.IElementFactory;
-import org.eclipse.ui.IMemento;
-
-public class ProcessEditorInputFactory implements IElementFactory {
-       public final static String ID = ClientUiPlugin.ID
-                       + ".processEditorInputFactory";
-
-       public IAdaptable createElement(IMemento memento) {
-               String path = memento.getString("processPath");
-               return new ProcessEditorInput(path);
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessLogPage.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessLogPage.java
deleted file mode 100644 (file)
index 57eff2e..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-package org.argeo.slc.client.ui.editors;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Workspace;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.query.Query;
-
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.execution.ExecutionStep;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class ProcessLogPage extends FormPage {
-       public final static String ID = "processLogPage";
-
-       private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
-
-       /** Where the log is displayed. */
-       private Text text;
-       /**
-        * Stores logs received before the text was shown. TODO : rather store in in
-        * JCR and reads it from there.
-        */
-       private StringBuffer beforeTextInit = new StringBuffer("");
-
-       private Node processNode;
-       /**
-        * optimization field: we compute once the length of the path to slc:log so
-        * that we can easily substring the relative path of logs.
-        */
-       //private Integer logPathLength;
-
-       public ProcessLogPage(FormEditor editor, Node processNode) {
-               super(editor, ID, "Log");
-               this.processNode = processNode;
-
-               EventListener listener = new LogListener(editor.getSite().getPage()
-                               .getWorkbenchWindow().getWorkbench().getDisplay());
-
-               try {
-                       String logBasePath = processNode.getPath() + '/' + SlcNames.SLC_LOG;
-                       //logPathLength = logBasePath.length();
-
-                       Workspace ws = processNode.getSession().getWorkspace();
-
-                       String statement = "SELECT * FROM ["
-                                       + SlcTypes.SLC_LOG_ENTRY
-                                       + "] as logEntry"
-                                       + " WHERE ISDESCENDANTNODE('"
-                                       + logBasePath
-                                       + "')"
-                                       + " ORDER BY logEntry.[slc:timestamp] ASC, NAME(logEntry) ASC";
-                       StringBuffer buf = new StringBuffer("");
-                       NodeIterator it = ws.getQueryManager()
-                                       .createQuery(statement, Query.JCR_SQL2).execute()
-                                       .getNodes();
-                       while (it.hasNext())
-                               appendLogEntry(buf, it.nextNode());
-                       beforeTextInit = new StringBuffer(buf.toString());
-                       // text.setText(buf.toString());
-                       ws.getObservationManager().addEventListener(listener,
-                                       Event.NODE_ADDED, logBasePath, true, null, null, false);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot register listener", e);
-               }
-       }
-
-       @Override
-       public synchronized void createPartControl(Composite parent) {
-               // bypass createFormContent
-               FormToolkit tk = getEditor().getToolkit();
-               // parent.setLayout(new FillLayout());
-               text = tk.createText(parent, "", SWT.MULTI | SWT.H_SCROLL
-                               | SWT.V_SCROLL);
-               text.setEditable(false);
-
-               // transfer the existing buffer the first time
-               if (beforeTextInit.length() > 0) {
-                       text.append(beforeTextInit.toString());
-                       // clear buffer
-                       beforeTextInit.setLength(0);
-               }
-
-       }
-
-       // @Override
-       // protected synchronized void createFormContent(IManagedForm mf) {
-       // ScrolledForm form = mf.getForm();
-       // form.setExpandHorizontal(true);
-       // form.setExpandVertical(true);
-       // // form.setText("Log");
-       // FillLayout mainLayout = new FillLayout();
-       // form.getBody().setLayout(mainLayout);
-       //
-       // FormToolkit tk = getManagedForm().getToolkit();
-       // text = tk.createText(form.getBody(), "", SWT.MULTI | SWT.H_SCROLL
-       // | SWT.V_SCROLL);
-       // text.setEditable(false);
-       // // transfer the existing buffer the first time
-       // if (beforeTextInit.length() > 0) {
-       // text.append(beforeTextInit.toString());
-       // // clear buffer
-       // beforeTextInit.setLength(0);
-       // }
-       // }
-
-       protected void appendLogEntry(StringBuffer buf, Node logEntry)
-                       throws RepositoryException {
-               // +1 in order to remove the first slash
-//             String relPath = logEntry.getPath().substring(logPathLength + 1);
-               //System.out.println("relPath=" + relPath);
-//             int firstSlashIndex = relPath.indexOf('/');
-//             int lastSlashIndex = relPath.lastIndexOf('/');
-//             String thread = relPath.substring(0, firstSlashIndex);
-//             String location = relPath.substring(firstSlashIndex, lastSlashIndex);
-
-               // String date = dateFormat.format(logEntry
-               // .getProperty(SlcNames.SLC_TIMESTAMP).getDate().getTime());
-               String date = logEntry.getProperty(SlcNames.SLC_TIMESTAMP).getString();
-               buf.append(date).append(' ');
-               String type = logEntry.getPrimaryNodeType().getName().substring(7);
-               buf.append(type).append('\t');
-               // buf.append(thread).append('\t');
-               // buf.append(location).append('\t');
-               buf.append(logEntry.getProperty(SlcNames.SLC_MESSAGE).getString());
-               buf.append('\n');
-
-       }
-
-       /** @deprecated */
-       public synchronized void addSteps(List<ExecutionStep> steps) {
-               final StringBuffer buf = new StringBuffer("");
-               for (ExecutionStep step : steps) {
-                       buf.append(dateFormat.format(step.getTimestamp()));
-                       buf.append(' ');
-                       if (step.getType().equals(ExecutionStep.PHASE_START)) {
-                               buf.append("## START ").append(step.getLog());
-                               buf.append('\n');
-                       } else if (step.getType().equals(ExecutionStep.PHASE_END)) {
-                               buf.append("## END   ").append(step.getLog());
-                               buf.append("\n");
-                       } else {
-                               buf.append(step.getLog());
-                       }
-               }
-
-               if (text != null) {
-                       Display.getDefault().asyncExec(new Runnable() {
-                               public void run() {
-                                       text.append(buf.toString());
-                               }
-                       });
-               } else
-                       beforeTextInit.append(buf);
-       }
-
-       @Override
-       public Control getPartControl() {
-               return text;
-       }
-
-       @Override
-       public void setFocus() {
-               if (text != null)
-                       text.setFocus();
-       }
-
-       /** JCR event listener notifying when new nodes are added */
-       private class LogListener extends AsyncUiEventListener {
-
-               public LogListener(Display display) {
-                       super(display);
-               }
-
-               @Override
-               protected void onEventInUiThread(List<Event> events)
-                               throws RepositoryException {
-                       // since we use batch save, order is not guaranteed
-                       // so we need to reorder, according to log line number for the time
-                       // being
-                       SortedMap<Long, Node> nodes = new TreeMap<Long, Node>();
-
-                       for (Event evt : events) {
-                               Node newNode = ProcessLogPage.this.processNode.getSession()
-                                               .getNode(evt.getPath());
-                               if (newNode.isNodeType(SlcTypes.SLC_LOG_ENTRY)) {
-                                       nodes.put(Long.parseLong(newNode.getName()), newNode);
-                               }
-                       }
-
-                       StringBuffer buf = new StringBuffer("");
-                       for (Node logEntry : nodes.values()) {
-                               appendLogEntry(buf, logEntry);
-                       }
-
-                       if (text != null)
-                               text.append(buf.toString());
-                       else
-                               beforeTextInit.append(buf);
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ParentNodeFolder.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ParentNodeFolder.java
deleted file mode 100644 (file)
index c6ffcd8..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/**
- * UI Tree component that wrap a node of type NT_UNSTRUCTURED or base node for
- * UI specific, user defined tree structure of type SLC_MY_RESULTS_ROOT_FOLDER.
- * 
- * It is used for
- * <ul>
- * <li>automatically generated tree structure to store results (typically
- * Year/Month/Day...)</li>
- * <li>parent node for user defined tree structure (typically My Results node)</li>
- * </ul>
- * It thus lists either result folders, other folders and/or a list of results
- * and keeps a reference to its parent.
- */
-public class ParentNodeFolder extends ResultParent {
-       // private final static Log log = LogFactory.getLog(ParentNodeFolder.class);
-
-       private Node node = null;
-
-       /**
-        * 
-        * @param parent
-        * @param node
-        *            throws an exception if null
-        * @param name
-        */
-       public ParentNodeFolder(ParentNodeFolder parent, Node node, String name) {
-               super(name);
-               if (node == null)
-                       throw new SlcException("Node Object cannot be null");
-               setParent(parent);
-               this.node = node;
-       }
-
-       @Override
-       protected void initialize() {
-               try {
-                       NodeIterator ni = node.getNodes();
-                       while (ni.hasNext()) {
-                               Node currNode = ni.nextNode();
-                               if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
-                                       SingleResultNode srn = new SingleResultNode(this, currNode,
-                                                       currNode.getProperty(SlcNames.SLC_TEST_CASE)
-                                                                       .getString());
-                                       addChild(srn);
-                               } else if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
-                                       // FIXME change label
-                                       ResultFolder rf = new ResultFolder(this, currNode,
-                                                       currNode.getName());
-                                       addChild(rf);
-                               } else if (currNode.isNodeType(SlcTypes.SLC_CHECK)) {
-                                       // FIXME : manually skip node types that are not to be
-                                       // displayed
-                                       // Do nothing
-                               } else if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
-                                       addChild(new ParentNodeFolder(this, currNode,
-                                                       currNode.getName()));
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while initializing ParentNodeFolder : "
-                                                       + getName(), re);
-               }
-       }
-
-       public Node getNode() {
-               return node;
-       }
-
-       // /**
-       // * Overriden in the specific case of "My result" root object to return an
-       // * ordered list of children
-       // */
-       // public synchronized Object[] getChildren() {
-       // Object[] children = super.getChildren();
-       // try {
-       // if (node.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
-       // return ResultParentUtils.orderChildren(children);
-       // else
-       // return children;
-       // } catch (RepositoryException re) {
-       // throw new SlcException(
-       // "Unexpected error while initializing simple node folder : "
-       // + getName(), re);
-       // }
-       // }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultFolder.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultFolder.java
deleted file mode 100644 (file)
index 25d0259..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-
-/**
- * UI Tree component that wrap a node of type ResultFolder. list either other
- * folders and/or a list of results. keeps a reference to its parent.
- */
-public class ResultFolder extends ParentNodeFolder {
-
-       /**
-        * 
-        * @param parent
-        * @param node
-        *            throws an exception if null
-        * @param name
-        */
-       public ResultFolder(ParentNodeFolder parent, Node node, String name) {
-               super(parent, node, name);
-               try {
-                       // initialize passed status if possible
-                       if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
-                               setPassed(node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
-                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean());
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while initializing result folder : "
-                                                       + getName(), re);
-               }
-       }
-
-       // /**
-       // * Overriden to return an ordered list of children
-       // */
-       // public synchronized Object[] getChildren() {
-       // Object[] children = super.getChildren();
-       // return ResultParentUtils.orderChildren(children);
-       // }
-       //
-       // public int compareTo(ResultFolder o) {
-       // return super.compareTo(o);
-       // }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparator.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparator.java
deleted file mode 100644 (file)
index 74ec9ec..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-
-/** Enable specific sorting of the ResultTreeView */
-public class ResultItemsComparator extends ViewerComparator {
-
-       @Override
-       public int category(Object element) {
-               if (element instanceof SingleResultNode) {
-                       return 10;
-
-               }
-               // folder always first
-               return 5;
-       }
-
-       @Override
-       public int compare(Viewer viewer, Object e1, Object e2) {
-               int cat1 = category(e1);
-               int cat2 = category(e2);
-
-               if (cat1 != cat2) {
-                       return cat1 - cat2;
-               }
-
-               int result = 0;
-
-               if (e1 instanceof TreeParent && ((TreeParent) e1).getParent() == null) {
-                       // preserve predefined order on UI root items
-                       return 0;
-               }
-
-               if (e1 instanceof SingleResultNode && e2 instanceof SingleResultNode) {
-                       Node an = ((SingleResultNode) e1).getNode();
-                       Node bn = ((SingleResultNode) e2).getNode();
-                       try {
-                               // Order is different if we are under my Result or )in the
-                               // rest of the tree structure
-                               if (an.getParent().isNodeType(
-                                               SlcTypes.SLC_MY_RESULT_ROOT_FOLDER)
-                                               || an.getParent()
-                                                               .isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
-                                       result = super.compare(viewer, e1, e2);
-                                       // Specific case of two result with same name
-                                       if (result == 0) {
-                                               result = an
-                                                               .getProperty(SlcNames.SLC_COMPLETED)
-                                                               .getDate()
-                                                               .compareTo(
-                                                                               bn.getProperty(SlcNames.SLC_COMPLETED)
-                                                                                               .getDate());
-                                       }
-                               } else {
-                                       result = an
-                                                       .getProperty(Property.JCR_CREATED)
-                                                       .getDate()
-                                                       .compareTo(
-                                                                       bn.getProperty(Property.JCR_CREATED)
-                                                                                       .getDate());
-                                       result = result * -1; // last are displayed first
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Unable to compare date created", e);
-                       }
-               } else if (e1 instanceof ParentNodeFolder
-                               && e2 instanceof ParentNodeFolder) {
-                       try {
-                               Node an = ((ParentNodeFolder) e1).getNode();
-                               // under my Result
-                               if (an.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER)
-                                               || an.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
-                                       result = super.compare(viewer, e1, e2);
-                               } else {
-                                       // only remaining objects for the time being
-                                       // NT_UNSTRUCTURED that display all result tree structures
-                                       // We want the newest folders first
-                                       result = super.compare(viewer, e1, e2) * -1;
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Unable to compare date created", e);
-                       }
-               }
-               return result;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparer.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparer.java
deleted file mode 100644 (file)
index 14b9b06..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.eclipse.jface.viewers.IElementComparer;
-
-/**
- * Override default behaviour to insure that 2 distincts results that have the
- * same name will be correctly and distincly returned by corresponding
- * TreeViewer.getSelection() method.
- * 
- */
-public class ResultItemsComparer implements IElementComparer {
-       // private final static Log log =
-       // LogFactory.getLog(ResultItemsComparer.class);
-
-       public boolean equals(Object a, Object b) {
-               if (b == null)
-                       return a == null ? true : false;
-
-               if (a.hashCode() != b.hashCode() || !a.getClass().equals(b.getClass()))
-                       return false;
-               else if (a instanceof SingleResultNode) {
-                       try {
-                               String ida = ((SingleResultNode) a).getNode().getIdentifier();
-
-                               String idb = ((SingleResultNode) b).getNode().getIdentifier();
-
-                               if (ida.equals(idb))
-                                       return true;
-                               else
-                                       return false;
-
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot compare single reult nodes", e);
-                       }
-               } else
-                       return true;
-       }
-
-       public int hashCode(Object element) {
-               return element.hashCode();
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParent.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParent.java
deleted file mode 100644 (file)
index 8ea91f2..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.argeo.slc.client.ui.model;
-
-import org.argeo.eclipse.ui.TreeParent;
-
-/**
- * Common base UI object to build result Tree.
- */
-
-public abstract class ResultParent extends TreeParent {
-
-       public ResultParent(String name) {
-               super(name);
-       }
-
-       private boolean isPassed = true;
-
-       protected synchronized void setPassed(boolean isPassed) {
-               this.isPassed = isPassed;
-       }
-
-       public boolean isPassed() {
-               return isPassed;
-       }
-
-       @Override
-       public synchronized boolean hasChildren() {
-               // only initialize when needed : correctly called by the jface framework
-               if (!isLoaded())
-                       initialize();
-               return super.hasChildren();
-       }
-
-       public void forceFullRefresh() {
-               // if (isDisposed)
-               // return;
-               if (hasChildren())
-                       clearChildren();
-               initialize();
-       }
-
-       protected abstract void initialize();
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParentUtils.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParentUtils.java
deleted file mode 100644 (file)
index 98fd194..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-package org.argeo.slc.client.ui.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-
-public class ResultParentUtils {
-       // private final static Log log =
-       // LogFactory.getLog(ResultParentUtils.class);
-
-       // public static Object[] orderChildren(Object[] children) {
-       // List<ResultFolder> folders = new ArrayList<ResultFolder>();
-       // List<SingleResultNode> results = new ArrayList<SingleResultNode>();
-       // for (Object child : children) {
-       // if (child instanceof ResultFolder)
-       // folders.add((ResultFolder) child);
-       // else if (child instanceof SingleResultNode)
-       // results.add((SingleResultNode) child);
-       // }
-       //
-       // // Comparator first = Collections.reverseOrder();
-       // Collections.sort(folders);
-       // // Comparator<SingleResultNode> second = Collections.reverseOrder();
-       // Collections.sort(results);
-       //
-       // Object[] orderedChildren = new Object[folders.size() + results.size()];
-       // int i = 0;
-       // Iterator<ResultFolder> it = folders.iterator();
-       // while (it.hasNext()) {
-       // orderedChildren[i] = it.next();
-       // i++;
-       // }
-       // Iterator<SingleResultNode> it2 = results.iterator();
-       // while (it2.hasNext()) {
-       // orderedChildren[i] = it2.next();
-       // i++;
-       // }
-       // return orderedChildren;
-       // }
-
-       public static List<Node> getResultsForDates(Session session,
-                       List<String> dateRelPathes) {
-               if (dateRelPathes == null || dateRelPathes.size() == 0)
-                       throw new SlcException("Specify at least one correct date as Path");
-
-               try {
-                       String basePath = SlcJcrResultUtils.getSlcResultsBasePath(session);
-                       Iterator<String> it = dateRelPathes.iterator();
-                       StringBuffer clause = new StringBuffer();
-                       clause.append("SELECT * FROM [");
-                       clause.append(SlcTypes.SLC_TEST_RESULT);
-                       clause.append("] as results");
-                       clause.append(" WHERE ");
-                       while (it.hasNext()) {
-                               String absPath = basePath + "/" + it.next();
-                               clause.append("ISDESCENDANTNODE(results, [");
-                               clause.append(absPath);
-                               clause.append("]) ");
-                               clause.append(" OR ");
-                       }
-                       // remove last " OR "
-                       clause.delete(clause.length() - 4, clause.length());
-                       clause.append(" ORDER BY results.[" + Property.JCR_CREATED
-                                       + "] DESC");
-
-                       // log.debug("request : " + clause.toString());
-                       QueryManager qm = session.getWorkspace().getQueryManager();
-                       Query q = qm.createQuery(clause.toString(), Query.JCR_SQL2);
-                       QueryResult result = q.execute();
-
-                       NodeIterator ni = result.getNodes();
-                       List<Node> nodes = new ArrayList<Node>();
-                       while (ni.hasNext()) {
-                               nodes.add(ni.nextNode());
-                       }
-                       return nodes;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while getting Results for given date", re);
-               }
-       }
-
-       /**
-        * recursively update passed status of the current ResultFolder and its
-        * parent if needed
-        * 
-        * @param node
-        *            cannot be null
-        * 
-        */
-       public static void updatePassedStatus(Node node, boolean passed) {
-               try {
-                       if (!node.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
-                               // we have reached the root of the tree. stop the
-                               // recursivity
-                               return;
-                       boolean pStatus = node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
-                                       .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
-                       if (pStatus == passed)
-                               // nothing to update
-                               return;
-                       else if (!passed) {
-                               // New status is 'failed' : we only update status of the result
-                               // folder and its
-                               // parent if needed
-                               node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
-                                               SlcNames.SLC_SUCCESS, passed);
-                               updatePassedStatus(node.getParent(), passed);
-                       } else {
-                               // New status is 'passed': we must first check if all siblings
-                               // have also
-                               // successfully completed
-                               boolean success = true;
-                               NodeIterator ni = node.getNodes();
-                               children: while (ni.hasNext()) {
-                                       Node currNode = ni.nextNode();
-                                       if ((currNode.isNodeType(SlcTypes.SLC_DIFF_RESULT) || currNode
-                                                       .isNodeType(SlcTypes.SLC_RESULT_FOLDER))
-                                                       && !currNode
-                                                                       .getNode(SlcNames.SLC_AGGREGATED_STATUS)
-                                                                       .getProperty(SlcNames.SLC_SUCCESS)
-                                                                       .getBoolean()) {
-                                               success = false;
-                                               break children;
-                                       }
-                               }
-                               if (success) {
-                                       node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
-                                                       SlcNames.SLC_SUCCESS, passed);
-                                       updatePassedStatus(node.getParent(), passed);
-                               } else
-                                       // one of the siblings had also the failed status so
-                                       // above tree remains unchanged.
-                                       return;
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot update result passed status", e);
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/SingleResultNode.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/SingleResultNode.java
deleted file mode 100644 (file)
index ff14fcf..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Workspace;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-
-/**
- * UI Tree component. Wraps a result node of a JCR {@link Workspace}. It also
- * keeps a reference to its parent node that can either be a
- * {@link ResultFolder}, a {@link SingleResultNode} or a {@link VirtualFolder}.
- * It has no child.
- */
-
-public class SingleResultNode extends ResultParent implements
-               Comparable<SingleResultNode> {
-
-       private final Node node;
-       private boolean passed;
-
-       // keeps a local reference to the node's name to avoid exception when the
-       // session is lost
-
-       /** Creates a new UiNode in the UI Tree */
-       public SingleResultNode(TreeParent parent, Node node, String name) {
-               super(name);
-               setParent(parent);
-               this.node = node;
-               setPassed(refreshPassedStatus());
-       }
-
-       public boolean refreshPassedStatus() {
-               try {
-                       Node check;
-                       if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS)) {
-                               check = node.getNode(SlcNames.SLC_AGGREGATED_STATUS);
-                               passed = check.getProperty(SlcNames.SLC_SUCCESS).getBoolean();
-                               return passed;
-                       } else
-                               // Happens only if the UI triggers a refresh while the execution
-                               // is in progress and the corresponding node is being built
-                               return false;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while checking result status", re);
-               }
-       }
-
-       /** returns the node wrapped by the current UI object */
-       public Node getNode() {
-               return node;
-       }
-
-       /**
-        * Override normal behavior : Results have no children for this view
-        */
-       @Override
-       public synchronized Object[] getChildren() {
-               return null;
-       }
-
-       @Override
-       public boolean hasChildren() {
-               return false;
-       }
-
-       public boolean isPassed() {
-               return passed;
-       }
-
-       @Override
-       protected void initialize() {
-               // Do nothing this object is fully initialized at instantiation time.
-       }
-
-       public int compareTo(SingleResultNode o) {
-               return super.compareTo(o);
-       }
-
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/VirtualFolder.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/VirtualFolder.java
deleted file mode 100644 (file)
index 558fe0d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.argeo.slc.client.ui.model;
-
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/**
- * UI Tree component. Virtual folder to list a list of results. Keeps a
- * reference to its parent that might be null. It also keeps a reference to all
- * nodes that must be displayed as children of the current virtual folder.
- */
-public class VirtualFolder extends ResultParent {
-       List<Node> displayedNodes;
-
-       public VirtualFolder(VirtualFolder parent, List<Node> displayedNodes,
-                       String name) {
-               super(name);
-               setParent(parent);
-               this.displayedNodes = displayedNodes;
-       }
-
-       @Override
-       protected void initialize() {
-               try {
-                       for (Node currNode : displayedNodes) {
-                               if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
-                                       SingleResultNode srn = new SingleResultNode(this, currNode,
-                                                       currNode.getProperty(SlcNames.SLC_TEST_CASE)
-                                                                       .getString());
-                                       addChild(srn);
-                               }
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while initializing ParentNodeFolder : "
-                                                       + getName(), re);
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeContentProvider.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeContentProvider.java
deleted file mode 100644 (file)
index c2594ec..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.argeo.slc.client.ui.providers;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/** Basic content provider for a tree of result */
-public class ResultTreeContentProvider implements ITreeContentProvider {
-
-       /**
-        * @param parent
-        *            Pass current user home as parameter
-        * 
-        */
-       public Object[] getElements(Object parent) {
-               if (parent instanceof Object[])
-                       return (Object[]) parent;
-               else
-                       return null;
-       }
-
-       public Object getParent(Object child) {
-               return ((TreeParent) child).getParent();
-       }
-
-       public Object[] getChildren(Object parent) {
-               return ((TreeParent) parent).getChildren();
-       }
-
-       public boolean hasChildren(Object parent) {
-               return ((TreeParent) parent).hasChildren();
-       }
-
-       public void dispose() {
-               // FIXME implement if needed
-       }
-
-       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java
deleted file mode 100644 (file)
index 3c418d6..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.argeo.slc.client.ui.providers;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.client.ui.SlcUiConstants;
-import org.argeo.slc.client.ui.model.ParentNodeFolder;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/** Basic label provider for a tree of result */
-public class ResultTreeLabelProvider extends LabelProvider {
-       // private final static Log log = LogFactory
-       // .getLog(ResultTreeLabelProvider.class);
-
-       @Override
-       public String getText(Object element) {
-               try {
-
-                       if (element instanceof SingleResultNode) {
-                               Node node = ((SingleResultNode) element).getNode();
-                               if (node.isNodeType(NodeType.MIX_TITLE))
-                                       return node.getProperty(Property.JCR_TITLE).getString();
-
-                       } else if (element instanceof ParentNodeFolder) {
-                               Node node = ((ParentNodeFolder) element).getNode();
-                               if (node.hasProperty(Property.JCR_TITLE))
-                                       return node.getProperty(Property.JCR_TITLE).getString();
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unexpected error while getting "
-                                       + "custom result label", e);
-               }
-               return ((TreeParent) element).getName();
-       }
-
-       public Image getImage(Object obj) {
-               if (obj instanceof SingleResultNode) {
-                       // FIXME add realtime modification of process icon (SCHEDULED,
-                       // RUNNING, COMPLETED...)
-                       // Node resultNode = ((SingleResultNode) obj).getNode();
-                       // int status = SlcJcrUtils.aggregateTestStatus(resultNode);
-                       return SlcImages.PROCESS_COMPLETED;
-               } else if (obj instanceof ResultParent) {
-                       ResultParent rParent = (ResultParent) obj;
-                       if (SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL.equals(rParent
-                                       .getName()))
-                               return SlcImages.MY_RESULTS_FOLDER;
-                       else
-                               return SlcImages.FOLDER;
-               } else
-                       return null;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java
deleted file mode 100644 (file)
index 6ddc197..0000000
+++ /dev/null
@@ -1,417 +0,0 @@
-package org.argeo.slc.client.ui.views;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.observation.Event;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.eclipse.ui.jcr.DefaultNodeLabelProvider;
-import org.argeo.eclipse.ui.jcr.NodeElementComparer;
-import org.argeo.eclipse.ui.jcr.SimpleNodeContentProvider;
-import org.argeo.eclipse.ui.specific.EclipseUiSpecificUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.client.ui.editors.ProcessEditor;
-import org.argeo.slc.client.ui.editors.ProcessEditorInput;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.jcr.SlcJcrConstants;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.rap.rwt.service.ServerPushSession;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceAdapter;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-/** JCR based view of the execution modules. */
-public class JcrExecutionModulesView extends ViewPart implements SlcTypes, SlcNames {
-       private final static Log log = LogFactory.getLog(JcrExecutionModulesView.class);
-
-       public static final String ID = ClientUiPlugin.ID + ".jcrExecutionModulesView";
-
-       private TreeViewer viewer;
-
-       private ServerPushSession pushSession;
-
-       /* DEPENDENCY INJECTION */
-       private Repository repository;
-       private Session session;
-       private ExecutionModulesManager modulesManager;
-
-       public void createPartControl(Composite parent) {
-               pushSession = new ServerPushSession();
-               pushSession.start();
-
-               try {
-                       session = repository.login();
-               } catch (RepositoryException e1) {
-                       throw new SlcException("Cannot log in to repository");
-               }
-
-               viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
-               EclipseUiSpecificUtils.enableToolTipSupport(viewer);
-               ViewContentProvider contentProvider = new ViewContentProvider(session);
-               viewer.setContentProvider(contentProvider);
-               viewer.setComparer(new NodeElementComparer());
-               final ViewLabelProvider viewLabelProvider = new ViewLabelProvider();
-               viewer.setLabelProvider(viewLabelProvider);
-               viewer.setInput(getViewSite());
-               viewer.addDoubleClickListener(new ViewDoubleClickListener());
-               // context menu
-               // addContextMenu(viewer);
-
-               getViewSite().setSelectionProvider(viewer);
-
-               Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
-               // Transfer[] tt = new Transfer[] { EditorInputTransfer.getInstance() };
-               int operations = DND.DROP_COPY | DND.DROP_MOVE;
-               viewer.addDragSupport(operations, tt, new ViewDragListener());
-
-               try {
-                       String[] nodeTypes = { SlcTypes.SLC_AGENT, SlcTypes.SLC_AGENT_FACTORY, SlcTypes.SLC_EXECUTION_MODULE };
-                       session.getWorkspace().getObservationManager().addEventListener(
-                                       new VmAgentObserver(viewer.getTree().getDisplay()),
-                                       Event.NODE_ADDED | Event.NODE_REMOVED | Event.NODE_MOVED, SlcJcrConstants.VM_AGENT_FACTORY_PATH,
-                                       true, null, nodeTypes, false);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot add observer", e);
-               }
-       }
-
-       public void setFocus() {
-               viewer.getControl().setFocus();
-       }
-
-       public TreeViewer getViewer() {
-               return viewer;
-       }
-
-       public void refreshView() {
-               viewer.setInput(getViewSite());
-       }
-
-       // Controllers
-       class ViewContentProvider extends SimpleNodeContentProvider {
-               private static final long serialVersionUID = 5117887833174813672L;
-
-               public ViewContentProvider(Session session) {
-                       super(session, new String[] { SlcJcrConstants.VM_AGENT_FACTORY_PATH });
-               }
-
-               @Override
-               protected Object[] sort(Object parent, Object[] children) {
-                       Object[] sorted = new Object[children.length];
-                       System.arraycopy(children, 0, sorted, 0, children.length);
-                       Arrays.sort(sorted, new ViewComparator());
-                       return sorted;
-               }
-
-               @Override
-               protected List<Node> filterChildren(List<Node> children) throws RepositoryException {
-                       for (Iterator<Node> it = children.iterator(); it.hasNext();) {
-                               Node node = it.next();
-                               // execution spec definitions
-                               if (node.getName().equals(SLC_EXECUTION_SPECS))
-                                       it.remove();
-                               // flow values
-                               else if (node.getParent().isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
-                                       it.remove();
-                       }
-                       return super.filterChildren(children);
-               }
-
-               @Override
-               public boolean hasChildren(Object element) {
-                       if (element instanceof Node) {
-                               Node node = (Node) element;
-                               try {
-                                       if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
-                                               return false;
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot check has children", e);
-                               }
-                       }
-                       return super.hasChildren(element);
-               }
-       }
-
-       static class ViewComparator implements Comparator<Object> {
-
-               public int compare(Object o1, Object o2) {
-                       try {
-                               if (o1 instanceof Node && o2 instanceof Node) {
-                                       Node node1 = (Node) o1;
-                                       Node node2 = (Node) o2;
-
-                                       if (node1.getName().equals(SLC_EXECUTION_SPECS))
-                                               return -100;
-                                       if (node2.getName().equals(SLC_EXECUTION_SPECS))
-                                               return 100;
-
-                                       if (node1.isNodeType(SLC_EXECUTION_FLOW) && node2.isNodeType(SLC_EXECUTION_FLOW)) {
-                                               return node1.getName().compareTo(node2.getName());
-                                       } else if (node1.isNodeType(SLC_EXECUTION_FLOW) && !node2.isNodeType(SLC_EXECUTION_FLOW)) {
-                                               return 1;
-                                       } else if (!node1.isNodeType(SLC_EXECUTION_FLOW) && node2.isNodeType(SLC_EXECUTION_FLOW)) {
-                                               return -1;
-                                       } else {
-                                               // TODO: check title
-                                               return node1.getName().compareTo(node2.getName());
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot compare " + o1 + " and " + o2, e);
-                       }
-                       return 0;
-               }
-
-       }
-
-       // private void addContextMenu(TreeViewer flowsViewer) {
-       //
-       // final MenuManager menuMgr = new MenuManager();
-       // menuMgr.setRemoveAllWhenShown(true);
-       // menuMgr.addMenuListener(new IMenuListener() {
-       //
-       // public void menuAboutToShow(IMenuManager manager) {
-       // menuMgr.add(new Action("Test") {
-       // public void run() {
-       // log.debug("do something");
-       // }
-       // });
-       // }
-       // });
-       // Menu menu = menuMgr.createContextMenu(flowsViewer.getControl());
-       // flowsViewer.getTree().setMenu(menu);
-       // getSite().registerContextMenu(menuMgr, flowsViewer);
-       // }
-
-       class VmAgentObserver extends AsyncUiEventListener {
-
-               public VmAgentObserver(Display display) {
-                       super(display);
-               }
-
-               protected void onEventInUiThread(List<Event> events) {
-                       for (Event event : events) {
-                               try {
-                                       String path = event.getPath();
-
-                                       if (session.itemExists(path)) {
-                                               Node parentNode = session.getNode(path);// .getParent();
-                                               if (log.isTraceEnabled())
-                                                       log.trace("Refresh " + parentNode + " after event " + event);
-                                               viewer.refresh(parentNode);
-                                       }
-                               } catch (RepositoryException e) {
-                                       log.warn("Cannot process event " + event + ": " + e);
-                               }
-                       }
-
-                       // TODO: optimize based on event
-                       viewer.refresh();
-               }
-       }
-
-       class ViewLabelProvider extends DefaultNodeLabelProvider implements ITableLabelProvider {
-               private static final long serialVersionUID = 2410754425574656399L;
-
-               @Override
-               protected String getText(Node node) throws RepositoryException {
-                       if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_TITLE))
-                               return node.getProperty(Property.JCR_TITLE).getString();
-                       else if (node.getName().equals(SLC_EXECUTION_SPECS))
-                               return "Execution Specifications";
-                       else if (node.getPath().equals(SlcJcrConstants.VM_AGENT_FACTORY_PATH))
-                               return "Internal Agents";
-                       return super.getText(node);
-               }
-
-               @Override
-               public Image getImage(Node node) throws RepositoryException {
-                       // we try to optimize a bit by putting deeper nodes first
-                       if (node.getParent().isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
-                               return SlcImages.CHOICES;
-                       else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
-                               return SlcImages.EXECUTION_SPEC_ATTRIBUTE;
-                       else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC))
-                               return SlcImages.EXECUTION_SPEC;
-                       else if (node.getName().equals(SLC_EXECUTION_SPECS))
-                               return SlcImages.EXECUTION_SPECS;
-                       else if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
-                               return SlcImages.FLOW;
-                       else if (node.isNodeType(SlcTypes.SLC_MODULE)) {
-                               if (node.getProperty(SLC_STARTED).getBoolean())
-                                       return SlcImages.MODULE;
-                               else
-                                       return SlcImages.MODULE_STOPPED;
-                       } else if (node.isNodeType(SlcTypes.SLC_AGENT))
-                               return SlcImages.AGENT;
-                       else if (node.isNodeType(SlcTypes.SLC_AGENT_FACTORY))
-                               return SlcImages.AGENT_FACTORY;
-                       else
-                               return SlcImages.FOLDER;
-               }
-
-               public String getToolTipText(Node node) throws RepositoryException {
-                       if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_DESCRIPTION))
-                               return node.getProperty(Property.JCR_DESCRIPTION).getString();
-                       return super.getToolTipText(node);
-               }
-
-               public String getColumnText(Object obj, int index) {
-                       return getText(obj);
-               }
-
-               public Image getColumnImage(Object obj, int index) {
-                       return getImage(obj);
-               }
-
-       }
-
-       class ViewDoubleClickListener implements IDoubleClickListener {
-               public void doubleClick(DoubleClickEvent evt) {
-                       Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement();
-                       try {
-                               if (obj instanceof Node) {
-                                       Node node = (Node) obj;
-                                       if (node.isNodeType(SLC_EXECUTION_MODULE)) {
-                                               ClientUiPlugin.startStopExecutionModule(modulesManager, node);
-                                       } else {
-                                               String path = node.getPath();
-                                               // TODO factorize with editor
-                                               QueryManager qm = node.getSession().getWorkspace().getQueryManager();
-                                               String statement = "SELECT * FROM [" + SlcTypes.SLC_EXECUTION_FLOW
-                                                               + "] WHERE ISDESCENDANTNODE(['" + path + "']) OR ISSAMENODE(['" + path + "'])";
-                                               // log.debug(statement);
-                                               Query query = qm.createQuery(statement, Query.JCR_SQL2);
-
-                                               // order paths
-                                               SortedSet<String> paths = new TreeSet<String>();
-                                               for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
-                                                       paths.add(nit.nextNode().getPath());
-                                               }
-
-                                               IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
-                                                               .getActivePage();
-                                               activePage.openEditor(new ProcessEditorInput(new ArrayList<String>(paths), true),
-                                                               ProcessEditor.ID);
-                                       }
-                               }
-                       } catch (Exception e) {
-                               throw new SlcException("Cannot open " + obj, e);
-                       }
-               }
-
-       }
-
-       /** Listen to drags */
-       class ViewDragListener extends DragSourceAdapter {
-               private static final long serialVersionUID = 250270504802674171L;
-
-               // Check if the drag action should start.
-               public void dragStart(DragSourceEvent event) {
-                       // we only start drag if at least one of the selected elements is
-                       // valid
-                       boolean doIt = false;
-                       IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
-                       @SuppressWarnings("rawtypes")
-                       Iterator it = selection.iterator();
-                       try {
-                               while (it.hasNext()) {
-                                       Object obj = it.next();
-                                       if (obj instanceof Node) {
-                                               Node node = (Node) obj;
-                                               if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW)
-                                                               || node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) {
-                                                       doIt = true;
-                                               }
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot read node to set drag data", e);
-                       }
-                       event.doit = doIt;
-               }
-
-               public void dragSetData(DragSourceEvent event) {
-                       IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
-                       StringBuilder buf = new StringBuilder();
-                       @SuppressWarnings("rawtypes")
-                       Iterator it = selection.iterator();
-                       try {
-
-                               while (it.hasNext()) {
-                                       Object obj = it.next();
-
-                                       if (obj instanceof Node) {
-                                               Node node = (Node) obj;
-                                               if ((node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW)
-                                                               || node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE))
-                                                               && TextTransfer.getInstance().isSupportedType(event.dataType)) {
-                                                       buf.append(node.getPath()).append('\n');
-                                               }
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot read node to set drag data", e);
-                       }
-
-                       if (buf.length() > 0) {
-                               if (buf.charAt(buf.length() - 1) == '\n')
-                                       buf.deleteCharAt(buf.length() - 1);
-                               event.data = buf.toString();
-                               log.debug("data set to : " + buf.toString());
-                       }
-               }
-       }
-
-       public void dispose() {
-               JcrUtils.logoutQuietly(session);
-               if (pushSession != null)
-                       pushSession.stop();
-               super.dispose();
-       }
-
-       // DEPENDENCY INJECTION
-
-       public void setModulesManager(ExecutionModulesManager modulesManager) {
-               this.modulesManager = modulesManager;
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java
deleted file mode 100644 (file)
index 7a92144..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-package org.argeo.slc.client.ui.views;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-import javax.jcr.query.Query;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.client.ui.editors.ProcessEditor;
-import org.argeo.slc.client.ui.editors.ProcessEditorInput;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rap.rwt.service.ServerPushSession;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-/** Displays processes. */
-public class JcrProcessListView extends ViewPart {
-       public static final String ID = ClientUiPlugin.ID + ".jcrProcessListView";
-
-       private TableViewer viewer;
-       private ServerPushSession pushSession;
-
-       private Repository repository;
-       private Session session;
-
-       private EventListener processesObserver;
-
-       private DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
-       private Integer queryLimit = 2000;
-
-       public void createPartControl(Composite parent) {
-               pushSession = new ServerPushSession();
-               pushSession.start();
-               try {
-                       session = repository.login(NodeConstants.HOME_WORKSPACE);
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unable to log in Repository " + repository, re);
-               }
-               Table table = createTable(parent);
-               viewer = new TableViewer(table);
-               viewer.setLabelProvider(new LabelProvider());
-               viewer.setContentProvider(new ContentProvider());
-               viewer.setInput(getViewSite());
-               viewer.addDoubleClickListener(new ViewDoubleClickListener());
-
-               processesObserver = new AsyncUiEventListener(viewer.getTable().getDisplay()) {
-                       protected void onEventInUiThread(List<Event> events) {
-                               // TODO optimize by updating only the changed process
-                               viewer.refresh();
-                       }
-               };
-               try {
-                       ObservationManager observationManager = session.getWorkspace().getObservationManager();
-                       observationManager.addEventListener(processesObserver,
-                                       Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_CHANGED,
-                                       SlcJcrUtils.getSlcProcessesBasePath(session), true, null, null, false);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot register listeners", e);
-               }
-
-       }
-
-       protected Table createTable(Composite parent) {
-               int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
-               // does not function with RAP, commented for the time being
-               // | SWT.HIDE_SELECTION;
-
-               Table table = new Table(parent, style);
-
-               table.setLinesVisible(true);
-               table.setHeaderVisible(true);
-
-               TableColumn column = new TableColumn(table, SWT.LEFT, 0);
-               column.setText("Date");
-               column.setWidth(200);
-
-               column = new TableColumn(table, SWT.LEFT, 1);
-               column.setText("Host");
-               column.setWidth(100);
-
-               column = new TableColumn(table, SWT.LEFT, 2);
-               column.setText("Id");
-               column.setWidth(300);
-
-               column = new TableColumn(table, SWT.LEFT, 3);
-               column.setText("Status");
-               column.setWidth(100);
-
-               return table;
-       }
-
-       public void setFocus() {
-               viewer.getControl().setFocus();
-       }
-
-       class ContentProvider implements IStructuredContentProvider {
-
-               public Object[] getElements(Object inputElement) {
-                       try {
-                               // TODO filter, optimize with virtual table, ...
-                               String sql = "SELECT * from [slc:process] ORDER BY [jcr:lastModified] DESC";
-                               Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
-                               // TODO paging
-                               query.setLimit(queryLimit);
-                               List<Node> nodes = new ArrayList<Node>();
-                               for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
-                                       nodes.add(nit.nextNode());
-                               }
-                               return nodes.toArray();
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot retrieve processes", e);
-                       }
-               }
-
-               public void dispose() {
-               }
-
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-               }
-
-       }
-
-       class LabelProvider extends ColumnLabelProvider implements ITableLabelProvider {
-
-               public Image getColumnImage(Object obj, int columnIndex) {
-                       if (columnIndex != 0)
-                               return null;
-                       try {
-                               Node node = (Node) obj;
-                               String status = node.getProperty(SlcNames.SLC_STATUS).getString();
-                               if (status.equals(ExecutionProcess.NEW) || status.equals(ExecutionProcess.INITIALIZED)
-                                               || status.equals(ExecutionProcess.SCHEDULED))
-                                       return SlcImages.PROCESS_SCHEDULED;
-                               else if (status.equals(ExecutionProcess.ERROR) || status.equals(ExecutionProcess.UNKOWN))
-                                       return SlcImages.PROCESS_ERROR;
-                               else if (status.equals(ExecutionProcess.COMPLETED))
-                                       return SlcImages.PROCESS_COMPLETED;
-                               else if (status.equals(ExecutionProcess.RUNNING))
-                                       return SlcImages.PROCESS_RUNNING;
-                               else if (status.equals(ExecutionProcess.KILLED))
-                                       return SlcImages.PROCESS_ERROR;
-                               else
-                                       throw new SlcException("Unkown status " + status);
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get column text", e);
-                       }
-               }
-
-               public String getColumnText(Object obj, int index) {
-                       try {
-                               Node node = (Node) obj;
-                               switch (index) {
-
-                               case 0:
-                                       return dateFormat.format(node.getProperty(Property.JCR_LAST_MODIFIED).getDate().getTime());
-                               case 1:
-                                       return "local";
-                               case 2:
-                                       return node.getProperty(SlcNames.SLC_UUID).getString();
-                               case 3:
-                                       return node.getProperty(SlcNames.SLC_STATUS).getString();
-                               }
-                               return getText(obj);
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get column text", e);
-                       }
-               }
-
-       }
-
-       class ViewDoubleClickListener implements IDoubleClickListener {
-               public void doubleClick(DoubleClickEvent evt) {
-                       Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement();
-                       try {
-                               if (obj instanceof Node) {
-                                       Node node = (Node) obj;
-                                       if (node.isNodeType(SlcTypes.SLC_PROCESS)) {
-                                               IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
-                                                               .getActivePage();
-                                               activePage.openEditor(new ProcessEditorInput(node.getPath()), ProcessEditor.ID);
-                                       }
-                               }
-                       } catch (Exception e) {
-                               throw new SlcException("Cannot open " + obj, e);
-                       }
-               }
-
-       }
-
-       public void dispose() {
-               JcrUtils.unregisterQuietly(session.getWorkspace(), processesObserver);
-               JcrUtils.logoutQuietly(session);
-               if (pushSession != null)
-                       pushSession.stop();
-               super.dispose();
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java
deleted file mode 100644 (file)
index 41a1d52..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-package org.argeo.slc.client.ui.views;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-import javax.jcr.query.Query;
-
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.eclipse.ui.jcr.NodeElementComparer;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.editors.ProcessEditor;
-import org.argeo.slc.client.ui.editors.ProcessEditorInput;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-/** Displays results. */
-public class JcrResultListView extends ViewPart implements SlcNames {
-       public static final String ID = ClientUiPlugin.ID + ".jcrResultListView";
-
-       private TableViewer viewer;
-
-       private Repository repository;
-       private Session session;
-
-       private EventListener resultsObserver;
-
-       private DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
-       private Integer queryLimit = 2000;
-
-       public void createPartControl(Composite parent) {
-               try {
-                       session = repository.login();
-               } catch (RepositoryException e1) {
-                       throw new SlcException("Cannot log in to repository");
-               }
-
-               Table table = createTable(parent);
-               viewer = new TableViewer(table);
-               viewer.setLabelProvider(createLabelProvider());
-               viewer.setContentProvider(new ViewContentProvider());
-               viewer.setInput(getViewSite());
-               viewer.addDoubleClickListener(new ViewDoubleClickListener());
-               viewer.setComparer(new NodeElementComparer());
-
-               getViewSite().setSelectionProvider(viewer);
-
-               resultsObserver = new ResultObserver(viewer.getTable().getDisplay());
-               try {
-                       ObservationManager observationManager = session.getWorkspace().getObservationManager();
-                       String[] nodeTypes = { SlcTypes.SLC_TEST_RESULT };
-                       // FIXME Will not be notified if empty result is deleted
-                       observationManager.addEventListener(resultsObserver, Event.PROPERTY_ADDED | Event.NODE_REMOVED,
-                                       SlcJcrResultUtils.getSlcResultsBasePath(session), true, null, nodeTypes, false);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot register listeners", e);
-               }
-
-       }
-
-       protected Table createTable(Composite parent) {
-               int style = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI;
-               // does not work with RAP, commented for the time being
-               // | SWT.HIDE_SELECTION;
-
-               Table table = new Table(parent, style);
-
-               table.setLinesVisible(true);
-               table.setHeaderVisible(true);
-
-               TableColumn column = new TableColumn(table, SWT.LEFT, 0);
-               column.setText("Date");
-               column.setWidth(200);
-
-               column = new TableColumn(table, SWT.LEFT, 1);
-               column.setText("Id");
-               column.setWidth(300);
-
-               return table;
-       }
-
-       // public void refresh() {
-       // viewer.refresh();
-       // }
-
-       /*
-        * METHODS TO BE OVERRIDDEN
-        */
-       protected IBaseLabelProvider createLabelProvider() {
-               return new ViewLabelProvider();
-       }
-
-       protected void processDoubleClick(DoubleClickEvent evt) {
-               Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement();
-               try {
-                       if (obj instanceof Node) {
-                               Node node = (Node) obj;
-                               // FIXME: open a default result editor
-                               if (node.isNodeType(SlcTypes.SLC_PROCESS)) {
-                                       IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-                                       activePage.openEditor(new ProcessEditorInput(node.getPath()), ProcessEditor.ID);
-                               }
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot open " + obj, e);
-               }
-       }
-
-       public void setFocus() {
-               viewer.getControl().setFocus();
-       }
-
-       class ViewContentProvider implements IStructuredContentProvider {
-               private static final long serialVersionUID = -4719077015405546260L;
-
-               public Object[] getElements(Object inputElement) {
-                       try {
-                               // TODO filter, optimize with virtual table, ...
-                               String sql = "SELECT * from [" + SlcTypes.SLC_TEST_RESULT + "] ORDER BY [jcr:lastModified] DESC";
-                               Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
-                               // TODO paging
-                               query.setLimit(queryLimit);
-                               List<Node> nodes = new ArrayList<Node>();
-                               for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
-                                       nodes.add(nit.nextNode());
-                               }
-                               return nodes.toArray();
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot retrieve processes", e);
-                       }
-               }
-
-               public void dispose() {
-               }
-
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-               }
-
-       }
-
-       class ViewLabelProvider extends ColumnLabelProvider implements ITableLabelProvider {
-               private static final long serialVersionUID = -6323202576386795247L;
-
-               public Image getColumnImage(Object obj, int columnIndex) {
-                       if (columnIndex != 0)
-                               return null;
-                       try {
-                               Node node = (Node) obj;
-                               if (node.hasProperty(SLC_COMPLETED)) {
-                                       // TODO
-                               }
-                               return null;
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get column text", e);
-                       }
-               }
-
-               public String getColumnText(Object obj, int index) {
-                       try {
-                               Node node = (Node) obj;
-                               switch (index) {
-
-                               case 0:
-                                       if (node.hasProperty(SLC_COMPLETED)) {
-                                               return dateFormat.format(node.getProperty(SLC_COMPLETED).getDate().getTime());
-                                       } else {
-                                               return "OPEN";
-                                       }
-                               case 1:
-                                       return node.getProperty(SlcNames.SLC_UUID).getString();
-                               }
-                               return getText(obj);
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get column text", e);
-                       }
-               }
-
-       }
-
-       class ViewDoubleClickListener implements IDoubleClickListener {
-               public void doubleClick(DoubleClickEvent evt) {
-                       processDoubleClick(evt);
-               }
-
-       }
-
-       class ResultObserver extends AsyncUiEventListener {
-
-               public ResultObserver(Display display) {
-                       super(display);
-               }
-
-               @Override
-               protected Boolean willProcessInUiThread(List<Event> events) throws RepositoryException {
-                       for (Event event : events) {
-                               // getLog().debug("Received event " + event);
-                               int eventType = event.getType();
-                               if (eventType == Event.NODE_REMOVED)
-                                       return true;
-                               String path = event.getPath();
-                               int index = path.lastIndexOf('/');
-                               String propertyName = path.substring(index + 1);
-                               if (propertyName.equals(SLC_COMPLETED) || propertyName.equals(SLC_UUID)) {
-                                       return true;
-                               }
-                       }
-                       return false;
-               }
-
-               protected void onEventInUiThread(List<Event> events) throws RepositoryException {
-                       if (getLog().isTraceEnabled())
-                               getLog().trace("Refresh result list");
-                       viewer.refresh();
-               }
-       }
-
-       public void dispose() {
-               JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver);
-               JcrUtils.logoutQuietly(session);
-               super.dispose();
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java
deleted file mode 100644 (file)
index 824dcfd..0000000
+++ /dev/null
@@ -1,953 +0,0 @@
-package org.argeo.slc.client.ui.views;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcUiConstants;
-import org.argeo.slc.client.ui.commands.AddResultFolder;
-import org.argeo.slc.client.ui.commands.DeleteItems;
-import org.argeo.slc.client.ui.commands.RefreshJcrResultTreeView;
-import org.argeo.slc.client.ui.commands.RenameResultFolder;
-import org.argeo.slc.client.ui.commands.RenameResultNode;
-import org.argeo.slc.client.ui.editors.ProcessEditor;
-import org.argeo.slc.client.ui.editors.ProcessEditorInput;
-import org.argeo.slc.client.ui.model.ParentNodeFolder;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.argeo.slc.client.ui.model.ResultItemsComparator;
-import org.argeo.slc.client.ui.model.ResultItemsComparer;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.model.ResultParentUtils;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.argeo.slc.client.ui.model.VirtualFolder;
-import org.argeo.slc.client.ui.providers.ResultTreeContentProvider;
-import org.argeo.slc.client.ui.providers.ResultTreeLabelProvider;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-/** SLC generic JCR Result tree view. */
-public class JcrResultTreeView extends ViewPart {
-       public final static String ID = ClientUiPlugin.ID + ".jcrResultTreeView";
-
-       private final static DateFormat dateFormat = new SimpleDateFormat(
-                       SlcUiConstants.DEFAULT_DISPLAY_DATE_TIME_FORMAT);
-
-       // private final static Log log =
-       // LogFactory.getLog(JcrResultTreeView.class);
-
-       /* DEPENDENCY INJECTION */
-       private Repository repository;
-       private Session session;
-
-       // This page widgets
-       private TreeViewer resultTreeViewer;
-       private TableViewer propertiesViewer;
-
-       private EventListener myResultsObserver = null;
-       private EventListener allResultsObserver = null;
-
-       // under My Results
-       private final static String[] observedNodeTypesUnderMyResult = {
-                       SlcTypes.SLC_TEST_RESULT, SlcTypes.SLC_RESULT_FOLDER,
-                       SlcTypes.SLC_MY_RESULT_ROOT_FOLDER };
-
-       private final static String[] observedNodeTypesUnderAllResults = {
-                       SlcTypes.SLC_TEST_RESULT, NodeType.NT_UNSTRUCTURED };
-
-       private boolean isResultFolder = false;
-
-       /**
-        * To be overridden to adapt size of form and result frames.
-        */
-       protected int[] getWeights() {
-               return new int[] { 70, 30 };
-       }
-
-       @Override
-       public void createPartControl(Composite parent) {
-               try {
-                       session = repository.login(NodeConstants.HOME_WORKSPACE);
-               } catch (RepositoryException e1) {
-                       throw new SlcException("Cannot log in to repository");
-               }
-
-               parent.setLayout(new FillLayout());
-               // Main layout
-               SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
-               sashForm.setSashWidth(4);
-               sashForm.setLayout(new FillLayout());
-
-               // Create the tree on top of the view
-               Composite top = new Composite(sashForm, SWT.NONE);
-               GridLayout gl = new GridLayout(1, false);
-               top.setLayout(gl);
-               resultTreeViewer = createResultsTreeViewer(top);
-
-               // Create the property viewer on the bottom
-               Composite bottom = new Composite(sashForm, SWT.NONE);
-               bottom.setLayout(new GridLayout(1, false));
-               propertiesViewer = createPropertiesViewer(bottom);
-
-               sashForm.setWeights(getWeights());
-
-               setOrderedInput(resultTreeViewer);
-
-               // Initialize observer
-               try {
-                       ObservationManager observationManager = session.getWorkspace()
-                                       .getObservationManager();
-                       myResultsObserver = new MyResultsObserver(resultTreeViewer
-                                       .getTree().getDisplay());
-                       allResultsObserver = new AllResultsObserver(resultTreeViewer
-                                       .getTree().getDisplay());
-
-                       // observe tree changes under MyResults
-                       observationManager.addEventListener(myResultsObserver,
-                                       Event.NODE_ADDED | Event.NODE_REMOVED,
-                                       SlcJcrResultUtils.getMyResultsBasePath(session), true,
-                                       null, observedNodeTypesUnderMyResult, false);
-                       // observe tree changes under All results
-                       observationManager.addEventListener(allResultsObserver,
-                                       Event.NODE_ADDED | Event.NODE_REMOVED,
-                                       SlcJcrResultUtils.getSlcResultsBasePath(session), true,
-                                       null, observedNodeTypesUnderAllResults, false);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot register listeners", e);
-               }
-       }
-
-       /**
-        * Override default behaviour so that default defined order remains
-        * unchanged on first level of the tree
-        */
-       private void setOrderedInput(TreeViewer viewer) {
-               // Add specific ordering
-               viewer.setInput(null);
-               viewer.setComparator(null);
-               viewer.setInput(initializeResultTree());
-               viewer.setComparator(new ResultItemsComparator());
-       }
-
-       // The main tree viewer
-       protected TreeViewer createResultsTreeViewer(Composite parent) {
-               int style = SWT.BORDER | SWT.MULTI;
-
-               TreeViewer viewer = new TreeViewer(parent, style);
-               viewer.getTree().setLayoutData(
-                               new GridData(SWT.FILL, SWT.FILL, true, true));
-
-               viewer.setContentProvider(new ResultTreeContentProvider());
-
-               // Add label provider with label decorator
-               ResultTreeLabelProvider rtLblProvider = new ResultTreeLabelProvider();
-               ILabelDecorator decorator = ClientUiPlugin.getDefault().getWorkbench()
-                               .getDecoratorManager().getLabelDecorator();
-               viewer.setLabelProvider(new DecoratingLabelProvider(rtLblProvider,
-                               decorator));
-               viewer.addDoubleClickListener(new ViewDoubleClickListener());
-
-               // Override default behaviour to insure that 2 distincts results that
-               // have the same name will be correctly and distincly returned by
-               // corresponding TreeViewer.getSelection() method.
-               viewer.setComparer(new ResultItemsComparer());
-
-               // viewer.setLabelProvider(rtLblProvider);
-               getSite().setSelectionProvider(viewer);
-
-               // add drag & drop support
-               int operations = DND.DROP_COPY | DND.DROP_MOVE;
-               Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
-               viewer.addDragSupport(operations, tt, new ViewDragListener());
-               viewer.addDropSupport(operations, tt, new ViewDropListener(viewer));
-
-               // add context menu
-               MenuManager menuManager = new MenuManager();
-               Menu menu = menuManager.createContextMenu(viewer.getTree());
-               menuManager.addMenuListener(new IMenuListener() {
-                       public void menuAboutToShow(IMenuManager manager) {
-                               contextMenuAboutToShow(manager);
-                       }
-               });
-               viewer.getTree().setMenu(menu);
-               menuManager.setRemoveAllWhenShown(true);
-
-               getSite().registerContextMenu(menuManager, viewer);
-
-               // add change listener to display TestResult information in the property
-               // viewer
-               viewer.addSelectionChangedListener(new MySelectionChangedListener());
-               return viewer;
-       }
-
-       // Detailed property viewer
-       protected TableViewer createPropertiesViewer(Composite parent) {
-               propertiesViewer = new TableViewer(parent);
-               propertiesViewer.getTable().setLayoutData(
-                               new GridData(SWT.FILL, SWT.FILL, true, true));
-               propertiesViewer.getTable().setHeaderVisible(true);
-               propertiesViewer.setContentProvider(new PropertiesContentProvider());
-               TableViewerColumn col = new TableViewerColumn(propertiesViewer,
-                               SWT.NONE);
-               col.getColumn().setText("Name");
-               col.getColumn().setWidth(100);
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       public String getText(Object element) {
-                               try {
-                                       String name = ((Property) element).getName();
-                                       String value = null;
-                                       if (SlcNames.SLC_TEST_CASE.equals(name))
-                                               value = "Test case";
-                                       else if (SlcNames.SLC_COMPLETED.equals(name))
-                                               value = "Completed on";
-                                       else if (SlcNames.SLC_SUCCESS.equals(name))
-                                               value = "Status";
-                                       else if (SlcNames.SLC_MESSAGE.equals(name))
-                                               value = "Message";
-                                       else if (SlcNames.SLC_ERROR_MESSAGE.equals(name))
-                                               value = "Error";
-                                       return value;
-                               } catch (RepositoryException e) {
-                                       throw new SlcException(
-                                                       "Unexpected exception in label provider", e);
-                               }
-                       }
-               });
-               col = new TableViewerColumn(propertiesViewer, SWT.NONE);
-               col.getColumn().setText("Value");
-               col.getColumn().setWidth(200);
-               col.setLabelProvider(new ColumnLabelProvider() {
-                       public String getText(Object element) {
-                               try {
-                                       Property property = (Property) element;
-                                       String name = property.getName();
-                                       String value = null;
-
-                                       if (SlcNames.SLC_TEST_CASE.equals(name)
-                                                       || SlcNames.SLC_ERROR_MESSAGE.equals(name)
-                                                       || SlcNames.SLC_MESSAGE.equals(name))
-                                               value = property.getValue().getString();
-                                       else if (SlcNames.SLC_COMPLETED.equals(name)) {
-                                               Calendar date = property.getValue().getDate();
-                                               value = dateFormat.format(date.getTime());
-                                       } else if (SlcNames.SLC_SUCCESS.equals(name)) {
-                                               if (property.getValue().getBoolean())
-                                                       value = "PASSED";
-                                               else {
-                                                       if (property.getParent().hasProperty(
-                                                                       SlcNames.SLC_ERROR_MESSAGE))
-                                                               value = "ERROR";
-                                                       else
-                                                               value = "FAILED";
-                                               }
-                                       }
-                                       return value;
-                               } catch (RepositoryException e) {
-                                       throw new SlcException(
-                                                       "Unexpected exception in label provider", e);
-                               }
-                       }
-               });
-               propertiesViewer.setInput(getViewSite());
-               return propertiesViewer;
-       }
-
-       /**
-        * Override to provide specific behaviour. Typically to enable the display
-        * of a result file.
-        * 
-        * @param evt
-        */
-       protected void processDoubleClick(DoubleClickEvent evt) {
-               Object obj = ((IStructuredSelection) evt.getSelection())
-                               .getFirstElement();
-               try {
-                       if (obj instanceof SingleResultNode) {
-                               SingleResultNode srNode = (SingleResultNode) obj;
-                               Node node = srNode.getNode();
-                               // FIXME: open a default result editor
-                               if (node.isNodeType(SlcTypes.SLC_PROCESS)) {
-                                       IWorkbenchPage activePage = PlatformUI.getWorkbench()
-                                                       .getActiveWorkbenchWindow().getActivePage();
-                                       activePage.openEditor(
-                                                       new ProcessEditorInput(node.getPath()),
-                                                       ProcessEditor.ID);
-                               }
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot open " + obj, e);
-               }
-       }
-
-       @Override
-       public void setFocus() {
-       }
-
-       /**
-        * refreshes the passed resultParent and its corresponding subtree. It
-        * refreshes the whole viewer if null is passed.
-        * 
-        * @param ResultParent
-        * 
-        */
-       public void refresh(ResultParent resultParent) {
-               if (resultParent == null) {
-                       if (!resultTreeViewer.getTree().isDisposed()) {
-                               TreePath[] tps = resultTreeViewer.getExpandedTreePaths();
-                               setOrderedInput(resultTreeViewer);
-                               resultTreeViewer.setExpandedTreePaths(tps);
-                       } else
-                               setOrderedInput(resultTreeViewer);
-               } else {
-                       if (resultParent instanceof ParentNodeFolder) {
-                               ParentNodeFolder currFolder = (ParentNodeFolder) resultParent;
-                               jcrRefresh(currFolder.getNode());
-                               currFolder.forceFullRefresh();
-                       }
-                       // FIXME: specific refresh does not work
-                       // resultTreeViewer.refresh(resultParent, true);
-                       refresh(null);
-               }
-       }
-
-       /**
-        * refreshes the passed node and its corresponding subtree.
-        * 
-        * @param node
-        *            cannot be null
-        * 
-        */
-       public boolean jcrRefresh(Node node) {
-               // if (log.isDebugEnabled())
-               // log.debug(" JCR refreshing " + node + "...");
-               // Thread.dumpStack();
-               boolean isPassed = true;
-               try {
-                       if (node.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
-                               isPassed = node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
-                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
-                       } else if (node.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
-                               NodeIterator ni = node.getNodes();
-                               while (ni.hasNext()) {
-                                       Node currChild = ni.nextNode();
-                                       isPassed = isPassed & jcrRefresh(currChild);
-                               }
-                               if (isPassed != node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
-                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean()) {
-                                       node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
-                                                       SlcNames.SLC_SUCCESS, isPassed);
-                                       node.getSession().save();
-                                       return isPassed;
-                               }
-                       } else
-                               ; // do nothing
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot register listeners", e);
-               }
-               return isPassed;
-       }
-
-       private ResultParent[] initializeResultTree() {
-               try {
-                       // Force initialization of the tree structure if needed
-                       SlcJcrResultUtils.getSlcResultsParentNode(session);
-                       SlcJcrResultUtils.getMyResultParentNode(session);
-                       // Remove yesterday and last 7 days virtual folders
-                       // ResultParent[] roots = new ResultParent[5];
-                       ResultParent[] roots = new ResultParent[3];
-
-                       // My results
-                       roots[0] = new ParentNodeFolder(null,
-                                       SlcJcrResultUtils.getMyResultParentNode(session),
-                                       SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL);
-
-                       // today
-                       Calendar cal = Calendar.getInstance();
-                       String relPath = JcrUtils.dateAsPath(cal);
-                       List<String> datePathes = new ArrayList<String>();
-                       datePathes.add(relPath);
-                       roots[1] = new VirtualFolder(null,
-                                       ResultParentUtils.getResultsForDates(session, datePathes),
-                                       "Today");
-
-                       // // Yesterday
-                       // cal = Calendar.getInstance();
-                       // cal.add(Calendar.DAY_OF_YEAR, -1);
-                       // relPath = JcrUtils.dateAsPath(cal);
-                       // datePathes = new ArrayList<String>();
-                       // datePathes.add(relPath);
-                       // roots[2] = new VirtualFolder(null,
-                       // ResultParentUtils.getResultsForDates(session, datePathes),
-                       // "Yesterday");
-                       // // Last 7 days
-                       //
-                       // cal = Calendar.getInstance();
-                       // datePathes = new ArrayList<String>();
-                       //
-                       // for (int i = 0; i < 7; i++) {
-                       // cal.add(Calendar.DAY_OF_YEAR, -i);
-                       // relPath = JcrUtils.dateAsPath(cal);
-                       // datePathes.add(relPath);
-                       // }
-                       // roots[3] = new VirtualFolder(null,
-                       // ResultParentUtils.getResultsForDates(session, datePathes),
-                       // "Last 7 days");
-
-                       // All results
-                       Node otherResultsPar = session.getNode(SlcJcrResultUtils
-                                       .getSlcResultsBasePath(session));
-                       // roots[4] = new ParentNodeFolder(null, otherResultsPar,
-                       // "All results");
-                       roots[2] = new ParentNodeFolder(null, otherResultsPar,
-                                       "All results");
-                       return roots;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while initializing ResultTree.", re);
-               }
-       }
-
-       // Manage context menu
-       /**
-        * Defines the commands that will pop up in the context menu.
-        **/
-       protected void contextMenuAboutToShow(IMenuManager menuManager) {
-               IWorkbenchWindow window = ClientUiPlugin.getDefault().getWorkbench()
-                               .getActiveWorkbenchWindow();
-
-               IStructuredSelection selection = (IStructuredSelection) resultTreeViewer
-                               .getSelection();
-               boolean canAddSubfolder = false;
-               boolean canRenamefolder = false;
-               boolean isSingleResultNode = false;
-               boolean isUnderMyResult = false;
-               boolean validMultipleDelete = false;
-               try {
-
-                       // Building conditions
-                       if (selection.size() == 1) {
-                               Object obj = selection.getFirstElement();
-                               if (obj instanceof SingleResultNode)
-                                       isSingleResultNode = true;
-                               else if (obj instanceof ParentNodeFolder) {
-                                       Node cNode = ((ParentNodeFolder) obj).getNode();
-                                       if (cNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
-                                               canAddSubfolder = true;
-                                               canRenamefolder = true;
-                                               isUnderMyResult = true;
-                                       } else if (cNode
-                                                       .isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER)) {
-                                               canAddSubfolder = true;
-                                       }
-                               }
-                       } else {
-                               @SuppressWarnings("rawtypes")
-                               Iterator it = selection.iterator();
-                               multicheck: while (it.hasNext()) {
-                                       validMultipleDelete = true;
-                                       Object obj = it.next();
-                                       if (obj instanceof SingleResultNode)
-                                               continue multicheck;
-                                       else if (obj instanceof ParentNodeFolder) {
-                                               Node cNode = ((ParentNodeFolder) obj).getNode();
-                                               if (cNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER))
-                                                       continue multicheck;
-                                               else {
-                                                       validMultipleDelete = false;
-                                                       break multicheck;
-                                               }
-                                       } else {
-                                               validMultipleDelete = false;
-                                               break multicheck;
-                                       }
-                               }
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "unexpected error while building condition for context menu",
-                                       re);
-               }
-
-               // Effective Refresh
-               CommandUtils.refreshCommand(menuManager, window,
-                               RefreshJcrResultTreeView.ID,
-                               RefreshJcrResultTreeView.DEFAULT_LABEL,
-                               RefreshJcrResultTreeView.DEFAULT_IMG_DESCRIPTOR, true);
-
-               CommandUtils.refreshCommand(menuManager, window, DeleteItems.ID,
-                               DeleteItems.DEFAULT_LABEL, DeleteItems.DEFAULT_IMG_DESCRIPTOR,
-                               isUnderMyResult || isSingleResultNode || validMultipleDelete);
-
-               CommandUtils.refreshCommand(menuManager, window, AddResultFolder.ID,
-                               AddResultFolder.DEFAULT_LABEL,
-                               ClientUiPlugin.getDefault().getWorkbench().getSharedImages()
-                                               .getImageDescriptor(ISharedImages.IMG_OBJ_ADD),
-                               canAddSubfolder);
-
-               CommandUtils.refreshCommand(menuManager, window, RenameResultFolder.ID,
-                               RenameResultFolder.DEFAULT_LABEL,
-                               RenameResultFolder.DEFAULT_IMG_DESCRIPTOR, canRenamefolder);
-
-               // Command removed for the time being.
-               CommandUtils.refreshCommand(menuManager, window, RenameResultNode.ID,
-                               RenameResultNode.DEFAULT_LABEL,
-                               RenameResultNode.DEFAULT_IMG_DESCRIPTOR, false);
-
-               // Test to be removed
-               // If you use this pattern, do not forget to call
-               // menuManager.setRemoveAllWhenShown(true);
-               // when creating the menuManager
-
-               // menuManager.add(new Action("Test") {
-               // public void run() {
-               // log.debug("do something");
-               // }
-               // });
-       }
-
-       /* INNER CLASSES */
-       class ViewDragListener implements DragSourceListener {
-
-               public void dragStart(DragSourceEvent event) {
-                       // Check if the drag action should start.
-                       IStructuredSelection selection = (IStructuredSelection) resultTreeViewer
-                                       .getSelection();
-                       boolean doIt = false;
-
-                       // FIXME clean this code.
-                       try {
-                               if (selection.size() == 1) {
-                                       Object obj = selection.getFirstElement();
-                                       if (obj instanceof ResultFolder) {
-                                               Node tNode = ((ResultFolder) obj).getNode();
-                                               if (tNode.getPrimaryNodeType().isNodeType(
-                                                               SlcTypes.SLC_RESULT_FOLDER)) {
-                                                       doIt = true;
-                                                       isResultFolder = true;
-                                               }
-                                       } else
-                                               isResultFolder = false;
-                               } else
-                                       isResultFolder = false;
-
-                               if (!isResultFolder) {
-                                       @SuppressWarnings("rawtypes")
-                                       Iterator it = selection.iterator();
-                                       while (it.hasNext()) {
-                                               Object obj = it.next();
-                                               if (obj instanceof SingleResultNode) {
-                                                       Node tNode = ((SingleResultNode) obj).getNode();
-                                                       if (tNode.getPrimaryNodeType().isNodeType(
-                                                                       SlcTypes.SLC_TEST_RESULT)) {
-                                                               doIt = true;
-                                                       }
-                                               }
-                                       }
-                               }
-
-                       } catch (RepositoryException re) {
-                               throw new SlcException(
-                                               "unexpected error while validating drag source", re);
-                       }
-                       event.doit = doIt;
-               }
-
-               public void dragSetData(DragSourceEvent event) {
-                       IStructuredSelection selection = (IStructuredSelection) resultTreeViewer
-                                       .getSelection();
-
-                       try {
-                               // specific case of a result folder
-                               if (isResultFolder) {
-                                       Object obj = selection.getFirstElement();
-                                       event.data = ((ResultFolder) obj).getNode().getIdentifier();
-                               } else {
-                                       @SuppressWarnings("rawtypes")
-                                       Iterator it = selection.iterator();
-                                       StringBuilder nodes = new StringBuilder();
-                                       while (it.hasNext()) {
-                                               Object obj = it.next();
-                                               if (obj instanceof SingleResultNode) {
-                                                       Node tNode = ((SingleResultNode) obj).getNode();
-                                                       if (tNode.getPrimaryNodeType().isNodeType(
-                                                                       SlcTypes.SLC_TEST_RESULT)) {
-                                                               nodes.append(tNode.getIdentifier()).append(";");
-                                                       }
-                                               }
-                                       }
-                                       event.data = nodes.toString();
-                               }
-                       } catch (RepositoryException re) {
-                               throw new SlcException("unexpected error while setting data",
-                                               re);
-                       }
-               }
-
-               public void dragFinished(DragSourceEvent event) {
-                       // refresh is done via observer
-               }
-       }
-
-       // Implementation of the Drop Listener
-       protected class ViewDropListener extends ViewerDropAdapter {
-               private Node targetParentNode = null;
-
-               public ViewDropListener(Viewer viewer) {
-                       super(viewer);
-               }
-
-               @Override
-               public boolean validateDrop(Object target, int operation,
-                               TransferData transferType) {
-                       boolean validDrop = false;
-                       try {
-                               // We can only drop under myResults
-                               Node tpNode = null;
-                               if (target instanceof SingleResultNode) {
-                                       Node currNode = ((SingleResultNode) target).getNode();
-                                       String pPath = currNode.getParent().getPath();
-                                       if (pPath.startsWith(SlcJcrResultUtils
-                                                       .getMyResultsBasePath(session)))
-                                               tpNode = currNode.getParent();
-                               } else if (target instanceof ResultFolder) {
-                                       tpNode = ((ResultFolder) target).getNode();
-                               } else if (target instanceof ParentNodeFolder) {
-                                       Node node = ((ParentNodeFolder) target).getNode();
-                                       if (node.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
-                                               tpNode = ((ParentNodeFolder) target).getNode();
-                               }
-
-                               if (tpNode != null) {
-                                       targetParentNode = tpNode;
-                                       validDrop = true;
-                               }
-                       } catch (RepositoryException re) {
-                               throw new SlcException(
-                                               "unexpected error while validating drop target", re);
-                       }
-                       return validDrop;
-               }
-
-               @Override
-               public boolean performDrop(Object data) {
-                       // clear selection to prevent unwanted scrolling of the UI
-                       resultTreeViewer.setSelection(null);
-                       try {
-                               if (isResultFolder) {
-                                       // Sanity check : we cannot move a folder to one of its sub
-                                       // folder or neither move an object in the same parent
-                                       // folder
-                                       Node source = session.getNodeByIdentifier((String) data);
-                                       if (targetParentNode.getPath().startsWith(source.getPath())
-                                                       || source.getParent().getPath()
-                                                                       .equals(targetParentNode.getPath()))
-                                               return false;
-
-                                       // Move
-                                       String sourcePath = source.getPath();
-                                       String destPath = targetParentNode.getPath() + "/"
-                                                       + source.getName();
-                                       session.move(sourcePath, destPath);
-                                       // Update passed status of the parent source Node
-                                       ResultParentUtils.updatePassedStatus(
-                                                       session.getNode(JcrUtils.parentPath(sourcePath)),
-                                                       true);
-                                       // Node target = session.getNode(destPath);
-                                       session.save();
-                                       return true;
-                               }
-
-                               String[] datas = ((String) data).split(";");
-                               nodesToCopy: for (String id : datas) {
-
-                                       Node source = session.getNodeByIdentifier(id);
-                                       String name;
-                                       if (source.hasProperty(Property.JCR_TITLE))
-                                               name = source.getProperty(Property.JCR_TITLE)
-                                                               .getString();
-                                       else if (source.hasProperty(SlcNames.SLC_TEST_CASE))
-                                               name = source.getProperty(SlcNames.SLC_TEST_CASE)
-                                                               .getString();
-                                       else
-                                               name = source.getName();
-
-                                       // Check if another copy of the same test instance already
-                                       // exists at target
-                                       NodeIterator ni = targetParentNode.getNodes();
-                                       String slcUid = source.getProperty(SlcNames.SLC_UUID)
-                                                       .getString();
-                                       while (ni.hasNext()) {
-                                               Node curr = ni.nextNode();
-                                               if (curr.hasProperty(SlcNames.SLC_UUID)
-                                                               && slcUid.equals(curr.getProperty(
-                                                                               SlcNames.SLC_UUID).getString())) {
-                                                       MessageDialog
-                                                                       .openWarning(
-                                                                                       PlatformUI.getWorkbench()
-                                                                                                       .getDisplay()
-                                                                                                       .getActiveShell(),
-                                                                                       "Duplicated instance.",
-                                                                                       "An instance of the same test case ("
-                                                                                                       + name
-                                                                                                       + ") exists at destination.\n "
-                                                                                                       + "This item will not be neither copied nor moved.");
-                                                       continue nodesToCopy;
-
-                                               }
-                                       }
-
-                                       Node target;
-                                       boolean passedStatus = false;
-                                       if (source.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
-                                               passedStatus = source
-                                                               .getNode(SlcNames.SLC_AGGREGATED_STATUS)
-                                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
-
-                                       boolean isActionUnderMyResult = source.getPath()
-                                                       .startsWith(
-                                                                       SlcJcrResultUtils
-                                                                                       .getMyResultsBasePath(session));
-
-                                       if (!isActionUnderMyResult) {// Copy
-                                               target = targetParentNode.addNode(source.getName(),
-                                                               source.getPrimaryNodeType().getName());
-                                               JcrUtils.copy(source, target);
-                                       } else {// move
-                                               String sourcePath = source.getPath();
-                                               String destPath = targetParentNode.getPath() + "/"
-                                                               + name;
-                                               session.move(sourcePath, destPath);
-                                               // Update passed status of the parent source Node
-                                               ResultParentUtils
-                                                               .updatePassedStatus(session.getNode(JcrUtils
-                                                                               .parentPath(sourcePath)), true);
-                                               target = session.getNode(destPath);
-
-                                       }
-                                       if (!target.isNodeType(NodeType.MIX_TITLE))
-                                               target.addMixin(NodeType.MIX_TITLE);
-                                       target.setProperty(Property.JCR_TITLE, name);
-                                       ResultParentUtils.updatePassedStatus(target.getParent(),
-                                                       passedStatus);
-                                       session.save();
-                               }
-                       } catch (RepositoryException re) {
-                               throw new SlcException(
-                                               "unexpected error while copying dropped node", re);
-
-                       }
-                       return true;
-               }
-       }
-
-       class MyResultsObserver extends AsyncUiEventListener {
-
-               public MyResultsObserver(Display display) {
-                       super(display);
-               }
-
-               @Override
-               protected Boolean willProcessInUiThread(List<Event> events)
-                               throws RepositoryException {
-                       // unfiltered for the time being
-                       return true;
-               }
-
-               protected void onEventInUiThread(List<Event> events)
-                               throws RepositoryException {
-                       List<Node> nodesToRefresh = new ArrayList<Node>();
-
-                       for (Event event : events) {
-                               String parPath = JcrUtils.parentPath(event.getPath());
-                               if (session.nodeExists(parPath)) {
-                                       Node node = session.getNode(parPath);
-                                       if (!nodesToRefresh.contains(node)) {
-                                               nodesToRefresh.add(node);
-                                       }
-                               }
-                       }
-
-                       // Update check nodes
-                       for (Node node : nodesToRefresh)
-                               jcrRefresh(node);
-                       refresh(null);
-               }
-       }
-
-       class AllResultsObserver extends AsyncUiEventListener {
-
-               public AllResultsObserver(Display display) {
-                       super(display);
-               }
-
-               @Override
-               protected Boolean willProcessInUiThread(List<Event> events)
-                               throws RepositoryException {
-                       // unfiltered for the time being
-                       return true;
-               }
-
-               protected void onEventInUiThread(List<Event> events)
-                               throws RepositoryException {
-                       refresh(null);
-                       // if (lastSelectedSourceElementParent != null)
-                       // refresh(lastSelectedSourceElementParent);
-               }
-       }
-
-       class PropertiesContentProvider implements IStructuredContentProvider {
-
-               public void dispose() {
-               }
-
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-               }
-
-               public Object[] getElements(Object inputElement) {
-                       try {
-                               if (inputElement instanceof Node) {
-                                       Node node = (Node) inputElement;
-                                       if (node.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
-                                               List<Property> props = new ArrayList<Property>();
-                                               if (node.hasProperty(SlcNames.SLC_TEST_CASE))
-                                                       props.add(node.getProperty(SlcNames.SLC_TEST_CASE));
-                                               if (node.hasProperty(SlcNames.SLC_COMPLETED))
-                                                       props.add(node.getProperty(SlcNames.SLC_COMPLETED));
-                                               if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS)) {
-                                                       Node status = node
-                                                                       .getNode(SlcNames.SLC_AGGREGATED_STATUS);
-                                                       props.add(status.getProperty(SlcNames.SLC_SUCCESS));
-                                                       if (status.hasProperty(SlcNames.SLC_MESSAGE))
-                                                               props.add(status
-                                                                               .getProperty(SlcNames.SLC_MESSAGE));
-                                                       if (status.hasProperty(SlcNames.SLC_ERROR_MESSAGE))
-                                                               props.add(status
-                                                                               .getProperty(SlcNames.SLC_ERROR_MESSAGE));
-                                               }
-                                               return props.toArray();
-                                       }
-                               }
-                               return new Object[] {};
-
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot get element for "
-                                               + inputElement, e);
-                       }
-               }
-       }
-
-       class MySelectionChangedListener implements ISelectionChangedListener {
-
-               public void selectionChanged(SelectionChangedEvent event) {
-                       if (!event.getSelection().isEmpty()) {
-                               IStructuredSelection sel = (IStructuredSelection) event
-                                               .getSelection();
-                               ResultParent firstItem = (ResultParent) sel.getFirstElement();
-                               if (firstItem instanceof SingleResultNode)
-                                       propertiesViewer.setInput(((SingleResultNode) firstItem)
-                                                       .getNode());
-                               else
-                                       propertiesViewer.setInput(null);
-                               // update cache for Drag & drop
-                               // lastSelectedTargetElement = firstItem;
-                               // lastSelectedSourceElement = firstItem;
-                               // lastSelectedSourceElementParent = (ResultParent) firstItem
-                               // .getParent();
-                               // String pPath = "";
-                               // try {
-                               //
-                               // if (firstItem instanceof ParentNodeFolder)
-                               // pPath = ((ParentNodeFolder) firstItem).getNode()
-                               // .getPath();
-                               // else if (firstItem instanceof SingleResultNode)
-                               // pPath = ((SingleResultNode) firstItem).getNode()
-                               // .getPath();
-                               // } catch (RepositoryException e) {
-                               // throw new SlcException(
-                               // "Unexpected error while checking parent UI tree", e);
-                               // }
-                               // if ((pPath.startsWith(SlcJcrResultUtils
-                               // .getMyResultsBasePath(session))))
-                               // isActionUnderMyResult = true;
-                               // else
-                               // isActionUnderMyResult = false;
-                       }
-               }
-       }
-
-       class ViewDoubleClickListener implements IDoubleClickListener {
-               public void doubleClick(DoubleClickEvent evt) {
-                       processDoubleClick(evt);
-               }
-
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void dispose() {
-               // JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver);
-               JcrUtils.logoutQuietly(session);
-               super.dispose();
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-}
diff --git a/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/wizards/ConfirmOverwriteWizard.java b/cms/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/wizards/ConfirmOverwriteWizard.java
deleted file mode 100644 (file)
index d766219..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-package org.argeo.slc.client.ui.wizards;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcUiConstants;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.ISharedImages;
-
-public class ConfirmOverwriteWizard extends Wizard {
-
-       // Define widget here to simplify getters
-       private Button overwriteBtn, renameBtn;
-       private Text newNameTxt;
-       private Label newNameLbl;
-
-       // business object
-       private String sourceNodeName;
-       private Node targetParentNode;
-
-       private String newName;
-       private String parentRelPath;
-       private boolean overwrite;
-
-       public ConfirmOverwriteWizard(String sourceNodeName, Node targetParentNode) {
-               setWindowTitle("Confirm overwrite or define a new name");
-               this.sourceNodeName = sourceNodeName;
-               this.targetParentNode = targetParentNode;
-       }
-
-       @Override
-       public void addPages() {
-               try {
-                       addPage(new MyPage());
-               } catch (Exception e) {
-                       throw new SlcException("Cannot add page to wizard ", e);
-               }
-               getShell().setImage(
-                               ClientUiPlugin.getDefault().getWorkbench().getSharedImages()
-                                               .getImageDescriptor(ISharedImages.IMG_LCL_LINKTO_HELP)
-                                               .createImage());
-       }
-
-       // Expose info to the calling view
-       public boolean overwrite() {
-               return overwrite;
-       }
-
-       public String newName() {
-               return newName;
-       }
-
-       @Override
-       public boolean performFinish() {
-               boolean doFinish = false;
-
-               if (canFinish()) {
-                       if (overwriteBtn.getSelection())
-                               doFinish = MessageDialog.openConfirm(Display.getDefault()
-                                               .getActiveShell(), "CAUTION", "All data contained in ["
-                                               + (parentRelPath != null ? parentRelPath : "")
-                                               + "/"+ sourceNodeName
-                                               + "] are about to be definitively destroyed. \n "
-                                               + "Are you sure you want to proceed ?");
-                       else
-                               doFinish = true;
-                       // cache values
-               }
-               if (doFinish) {
-                       overwrite = overwriteBtn.getSelection();
-                       newName = newNameTxt.getText();
-               }
-               return doFinish;
-       }
-
-       class MyPage extends WizardPage implements ModifyListener {
-
-               public MyPage() {
-                       super("");
-                       String msg = "An object with same name (" + sourceNodeName
-                                       + ") already exists at chosen target path";
-
-                       // Add target rel path to the message
-                       Session session;
-                       String relPath;
-                       try {
-                               session = targetParentNode.getSession();
-                               relPath = targetParentNode.getPath();
-                               String basePath = SlcJcrResultUtils
-                                               .getMyResultsBasePath(session);
-                               if (relPath.startsWith(basePath))
-                                       relPath = relPath.substring(basePath.length());
-                               // FIXME currently add the default base label
-                               parentRelPath = SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL
-                                               + relPath;
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Unexpected error while defining "
-                                               + "target parent node rel path", e);
-                       }
-                       msg = msg + (parentRelPath == null ? "." : ": \n" + parentRelPath);
-
-                       // Set Title
-                       setTitle(msg);
-               }
-
-               public void createControl(Composite parent) {
-                       Composite composite = new Composite(parent, SWT.NONE);
-                       composite.setLayout(new GridLayout(2, false));
-
-                       // choose between overwrite and rename
-                       overwriteBtn = new Button(composite, SWT.RADIO);
-                       overwriteBtn.setText("Overwrite");
-                       GridData gd = new GridData();
-                       gd.horizontalIndent = 30;
-                       gd.horizontalSpan = 2;
-                       overwriteBtn.setLayoutData(gd);
-                       overwriteBtn.setSelection(true);
-
-                       renameBtn = new Button(composite, SWT.RADIO);
-                       renameBtn.setText("Rename");
-                       renameBtn.setSelection(false);
-                       renameBtn.setText("Rename");
-                       gd = new GridData();
-                       gd.horizontalIndent = 30;
-                       gd.horizontalSpan = 2;
-                       renameBtn.setLayoutData(gd);
-
-                       newNameLbl = new Label(composite, SWT.LEAD);
-                       newNameLbl.setText("New name");
-                       newNameLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
-                                       false));
-                       newNameLbl.setEnabled(false);
-
-                       newNameTxt = new Text(composite, SWT.LEAD | SWT.BORDER);
-                       newNameTxt.setText(sourceNodeName);
-                       newNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
-                                       false));
-                       if (newNameTxt != null)
-                               newNameTxt.addModifyListener(this);
-                       newNameTxt.setEnabled(false);
-
-                       SelectionAdapter sa = new SelectionAdapter() {
-                               public void widgetSelected(SelectionEvent e) {
-                                       updateSelection(overwriteBtn.getSelection());
-                               }
-                       };
-                       overwriteBtn.addSelectionListener(sa);
-                       renameBtn.addSelectionListener(sa);
-
-                       // Compulsory
-                       setControl(composite);
-               }
-
-               private void updateSelection(boolean overwrite) {
-                       newNameLbl.setEnabled(!overwrite);
-                       newNameTxt.setEnabled(!overwrite);
-                       if (overwrite)
-                               setPageComplete(true);
-                       else
-                               checkComplete();
-               }
-
-               protected String getTechName() {
-                       return newNameTxt.getText();
-               }
-
-               public void modifyText(ModifyEvent event) {
-                       checkComplete();
-               }
-
-               private void checkComplete() {
-                       try {
-
-                               String newName = newNameTxt.getText();
-                               if (newName == null || "".equals(newName.trim())) {
-                                       setMessage("Name cannot be blank or empty",
-                                                       WizardPage.ERROR);
-                                       setPageComplete(false);
-                               } else if (targetParentNode.hasNode(newName)) {
-                                       setMessage("An object with the same name already exists.",
-                                                       WizardPage.ERROR);
-                                       setPageComplete(false);
-                               } else {
-                                       setMessage("Complete", WizardPage.INFORMATION);
-                                       setPageComplete(true);
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Unexpected error while checking "
-                                               + "children node with same name", e);
-                       }
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.factory/.classpath b/cms/org.argeo.slc.factory/.classpath
deleted file mode 100644 (file)
index bc86c42..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" output="target/classes" path="src"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/cms/org.argeo.slc.factory/.gitignore b/cms/org.argeo.slc.factory/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/cms/org.argeo.slc.factory/.project b/cms/org.argeo.slc.factory/.project
deleted file mode 100644 (file)
index 948356f..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.factory</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.jdt.core.javanature</nature>
-               <nature>org.eclipse.pde.PluginNature</nature>
-       </natures>
-</projectDescription>
diff --git a/cms/org.argeo.slc.factory/META-INF/.gitignore b/cms/org.argeo.slc.factory/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.factory/bnd.bnd b/cms/org.argeo.slc.factory/bnd.bnd
deleted file mode 100644 (file)
index 35c4c44..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-Import-Package: javax.jcr.nodetype,\
-org.argeo.slc.repo,\
-org.osgi.*;version=0.0.0,\
-*
-                                                       
\ No newline at end of file
diff --git a/cms/org.argeo.slc.factory/pom.xml b/cms/org.argeo.slc.factory/pom.xml
deleted file mode 100644 (file)
index 08dbed9..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.factory</artifactId>
-       <name>SLC Factory</name>
-       <dependencies>
-               <!-- SLC -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.runtime</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.repo</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmFactory.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmFactory.java
deleted file mode 100644 (file)
index 0223a20..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.argeo.slc.rpmfactory;
-
-import java.io.File;
-import java.util.List;
-
-import javax.jcr.Node;
-
-/**
- * Defines a build environment. This information is typically used by other
- * components performing the various actions related to RPM build.
- */
-public interface RpmFactory {
-       //
-       // DIRECT ACTIONS ON JCR REPOSITORY
-       //
-       public void indexWorkspace(String workspace);
-
-       public Node newDistribution(String distributionId);
-
-       //
-       // CONFIG FILES GENERATION
-       //
-       /** Creates a mock config file. */
-       public File getMockConfigFile(String arch, String branch);
-
-       /** Creates a yum config file. */
-       public File getYumRepoFile(String arch);
-
-       //
-       // WORKSPACES
-       //
-       public String getStagingWorkspace();
-
-       /**
-        * @return the name of the testing workspace, or null if and only if the
-        *         testing workspace was not enabled.
-        */
-       public String getTestingWorkspace();
-
-       public String getStableWorkspace();
-
-       public File getWorkspaceDir(String workspace);
-
-       //
-       // ARCH DEPENDENT INFOS
-       //
-       public List<String> getArchs();
-
-       public String getMockConfig(String arch);
-
-       public String getIdWithArch(String arch);
-
-       public File getResultDir(String arch);
-
-       //
-       // DEPLOYMENT
-       //
-       public String getGitBaseUrl();
-
-       public Boolean isDeveloperInstance();
-
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmProxyService.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmProxyService.java
deleted file mode 100644 (file)
index 40002a8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.rpmfactory;
-
-import org.argeo.jcr.proxy.ResourceProxy;
-
-/** Marker interface (useful for OSGi services references), may be extended later */
-public interface RpmProxyService extends ResourceProxy {
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmRepository.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmRepository.java
deleted file mode 100644 (file)
index 24d7c72..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.argeo.slc.rpmfactory;
-
-/** A YUM compatible repository of RPM packages. */
-public interface RpmRepository {
-       public String getId();
-
-       public String getUrl();
-
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/AbstractRpmRepository.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/AbstractRpmRepository.java
deleted file mode 100644 (file)
index 19418b6..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-import org.argeo.slc.rpmfactory.RpmRepository;
-
-/** Common method to RPM repositories. */
-public abstract class AbstractRpmRepository implements RpmRepository {
-       private String id;
-       private String url;
-
-       @Override
-       public String getId() {
-               return id;
-       }
-
-       @Override
-       public String getUrl() {
-               return url;
-       }
-
-       public void setId(String id) {
-               this.id = id;
-       }
-
-       public void setUrl(String url) {
-               this.url = url;
-       }
-
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/BuildInMock.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/BuildInMock.java
deleted file mode 100644 (file)
index a69e39f..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.exec.Executor;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.rpmfactory.RpmFactory;
-import org.argeo.slc.runtime.tasks.SystemCall;
-
-/** Build an RPM in mock. */
-public class BuildInMock implements Runnable {
-       private final static Log log = LogFactory.getLog(BuildInMock.class);
-       private final static String NOARCH = "noarch";
-
-       private String rpmPackage = null;
-       private String branch = null;
-       private String arch = NOARCH;
-
-       private RpmFactory rpmFactory;
-       private Executor executor;
-
-       private String debuginfoDirName = "debuginfo";
-       private String mockExecutable = "/usr/bin/mock";
-
-       private List<String> preBuildCommands = new ArrayList<String>();
-
-       public void run() {
-               if (!rpmFactory.isDeveloperInstance()) {
-                       // clean/init
-                       SystemCall mockClean = createBaseMockCall();
-                       mockClean.arg("--init");
-                       mockClean.run();
-               }
-
-               // pre build commands
-               for (String preBuildCmd : preBuildCommands) {
-                       SystemCall mockClean = createBaseMockCall();
-                       mockClean.arg("--chroot").arg(preBuildCmd);
-                       mockClean.run();
-               }
-
-               // actual build
-               SystemCall mockBuild = createBaseMockCall();
-               mockBuild.arg("--scm-enable");
-               mockBuild.arg("--scm-option").arg("package=" + rpmPackage);
-               mockBuild.arg("--no-clean");
-               //
-               //
-               mockBuild.run();
-               //
-
-               // copy RPMs to target directories
-               File stagingDir = rpmFactory.getWorkspaceDir(rpmFactory
-                               .getStagingWorkspace());
-               File srpmDir = new File(stagingDir, "SRPMS");
-               srpmDir.mkdirs();
-               File archDir = null;
-               File debuginfoDir = null;
-               if (!arch.equals(NOARCH)) {
-                       archDir = new File(stagingDir, arch);
-                       debuginfoDir = new File(archDir, debuginfoDirName);
-                       debuginfoDir.mkdirs();
-               }
-
-               Set<File> reposToRecreate = new HashSet<File>();
-               File resultDir = rpmFactory.getResultDir(arch);
-               if (resultDir.exists())
-                       rpms: for (File file : resultDir.listFiles()) {
-                               if (file.isDirectory())
-                                       continue rpms;
-
-                               File[] targetDirs;
-                               if (file.getName().contains(".src.rpm"))
-                                       targetDirs = new File[] { srpmDir };
-                               else if (file.getName().contains("-debuginfo-"))
-                                       targetDirs = new File[] { debuginfoDir };
-                               else if (!arch.equals(NOARCH)
-                                               && file.getName().contains("." + arch + ".rpm"))
-                                       targetDirs = new File[] { archDir };
-                               else if (file.getName().contains(".noarch.rpm")) {
-                                       List<File> dirs = new ArrayList<File>();
-                                       for (String arch : rpmFactory.getArchs())
-                                               dirs.add(new File(stagingDir, arch));
-                                       targetDirs = dirs.toArray(new File[dirs.size()]);
-                               } else if (file.getName().contains(".rpm"))
-                                       throw new SlcException("Don't know where to copy " + file);
-                               else {
-                                       if (log.isTraceEnabled())
-                                               log.trace("Skip " + file);
-                                       continue rpms;
-                               }
-
-                               reposToRecreate.addAll(Arrays.asList(targetDirs));
-                               copyToDirs(file, targetDirs);
-                       }
-
-               // recreate changed repos
-               for (File repoToRecreate : reposToRecreate) {
-                       SystemCall createrepo = new SystemCall();
-                       createrepo.arg("createrepo");
-                       // sqllite db
-                       createrepo.arg("-d");
-                       // debuginfo
-                       if (!repoToRecreate.getName().equals(debuginfoDirName))
-                               createrepo.arg("-x").arg(debuginfoDirName + "/*");
-                       // quiet
-                       createrepo.arg("-q");
-                       createrepo.arg(repoToRecreate.getAbsolutePath());
-
-                       createrepo.setExecutor(executor);
-                       createrepo.run();
-                       log.info("Updated repo " + repoToRecreate);
-               }
-
-               // index staging workspace
-               rpmFactory.indexWorkspace(rpmFactory.getStagingWorkspace());
-       }
-
-       /** Creates a mock call with all the common options such as config file etc. */
-       protected SystemCall createBaseMockCall() {
-               String mockCfg = rpmFactory.getMockConfig(arch);
-               File mockConfigFile = rpmFactory.getMockConfigFile(arch, branch);
-
-               // prepare mock call
-               SystemCall mock = new SystemCall();
-
-               if (arch != null)
-                       mock.arg("setarch").arg(arch);
-               mock.arg(mockExecutable);
-               mock.arg("-v");
-               mock.arg("--configdir=" + mockConfigFile.getAbsoluteFile().getParent());
-               if (arch != null)
-                       mock.arg("--arch=" + arch);
-               mock.arg("-r").arg(mockCfg);
-
-               mock.setLogCommand(true);
-               mock.setExecutor(executor);
-
-               return mock;
-       }
-
-       protected void copyToDirs(File file, File[] dirs) {
-               for (File dir : dirs) {
-                       try {
-                               FileUtils.copyFileToDirectory(file, dir);
-                               if (log.isDebugEnabled())
-                                       log.debug(file + " => " + dir);
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot copy " + file + " to " + dir, e);
-                       }
-               }
-       }
-
-       public void setArch(String arch) {
-               this.arch = arch;
-       }
-
-       public void setRpmPackage(String rpmPackage) {
-               this.rpmPackage = rpmPackage;
-       }
-
-       public void setBranch(String branch) {
-               this.branch = branch;
-       }
-
-       public void setRpmFactory(RpmFactory env) {
-               this.rpmFactory = env;
-       }
-
-       public void setExecutor(Executor executor) {
-               this.executor = executor;
-       }
-
-       public void setMockExecutable(String mockExecutable) {
-               this.mockExecutable = mockExecutable;
-       }
-
-       public void setPreBuildCommands(List<String> preBuildCommands) {
-               this.preBuildCommands = preBuildCommands;
-       }
-
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/CreateRpmDistribution.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/CreateRpmDistribution.java
deleted file mode 100644 (file)
index 6f60b3d..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.StringTokenizer;
-
-import javax.jcr.Node;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.rpmfactory.RpmFactory;
-import org.argeo.slc.runtime.tasks.SystemCall;
-
-/**
- * Gather RPMs from various sources (local builds or third party) into a
- * consistent distributable set (typically to be used to generate an ISO).
- */
-public class CreateRpmDistribution implements Runnable {
-       private final static Log log = LogFactory
-                       .getLog(CreateRpmDistribution.class);
-
-       private RpmFactory rpmFactory;
-       private RpmDistribution rpmDistribution;
-
-       private String arch = "x86_64";
-
-       private String repoqueryExecutable = "/usr/bin/repoquery";
-
-       @Override
-       public void run() {
-               Session session = null;
-               // Reader reader = null;
-               try {
-                       Node baseFolder = rpmFactory.newDistribution(rpmDistribution
-                                       .getId());
-                       session = baseFolder.getSession();
-                       Node targetFolder = baseFolder.addNode(arch, NodeType.NT_FOLDER);
-
-                       SystemCall repoquery = new SystemCall();
-                       repoquery.arg(repoqueryExecutable);
-
-                       File yumConfigFile = rpmFactory.getYumRepoFile(arch);
-                       repoquery.arg("-c", yumConfigFile.getAbsolutePath());
-                       repoquery.arg("--requires");
-                       repoquery.arg("--resolve");
-                       repoquery.arg("--location");
-                       repoquery.arg("--archlist=" + arch);
-
-                       for (String rpmPackage : rpmDistribution.getPackages())
-                               repoquery.arg(rpmPackage);
-
-                       if (log.isDebugEnabled())
-                               log.debug("Command:\n" + repoquery.asCommand());
-
-                       String output = repoquery.function();
-
-                       if (log.isDebugEnabled())
-                               log.debug(output + "\n");
-                       // reader = new StringReader(output);
-                       StringTokenizer lines = new StringTokenizer(output, "\n");
-                       // List<String> dependencies = IOUtils.readLines(reader);
-                       dependencies: while (lines.hasMoreTokens()) {
-                               String urlStr = lines.nextToken();
-                               InputStream in = null;
-                               try {
-                                       URL url = new URL(urlStr);
-                                       String fileName = FilenameUtils.getName(url.getFile());
-                                       String[] tokens = fileName.split("-");
-                                       if (tokens.length < 3)
-                                               continue dependencies;
-                                       StringBuilder buf = new StringBuilder();
-                                       for (int i = 0; i < tokens.length - 2; i++) {
-                                               if (i != 0)
-                                                       buf.append('-');
-                                               buf.append(tokens[i]);
-
-                                       }
-                                       String packageName = buf.toString();
-                                       for (RpmPackageSet excluded : rpmDistribution
-                                                       .getExcludedPackages()) {
-                                               if (excluded.contains(packageName)) {
-                                                       if (log.isDebugEnabled())
-                                                               log.debug("Skipped " + packageName);
-                                                       continue dependencies;// skip
-                                               }
-                                       }
-                                       in = url.openStream();
-                                       JcrUtils.copyStreamAsFile(targetFolder, fileName, in);
-                                       targetFolder.getSession().save();
-                                       if (log.isDebugEnabled())
-                                               log.debug("Copied  " + packageName);
-                               } catch (Exception e) {
-                                       log.error("Cannot copy " + urlStr, e);
-                               } finally {
-                                       IOUtils.closeQuietly(in);
-                               }
-                       }
-
-                       // createrepo
-                       File workspaceDir = rpmFactory.getWorkspaceDir(rpmDistribution
-                                       .getId());
-                       SystemCall createrepo = new SystemCall();
-                       createrepo.arg("createrepo");
-                       createrepo.arg("-q");
-                       createrepo.arg("-d");
-                       File archDir = new File(workspaceDir.getPath()
-                                       + targetFolder.getPath());
-                       createrepo.arg(archDir.getAbsolutePath());
-                       createrepo.run();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot generate distribution "
-                                       + rpmDistribution.getId(), e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-                       // IOUtils.closeQuietly(reader);
-               }
-       }
-
-       public void setRpmDistribution(RpmDistribution rpmDistribution) {
-               this.rpmDistribution = rpmDistribution;
-       }
-
-       public void setRpmFactory(RpmFactory rpmFactory) {
-               this.rpmFactory = rpmFactory;
-       }
-
-       public void setArch(String arch) {
-               this.arch = arch;
-       }
-
-       public void setRepoqueryExecutable(String yumdownloaderExecutable) {
-               this.repoqueryExecutable = yumdownloaderExecutable;
-       }
-
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ReleaseStaging.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ReleaseStaging.java
deleted file mode 100644 (file)
index dcdbc9c..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.exec.Executor;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.rpmfactory.RpmFactory;
-import org.argeo.slc.runtime.tasks.SystemCall;
-
-/** Releases the content of staging to a public repository. */
-public class ReleaseStaging implements Runnable {
-       private final static Log log = LogFactory.getLog(ReleaseStaging.class);
-
-       private RpmFactory rpmFactory;
-       private Executor executor;
-
-       private String debuginfoDirName = "debuginfo";
-
-       @Override
-       public void run() {
-               String sourceWorkspace = rpmFactory.getStagingWorkspace();
-               File sourceRepoDir = rpmFactory.getWorkspaceDir(sourceWorkspace);
-               String targetWorkspace = rpmFactory.getTestingWorkspace() != null ? rpmFactory
-                               .getTestingWorkspace() : rpmFactory.getStableWorkspace();
-               File targetRepoDir = rpmFactory.getWorkspaceDir(targetWorkspace);
-               List<File> reposToRecreate = new ArrayList<File>();
-
-               stagingChildren: for (File dir : sourceRepoDir.listFiles()) {
-                       if (!dir.isDirectory())
-                               continue stagingChildren;
-                       if (dir.getName().equals("lost+found"))
-                               continue stagingChildren;
-
-                       File targetDir = new File(targetRepoDir, dir.getName());
-                       try {
-                               FileUtils.copyDirectory(dir, targetDir);
-                               if (log.isDebugEnabled())
-                                       log.debug(dir + " => " + targetDir);
-                       } catch (IOException e) {
-                               throw new SlcException(sourceRepoDir
-                                               + " could not be copied properly, check it manually."
-                                               + " Metadata have NOT been updated.", e);
-                       }
-
-                       reposToRecreate.add(dir);
-                       reposToRecreate.add(targetDir);
-                       File debugInfoDir = new File(dir, debuginfoDirName);
-                       if (debugInfoDir.exists())
-                               reposToRecreate.add(debugInfoDir);
-                       File targetDebugInfoDir = new File(targetDir, debuginfoDirName);
-                       if (targetDebugInfoDir.exists())
-                               reposToRecreate.add(targetDebugInfoDir);
-
-               }
-
-               // clear staging
-               for (File dir : sourceRepoDir.listFiles()) {
-                       try {
-                               if (dir.getName().equals("lost+found"))
-                                       continue;
-                               if (dir.isDirectory())
-                                       FileUtils.deleteDirectory(dir);
-                       } catch (IOException e) {
-                               log.error("Could not delete " + dir + ". " + e);
-                       }
-               }
-
-               // recreate changed repos
-               for (File repoToRecreate : reposToRecreate) {
-                       repoToRecreate.mkdirs();
-                       SystemCall createrepo = new SystemCall();
-                       createrepo.arg("createrepo");
-                       // sqllite db
-                       createrepo.arg("-d");
-                       // debuginfo
-                       if (!repoToRecreate.getName().equals(debuginfoDirName))
-                               createrepo.arg("-x").arg(debuginfoDirName + "/*");
-                       // quiet
-                       createrepo.arg("-q");
-                       createrepo.arg(repoToRecreate.getAbsolutePath());
-
-                       createrepo.setExecutor(executor);
-                       createrepo.run();
-                       log.info("Updated repo " + repoToRecreate);
-               }
-
-               rpmFactory.indexWorkspace(sourceWorkspace);
-               rpmFactory.indexWorkspace(targetWorkspace);
-       }
-
-       public void setRpmFactory(RpmFactory rpmFactory) {
-               this.rpmFactory = rpmFactory;
-       }
-
-       public void setExecutor(Executor executor) {
-               this.executor = executor;
-       }
-
-       public void setDebuginfoDirName(String debuginfoDirName) {
-               this.debuginfoDirName = debuginfoDirName;
-       }
-
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmDistribution.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmDistribution.java
deleted file mode 100644 (file)
index 0df31c6..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-import java.util.List;
-
-/** A consistent distributable set of RPM. */
-public class RpmDistribution {
-       private String id;
-       private List<String> packages;
-       private List<RpmPackageSet> excludedPackages;
-
-       public List<String> getPackages() {
-               return packages;
-       }
-
-       public void setPackages(List<String> packages) {
-               this.packages = packages;
-       }
-
-       public String getId() {
-               return id;
-       }
-
-       public void setId(String id) {
-               this.id = id;
-       }
-
-       public List<RpmPackageSet> getExcludedPackages() {
-               return excludedPackages;
-       }
-
-       public void setExcludedPackages(List<RpmPackageSet> excludedPackages) {
-               this.excludedPackages = excludedPackages;
-       }
-
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmFactoryImpl.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmFactoryImpl.java
deleted file mode 100644 (file)
index 5e1a627..0000000
+++ /dev/null
@@ -1,458 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.NodeIndexerVisitor;
-import org.argeo.slc.repo.RpmIndexer;
-import org.argeo.slc.rpmfactory.RpmFactory;
-import org.argeo.slc.rpmfactory.RpmRepository;
-import org.argeo.slc.runtime.tasks.SystemCall;
-
-/**
- * Defines a build environment. This information is typically used by other
- * components performing the various actions related to RPM build.
- */
-public class RpmFactoryImpl implements RpmFactory {
-       private Log log = LogFactory.getLog(RpmFactoryImpl.class);
-
-       private Repository rpmRepository;
-       private Repository distRepository;
-
-       private String id;
-       private List<RpmRepository> repositories = new ArrayList<RpmRepository>();
-       private List<String> archs = new ArrayList<String>();
-
-       private String rpmBase = "/mnt/slc/repos/rpm";
-       private String distBase = "/mnt/slc/repos/dist";
-       private String mockVar = "/var/lib/mock";
-       private String mockEtc = "/etc/mock";
-
-       private DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmm");
-
-       private String gitWorkspace = "git";
-
-       private String localUrlBase = "http://localhost:7070/";
-       /** If not null or empty, this is a developer instance. */
-       private String gitDevBaseUrl = null;
-
-       private Boolean withTestingRepository = false;
-
-       private String yumConfigMainSection = "cachedir=/var/cache/yum\n"
-                       + "debuglevel=1\n" + "reposdir=/dev/null\n"
-                       + "logfile=/var/log/yum.log\n" + "retries=20\n" + "obsoletes=1\n"
-                       + "gpgcheck=0\n" + "assumeyes=1\n" + "syslog_ident=mock\n"
-                       + "syslog_device=\n" + "http_caching=none\n";
-
-       private String defaultMacroFiles = "/usr/lib/rpm/macros:"
-                       + "/usr/lib/rpm/ia32e-linux/macros:"
-                       + "/usr/lib/rpm/redhat/macros:" + "/etc/rpm/macros.*:"
-                       + "/etc/rpm/macros:" + "/etc/rpm/ia32e-linux/macros:"
-                       + "~/.rpmmacros";
-       private Map<String, String> rpmmacros = new HashMap<String, String>();
-
-       // set by init
-       private String proxiedReposBase;
-       private String managedReposBase;
-
-       private String stagingWorkspace;
-       private String testingWorkspace;
-       private String stableWorkspace;
-
-       private File rpmFactoryBaseDir;
-       private File mockConfDir;
-       private File yumConfDir;
-
-       public void init() {
-               // local URL bases
-               proxiedReposBase = localUrlBase + "repo/rpm/";
-               managedReposBase = localUrlBase + "data/public/rpm/";
-
-               // local directories
-               rpmFactoryBaseDir.mkdirs();
-               mockConfDir = new File(rpmFactoryBaseDir.getPath() + "/conf/mock");
-               mockConfDir.mkdirs();
-               yumConfDir = new File(rpmFactoryBaseDir.getPath() + "/conf/yum");
-               yumConfDir.mkdirs();
-
-               // managed repositories
-               stagingWorkspace = id + "-staging";
-               if (withTestingRepository)
-                       testingWorkspace = id + "-testing";
-               stableWorkspace = id;
-
-               initDistWorkspace(stableWorkspace);
-               initGitWorkspace();
-               initRpmWorkspace(stagingWorkspace);
-               if (withTestingRepository)
-                       initRpmWorkspace(testingWorkspace);
-               initRpmWorkspace(stableWorkspace);
-       }
-
-       protected void initRpmWorkspace(String workspace) {
-               Session session = null;
-               try {
-                       session = JcrUtils.loginOrCreateWorkspace(rpmRepository, workspace);
-                       JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
-                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
-                                       "jcr:all");
-
-                       for (String arch : archs) {
-                               Node archFolder = JcrUtils.mkfolders(session, "/" + arch);
-                               session.save();
-                               File workspaceDir = getWorkspaceDir(workspace);
-                               try {
-                                       if (!archFolder.hasNode("repodata")) {
-                                               // touch a file in order to make sure this is properly
-                                               // mounted.
-                                               File touch = new File(workspaceDir, ".touch");
-                                               touch.createNewFile();
-                                               touch.delete();
-
-                                               SystemCall createrepo = new SystemCall();
-                                               createrepo.arg("createrepo");
-                                               createrepo.arg("-q");
-                                               File archDir = new File(workspaceDir, arch);
-                                               createrepo.arg(archDir.getAbsolutePath());
-                                               createrepo.run();
-                                       }
-                               } catch (IOException e) {
-                                       log.error(workspaceDir + " not properly mounted.", e);
-                               }
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot initialize workspace " + workspace,
-                                       e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       /** Caller must logout the underlying session. */
-       public Node newDistribution(String distributionId) {
-               Session session = null;
-               try {
-                       session = JcrUtils.loginOrCreateWorkspace(rpmRepository,
-                                       distributionId);
-                       JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
-                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
-                                       "jcr:all");
-
-                       Calendar now = new GregorianCalendar();
-                       String folderName = dateFormat.format(now.getTime());
-                       return JcrUtils.mkfolders(session, "/" + folderName);
-               } catch (Exception e) {
-                       JcrUtils.logoutQuietly(session);
-                       throw new SlcException("Cannot initialize distribution workspace "
-                                       + distributionId, e);
-               }
-       }
-
-       protected void initGitWorkspace() {
-               Session session = null;
-               try {
-                       session = JcrUtils.loginOrCreateWorkspace(rpmRepository,
-                                       gitWorkspace);
-                       JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
-                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
-                                       "jcr:all");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot initialize workspace "
-                                       + gitWorkspace, e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       protected void initDistWorkspace(String workspace) {
-               Session session = null;
-               try {
-                       session = JcrUtils
-                                       .loginOrCreateWorkspace(distRepository, workspace);
-                       JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot initialize workspace " + workspace,
-                                       e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       public void destroy() {
-
-       }
-
-       public String generateMockConfigFile(String arch, String branch) {
-               StringBuffer buf = new StringBuffer();
-
-               buf.append("config_opts['root'] = '" + getIdWithArch(arch) + "'\n");
-               buf.append("config_opts['target_arch'] = '" + arch + "'\n");
-               buf.append("config_opts['legal_host_arches'] = ('" + arch + "',)\n");
-               buf.append("config_opts['chroot_setup_cmd'] = 'groupinstall buildsys-build'\n");
-               // buf.append("config_opts['dist'] = 'el6'\n");
-               buf.append("config_opts['plugin_conf']['yum_cache_enable'] = False\n");
-
-               buf.append("config_opts['scm'] = False\n");
-               buf.append("config_opts['scm_opts']['method'] = 'git'\n");
-               buf.append("config_opts['scm_opts']['spec'] = 'SCM_PKG.spec'\n");
-               buf.append("config_opts['scm_opts']['ext_src_dir'] = '"
-                               + getSourcesDir().getAbsolutePath() + "'\n");
-               buf.append("config_opts['scm_opts']['git_timestamps'] = True\n");
-
-               // development
-               if (gitDevBaseUrl != null && !gitDevBaseUrl.trim().equals(""))
-                       buf.append("config_opts['scm_opts']['git_get'] = 'git clone "
-                                       + (branch != null ? "-b " + branch : "") + " "
-                                       + gitDevBaseUrl + "/SCM_PKG SCM_PKG'\n");
-               else
-                       buf.append("config_opts['scm_opts']['git_get'] = 'git clone "
-                                       + (branch != null ? "-b " + branch : "") + " "
-                                       + getGitBaseUrl() + "/SCM_PKG.git SCM_PKG'\n");
-
-               buf.append("\nconfig_opts['yum.conf'] = \"\"\"\n");
-               buf.append(generateYumConfigFile(arch)).append('\n');
-               buf.append("\"\"\"\n");
-               return buf.toString();
-       }
-
-       public String generateYumConfigFile(String arch) {
-               StringBuffer buf = new StringBuffer();
-               buf.append("[main]\n");
-               buf.append(yumConfigMainSection).append('\n');
-
-               for (RpmRepository repository : repositories) {
-                       buf.append('[').append(repository.getId()).append("]\n");
-                       buf.append("name=").append(repository.getId()).append('\n');
-                       if (repository instanceof ThirdPartyRpmRepository) {
-                               buf.append("#baseurl=").append(repository.getUrl())
-                                               .append(arch).append('/').append("\n");
-                               buf.append("baseurl=").append(proxiedReposBase)
-                                               .append(repository.getId()).append('/').append(arch)
-                                               .append('/').append("\n");
-                               if (((ThirdPartyRpmRepository) repository).getYumConf() != null)
-                                       buf.append(
-                                                       ((ThirdPartyRpmRepository) repository).getYumConf()
-                                                                       .trim()).append('\n');
-                       }
-               }
-
-               // managed repos
-               addManagedRepository(buf, stagingWorkspace, arch);
-               if (withTestingRepository)
-                       addManagedRepository(buf, testingWorkspace, arch);
-               addManagedRepository(buf, stableWorkspace, arch);
-               return buf.toString();
-       }
-
-       protected void addManagedRepository(StringBuffer buf, String workspace,
-                       String arch) {
-               buf.append('[').append(workspace).append("]\n");
-               buf.append("baseurl=").append(managedReposBase).append(workspace)
-                               .append('/').append(arch).append('/').append("\n");
-               buf.append("gpgcheck=0").append("\n");
-       }
-
-       /** Creates a mock config file. */
-       public File getMockConfigFile(String arch, String branch) {
-               File mockSiteDefaultsFile = new File(mockConfDir, "site-defaults.cfg");
-               File mockLoggingFile = new File(mockConfDir, "logging.ini");
-               File mockConfigFile = new File(mockConfDir, getIdWithArch(arch)
-                               + ".cfg");
-               try {
-                       if (!mockSiteDefaultsFile.exists())
-                               mockSiteDefaultsFile.createNewFile();
-                       if (!mockLoggingFile.exists())
-                               FileUtils.copyFile(new File(mockEtc + "/logging.ini"),
-                                               mockLoggingFile);
-
-                       FileUtils.writeStringToFile(mockConfigFile,
-                                       generateMockConfigFile(arch, branch));
-                       return mockConfigFile;
-               } catch (IOException e) {
-                       throw new SlcException("Cannot write mock config file to "
-                                       + mockConfigFile, e);
-               }
-       }
-
-       /** Creates a yum config file. */
-       public File getYumRepoFile(String arch) {
-               File yumConfigFile = new File(yumConfDir, getIdWithArch(arch) + ".repo");
-               try {
-                       FileUtils.writeStringToFile(yumConfigFile,
-                                       generateYumConfigFile(arch));
-                       return yumConfigFile;
-               } catch (IOException e) {
-                       throw new SlcException("Cannot write yum config file to "
-                                       + yumConfigFile, e);
-               }
-       }
-
-       public File getResultDir(String arch) {
-               return new File(mockVar + "/" + getIdWithArch(arch) + "/result");
-       }
-
-       public File getWorkspaceDir(String workspace) {
-               return new File(rpmBase + "/" + workspace);
-       }
-
-       public File getSourcesDir() {
-               return new File(distBase + "/" + stableWorkspace);
-       }
-
-       public String getMockConfig(String arch) {
-               return getIdWithArch(arch);
-       }
-
-       public String getIdWithArch(String arch) {
-               return id + "-" + arch;
-       }
-
-       public String getGitBaseUrl() {
-               return managedReposBase + gitWorkspace;
-       }
-
-       public void indexWorkspace(String workspace) {
-               Session session = null;
-               try {
-                       session = rpmRepository.login(workspace);
-                       session.getRootNode().accept(
-                                       new NodeIndexerVisitor(new RpmIndexer()));
-                       if (log.isDebugEnabled())
-                               log.debug("Indexed workspace " + workspace);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot index workspace " + workspace, e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       public Boolean isDeveloperInstance() {
-               return gitDevBaseUrl != null;
-       }
-
-       /** Write (topdir)/rpmmacros and (topdir)/rpmrc */
-       public void writeRpmbuildConfigFiles(File topdir) {
-               writeRpmbuildConfigFiles(topdir, new File(topdir, "rpmmacros"),
-                               new File(topdir, "rpmrc"));
-       }
-
-       public void writeRpmbuildConfigFiles(File topdir, File rpmmacroFile,
-                       File rpmrcFile) {
-               try {
-                       List<String> macroLines = new ArrayList<String>();
-                       macroLines.add("%_topdir " + topdir.getCanonicalPath());
-                       for (String macroKey : rpmmacros.keySet()) {
-                               macroLines.add(macroKey + " " + rpmmacros.get(macroKey));
-                       }
-                       FileUtils.writeLines(rpmmacroFile, macroLines);
-
-                       List<String> rpmrcLines = new ArrayList<String>();
-                       rpmrcLines.add("include: /usr/lib/rpm/rpmrc");
-                       rpmrcLines.add("macrofiles: " + defaultMacroFiles + ":"
-                                       + rpmmacroFile.getCanonicalPath());
-                       FileUtils.writeLines(rpmrcFile, rpmrcLines);
-               } catch (IOException e) {
-                       throw new SlcException("Cannot write rpmbuild config files", e);
-               }
-
-       }
-
-       public Map<String, String> getRpmmacros() {
-               return rpmmacros;
-       }
-
-       public void setRpmmacros(Map<String, String> rpmmacros) {
-               this.rpmmacros = rpmmacros;
-       }
-
-       public String getDefaultMacroFiles() {
-               return defaultMacroFiles;
-       }
-
-       public void setDefaultMacroFiles(String defaultMacroFiles) {
-               this.defaultMacroFiles = defaultMacroFiles;
-       }
-
-       public void setArchs(List<String> archs) {
-               this.archs = archs;
-       }
-
-       public List<String> getArchs() {
-               return archs;
-       }
-
-       public void setRpmBase(String stagingBase) {
-               this.rpmBase = stagingBase;
-       }
-
-       public void setId(String id) {
-               this.id = id;
-       }
-
-       public void setMockVar(String mockVar) {
-               this.mockVar = mockVar;
-       }
-
-       public void setRpmRepository(Repository rpmRepository) {
-               this.rpmRepository = rpmRepository;
-       }
-
-       public void setDistRepository(Repository distRepository) {
-               this.distRepository = distRepository;
-       }
-
-       public void setLocalUrlBase(String localUrlBase) {
-               this.localUrlBase = localUrlBase;
-       }
-
-       public void setYumConfigMainSection(String yumConfigMainSection) {
-               this.yumConfigMainSection = yumConfigMainSection;
-       }
-
-       public void setRepositories(List<RpmRepository> repositories) {
-               this.repositories = repositories;
-       }
-
-       public void setRpmFactoryBaseDir(File rpmFactoryBaseDir) {
-               this.rpmFactoryBaseDir = rpmFactoryBaseDir;
-       }
-
-       public String getStagingWorkspace() {
-               return stagingWorkspace;
-       }
-
-       public String getTestingWorkspace() {
-               return testingWorkspace;
-       }
-
-       public String getStableWorkspace() {
-               return stableWorkspace;
-       }
-
-       public void setWithTestingRepository(Boolean withTestingRepository) {
-               this.withTestingRepository = withTestingRepository;
-       }
-
-       public void setGitDevBaseUrl(String gitBaseUrl) {
-               this.gitDevBaseUrl = gitBaseUrl;
-       }
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmPackageSet.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmPackageSet.java
deleted file mode 100644 (file)
index 1693413..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-/** Set of RPM packages */
-public interface RpmPackageSet {
-       public Boolean contains(String rpmPackage);
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java
deleted file mode 100644 (file)
index d067dfa..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.security.AccessControlException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.jcr.proxy.AbstractUrlProxy;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.rpmfactory.RpmProxyService;
-import org.argeo.slc.rpmfactory.RpmRepository;
-
-/** Synchronises the node repository with remote Maven repositories */
-public class RpmProxyServiceImpl extends AbstractUrlProxy implements
-               RpmProxyService, ArgeoNames, SlcNames {
-       private final static Log log = LogFactory.getLog(RpmProxyServiceImpl.class);
-
-       private Set<RpmRepository> defaultRepositories = new HashSet<RpmRepository>();
-
-       @Override
-       protected void beforeInitSessionSave(Session session)
-                       throws RepositoryException {
-               JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
-               try {
-                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
-                                       "jcr:all");
-               } catch (AccessControlException e) {
-                       if (log.isTraceEnabled())
-                               log.trace("Cannot give jcr:all privileges to "+SlcConstants.ROLE_SLC);
-               }
-
-               JcrUtils.mkdirsSafe(session, RepoConstants.PROXIED_REPOSITORIES);
-       }
-
-       /**
-        * Retrieve and add this file to the repository
-        */
-       @Override
-       protected Node retrieve(Session session, String path) {
-               StringBuilder relativePathBuilder = new StringBuilder();
-               String repoId = extractRepoId(path, relativePathBuilder);
-               // remove starting '/'
-               String relativePath = relativePathBuilder.toString().substring(1);
-
-               RpmRepository sourceRepo = null;
-               for (Iterator<RpmRepository> reposIt = defaultRepositories.iterator(); reposIt
-                               .hasNext();) {
-                       RpmRepository rpmRepo = reposIt.next();
-                       if (rpmRepo.getId().equals(repoId)) {
-                               sourceRepo = rpmRepo;
-                               break;
-                       }
-               }
-
-               if (sourceRepo == null)
-                       throw new SlcException("No RPM repository found for " + path);
-
-               try {
-                       String baseUrl = sourceRepo.getUrl();
-                       String remoteUrl = baseUrl + relativePath;
-                       Node node = proxyUrl(session, remoteUrl, path);
-                       if (node != null) {
-                               registerSource(sourceRepo, node, remoteUrl);
-                               if (log.isDebugEnabled())
-                                       log.debug("Imported " + remoteUrl + " to " + node);
-                               return node;
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot proxy " + path, e);
-               }
-               JcrUtils.discardQuietly(session);
-               throw new SlcException("No proxy found for " + path);
-       }
-
-       protected void registerSource(RpmRepository sourceRepo, Node node,
-                       String remoteUrl) throws RepositoryException {
-               node.addMixin(SlcTypes.SLC_KNOWN_ORIGIN);
-               Node origin;
-               if (!node.hasNode(SLC_ORIGIN))
-                       origin = node.addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
-               else
-                       origin = node.getNode(SLC_ORIGIN);
-
-               // proxied repository
-               Node proxiedRepository;
-               String proxiedRepositoryPath = RepoConstants.PROXIED_REPOSITORIES + '/'
-                               + sourceRepo.getId();
-               Session session = node.getSession();
-               if (session.itemExists(proxiedRepositoryPath)) {
-                       proxiedRepository = session.getNode(proxiedRepositoryPath);
-               } else {
-                       proxiedRepository = session.getNode(
-                                       RepoConstants.PROXIED_REPOSITORIES).addNode(
-                                       sourceRepo.getId());
-                       proxiedRepository.addMixin(NodeType.MIX_REFERENCEABLE);
-                       JcrUtils.urlToAddressProperties(proxiedRepository,
-                                       sourceRepo.getUrl());
-                       proxiedRepository.setProperty(SLC_URL, sourceRepo.getUrl());
-               }
-
-               origin.setProperty(SLC_PROXY, proxiedRepository);
-               JcrUtils.urlToAddressProperties(origin, remoteUrl);
-       }
-
-       /** Returns the first token of the path */
-       protected String extractRepoId(String path, StringBuilder relativePath) {
-               StringBuilder workspace = new StringBuilder();
-               StringBuilder buf = workspace;
-               for (int i = 1; i < path.length(); i++) {
-                       char c = path.charAt(i);
-                       if (c == '/') {
-                               buf = relativePath;
-                       }
-                       buf.append(c);
-               }
-               return workspace.toString();
-       }
-
-       @Override
-       protected Boolean shouldUpdate(Session clientSession, String nodePath) {
-               // if (nodePath.contains("/repodata/"))
-               // return true;
-               return super.shouldUpdate(clientSession, nodePath);
-       }
-
-       public void setDefaultRepositories(Set<RpmRepository> defaultRepositories) {
-               this.defaultRepositories = defaultRepositories;
-       }
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmSpecFile.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmSpecFile.java
deleted file mode 100644 (file)
index c9132f9..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class RpmSpecFile {
-       private Path specFile;
-
-       private String name;
-       private String version;
-       private String release;
-       private Map<String, String> sources = new HashMap<String, String>();
-       private Map<String, String> patches = new HashMap<String, String>();
-
-       public RpmSpecFile(Path specFile) {
-               this.specFile = specFile;
-               parseSpecFile();
-       }
-
-       public void init() {
-               parseSpecFile();
-       }
-
-       protected void parseSpecFile() {
-               try {
-                       List<String> lines = (List<String>) Files.readAllLines(specFile);
-
-                       lines: for (String line : lines) {
-                               int indexSemiColon = line.indexOf(':');
-                               if (indexSemiColon <= 0)
-                                       continue lines;
-                               String directive = line.substring(0, indexSemiColon).trim();
-                               String value = line.substring(indexSemiColon + 1).trim();
-                               if ("name".equals(directive.toLowerCase()))
-                                       name = value;
-                               else if ("version".equals(directive.toLowerCase()))
-                                       version = value;
-                               else if ("release".equals(directive.toLowerCase()))
-                                       release = value;
-                               else if (directive.toLowerCase().startsWith("source"))
-                                       sources.put(directive, interpret(value));
-                               else if (directive.toLowerCase().startsWith("patch"))
-                                       patches.put(directive, interpret(value));
-                       }
-
-               } catch (IOException e) {
-                       throw new RuntimeException("Cannot parse spec file " + specFile, e);
-               }
-       }
-
-       protected String interpret(String value) {
-               StringBuffer buf = new StringBuffer(value.length());
-               StringBuffer currKey = null;
-               boolean mayBeKey = false;
-               chars: for (char c : value.toCharArray()) {
-                       if (c == '%')
-                               mayBeKey = true;
-                       else if (c == '{') {
-                               if (mayBeKey)
-                                       currKey = new StringBuffer();
-                       } else if (c == '}') {
-                               if (currKey == null)
-                                       continue chars;
-                               String key = currKey.toString();
-                               if ("name".equals(key.toLowerCase()))
-                                       buf.append(name);
-                               else if ("version".equals(key.toLowerCase()))
-                                       buf.append(version);
-                               else
-                                       buf.append("%{").append(key).append('}');
-                               currKey = null;
-                       } else {
-                               if (currKey != null)
-                                       currKey.append(c);
-                               else
-                                       buf.append(c);
-                       }
-               }
-               return buf.toString();
-       }
-
-       public Path getSpecFile() {
-               return specFile;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       public String getRelease() {
-               return release;
-       }
-
-       public Map<String, String> getSources() {
-               return sources;
-       }
-
-       public Map<String, String> getPatches() {
-               return patches;
-       }
-
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/StagingRpmRepository.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/StagingRpmRepository.java
deleted file mode 100644 (file)
index 58977f4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-/** Local build repository, used only for builds. */
-public class StagingRpmRepository extends AbstractRpmRepository {
-
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ThirdPartyRpmRepository.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ThirdPartyRpmRepository.java
deleted file mode 100644 (file)
index 2902530..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-/**
- * A repository of third party RPMs used for the build. RPM used by the builds
- * will be cached within the system.
- */
-public class ThirdPartyRpmRepository extends AbstractRpmRepository {
-       private String yumConf;
-
-       public String getYumConf() {
-               return yumConf;
-       }
-
-       public void setYumConf(String yumConf) {
-               this.yumConf = yumConf;
-       }
-
-}
diff --git a/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/YumListParser.java b/cms/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/YumListParser.java
deleted file mode 100644 (file)
index ee89aa3..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.LineIterator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-
-/**
- * Reads the output of a 'yum list all' command and interpret the list of
- * packages.
- */
-public class YumListParser implements RpmPackageSet {
-       private final static Log log = LogFactory.getLog(YumListParser.class);
-
-       private Set<String> installed = new TreeSet<String>();
-       /** Not installed but available */
-       private Set<String> installable = new TreeSet<String>();
-
-       private Path yumListOutput;
-
-       public void init() {
-               if (yumListOutput != null) {
-                       try (InputStream in = Files.newInputStream(yumListOutput)) {
-                               load(in);
-                               if (log.isDebugEnabled())
-                                       log.debug(installed.size() + " installed, " + installable.size() + " installable, from "
-                                                       + yumListOutput);
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot initialize yum list parser", e);
-                       }
-               }
-       }
-
-       public Boolean contains(String packageName) {
-               if (installed.contains(packageName))
-                       return true;
-               else
-                       return installable.contains(packageName);
-       }
-
-       protected void load(InputStream in) throws IOException {
-               Boolean readingInstalled = false;
-               Boolean readingAvailable = false;
-               LineIterator it = IOUtils.lineIterator(in, "UTF-8");
-               while (it.hasNext()) {
-                       String line = it.nextLine();
-                       if (line.trim().equals("Installed Packages")) {
-                               readingInstalled = true;
-                       } else if (line.trim().equals("Available Packages")) {
-                               readingAvailable = true;
-                               readingInstalled = false;
-                       } else if (readingAvailable) {
-                               if (Character.isLetterOrDigit(line.charAt(0))) {
-                                       installable.add(extractRpmName(line));
-                               }
-                       } else if (readingInstalled) {
-                               if (Character.isLetterOrDigit(line.charAt(0))) {
-                                       installed.add(extractRpmName(line));
-                               }
-                       }
-               }
-       }
-
-       protected String extractRpmName(String line) {
-               StringTokenizer st = new StringTokenizer(line, " \t");
-               String packageName = st.nextToken();
-               // consider the arch as an extension
-               return FilenameUtils.getBaseName(packageName);
-               // return packageName.split("\\.")[0];
-       }
-
-       public Set<String> getInstalled() {
-               return installed;
-       }
-
-       public Set<String> getInstallable() {
-               return installable;
-       }
-
-       public void setYumListOutput(Path yumListOutput) {
-               this.yumListOutput = yumListOutput;
-       }
-
-}
diff --git a/cms/org.argeo.slc.jcr/.classpath b/cms/org.argeo.slc.jcr/.classpath
deleted file mode 100644 (file)
index e801ebf..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/cms/org.argeo.slc.jcr/.gitignore b/cms/org.argeo.slc.jcr/.gitignore
deleted file mode 100644 (file)
index 09e3bc9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/bin/
-/target/
diff --git a/cms/org.argeo.slc.jcr/.project b/cms/org.argeo.slc.jcr/.project
deleted file mode 100644 (file)
index a4cd874..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.jcr</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/cms/org.argeo.slc.jcr/META-INF/.gitignore b/cms/org.argeo.slc.jcr/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.jcr/bnd.bnd b/cms/org.argeo.slc.jcr/bnd.bnd
deleted file mode 100644 (file)
index 28c2b84..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Import-Package: javax.jcr.nodetype,\
-javax.jcr.security,\
-*
\ No newline at end of file
diff --git a/cms/org.argeo.slc.jcr/build.properties b/cms/org.argeo.slc.jcr/build.properties
deleted file mode 100644 (file)
index 34d2e4d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
-               .
diff --git a/cms/org.argeo.slc.jcr/pom.xml b/cms/org.argeo.slc.jcr/pom.xml
deleted file mode 100644 (file)
index 7c56e4e..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.jcr</artifactId>
-       <name>SLC JCR implementations</name>
-       <dependencies>
-               <!-- SLC -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.api</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.runtime</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Commons -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.enterprise</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.api</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.cms</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.jcr</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrMetadataWriter.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrMetadataWriter.java
deleted file mode 100644 (file)
index e2d1b10..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.argeo.slc.jcr;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-
-/**
- * Writes arbitrary metadata into a child node of a given node (or the node
- * itself if metadata node name is set to null)
- */
-public class JcrMetadataWriter implements Runnable {
-       private final static Log log = LogFactory.getLog(JcrMetadataWriter.class);
-
-       private Node baseNode;
-       private String metadataNodeName = SlcNames.SLC_METADATA;
-
-       private Map<String, String> metadata = new HashMap<String, String>();
-
-       public void run() {
-               try {
-                       Node metadataNode;
-                       if (metadataNodeName != null)
-                               metadataNode = baseNode.hasNode(metadataNodeName) ? baseNode
-                                               .getNode(metadataNodeName) : baseNode
-                                               .addNode(metadataNodeName);
-                       else
-                               metadataNode = baseNode;
-
-                       for (String key : metadata.keySet())
-                               metadataNode.setProperty(key, metadata.get(key));
-
-                       baseNode.getSession().save();
-
-                       if (log.isDebugEnabled())
-                               log.debug("Wrote " + metadata.size() + " metadata entries to "
-                                               + metadataNode);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot write metadata to " + baseNode, e);
-               } finally {
-                       JcrUtils.discardUnderlyingSessionQuietly(baseNode);
-               }
-
-       }
-
-       public void setBaseNode(Node baseNode) {
-               this.baseNode = baseNode;
-       }
-
-       public void setMetadataNodeName(String metadataNodeName) {
-               this.metadataNodeName = metadataNodeName;
-       }
-
-       public void setMetadata(Map<String, String> metadata) {
-               this.metadata = metadata;
-       }
-
-}
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrTestResult.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrTestResult.java
deleted file mode 100644 (file)
index e2d0607..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-package org.argeo.slc.jcr;
-
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.attachment.Attachment;
-import org.argeo.slc.attachment.AttachmentsEnabled;
-import org.argeo.slc.test.TestResult;
-import org.argeo.slc.test.TestResultPart;
-import org.argeo.slc.test.TestRun;
-import org.argeo.slc.test.TestStatus;
-
-/**
- * {@link TestResult} wrapping a JCR node of type
- * {@link SlcTypes#SLC_TEST_RESULT}.
- */
-public class JcrTestResult implements TestResult, SlcNames, AttachmentsEnabled {
-       private final static Log log = LogFactory.getLog(JcrTestResult.class);
-
-       /** Should only be set for an already existing result. */
-       private String uuid;
-       private Repository repository;
-       private Session session;
-       /**
-        * For testing purposes, best practice is to not set them explicitely but
-        * via other mechanisms such as JAAS or SPring Security.
-        */
-       private Credentials credentials = null;
-       private String resultType = SlcTypes.SLC_TEST_RESULT;
-
-       /** cached for performance purposes */
-       private String nodeIdentifier = null;
-
-       private Map<String, String> attributes = new HashMap<String, String>();
-
-       public void init() {
-               try {
-                       session = repository.login(credentials);
-                       if (uuid == null) {
-                               // create new result
-                               uuid = UUID.randomUUID().toString();
-                               String path = SlcJcrUtils.createResultPath(session, uuid);
-                               Node resultNode = JcrUtils.mkdirs(session, path, resultType);
-                               resultNode.setProperty(SLC_UUID, uuid);
-                               for (String attr : attributes.keySet()) {
-                                       String property = attr;
-                                       // compatibility with legacy applications
-                                       if ("testCase".equals(attr))
-                                               property = SLC_TEST_CASE;
-                                       else if ("testCaseType".equals(attr))
-                                               property = SLC_TEST_CASE_TYPE;
-                                       resultNode.setProperty(property, attributes.get(attr));
-                               }
-                               session.save();
-                               if (log.isDebugEnabled())
-                                       log.debug("Created test result " + uuid);
-                       }
-               } catch (Exception e) {
-                       JcrUtils.discardQuietly(session);
-                       throw new SlcException("Cannot initialize JCR result", e);
-               }
-       }
-
-       public void destroy() {
-               JcrUtils.logoutQuietly(session);
-               if (log.isTraceEnabled())
-                       log.trace("Logged out session for result " + uuid);
-       }
-
-       public Node getNode() {
-               try {
-                       Node resultNode;
-                       if (nodeIdentifier != null) {
-                               return session.getNodeByIdentifier(nodeIdentifier);
-                       } else {
-                               QueryManager qm = session.getWorkspace().getQueryManager();
-                               Query q = qm.createQuery("select * from ["
-                                               + SlcTypes.SLC_TEST_RESULT + "] where [slc:uuid]='"
-                                               + uuid + "'", Query.JCR_SQL2);
-                               resultNode = JcrUtils.querySingleNode(q);
-                               if (resultNode != null)
-                                       nodeIdentifier = resultNode.getIdentifier();
-                       }
-                       return resultNode;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot get result node", e);
-               }
-       }
-
-       public void notifyTestRun(TestRun testRun) {
-               // TODO store meta data about the test running
-               // if (log.isDebugEnabled())
-               // log.debug("Running test "
-               // + testRun.getTestDefinition().getClass().getName() + "...");
-       }
-
-       public void addResultPart(TestResultPart testResultPart) {
-               Node node = getNode();
-
-               try {
-                       // error : revert all unsaved changes on the resultNode to be sure
-                       // it is in a consistant state
-                       if (testResultPart.getExceptionMessage() != null)
-                               JcrUtils.discardQuietly(node.getSession());
-                       node.getSession().save();
-
-                       // add the new result part, retrieving status information
-                       Node resultPartNode = node.addNode(SlcNames.SLC_RESULT_PART,
-                                       SlcTypes.SLC_CHECK);
-                       resultPartNode.setProperty(SLC_SUCCESS, testResultPart.getStatus()
-                                       .equals(TestStatus.PASSED));
-                       if (testResultPart.getMessage() != null)
-                               resultPartNode.setProperty(SLC_MESSAGE,
-                                               testResultPart.getMessage());
-                       if (testResultPart.getStatus().equals(TestStatus.ERROR)) {
-                               resultPartNode.setProperty(SLC_ERROR_MESSAGE,
-                                               (testResultPart.getExceptionMessage() == null) ? ""
-                                                               : testResultPart.getExceptionMessage());
-                       }
-
-                       // helper update aggregate status node
-                       Node mainStatus;
-                       if (!node.hasNode(SLC_AGGREGATED_STATUS)) {
-
-                               mainStatus = node.addNode(SLC_AGGREGATED_STATUS,
-                                               SlcTypes.SLC_CHECK);
-                               mainStatus.setProperty(SLC_SUCCESS,
-                                               resultPartNode.getProperty(SLC_SUCCESS).getBoolean());
-                               if (resultPartNode.hasProperty(SLC_MESSAGE))
-                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
-                                                       .getProperty(SLC_MESSAGE).getString());
-                               if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE))
-                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
-                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
-                       } else {
-                               mainStatus = node.getNode(SLC_AGGREGATED_STATUS);
-                               if (mainStatus.hasProperty(SLC_ERROR_MESSAGE)) {
-                                       // main status already in error we do nothing
-                               } else if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE)) {
-                                       // main status was not in error and new result part is in
-                                       // error; we update main status
-                                       mainStatus.setProperty(SLC_SUCCESS, false);
-                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
-                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
-                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
-                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
-                                                               .getProperty(SLC_MESSAGE).getString());
-                                       else
-                                               // remove old message to remain consistent
-                                               mainStatus.setProperty(SLC_MESSAGE, "");
-                               } else if (!mainStatus.getProperty(SLC_SUCCESS).getBoolean()) {
-                                       // main status was already failed and new result part is not
-                                       // in error, we do nothing
-                               } else if (!resultPartNode.getProperty(SLC_SUCCESS)
-                                               .getBoolean()) {
-                                       // new resultPart that is failed
-                                       mainStatus.setProperty(SLC_SUCCESS, false);
-                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
-                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
-                                                               .getProperty(SLC_MESSAGE).getString());
-                                       else
-                                               // remove old message to remain consistent
-                                               mainStatus.setProperty(SLC_MESSAGE, "");
-                               } else if (resultPartNode.hasProperty(SLC_MESSAGE)
-                                               && (!mainStatus.hasProperty(SLC_MESSAGE) || (""
-                                                               .equals(mainStatus.getProperty(SLC_MESSAGE)
-                                                                               .getString().trim())))) {
-                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
-                                                       .getProperty(SLC_MESSAGE).getString());
-                               }
-                       }
-                       JcrUtils.updateLastModified(node);
-                       node.getSession().save();
-               } catch (Exception e) {
-                       JcrUtils.discardUnderlyingSessionQuietly(node);
-                       throw new SlcException("Cannot add ResultPart to node " + node, e);
-               }
-       }
-
-       public String getUuid() {
-               Node node = getNode();
-               try {
-                       return node.getProperty(SLC_UUID).getString();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot get UUID from " + node, e);
-               }
-       }
-
-       /** JCR session is NOT logged out */
-       public void close() {
-               Node node = getNode();
-               try {
-                       if (node.hasNode(SLC_COMPLETED))
-                               return;
-                       node.setProperty(SLC_COMPLETED, new GregorianCalendar());
-                       JcrUtils.updateLastModified(node);
-                       node.getSession().save();
-               } catch (Exception e) {
-                       JcrUtils.discardUnderlyingSessionQuietly(node);
-                       throw new SlcException("Cannot get close date from " + node, e);
-               }
-       }
-
-       public Date getCloseDate() {
-               Node node = getNode();
-               try {
-                       if (!node.hasNode(SLC_COMPLETED))
-                               return null;
-                       return node.getProperty(SLC_COMPLETED).getDate().getTime();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot get close date from " + node, e);
-               }
-       }
-
-       public Map<String, String> getAttributes() {
-               Node node = getNode();
-               try {
-                       Map<String, String> map = new HashMap<String, String>();
-                       PropertyIterator pit = node.getProperties();
-                       while (pit.hasNext()) {
-                               Property p = pit.nextProperty();
-                               if (!p.isMultiple())
-                                       map.put(p.getName(), p.getValue().getString());
-                       }
-                       return map;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot get close date from " + node, e);
-               }
-       }
-
-       public void addAttachment(Attachment attachment) {
-               // TODO implement it
-       }
-
-       public void setUuid(String uuid) {
-               this.uuid = uuid;
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setResultType(String resultType) {
-               this.resultType = resultType;
-       }
-
-       public void setAttributes(Map<String, String> attributes) {
-               if (uuid != null)
-                       throw new SlcException(
-                                       "Attributes cannot be set on an already initialized test result."
-                                                       + " Update the related JCR node directly instead.");
-               this.attributes = attributes;
-       }
-
-       public void setCredentials(Credentials credentials) {
-               this.credentials = credentials;
-       }
-}
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrConstants.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrConstants.java
deleted file mode 100644 (file)
index 19e6430..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.argeo.slc.jcr;
-
-import org.argeo.slc.SlcNames;
-
-/** JCR related constants used across SLC */
-public interface SlcJcrConstants {
-       public final static String PROPERTY_PATH = "argeo.slc.jcr.path";
-
-       public final static String SLC_BASE_PATH = "/" + SlcNames.SLC_SYSTEM;
-       public final static String AGENTS_BASE_PATH = SLC_BASE_PATH + "/"
-                       + SlcNames.SLC_AGENTS;
-       public final static String VM_AGENT_FACTORY_PATH = AGENTS_BASE_PATH + "/"
-                       + SlcNames.SLC_VM;
-}
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrResultUtils.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrResultUtils.java
deleted file mode 100644 (file)
index c7717db..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.argeo.slc.jcr;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.api.NodeUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/**
- * Utilities around the SLC JCR Result model. Note that it relies on fixed base
- * paths (convention over configuration) for optimization purposes.
- */
-public class SlcJcrResultUtils {
-
-       /**
-        * Returns the path to the current slc:result node
-        */
-       public static String getSlcResultsBasePath(Session session) {
-               try {
-                       Node userHome = NodeUtils.getUserHome(session);
-                       if (userHome == null)
-                               throw new SlcException("No user home available for "
-                                               + session.getUserID());
-                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
-                                       + SlcNames.SLC_RESULTS;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while getting Slc Results Base Path.", re);
-               }
-       }
-
-       /**
-        * Returns the base node to store SlcResults. If it does not exists, it is
-        * created. If a node already exists at the given path with the wrong type,
-        * it throws an exception.
-        * 
-        * @param session
-        * @return
-        */
-       public static Node getSlcResultsParentNode(Session session) {
-               try {
-                       String absPath = getSlcResultsBasePath(session);
-                       if (session.nodeExists(absPath)) {
-                               Node currNode = session.getNode(absPath);
-                               if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
-                                       return currNode;
-                               else
-                                       throw new SlcException(
-                                                       "A node already exists at this path : " + absPath
-                                                                       + " that has the wrong type. ");
-                       } else {
-                               Node slcResParNode = JcrUtils.mkdirs(session, absPath);
-                               slcResParNode.setPrimaryType(NodeType.NT_UNSTRUCTURED);
-                               session.save();
-                               return slcResParNode;
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while creating slcResult root parent node.",
-                                       re);
-               }
-       }
-
-       /**
-        * Returns the path to the current Result UI specific node, depending the
-        * current user
-        */
-       public static String getMyResultsBasePath(Session session) {
-               try {
-                       Node userHome = NodeUtils.getUserHome(session);
-                       if (userHome == null)
-                               throw new SlcException("No user home available for "
-                                               + session.getUserID());
-                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
-                                       + SlcNames.SLC_MY_RESULTS;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while getting Slc Results Base Path.", re);
-               }
-       }
-
-       /**
-        * Creates a new node with type SlcTypes.SLC_MY_RESULT_ROOT_FOLDER at the
-        * given absolute path. If a node already exists at the given path, returns
-        * that node if it has the correct type and throws an exception otherwise.
-        * 
-        * @param session
-        * @return
-        */
-       public static Node getMyResultParentNode(Session session) {
-               try {
-                       String absPath = getMyResultsBasePath(session);
-                       if (session.nodeExists(absPath)) {
-                               Node currNode = session.getNode(absPath);
-                               if (currNode.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
-                                       return currNode;
-                               else
-                                       throw new SlcException(
-                                                       "A node already exists at this path : " + absPath
-                                                                       + " that has the wrong type. ");
-                       } else {
-                               Node myResParNode = JcrUtils.mkdirs(session, absPath);
-                               myResParNode.setPrimaryType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER);
-                               session.save();
-                               return myResParNode;
-                       }
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while creating user MyResult base node.",
-                                       re);
-               }
-       }
-
-       /**
-        * Creates a new node with type SlcTypes.SLC_RESULT_FOLDER at the given
-        * absolute path. If a node already exists at the given path, returns that
-        * node if it has the correct type and throws an exception otherwise.
-        * 
-        * @param session
-        * @param absPath
-        * @return
-        */
-       public static synchronized Node createResultFolderNode(Session session,
-                       String absPath) {
-               try {
-                       if (session.nodeExists(absPath)) {
-                               // Sanity check
-                               Node currNode = session.getNode(absPath);
-                               if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER))
-                                       return currNode;
-                               else
-                                       throw new SlcException(
-                                                       "A node already exists at this path : " + absPath
-                                                                       + " that has the wrong type. ");
-                       }
-                       Node rfNode = JcrUtils.mkdirs(session, absPath);
-                       rfNode.setPrimaryType(SlcTypes.SLC_RESULT_FOLDER);
-                       Node statusNode = rfNode.addNode(SlcNames.SLC_AGGREGATED_STATUS,
-                                       SlcTypes.SLC_CHECK);
-                       statusNode.setProperty(SlcNames.SLC_SUCCESS, true);
-                       session.save();
-                       return rfNode;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while creating Result Folder node.", re);
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrUtils.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrUtils.java
deleted file mode 100644 (file)
index c91a94c..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-package org.argeo.slc.jcr;
-
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.api.NodeUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.deploy.ModuleDescriptor;
-import org.argeo.slc.primitive.PrimitiveAccessor;
-import org.argeo.slc.primitive.PrimitiveUtils;
-import org.argeo.slc.test.TestStatus;
-
-/**
- * Utilities around the SLC JCR model. Note that it relies on fixed base paths
- * (convention over configuration) for optimization purposes.
- */
-public class SlcJcrUtils implements SlcNames {
-       public final static Integer AGENT_FACTORY_DEPTH = 3;
-
-       /** Extracts the path of a flow relative to its execution module */
-       public static String flowRelativePath(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               StringBuffer buf = new StringBuffer(fullFlowPath.length());
-               for (int i = AGENT_FACTORY_DEPTH + 3; i < tokens.length; i++) {
-                       buf.append('/').append(tokens[i]);
-               }
-               return buf.toString();
-       }
-
-       /** Extracts the path to the related execution module */
-       public static String modulePath(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               StringBuffer buf = new StringBuffer(fullFlowPath.length());
-               for (int i = 0; i < AGENT_FACTORY_DEPTH + 3; i++) {
-                       if (!tokens[i].equals(""))
-                               buf.append('/').append(tokens[i]);
-               }
-               return buf.toString();
-       }
-
-       /** Extracts the module name from a flow path */
-       public static String moduleName(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               String moduleName = tokens[AGENT_FACTORY_DEPTH + 2];
-               moduleName = moduleName.substring(0, moduleName.indexOf('_'));
-               return moduleName;
-       }
-
-       /** Extracts the module name and version from a flow path */
-       public static NameVersion moduleNameVersion(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               String module = tokens[AGENT_FACTORY_DEPTH + 2];
-               String moduleName = module.substring(0, module.indexOf('_'));
-               String moduleVersion = module.substring(module.indexOf('_') + 1);
-               return new DefaultNameVersion(moduleName, moduleVersion);
-       }
-
-       /** Module node name based on module name and version */
-       public static String getModuleNodeName(ModuleDescriptor moduleDescriptor) {
-               return moduleDescriptor.getName() + "_" + moduleDescriptor.getVersion();
-       }
-
-       /** Extracts the agent factory of a flow */
-       public static String flowAgentFactoryPath(String fullFlowPath) {
-               String[] tokens = fullFlowPath.split("/");
-               StringBuffer buf = new StringBuffer(fullFlowPath.length());
-               // first token is always empty
-               for (int i = 1; i < AGENT_FACTORY_DEPTH + 1; i++) {
-                       buf.append('/').append(tokens[i]);
-               }
-               return buf.toString();
-       }
-
-       /** Create a new execution process path based on the current time */
-       public static String createExecutionProcessPath(Session session, String uuid) {
-               Calendar now = new GregorianCalendar();
-               return getSlcProcessesBasePath(session) + '/'
-                               + JcrUtils.dateAsPath(now, true) + uuid;
-       }
-
-       /** Get the base for the user processi. */
-       public static String getSlcProcessesBasePath(Session session) {
-               try {
-                       Node userHome = NodeUtils.getUserHome(session);
-                       if (userHome == null)
-                               throw new SlcException("No user home available for "
-                                               + session.getUserID());
-                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
-                                       + SlcNames.SLC_PROCESSES;
-               } catch (RepositoryException re) {
-                       throw new SlcException(
-                                       "Unexpected error while getting Slc Results Base Path.", re);
-               }
-       }
-
-       /**
-        * Create a new execution result path in the user home based on the current
-        * time
-        */
-       public static String createResultPath(Session session, String uuid)
-                       throws RepositoryException {
-               Calendar now = new GregorianCalendar();
-               StringBuffer absPath = new StringBuffer(
-                               SlcJcrResultUtils.getSlcResultsBasePath(session) + '/');
-               // Remove hours and add title property to the result process path on
-               // request of O. Capillon
-               // return getSlcProcessesBasePath(session) + '/'
-               // + JcrUtils.dateAsPath(now, true) + uuid;
-               String relPath = JcrUtils.dateAsPath(now, false);
-               List<String> names = JcrUtils.tokenize(relPath);
-               for (String name : names) {
-                       absPath.append(name + "/");
-                       Node node = JcrUtils.mkdirs(session, absPath.toString());
-                       try {
-                               node.addMixin(NodeType.MIX_TITLE);
-                               node.setProperty(Property.JCR_TITLE, name.substring(1));
-                       } catch (RepositoryException e) {
-                               throw new SlcException(
-                                               "unable to create execution process path", e);
-                       }
-               }
-               return absPath.toString() + uuid;
-       }
-
-       /**
-        * Set the value of the primitive accessor as a JCR property. Does nothing
-        * if the value is null.
-        */
-       public static void setPrimitiveAsProperty(Node node, String propertyName,
-                       PrimitiveAccessor primitiveAccessor) {
-               String type = primitiveAccessor.getType();
-               Object value = primitiveAccessor.getValue();
-               setPrimitiveAsProperty(node, propertyName, type, value);
-       }
-
-       /** Map a primitive value to JCR property value. */
-       public static void setPrimitiveAsProperty(Node node, String propertyName,
-                       String type, Object value) {
-               if (value == null)
-                       return;
-               if (value instanceof CharSequence)
-                       value = PrimitiveUtils.convert(type,
-                                       ((CharSequence) value).toString());
-               if (value instanceof char[])
-                       value = new String((char[]) value);
-
-               try {
-                       if (type.equals(PrimitiveAccessor.TYPE_STRING))
-                               node.setProperty(propertyName, value.toString());
-                       else if (type.equals(PrimitiveAccessor.TYPE_PASSWORD))
-                               node.setProperty(propertyName, value.toString());
-                       else if (type.equals(PrimitiveAccessor.TYPE_INTEGER))
-                               node.setProperty(propertyName, (long) ((Integer) value));
-                       else if (type.equals(PrimitiveAccessor.TYPE_LONG))
-                               node.setProperty(propertyName, ((Long) value));
-                       else if (type.equals(PrimitiveAccessor.TYPE_FLOAT))
-                               node.setProperty(propertyName, (double) ((Float) value));
-                       else if (type.equals(PrimitiveAccessor.TYPE_DOUBLE))
-                               node.setProperty(propertyName, ((Double) value));
-                       else if (type.equals(PrimitiveAccessor.TYPE_BOOLEAN))
-                               node.setProperty(propertyName, ((Boolean) value));
-                       else
-                               throw new SlcException("Unsupported type " + type);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot set primitive of " + type
-                                       + " as property " + propertyName + " on " + node, e);
-               }
-       }
-
-       /** Aggregates the {@link TestStatus} of this sub-tree. */
-       public static Integer aggregateTestStatus(Node node) {
-               try {
-                       Integer status = TestStatus.PASSED;
-                       if (node.isNodeType(SlcTypes.SLC_CHECK))
-                               if (node.getProperty(SLC_SUCCESS).getBoolean())
-                                       status = TestStatus.PASSED;
-                               else if (node.hasProperty(SLC_ERROR_MESSAGE))
-                                       status = TestStatus.ERROR;
-                               else
-                                       status = TestStatus.FAILED;
-
-                       NodeIterator it = node.getNodes();
-                       while (it.hasNext()) {
-                               Node curr = it.nextNode();
-
-                               // Manually skip aggregated status
-                               if (!SlcNames.SLC_AGGREGATED_STATUS.equals(curr.getName())) {
-                                       Integer childStatus = aggregateTestStatus(curr);
-                                       if (childStatus > status)
-                                               status = childStatus;
-                               }
-                       }
-                       return status;
-               } catch (Exception e) {
-                       throw new SlcException("Could not aggregate test status from "
-                                       + node, e);
-               }
-       }
-
-       /**
-        * Aggregates the {@link TestStatus} of this sub-tree.
-        * 
-        * @return the same {@link StringBuffer}, for convenience (typically calling
-        *         toString() on it)
-        */
-       public static StringBuffer aggregateTestMessages(Node node,
-                       StringBuffer messages) {
-               try {
-                       if (node.isNodeType(SlcTypes.SLC_CHECK)) {
-                               if (node.hasProperty(SLC_MESSAGE)) {
-                                       if (messages.length() > 0)
-                                               messages.append('\n');
-                                       messages.append(node.getProperty(SLC_MESSAGE).getString());
-                               }
-                               if (node.hasProperty(SLC_ERROR_MESSAGE)) {
-                                       if (messages.length() > 0)
-                                               messages.append('\n');
-                                       messages.append(node.getProperty(SLC_ERROR_MESSAGE)
-                                                       .getString());
-                               }
-                       }
-                       NodeIterator it = node.getNodes();
-                       while (it.hasNext()) {
-                               Node child = it.nextNode();
-                               // Manually skip aggregated status
-                               if (!SlcNames.SLC_AGGREGATED_STATUS.equals(child.getName())) {
-                                       aggregateTestMessages(child, messages);
-                               }
-                       }
-                       return messages;
-               } catch (Exception e) {
-                       throw new SlcException("Could not aggregate test messages from "
-                                       + node, e);
-               }
-       }
-
-       /** Prevents instantiation */
-       private SlcJcrUtils() {
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrAgent.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrAgent.java
deleted file mode 100644 (file)
index 7f776d1..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.argeo.slc.jcr.execution;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.UUID;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.runtime.DefaultAgent;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.jcr.SlcJcrConstants;
-import org.argeo.slc.runtime.ProcessThread;
-
-/** SLC VM agent synchronizing with a JCR repository. */
-public class JcrAgent extends DefaultAgent implements SlcNames {
-       // final static String ROLE_REMOTE = "ROLE_REMOTE";
-       final static String NODE_REPO_URI = "argeo.node.repo.uri";
-
-       private Repository repository;
-
-       private String agentNodeName = "default";
-
-       /*
-        * LIFECYCLE
-        */
-       protected String initAgentUuid() {
-               Session session = null;
-               try {
-                       session = repository.login();
-
-                       String agentFactoryPath = getAgentFactoryPath();
-                       Node vmAgentFactoryNode = JcrUtils.mkdirsSafe(session, agentFactoryPath, SlcTypes.SLC_AGENT_FACTORY);
-                       JcrUtils.addPrivilege(session, SlcJcrConstants.SLC_BASE_PATH, SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
-                       if (!vmAgentFactoryNode.hasNode(agentNodeName)) {
-                               String uuid = UUID.randomUUID().toString();
-                               Node agentNode = vmAgentFactoryNode.addNode(agentNodeName, SlcTypes.SLC_AGENT);
-                               agentNode.setProperty(SLC_UUID, uuid);
-                       }
-                       session.save();
-                       return vmAgentFactoryNode.getNode(agentNodeName).getProperty(SLC_UUID).getString();
-               } catch (RepositoryException e) {
-                       JcrUtils.discardQuietly(session);
-                       throw new SlcException("Cannot find JCR agent UUID", e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       @Override
-       public void destroy() {
-               super.destroy();
-       }
-
-       /*
-        * SLC AGENT
-        */
-       @Override
-       protected ProcessThread createProcessThread(ThreadGroup processesThreadGroup,
-                       ExecutionModulesManager modulesManager, ExecutionProcess process) {
-               if (process instanceof JcrExecutionProcess)
-                       return new JcrProcessThread(processesThreadGroup, modulesManager, (JcrExecutionProcess) process);
-               else
-                       return super.createProcessThread(processesThreadGroup, modulesManager, process);
-       }
-
-       /*
-        * UTILITIES
-        */
-       public String getNodePath() {
-               return getAgentFactoryPath() + '/' + getAgentNodeName();
-       }
-
-       public String getAgentFactoryPath() {
-               try {
-                       Boolean isRemote = System.getProperty(NODE_REPO_URI) != null;
-                       String agentFactoryPath;
-                       if (isRemote) {
-                               InetAddress localhost = InetAddress.getLocalHost();
-                               agentFactoryPath = SlcJcrConstants.AGENTS_BASE_PATH + "/" + localhost.getCanonicalHostName();
-
-                               if (agentFactoryPath.equals(SlcJcrConstants.VM_AGENT_FACTORY_PATH))
-                                       throw new SlcException("Unsupported hostname " + localhost.getCanonicalHostName());
-                       } else {// local
-                               agentFactoryPath = SlcJcrConstants.VM_AGENT_FACTORY_PATH;
-                       }
-                       return agentFactoryPath;
-               } catch (UnknownHostException e) {
-                       throw new SlcException("Cannot find agent factory base path", e);
-               }
-       }
-
-       /*
-        * BEAN
-        */
-       public String getAgentNodeName() {
-               return agentNodeName;
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setAgentNodeName(String agentNodeName) {
-               this.agentNodeName = agentNodeName;
-       }
-}
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java
deleted file mode 100644 (file)
index 2804b22..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
-package org.argeo.slc.jcr.execution;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.deploy.ModuleDescriptor;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionModuleDescriptor;
-import org.argeo.slc.execution.ExecutionModulesListener;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValueChoice;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveValue;
-
-/**
- * Synchronizes the local execution runtime with a JCR repository. For the time
- * being the state is completely reset from one start to another.
- */
-public class JcrExecutionModulesListener implements ExecutionModulesListener,
-               SlcNames {
-       private final static String SLC_EXECUTION_MODULES_PROPERTY = "slc.executionModules";
-
-       private final static Log log = LogFactory
-                       .getLog(JcrExecutionModulesListener.class);
-       private JcrAgent agent;
-
-       private ExecutionModulesManager modulesManager;
-
-       private Repository repository;
-       /**
-        * We don't use a thread bound session because many different threads will
-        * call this critical component and we don't want to login each time. We
-        * therefore rather protect access to this session via synchronized.
-        */
-       private Session session;
-
-       /*
-        * LIFECYCLE
-        */
-       public void init() {
-               try {
-                       session = repository.login();
-                       clearAgent();
-                       if (modulesManager != null) {
-                               Node agentNode = session.getNode(agent.getNodePath());
-
-                               List<ModuleDescriptor> moduleDescriptors = modulesManager
-                                               .listModules();
-
-                               // scan SLC-ExecutionModule metadata
-                               for (ModuleDescriptor md : moduleDescriptors) {
-                                       if (md.getMetadata().containsKey(
-                                                       ExecutionModuleDescriptor.SLC_EXECUTION_MODULE)) {
-                                               String moduleNodeName = SlcJcrUtils
-                                                               .getModuleNodeName(md);
-                                               Node moduleNode = agentNode.hasNode(moduleNodeName) ? agentNode
-                                                               .getNode(moduleNodeName) : agentNode
-                                                               .addNode(moduleNodeName);
-                                               moduleNode.addMixin(SlcTypes.SLC_EXECUTION_MODULE);
-                                               moduleNode.setProperty(SLC_NAME, md.getName());
-                                               moduleNode.setProperty(SLC_VERSION, md.getVersion());
-                                               moduleNode.setProperty(Property.JCR_TITLE,
-                                                               md.getTitle());
-                                               moduleNode.setProperty(Property.JCR_DESCRIPTION,
-                                                               md.getDescription());
-                                               moduleNode.setProperty(SLC_STARTED, md.getStarted());
-                                       }
-                               }
-
-                               // scan execution modules property
-                               String executionModules = System
-                                               .getProperty(SLC_EXECUTION_MODULES_PROPERTY);
-                               if (executionModules != null) {
-                                       for (String executionModule : executionModules.split(",")) {
-                                               allModules: for (ModuleDescriptor md : moduleDescriptors) {
-                                                       String moduleNodeName = SlcJcrUtils
-                                                                       .getModuleNodeName(md);
-                                                       if (md.getName().equals(executionModule)) {
-                                                               Node moduleNode = agentNode
-                                                                               .hasNode(moduleNodeName) ? agentNode
-                                                                               .getNode(moduleNodeName) : agentNode
-                                                                               .addNode(moduleNodeName);
-                                                               moduleNode
-                                                                               .addMixin(SlcTypes.SLC_EXECUTION_MODULE);
-                                                               moduleNode.setProperty(SLC_NAME, md.getName());
-                                                               moduleNode.setProperty(SLC_VERSION,
-                                                                               md.getVersion());
-                                                               moduleNode.setProperty(Property.JCR_TITLE,
-                                                                               md.getTitle());
-                                                               moduleNode.setProperty(
-                                                                               Property.JCR_DESCRIPTION,
-                                                                               md.getDescription());
-                                                               moduleNode.setProperty(SLC_STARTED,
-                                                                               md.getStarted());
-                                                               break allModules;
-                                                       }
-                                               }
-                                       }
-
-                                       // save if needed
-                                       if (session.hasPendingChanges())
-                                               session.save();
-                               }
-                       }
-               } catch (RepositoryException e) {
-                       JcrUtils.discardQuietly(session);
-                       JcrUtils.logoutQuietly(session);
-                       throw new SlcException("Cannot initialize modules", e);
-               }
-       }
-
-       public void destroy() {
-               clearAgent();
-               JcrUtils.logoutQuietly(session);
-       }
-
-       protected synchronized void clearAgent() {
-               try {
-                       Node agentNode = session.getNode(agent.getNodePath());
-                       for (NodeIterator nit = agentNode.getNodes(); nit.hasNext();)
-                               nit.nextNode().remove();
-                       session.save();
-               } catch (RepositoryException e) {
-                       JcrUtils.discardQuietly(session);
-                       throw new SlcException("Cannot clear agent " + agent, e);
-               }
-       }
-
-       /*
-        * EXECUTION MODULES LISTENER
-        */
-
-       public synchronized void executionModuleAdded(
-                       ModuleDescriptor moduleDescriptor) {
-               syncExecutionModule(moduleDescriptor);
-       }
-
-       protected void syncExecutionModule(ModuleDescriptor moduleDescriptor) {
-               try {
-                       Node agentNode = session.getNode(agent.getNodePath());
-                       String moduleNodeName = SlcJcrUtils
-                                       .getModuleNodeName(moduleDescriptor);
-                       Node moduleNode = agentNode.hasNode(moduleNodeName) ? agentNode
-                                       .getNode(moduleNodeName) : agentNode
-                                       .addNode(moduleNodeName);
-                       moduleNode.addMixin(SlcTypes.SLC_EXECUTION_MODULE);
-                       moduleNode.setProperty(SLC_NAME, moduleDescriptor.getName());
-                       moduleNode.setProperty(SLC_VERSION, moduleDescriptor.getVersion());
-                       moduleNode.setProperty(Property.JCR_TITLE,
-                                       moduleDescriptor.getTitle());
-                       moduleNode.setProperty(Property.JCR_DESCRIPTION,
-                                       moduleDescriptor.getDescription());
-                       moduleNode.setProperty(SLC_STARTED, moduleDescriptor.getStarted());
-                       session.save();
-               } catch (RepositoryException e) {
-                       JcrUtils.discardQuietly(session);
-                       throw new SlcException("Cannot sync module " + moduleDescriptor, e);
-               }
-       }
-
-       public synchronized void executionModuleRemoved(
-                       ModuleDescriptor moduleDescriptor) {
-               try {
-                       String moduleName = SlcJcrUtils.getModuleNodeName(moduleDescriptor);
-                       Node agentNode = session.getNode(agent.getNodePath());
-                       if (agentNode.hasNode(moduleName)) {
-                               Node moduleNode = agentNode.getNode(moduleName);
-                               for (NodeIterator nit = moduleNode.getNodes(); nit.hasNext();) {
-                                       nit.nextNode().remove();
-                               }
-                               moduleNode.setProperty(SLC_STARTED, false);
-                       }
-                       session.save();
-               } catch (RepositoryException e) {
-                       JcrUtils.discardQuietly(session);
-                       throw new SlcException("Cannot remove module " + moduleDescriptor,
-                                       e);
-               }
-       }
-
-       public synchronized void executionFlowAdded(ModuleDescriptor module,
-                       ExecutionFlowDescriptor efd) {
-               try {
-                       Node agentNode = session.getNode(agent.getNodePath());
-                       Node moduleNode = agentNode.getNode(SlcJcrUtils
-                                       .getModuleNodeName(module));
-                       String relativePath = getExecutionFlowRelativePath(efd);
-                       @SuppressWarnings("unused")
-                       Node flowNode = null;
-                       if (!moduleNode.hasNode(relativePath)) {
-                               flowNode = createExecutionFlowNode(moduleNode, relativePath,
-                                               efd);
-                               session.save();
-                       } else {
-                               flowNode = moduleNode.getNode(relativePath);
-                       }
-
-                       if (log.isTraceEnabled())
-                               log.trace("Flow " + efd + " added to JCR");
-               } catch (RepositoryException e) {
-                       JcrUtils.discardQuietly(session);
-                       throw new SlcException("Cannot add flow " + efd + " from module "
-                                       + module, e);
-               }
-
-       }
-
-       protected Node createExecutionFlowNode(Node moduleNode,
-                       String relativePath, ExecutionFlowDescriptor efd)
-                       throws RepositoryException {
-               Node flowNode = null;
-               List<String> pathTokens = Arrays.asList(relativePath.split("/"));
-
-               Iterator<String> names = pathTokens.iterator();
-               // create intermediary paths
-               Node currNode = moduleNode;
-               while (names.hasNext()) {
-                       String name = names.next();
-                       if (currNode.hasNode(name))
-                               currNode = currNode.getNode(name);
-                       else {
-                               if (names.hasNext())
-                                       currNode = currNode.addNode(name);
-                               else
-                                       flowNode = currNode.addNode(name,
-                                                       SlcTypes.SLC_EXECUTION_FLOW);
-                       }
-               }
-
-               // name, description
-               flowNode.setProperty(SLC_NAME, efd.getName());
-               String endName = pathTokens.get(pathTokens.size() - 1);
-               flowNode.setProperty(Property.JCR_TITLE, endName);
-               if (efd.getDescription() != null
-                               && !efd.getDescription().trim().equals("")) {
-                       flowNode.setProperty(Property.JCR_DESCRIPTION, efd.getDescription());
-               } else {
-                       flowNode.setProperty(Property.JCR_DESCRIPTION, endName);
-               }
-
-               // execution spec
-               ExecutionSpec executionSpec = efd.getExecutionSpec();
-               String esName = executionSpec.getName();
-               if (esName == null || esName.equals(ExecutionSpec.INTERNAL_NAME)
-                               || esName.contains("#")/* automatically generated bean name */) {
-                       // internal spec node
-                       mapExecutionSpec(flowNode, executionSpec);
-               } else {
-                       // reference spec node
-                       Node executionSpecsNode = moduleNode.hasNode(SLC_EXECUTION_SPECS) ? moduleNode
-                                       .getNode(SLC_EXECUTION_SPECS) : moduleNode
-                                       .addNode(SLC_EXECUTION_SPECS);
-                       Node executionSpecNode = executionSpecsNode.addNode(esName,
-                                       SlcTypes.SLC_EXECUTION_SPEC);
-                       executionSpecNode.setProperty(SLC_NAME, esName);
-                       executionSpecNode.setProperty(Property.JCR_TITLE, esName);
-                       if (executionSpec.getDescription() != null
-                                       && !executionSpec.getDescription().trim().equals(""))
-                               executionSpecNode.setProperty(Property.JCR_DESCRIPTION,
-                                               executionSpec.getDescription());
-                       mapExecutionSpec(executionSpecNode, executionSpec);
-                       flowNode.setProperty(SLC_SPEC, executionSpecNode);
-               }
-
-               // flow values
-               for (String attr : efd.getValues().keySet()) {
-                       ExecutionSpecAttribute esa = executionSpec.getAttributes()
-                                       .get(attr);
-                       if (esa instanceof PrimitiveSpecAttribute) {
-                               PrimitiveSpecAttribute psa = (PrimitiveSpecAttribute) esa;
-                               // if spec reference there will be no node at this stage
-                               Node valueNode = JcrUtils.getOrAdd(flowNode, attr);
-                               valueNode.setProperty(SLC_TYPE, psa.getType());
-                               SlcJcrUtils.setPrimitiveAsProperty(valueNode, SLC_VALUE,
-                                               (PrimitiveValue) efd.getValues().get(attr));
-                       }
-               }
-
-               return flowNode;
-       }
-
-       /**
-        * Base can be either an execution spec node, or an execution flow node (in
-        * case the execution spec is internal)
-        */
-       protected void mapExecutionSpec(Node baseNode, ExecutionSpec executionSpec)
-                       throws RepositoryException {
-               for (String attrName : executionSpec.getAttributes().keySet()) {
-                       ExecutionSpecAttribute esa = executionSpec.getAttributes().get(
-                                       attrName);
-                       Node attrNode = baseNode.addNode(attrName);
-                       // booleans
-                       attrNode.addMixin(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE);
-                       attrNode.setProperty(SLC_IS_IMMUTABLE, esa.getIsImmutable());
-                       attrNode.setProperty(SLC_IS_CONSTANT, esa.getIsConstant());
-                       attrNode.setProperty(SLC_IS_HIDDEN, esa.getIsHidden());
-
-                       if (esa instanceof PrimitiveSpecAttribute) {
-                               attrNode.addMixin(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE);
-                               PrimitiveSpecAttribute psa = (PrimitiveSpecAttribute) esa;
-                               SlcJcrUtils.setPrimitiveAsProperty(attrNode, SLC_VALUE, psa);
-                               attrNode.setProperty(SLC_TYPE, psa.getType());
-                       } else if (esa instanceof RefSpecAttribute) {
-                               attrNode.addMixin(SlcTypes.SLC_REF_SPEC_ATTRIBUTE);
-                               RefSpecAttribute rsa = (RefSpecAttribute) esa;
-                               attrNode.setProperty(SLC_TYPE, rsa.getTargetClassName());
-                               Object value = rsa.getValue();
-                               if (rsa.getChoices() != null) {
-                                       Integer index = null;
-                                       int count = 0;
-                                       for (RefValueChoice choice : rsa.getChoices()) {
-                                               String name = choice.getName();
-                                               if (value != null && name.equals(value.toString()))
-                                                       index = count;
-                                               Node choiceNode = attrNode.addNode(choice.getName());
-                                               choiceNode.addMixin(NodeType.MIX_TITLE);
-                                               choiceNode.setProperty(Property.JCR_TITLE,
-                                                               choice.getName());
-                                               if (choice.getDescription() != null
-                                                               && !choice.getDescription().trim().equals(""))
-                                                       choiceNode.setProperty(Property.JCR_DESCRIPTION,
-                                                                       choice.getDescription());
-                                               count++;
-                                       }
-
-                                       if (index != null)
-                                               attrNode.setProperty(SLC_VALUE, index);
-                               }
-                       }
-               }
-       }
-
-       public synchronized void executionFlowRemoved(ModuleDescriptor module,
-                       ExecutionFlowDescriptor executionFlow) {
-               try {
-                       Node agentNode = session.getNode(agent.getNodePath());
-                       Node moduleNode = agentNode.getNode(SlcJcrUtils
-                                       .getModuleNodeName(module));
-                       String relativePath = getExecutionFlowRelativePath(executionFlow);
-                       if (moduleNode.hasNode(relativePath))
-                               moduleNode.getNode(relativePath).remove();
-                       agentNode.getSession().save();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot remove flow " + executionFlow
-                                       + " from module " + module, e);
-               }
-       }
-
-       /*
-        * UTILITIES
-        */
-       /** @return the relative path, never starts with '/' */
-       @SuppressWarnings("deprecation")
-       protected String getExecutionFlowRelativePath(
-                       ExecutionFlowDescriptor executionFlow) {
-               String relativePath = executionFlow.getPath() == null ? executionFlow
-                               .getName() : executionFlow.getPath() + '/'
-                               + executionFlow.getName();
-               // we assume that it is more than one char long
-               if (relativePath.charAt(0) == '/')
-                       relativePath = relativePath.substring(1);
-               // FIXME quick hack to avoid duplicate '/'
-               relativePath = relativePath.replaceAll("//", "/");
-               return relativePath;
-       }
-
-       /*
-        * BEAN
-        */
-       public void setAgent(JcrAgent agent) {
-               this.agent = agent;
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setModulesManager(ExecutionModulesManager modulesManager) {
-               this.modulesManager = modulesManager;
-       }
-
-}
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionProcess.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionProcess.java
deleted file mode 100644 (file)
index 9d00459..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-package org.argeo.slc.jcr.execution;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.execution.ExecutionStep;
-import org.argeo.slc.execution.RealizedFlow;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.argeo.slc.runtime.ProcessThread;
-
-/** Execution process implementation based on a JCR node. */
-public class JcrExecutionProcess implements ExecutionProcess, SlcNames {
-       private final static Log log = LogFactory.getLog(JcrExecutionProcess.class);
-       private final Node node;
-
-       private Long nextLogLine = 1l;
-
-       public JcrExecutionProcess(Node node) {
-               this.node = node;
-       }
-
-       public synchronized String getUuid() {
-               try {
-                       return node.getProperty(SLC_UUID).getString();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot get uuid for " + node, e);
-               }
-       }
-
-       public synchronized String getStatus() {
-               try {
-                       return node.getProperty(SLC_STATUS).getString();
-               } catch (RepositoryException e) {
-                       log.error("Cannot get status: " + e);
-                       // we should re-throw exception because this information can
-                       // probably used for monitoring in case there are already unexpected
-                       // exceptions
-                       return UNKOWN;
-               }
-       }
-
-       public synchronized void setStatus(String status) {
-               try {
-                       node.setProperty(SLC_STATUS, status);
-                       // last modified properties needs to be manually updated
-                       // see https://issues.apache.org/jira/browse/JCR-2233
-                       JcrUtils.updateLastModified(node);
-                       node.getSession().save();
-               } catch (RepositoryException e) {
-                       JcrUtils.discardUnderlyingSessionQuietly(node);
-                       // we should re-throw exception because this information can
-                       // probably used for monitoring in case there are already unexpected
-                       // exceptions
-                       log.error("Cannot set status " + status + ": " + e);
-               }
-       }
-
-       /**
-        * Synchronized in order to make sure that there is no concurrent
-        * modification of {@link #nextLogLine}.
-        */
-       public synchronized void addSteps(List<ExecutionStep> steps) {
-               try {
-                       steps: for (ExecutionStep step : steps) {
-                               String type;
-                               if (step.getType().equals(ExecutionStep.TRACE))
-                                       type = SlcTypes.SLC_LOG_TRACE;
-                               else if (step.getType().equals(ExecutionStep.DEBUG))
-                                       type = SlcTypes.SLC_LOG_DEBUG;
-                               else if (step.getType().equals(ExecutionStep.INFO))
-                                       type = SlcTypes.SLC_LOG_INFO;
-                               else if (step.getType().equals(ExecutionStep.WARNING))
-                                       type = SlcTypes.SLC_LOG_WARNING;
-                               else if (step.getType().equals(ExecutionStep.ERROR))
-                                       type = SlcTypes.SLC_LOG_ERROR;
-                               else
-                                       // skip
-                                       continue steps;
-
-                               String relPath = SLC_LOG + '/'
-                                               + step.getThread().replace('/', '_') + '/'
-                                               + step.getLocation().replace('.', '/');
-                               String path = node.getPath() + '/' + relPath;
-                               // clean special character
-                               // TODO factorize in JcrUtils
-                               path = path.replace('@', '_');
-
-                               Node location = JcrUtils.mkdirs(node.getSession(), path);
-                               Node logEntry = location.addNode(Long.toString(nextLogLine),
-                                               type);
-                               logEntry.setProperty(SLC_MESSAGE, step.getLog());
-                               Calendar calendar = new GregorianCalendar();
-                               calendar.setTime(step.getTimestamp());
-                               logEntry.setProperty(SLC_TIMESTAMP, calendar);
-
-                               // System.out.println("Logged " + logEntry.getPath());
-
-                               nextLogLine++;
-                       }
-
-                       // last modified properties needs to be manually updated
-                       // see https://issues.apache.org/jira/browse/JCR-2233
-                       JcrUtils.updateLastModified(node);
-
-                       node.getSession().save();
-               } catch (Exception e) {
-                       JcrUtils.discardUnderlyingSessionQuietly(node);
-                       e.printStackTrace();
-               }
-       }
-
-       // public Node getNode() {
-       // return node;
-       // }
-
-       public List<RealizedFlow> getRealizedFlows() {
-               try {
-                       List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();
-                       Node rootRealizedFlowNode = node.getNode(SLC_FLOW);
-                       // we just manage one level for the time being
-                       NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW);
-                       while (nit.hasNext()) {
-                               Node realizedFlowNode = nit.nextNode();
-
-                               if (realizedFlowNode.hasNode(SLC_ADDRESS)) {
-                                       String flowPath = realizedFlowNode.getNode(SLC_ADDRESS)
-                                                       .getProperty(Property.JCR_PATH).getString();
-                                       NameVersion moduleNameVersion = SlcJcrUtils
-                                                       .moduleNameVersion(flowPath);
-                                       ((ProcessThread) Thread.currentThread())
-                                                       .getExecutionModulesManager().start(
-                                                                       moduleNameVersion);
-                               }
-
-                               RealizedFlow realizedFlow = new JcrRealizedFlow(
-                                               realizedFlowNode);
-                               if (realizedFlow != null)
-                                       realizedFlows.add(realizedFlow);
-                       }
-                       return realizedFlows;
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot get realized flows", e);
-               }
-       }
-
-       public String getNodePath() {
-               try {
-                       return node.getPath();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot get process node path for " + node,
-                                       e);
-               }
-       }
-
-       public Repository getRepository() {
-               try {
-                       return node.getSession().getRepository();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot get process JCR repository for "
-                                       + node, e);
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java
deleted file mode 100644 (file)
index bef375a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.argeo.slc.jcr.execution;
-
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.execution.RealizedFlow;
-import org.argeo.slc.runtime.ProcessThread;
-
-/** Where the actual execution takes place */
-public class JcrProcessThread extends ProcessThread implements SlcNames {
-
-       public JcrProcessThread(ThreadGroup processesThreadGroup, ExecutionModulesManager executionModulesManager,
-                       JcrExecutionProcess process) {
-               super(processesThreadGroup, executionModulesManager, process);
-       }
-
-       /** Overridden in order to set progress status on realized flow nodes. */
-       @Override
-       protected void process() throws InterruptedException {
-               Session session = null;
-               if (getProcess() instanceof JcrExecutionProcess)
-                       try {
-                               session = ((JcrExecutionProcess) getProcess()).getRepository().login(NodeConstants.HOME_WORKSPACE);
-
-                               List<RealizedFlow> realizedFlows = getProcess().getRealizedFlows();
-                               for (RealizedFlow realizedFlow : realizedFlows) {
-                                       Node realizedFlowNode = session.getNode(((JcrRealizedFlow) realizedFlow).getPath());
-                                       setFlowStatus(realizedFlowNode, ExecutionProcess.RUNNING);
-
-                                       try {
-                                               //
-                                               // EXECUTE THE FLOW
-                                               //
-                                               execute(realizedFlow, true);
-
-                                               setFlowStatus(realizedFlowNode, ExecutionProcess.COMPLETED);
-                                       } catch (RepositoryException e) {
-                                               throw e;
-                                       } catch (InterruptedException e) {
-                                               setFlowStatus(realizedFlowNode, ExecutionProcess.KILLED);
-                                               throw e;
-                                       } catch (RuntimeException e) {
-                                               setFlowStatus(realizedFlowNode, ExecutionProcess.ERROR);
-                                               throw e;
-                                       }
-                               }
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot process " + getJcrExecutionProcess().getNodePath(), e);
-                       } finally {
-                               JcrUtils.logoutQuietly(session);
-                       }
-               else
-                       super.process();
-       }
-
-       protected void setFlowStatus(Node realizedFlowNode, String status) throws RepositoryException {
-               realizedFlowNode.setProperty(SLC_STATUS, status);
-               realizedFlowNode.getSession().save();
-       }
-
-       protected JcrExecutionProcess getJcrExecutionProcess() {
-               return (JcrExecutionProcess) getProcess();
-       }
-}
diff --git a/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java b/cms/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java
deleted file mode 100644 (file)
index b7444d4..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-package org.argeo.slc.jcr.execution;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.RealizedFlow;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveUtils;
-import org.argeo.slc.runtime.DefaultExecutionSpec;
-
-public class JcrRealizedFlow extends RealizedFlow implements SlcNames {
-       private static final long serialVersionUID = -3709453850260712001L;
-       private String path;
-
-       public JcrRealizedFlow(Node node) {
-               try {
-                       this.path = node.getPath();
-                       loadFromNode(node);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot initialize from " + node, e);
-               }
-       }
-
-       protected void loadFromNode(Node realizedFlowNode) throws RepositoryException {
-               if (realizedFlowNode.hasNode(SLC_ADDRESS)) {
-                       String flowPath = realizedFlowNode.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString();
-                       // TODO: convert to local path if remote
-                       // FIXME start related module
-                       Session agentSession = realizedFlowNode.getSession().getRepository().login();
-                       try {
-                               Node flowNode = agentSession.getNode(flowPath);
-                               String flowName = flowNode.getProperty(SLC_NAME).getString();
-                               String description = null;
-                               if (flowNode.hasProperty(Property.JCR_DESCRIPTION))
-                                       description = flowNode.getProperty(Property.JCR_DESCRIPTION).getString();
-
-                               Node executionModuleNode = flowNode.getSession().getNode(SlcJcrUtils.modulePath(flowPath));
-                               String executionModuleName = executionModuleNode.getProperty(SLC_NAME).getString();
-                               String executionModuleVersion = executionModuleNode.getProperty(SLC_VERSION).getString();
-
-                               RealizedFlow realizedFlow = this;
-                               realizedFlow.setModuleName(executionModuleName);
-                               realizedFlow.setModuleVersion(executionModuleVersion);
-
-                               // retrieve execution spec
-                               DefaultExecutionSpec executionSpec = new DefaultExecutionSpec();
-                               Map<String, ExecutionSpecAttribute> attrs = readExecutionSpecAttributes(realizedFlowNode);
-                               executionSpec.setAttributes(attrs);
-
-                               // set execution spec name
-                               if (flowNode.hasProperty(SlcNames.SLC_SPEC)) {
-                                       Node executionSpecNode = flowNode.getProperty(SLC_SPEC).getNode();
-                                       executionSpec.setName(executionSpecNode.getProperty(SLC_NAME).getString());
-                               }
-
-                               // explicitly retrieve values
-                               Map<String, Object> values = new HashMap<String, Object>();
-                               for (String attrName : attrs.keySet()) {
-                                       ExecutionSpecAttribute attr = attrs.get(attrName);
-                                       Object value = attr.getValue();
-                                       values.put(attrName, value);
-                               }
-
-                               ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(flowName, description, values, executionSpec);
-                               realizedFlow.setFlowDescriptor(efd);
-
-                       } finally {
-                               JcrUtils.logoutQuietly(agentSession);
-                       }
-               } else {
-                       throw new SlcException("Unsupported realized flow " + realizedFlowNode);
-               }
-       }
-
-       protected Map<String, ExecutionSpecAttribute> readExecutionSpecAttributes(Node node) {
-               try {
-                       Map<String, ExecutionSpecAttribute> attrs = new HashMap<String, ExecutionSpecAttribute>();
-                       for (NodeIterator nit = node.getNodes(); nit.hasNext();) {
-                               Node specAttrNode = nit.nextNode();
-                               if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
-                                       String type = specAttrNode.getProperty(SLC_TYPE).getString();
-                                       Object value = null;
-                                       if (specAttrNode.hasProperty(SLC_VALUE)) {
-                                               String valueStr = specAttrNode.getProperty(SLC_VALUE).getString();
-                                               value = PrimitiveUtils.convert(type, valueStr);
-                                       }
-                                       PrimitiveSpecAttribute specAttr = new PrimitiveSpecAttribute(type, value);
-                                       attrs.put(specAttrNode.getName(), specAttr);
-                               } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
-                                       if (!specAttrNode.hasProperty(SLC_VALUE)) {
-                                               continue;
-                                       }
-                                       Integer value = (int) specAttrNode.getProperty(SLC_VALUE).getLong();
-                                       RefSpecAttribute specAttr = new RefSpecAttribute();
-                                       NodeIterator children = specAttrNode.getNodes();
-                                       int index = 0;
-                                       String id = null;
-                                       while (children.hasNext()) {
-                                               Node child = children.nextNode();
-                                               if (index == value)
-                                                       id = child.getName();
-                                               index++;
-                                       }
-                                       specAttr.setValue(id);
-                                       attrs.put(specAttrNode.getName(), specAttr);
-                               }
-                               // throw new SlcException("Unsupported spec attribute "
-                               // + specAttrNode);
-                       }
-                       return attrs;
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot read spec attributes from " + node, e);
-               }
-       }
-
-       public String getPath() {
-               return path;
-       }
-}
diff --git a/cms/org.argeo.slc.launcher/.classpath b/cms/org.argeo.slc.launcher/.classpath
deleted file mode 100644 (file)
index 5609932..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" output="target/classes" path="src"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="output" path="target/classes"/>
-</classpath>
diff --git a/cms/org.argeo.slc.launcher/.gitignore b/cms/org.argeo.slc.launcher/.gitignore
deleted file mode 100644 (file)
index c2bdee8..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/target/
-/.slc/
diff --git a/cms/org.argeo.slc.launcher/.project b/cms/org.argeo.slc.launcher/.project
deleted file mode 100644 (file)
index 7254f6d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.launcher</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.jdt.core.javanature</nature>
-               <nature>org.eclipse.pde.PluginNature</nature>
-       </natures>
-</projectDescription>
diff --git a/cms/org.argeo.slc.launcher/META-INF/.gitignore b/cms/org.argeo.slc.launcher/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.launcher/bnd.bnd b/cms/org.argeo.slc.launcher/bnd.bnd
deleted file mode 100644 (file)
index 8acf4c9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: org.argeo.slc.cli.SlcMain
\ No newline at end of file
diff --git a/cms/org.argeo.slc.launcher/build.properties b/cms/org.argeo.slc.launcher/build.properties
deleted file mode 100644 (file)
index f0cc4f1..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-source.. = src/main/java/,\
-           src/main/resources/
diff --git a/cms/org.argeo.slc.launcher/pom.xml b/cms/org.argeo.slc.launcher/pom.xml
deleted file mode 100644 (file)
index 79c7a74..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.launcher</artifactId>
-       <packaging>jar</packaging>
-       <name>SLC Launcher</name>
-       <build>
-               <plugins>
-<!--                   <plugin> -->
-<!--                           <groupId>org.apache.maven.plugins</groupId> -->
-<!--                           <artifactId>maven-assembly-plugin</artifactId> -->
-<!--                           <configuration> -->
-<!--                                   <descriptors> -->
-<!--                                           <descriptor>assembly/base.xml</descriptor> -->
-<!--                                   </descriptors> -->
-<!--                           </configuration> -->
-<!--                           <executions> -->
-<!--                                   <execution> -->
-<!--                                           <id>assembly-base</id> -->
-<!--                                           <phase>package</phase> -->
-<!--                                           <goals> -->
-<!--                                                   <goal>single</goal> -->
-<!--                                           </goals> -->
-<!--                                   </execution> -->
-<!--                           </executions> -->
-<!--                   </plugin> -->
-<!--                   <plugin> -->
-<!--                           <groupId>org.apache.felix</groupId> -->
-<!--                           <artifactId>maven-bundle-plugin</artifactId> -->
-<!--                           <configuration> -->
-<!--                                   <instructions> -->
-<!--                                           <Main-Class>org.argeo.slc.cli.SlcMain</Main-Class> -->
-<!--                                   </instructions> -->
-<!--                           </configuration> -->
-<!--                   </plugin> -->
-<!--                   <plugin> -->
-<!--                           <artifactId>maven-resources-plugin</artifactId> -->
-<!--                           <executions> -->
-<!--                                   <execution> -->
-<!--                                           <phase>validate</phase> -->
-<!--                                           <goals> -->
-<!--                                                   <goal>copy-resources</goal> -->
-<!--                                           </goals> -->
-<!--                                           <configuration> -->
-<!--                                                   <outputDirectory>${basedir}/target/base</outputDirectory> -->
-<!--                                                   <resources> -->
-<!--                                                           <resource> -->
-<!--                                                                   <directory>base</directory> -->
-<!--                                                                   <filtering>true</filtering> -->
-<!--                                                           </resource> -->
-<!--                                                   </resources> -->
-<!--                                           </configuration> -->
-<!--                                   </execution> -->
-<!--                           </executions> -->
-<!--                   </plugin> -->
-               </plugins>
-       </build>
-       <dependencies>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.osgi.boot</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java b/cms/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java
deleted file mode 100644 (file)
index 8717b50..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-package org.argeo.slc.cli;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceLoader;
-import java.util.UUID;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-
-import org.argeo.osgi.boot.OsgiBoot;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
-
-/** Configures an SLC runtime and runs a process. */
-public class SlcMain implements PrivilegedAction<String> {
-       public final static String NIX = "NIX";
-       public final static String WINDOWS = "WINDOWS";
-       public final static String SOLARIS = "SOLARIS";
-
-       public final static String os;
-       public final static String slcDirName = ".slc";
-       final static File homeDir = new File(System.getProperty("user.home"));
-
-       static {
-               String osName = System.getProperty("os.name");
-               if (osName.startsWith("Win"))
-                       os = WINDOWS;
-               else if (osName.startsWith("Solaris"))
-                       os = SOLARIS;
-               else
-                       os = NIX;
-       }
-
-       private Long timeout = 30 * 1000l;
-       private final String[] args;
-       private final File confDir;
-       private final File dataDir;
-       private final File modulesDir;
-
-       private final List<String> bundlesToStart = new ArrayList<String>();
-
-       public SlcMain(String[] args, File confDir, File dataDir, File modulesDir) {
-               this.args = args;
-               this.confDir = confDir;
-               this.dataDir = dataDir;
-               this.modulesDir = modulesDir;
-
-               bundlesToStart.add("org.eclipse.equinox.cm");
-               bundlesToStart.add("org.argeo.cms");
-               bundlesToStart.add("org.eclipse.gemini.blueprint.extender");
-               bundlesToStart.add("org.argeo.slc.agent");
-               bundlesToStart.add("org.argeo.slc.agent.jcr");
-
-               // bundlesToStart.add("org.springframework.osgi.extender");
-               // bundlesToStart.add("org.argeo.node.repo.jackrabbit");
-               // bundlesToStart.add("org.argeo.security.dao.os");
-               // bundlesToStart.add("org.argeo.slc.node.jackrabbit");
-               // bundlesToStart.add("org.argeo.slc.agent");
-               // bundlesToStart.add("org.argeo.slc.agent.jcr");
-               // if (args.length == 0)
-               // bundlesToStart.add("org.argeo.slc.support.equinox");
-               // bundlesToStart.add("org.argeo.slc.agent.cli");
-       }
-
-       public String run() {
-               long begin = System.currentTimeMillis();
-
-               Framework framework = null;
-               try {
-                       info("## Date : " + new Date());
-                       info("## Data : " + dataDir.getCanonicalPath());
-
-                       // Start Equinox
-                       ServiceLoader<FrameworkFactory> ff = ServiceLoader.load(FrameworkFactory.class);
-                       FrameworkFactory frameworkFactory = ff.iterator().next();
-                       Map<String, String> configuration = new HashMap<String, String>();
-                       configuration.put("osgi.configuration.area", confDir.getCanonicalPath());
-                       configuration.put("osgi.instance.area", dataDir.getCanonicalPath());
-                       // Do clean
-                       configuration.put("osgi.clean", "true");
-                       if (args.length == 0) {
-                               configuration.put("osgi.console", "");
-                       }
-
-                       // Spring configs currently require System properties
-                       System.getProperties().putAll(configuration);
-
-                       framework = frameworkFactory.newFramework(configuration);
-                       framework.start();
-                       BundleContext bundleContext = framework.getBundleContext();
-
-                       // OSGi bootstrap
-                       OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
-
-                       // working copy modules
-                       if (modulesDir.exists())
-                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(modulesDir.getCanonicalPath() + ";in=*;ex=.gitignore"));
-
-                       // system modules
-                       if (System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES) != null)
-                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES)));
-                       else
-                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty("user.home") + "/.slc/modules/;in=**"));
-
-                       // Start runtime
-                       osgiBoot.startBundles(bundlesToStart);
-
-                       // Find SLC Agent
-                       ServiceReference sr = null;
-                       while (sr == null) {
-                               sr = bundleContext.getServiceReference("org.argeo.slc.execution.SlcAgentCli");
-                               if (System.currentTimeMillis() - begin > timeout)
-                                       throw new RuntimeException("Cannot find SLC agent CLI");
-                               Thread.sleep(100);
-                       }
-                       Object agentCli = bundleContext.getService(sr);
-
-                       // Initialization completed
-                       long duration = System.currentTimeMillis() - begin;
-                       info("[[ Initialized in " + (duration / 1000) + "s " + (duration % 1000) + "ms ]]");
-
-                       if (args.length == 0)
-                               return null;// console mode
-
-                       // Subject.doAs(Subject.getSubject(AccessController.getContext()),
-                       // new AgentCliCall(agentCli));
-                       Class<?>[] parameterTypes = { String[].class };
-                       Method method = agentCli.getClass().getMethod("process", parameterTypes);
-                       Object[] methodArgs = { args };
-                       Object ret = method.invoke(agentCli, methodArgs);
-
-                       // Shutdown OSGi runtime
-                       framework.stop();
-                       framework.waitForStop(60 * 1000);
-
-                       return ret.toString();
-               } catch (Exception e) {
-                       // Shutdown OSGi runtime
-                       if (framework != null)
-                               try {
-                                       framework.stop();
-                                       framework.waitForStop(15 * 1000);
-                               } catch (Exception silent) {
-                               }
-                       throw new RuntimeException("Cannot run SLC command line", e);
-               } finally {
-
-               }
-       }
-
-       public static void main(String[] args) {
-               try {
-                       // Prepare directories
-                       File executionDir = new File(System.getProperty("user.dir"));
-                       File slcDir;
-                       Boolean isTransient = false;
-                       if (isTransient) {
-                               File tempDir = new File(System.getProperty("java.io.tmpdir") + "/" + System.getProperty("user.name"));
-                               slcDir = new File(tempDir, "slc-" + UUID.randomUUID().toString());
-                               slcDir.mkdirs();
-                               System.setProperty("argeo.node.repo.configuration", "osgibundle:repository-memory.xml");
-                       } else {
-                               slcDir = findSlcDir(executionDir);
-                               if (slcDir == null) {
-                                       slcDir = new File(executionDir, slcDirName);
-                                       slcDir.mkdirs();
-                                       info("## Creating an SLC node at " + slcDir + " ...");
-                               }
-                       }
-
-                       File dataDir = new File(slcDir, "data");
-                       if (!dataDir.exists())
-                               dataDir.mkdirs();
-
-                       File confDir = new File(slcDir, "conf");
-                       if (!confDir.exists())
-                               confDir.mkdirs();
-
-                       File modulesDir = new File(slcDir, "modules");
-
-                       // JAAS
-                       // File jaasFile = new File(confDir, "jaas.config");
-                       // if (!jaasFile.exists())
-                       // copyResource("/org/argeo/slc/cli/jaas.config", jaasFile);
-                       // System.setProperty("java.security.auth.login.config",
-                       // jaasFile.getCanonicalPath());
-
-                       // log4j
-                       File log4jFile = new File(confDir, "log4j.properties");
-                       if (!log4jFile.exists())
-                               copyResource("/org/argeo/slc/cli/log4j.properties", log4jFile);
-                       System.setProperty("log4j.configuration", "file://" + log4jFile.getCanonicalPath());
-                       // Run as a privileged action
-                       // LoginContext lc = new LoginContext(os);
-                       // lc.login();
-                       //
-                       // Subject subject =
-                       // Subject.getSubject(AccessController.getContext());
-                       // Subject.doAs(subject, new SlcMain(args, confDir, dataDir,
-                       // modulesDir));
-                       SlcMain slcMain = new SlcMain(args, confDir, dataDir, modulesDir);
-                       slcMain.run();
-                       if (args.length != 0)
-                               System.exit(0);
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       System.exit(1);
-               }
-       }
-
-       /**
-        * Recursively look in parent directories for a directory named
-        * {@link #slcDirName}
-        */
-       protected static File findSlcDir(File currentDir) {
-               File slcDir = new File(currentDir, slcDirName);
-               // covers the use case of running from the home directory
-               if (slcDir.exists() && slcDir.isDirectory())
-                       return slcDir;
-               File parentDir = currentDir.getParentFile();
-               if (parentDir == null)
-                       return null;
-               try {
-                       // ~/.slc reserved for agent
-                       if (parentDir.getCanonicalPath().equals(homeDir.getCanonicalPath()))
-                               return null;
-               } catch (IOException e) {
-                       throw new RuntimeException("Cannot check home directory", e);
-               }
-               return findSlcDir(parentDir);
-       }
-
-       protected static void copyResource(String resource, File targetFile) {
-               InputStream input = null;
-               FileOutputStream output = null;
-               try {
-                       input = SlcMain.class.getResourceAsStream(resource);
-                       output = new FileOutputStream(targetFile);
-                       byte[] buf = new byte[8192];
-                       while (true) {
-                               int length = input.read(buf);
-                               if (length < 0)
-                                       break;
-                               output.write(buf, 0, length);
-                       }
-               } catch (Exception e) {
-                       throw new RuntimeException("Cannot write " + resource + " file to " + targetFile, e);
-               } finally {
-                       try {
-                               input.close();
-                       } catch (Exception ignore) {
-                       }
-                       try {
-                               output.close();
-                       } catch (Exception ignore) {
-                       }
-               }
-
-       }
-
-       protected static void info(Object msg) {
-               System.out.println(msg);
-       }
-
-       protected static void err(Object msg) {
-               System.err.println(msg);
-       }
-
-       protected static void debug(Object msg) {
-               System.out.println(msg);
-       }
-
-}
-
-// private String bundlesToInstall = System.getProperty("user.home")
-// +
-// "/dev/src/slc/dep/org.argeo.slc.dep.minimal/target/dependency;in=*.jar,"
-// + System.getProperty("user.home")
-// + "/dev/src/slc/demo/modules;in=*;ex=pom.xml;ex=.svn";
-
-// ServiceTracker agentTracker = new ServiceTracker(bundleContext,
-// "org.argeo.slc.execution.SlcAgentCli", null);
-// agentTracker.open();
-// final Object agentCli = agentTracker.waitForService(30 * 1000);
-// if (agentCli == null)
-// throw new RuntimeException("Cannot find SLC agent CLI");
-
-// protected class AgentCliCall implements PrivilegedAction<String> {
-// private final Object agentCli;
-//
-// public AgentCliCall(Object agentCli) {
-// super();
-// this.agentCli = agentCli;
-// }
-//
-// public String run() {
-// try {
-// Class<?>[] parameterTypes = { String[].class };
-// Method method = agentCli.getClass().getMethod("process",
-// parameterTypes);
-// Object[] methodArgs = { args };
-// Object ret = method.invoke(agentCli, methodArgs);
-// return ret.toString();
-// } catch (Exception e) {
-// throw new RuntimeException("Cannot run "
-// + Arrays.toString(args) + " on " + agentCli, e);
-// }
-// }
-//
-// }
diff --git a/cms/org.argeo.slc.launcher/src/org/argeo/slc/cli/jaas.config b/cms/org.argeo.slc.launcher/src/org/argeo/slc/cli/jaas.config
deleted file mode 100644 (file)
index 2fc1198..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-NIX {
-   com.sun.security.auth.module.UnixLoginModule required;
-};
-
-WINDOWS {
-   com.sun.security.auth.module.NTLoginModule required;
-};
diff --git a/cms/org.argeo.slc.launcher/src/org/argeo/slc/cli/log4j.properties b/cms/org.argeo.slc.launcher/src/org/argeo/slc/cli/log4j.properties
deleted file mode 100644 (file)
index 6770d0a..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-log4j.rootLogger=WARN, console
-#log4j.rootLogger=DEBUG, development
-
-## Levels
-log4j.logger.org.argeo=INFO
-
-log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR
-log4j.logger.org.apache.jackrabbit.core.config.ConfigurationErrorHandler=ERROR
-log4j.logger.org.apache.jackrabbit.core.util.db.DbUtility=FATAL
-
-## Appenders
-# default appender
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %m%n
-
-# development appender
-log4j.appender.development=org.apache.log4j.ConsoleAppender
-log4j.appender.development.layout=org.apache.log4j.PatternLayout
-log4j.appender.development.layout.ConversionPattern=%d{HH:mm:ss,SSS} %5p %m [%16.16t] %c%n
diff --git a/cms/org.argeo.slc.repo/.classpath b/cms/org.argeo.slc.repo/.classpath
deleted file mode 100644 (file)
index 70b08e8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" output="target/classes" path="src"/>
-       <classpathentry kind="src" path="ext/test"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/cms/org.argeo.slc.repo/.gitignore b/cms/org.argeo.slc.repo/.gitignore
deleted file mode 100644 (file)
index 0f63015..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/target/
-/bin/
diff --git a/cms/org.argeo.slc.repo/.project b/cms/org.argeo.slc.repo/.project
deleted file mode 100644 (file)
index 26f4658..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.repo</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.jdt.core.javanature</nature>
-               <nature>org.eclipse.pde.PluginNature</nature>
-       </natures>
-</projectDescription>
diff --git a/cms/org.argeo.slc.repo/META-INF/.gitignore b/cms/org.argeo.slc.repo/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.repo/bnd.bnd b/cms/org.argeo.slc.repo/bnd.bnd
deleted file mode 100644 (file)
index 07af6b4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-Import-Package: org.w3c.dom.*,\
-org.xml.sax.*,\
-javax.xml.transform.*,\
-javax.xml.parsers.*,\
-javax.jcr.nodetype,\
-org.eclipse.aether.*;version=1.0.1,\
-org.osgi.*;version=0.0.0,\
-*
-
-Private-Package: org.eclipse.aether.*
-
-Require-Capability: cms.datamodel; filter:="(name=slc)"
-Provide-Capability: cms.datamodel; name=java,\
- cms.datamodel; name=dist,\
- cms.datamodel; name=docs,\
- cms.datamodel; name=rpm
diff --git a/cms/org.argeo.slc.repo/build.properties b/cms/org.argeo.slc.repo/build.properties
deleted file mode 100644 (file)
index 31b02d2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-additional.bundles = org.junit
diff --git a/cms/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/AetherUtilsTest.java b/cms/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/AetherUtilsTest.java
deleted file mode 100644 (file)
index 21563fe..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.argeo.slc.repo.internal;
-
-
-import junit.framework.TestCase;
-
-import org.argeo.slc.repo.maven.AetherUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-public class AetherUtilsTest extends TestCase {
-       public void testConvertPathToArtifact() throws Exception {
-               checkPathConversion("my.group.id:my-artifactId:pom:1.2.3",
-                               "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3.pom");
-               checkPathConversion("my.group.id:my-artifactId:pom:1.2.3-SNAPSHOT",
-                               "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT.pom");
-               checkPathConversion("my.group.id:my-artifactId:pom:myClassifier:1.2.3",
-                               "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3-myClassifier.pom");
-               checkPathConversion(
-                               "my.group.id:my-artifactId:pom:myClassifier:1.2.3-SNAPSHOT",
-                               "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT-myClassifier.pom");
-               checkPathConversion(
-                               "my.group.id:my-artifactId:pom:myClassifier:20110828.223836-2",
-                               "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-20110828.223836-2-myClassifier.pom");
-       }
-
-       public void testConvertPathToArtifactRealLife() throws Exception {
-               checkPathConversion(
-                               "org.apache.maven.plugins:maven-antrun-plugin:pom:1.1",
-                               "org/apache/maven/plugins/maven-antrun-plugin/1.1/maven-antrun-plugin-1.1.pom");
-               checkPathConversion(
-                               "org.apache.maven.plugins:maven-plugin-parent:pom:2.0.1",
-                               "org/apache/maven/plugins/maven-plugin-parent/2.0.1/maven-plugin-parent-2.0.1.pom");
-               checkPathConversion(
-                               "org.apache.avalon.framework:avalon-framework-impl:pom:4.3.1",
-                               "org/apache/avalon/framework/avalon-framework-impl/4.3.1/avalon-framework-impl-4.3.1.pom");
-               checkPathConversion(
-                               "org.apache.maven.shared:maven-dependency-tree:pom:1.2",
-                               "org/apache/maven/shared/maven-dependency-tree/1.2/maven-dependency-tree-1.2.pom");
-               checkPathConversion(
-                               "org.argeo.maven.plugins:maven-argeo-osgi-plugin:pom:1.0.33",
-                               "org/argeo/maven/plugins/maven-argeo-osgi-plugin/1.0.33/maven-argeo-osgi-plugin-1.0.33.pom");
-               checkPathConversion(
-                               "org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1",
-                               "org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom");
-       }
-
-       protected void checkPathConversion(String expectedArtifact, String path) {
-               Artifact artifact = AetherUtils.convertPathToArtifact(path, null);
-               if (expectedArtifact == null)
-                       assertNull(artifact);
-               else
-                       assertEquals(new DefaultArtifact(expectedArtifact), artifact);
-       }
-}
diff --git a/cms/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/pom.xml b/cms/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/pom.xml
deleted file mode 100644 (file)
index b12659b..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.commons</groupId>
-               <artifactId>argeo-commons</artifactId>
-               <version>2.1.70-SNAPSHOT</version>
-       </parent>
-       <groupId>org.argeo.slc</groupId>
-       <artifactId>argeo-slc</artifactId>
-       <packaging>pom</packaging>
-       <name>Argeo SLC</name>
-       <version>2.1.10-SNAPSHOT</version>
-       <properties>
-               <developmentCycle.slc>2.1</developmentCycle.slc>
-               <developmentCycle.startDate>2015-02-12</developmentCycle.startDate>
-               <version.argeo-rcp>2.1.15</version.argeo-rcp>
-               <version.slc>2.1.10-SNAPSHOT</version.slc>
-               <version.equinox>3.11.1.v20160708-1632</version.equinox>
-               <!-- Embedded Maven -->
-               <version.maven>3.2.5</version.maven>
-       </properties>
-       <modules>
-               <!-- Runtime -->
-               <module>org.argeo.slc.api</module>
-               <module>org.argeo.slc.core</module>
-               <module>org.argeo.slc.unit</module>
-               <module>org.argeo.slc.support</module>
-               <module>org.argeo.slc.support.maven</module>
-               <module>org.argeo.slc.repo</module>
-               <module>org.argeo.slc.factory</module>
-               <module>org.argeo.slc.launcher</module>
-
-               <!-- Modules -->
-               <module>org.argeo.slc.agent</module>
-               <module>org.argeo.slc.agent.jcr</module>
-               <module>org.argeo.slc.server.repo</module>
-
-               <!-- UI -->
-               <module>org.argeo.slc.client.ui</module>
-               <module>org.argeo.slc.client.ui.dist</module>
-               <module>org.argeo.slc.client.rap</module>
-               <!-- <module>org.argeo.slc.client.rcp</module> -->
-
-               <module>lib</module>
-               <module>dep</module>
-               <module>dist</module>
-               <module>demo</module>
-       </modules>
-       <url>http://projects.argeo.org/slc/</url>
-       <scm>
-               <connection>scm:git:http://git.argeo.org/apache2/argeo-slc.git</connection>
-               <url>http://git.argeo.org/?p=apache2/argeo-slc.git;a=summary</url>
-               <developerConnection>scm:git:https://code.argeo.org/git/apache2/argeo-slc.git</developerConnection>
-               <tag>HEAD</tag>
-       </scm>
-       <inceptionYear>2007</inceptionYear>
-       <licenses>
-               <license>
-                       <name>Apache 2</name>
-                       <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
-                       <distribution>repo</distribution>
-                       <comments><![CDATA[
-SLC (Software Life Cycle) framework
-                          
-Copyright (C) 2007-2012 Argeo GmbH
-
-Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-]]>
-                       </comments>
-               </license>
-       </licenses>
-       <developers>
-               <developer>
-                       <id>mbaudier</id>
-                       <name>Mathieu Baudier</name>
-                       <email><![CDATA[http://mailhide.recaptcha.net/d?k=01EM7GpnvY3k8woQ2tnnZLUA==&c=crsNpHjhOBDPswHG6HD_gXaqymhC69wmBf7wlagcSHw=]]></email>
-                       <organization>Argeo</organization>
-                       <organizationUrl>http://www.argeo.org</organizationUrl>
-                       <roles>
-                               <role>architect</role>
-                               <role>developer</role>
-                               <role>QA</role>
-                       </roles>
-               </developer>
-               <developer>
-                       <id>ocapillo</id>
-                       <name>Olivier Capillon</name>
-                       <email><![CDATA[http://mailhide.recaptcha.net/d?k=01EM7GpnvY3k8woQ2tnnZLUA==&c=BYw8i94WiejnvegUKJoCZQQr0h-mYlKCNKZVe_3WPIA=]]></email>
-                       <organization>Argeo</organization>
-                       <organizationUrl>http://www.argeo.org</organizationUrl>
-                       <roles>
-                               <role>developer</role>
-                       </roles>
-               </developer>
-               <developer>
-                       <id>bsinou</id>
-                       <name>Bruno Sinou</name>
-                       <email><![CDATA[http://www.google.com/recaptcha/mailhide/d?k=01SZoYvDnJzcw0KOR7M7u6Qg==&c=SVgEjXA_Uu9ZrNzLES92w1ght6puLFiVpoNUddCfSU8=]]></email>
-                       <organization>Argeo</organization>
-                       <organizationUrl>http://www.argeo.org</organizationUrl>
-                       <roles>
-                               <role>developer</role>
-                       </roles>
-               </developer>
-       </developers>
-       <build>
-               <plugins>
-                       <plugin>
-                               <artifactId>maven-site-plugin</artifactId>
-                               <inherited>false</inherited>
-                               <configuration>
-                                       <skip>false</skip>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <artifactId>maven-javadoc-plugin</artifactId>
-                               <configuration>
-                                       <skip>true</skip>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
-       <repositories>
-               <repository>
-                       <id>argeo</id>
-                       <url>http://forge.argeo.org/data/java/argeo-2.1/</url>
-                       <releases>
-                               <enabled>true</enabled>
-                               <updatePolicy>daily</updatePolicy>
-                               <checksumPolicy>warn</checksumPolicy>
-                       </releases>
-               </repository>
-               <repository>
-                       <id>argeo-rcp</id>
-                       <url>http://forge.argeo.org/data/java/argeo-rcp-2.1</url>
-                       <releases>
-                               <enabled>true</enabled>
-                               <updatePolicy>daily</updatePolicy>
-                               <checksumPolicy>warn</checksumPolicy>
-                       </releases>
-               </repository>
-
-               <!-- Disable Maven default repository -->
-               <repository>
-                       <id>central</id>
-                       <url>http://repo1.maven.org/maven2</url>
-                       <releases>
-                               <enabled>false</enabled>
-                       </releases>
-                       <snapshots>
-                               <enabled>false</enabled>
-                       </snapshots>
-               </repository>
-       </repositories>
-       <profiles>
-               <profile>
-                       <id>localrepo</id>
-                       <repositories>
-                               <repository>
-                                       <id>argeo-tp</id>
-                                       <url>http://localhost:7070/data/java/argeo-${developmentCycle.argeo-commons}</url>
-                                       <releases>
-                                               <enabled>true</enabled>
-                                               <updatePolicy>daily</updatePolicy>
-                                               <checksumPolicy>warn</checksumPolicy>
-                                       </releases>
-                               </repository>
-                               <!-- <repository> -->
-                               <!-- <id>argeo-tp-extras</id> -->
-                               <!-- <url>http://localhost:7080/data/java/argeo-tp-extras-2.1</url> -->
-                               <!-- <releases> -->
-                               <!-- <enabled>true</enabled> -->
-                               <!-- <updatePolicy>daily</updatePolicy> -->
-                               <!-- <checksumPolicy>warn</checksumPolicy> -->
-                               <!-- </releases> -->
-                               <!-- </repository> -->
-                               <repository>
-                                       <id>argeo-commons</id>
-                                       <url>http://localhost:7070/data/java/argeo-${developmentCycle.argeo-commons}</url>
-                                       <releases>
-                                               <enabled>true</enabled>
-                                               <updatePolicy>daily</updatePolicy>
-                                               <checksumPolicy>warn</checksumPolicy>
-                                       </releases>
-                               </repository>
-                       </repositories>
-                       <distributionManagement>
-                               <repository>
-                                       <id>staging</id>
-                                       <url>dav:http://localhost:7070/data/java/argeo-slc-${developmentCycle.slc}</url>
-                               </repository>
-                               <site>
-                                       <id>staging</id>
-                                       <url>dav:http://localhost:7070/data/docs/argeo-slc-${developmentCycle.slc}</url>
-                               </site>
-                       </distributionManagement>
-               </profile>
-       </profiles>
-</project>
diff --git a/cms/org.argeo.slc.repo/pom.xml b/cms/org.argeo.slc.repo/pom.xml
deleted file mode 100644 (file)
index d866458..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.repo</artifactId>
-       <name>SLC Repo</name>
-       <dependencies>
-               <!-- SLC API -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.api</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Commons -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.jcr</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.cms</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-
-               <!-- BND -->
-               <dependency>
-                       <groupId>org.argeo.tp.sdk</groupId>
-                       <artifactId>biz.aQute.bndlib</artifactId>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java
deleted file mode 100644 (file)
index 4b8878a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.argeo.slc.repo;
-
-import org.argeo.slc.CategoryNameVersion;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.build.ModularDistribution;
-
-/** Aether compatible OSGi distribution */
-public interface ArgeoOsgiDistribution extends Distribution,
-               CategoryNameVersion, ModularDistribution {
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java
deleted file mode 100644 (file)
index bc496f1..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.argeo.slc.repo;
-
-import org.argeo.slc.CategoryNameVersion;
-import org.argeo.slc.build.Distribution;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-/** A {@link Distribution} based on an Aether {@link Artifact} */
-public class ArtifactDistribution implements Distribution,
-               CategoryNameVersion {
-       private final Artifact artifact;
-
-       public ArtifactDistribution(Artifact artifact) {
-               this.artifact = artifact;
-       }
-
-       public ArtifactDistribution(String coords) {
-               this(new DefaultArtifact(coords));
-       }
-
-       /** Aether coordinates of the underlying artifact. */
-       public String getDistributionId() {
-               return artifact.toString();
-       }
-
-       public Artifact getArtifact() {
-               return artifact;
-       }
-
-       public String getName() {
-               return getArtifact().getArtifactId();
-       }
-
-       public String getVersion() {
-               return getArtifact().getVersion();
-       }
-
-       public String getCategory() {
-               return getArtifact().getGroupId();
-       }
-
-       @Override
-       public int hashCode() {
-               return artifact.hashCode();
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               if (obj instanceof CategoryNameVersion) {
-                       CategoryNameVersion cnv = (CategoryNameVersion) obj;
-                       return getCategory().equals(cnv.getCategory())
-                                       && getName().equals(cnv.getName())
-                                       && getVersion().equals(cnv.getVersion());
-               } else
-                       return artifact.equals(obj);
-       }
-
-       @Override
-       public String toString() {
-               return getDistributionId();
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactIndexer.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactIndexer.java
deleted file mode 100644 (file)
index 037a7be..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-package org.argeo.slc.repo;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.maven.AetherUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.osgi.framework.Constants;
-
-/**
- * Add {@link Artifact} properties to a {@link Node}. Does nothing if the node
- * name doesn't start with the artifact id (in order to skip Maven metadata XML
- * files and other non artifact files).
- */
-public class ArtifactIndexer implements NodeIndexer, SlcNames {
-       private Log log = LogFactory.getLog(ArtifactIndexer.class);
-       private Boolean force = false;
-
-       public Boolean support(String path) {
-               String relativePath = getRelativePath(path);
-               if (relativePath == null)
-                       return false;
-               Artifact artifact = null;
-               try {
-                       artifact = AetherUtils.convertPathToArtifact(relativePath, null);
-               } catch (Exception e) {
-                       if (log.isTraceEnabled())
-                               log.trace("Malformed path " + path + ", skipping silently", e);
-               }
-               return artifact != null;
-       }
-
-       public void index(Node fileNode) {
-               Artifact artifact = null;
-               try {
-                       if (!support(fileNode.getPath()))
-                               return;
-
-                       // Already indexed
-                       if (!force && fileNode.isNodeType(SlcTypes.SLC_ARTIFACT))
-                               return;
-
-                       if (!fileNode.isNodeType(NodeType.NT_FILE))
-                               return;
-
-                       String relativePath = getRelativePath(fileNode.getPath());
-                       if (relativePath == null)
-                               return;
-                       artifact = AetherUtils.convertPathToArtifact(relativePath, null);
-                       // support() guarantees that artifact won't be null, no NPE check
-                       fileNode.addMixin(SlcTypes.SLC_ARTIFACT);
-                       fileNode.setProperty(SlcNames.SLC_ARTIFACT_ID,
-                                       artifact.getArtifactId());
-                       fileNode.setProperty(SlcNames.SLC_GROUP_ID, artifact.getGroupId());
-                       fileNode.setProperty(SlcNames.SLC_ARTIFACT_VERSION,
-                                       artifact.getVersion());
-                       fileNode.setProperty(SlcNames.SLC_ARTIFACT_EXTENSION,
-                                       artifact.getExtension());
-                       // can be null but ok for JCR API
-                       fileNode.setProperty(SlcNames.SLC_ARTIFACT_CLASSIFIER,
-                                       artifact.getClassifier());
-                       JcrUtils.updateLastModified(fileNode);
-
-                       // make sure there are checksums
-                       String shaNodeName = fileNode.getName() + ".sha1";
-                       if (!fileNode.getParent().hasNode(shaNodeName)) {
-                               String sha = JcrUtils.checksumFile(fileNode, "SHA-1");
-                               JcrUtils.copyBytesAsFile(fileNode.getParent(), shaNodeName,
-                                               sha.getBytes());
-                       }
-                       String md5NodeName = fileNode.getName() + ".md5";
-                       if (!fileNode.getParent().hasNode(md5NodeName)) {
-                               String md5 = JcrUtils.checksumFile(fileNode, "MD5");
-                               JcrUtils.copyBytesAsFile(fileNode.getParent(), md5NodeName,
-                                               md5.getBytes());
-                       }
-
-                       // Create a default pom if none already exist
-                       String fileNodeName = fileNode.getName();
-                       String pomName = null;
-                       if (fileNodeName.endsWith(".jar"))
-                               pomName = fileNodeName.substring(0, fileNodeName.length()
-                                               - ".jar".length())
-                                               + ".pom";
-
-                       if (pomName != null && !fileNode.getParent().hasNode(pomName)) {
-                               String pom = generatePomForBundle(fileNode);
-                               Node pomNode = JcrUtils.copyBytesAsFile(fileNode.getParent(),
-                                               pomName, pom.getBytes());
-                               // corresponding check sums
-                               String sha = JcrUtils.checksumFile(pomNode, "SHA-1");
-                               JcrUtils.copyBytesAsFile(fileNode.getParent(), pomName
-                                               + ".sha1", sha.getBytes());
-                               String md5 = JcrUtils.checksumFile(fileNode, "MD5");
-                               JcrUtils.copyBytesAsFile(fileNode.getParent(),
-                                               pomName + ".md5", md5.getBytes());
-                       }
-
-                       // set higher levels
-                       Node artifactVersionBase = fileNode.getParent();
-                       if (!artifactVersionBase
-                                       .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
-                               artifactVersionBase
-                                               .addMixin(SlcTypes.SLC_ARTIFACT_VERSION_BASE);
-                               artifactVersionBase.setProperty(SlcNames.SLC_ARTIFACT_VERSION,
-                                               artifact.getBaseVersion());
-                               artifactVersionBase.setProperty(SlcNames.SLC_ARTIFACT_ID,
-                                               artifact.getArtifactId());
-                               artifactVersionBase.setProperty(SlcNames.SLC_GROUP_ID,
-                                               artifact.getGroupId());
-                       }
-                       JcrUtils.updateLastModified(artifactVersionBase);
-
-                       // pom
-                       if (artifact.getExtension().equals("pom")) {
-                               // TODO read to make it a distribution
-                       }
-
-                       Node artifactBase = artifactVersionBase.getParent();
-                       if (!artifactBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
-                               artifactBase.addMixin(SlcTypes.SLC_ARTIFACT_BASE);
-                               artifactBase.setProperty(SlcNames.SLC_ARTIFACT_ID,
-                                               artifact.getArtifactId());
-                               artifactBase.setProperty(SlcNames.SLC_GROUP_ID,
-                                               artifact.getGroupId());
-                       }
-                       JcrUtils.updateLastModified(artifactBase);
-
-                       Node groupBase = artifactBase.getParent();
-                       if (!groupBase.isNodeType(SlcTypes.SLC_GROUP_BASE)) {
-                               // if (groupBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
-                               // log.warn("Group base " + groupBase.getPath()
-                               // + " is also artifact base");
-                               // }
-                               groupBase.addMixin(SlcTypes.SLC_GROUP_BASE);
-                               groupBase.setProperty(SlcNames.SLC_GROUP_BASE_ID,
-                                               artifact.getGroupId());
-                       }
-                       JcrUtils.updateLastModifiedAndParents(groupBase,
-                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH);
-
-                       if (log.isTraceEnabled())
-                               log.trace("Indexed artifact " + artifact + " on " + fileNode);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot index artifact " + artifact
-                                       + " metadata on node " + fileNode, e);
-               }
-       }
-
-       private String getRelativePath(String nodePath) {
-               String basePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
-               if (!nodePath.startsWith(basePath))
-                       return null;
-               String relativePath = nodePath.substring(basePath.length());
-               return relativePath;
-       }
-
-       public void setForce(Boolean force) {
-               this.force = force;
-       }
-
-       private String generatePomForBundle(Node n) throws RepositoryException {
-               StringBuffer p = new StringBuffer();
-               p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-               p.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
-               p.append("<modelVersion>4.0.0</modelVersion>");
-
-               // Categorized name version
-               p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
-                               .append("</groupId>\n");
-               p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
-                               .append("</artifactId>\n");
-               p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
-                               .append("</version>\n");
-               // TODO make it more generic
-               p.append("<packaging>jar</packaging>\n");
-               if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
-                       p.append("<name>")
-                                       .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
-                                       .append("</name>\n");
-               if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
-                       p.append("<description>")
-                                       .append(JcrUtils
-                                                       .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
-                                       .append("</description>\n");
-
-               // Dependencies in case of a distribution
-               if (n.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION)) {
-                       p.append(getDependenciesSnippet(n.getNode(SlcNames.SLC_MODULES)
-                                       .getNodes()));
-                       p.append(getDependencyManagementSnippet(n.getNode(
-                                       SlcNames.SLC_MODULES).getNodes()));
-               }
-               p.append("</project>\n");
-               return p.toString();
-       }
-
-       private String getDependenciesSnippet(NodeIterator nit)
-                       throws RepositoryException {
-               StringBuilder b = new StringBuilder();
-               b.append("<dependencies>\n");
-               while (nit.hasNext()) {
-                       Node currModule = nit.nextNode();
-                       if (currModule.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
-                               b.append(getDependencySnippet(
-                                               currModule.getProperty(SlcNames.SLC_CATEGORY)
-                                                               .getString(),
-                                               currModule.getProperty(SlcNames.SLC_NAME).getString(),
-                                               null));
-                       }
-               }
-               b.append("</dependencies>\n");
-               return b.toString();
-       }
-
-       private String getDependencyManagementSnippet(NodeIterator nit)
-                       throws RepositoryException {
-               StringBuilder b = new StringBuilder();
-               b.append("<dependencyManagement>\n");
-               b.append("<dependencies>\n");
-               while (nit.hasNext()) {
-                       Node currModule = nit.nextNode();
-                       if (currModule.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
-                               b.append(getDependencySnippet(
-                                               currModule.getProperty(SlcNames.SLC_CATEGORY)
-                                                               .getString(),
-                                               currModule.getProperty(SlcNames.SLC_NAME).getString(),
-                                               currModule.getProperty(SlcNames.SLC_VERSION)
-                                                               .getString()));
-                       }
-               }
-               b.append("</dependencies>\n");
-               b.append("</dependencyManagement>\n");
-               return b.toString();
-       }
-
-       private String getDependencySnippet(String category, String name,
-                       String version) {
-               StringBuilder b = new StringBuilder();
-               b.append("<dependency>\n");
-               b.append("\t<groupId>").append(category).append("</groupId>\n");
-               b.append("\t<artifactId>").append(name).append("</artifactId>\n");
-               if (version != null)
-                       b.append("\t<version>").append(version).append("</version>\n");
-               b.append("</dependency>\n");
-               return b.toString();
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/FreeLicense.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/FreeLicense.java
deleted file mode 100644 (file)
index 1b83666..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-package org.argeo.slc.repo;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.build.License;
-
-/** A free software license */
-public abstract class FreeLicense implements License {
-       final static String RESOURCES = "/org/argeo/slc/repo/license/";
-
-       /** GNU */
-       public final static FreeLicense GPL_v3 = new FreeLicense(
-                       "GNU General Public License, version 3.0",
-                       "http://www.gnu.org/licenses/gpl-3.0.txt",
-                       "http://www.gnu.org/licenses/", RESOURCES + "gpl-3.0.txt") {
-       };
-
-       public final static FreeLicense GPL_v2 = new FreeLicense(
-                       "GNU General Public License, version 2.0",
-                       "http://www.gnu.org/licenses/gpl-2.0.txt",
-                       "http://www.gnu.org/licenses/", RESOURCES + "gpl-2.0.txt") {
-       };
-       public final static FreeLicense GPL = GPL_v3;
-
-       public final static FreeLicense LGPL_v3 = new FreeLicense(
-                       "GNU Lesser General Public License, version 3.0",
-                       "http://www.gnu.org/licenses/lgpl-3.0.txt",
-                       "http://www.gnu.org/licenses/", RESOURCES + "lgpl-3.0.txt") {
-       };
-
-       public final static FreeLicense LGPL_v2 = new FreeLicense(
-                       "GNU Lesser General Public License, version 2.1",
-                       "http://www.gnu.org/licenses/lgpl-2.1.txt",
-                       "http://www.gnu.org/licenses/", RESOURCES + "lgpl-2.1.txt") {
-       };
-       public final static FreeLicense LGPL = LGPL_v3;
-
-       /** Apache */
-       public final static FreeLicense APACHE_v2 = new FreeLicense(
-                       "Apache License, Version 2.0",
-                       "http://www.apache.org/licenses/LICENSE-2.0.txt",
-                       "http://www.apache.org/licenses/", RESOURCES + "apache-2.0.txt") {
-       };
-       public final static FreeLicense APACHE = APACHE_v2;
-
-       /** Eclipse */
-       public final static FreeLicense EPL_v1 = new FreeLicense(
-                       "Eclipse Public License, Version 1.0",
-                       "http://www.eclipse.org/legal/epl-v10.html",
-                       "http://www.eclipse.org/legal/eplfaq.php", RESOURCES
-                                       + "epl-1.0.txt") {
-       };
-       public final static FreeLicense EPL = EPL_v1;
-
-       /** Miscellaneous */
-       public final static FreeLicense MIT = new FreeLicense("The MIT License",
-                       "http://opensource.org/licenses/MIT", null, RESOURCES + "mit.txt") {
-       };
-
-       public final static FreeLicense BSD_NEW = new FreeLicense(
-                       "The BSD 3-Clause License",
-                       "http://opensource.org/licenses/BSD-3-Clause", null, RESOURCES
-                                       + "bsd-3-clause.txt") {
-       };
-
-       public final static FreeLicense BSD = BSD_NEW;
-
-       public final static FreeLicense CDDL_v1 = new FreeLicense(
-                       "Common Development and Distribution License",
-                       "http://opensource.org/licenses/CDDL-1.0", null, RESOURCES
-                                       + "cddl-1.0.txt") {
-       };
-       public final static FreeLicense CDDL = CDDL_v1;
-
-       /** Public domain corner case */
-       public final static License PUBLIC_DOMAIN = new License() {
-
-               public String getUri() {
-                       return "http://creativecommons.org/about/pdm";
-               }
-
-               public String getText() {
-                       return "This work is free of known copyright restrictions.";
-               }
-
-               public String getName() {
-                       return "Public Domain License";
-               }
-
-               public String getLink() {
-                       return "http://wiki.creativecommons.org/PDM_FAQ";
-               }
-       };
-
-       private final String name, uri, link, resource;
-
-       public FreeLicense(String name, String uri) {
-               this(name, uri, null, null);
-       }
-
-       public FreeLicense(String name, String uri, String link) {
-               this(name, uri, link, null);
-       }
-
-       public FreeLicense(String name, String uri, String link, String resource) {
-               if (uri == null)
-                       throw new SlcException("URI cannot be null");
-               this.name = name;
-               this.uri = uri;
-               this.link = link;
-               this.resource = resource;
-               getText();
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public String getUri() {
-               return uri;
-       }
-
-       public String getLink() {
-               return link;
-       }
-
-       @Override
-       public String getText() {
-               InputStream in = null;
-               URL url = null;
-               try {
-                       if (resource != null)
-                               url = getClass().getClassLoader().getResource(resource);
-                       else
-                               url = new URL(uri);
-                       in = url.openStream();
-                       String text = IOUtils.toString(in);
-                       return text;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot retrieve license " + name + " from "
-                                       + url, e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-               }
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               if (!(obj instanceof License))
-                       return false;
-               return ((License) obj).getUri().equals(getUri());
-       }
-
-       @Override
-       public int hashCode() {
-               return getUri().hashCode();
-       }
-
-       @Override
-       public String toString() {
-               return name + " (" + uri + ")";
-       }
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/JarFileIndexer.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/JarFileIndexer.java
deleted file mode 100644 (file)
index 95fa918..0000000
+++ /dev/null
@@ -1,483 +0,0 @@
-package org.argeo.slc.repo;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import java.util.jar.Attributes;
-import java.util.jar.Attributes.Name;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.Manifest;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-
-/**
- * Indexes jar file, currently supports standard J2SE and OSGi metadata (both
- * from MANIFEST)
- */
-public class JarFileIndexer implements NodeIndexer, SlcNames {
-       private final static Log log = LogFactory.getLog(JarFileIndexer.class);
-       private Boolean force = false;
-
-       public Boolean support(String path) {
-               return FilenameUtils.getExtension(path).equals("jar");
-       }
-
-       public void index(Node fileNode) {
-               Binary fileBinary = null;
-               JarInputStream jarIn = null;
-               ByteArrayOutputStream bo = null;
-               ByteArrayInputStream bi = null;
-               Binary manifestBinary = null;
-               try {
-                       if (!support(fileNode.getPath()))
-                               return;
-
-                       // Already indexed
-                       if (!force && fileNode.isNodeType(SlcTypes.SLC_JAR_FILE))
-                               return;
-
-                       if (!fileNode.isNodeType(NodeType.NT_FILE))
-                               return;
-
-                       Session jcrSession = fileNode.getSession();
-                       Node contentNode = fileNode.getNode(Node.JCR_CONTENT);
-                       fileBinary = contentNode.getProperty(Property.JCR_DATA).getBinary();
-
-                       jarIn = new JarInputStream(fileBinary.getStream());
-                       Manifest manifest = jarIn.getManifest();
-                       if (manifest == null) {
-                               log.error(fileNode + " has no MANIFEST");
-                               return;
-                       }
-
-                       bo = new ByteArrayOutputStream();
-                       manifest.write(bo);
-                       byte[] newManifest = bo.toByteArray();
-                       if (fileNode.hasProperty(SLC_MANIFEST)) {
-                               byte[] storedManifest = JcrUtils.getBinaryAsBytes(fileNode
-                                               .getProperty(SLC_MANIFEST));
-                               if (Arrays.equals(newManifest, storedManifest)) {
-                                       if (log.isTraceEnabled())
-                                               log.trace("Manifest not changed, doing nothing "
-                                                               + fileNode);
-                                       return;
-                               }
-                       }
-
-                       bi = new ByteArrayInputStream(newManifest);
-                       manifestBinary = jcrSession.getValueFactory().createBinary(bi);
-
-                       // standard jar file
-                       fileNode.addMixin(SlcTypes.SLC_JAR_FILE);
-
-                       fileNode.setProperty(SlcNames.SLC_MANIFEST, manifestBinary);
-                       Attributes attrs = manifest.getMainAttributes();
-
-                       getI18nValues(fileBinary, attrs);
-
-                       // standard J2SE MANIFEST attributes
-                       addAttr(Attributes.Name.MANIFEST_VERSION, fileNode, attrs);
-                       addAttr(Attributes.Name.SIGNATURE_VERSION, fileNode, attrs);
-                       addAttr(Attributes.Name.CLASS_PATH, fileNode, attrs);
-                       addAttr(Attributes.Name.MAIN_CLASS, fileNode, attrs);
-                       addAttr(Attributes.Name.EXTENSION_NAME, fileNode, attrs);
-                       addAttr(Attributes.Name.IMPLEMENTATION_VERSION, fileNode, attrs);
-                       addAttr(Attributes.Name.IMPLEMENTATION_VENDOR, fileNode, attrs);
-                       addAttr(Attributes.Name.IMPLEMENTATION_VENDOR_ID, fileNode, attrs);
-                       addAttr(Attributes.Name.SPECIFICATION_TITLE, fileNode, attrs);
-                       addAttr(Attributes.Name.SPECIFICATION_VERSION, fileNode, attrs);
-                       addAttr(Attributes.Name.SPECIFICATION_VENDOR, fileNode, attrs);
-                       addAttr(Attributes.Name.SEALED, fileNode, attrs);
-
-                       // OSGi
-                       if (attrs.containsKey(new Name(Constants.BUNDLE_SYMBOLICNAME))) {
-                               addOsgiMetadata(fileNode, attrs);
-                               if (log.isTraceEnabled())
-                                       log.trace("Indexed OSGi bundle " + fileNode);
-                       } else {
-                               if (log.isTraceEnabled())
-                                       log.trace("Indexed JAR file " + fileNode);
-                       }
-
-                       JcrUtils.updateLastModified(fileNode);
-
-               } catch (Exception e) {
-                       throw new SlcException("Cannot index jar " + fileNode, e);
-               } finally {
-                       IOUtils.closeQuietly(bi);
-                       IOUtils.closeQuietly(bo);
-                       IOUtils.closeQuietly(jarIn);
-                       JcrUtils.closeQuietly(manifestBinary);
-                       JcrUtils.closeQuietly(fileBinary);
-               }
-
-       }
-
-       private void getI18nValues(Binary fileBinary, Attributes attrs)
-                       throws IOException {
-               JarInputStream jarIn = null;
-               try {
-                       jarIn = new JarInputStream(fileBinary.getStream());
-                       String bundleLocalization = null;
-
-                       String blKey = Constants.BUNDLE_LOCALIZATION; // "Bundle-Localization";
-                       Name blkName = new Name(blKey);
-
-                       browse: for (Object obj : attrs.keySet()) {
-                               String value = attrs.getValue((Attributes.Name) obj);
-                               if (value.startsWith("%")) {
-                                       if (attrs.containsKey(blkName)) {
-                                               bundleLocalization = attrs.getValue(blkName);
-                                               break browse;
-                                       }
-                               }
-                       }
-
-                       JarEntry jarEntry = null;
-                       byte[] propBytes = null;
-                       ByteArrayOutputStream baos = null;
-                       browse: if (bundleLocalization != null) {
-                               JarEntry entry = jarIn.getNextJarEntry();
-                               while (entry != null) {
-                                       if (entry.getName().equals(
-                                                       bundleLocalization + ".properties")) {
-                                               jarEntry = entry;
-
-                                               // if(je.getSize() != -1){
-                                               // propBytes = new byte[(int)je.getSize()];
-                                               // int len = (int) je.getSize();
-                                               // int offset = 0;
-                                               // while (offset != len)
-                                               // offset += jarIn.read(propBytes, offset, len -
-                                               // offset);
-                                               // } else {
-                                               baos = new ByteArrayOutputStream();
-                                               while (true) {
-                                                       int qwe = jarIn.read();
-                                                       if (qwe == -1)
-                                                               break;
-                                                       baos.write(qwe);
-                                               }
-                                               propBytes = baos.toByteArray();
-                                               break browse;
-                                       }
-                                       entry = jarIn.getNextJarEntry();
-                               }
-                       }
-
-                       if (jarEntry != null) {
-                               Properties prop = new Properties();
-                               InputStream is = new ByteArrayInputStream(propBytes);
-                               prop.load(is);
-
-                               for (Object obj : attrs.keySet()) {
-                                       String value = attrs.getValue((Attributes.Name) obj);
-                                       if (value.startsWith("%")) {
-                                               String newVal = prop.getProperty(value.substring(1));
-                                               if (newVal != null)
-                                                       attrs.put(obj, newVal);
-                                       }
-                               }
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException(
-                                       "Error while reading the jar binary content " + fileBinary,
-                                       e);
-               } catch (IOException ioe) {
-                       throw new SlcException("unable to get internationalized values",
-                                       ioe);
-               } finally {
-                       IOUtils.closeQuietly(jarIn);
-               }
-       }
-
-       protected void addOsgiMetadata(Node fileNode, Attributes attrs)
-                       throws RepositoryException {
-
-               // TODO remove this ?
-               // Compulsory for the time being, because bundle artifact extends
-               // artifact
-               if (!fileNode.isNodeType(SlcTypes.SLC_ARTIFACT)) {
-                       ArtifactIndexer indexer = new ArtifactIndexer();
-                       indexer.index(fileNode);
-               }
-
-               fileNode.addMixin(SlcTypes.SLC_BUNDLE_ARTIFACT);
-
-               // symbolic name
-               String symbolicName = attrs.getValue(Constants.BUNDLE_SYMBOLICNAME);
-               // make sure there is no directive
-               symbolicName = symbolicName.split(";")[0];
-               fileNode.setProperty(SlcNames.SLC_SYMBOLIC_NAME, symbolicName);
-
-               // direct mapping
-               addAttr(Constants.BUNDLE_SYMBOLICNAME, fileNode, attrs);
-               addAttr(Constants.BUNDLE_NAME, fileNode, attrs);
-               addAttr(Constants.BUNDLE_DESCRIPTION, fileNode, attrs);
-               addAttr(Constants.BUNDLE_MANIFESTVERSION, fileNode, attrs);
-               addAttr(Constants.BUNDLE_CATEGORY, fileNode, attrs);
-               addAttr(Constants.BUNDLE_ACTIVATIONPOLICY, fileNode, attrs);
-               addAttr(Constants.BUNDLE_COPYRIGHT, fileNode, attrs);
-               addAttr(Constants.BUNDLE_VENDOR, fileNode, attrs);
-               addAttr("Bundle-License", fileNode, attrs);
-               addAttr(Constants.BUNDLE_DOCURL, fileNode, attrs);
-               addAttr(Constants.BUNDLE_CONTACTADDRESS, fileNode, attrs);
-               addAttr(Constants.BUNDLE_ACTIVATOR, fileNode, attrs);
-               addAttr(Constants.BUNDLE_UPDATELOCATION, fileNode, attrs);
-               addAttr(Constants.BUNDLE_LOCALIZATION, fileNode, attrs);
-
-               // required execution environment
-               if (attrs.containsKey(new Name(
-                               Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)))
-                       fileNode.setProperty(SlcNames.SLC_
-                                       + Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, attrs
-                                       .getValue(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)
-                                       .split(","));
-
-               // bundle classpath
-               if (attrs.containsKey(new Name(Constants.BUNDLE_CLASSPATH)))
-                       fileNode.setProperty(SlcNames.SLC_ + Constants.BUNDLE_CLASSPATH,
-                                       attrs.getValue(Constants.BUNDLE_CLASSPATH).split(","));
-
-               // version
-               Version version = new Version(attrs.getValue(Constants.BUNDLE_VERSION));
-               fileNode.setProperty(SlcNames.SLC_BUNDLE_VERSION, version.toString());
-               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.BUNDLE_VERSION);
-               Node bundleVersionNode = fileNode.addNode(SlcNames.SLC_
-                               + Constants.BUNDLE_VERSION, SlcTypes.SLC_OSGI_VERSION);
-               mapOsgiVersion(version, bundleVersionNode);
-
-               // fragment
-               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.FRAGMENT_HOST);
-               if (attrs.containsKey(new Name(Constants.FRAGMENT_HOST))) {
-                       String fragmentHost = attrs.getValue(Constants.FRAGMENT_HOST);
-                       String[] tokens = fragmentHost.split(";");
-                       Node node = fileNode.addNode(SlcNames.SLC_
-                                       + Constants.FRAGMENT_HOST, SlcTypes.SLC_FRAGMENT_HOST);
-                       node.setProperty(SlcNames.SLC_SYMBOLIC_NAME, tokens[0]);
-                       for (int i = 1; i < tokens.length; i++) {
-                               if (tokens[i].startsWith(Constants.BUNDLE_VERSION_ATTRIBUTE)) {
-                                       node.setProperty(SlcNames.SLC_BUNDLE_VERSION,
-                                                       attributeValue(tokens[i]));
-                               }
-                       }
-               }
-
-               // imported packages
-               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.IMPORT_PACKAGE);
-               if (attrs.containsKey(new Name(Constants.IMPORT_PACKAGE))) {
-                       String importPackages = attrs.getValue(Constants.IMPORT_PACKAGE);
-                       List<String> packages = parseCommaSeparated(importPackages);
-                       for (String pkg : packages) {
-                               String[] tokens = pkg.split(";");
-                               Node node = fileNode.addNode(SlcNames.SLC_
-                                               + Constants.IMPORT_PACKAGE,
-                                               SlcTypes.SLC_IMPORTED_PACKAGE);
-                               node.setProperty(SlcNames.SLC_NAME, tokens[0]);
-                               for (int i = 1; i < tokens.length; i++) {
-                                       if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
-                                               node.setProperty(SlcNames.SLC_VERSION,
-                                                               attributeValue(tokens[i]));
-                                       } else if (tokens[i]
-                                                       .startsWith(Constants.RESOLUTION_DIRECTIVE)) {
-                                               node.setProperty(
-                                                               SlcNames.SLC_OPTIONAL,
-                                                               directiveValue(tokens[i]).equals(
-                                                                               Constants.RESOLUTION_OPTIONAL));
-                                       }
-                               }
-                       }
-               }
-
-               // dynamic import package
-               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.DYNAMICIMPORT_PACKAGE);
-               if (attrs.containsKey(new Name(Constants.DYNAMICIMPORT_PACKAGE))) {
-                       String importPackages = attrs
-                                       .getValue(Constants.DYNAMICIMPORT_PACKAGE);
-                       List<String> packages = parseCommaSeparated(importPackages);
-                       for (String pkg : packages) {
-                               String[] tokens = pkg.split(";");
-                               Node node = fileNode.addNode(SlcNames.SLC_
-                                               + Constants.DYNAMICIMPORT_PACKAGE,
-                                               SlcTypes.SLC_DYNAMIC_IMPORTED_PACKAGE);
-                               node.setProperty(SlcNames.SLC_NAME, tokens[0]);
-                               for (int i = 1; i < tokens.length; i++) {
-                                       if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
-                                               node.setProperty(SlcNames.SLC_VERSION,
-                                                               attributeValue(tokens[i]));
-                                       }
-                               }
-                       }
-               }
-
-               // exported packages
-               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.EXPORT_PACKAGE);
-               if (attrs.containsKey(new Name(Constants.EXPORT_PACKAGE))) {
-                       String exportPackages = attrs.getValue(Constants.EXPORT_PACKAGE);
-                       List<String> packages = parseCommaSeparated(exportPackages);
-                       for (String pkg : packages) {
-                               String[] tokens = pkg.split(";");
-                               Node node = fileNode.addNode(SlcNames.SLC_
-                                               + Constants.EXPORT_PACKAGE,
-                                               SlcTypes.SLC_EXPORTED_PACKAGE);
-                               node.setProperty(SlcNames.SLC_NAME, tokens[0]);
-                               // TODO: are these cleans really necessary?
-                               cleanSubNodes(node, SlcNames.SLC_USES);
-                               cleanSubNodes(node, SlcNames.SLC_VERSION);
-                               for (int i = 1; i < tokens.length; i++) {
-                                       if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
-                                               String versionStr = attributeValue(tokens[i]);
-                                               Node versionNode = node.addNode(SlcNames.SLC_VERSION,
-                                                               SlcTypes.SLC_OSGI_VERSION);
-                                               mapOsgiVersion(new Version(versionStr), versionNode);
-                                       } else if (tokens[i].startsWith(Constants.USES_DIRECTIVE)) {
-                                               String usedPackages = directiveValue(tokens[i]);
-                                               // log.debug("uses='" + usedPackages + "'");
-                                               for (String usedPackage : usedPackages.split(",")) {
-                                                       // log.debug("usedPackage='" +
-                                                       // usedPackage +
-                                                       // "'");
-                                                       Node usesNode = node.addNode(SlcNames.SLC_USES,
-                                                                       SlcTypes.SLC_JAVA_PACKAGE);
-                                                       usesNode.setProperty(SlcNames.SLC_NAME, usedPackage);
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               // required bundle
-               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.REQUIRE_BUNDLE);
-               if (attrs.containsKey(new Name(Constants.REQUIRE_BUNDLE))) {
-                       String requireBundle = attrs.getValue(Constants.REQUIRE_BUNDLE);
-                       List<String> bundles = parseCommaSeparated(requireBundle);
-                       for (String bundle : bundles) {
-                               String[] tokens = bundle.split(";");
-                               Node node = fileNode.addNode(SlcNames.SLC_
-                                               + Constants.REQUIRE_BUNDLE,
-                                               SlcTypes.SLC_REQUIRED_BUNDLE);
-                               node.setProperty(SlcNames.SLC_SYMBOLIC_NAME, tokens[0]);
-                               for (int i = 1; i < tokens.length; i++) {
-                                       if (tokens[i]
-                                                       .startsWith(Constants.BUNDLE_VERSION_ATTRIBUTE)) {
-                                               node.setProperty(SlcNames.SLC_BUNDLE_VERSION,
-                                                               attributeValue(tokens[i]));
-                                       } else if (tokens[i]
-                                                       .startsWith(Constants.RESOLUTION_DIRECTIVE)) {
-                                               node.setProperty(
-                                                               SlcNames.SLC_OPTIONAL,
-                                                               directiveValue(tokens[i]).equals(
-                                                                               Constants.RESOLUTION_OPTIONAL));
-                                       }
-                               }
-                       }
-               }
-
-       }
-
-       private void addAttr(String key, Node node, Attributes attrs)
-                       throws RepositoryException {
-               addAttr(new Name(key), node, attrs);
-       }
-
-       private void addAttr(Name key, Node node, Attributes attrs)
-                       throws RepositoryException {
-               if (attrs.containsKey(key)) {
-                       String value = attrs.getValue(key);
-                       node.setProperty(SlcNames.SLC_ + key, value);
-               }
-       }
-
-       private void cleanSubNodes(Node node, String name)
-                       throws RepositoryException {
-               if (node.hasNode(name)) {
-                       NodeIterator nit = node.getNodes(name);
-                       while (nit.hasNext())
-                               nit.nextNode().remove();
-               }
-       }
-
-       private String attributeValue(String str) {
-               return extractValue(str, "=");
-       }
-
-       private String directiveValue(String str) {
-               return extractValue(str, ":=");
-       }
-
-       private String extractValue(String str, String eq) {
-               String[] tokens = str.split(eq);
-               // String key = tokens[0];
-               String value = tokens[1].trim();
-               // TODO: optimize?
-               if (value.startsWith("\""))
-                       value = value.substring(1);
-               if (value.endsWith("\""))
-                       value = value.substring(0, value.length() - 1);
-               return value;
-       }
-
-       /** Parse package list with nested directive with ',' */
-       private List<String> parseCommaSeparated(String str) {
-               List<String> res = new ArrayList<String>();
-               StringBuffer curr = new StringBuffer("");
-               boolean in = false;
-               for (char c : str.toCharArray()) {
-                       if (c == ',') {
-                               if (!in) {// new package
-                                       res.add(curr.toString());
-                                       curr = new StringBuffer("");
-                               } else {// a ',' within " "
-                                       curr.append(c);
-                               }
-                       } else if (c == '\"') {
-                               in = !in;
-                               curr.append(c);
-                       } else {
-                               curr.append(c);
-                       }
-               }
-               res.add(curr.toString());
-               // log.debug(res);
-               return res;
-       }
-
-       protected void mapOsgiVersion(Version version, Node versionNode)
-                       throws RepositoryException {
-               versionNode.setProperty(SlcNames.SLC_AS_STRING, version.toString());
-               versionNode.setProperty(SlcNames.SLC_MAJOR, version.getMajor());
-               versionNode.setProperty(SlcNames.SLC_MINOR, version.getMinor());
-               versionNode.setProperty(SlcNames.SLC_MICRO, version.getMicro());
-               if (!version.getQualifier().equals(""))
-                       versionNode.setProperty(SlcNames.SLC_QUALIFIER,
-                                       version.getQualifier());
-       }
-
-       public void setForce(Boolean force) {
-               this.force = force;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/JavaRepoManager.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/JavaRepoManager.java
deleted file mode 100644 (file)
index 4d7c3ef..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.repo;
-
-/** Java-specific operations */
-public interface JavaRepoManager {
-       public void createWorkspace(String workspaceName);
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/MavenProxyService.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/MavenProxyService.java
deleted file mode 100644 (file)
index 81261fe..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.repo;
-
-import org.argeo.jcr.proxy.ResourceProxy;
-
-/** Marker interface (useful for OSGi servcies references), maybe extended later */
-public interface MavenProxyService extends ResourceProxy {
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java
deleted file mode 100644 (file)
index 19627d8..0000000
+++ /dev/null
@@ -1,519 +0,0 @@
-package org.argeo.slc.repo;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.CategoryNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.osgi.framework.Constants;
-
-/**
- * Creates a jar bundle from an ArgeoOsgiDistribution. This jar is then
- * persisted and indexed in a java repository using the OSGI Factory.
- * 
- * It does the following <list>
- * <li>Creates a Manifest</li>
- * <li>Creates files indexes (csv, feature.xml ...)</li>
- * <li>Populate the corresponding jar</li>
- * <li>Save it in the repository</li>
- * <li>Index the node and creates corresponding sha1 and md5 files</li> </list>
- * 
- */
-public class ModularDistributionFactory implements Runnable {
-
-       private OsgiFactory osgiFactory;
-       private Session javaSession;
-       private ArgeoOsgiDistribution osgiDistribution;
-       private String modularDistributionSeparator = ",";
-       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
-       private String artifactType = "jar";
-
-       // Constants
-       private final static String CSV_FILE_NAME = "modularDistribution.csv";
-       private final DateFormat snapshotTimestamp = new SimpleDateFormat("YYYYMMddhhmm");
-
-       // private final static String FEATURE_FILE_NAME = "feature.xml";
-       // private static int BUFFER_SIZE = 10240;
-
-       /** Convenience constructor with minimal configuration */
-       public ModularDistributionFactory(OsgiFactory osgiFactory, ArgeoOsgiDistribution osgiDistribution) {
-               this.osgiFactory = osgiFactory;
-               this.osgiDistribution = osgiDistribution;
-       }
-
-       @Override
-       public void run() {
-               byte[] distFile = null;
-               try {
-                       javaSession = osgiFactory.openJavaSession();
-
-                       if (artifactType == "jar")
-                               distFile = generateJarFile();
-                       else if (artifactType == "pom")
-                               distFile = generatePomFile();
-                       else
-                               throw new SlcException("Unimplemented distribution artifact type: " + artifactType + " for "
-                                               + osgiDistribution.toString());
-
-                       // Save in java repository
-                       Artifact osgiArtifact = new DefaultArtifact(osgiDistribution.getCategory(), osgiDistribution.getName(),
-                                       artifactType, osgiDistribution.getVersion());
-
-                       Node distNode = RepoUtils.copyBytesAsArtifact(javaSession.getNode(artifactBasePath), osgiArtifact,
-                                       distFile);
-
-                       // index
-                       osgiFactory.indexNode(distNode);
-
-                       // We use a specific session. Save before closing
-                       javaSession.save();
-               } catch (RepositoryException e) {
-                       throw new SlcException(
-                                       "JCR error while persisting modular distribution in JCR " + osgiDistribution.toString(), e);
-               } finally {
-                       JcrUtils.logoutQuietly(javaSession);
-               }
-       }
-
-       private byte[] generateJarFile() {
-               ByteArrayOutputStream byteOut = null;
-               JarOutputStream jarOut = null;
-               try {
-                       byteOut = new ByteArrayOutputStream();
-                       jarOut = new JarOutputStream(byteOut, createManifest());
-                       // Create various indexes
-                       addToJar(createCsvDescriptor(), CSV_FILE_NAME, jarOut);
-                       jarOut.close();
-                       return byteOut.toByteArray();
-               } catch (IOException e) {
-                       throw new SlcException("IO error while generating modular distribution " + osgiDistribution.toString(), e);
-               } finally {
-                       IOUtils.closeQuietly(byteOut);
-                       IOUtils.closeQuietly(jarOut);
-               }
-       }
-
-       // private void indexDistribution(Node distNode) throws RepositoryException
-       // {
-       // distNode.addMixin(SlcTypes.SLC_MODULAR_DISTRIBUTION);
-       // distNode.addMixin(SlcTypes.SLC_CATEGORIZED_NAME_VERSION);
-       // distNode.setProperty(SlcNames.SLC_CATEGORY,
-       // osgiDistribution.getCategory());
-       // distNode.setProperty(SlcNames.SLC_NAME, osgiDistribution.getName());
-       // distNode.setProperty(SlcNames.SLC_VERSION,
-       // osgiDistribution.getVersion());
-       //
-       // if (distNode.hasNode(SlcNames.SLC_MODULES))
-       // distNode.getNode(SlcNames.SLC_MODULES).remove();
-       // Node modules = distNode.addNode(SlcNames.SLC_MODULES,
-       // NodeType.NT_UNSTRUCTURED);
-       //
-       // for (Iterator<? extends NameVersion> it = osgiDistribution
-       // .nameVersions(); it.hasNext();)
-       // addModule(modules, it.next());
-       // }
-
-       private Manifest createManifest() {
-               Manifest manifest = new Manifest();
-
-               // TODO make this configurable
-               manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
-//             addManifestAttribute(manifest, Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-1.8");
-               addManifestAttribute(manifest, Constants.BUNDLE_VENDOR, "Argeo");
-               addManifestAttribute(manifest, Constants.BUNDLE_MANIFESTVERSION, "2");
-//             addManifestAttribute(manifest, "Bundle-License", "http://www.apache.org/licenses/LICENSE-2.0.txt");
-
-               // TODO define a user friendly name
-               addManifestAttribute(manifest, Constants.BUNDLE_NAME, osgiDistribution.getName());
-
-               // Categorized name version
-               addManifestAttribute(manifest, RepoConstants.SLC_CATEGORY_ID, osgiDistribution.getCategory());
-               addManifestAttribute(manifest, Constants.BUNDLE_SYMBOLICNAME, osgiDistribution.getName());
-               String version = osgiDistribution.getVersion();
-               if (version.endsWith("-SNAPSHOT")) {
-                       version = version.substring(0, version.length() - "-SNAPSHOT".length());
-                       version = version + ".SNAPSHOT-r" + snapshotTimestamp.format(new Date());
-               }
-               addManifestAttribute(manifest, Constants.BUNDLE_VERSION, version);
-
-               return manifest;
-       }
-
-       private void addManifestAttribute(Manifest manifest, String name, String value) {
-               manifest.getMainAttributes().put(new Attributes.Name(name), value);
-       }
-
-       private byte[] createCsvDescriptor() {
-               Writer writer = null;
-               try {
-                       // FIXME remove use of tmp file.
-                       File tmpFile = File.createTempFile("modularDistribution", "csv");
-                       tmpFile.deleteOnExit();
-                       writer = new FileWriter(tmpFile);
-                       // Populate the file
-                       for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();)
-                               writer.write(getCsvLine(it.next()));
-                       writer.flush();
-                       return FileUtils.readFileToByteArray(tmpFile);
-               } catch (Exception e) {
-                       throw new SlcException("unable to create csv distribution file for " + osgiDistribution.toString(), e);
-               } finally {
-                       IOUtils.closeQuietly(writer);
-               }
-       }
-
-       @SuppressWarnings("unused")
-       private byte[] createFeatureDescriptor() {
-               // Directly retrieved from Argeo maven plugin
-               // Does not work due to the lack of org.codehaus.plexus/plexus-archiver
-               // third party dependency
-
-               throw new SlcException("Unimplemented method");
-
-               // // protected void writeFeatureDescriptor() throws
-               // MojoExecutionException {
-               // File featureDesc = File.createTempFile("feature", "xml");
-               // featureDesc.deleteOnExit();
-               //
-               // Writer writer = null;
-               // try {
-               // writer = new FileWriter(featureDesc);
-               // PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
-               // xmlWriter.startElement("feature");
-               // xmlWriter.addAttribute("id", project.getArtifactId());
-               // xmlWriter.addAttribute("label", project.getName());
-               //
-               // // Version
-               // String projectVersion = project.getVersion();
-               // int indexSnapshot = projectVersion.indexOf("-SNAPSHOT");
-               // if (indexSnapshot > -1)
-               // projectVersion = projectVersion.substring(0, indexSnapshot);
-               // projectVersion = projectVersion + ".qualifier";
-               //
-               // // project.
-               // xmlWriter.addAttribute("version", projectVersion);
-               //
-               // Organization organization = project.getOrganization();
-               // if (organization != null && organization.getName() != null)
-               // xmlWriter.addAttribute("provider-name", organization.getName());
-               //
-               // if (project.getDescription() != null || project.getUrl() != null) {
-               // xmlWriter.startElement("description");
-               // if (project.getUrl() != null)
-               // xmlWriter.addAttribute("url", project.getUrl());
-               // if (project.getDescription() != null)
-               // xmlWriter.writeText(project.getDescription());
-               // xmlWriter.endElement();// description
-               // }
-               //
-               // if (feature != null && feature.getCopyright() != null
-               // || (organization != null && organization.getUrl() != null)) {
-               // xmlWriter.startElement("copyright");
-               // if (organization != null && organization.getUrl() != null)
-               // xmlWriter.addAttribute("url", organization.getUrl());
-               // if (feature.getCopyright() != null)
-               // xmlWriter.writeText(feature.getCopyright());
-               // xmlWriter.endElement();// copyright
-               // }
-               //
-               // if (feature != null && feature.getUpdateSite() != null) {
-               // xmlWriter.startElement("url");
-               // xmlWriter.startElement("update");
-               // xmlWriter.addAttribute("url", feature.getUpdateSite());
-               // xmlWriter.endElement();// update
-               // xmlWriter.endElement();// url
-               // }
-               //
-               // List licenses = project.getLicenses();
-               // if (licenses.size() > 0) {
-               // // take the first one
-               // License license = (License) licenses.get(0);
-               // xmlWriter.startElement("license");
-               //
-               // if (license.getUrl() != null)
-               // xmlWriter.addAttribute("url", license.getUrl());
-               // if (license.getComments() != null)
-               // xmlWriter.writeText(license.getComments());
-               // else if (license.getName() != null)
-               // xmlWriter.writeText(license.getName());
-               // xmlWriter.endElement();// license
-               // }
-               //
-               // // deploymentRepository.pathOf(null);
-               // if (jarDirectory == null) {
-               // Set dependencies = mavenDependencyManager
-               // .getTransitiveProjectDependencies(project, remoteRepos,
-               // local);
-               // // // protected void writeFeatureDescriptor() throws
-               // MojoExecutionException {
-               // File featureDesc = File.createTempFile("feature", "xml");
-               // featureDesc.deleteOnExit();
-               //
-               // Writer writer = null;
-               // try {
-               // writer = new FileWriter(featureDesc);
-               // PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
-               // xmlWriter.startElement("feature");
-               // xmlWriter.addAttribute("id", project.getArtifactId());
-               // xmlWriter.addAttribute("label", project.getName());
-               //
-               // // Version
-               // String projectVersion = project.getVersion();
-               // int indexSnapshot = projectVersion.indexOf("-SNAPSHOT");
-               // if (indexSnapshot > -1)
-               // projectVersion = projectVersion.substring(0, indexSnapshot);
-               // projectVersion = projectVersion + ".qualifier";
-               //
-               // // project.
-               // xmlWriter.addAttribute("version", projectVersion);
-               //
-               // Organization organization = project.getOrganization();
-               // if (organization != null && organization.getName() != null)
-               // xmlWriter.addAttribute("provider-name", organization.getName());
-               //
-               // if (project.getDescription() != null || project.getUrl() != null) {
-               // xmlWriter.startElement("description");
-               // if (project.getUrl() != null)
-               // xmlWriter.addAttribute("url", project.getUrl());
-               // if (project.getDescription() != null)
-               // xmlWriter.writeText(project.getDescription());
-               // xmlWriter.endElement();// description
-               // }
-               //
-               // if (feature != null && feature.getCopyright() != null
-               // || (organization != null && organization.getUrl() != null)) {
-               // xmlWriter.startElement("copyright");
-               // if (organization != null && organization.getUrl() != null)
-               // xmlWriter.addAttribute("url", organization.getUrl());
-               // if (feature.getCopyright() != null)
-               // xmlWriter.writeText(feature.getCopyright());
-               // xmlWriter.endElement();// copyright
-               // }
-               //
-               // if (feature != null && feature.getUpdateSite() != null) {
-               // xmlWriter.startElement("url");
-               // xmlWriter.startElement("update");
-               // xmlWriter.addAttribute("url", feature.getUpdateSite());
-               // xmlWriter.endElement();// update
-               // xmlWriter.endElement();// url
-               // }
-               //
-               // List licenses = project.getLicenses();
-               // if (licenses.size() > 0) {
-               // // take the first one
-               // License license = (License) licenses.get(0);
-               // xmlWriter.startElement("license");
-               //
-               // if (license.getUrl() != null)
-               // xmlWriter.addAttribute("url", license.getUrl());
-               // if (license.getComments() != null)
-               // xmlWriter.writeText(license.getComments());
-               // else if (license.getName() != null)
-               // xmlWriter.writeText(license.getName());
-               // xmlWriter.endElement();// license
-               // }
-               //
-               // // deploymentRepository.pathOf(null);
-               // if (jarDirectory == null) {
-               // Set dependencies = mavenDependencyManager
-               // .getTransitiveProjectDependencies(project, remoteRepos,
-               // local);
-               // for (Iterator it = dependencies.iterator(); it.hasNext();) {
-               // Artifact artifact = (Artifact) it.next();
-               // writeFeaturePlugin(xmlWriter, artifact.getFile());
-               // }
-               // } else {
-               // // TODO: filter jars
-               // File[] jars = jarDirectory.listFiles();
-               // if (jars == null)
-               // throw new MojoExecutionException("No jar found in "
-               // + jarDirectory);
-               // for (int i = 0; i < jars.length; i++) {
-               // writeFeaturePlugin(xmlWriter, jars[i]);
-               // }
-               // }
-               //
-               // xmlWriter.endElement();// feature
-               //
-               // if (getLog().isDebugEnabled())
-               // getLog().debug("Wrote Eclipse feature descriptor.");
-               // } catch (Exception e) {
-               // throw new MojoExecutionException("Cannot write feature descriptor",
-               // e);
-               // } finally {
-               // IOUtil.close(writer);
-               // }for (Iterator it = dependencies.iterator(); it.hasNext();) {
-               // Artifact artifact = (Artifact) it.next();
-               // writeFeaturePlugin(xmlWriter, artifact.getFile());
-               // }
-               // } else {
-               // // TODO: filter jars
-               // File[] jars = jarDirectory.listFiles();
-               // if (jars == null)
-               // throw new MojoExecutionException("No jar found in "
-               // + jarDirectory);
-               // for (int i = 0; i < jars.length; i++) {
-               // writeFeaturePlugin(xmlWriter, jars[i]);
-               // }
-               // }
-               //
-               // xmlWriter.endElement();// feature
-               //
-               // if (getLog().isDebugEnabled())
-               // getLog().debug("Wrote Eclipse feature descriptor.");
-               // } catch (Exception e) {
-               // throw new MojoExecutionException("Cannot write feature descriptor",
-               // e);
-               // } finally {
-               // IOUtil.close(writer);
-               // }
-       }
-
-       /** Create an Aether like distribution artifact */
-       private byte[] generatePomFile() {
-               StringBuilder b = new StringBuilder();
-               // XML header
-               b.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-               b.append(
-                               "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
-               b.append("<modelVersion>4.0.0</modelVersion>");
-
-               // Artifact
-               b.append("<groupId>").append(osgiDistribution.getCategory()).append("</groupId>\n");
-               b.append("<artifactId>").append(osgiDistribution.getName()).append("</artifactId>\n");
-               b.append("<version>").append(osgiDistribution.getVersion()).append("</version>\n");
-               b.append("<packaging>pom</packaging>\n");
-               // p.append("<name>").append("Bundle Name").append("</name>\n");
-               // p.append("<description>").append("Bundle
-               // Description").append("</description>\n");
-
-               // Dependencies
-               b.append("<dependencies>\n");
-               for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();) {
-                       NameVersion nameVersion = it.next();
-                       if (!(nameVersion instanceof CategoryNameVersion))
-                               throw new SlcException("Unsupported type " + nameVersion.getClass());
-                       CategoryNameVersion nv = (CategoryNameVersion) nameVersion;
-                       b.append(getDependencySnippet(nv, false));
-               }
-               b.append("</dependencies>\n");
-
-               // Dependency management
-               b.append("<dependencyManagement>\n");
-               b.append("<dependencies>\n");
-
-               for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();)
-                       b.append(getDependencySnippet((CategoryNameVersion) it.next(), true));
-               b.append("</dependencies>\n");
-               b.append("</dependencyManagement>\n");
-
-               b.append("</project>\n");
-               return b.toString().getBytes();
-       }
-
-       private String getDependencySnippet(CategoryNameVersion cnv, boolean includeVersion) { // , String type, String
-                                                                                                                                                                                               // scope
-               StringBuilder b = new StringBuilder();
-               b.append("<dependency>\n");
-               b.append("\t<groupId>").append(cnv.getCategory()).append("</groupId>\n");
-               b.append("\t<artifactId>").append(cnv.getName()).append("</artifactId>\n");
-               if (includeVersion)
-                       b.append("\t<version>").append(cnv.getVersion()).append("</version>\n");
-               // if (type!= null)
-               // p.append("\t<type>").append(type).append("</type>\n");
-               // if (type!= null)
-               // p.append("\t<scope>").append(scope).append("</scope>\n");
-               b.append("</dependency>\n");
-               return b.toString();
-       }
-
-       // Helpers
-       private void addToJar(byte[] content, String name, JarOutputStream target) throws IOException {
-               ByteArrayInputStream in = null;
-               try {
-                       target.putNextEntry(new JarEntry(name));
-                       in = new ByteArrayInputStream(content);
-                       byte[] buffer = new byte[1024];
-                       while (true) {
-                               int count = in.read(buffer);
-                               if (count == -1)
-                                       break;
-                               target.write(buffer, 0, count);
-                       }
-                       target.closeEntry();
-               } finally {
-                       IOUtils.closeQuietly(in);
-               }
-       }
-
-       private String getCsvLine(NameVersion nameVersion) throws RepositoryException {
-               if (!(nameVersion instanceof CategoryNameVersion))
-                       throw new SlcException("Unsupported type " + nameVersion.getClass());
-               CategoryNameVersion cnv = (CategoryNameVersion) nameVersion;
-               StringBuilder builder = new StringBuilder();
-
-               builder.append(cnv.getName());
-               builder.append(modularDistributionSeparator);
-               builder.append(nameVersion.getVersion());
-               builder.append(modularDistributionSeparator);
-               builder.append(cnv.getCategory().replace('.', '/'));
-               // MavenConventionsUtils.groupPath("", cnv.getCategory());
-               builder.append('/');
-               builder.append(cnv.getName());
-               builder.append('/');
-               builder.append(cnv.getVersion());
-               builder.append('/');
-               builder.append(cnv.getName());
-               builder.append('-');
-               builder.append(cnv.getVersion());
-               builder.append('.');
-               // TODO make this dynamic
-               builder.append("jar");
-               builder.append("\n");
-
-               return builder.toString();
-       }
-
-       /** Enable dependency injection */
-       public void setOsgiFactory(OsgiFactory osgiFactory) {
-               this.osgiFactory = osgiFactory;
-       }
-
-       public void setOsgiDistribution(ArgeoOsgiDistribution osgiDistribution) {
-               this.osgiDistribution = osgiDistribution;
-       }
-
-       public void setModularDistributionSeparator(String modularDistributionSeparator) {
-               this.modularDistributionSeparator = modularDistributionSeparator;
-       }
-
-       public void setArtifactBasePath(String artifactBasePath) {
-               this.artifactBasePath = artifactBasePath;
-       }
-
-       public void setArtifactType(String artifactType) {
-               this.artifactType = artifactType;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java
deleted file mode 100644 (file)
index 77e8f84..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-package org.argeo.slc.repo;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.Manifest;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.CategoryNameVersion;
-import org.argeo.slc.DefaultCategoryNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.repo.maven.AetherUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.osgi.framework.Constants;
-
-/**
- * Create or update JCR meta-data for an SLC Modular Distribution
- * 
- * Currently, following types are managed: <list>
- * <li>* .jar: dependency artifacts with csv index</li>
- * <li>@Deprecated : .pom: artifact (binaries) that indexes a group, the .pom
- * file contains a tag "dependencyManagement" that list all modules</li> </list>
- */
-public class ModularDistributionIndexer implements NodeIndexer, SlcNames {
-       private final static Log log = LogFactory.getLog(ModularDistributionIndexer.class);
-
-       // Constants for csv indexing
-       private final static String INDEX_FILE_NAME = "modularDistribution.csv";
-       private String separator = ",";
-
-       private Manifest manifest;
-
-       public Boolean support(String path) {
-               if (FilenameUtils.getExtension(path).equals("jar"))
-                       return true;
-               return false;
-       }
-
-       public void index(Node fileNode) {
-               Binary fileBinary = null;
-               try {
-                       String fileNodePath = fileNode.getPath();
-                       if (!support(fileNodePath))
-                               return;
-
-                       if (!fileNode.isNodeType(NodeType.NT_FILE))
-                               return;
-
-                       Node contentNode = fileNode.getNode(Node.JCR_CONTENT);
-                       fileBinary = contentNode.getProperty(Property.JCR_DATA).getBinary();
-
-                       MyModularDistribution currDist = null;
-                       if (FilenameUtils.getExtension(fileNode.getPath()).equals("jar"))
-                               currDist = listModulesFromCsvIndex(fileNode, fileBinary);
-
-                       if (fileNode.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION) || currDist == null
-                                       || !currDist.nameVersions().hasNext())
-                               return; // already indexed or no modules found
-                       else {
-                               fileNode.addMixin(SlcTypes.SLC_MODULAR_DISTRIBUTION);
-                               fileNode.addMixin(SlcTypes.SLC_CATEGORIZED_NAME_VERSION);
-                               if (currDist.getCategory() != null)
-                                       fileNode.setProperty(SLC_CATEGORY, currDist.getCategory());
-                               fileNode.setProperty(SLC_NAME, currDist.getName());
-                               fileNode.setProperty(SLC_VERSION, currDist.getVersion());
-                               indexDistribution(currDist, fileNode);
-                       }
-
-                       if (log.isTraceEnabled())
-                               log.trace("Indexed " + fileNode + " as modular distribution");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot list dependencies from " + fileNode, e);
-               } finally {
-                       JcrUtils.closeQuietly(fileBinary);
-               }
-       }
-
-       private void indexDistribution(ArgeoOsgiDistribution osgiDist, Node distNode) throws RepositoryException {
-               distNode.addMixin(SlcTypes.SLC_MODULAR_DISTRIBUTION);
-               distNode.addMixin(SlcTypes.SLC_CATEGORIZED_NAME_VERSION);
-               distNode.setProperty(SlcNames.SLC_CATEGORY, osgiDist.getCategory());
-               distNode.setProperty(SlcNames.SLC_NAME, osgiDist.getName());
-               distNode.setProperty(SlcNames.SLC_VERSION, osgiDist.getVersion());
-               if (distNode.hasNode(SLC_MODULES))
-                       distNode.getNode(SLC_MODULES).remove();
-               Node modules = distNode.addNode(SLC_MODULES, NodeType.NT_UNSTRUCTURED);
-
-               for (Iterator<? extends NameVersion> it = osgiDist.nameVersions(); it.hasNext();)
-                       addModule(modules, it.next());
-       }
-
-       // Helpers
-       private Node addModule(Node modules, NameVersion nameVersion) throws RepositoryException {
-               CategoryNameVersion cnv = (CategoryNameVersion) nameVersion;
-               Node moduleCoord = null;
-               moduleCoord = modules.addNode(cnv.getName(), SlcTypes.SLC_MODULE_COORDINATES);
-               moduleCoord.setProperty(SlcNames.SLC_CATEGORY, cnv.getCategory());
-               moduleCoord.setProperty(SlcNames.SLC_NAME, cnv.getName());
-               moduleCoord.setProperty(SlcNames.SLC_VERSION, cnv.getVersion());
-               return moduleCoord;
-       }
-
-       private MyModularDistribution listModulesFromCsvIndex(Node fileNode, Binary fileBinary) {
-               JarInputStream jarIn = null;
-               BufferedReader reader = null;
-               try {
-                       jarIn = new JarInputStream(fileBinary.getStream());
-
-                       List<CategoryNameVersion> modules = new ArrayList<CategoryNameVersion>();
-
-                       // meta data
-                       manifest = jarIn.getManifest();
-                       if (manifest == null) {
-                               log.error(fileNode + " has no MANIFEST");
-                               return null;
-                       }
-                       String category = manifest.getMainAttributes().getValue(RepoConstants.SLC_CATEGORY_ID);
-                       String name = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
-                       String version = manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
-
-                       Artifact distribution = new DefaultArtifact(category, name, "jar", version);
-                       // Retrieve the index file
-                       JarEntry indexEntry;
-                       while ((indexEntry = jarIn.getNextJarEntry()) != null) {
-                               String entryName = indexEntry.getName();
-                               if (entryName.equals(INDEX_FILE_NAME)) {
-                                       break;
-                               }
-                               try {
-                                       jarIn.closeEntry();
-                               } catch (SecurityException se) {
-                                       log.error("Invalid signature file digest " + "for Manifest main attributes: " + entryName
-                                                       + " while looking for an index in bundle " + name);
-                               }
-                       }
-                       if (indexEntry == null)
-                               return null; // Not a modular definition
-
-                       if (category == null) {
-                               log.warn("Modular definition found but no " + RepoConstants.SLC_CATEGORY_ID + " in " + fileNode);
-                       }
-
-                       // Process the index
-                       reader = new BufferedReader(new InputStreamReader(jarIn));
-                       String line = null;
-                       while ((line = reader.readLine()) != null) {
-                               StringTokenizer st = new StringTokenizer(line, separator);
-                               st.nextToken(); // moduleName
-                               st.nextToken(); // moduleVersion
-                               String relativeUrl = st.nextToken();
-                               Artifact currModule = AetherUtils.convertPathToArtifact(relativeUrl, null);
-                               modules.add(new DefaultCategoryNameVersion(currModule.getGroupId(), currModule.getArtifactId(),
-                                               currModule.getVersion()));
-                       }
-                       return new MyModularDistribution(distribution, modules);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot list artifacts", e);
-               } finally {
-                       IOUtils.closeQuietly(jarIn);
-                       IOUtils.closeQuietly(reader);
-               }
-       }
-
-       /**
-        * A consistent and versioned OSGi distribution, which can be built and tested.
-        */
-       private class MyModularDistribution extends ArtifactDistribution implements ArgeoOsgiDistribution {
-
-               private List<CategoryNameVersion> modules;
-
-               public MyModularDistribution(Artifact artifact, List<CategoryNameVersion> modules) {
-                       super(artifact);
-                       this.modules = modules;
-               }
-
-               public Iterator<CategoryNameVersion> nameVersions() {
-                       return modules.iterator();
-               }
-
-               // Modular distribution interface methods. Not yet used.
-               public Distribution getModuleDistribution(String moduleName, String moduleVersion) {
-                       return null;
-               }
-
-               public Object getModulesDescriptor(String descriptorType) {
-                       return null;
-               }
-       }
-
-       /** Separator used to parse the tabular file, default is "," */
-       public void setSeparator(String modulesUrlSeparator) {
-               this.separator = modulesUrlSeparator;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexer.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexer.java
deleted file mode 100644 (file)
index 374ad85..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.argeo.slc.repo;
-
-import javax.jcr.Node;
-import javax.jcr.observation.EventListener;
-
-/**
- * Adds metadata to an existing node, ideally via observation after it has been
- * added. There is a similar concept in ModeShape with which this abstraction
- * may be merged in the future.
- */
-public interface NodeIndexer {
-       /**
-        * Whether the node at this path will be supported. This is typically use in
-        * an {@link EventListener} before the node is loaded, and would apply on
-        * information contained in the path / file name: file extension, base path,
-        * etc. If the node needs to be loaded, the recommended approach is to
-        * return <code>true</code> here and wait for index to be called, possibly
-        * returning without processing if the node should not be indexed. While
-        * not strictly a requirement, this avoids to open sessions in the indexer,
-        * centralizing such tasks in the caller.
-        */
-       public Boolean support(String path);
-
-       /**
-        * Adds the metadata. This is the responsibility of the caller to save the
-        * underlying session.
-        */
-       public void index(Node node);
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexerVisitor.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexerVisitor.java
deleted file mode 100644 (file)
index c0f90d1..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.argeo.slc.repo;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.ItemVisitor;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-
-/**
- * Recursively visit a sub tree and apply the list of node indexer on supported
- * nodes.
- */
-public class NodeIndexerVisitor implements ItemVisitor {
-       /** order may be important */
-       private List<NodeIndexer> nodeIndexers = new ArrayList<NodeIndexer>();
-
-       public NodeIndexerVisitor() {
-       }
-
-       /** Convenience constructor */
-       public NodeIndexerVisitor(NodeIndexer nodeIndexer) {
-               nodeIndexers.add(nodeIndexer);
-       }
-
-       public NodeIndexerVisitor(List<NodeIndexer> nodeIndexers) {
-               this.nodeIndexers = nodeIndexers;
-       }
-
-       public void visit(Node node) throws RepositoryException {
-               for (NodeIndexer nodeIndexer : nodeIndexers)
-                       if (nodeIndexer.support(node.getPath()))
-                               nodeIndexer.index(node);
-
-               for (NodeIterator it = node.getNodes(); it.hasNext();)
-                       visit(it.nextNode());
-       }
-
-       public void visit(Property property) throws RepositoryException {
-       }
-
-       public void setNodeIndexers(List<NodeIndexer> nodeIndexers) {
-               this.nodeIndexers = nodeIndexers;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiBundlesProvider.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiBundlesProvider.java
deleted file mode 100644 (file)
index de5f03c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.repo;
-
-import java.util.List;
-
-/**
- * Provides OSGi bundles either by linking to them, by wrapping existing
- * archives or by building them.
- */
-public interface OsgiBundlesProvider {
-       /** The provided bundles in the order they will be retrieved/wrapped/built. */
-       public List<ArtifactDistribution> provides();
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiFactory.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiFactory.java
deleted file mode 100644 (file)
index 8178493..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.argeo.slc.repo;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-/** OSGi Factory */
-public interface OsgiFactory {
-       public Session openJavaSession() throws RepositoryException;
-
-       public Session openDistSession() throws RepositoryException;
-
-       public void indexNode(Node node);
-
-       /**
-        * Provide access to a third party archive in the 'dist' repository,
-        * downloading it if it is not available.
-        */
-       public Node getDist(Session distSession, String uri)
-                       throws RepositoryException;
-
-       /**
-        * Provide access to a cached maven ardifact identified by its coordinates
-        * the 'dist' repository, downloading it if it is not available.
-        */
-       public Node getMaven(Session distSession, String coords)
-                       throws RepositoryException;
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/PdeSourcesIndexer.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/PdeSourcesIndexer.java
deleted file mode 100644 (file)
index 0ce3ba9..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.argeo.slc.repo;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.maven.AetherUtils;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-/**
- * Creates pde sources from a source {@link Artifact} with name
- * "...-sources.jar"
- */
-public class PdeSourcesIndexer implements NodeIndexer {
-       private Log log = LogFactory.getLog(PdeSourcesIndexer.class);
-
-       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
-
-       // private ArtifactIndexer artifactIndexer;
-       // private JarFileIndexer jarFileIndexer;
-
-       // public PdeSourcesIndexer(){
-       // // ArtifactIndexer artifactIndexer,
-       // // JarFileIndexer jarFileIndexer) {
-       // // this.artifactIndexer = artifactIndexer;
-       // // this.jarFileIndexer = jarFileIndexer;
-       // }
-
-       public Boolean support(String path) {
-               // TODO implement clean management of same name siblings
-               String name = FilenameUtils.getBaseName(path);
-               // int lastInd = name.lastIndexOf("[");
-               // if (lastInd != -1)
-               // name = name.substring(0, lastInd);
-               return name.endsWith("-sources") && FilenameUtils.getExtension(path).equals("jar");
-       }
-
-       public void index(Node sourcesNode) {
-               try {
-                       if (!support(sourcesNode.getPath()))
-                               return;
-
-                       packageSourcesAsPdeSource(sourcesNode);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot generate pde sources for node " + sourcesNode, e);
-               }
-       }
-
-       protected void packageSourcesAsPdeSource(Node sourcesNode) {
-               Binary origBinary = null;
-               Binary osgiBinary = null;
-               try {
-                       Session session = sourcesNode.getSession();
-                       Artifact sourcesArtifact = AetherUtils.convertPathToArtifact(sourcesNode.getPath(), null);
-
-                       // read name version from manifest
-                       Artifact osgiArtifact = new DefaultArtifact(sourcesArtifact.getGroupId(), sourcesArtifact.getArtifactId(),
-                                       sourcesArtifact.getExtension(), sourcesArtifact.getVersion());
-                       String osgiPath = MavenConventionsUtils.artifactPath(artifactBasePath, osgiArtifact);
-                       osgiBinary = session.getNode(osgiPath).getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary();
-
-                       NameVersion nameVersion = RepoUtils.readNameVersion(osgiBinary.getStream());
-                       if (nameVersion == null) {
-                               log.warn("Cannot package PDE sources for " + osgiPath + " as it is probably not an OSGi bundle");
-                               return;
-                       }
-
-                       // create PDe sources artifact
-                       Artifact pdeSourceArtifact = new DefaultArtifact(sourcesArtifact.getGroupId(),
-                                       sourcesArtifact.getArtifactId() + ".source", sourcesArtifact.getExtension(),
-                                       sourcesArtifact.getVersion());
-                       String targetSourceParentPath = MavenConventionsUtils.artifactParentPath(artifactBasePath,
-                                       pdeSourceArtifact);
-                       String targetSourceFileName = MavenConventionsUtils.artifactFileName(pdeSourceArtifact);
-                       // String targetSourceJarPath = targetSourceParentPath + '/'
-                       // + targetSourceFileName;
-
-                       Node targetSourceParentNode = JcrUtils.mkfolders(session, targetSourceParentPath);
-                       origBinary = sourcesNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary();
-                       byte[] targetJarBytes = RepoUtils.packageAsPdeSource(origBinary.getStream(), nameVersion);
-                       JcrUtils.copyBytesAsFile(targetSourceParentNode, targetSourceFileName, targetJarBytes);
-
-                       // reindex
-                       // Automagically done via the various listeners or manually
-                       // triggered.
-                       // Node targetSourceJarNode = session.getNode(targetSourceJarPath);
-                       // artifactIndexer.index(targetSourceJarNode);
-                       // jarFileIndexer.index(targetSourceJarNode);
-                       if (log.isTraceEnabled())
-                               log.trace("Created pde source artifact " + pdeSourceArtifact + " from " + sourcesNode);
-
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot add PDE sources for " + sourcesNode, e);
-               } finally {
-                       JcrUtils.closeQuietly(origBinary);
-                       JcrUtils.closeQuietly(osgiBinary);
-               }
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java
deleted file mode 100644 (file)
index 0645664..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.argeo.slc.repo;
-
-import org.argeo.api.NodeConstants;
-
-/** SLC repository constants */
-public interface RepoConstants {
-       String DEFAULT_JAVA_REPOSITORY_ALIAS = "java";
-       String DEFAULT_JAVA_REPOSITORY_LABEL = "Internal Java Repository";
-
-
-       String DEFAULT_ARTIFACTS_BASE_PATH = "/";
-       String REPO_BASEPATH = "/slc:repo";
-       String PROXIED_REPOSITORIES = REPO_BASEPATH + "/slc:sources";
-       String DISTRIBUTIONS_BASE_PATH = REPO_BASEPATH + "/slc:distributions";
-       String REPOSITORIES_BASE_PATH = REPO_BASEPATH + "/slc:repositories";
-       String DIST_DOWNLOAD_BASEPATH = "/download";
-
-       String BINARIES_ARTIFACT_ID = "binaries";
-       String SOURCES_ARTIFACT_ID = "sources";
-       String SDK_ARTIFACT_ID = "sdk";
-
-       // TODO might exists somewhere else
-       String SLC_CATEGORY_ID = "SLC-Category";
-
-       // TODO find a more generic way
-       String DEFAULT_DEFAULT_WORKSPACE = NodeConstants.SYS_WORKSPACE;
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoService.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoService.java
deleted file mode 100644 (file)
index 9b9bc66..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.argeo.slc.repo;
-
-import javax.jcr.Session;
-
-/** Start factorisation of the session management using a manager service */
-public interface RepoService {
-
-       /**
-        * Returns a corresponding session given the current context. Caller must
-        * close the session once it has been used
-        */
-       public Session getRemoteSession(String repoNodePath, String uri,
-                       String workspaceName);
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java
deleted file mode 100644 (file)
index 2eb532e..0000000
+++ /dev/null
@@ -1,590 +0,0 @@
-package org.argeo.slc.repo;
-
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import javax.jcr.Binary;
-import javax.jcr.Credentials;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.PropertyType;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryResult;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.api.NodeUtils;
-import org.argeo.slc.SlcException;
-import org.xml.sax.SAXException;
-
-/**
- * Synchronise workspaces from a remote software repository to the local
- * repository (Synchronisation in the other direction does not work).
- * 
- * Workspaces are retrieved by name given a map that links the source with a
- * target name. If a target workspace does not exist, it is created. Otherwise
- * we copy the content of the source workspace into the target one.
- */
-public class RepoSync implements Runnable {
-       private final static Log log = LogFactory.getLog(RepoSync.class);
-
-       // Centralizes definition of workspaces that must be ignored by the sync.
-       private final static List<String> IGNORED_WKSP_LIST = Arrays.asList("security", "localrepo");
-
-       private final Calendar zero;
-       private Session sourceDefaultSession = null;
-       private Session targetDefaultSession = null;
-
-       private Repository sourceRepository;
-       private Credentials sourceCredentials;
-       private Repository targetRepository;
-       private Credentials targetCredentials;
-
-       // if Repository and Credentials objects are not explicitly set
-       private String sourceRepoUri;
-       private String sourceUsername;
-       private char[] sourcePassword;
-       private String targetRepoUri;
-       private String targetUsername;
-       private char[] targetPassword;
-
-       private RepositoryFactory repositoryFactory;
-
-       private JcrMonitor monitor;
-       private Map<String, String> workspaceMap;
-
-       // TODO fix monitor
-       private Boolean filesOnly = false;
-
-       public RepoSync() {
-               zero = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
-               zero.setTimeInMillis(0);
-       }
-
-       /**
-        * 
-        * Shortcut to instantiate a RepoSync with already known repositories and
-        * credentials.
-        * 
-        * @param sourceRepository
-        * @param sourceCredentials
-        * @param targetRepository
-        * @param targetCredentials
-        */
-       public RepoSync(Repository sourceRepository, Credentials sourceCredentials, Repository targetRepository,
-                       Credentials targetCredentials) {
-               this();
-               this.sourceRepository = sourceRepository;
-               this.sourceCredentials = sourceCredentials;
-               this.targetRepository = targetRepository;
-               this.targetCredentials = targetCredentials;
-       }
-
-       public void run() {
-               try {
-                       long begin = System.currentTimeMillis();
-
-                       // Setup
-                       if (sourceRepository == null)
-                               sourceRepository = NodeUtils.getRepositoryByUri(repositoryFactory, sourceRepoUri);
-                       if (sourceCredentials == null && sourceUsername != null)
-                               sourceCredentials = new SimpleCredentials(sourceUsername, sourcePassword);
-                       // FIXME make it more generic
-                       sourceDefaultSession = sourceRepository.login(sourceCredentials, RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
-
-                       if (targetRepository == null)
-                               targetRepository = NodeUtils.getRepositoryByUri(repositoryFactory, targetRepoUri);
-                       if (targetCredentials == null && targetUsername != null)
-                               targetCredentials = new SimpleCredentials(targetUsername, targetPassword);
-                       targetDefaultSession = targetRepository.login(targetCredentials);
-
-                       Map<String, Exception> errors = new HashMap<String, Exception>();
-                       for (String sourceWorkspaceName : sourceDefaultSession.getWorkspace().getAccessibleWorkspaceNames()) {
-                               if (monitor != null && monitor.isCanceled())
-                                       break;
-
-                               if (workspaceMap != null && !workspaceMap.containsKey(sourceWorkspaceName))
-                                       continue;
-                               if (IGNORED_WKSP_LIST.contains(sourceWorkspaceName))
-                                       continue;
-
-                               Session sourceSession = null;
-                               Session targetSession = null;
-                               String targetWorkspaceName = workspaceMap.get(sourceWorkspaceName);
-                               try {
-                                       try {
-                                               targetSession = targetRepository.login(targetCredentials, targetWorkspaceName);
-                                       } catch (NoSuchWorkspaceException e) {
-                                               targetDefaultSession.getWorkspace().createWorkspace(targetWorkspaceName);
-                                               targetSession = targetRepository.login(targetCredentials, targetWorkspaceName);
-                                       }
-                                       sourceSession = sourceRepository.login(sourceCredentials, sourceWorkspaceName);
-                                       syncWorkspace(sourceSession, targetSession);
-                               } catch (Exception e) {
-                                       errors.put("Could not sync workspace " + sourceWorkspaceName, e);
-                                       if (log.isErrorEnabled())
-                                               e.printStackTrace();
-
-                               } finally {
-                                       JcrUtils.logoutQuietly(sourceSession);
-                                       JcrUtils.logoutQuietly(targetSession);
-                               }
-                       }
-
-                       if (monitor != null && monitor.isCanceled())
-                               log.info("Sync has been canceled by user");
-
-                       long duration = (System.currentTimeMillis() - begin) / 1000;// s
-                       log.info("Sync " + sourceRepoUri + " to " + targetRepoUri + " in " + (duration / 60)
-
-                                       + "min " + (duration % 60) + "s");
-
-                       if (errors.size() > 0) {
-                               throw new SlcException("Sync failed " + errors);
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot sync " + sourceRepoUri + " to " + targetRepoUri, e);
-               } finally {
-                       JcrUtils.logoutQuietly(sourceDefaultSession);
-                       JcrUtils.logoutQuietly(targetDefaultSession);
-               }
-       }
-
-       private long getNodesNumber(Session session) {
-               if (IGNORED_WKSP_LIST.contains(session.getWorkspace().getName()))
-                       return 0l;
-               try {
-                       Query countQuery = session.getWorkspace().getQueryManager().createQuery(
-                                       "select file from [" + (true ? NodeType.NT_FILE : NodeType.NT_BASE) + "] as file", Query.JCR_SQL2);
-
-                       QueryResult result = countQuery.execute();
-                       Long expectedCount = result.getNodes().getSize();
-                       return expectedCount;
-               } catch (RepositoryException e) {
-                       throw new SlcException("Unexpected error while computing " + "the size of the fetch for workspace "
-                                       + session.getWorkspace().getName(), e);
-               }
-       }
-
-       protected void syncWorkspace(Session sourceSession, Session targetSession) {
-               if (monitor != null) {
-                       monitor.beginTask("Computing fetch size...", -1);
-                       Long totalAmount = getNodesNumber(sourceSession);
-                       monitor.beginTask("Fetch", totalAmount.intValue());
-               }
-
-               try {
-                       String msg = "Synchronizing workspace: " + sourceSession.getWorkspace().getName();
-                       if (monitor != null)
-                               monitor.setTaskName(msg);
-                       if (log.isDebugEnabled())
-                               log.debug(msg);
-
-                       for (NodeIterator it = sourceSession.getRootNode().getNodes(); it.hasNext();) {
-                               Node node = it.nextNode();
-                               if (node.getName().contains(":"))
-                                       continue;
-                               if (node.getName().equals("download"))
-                                       continue;
-                               if (!node.isNodeType(NodeType.NT_HIERARCHY_NODE))
-                                       continue;
-                               syncNode(node, targetSession);
-                       }
-                       // if (filesOnly) {
-                       // JcrUtils.copyFiles(sourceSession.getRootNode(), targetSession.getRootNode(),
-                       // true, monitor);
-                       // } else {
-                       // for (NodeIterator it = sourceSession.getRootNode().getNodes(); it.hasNext();)
-                       // {
-                       // Node node = it.nextNode();
-                       // if (node.getName().equals("jcr:system"))
-                       // continue;
-                       // syncNode(node, targetSession);
-                       // }
-                       // }
-                       if (log.isDebugEnabled())
-                               log.debug("Synced " + sourceSession.getWorkspace().getName());
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       throw new SlcException("Cannot sync " + sourceSession.getWorkspace().getName() + " to "
-                                       + targetSession.getWorkspace().getName(), e);
-               }
-       }
-
-       /** factorizes monitor management */
-       private void updateMonitor(String msg) {
-               updateMonitor(msg, false);
-       }
-
-       protected void syncNode(Node sourceNode, Session targetSession) throws RepositoryException, SAXException {
-               if (filesOnly) {
-                       Node targetNode;
-                       if (targetSession.itemExists(sourceNode.getPath()))
-                               targetNode = targetSession.getNode(sourceNode.getPath());
-                       else
-                               targetNode = JcrUtils.mkdirs(targetSession, sourceNode.getPath(), NodeType.NT_FOLDER);
-                       JcrUtils.copyFiles(sourceNode, targetNode, true, monitor, true);
-                       return;
-               }
-               // Boolean singleLevel = singleLevel(sourceNode);
-               try {
-                       if (monitor != null && monitor.isCanceled()) {
-                               updateMonitor("Fetched has been canceled, " + "process is terminating");
-                               return;
-                       }
-
-                       Node targetParentNode = targetSession.getNode(sourceNode.getParent().getPath());
-                       Node targetNode;
-                       if (monitor != null && sourceNode.isNodeType(NodeType.NT_HIERARCHY_NODE))
-                               monitor.subTask("Process " + sourceNode.getPath());
-
-                       final Boolean isNew;
-                       if (!targetSession.itemExists(sourceNode.getPath())) {
-                               isNew = true;
-                               targetNode = targetParentNode.addNode(sourceNode.getName(), sourceNode.getPrimaryNodeType().getName());
-                       } else {
-                               isNew = false;
-                               targetNode = targetSession.getNode(sourceNode.getPath());
-                               if (!targetNode.getPrimaryNodeType().getName().equals(sourceNode.getPrimaryNodeType().getName()))
-                                       targetNode.setPrimaryType(sourceNode.getPrimaryNodeType().getName());
-                       }
-
-                       // export
-                       // sourceNode.getSession().exportSystemView(sourceNode.getPath(),
-                       // contentHandler, false, singleLevel);
-
-                       // if (singleLevel) {
-                       // if (targetSession.hasPendingChanges()) {
-                       // // updateMonitor(
-                       // // (isNew ? "Added " : "Updated ") + targetNode.getPath(),
-                       // // true);
-                       // if (doSave)
-                       // targetSession.save();
-                       // } else {
-                       // // updateMonitor("Checked " + targetNode.getPath(), false);
-                       // }
-                       // }
-
-                       // mixin and properties
-                       for (NodeType nt : sourceNode.getMixinNodeTypes()) {
-                               if (!targetNode.isNodeType(nt.getName()) && targetNode.canAddMixin(nt.getName()))
-                                       targetNode.addMixin(nt.getName());
-                       }
-                       copyProperties(sourceNode, targetNode);
-
-                       // next level
-                       NodeIterator ni = sourceNode.getNodes();
-                       while (ni != null && ni.hasNext()) {
-                               Node sourceChild = ni.nextNode();
-                               syncNode(sourceChild, targetSession);
-                       }
-
-                       copyTimestamps(sourceNode, targetNode);
-
-                       if (sourceNode.isNodeType(NodeType.NT_HIERARCHY_NODE)) {
-                               if (targetSession.hasPendingChanges()) {
-                                       if (sourceNode.isNodeType(NodeType.NT_FILE))
-                                               updateMonitor((isNew ? "Added " : "Updated ") + targetNode.getPath(), true);
-                                       // if (doSave)
-                                       targetSession.save();
-                               } else {
-                                       if (sourceNode.isNodeType(NodeType.NT_FILE))
-                                               updateMonitor("Checked " + targetNode.getPath(), false);
-                               }
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot sync source node " + sourceNode, e);
-               }
-       }
-
-       private void copyTimestamps(Node sourceNode, Node targetNode) throws RepositoryException {
-               if (sourceNode.getDefinition().isProtected())
-                       return;
-               if (targetNode.getDefinition().isProtected())
-                       return;
-               copyTimestamp(sourceNode, targetNode, Property.JCR_CREATED);
-               copyTimestamp(sourceNode, targetNode, Property.JCR_CREATED_BY);
-               copyTimestamp(sourceNode, targetNode, Property.JCR_LAST_MODIFIED);
-               copyTimestamp(sourceNode, targetNode, Property.JCR_LAST_MODIFIED_BY);
-       }
-
-       private void copyTimestamp(Node sourceNode, Node targetNode, String property) throws RepositoryException {
-               if (sourceNode.hasProperty(property)) {
-                       Property p = sourceNode.getProperty(property);
-                       if (p.getDefinition().isProtected())
-                               return;
-                       if (targetNode.hasProperty(property)
-                                       && targetNode.getProperty(property).getValue().equals(sourceNode.getProperty(property).getValue()))
-                               return;
-                       targetNode.setProperty(property, sourceNode.getProperty(property).getValue());
-               }
-       }
-
-       private void copyProperties(Node sourceNode, Node targetNode) throws RepositoryException {
-               properties: for (PropertyIterator pi = sourceNode.getProperties(); pi.hasNext();) {
-                       Property p = pi.nextProperty();
-                       if (p.getDefinition().isProtected())
-                               continue properties;
-                       if (p.getName().equals(Property.JCR_CREATED) || p.getName().equals(Property.JCR_CREATED_BY)
-                                       || p.getName().equals(Property.JCR_LAST_MODIFIED)
-                                       || p.getName().equals(Property.JCR_LAST_MODIFIED_BY))
-                               continue properties;
-
-                       if (p.getType() == PropertyType.BINARY) {
-                               copyBinary(p, targetNode);
-                       } else {
-
-                               if (p.isMultiple()) {
-                                       if (!targetNode.hasProperty(p.getName())
-                                                       || !Arrays.equals(targetNode.getProperty(p.getName()).getValues(), p.getValues()))
-                                               targetNode.setProperty(p.getName(), p.getValues());
-                               } else {
-                                       if (!targetNode.hasProperty(p.getName())
-                                                       || !targetNode.getProperty(p.getName()).getValue().equals(p.getValue()))
-                                               targetNode.setProperty(p.getName(), p.getValue());
-                               }
-                       }
-               }
-       }
-
-       private static void copyBinary(Property p, Node targetNode) throws RepositoryException {
-               InputStream in = null;
-               Binary sourceBinary = null;
-               Binary targetBinary = null;
-               try {
-                       sourceBinary = p.getBinary();
-                       if (targetNode.hasProperty(p.getName()))
-                               targetBinary = targetNode.getProperty(p.getName()).getBinary();
-
-                       // optim FIXME make it more configurable
-                       if (targetBinary != null)
-                               if (sourceBinary.getSize() == targetBinary.getSize()) {
-                                       if (log.isTraceEnabled())
-                                               log.trace("Skipped " + p.getPath());
-                                       return;
-                               }
-
-                       in = sourceBinary.getStream();
-                       targetBinary = targetNode.getSession().getValueFactory().createBinary(in);
-                       targetNode.setProperty(p.getName(), targetBinary);
-               } catch (Exception e) {
-                       throw new SlcException("Could not transfer " + p, e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-                       JcrUtils.closeQuietly(sourceBinary);
-                       JcrUtils.closeQuietly(targetBinary);
-               }
-       }
-
-       /** factorizes monitor management */
-       private void updateMonitor(String msg, Boolean doLog) {
-               if (doLog && log.isDebugEnabled())
-                       log.debug(msg);
-               if (monitor != null) {
-                       monitor.worked(1);
-                       monitor.subTask(msg);
-               }
-       }
-
-       // private void syncNode_old(Node sourceNode, Node targetParentNode)
-       // throws RepositoryException, SAXException {
-       //
-       // // enable cancelation of the current fetch process
-       // // fxme insure the repository stays in a stable state
-       // if (monitor != null && monitor.isCanceled()) {
-       // updateMonitor("Fetched has been canceled, "
-       // + "process is terminating");
-       // return;
-       // }
-       //
-       // Boolean noRecurse = singleLevel(sourceNode);
-       // Calendar sourceLastModified = null;
-       // if (sourceNode.isNodeType(NodeType.MIX_LAST_MODIFIED)) {
-       // sourceLastModified = sourceNode.getProperty(
-       // Property.JCR_LAST_MODIFIED).getDate();
-       // }
-       //
-       // if (sourceNode.getDefinition().isProtected())
-       // log.warn(sourceNode + " is protected.");
-       //
-       // if (!targetParentNode.hasNode(sourceNode.getName())) {
-       // String msg = "Adding " + sourceNode.getPath();
-       // updateMonitor(msg);
-       // if (log.isDebugEnabled())
-       // log.debug(msg);
-       // ContentHandler contentHandler = targetParentNode
-       // .getSession()
-       // .getWorkspace()
-       // .getImportContentHandler(targetParentNode.getPath(),
-       // ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
-       // sourceNode.getSession().exportSystemView(sourceNode.getPath(),
-       // contentHandler, false, noRecurse);
-       // } else {
-       // Node targetNode = targetParentNode.getNode(sourceNode.getName());
-       // if (sourceLastModified != null) {
-       // Calendar targetLastModified = null;
-       // if (targetNode.isNodeType(NodeType.MIX_LAST_MODIFIED)) {
-       // targetLastModified = targetNode.getProperty(
-       // Property.JCR_LAST_MODIFIED).getDate();
-       // }
-       //
-       // if (targetLastModified == null
-       // || targetLastModified.before(sourceLastModified)) {
-       // String msg = "Updating " + targetNode.getPath();
-       // updateMonitor(msg);
-       // if (log.isDebugEnabled())
-       // log.debug(msg);
-       // ContentHandler contentHandler = targetParentNode
-       // .getSession()
-       // .getWorkspace()
-       // .getImportContentHandler(
-       // targetParentNode.getPath(),
-       // ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
-       // sourceNode.getSession().exportSystemView(
-       // sourceNode.getPath(), contentHandler, false,
-       // noRecurse);
-       // } else {
-       // String msg = "Skipped up to date " + targetNode.getPath();
-       // updateMonitor(msg);
-       // if (log.isDebugEnabled())
-       // log.debug(msg);
-       // return;
-       // }
-       // }
-       // }
-       //
-       // if (noRecurse) {
-       // // recurse
-       // Node targetNode = targetParentNode.getNode(sourceNode.getName());
-       // if (sourceLastModified != null) {
-       // Calendar zero = new GregorianCalendar();
-       // zero.setTimeInMillis(0);
-       // targetNode.setProperty(Property.JCR_LAST_MODIFIED, zero);
-       // targetNode.getSession().save();
-       // }
-       //
-       // for (NodeIterator it = sourceNode.getNodes(); it.hasNext();) {
-       // syncNode_old(it.nextNode(), targetNode);
-       // }
-       //
-       // if (sourceLastModified != null) {
-       // targetNode.setProperty(Property.JCR_LAST_MODIFIED,
-       // sourceLastModified);
-       // targetNode.getSession().save();
-       // }
-       // }
-       // }
-
-       protected Boolean singleLevel(Node sourceNode) throws RepositoryException {
-               if (sourceNode.isNodeType(NodeType.NT_FILE))
-                       return false;
-               return true;
-       }
-
-       /**
-        * Synchronises only one workspace, retrieved by name without changing its name.
-        */
-       public void setSourceWksp(String sourceWksp) {
-               if (sourceWksp != null && !sourceWksp.trim().equals("")) {
-                       Map<String, String> map = new HashMap<String, String>();
-                       map.put(sourceWksp, sourceWksp);
-                       setWkspMap(map);
-               }
-       }
-
-       /**
-        * Synchronises a map of workspaces that will be retrieved by name. If the
-        * target name is not defined (eg null or an empty string) for a given source
-        * workspace, we use the source name as target name.
-        */
-       public void setWkspMap(Map<String, String> workspaceMap) {
-               // clean the list to ease later use
-               this.workspaceMap = new HashMap<String, String>();
-               if (workspaceMap != null) {
-                       workspaceNames: for (String srcName : workspaceMap.keySet()) {
-                               String targetName = workspaceMap.get(srcName);
-
-                               // Sanity check
-                               if (srcName.trim().equals(""))
-                                       continue workspaceNames;
-                               if (targetName == null || "".equals(targetName.trim()))
-                                       targetName = srcName;
-                               this.workspaceMap.put(srcName, targetName);
-                       }
-               }
-               // clean the map to ease later use
-               if (this.workspaceMap.size() == 0)
-                       this.workspaceMap = null;
-       }
-
-       public void setMonitor(JcrMonitor monitor) {
-               this.monitor = monitor;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setSourceRepoUri(String sourceRepoUri) {
-               this.sourceRepoUri = sourceRepoUri;
-       }
-
-       public void setSourceUsername(String sourceUsername) {
-               this.sourceUsername = sourceUsername;
-       }
-
-       public void setSourcePassword(char[] sourcePassword) {
-               this.sourcePassword = sourcePassword;
-       }
-
-       public void setTargetRepoUri(String targetRepoUri) {
-               this.targetRepoUri = targetRepoUri;
-       }
-
-       public void setTargetUsername(String targetUsername) {
-               this.targetUsername = targetUsername;
-       }
-
-       public void setTargetPassword(char[] targetPassword) {
-               this.targetPassword = targetPassword;
-       }
-
-       public void setSourceRepository(Repository sourceRepository) {
-               this.sourceRepository = sourceRepository;
-       }
-
-       public void setSourceCredentials(Credentials sourceCredentials) {
-               this.sourceCredentials = sourceCredentials;
-       }
-
-       public void setTargetRepository(Repository targetRepository) {
-               this.targetRepository = targetRepository;
-       }
-
-       public void setTargetCredentials(Credentials targetCredentials) {
-               this.targetCredentials = targetCredentials;
-       }
-
-       public void setFilesOnly(Boolean filesOnly) {
-               this.filesOnly = filesOnly;
-       }
-
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoUtils.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoUtils.java
deleted file mode 100644 (file)
index a6dc5d9..0000000
+++ /dev/null
@@ -1,635 +0,0 @@
-package org.argeo.slc.repo;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import java.util.zip.ZipInputStream;
-
-import javax.jcr.Credentials;
-import javax.jcr.GuestCredentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.maven.ArtifactIdComparator;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.osgi.framework.Constants;
-
-/** Utilities around repo */
-public class RepoUtils implements ArgeoNames, SlcNames {
-       private final static Log log = LogFactory.getLog(RepoUtils.class);
-
-       /** Packages a regular sources jar as PDE source. */
-       public static void packagesAsPdeSource(File sourceFile,
-                       NameVersion nameVersion, OutputStream out) throws IOException {
-               if (isAlreadyPdeSource(sourceFile)) {
-                       FileInputStream in = new FileInputStream(sourceFile);
-                       IOUtils.copy(in, out);
-                       IOUtils.closeQuietly(in);
-               } else {
-                       String sourceSymbolicName = nameVersion.getName() + ".source";
-
-                       Manifest sourceManifest = null;
-                       sourceManifest = new Manifest();
-                       sourceManifest.getMainAttributes().put(
-                                       Attributes.Name.MANIFEST_VERSION, "1.0");
-                       sourceManifest.getMainAttributes().putValue("Bundle-SymbolicName",
-                                       sourceSymbolicName);
-                       sourceManifest.getMainAttributes().putValue("Bundle-Version",
-                                       nameVersion.getVersion());
-                       sourceManifest.getMainAttributes().putValue(
-                                       "Eclipse-SourceBundle",
-                                       nameVersion.getName() + ";version="
-                                                       + nameVersion.getVersion());
-                       copyJar(sourceFile, out, sourceManifest);
-               }
-       }
-
-       public static byte[] packageAsPdeSource(InputStream sourceJar,
-                       NameVersion nameVersion) {
-               String sourceSymbolicName = nameVersion.getName() + ".source";
-
-               Manifest sourceManifest = null;
-               sourceManifest = new Manifest();
-               sourceManifest.getMainAttributes().put(
-                               Attributes.Name.MANIFEST_VERSION, "1.0");
-               sourceManifest.getMainAttributes().putValue("Bundle-SymbolicName",
-                               sourceSymbolicName);
-               sourceManifest.getMainAttributes().putValue("Bundle-Version",
-                               nameVersion.getVersion());
-               sourceManifest.getMainAttributes().putValue("Eclipse-SourceBundle",
-                               nameVersion.getName() + ";version=" + nameVersion.getVersion());
-
-               return modifyManifest(sourceJar, sourceManifest);
-       }
-
-       /**
-        * Check whether the file as already been packaged as PDE source, in order
-        * not to mess with Jar signing
-        */
-       private static boolean isAlreadyPdeSource(File sourceFile) {
-               JarInputStream jarInputStream = null;
-
-               try {
-                       jarInputStream = new JarInputStream(new FileInputStream(sourceFile));
-
-                       Manifest manifest = jarInputStream.getManifest();
-                       Iterator<?> it = manifest.getMainAttributes().keySet().iterator();
-                       boolean res = false;
-                       // containsKey() does not work, iterating...
-                       while (it.hasNext())
-                               if (it.next().toString().equals("Eclipse-SourceBundle")) {
-                                       res = true;
-                                       break;
-                               }
-                       // boolean res = manifest.getMainAttributes().get(
-                       // "Eclipse-SourceBundle") != null;
-                       if (res)
-                               log.info(sourceFile + " is already a PDE source");
-                       return res;
-               } catch (Exception e) {
-                       // probably not a jar, skipping
-                       if (log.isDebugEnabled())
-                               log.debug("Skipping " + sourceFile + " because of "
-                                               + e.getMessage());
-                       return false;
-               } finally {
-                       IOUtils.closeQuietly(jarInputStream);
-               }
-       }
-
-       /**
-        * Copy a jar, replacing its manifest with the provided one
-        * 
-        * @param manifest
-        *            can be null
-        */
-       private static void copyJar(File source, OutputStream out, Manifest manifest)
-                       throws IOException {
-               JarFile sourceJar = null;
-               JarOutputStream output = null;
-               try {
-                       output = manifest != null ? new JarOutputStream(out, manifest)
-                                       : new JarOutputStream(out);
-                       sourceJar = new JarFile(source);
-
-                       entries: for (Enumeration<?> entries = sourceJar.entries(); entries
-                                       .hasMoreElements();) {
-                               JarEntry entry = (JarEntry) entries.nextElement();
-                               if (manifest != null
-                                               && entry.getName().equals("META-INF/MANIFEST.MF"))
-                                       continue entries;
-
-                               InputStream entryStream = sourceJar.getInputStream(entry);
-                               JarEntry newEntry = new JarEntry(entry.getName());
-                               // newEntry.setMethod(JarEntry.DEFLATED);
-                               output.putNextEntry(newEntry);
-                               IOUtils.copy(entryStream, output);
-                       }
-               } finally {
-                       IOUtils.closeQuietly(output);
-                       try {
-                               if (sourceJar != null)
-                                       sourceJar.close();
-                       } catch (IOException e) {
-                               // silent
-                       }
-               }
-       }
-
-       /** Copy a jar changing onlythe manifest */
-       public static void copyJar(InputStream in, OutputStream out,
-                       Manifest manifest) {
-               JarInputStream jarIn = null;
-               JarOutputStream jarOut = null;
-               try {
-                       jarIn = new JarInputStream(in);
-                       jarOut = new JarOutputStream(out, manifest);
-                       JarEntry jarEntry = null;
-                       while ((jarEntry = jarIn.getNextJarEntry()) != null) {
-                               if (!jarEntry.getName().equals("META-INF/MANIFEST.MF")) {
-                                       JarEntry newJarEntry = new JarEntry(jarEntry.getName());
-                                       jarOut.putNextEntry(newJarEntry);
-                                       IOUtils.copy(jarIn, jarOut);
-                                       jarIn.closeEntry();
-                                       jarOut.closeEntry();
-                               }
-                       }
-               } catch (IOException e) {
-                       throw new SlcException("Could not copy jar with MANIFEST "
-                                       + manifest.getMainAttributes(), e);
-               } finally {
-                       if (!(in instanceof ZipInputStream))
-                               IOUtils.closeQuietly(jarIn);
-                       IOUtils.closeQuietly(jarOut);
-               }
-       }
-
-       /** Reads a jar file, modify its manifest */
-       public static byte[] modifyManifest(InputStream in, Manifest manifest) {
-               ByteArrayOutputStream out = new ByteArrayOutputStream(200 * 1024);
-               try {
-                       copyJar(in, out, manifest);
-                       return out.toByteArray();
-               } finally {
-                       IOUtils.closeQuietly(out);
-               }
-       }
-
-       /** Read the OSGi {@link NameVersion} */
-       public static NameVersion readNameVersion(Artifact artifact) {
-               File artifactFile = artifact.getFile();
-               if (artifact.getExtension().equals("pom")) {
-                       // hack to process jars which weirdly appear as POMs
-                       File jarFile = new File(artifactFile.getParentFile(),
-                                       FilenameUtils.getBaseName(artifactFile.getPath()) + ".jar");
-                       if (jarFile.exists()) {
-                               log.warn("Use " + jarFile + " instead of " + artifactFile
-                                               + " for " + artifact);
-                               artifactFile = jarFile;
-                       }
-               }
-               return readNameVersion(artifactFile);
-       }
-
-       /** Read the OSGi {@link NameVersion} */
-       public static NameVersion readNameVersion(File artifactFile) {
-               try {
-                       return readNameVersion(new FileInputStream(artifactFile));
-               } catch (Exception e) {
-                       // probably not a jar, skipping
-                       if (log.isDebugEnabled()) {
-                               log.debug("Skipping " + artifactFile + " because of " + e);
-                               // e.printStackTrace();
-                       }
-               }
-               return null;
-       }
-
-       /** Read the OSGi {@link NameVersion} */
-       public static NameVersion readNameVersion(InputStream in) {
-               JarInputStream jarInputStream = null;
-               try {
-                       jarInputStream = new JarInputStream(in);
-                       return readNameVersion(jarInputStream.getManifest());
-               } catch (Exception e) {
-                       // probably not a jar, skipping
-                       if (log.isDebugEnabled()) {
-                               log.debug("Skipping because of " + e);
-                       }
-               } finally {
-                       IOUtils.closeQuietly(jarInputStream);
-               }
-               return null;
-       }
-
-       /** Read the OSGi {@link NameVersion} */
-       public static NameVersion readNameVersion(Manifest manifest) {
-               DefaultNameVersion nameVersion = new DefaultNameVersion();
-               nameVersion.setName(manifest.getMainAttributes().getValue(
-                               Constants.BUNDLE_SYMBOLICNAME));
-
-               // Skip additional specs such as
-               // ; singleton:=true
-               if (nameVersion.getName().indexOf(';') > -1) {
-                       nameVersion
-                                       .setName(new StringTokenizer(nameVersion.getName(), " ;")
-                                                       .nextToken());
-               }
-
-               nameVersion.setVersion(manifest.getMainAttributes().getValue(
-                               Constants.BUNDLE_VERSION));
-
-               return nameVersion;
-       }
-
-       /*
-        * DATA MODEL
-        */
-       /** The artifact described by this node */
-       public static Artifact asArtifact(Node node) throws RepositoryException {
-               if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
-                       // FIXME update data model to store packaging at this level
-                       String extension = "jar";
-                       return new DefaultArtifact(node.getProperty(SLC_GROUP_ID)
-                                       .getString(),
-                                       node.getProperty(SLC_ARTIFACT_ID).getString(), extension,
-                                       node.getProperty(SLC_ARTIFACT_VERSION).getString());
-               } else if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
-                       return new DefaultArtifact(node.getProperty(SLC_GROUP_ID)
-                                       .getString(),
-                                       node.getProperty(SLC_ARTIFACT_ID).getString(), node
-                                                       .getProperty(SLC_ARTIFACT_CLASSIFIER).getString(),
-                                       node.getProperty(SLC_ARTIFACT_EXTENSION).getString(), node
-                                                       .getProperty(SLC_ARTIFACT_VERSION).getString());
-               } else if (node.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
-                       return new DefaultArtifact(node.getProperty(SLC_CATEGORY)
-                                       .getString(), node.getProperty(SLC_NAME).getString(),
-                                       "jar", node.getProperty(SLC_VERSION).getString());
-               } else {
-                       throw new SlcException("Unsupported node type for " + node);
-               }
-       }
-
-       /**
-        * The path to the PDE source related to this artifact (or artifact version
-        * base). There may or there may not be a node at this location (the
-        * returned path will typically be used to test whether PDE sources are
-        * attached to this artifact).
-        */
-       public static String relatedPdeSourcePath(String artifactBasePath,
-                       Node artifactNode) throws RepositoryException {
-               Artifact artifact = asArtifact(artifactNode);
-               Artifact pdeSourceArtifact = new DefaultArtifact(artifact.getGroupId(),
-                               artifact.getArtifactId() + ".source", artifact.getExtension(),
-                               artifact.getVersion());
-               return MavenConventionsUtils.artifactPath(artifactBasePath,
-                               pdeSourceArtifact);
-       }
-
-       /**
-        * Copy this bytes array as an artifact, relative to the root of the
-        * repository (typically the workspace root node)
-        */
-       public static Node copyBytesAsArtifact(Node artifactsBase,
-                       Artifact artifact, byte[] bytes) throws RepositoryException {
-               String parentPath = MavenConventionsUtils.artifactParentPath(
-                               artifactsBase.getPath(), artifact);
-               Node folderNode = JcrUtils.mkfolders(artifactsBase.getSession(),
-                               parentPath);
-               return JcrUtils.copyBytesAsFile(folderNode,
-                               MavenConventionsUtils.artifactFileName(artifact), bytes);
-       }
-
-       private RepoUtils() {
-       }
-
-       /** If a source return the base bundle name, does not change otherwise */
-       public static String extractBundleNameFromSourceName(String sourceBundleName) {
-               if (sourceBundleName.endsWith(".source"))
-                       return sourceBundleName.substring(0, sourceBundleName.length()
-                                       - ".source".length());
-               else
-                       return sourceBundleName;
-       }
-
-       /*
-        * SOFTWARE REPOSITORIES
-        */
-
-       /** Retrieve repository based on information in the repo node */
-       public static Repository getRepository(RepositoryFactory repositoryFactory,
-                       Keyring keyring, Node repoNode) {
-               try {
-                       Repository repository;
-                       if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
-                               String uri = repoNode.getProperty(ARGEO_URI).getString();
-                               if (uri.startsWith("http")) {// http, https
-                                       repository = NodeUtils.getRepositoryByUri(
-                                                       repositoryFactory, uri);
-                               } else if (uri.startsWith("vm:")) {// alias
-                                       repository = NodeUtils.getRepositoryByUri(
-                                                       repositoryFactory, uri);
-                               } else {
-                                       throw new SlcException("Unsupported repository uri " + uri);
-                               }
-                               return repository;
-                       } else {
-                               throw new SlcException("Unsupported node type " + repoNode);
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot connect to repository " + repoNode,
-                                       e);
-               }
-       }
-
-       /**
-        * Reads credentials from node, using keyring if there is a password. Can
-        * return null if no credentials needed (local repo) at all, but returns
-        * {@link GuestCredentials} if user id is 'anonymous' .
-        */
-       public static Credentials getRepositoryCredentials(Keyring keyring,
-                       Node repoNode) {
-               try {
-                       if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
-                               if (!repoNode.hasProperty(ARGEO_USER_ID))
-                                       return null;
-
-                               String userId = repoNode.getProperty(ARGEO_USER_ID).getString();
-                               if (userId.equals("anonymous"))// FIXME hardcoded userId
-                                       return new GuestCredentials();
-                               char[] password = keyring.getAsChars(repoNode.getPath() + '/'
-                                               + ARGEO_PASSWORD);
-                               Credentials credentials = new SimpleCredentials(userId,
-                                               password);
-                               return credentials;
-                       } else {
-                               throw new SlcException("Unsupported node type " + repoNode);
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot connect to repository " + repoNode,
-                                       e);
-               }
-       }
-
-       /**
-        * Shortcut to retrieve a session given variable information: Handle the
-        * case where we only have an URI of the repository, that we want to connect
-        * as anonymous or the case of a identified connection to a local or remote
-        * repository.
-        * 
-        * Callers must close the session once it has been used
-        */
-       public static Session getRemoteSession(RepositoryFactory repositoryFactory,
-                       Keyring keyring, Node repoNode, String uri, String workspaceName) {
-               try {
-                       if (repoNode == null && uri == null)
-                               throw new SlcException(
-                                               "At least one of repoNode and uri must be defined");
-                       Repository currRepo = null;
-                       Credentials credentials = null;
-                       // Anonymous URI only workspace
-                       if (repoNode == null)
-                               // Anonymous
-                               currRepo = NodeUtils.getRepositoryByUri(repositoryFactory, uri);
-                       else {
-                               currRepo = RepoUtils.getRepository(repositoryFactory, keyring,
-                                               repoNode);
-                               credentials = RepoUtils.getRepositoryCredentials(keyring,
-                                               repoNode);
-                       }
-                       return currRepo.login(credentials, workspaceName);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot connect to workspace "
-                                       + workspaceName + " of repository " + repoNode
-                                       + " with URI " + uri, e);
-               }
-       }
-
-       /**
-        * Shortcut to retrieve a session on a remote Jrc Repository from
-        * information stored in a local argeo node or from an URI: Handle the case
-        * where we only have an URI of the repository, that we want to connect as
-        * anonymous or the case of a identified connection to a local or remote
-        * repository.
-        * 
-        * Callers must close the session once it has been used
-        */
-       public static Session getRemoteSession(RepositoryFactory repositoryFactory,
-                       Keyring keyring, Repository localRepository, String repoNodePath,
-                       String uri, String workspaceName) {
-               Session localSession = null;
-               Node repoNode = null;
-               try {
-                       localSession = localRepository.login();
-                       if (repoNodePath != null && localSession.nodeExists(repoNodePath))
-                               repoNode = localSession.getNode(repoNodePath);
-
-                       return RepoUtils.getRemoteSession(repositoryFactory, keyring,
-                                       repoNode, uri, workspaceName);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot log to workspace " + workspaceName
-                                       + " for repo defined in " + repoNodePath, e);
-               } finally {
-                       JcrUtils.logoutQuietly(localSession);
-               }
-       }
-
-       /**
-        * Write group indexes: 'binaries' lists all bundles and their versions,
-        * 'sources' list their sources, and 'sdk' aggregates both.
-        */
-       public static void writeGroupIndexes(Session session,
-                       String artifactBasePath, String groupId, String version,
-                       Set<Artifact> binaries, Set<Artifact> sources) {
-               try {
-                       Set<Artifact> indexes = new TreeSet<Artifact>(
-                                       new ArtifactIdComparator());
-                       Artifact binariesArtifact = writeIndex(session, artifactBasePath,
-                                       groupId, RepoConstants.BINARIES_ARTIFACT_ID, version,
-                                       binaries);
-                       indexes.add(binariesArtifact);
-                       if (sources != null) {
-                               Artifact sourcesArtifact = writeIndex(session,
-                                               artifactBasePath, groupId,
-                                               RepoConstants.SOURCES_ARTIFACT_ID, version, sources);
-                               indexes.add(sourcesArtifact);
-                       }
-                       // sdk
-                       writeIndex(session, artifactBasePath, groupId,
-                                       RepoConstants.SDK_ARTIFACT_ID, version, indexes);
-                       session.save();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot write indexes for group " + groupId,
-                                       e);
-               }
-       }
-
-       /** Write a group index. */
-       private static Artifact writeIndex(Session session,
-                       String artifactBasePath, String groupId, String artifactId,
-                       String version, Set<Artifact> artifacts) throws RepositoryException {
-               Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
-                               version);
-               String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
-                               artifacts, null);
-               Node node = RepoUtils.copyBytesAsArtifact(
-                               session.getNode(artifactBasePath), artifact, pom.getBytes());
-               addMavenChecksums(node);
-               return artifact;
-       }
-
-       /** Add files containing the SHA-1 and MD5 checksums. */
-       public static void addMavenChecksums(Node node) throws RepositoryException {
-               // TODO optimize
-               String sha = JcrUtils.checksumFile(node, "SHA-1");
-               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
-                               sha.getBytes());
-               String md5 = JcrUtils.checksumFile(node, "MD5");
-               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
-                               md5.getBytes());
-       }
-
-       /**
-        * Custom copy since the one in commons does not fit the needs when copying
-        * a workspace completely.
-        */
-       public static void copy(Node fromNode, Node toNode) {
-               copy(fromNode, toNode, null);
-       }
-
-       public static void copy(Node fromNode, Node toNode, JcrMonitor monitor) {
-               try {
-                       String fromPath = fromNode.getPath();
-                       if (monitor != null)
-                               monitor.subTask("copying node :" + fromPath);
-                       if (log.isDebugEnabled())
-                               log.debug("copy node :" + fromPath);
-
-                       // FIXME : small hack to enable specific workspace copy
-                       if (fromNode.isNodeType("rep:ACL")
-                                       || fromNode.isNodeType("rep:system")) {
-                               if (log.isTraceEnabled())
-                                       log.trace("node " + fromNode + " skipped");
-                               return;
-                       }
-
-                       // add mixins
-                       for (NodeType mixinType : fromNode.getMixinNodeTypes()) {
-                               toNode.addMixin(mixinType.getName());
-                       }
-
-                       // Double check
-                       for (NodeType mixinType : toNode.getMixinNodeTypes()) {
-                               if (log.isDebugEnabled())
-                                       log.debug(mixinType.getName());
-                       }
-
-                       // process properties
-                       PropertyIterator pit = fromNode.getProperties();
-                       properties: while (pit.hasNext()) {
-                               Property fromProperty = pit.nextProperty();
-                               String propName = fromProperty.getName();
-                               try {
-                                       String propertyName = fromProperty.getName();
-                                       if (toNode.hasProperty(propertyName)
-                                                       && toNode.getProperty(propertyName).getDefinition()
-                                                                       .isProtected())
-                                               continue properties;
-
-                                       if (fromProperty.getDefinition().isProtected())
-                                               continue properties;
-
-                                       if (propertyName.equals("jcr:created")
-                                                       || propertyName.equals("jcr:createdBy")
-                                                       || propertyName.equals("jcr:lastModified")
-                                                       || propertyName.equals("jcr:lastModifiedBy"))
-                                               continue properties;
-
-                                       if (fromProperty.isMultiple()) {
-                                               toNode.setProperty(propertyName,
-                                                               fromProperty.getValues());
-                                       } else {
-                                               toNode.setProperty(propertyName,
-                                                               fromProperty.getValue());
-                                       }
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot property " + propName, e);
-                               }
-                       }
-
-                       // recursively process children nodes
-                       NodeIterator nit = fromNode.getNodes();
-                       while (nit.hasNext()) {
-                               Node fromChild = nit.nextNode();
-                               Integer index = fromChild.getIndex();
-                               String nodeRelPath = fromChild.getName() + "[" + index + "]";
-                               Node toChild;
-                               if (toNode.hasNode(nodeRelPath))
-                                       toChild = toNode.getNode(nodeRelPath);
-                               else
-                                       toChild = toNode.addNode(fromChild.getName(), fromChild
-                                                       .getPrimaryNodeType().getName());
-                               copy(fromChild, toChild);
-                       }
-
-                       // update jcr:lastModified and jcr:lastModifiedBy in toNode in
-                       // case
-                       // they existed
-                       if (!toNode.getDefinition().isProtected()
-                                       && toNode.isNodeType(NodeType.MIX_LAST_MODIFIED))
-                               JcrUtils.updateLastModified(toNode);
-
-                       // Workaround to reduce session size: artifact is a saveable
-                       // unity
-                       if (toNode.isNodeType(SlcTypes.SLC_ARTIFACT))
-                               toNode.getSession().save();
-
-                       if (monitor != null)
-                               monitor.worked(1);
-
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot copy " + fromNode + " to " + toNode,
-                                       e);
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmIndexer.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmIndexer.java
deleted file mode 100644 (file)
index fadac82..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.argeo.slc.repo;
-
-import static org.redline_rpm.header.Header.HeaderTag.HEADERIMMUTABLE;
-import static org.redline_rpm.header.Signature.SignatureTag.SIGNATURES;
-
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.FilenameUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.redline_rpm.ChannelWrapper.Key;
-import org.redline_rpm.ReadableChannelWrapper;
-import org.redline_rpm.header.AbstractHeader;
-import org.redline_rpm.header.Format;
-import org.redline_rpm.header.Header;
-
-/** Indexes an RPM file. */
-public class RpmIndexer implements NodeIndexer, SlcNames {
-       private Boolean force = false;
-
-       @Override
-       public Boolean support(String path) {
-               return FilenameUtils.getExtension(path).equals("rpm");
-       }
-
-       @Override
-       public void index(Node node) {
-               try {
-                       if (!support(node.getPath()))
-                               return;
-
-                       // Already indexed
-                       if (!force && node.isNodeType(SlcTypes.SLC_RPM))
-                               return;
-
-                       if (!node.isNodeType(NodeType.NT_FILE))
-                               return;
-
-                       InputStream in = node.getNode(Node.JCR_CONTENT)
-                                       .getProperty(Property.JCR_DATA).getBinary().getStream();
-                       ReadableChannelWrapper channel = new ReadableChannelWrapper(
-                                       Channels.newChannel(in));
-                       Format format = readRpmInfo(channel);
-
-                       node.addMixin(SlcTypes.SLC_RPM);
-                       node.setProperty(SLC_NAME, readTag(format, Header.HeaderTag.NAME));
-                       String rpmVersion = readTag(format, Header.HeaderTag.VERSION);
-                       String rpmRelease = readTag(format, Header.HeaderTag.RELEASE);
-                       node.setProperty(SLC_RPM_VERSION, rpmVersion);
-                       node.setProperty(SLC_RPM_RELEASE, rpmRelease);
-                       node.setProperty(SLC_VERSION, rpmVersion + "-" + rpmRelease);
-
-                       String arch = readTag(format, Header.HeaderTag.ARCH);
-                       if (arch != null)
-                               node.setProperty(SLC_RPM_ARCH, arch);
-
-                       String archiveSize = readTag(format, Header.HeaderTag.ARCHIVESIZE);
-                       if (archiveSize != null)
-                               node.setProperty(SLC_RPM_ARCHIVE_SIZE,
-                                               Long.parseLong(archiveSize));
-
-                       node.getSession().save();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot index " + node, e);
-               }
-
-       }
-
-       @SuppressWarnings("unused")
-       public Format readRpmInfo(ReadableChannelWrapper channel) throws Exception {
-               Format format = new Format();
-
-               Key<Integer> lead = channel.start();
-               format.getLead().read(channel);
-               // System.out.println( "Lead ended at '" + in.finish( lead) + "'.");
-
-               Key<Integer> signature = channel.start();
-               int count = format.getSignature().read(channel);
-               int expected = ByteBuffer
-                               .wrap((byte[]) format.getSignature().getEntry(SIGNATURES)
-                                               .getValues(), 8, 4).getInt()
-                               / -16;
-               // System.out.println( "Signature ended at '" + in.finish( signature) +
-               // "' and contained '" + count + "' headers (expected '" + expected +
-               // "').");
-
-               Key<Integer> header = channel.start();
-               count = format.getHeader().read(channel);
-               expected = ByteBuffer.wrap(
-                               (byte[]) format.getHeader().getEntry(HEADERIMMUTABLE)
-                                               .getValues(), 8, 4).getInt()
-                               / -16;
-               // System.out.println( "Header ended at '" + in.finish( header) +
-               // " and contained '" + count + "' headers (expected '" + expected +
-               // "').");
-
-               return format;
-       }
-
-       private String readTag(Format format, Header.HeaderTag tag) {
-               AbstractHeader.Entry<?> entry = format.getHeader().getEntry(tag);
-               if (entry == null)
-                       return null;
-               if (entry.getValues() == null)
-                       return null;
-               Object[] values = (Object[]) entry.getValues();
-               return values[0].toString().trim();
-       }
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmRepoManager.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmRepoManager.java
deleted file mode 100644 (file)
index 7535468..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.repo;
-
-public interface RpmRepoManager {
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/SlcRepoManager.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/SlcRepoManager.java
deleted file mode 100644 (file)
index a0ba8e0..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.argeo.slc.repo;
-
-/** Coordinator of the various type of repository (Java, RPM, etc.) */
-public interface SlcRepoManager {
-       /** @return null if Java not supported. */
-       public JavaRepoManager getJavaRepoManager();
-
-       /** @return null if RPM not supported. */
-       public RpmRepoManager getRpmRepoManager();
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/AbstractJcrRepoManager.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/AbstractJcrRepoManager.java
deleted file mode 100644 (file)
index 4bdda83..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.argeo.slc.repo.core;
-
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.NodeIndexer;
-
-/** Generic operations on a JCR-based repo. */
-abstract class AbstractJcrRepoManager {
-       private final static Log log = LogFactory
-                       .getLog(AbstractJcrRepoManager.class);
-       private String securityWorkspace = "security";
-
-       private Repository jcrRepository;
-       private Session adminSession;
-       private List<NodeIndexer> nodeIndexers;
-
-       // registries
-       private Map<String, Session> workspaceSessions = new TreeMap<String, Session>();
-       private Map<String, WorkspaceIndexer> workspaceIndexers = new TreeMap<String, WorkspaceIndexer>();
-
-       public void init() {
-               try {
-                       adminSession = jcrRepository.login();
-                       String[] workspaceNames = adminSession.getWorkspace()
-                                       .getAccessibleWorkspaceNames();
-                       for (String workspaceName : workspaceNames) {
-                               if (workspaceName.equals(securityWorkspace))
-                                       continue;
-                               if (workspaceName.equals(adminSession.getWorkspace().getName()))
-                                       continue;
-                               workspaceInit(workspaceName);
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot initialize repo manager", e);
-               }
-       }
-
-       public void destroy() {
-               for (String key : workspaceIndexers.keySet()) {
-                       workspaceIndexers.get(key).close();
-               }
-
-               for (String key : workspaceSessions.keySet()) {
-                       JcrUtils.logoutQuietly(workspaceSessions.get(key));
-               }
-               JcrUtils.logoutQuietly(adminSession);
-       }
-
-       public void createWorkspace(String workspaceName) {
-               try {
-                       try {
-                               jcrRepository.login(workspaceName);
-                               throw new SlcException("Workspace " + workspaceName
-                                               + " exists already.");
-                       } catch (NoSuchWorkspaceException e) {
-                               // try to create workspace
-                               adminSession.getWorkspace().createWorkspace(workspaceName);
-                               workspaceInit(workspaceName);
-                       }
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot create workspace " + workspaceName,
-                                       e);
-               }
-       }
-
-       protected void workspaceInit(String workspaceName) {
-               Session workspaceAdminSession = null;
-               try {
-                       workspaceAdminSession = jcrRepository.login(workspaceName);
-                       workspaceSessions.put(workspaceName, adminSession);
-                       JcrUtils.addPrivilege(workspaceAdminSession, "/",
-                                       SlcConstants.ROLE_SLC, "jcr:all");
-                       WorkspaceIndexer workspaceIndexer = new WorkspaceIndexer(
-                                       workspaceAdminSession, nodeIndexers);
-                       workspaceIndexers.put(workspaceName, workspaceIndexer);
-               } catch (RepositoryException e) {
-                       log.error("Cannot initialize workspace " + workspaceName, e);
-               } finally {
-                       JcrUtils.logoutQuietly(workspaceAdminSession);
-               }
-       }
-
-       public void setJcrRepository(Repository jcrRepository) {
-               this.jcrRepository = jcrRepository;
-       }
-
-       public void setNodeIndexers(List<NodeIndexer> nodeIndexers) {
-               this.nodeIndexers = nodeIndexers;
-       }
-
-       public void setSecurityWorkspace(String securityWorkspace) {
-               this.securityWorkspace = securityWorkspace;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/JavaRepoManagerImpl.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/JavaRepoManagerImpl.java
deleted file mode 100644 (file)
index dfd0c8a..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc.repo.core;
-
-import org.argeo.slc.repo.JavaRepoManager;
-
-/** Java-specific operations */
-public class JavaRepoManagerImpl extends AbstractJcrRepoManager implements
-               JavaRepoManager {
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RepoServiceImpl.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RepoServiceImpl.java
deleted file mode 100644 (file)
index bca40cb..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.argeo.slc.repo.core;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.slc.repo.RepoService;
-import org.argeo.slc.repo.RepoUtils;
-
-/**
- * Work in Progress - enhance this. First implementation of a service that
- * centralizes session management in an argeo SLC context, repositories are
- * either defined using an URI and a workspace name in a anonymous context or
- * using connection information that are store in a corresponding node in the
- * local repository home
- */
-public class RepoServiceImpl implements RepoService {
-
-       /* DEPENDENCY INJECTION */
-       private Repository nodeRepository;
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-
-       public Session getRemoteSession(String repoNodePath, String uri,
-                       String workspaceName) {
-               return RepoUtils.getRemoteSession(repositoryFactory, keyring,
-                               nodeRepository, repoNodePath, uri, workspaceName);
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setNodeRepository(Repository nodeRepository) {
-               this.nodeRepository = nodeRepository;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RpmRepoManagerImpl.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RpmRepoManagerImpl.java
deleted file mode 100644 (file)
index 6e83523..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc.repo.core;
-
-import org.argeo.slc.repo.RpmRepoManager;
-
-/** RPM-specific operations */
-public class RpmRepoManagerImpl extends AbstractJcrRepoManager implements
-               RpmRepoManager {
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/SlcRepoManagerImpl.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/SlcRepoManagerImpl.java
deleted file mode 100644 (file)
index bce6f03..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.argeo.slc.repo.core;
-
-import org.argeo.slc.repo.JavaRepoManager;
-import org.argeo.slc.repo.RpmRepoManager;
-import org.argeo.slc.repo.SlcRepoManager;
-
-/** Coordinator of the various repositories. */
-public class SlcRepoManagerImpl implements SlcRepoManager {
-       private JavaRepoManager javaRepoManager;
-       private RpmRepoManager rpmRepoManager;
-
-       public void init() {
-
-       }
-
-       public void destroy() {
-
-       }
-
-       @Override
-       public JavaRepoManager getJavaRepoManager() {
-               return javaRepoManager;
-       }
-
-       public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
-               this.javaRepoManager = javaRepoManager;
-       }
-
-       @Override
-       public RpmRepoManager getRpmRepoManager() {
-               return rpmRepoManager;
-       }
-
-       public void setRpmRepoManager(RpmRepoManager rpmRepoManager) {
-               this.rpmRepoManager = rpmRepoManager;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/WorkspaceIndexer.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/core/WorkspaceIndexer.java
deleted file mode 100644 (file)
index d0233c3..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.argeo.slc.repo.core;
-
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventIterator;
-import javax.jcr.observation.EventListener;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.NodeIndexer;
-
-/** Maintains the metadata of a workspace, using listeners */
-public class WorkspaceIndexer {
-       private final static Log log = LogFactory.getLog(WorkspaceIndexer.class);
-
-       private final Session adminSession;
-       private IndexingListener artifactListener;
-       /** order may be important */
-       private final List<NodeIndexer> nodeIndexers;
-
-       public WorkspaceIndexer(Session adminSession, List<NodeIndexer> nodeIndexers) {
-               this.adminSession = adminSession;
-               this.nodeIndexers = nodeIndexers;
-               try {
-                       artifactListener = new IndexingListener();
-                       adminSession
-                                       .getWorkspace()
-                                       .getObservationManager()
-                                       .addEventListener(artifactListener, Event.NODE_ADDED, "/",
-                                                       true, null, null, true);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot initialize repository backend", e);
-               }
-       }
-
-       public void close() {
-               try {
-                       adminSession.getWorkspace().getObservationManager()
-                                       .removeEventListener(artifactListener);
-               } catch (RepositoryException e) {
-                       log.error("Cannot close workspace indexer "
-                                       + adminSession.getWorkspace().getName(), e);
-               }
-       }
-
-       class IndexingListener implements EventListener {
-
-               public void onEvent(EventIterator events) {
-                       while (events.hasNext()) {
-                               Event event = events.nextEvent();
-                               try {
-                                       String newNodePath = event.getPath();
-                                       Node newNode = null;
-                                       for (NodeIndexer nodeIndexer : nodeIndexers) {
-                                               try {
-                                                       if (nodeIndexer.support(newNodePath)) {
-                                                               if (newNode == null)
-                                                                       newNode = adminSession.getNode(newNodePath);
-                                                               nodeIndexer.index(newNode);
-                                                       }
-                                               } catch (RuntimeException e) {
-                                                       e.printStackTrace();
-                                                       throw e;
-                                               }
-                                       }
-                                       if (newNode != null)
-                                               adminSession.save();
-                               } catch (RepositoryException e) {
-                                       throw new SlcException("Cannot process event " + event, e);
-                               } finally {
-                                       JcrUtils.discardQuietly(adminSession);
-                               }
-                       }
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/AntPathMatcher.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/AntPathMatcher.java
deleted file mode 100644 (file)
index 20becbc..0000000
+++ /dev/null
@@ -1,424 +0,0 @@
-/*\r
- * Copyright 2002-2007 the original author or authors.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.argeo.slc.repo.internal.springutil;\r
-\r
-/**\r
- * PathMatcher implementation for Ant-style path patterns. Examples are provided\r
- * below.\r
- *\r
- * <p>\r
- * Part of this mapping code has been kindly borrowed from\r
- * <a href="http://ant.apache.org">Apache Ant</a>.\r
- *\r
- * <p>\r
- * The mapping matches URLs using the following rules:<br>\r
- * <ul>\r
- * <li>? matches one character</li>\r
- * <li>* matches zero or more characters</li>\r
- * <li>** matches zero or more 'directories' in a path</li>\r
- * </ul>\r
- *\r
- * <p>\r
- * Some examples:<br>\r
- * <ul>\r
- * <li><code>com/t?st.jsp</code> - matches <code>com/test.jsp</code> but also\r
- * <code>com/tast.jsp</code> or <code>com/txst.jsp</code></li>\r
- * <li><code>com/*.jsp</code> - matches all <code>.jsp</code> files in the\r
- * <code>com</code> directory</li>\r
- * <li><code>com/&#42;&#42;/test.jsp</code> - matches all <code>test.jsp</code>\r
- * files underneath the <code>com</code> path</li>\r
- * <li><code>org/springframework/&#42;&#42;/*.jsp</code> - matches all\r
- * <code>.jsp</code> files underneath the <code>org/springframework</code>\r
- * path</li>\r
- * <li><code>org/&#42;&#42;/servlet/bla.jsp</code> - matches\r
- * <code>org/springframework/servlet/bla.jsp</code> but also\r
- * <code>org/springframework/testing/servlet/bla.jsp</code> and\r
- * <code>org/servlet/bla.jsp</code></li>\r
- * </ul>\r
- *\r
- * @author Alef Arendsen\r
- * @author Juergen Hoeller\r
- * @author Rob Harrop\r
- * @since 16.07.2003\r
- */\r
-public class AntPathMatcher implements PathMatcher {\r
-\r
-       /** Default path separator: "/" */\r
-       public static final String DEFAULT_PATH_SEPARATOR = "/";\r
-\r
-       private String pathSeparator = DEFAULT_PATH_SEPARATOR;\r
-\r
-       /**\r
-        * Set the path separator to use for pattern parsing. Default is "/", as in Ant.\r
-        */\r
-       public void setPathSeparator(String pathSeparator) {\r
-               this.pathSeparator = (pathSeparator != null ? pathSeparator : DEFAULT_PATH_SEPARATOR);\r
-       }\r
-\r
-       public boolean isPattern(String path) {\r
-               return (path.indexOf('*') != -1 || path.indexOf('?') != -1);\r
-       }\r
-\r
-       public boolean match(String pattern, String path) {\r
-               return doMatch(pattern, path, true);\r
-       }\r
-\r
-       public boolean matchStart(String pattern, String path) {\r
-               return doMatch(pattern, path, false);\r
-       }\r
-\r
-       /**\r
-        * Actually match the given <code>path</code> against the given\r
-        * <code>pattern</code>.\r
-        * \r
-        * @param pattern   the pattern to match against\r
-        * @param path      the path String to test\r
-        * @param fullMatch whether a full pattern match is required (else a pattern\r
-        *                  match as far as the given base path goes is sufficient)\r
-        * @return <code>true</code> if the supplied <code>path</code> matched,\r
-        *         <code>false</code> if it didn't\r
-        */\r
-       protected boolean doMatch(String pattern, String path, boolean fullMatch) {\r
-               if (path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {\r
-                       return false;\r
-               }\r
-\r
-//             String[] pattDirs = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator);\r
-//             String[] pathDirs = StringUtils.tokenizeToStringArray(path, this.pathSeparator);\r
-               // mbaudier - 2020-03-13 : Use standard Java call:\r
-               String[] pattDirs = pattern.split(this.pathSeparator);\r
-               String[] pathDirs = path.split(this.pathSeparator);\r
-\r
-               int pattIdxStart = 0;\r
-               int pattIdxEnd = pattDirs.length - 1;\r
-               int pathIdxStart = 0;\r
-               int pathIdxEnd = pathDirs.length - 1;\r
-\r
-               // Match all elements up to the first **\r
-               while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {\r
-                       String patDir = pattDirs[pattIdxStart];\r
-                       if ("**".equals(patDir)) {\r
-                               break;\r
-                       }\r
-                       if (!matchStrings(patDir, pathDirs[pathIdxStart])) {\r
-                               return false;\r
-                       }\r
-                       pattIdxStart++;\r
-                       pathIdxStart++;\r
-               }\r
-\r
-               if (pathIdxStart > pathIdxEnd) {\r
-                       // Path is exhausted, only match if rest of pattern is * or **'s\r
-                       if (pattIdxStart > pattIdxEnd) {\r
-                               return (pattern.endsWith(this.pathSeparator) ? path.endsWith(this.pathSeparator)\r
-                                               : !path.endsWith(this.pathSeparator));\r
-                       }\r
-                       if (!fullMatch) {\r
-                               return true;\r
-                       }\r
-                       if (pattIdxStart == pattIdxEnd && pattDirs[pattIdxStart].equals("*") && path.endsWith(this.pathSeparator)) {\r
-                               return true;\r
-                       }\r
-                       for (int i = pattIdxStart; i <= pattIdxEnd; i++) {\r
-                               if (!pattDirs[i].equals("**")) {\r
-                                       return false;\r
-                               }\r
-                       }\r
-                       return true;\r
-               } else if (pattIdxStart > pattIdxEnd) {\r
-                       // String not exhausted, but pattern is. Failure.\r
-                       return false;\r
-               } else if (!fullMatch && "**".equals(pattDirs[pattIdxStart])) {\r
-                       // Path start definitely matches due to "**" part in pattern.\r
-                       return true;\r
-               }\r
-\r
-               // up to last '**'\r
-               while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {\r
-                       String patDir = pattDirs[pattIdxEnd];\r
-                       if (patDir.equals("**")) {\r
-                               break;\r
-                       }\r
-                       if (!matchStrings(patDir, pathDirs[pathIdxEnd])) {\r
-                               return false;\r
-                       }\r
-                       pattIdxEnd--;\r
-                       pathIdxEnd--;\r
-               }\r
-               if (pathIdxStart > pathIdxEnd) {\r
-                       // String is exhausted\r
-                       for (int i = pattIdxStart; i <= pattIdxEnd; i++) {\r
-                               if (!pattDirs[i].equals("**")) {\r
-                                       return false;\r
-                               }\r
-                       }\r
-                       return true;\r
-               }\r
-\r
-               while (pattIdxStart != pattIdxEnd && pathIdxStart <= pathIdxEnd) {\r
-                       int patIdxTmp = -1;\r
-                       for (int i = pattIdxStart + 1; i <= pattIdxEnd; i++) {\r
-                               if (pattDirs[i].equals("**")) {\r
-                                       patIdxTmp = i;\r
-                                       break;\r
-                               }\r
-                       }\r
-                       if (patIdxTmp == pattIdxStart + 1) {\r
-                               // '**/**' situation, so skip one\r
-                               pattIdxStart++;\r
-                               continue;\r
-                       }\r
-                       // Find the pattern between padIdxStart & padIdxTmp in str between\r
-                       // strIdxStart & strIdxEnd\r
-                       int patLength = (patIdxTmp - pattIdxStart - 1);\r
-                       int strLength = (pathIdxEnd - pathIdxStart + 1);\r
-                       int foundIdx = -1;\r
-\r
-                       strLoop: for (int i = 0; i <= strLength - patLength; i++) {\r
-                               for (int j = 0; j < patLength; j++) {\r
-                                       String subPat = (String) pattDirs[pattIdxStart + j + 1];\r
-                                       String subStr = (String) pathDirs[pathIdxStart + i + j];\r
-                                       if (!matchStrings(subPat, subStr)) {\r
-                                               continue strLoop;\r
-                                       }\r
-                               }\r
-                               foundIdx = pathIdxStart + i;\r
-                               break;\r
-                       }\r
-\r
-                       if (foundIdx == -1) {\r
-                               return false;\r
-                       }\r
-\r
-                       pattIdxStart = patIdxTmp;\r
-                       pathIdxStart = foundIdx + patLength;\r
-               }\r
-\r
-               for (int i = pattIdxStart; i <= pattIdxEnd; i++) {\r
-                       if (!pattDirs[i].equals("**")) {\r
-                               return false;\r
-                       }\r
-               }\r
-\r
-               return true;\r
-       }\r
-\r
-       /**\r
-        * Tests whether or not a string matches against a pattern. The pattern may\r
-        * contain two special characters:<br>\r
-        * '*' means zero or more characters<br>\r
-        * '?' means one and only one character\r
-        * \r
-        * @param pattern pattern to match against. Must not be <code>null</code>.\r
-        * @param str     string which must be matched against the pattern. Must not be\r
-        *                <code>null</code>.\r
-        * @return <code>true</code> if the string matches against the pattern, or\r
-        *         <code>false</code> otherwise.\r
-        */\r
-       private boolean matchStrings(String pattern, String str) {\r
-               char[] patArr = pattern.toCharArray();\r
-               char[] strArr = str.toCharArray();\r
-               int patIdxStart = 0;\r
-               int patIdxEnd = patArr.length - 1;\r
-               int strIdxStart = 0;\r
-               int strIdxEnd = strArr.length - 1;\r
-               char ch;\r
-\r
-               boolean containsStar = false;\r
-               for (int i = 0; i < patArr.length; i++) {\r
-                       if (patArr[i] == '*') {\r
-                               containsStar = true;\r
-                               break;\r
-                       }\r
-               }\r
-\r
-               if (!containsStar) {\r
-                       // No '*'s, so we make a shortcut\r
-                       if (patIdxEnd != strIdxEnd) {\r
-                               return false; // Pattern and string do not have the same size\r
-                       }\r
-                       for (int i = 0; i <= patIdxEnd; i++) {\r
-                               ch = patArr[i];\r
-                               if (ch != '?') {\r
-                                       if (ch != strArr[i]) {\r
-                                               return false;// Character mismatch\r
-                                       }\r
-                               }\r
-                       }\r
-                       return true; // String matches against pattern\r
-               }\r
-\r
-               if (patIdxEnd == 0) {\r
-                       return true; // Pattern contains only '*', which matches anything\r
-               }\r
-\r
-               // Process characters before first star\r
-               while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) {\r
-                       if (ch != '?') {\r
-                               if (ch != strArr[strIdxStart]) {\r
-                                       return false;// Character mismatch\r
-                               }\r
-                       }\r
-                       patIdxStart++;\r
-                       strIdxStart++;\r
-               }\r
-               if (strIdxStart > strIdxEnd) {\r
-                       // All characters in the string are used. Check if only '*'s are\r
-                       // left in the pattern. If so, we succeeded. Otherwise failure.\r
-                       for (int i = patIdxStart; i <= patIdxEnd; i++) {\r
-                               if (patArr[i] != '*') {\r
-                                       return false;\r
-                               }\r
-                       }\r
-                       return true;\r
-               }\r
-\r
-               // Process characters after last star\r
-               while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) {\r
-                       if (ch != '?') {\r
-                               if (ch != strArr[strIdxEnd]) {\r
-                                       return false;// Character mismatch\r
-                               }\r
-                       }\r
-                       patIdxEnd--;\r
-                       strIdxEnd--;\r
-               }\r
-               if (strIdxStart > strIdxEnd) {\r
-                       // All characters in the string are used. Check if only '*'s are\r
-                       // left in the pattern. If so, we succeeded. Otherwise failure.\r
-                       for (int i = patIdxStart; i <= patIdxEnd; i++) {\r
-                               if (patArr[i] != '*') {\r
-                                       return false;\r
-                               }\r
-                       }\r
-                       return true;\r
-               }\r
-\r
-               // process pattern between stars. padIdxStart and patIdxEnd point\r
-               // always to a '*'.\r
-               while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {\r
-                       int patIdxTmp = -1;\r
-                       for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {\r
-                               if (patArr[i] == '*') {\r
-                                       patIdxTmp = i;\r
-                                       break;\r
-                               }\r
-                       }\r
-                       if (patIdxTmp == patIdxStart + 1) {\r
-                               // Two stars next to each other, skip the first one.\r
-                               patIdxStart++;\r
-                               continue;\r
-                       }\r
-                       // Find the pattern between padIdxStart & padIdxTmp in str between\r
-                       // strIdxStart & strIdxEnd\r
-                       int patLength = (patIdxTmp - patIdxStart - 1);\r
-                       int strLength = (strIdxEnd - strIdxStart + 1);\r
-                       int foundIdx = -1;\r
-                       strLoop: for (int i = 0; i <= strLength - patLength; i++) {\r
-                               for (int j = 0; j < patLength; j++) {\r
-                                       ch = patArr[patIdxStart + j + 1];\r
-                                       if (ch != '?') {\r
-                                               if (ch != strArr[strIdxStart + i + j]) {\r
-                                                       continue strLoop;\r
-                                               }\r
-                                       }\r
-                               }\r
-\r
-                               foundIdx = strIdxStart + i;\r
-                               break;\r
-                       }\r
-\r
-                       if (foundIdx == -1) {\r
-                               return false;\r
-                       }\r
-\r
-                       patIdxStart = patIdxTmp;\r
-                       strIdxStart = foundIdx + patLength;\r
-               }\r
-\r
-               // All characters in the string are used. Check if only '*'s are left\r
-               // in the pattern. If so, we succeeded. Otherwise failure.\r
-               for (int i = patIdxStart; i <= patIdxEnd; i++) {\r
-                       if (patArr[i] != '*') {\r
-                               return false;\r
-                       }\r
-               }\r
-\r
-               return true;\r
-       }\r
-\r
-       /**\r
-        * Given a pattern and a full path, determine the pattern-mapped part.\r
-        * <p>\r
-        * For example:\r
-        * <ul>\r
-        * <li>'<code>/docs/cvs/commit.html</code>' and\r
-        * '<code>/docs/cvs/commit.html</code> to ''</li>\r
-        * <li>'<code>/docs/*</code>' and '<code>/docs/cvs/commit</code> to\r
-        * '<code>cvs/commit</code>'</li>\r
-        * <li>'<code>/docs/cvs/*.html</code>' and '<code>/docs/cvs/commit.html</code>\r
-        * to '<code>commit.html</code>'</li>\r
-        * <li>'<code>/docs/**</code>' and '<code>/docs/cvs/commit</code> to\r
-        * '<code>cvs/commit</code>'</li>\r
-        * <li>'<code>/docs/**\/*.html</code>' and '<code>/docs/cvs/commit.html</code>\r
-        * to '<code>cvs/commit.html</code>'</li>\r
-        * <li>'<code>/*.html</code>' and '<code>/docs/cvs/commit.html</code> to\r
-        * '<code>docs/cvs/commit.html</code>'</li>\r
-        * <li>'<code>*.html</code>' and '<code>/docs/cvs/commit.html</code> to\r
-        * '<code>/docs/cvs/commit.html</code>'</li>\r
-        * <li>'<code>*</code>' and '<code>/docs/cvs/commit.html</code> to\r
-        * '<code>/docs/cvs/commit.html</code>'</li>\r
-        * </ul>\r
-        * <p>\r
-        * Assumes that {@link #match} returns <code>true</code> for\r
-        * '<code>pattern</code>' and '<code>path</code>', but does <strong>not</strong>\r
-        * enforce this.\r
-        */\r
-       public String extractPathWithinPattern(String pattern, String path) {\r
-//             String[] patternParts = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator);\r
-//             String[] pathParts = StringUtils.tokenizeToStringArray(path, this.pathSeparator);\r
-               // mbaudier - 2020-03-13 : Use standard Java call:\r
-               String[] patternParts = pattern.split(this.pathSeparator);\r
-               String[] pathParts = path.split(this.pathSeparator);\r
-\r
-               StringBuffer buffer = new StringBuffer();\r
-\r
-               // Add any path parts that have a wildcarded pattern part.\r
-               int puts = 0;\r
-               for (int i = 0; i < patternParts.length; i++) {\r
-                       String patternPart = patternParts[i];\r
-                       if ((patternPart.indexOf('*') > -1 || patternPart.indexOf('?') > -1) && pathParts.length >= i + 1) {\r
-                               if (puts > 0 || (i == 0 && !pattern.startsWith(this.pathSeparator))) {\r
-                                       buffer.append(this.pathSeparator);\r
-                               }\r
-                               buffer.append(pathParts[i]);\r
-                               puts++;\r
-                       }\r
-               }\r
-\r
-               // Append any trailing path parts.\r
-               for (int i = patternParts.length; i < pathParts.length; i++) {\r
-                       if (puts > 0 || i > 0) {\r
-                               buffer.append(this.pathSeparator);\r
-                       }\r
-                       buffer.append(pathParts[i]);\r
-               }\r
-\r
-               return buffer.toString();\r
-       }\r
-\r
-}\r
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/PathMatcher.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/PathMatcher.java
deleted file mode 100644 (file)
index 9fc1f22..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*\r
- * Copyright 2002-2007 the original author or authors.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.argeo.slc.repo.internal.springutil;\r
-\r
-/**\r
- * Strategy interface for <code>String</code>-based path matching.\r
- * \r
- * <p>Used by <code>org.springframework.core.io.support.PathMatchingResourcePatternResolver</code>,\r
- * {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping},\r
- * {@link org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver},\r
- * and {@link org.springframework.web.servlet.mvc.WebContentInterceptor}.\r
- *\r
- * <p>The default implementation is {@link AntPathMatcher}, supporting the\r
- * Ant-style pattern syntax.\r
- *\r
- * @author Juergen Hoeller\r
- * @since 1.2\r
- * @see AntPathMatcher\r
- */\r
-public interface PathMatcher {\r
-\r
-       /**\r
-        * Does the given <code>path</code> represent a pattern that can be matched\r
-        * by an implementation of this interface?\r
-        * <p>If the return value is <code>false</code>, then the {@link #match}\r
-        * method does not have to be used because direct equality comparisons\r
-        * on the static path Strings will lead to the same result.\r
-        * @param path the path String to check\r
-        * @return <code>true</code> if the given <code>path</code> represents a pattern\r
-        */\r
-       boolean isPattern(String path);\r
-\r
-       /**\r
-        * Match the given <code>path</code> against the given <code>pattern</code>,\r
-        * according to this PathMatcher's matching strategy.\r
-        * @param pattern the pattern to match against\r
-        * @param path the path String to test\r
-        * @return <code>true</code> if the supplied <code>path</code> matched,\r
-        * <code>false</code> if it didn't\r
-        */\r
-       boolean match(String pattern, String path);\r
-\r
-       /**\r
-        * Match the given <code>path</code> against the corresponding part of the given\r
-        * <code>pattern</code>, according to this PathMatcher's matching strategy.\r
-        * <p>Determines whether the pattern at least matches as far as the given base\r
-        * path goes, assuming that a full path may then match as well.\r
-        * @param pattern the pattern to match against\r
-        * @param path the path String to test\r
-        * @return <code>true</code> if the supplied <code>path</code> matched,\r
-        * <code>false</code> if it didn't\r
-        */\r
-       boolean matchStart(String pattern, String path);\r
-\r
-       /**\r
-        * Given a pattern and a full path, determine the pattern-mapped part.\r
-        * <p>This method is supposed to find out which part of the path is matched\r
-        * dynamically through an actual pattern, that is, it strips off a statically\r
-        * defined leading path from the given full path, returning only the actually\r
-        * pattern-matched part of the path.\r
-        * <p>For example: For "myroot/*.html" as pattern and "myroot/myfile.html"\r
-        * as full path, this method should return "myfile.html". The detailed\r
-        * determination rules are specified to this PathMatcher's matching strategy.\r
-        * <p>A simple implementation may return the given full path as-is in case\r
-        * of an actual pattern, and the empty String in case of the pattern not\r
-        * containing any dynamic parts (i.e. the <code>pattern</code> parameter being\r
-        * a static path that wouldn't qualify as an actual {@link #isPattern pattern}).\r
-        * A sophisticated implementation will differentiate between the static parts\r
-        * and the dynamic parts of the given path pattern.\r
-        * @param pattern the path pattern\r
-        * @param path the full path to introspect\r
-        * @return the pattern-mapped part of the given <code>path</code>\r
-        * (never <code>null</code>)\r
-        */\r
-       String extractPathWithinPattern(String pattern, String path);\r
-\r
-}\r
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/apache-2.0.txt b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/apache-2.0.txt
deleted file mode 100644 (file)
index d645695..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/bsd-3-clause.txt b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/bsd-3-clause.txt
deleted file mode 100644 (file)
index ed0116e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Copyright (c) <YEAR>, <OWNER>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/cddl-1.0.txt b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/cddl-1.0.txt
deleted file mode 100644 (file)
index 9dc4442..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
- COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 1.
-
-Definitions.
-
-1.1. Contributor means each individual or entity that creates or contributes to the creation of Modifications.
-
-1.2. Contributor Version means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
-
-1.3. Covered Software means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
-
-1.4. Executable means the Covered Software in any form other than Source Code.
-
-1.5. Initial Developer means the individual or entity that first makes Original Software available under this License.
-
-1.6. Larger Work means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
-
-1.7. License means this document.
-
-1.8. Licensable means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
-
-1.9. Modifications means the Source Code and Executable form of any of the following: A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications; B. Any new file that contains any part of the Original Software or previous Modification; or C. Any new file that is contributed or otherwise made available under the terms of this License.
-
-1.10. Original Software means the Source Code and Executable form of computer software code that is originally released under this License.
-
-1.11. Patent Claims means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
-
-1.12. Source Code means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
-
-1.13. You (or Your) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, You includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, control means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
-
-2. License Grants.
-
- 2.1. The Initial Developer Grant. Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
-
-(b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof);
-
- (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License;
-
- (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
-
-2.2. Contributor Grant. Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
-
-(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
-
-(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
-
-(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
-
-(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
-
-3. Distribution Obligations.
-
-3.1. Availability of Source Code. Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
-
-3.2. Modifications. The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
-
-3.3. Required Notices. You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
-
-3.4. Application of Additional Terms. You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
-
-3.5. Distribution of Executable Versions. You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipients rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
-
-3.6. Larger Works. You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
-
-4. Versions of the License.
-
-4.1. New Versions. Sun Microsystems, Inc. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
-
-4.2. Effect of New Versions. You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
-
-4.3. Modified Versions. When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
-
-5. DISCLAIMER OF WARRANTY. COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN AS IS BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
-
-6. TERMINATION.
-
-6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
-
-6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as Participant) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
-
-6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
-
-7. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTYS NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
-
-8. U.S. GOVERNMENT END USERS. The Covered Software is a commercial item, as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of commercial computer software (as that term is defined at 48 C.F.R.  252.227-7014(a)(1)) and commercial computer software documentation as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
-
-9. MISCELLANEOUS. This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdictions conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
-
-10. RESPONSIBILITY FOR CLAIMS. As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
-
-NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California. 
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/epl-1.0.txt b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/epl-1.0.txt
deleted file mode 100644 (file)
index 795c0c3..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
- THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
-1. DEFINITIONS
-
-"Contribution" means:
-
-    a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
-    b) in the case of each subsequent Contributor:
-    i) changes to the Program, and
-    ii) additions to the Program; 
-
-where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
-
-"Contributor" means any person or entity that distributes the Program.
-
-"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
-
-"Program" means the Contributions distributed in accordance with this Agreement.
-
-"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
-
-2. GRANT OF RIGHTS
-
-    a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
-    b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
-    c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
-    d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 
-
-3. REQUIREMENTS
-
-A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
-
-    a) it complies with the terms and conditions of this Agreement; and
-    b) its license agreement:
-    i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
-    ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
-    iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
-    iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. 
-
-When the Program is made available in source code form:
-
-    a) it must be made available under this Agreement; and
-    b) a copy of this Agreement must be included with each copy of the Program. 
-
-Contributors may not remove or alter any copyright notices contained within the Program.
-
-Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
-
-4. COMMERCIAL DISTRIBUTION
-
-Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
-
-For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
-
-5. NO WARRANTY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
-
-6. DISCLAIMER OF LIABILITY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-7. GENERAL
-
-If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
-
-If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
-
-All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
-
-Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
-
-This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-2.0.txt b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-2.0.txt
deleted file mode 100644 (file)
index d159169..0000000
+++ /dev/null
@@ -1,339 +0,0 @@
-                    GNU GENERAL PUBLIC LICENSE
-                       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-                    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-                            NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-
-            How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) year name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-3.0.txt b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-3.0.txt
deleted file mode 100644 (file)
index 94a9ed0..0000000
+++ /dev/null
@@ -1,674 +0,0 @@
-                    GNU GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-                            Preamble
-
-  The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
-  The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works.  By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.  We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors.  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
-  To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights.  Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received.  You must make sure that they, too, receive
-or can get the source code.  And you must show them these terms so they
-know their rights.
-
-  Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
-  For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software.  For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
-  Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so.  This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software.  The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable.  Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products.  If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
-  Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary.  To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-                       TERMS AND CONDITIONS
-
-  0. Definitions.
-
-  "This License" refers to version 3 of the GNU General Public License.
-
-  "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
-  "The Program" refers to any copyrightable work licensed under this
-License.  Each licensee is addressed as "you".  "Licensees" and
-"recipients" may be individuals or organizations.
-
-  To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy.  The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
-  A "covered work" means either the unmodified Program or a work based
-on the Program.
-
-  To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy.  Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
-  To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies.  Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
-  An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License.  If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
-  1. Source Code.
-
-  The "source code" for a work means the preferred form of the work
-for making modifications to it.  "Object code" means any non-source
-form of a work.
-
-  A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
-  The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form.  A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
-  The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities.  However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work.  For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
-  The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
-  The Corresponding Source for a work in source code form is that
-same work.
-
-  2. Basic Permissions.
-
-  All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met.  This License explicitly affirms your unlimited
-permission to run the unmodified Program.  The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work.  This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
-  You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force.  You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright.  Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
-  Conveying under any other circumstances is permitted solely under
-the conditions stated below.  Sublicensing is not allowed; section 10
-makes it unnecessary.
-
-  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
-  No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
-  When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
-  4. Conveying Verbatim Copies.
-
-  You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
-  You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
-  5. Conveying Modified Source Versions.
-
-  You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
-    a) The work must carry prominent notices stating that you modified
-    it, and giving a relevant date.
-
-    b) The work must carry prominent notices stating that it is
-    released under this License and any conditions added under section
-    7.  This requirement modifies the requirement in section 4 to
-    "keep intact all notices".
-
-    c) You must license the entire work, as a whole, under this
-    License to anyone who comes into possession of a copy.  This
-    License will therefore apply, along with any applicable section 7
-    additional terms, to the whole of the work, and all its parts,
-    regardless of how they are packaged.  This License gives no
-    permission to license the work in any other way, but it does not
-    invalidate such permission if you have separately received it.
-
-    d) If the work has interactive user interfaces, each must display
-    Appropriate Legal Notices; however, if the Program has interactive
-    interfaces that do not display Appropriate Legal Notices, your
-    work need not make them do so.
-
-  A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit.  Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
-  6. Conveying Non-Source Forms.
-
-  You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
-    a) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by the
-    Corresponding Source fixed on a durable physical medium
-    customarily used for software interchange.
-
-    b) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by a
-    written offer, valid for at least three years and valid for as
-    long as you offer spare parts or customer support for that product
-    model, to give anyone who possesses the object code either (1) a
-    copy of the Corresponding Source for all the software in the
-    product that is covered by this License, on a durable physical
-    medium customarily used for software interchange, for a price no
-    more than your reasonable cost of physically performing this
-    conveying of source, or (2) access to copy the
-    Corresponding Source from a network server at no charge.
-
-    c) Convey individual copies of the object code with a copy of the
-    written offer to provide the Corresponding Source.  This
-    alternative is allowed only occasionally and noncommercially, and
-    only if you received the object code with such an offer, in accord
-    with subsection 6b.
-
-    d) Convey the object code by offering access from a designated
-    place (gratis or for a charge), and offer equivalent access to the
-    Corresponding Source in the same way through the same place at no
-    further charge.  You need not require recipients to copy the
-    Corresponding Source along with the object code.  If the place to
-    copy the object code is a network server, the Corresponding Source
-    may be on a different server (operated by you or a third party)
-    that supports equivalent copying facilities, provided you maintain
-    clear directions next to the object code saying where to find the
-    Corresponding Source.  Regardless of what server hosts the
-    Corresponding Source, you remain obligated to ensure that it is
-    available for as long as needed to satisfy these requirements.
-
-    e) Convey the object code using peer-to-peer transmission, provided
-    you inform other peers where the object code and Corresponding
-    Source of the work are being offered to the general public at no
-    charge under subsection 6d.
-
-  A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
-  A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling.  In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage.  For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product.  A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
-  "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source.  The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
-  If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information.  But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
-  The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed.  Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
-  Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
-  7. Additional Terms.
-
-  "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law.  If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
-  When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it.  (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.)  You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
-  Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
-    a) Disclaiming warranty or limiting liability differently from the
-    terms of sections 15 and 16 of this License; or
-
-    b) Requiring preservation of specified reasonable legal notices or
-    author attributions in that material or in the Appropriate Legal
-    Notices displayed by works containing it; or
-
-    c) Prohibiting misrepresentation of the origin of that material, or
-    requiring that modified versions of such material be marked in
-    reasonable ways as different from the original version; or
-
-    d) Limiting the use for publicity purposes of names of licensors or
-    authors of the material; or
-
-    e) Declining to grant rights under trademark law for use of some
-    trade names, trademarks, or service marks; or
-
-    f) Requiring indemnification of licensors and authors of that
-    material by anyone who conveys the material (or modified versions of
-    it) with contractual assumptions of liability to the recipient, for
-    any liability that these contractual assumptions directly impose on
-    those licensors and authors.
-
-  All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10.  If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term.  If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
-  If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
-  Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
-  8. Termination.
-
-  You may not propagate or modify a covered work except as expressly
-provided under this License.  Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
-  However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
-  Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-  Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License.  If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
-  9. Acceptance Not Required for Having Copies.
-
-  You are not required to accept this License in order to receive or
-run a copy of the Program.  Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance.  However,
-nothing other than this License grants you permission to propagate or
-modify any covered work.  These actions infringe copyright if you do
-not accept this License.  Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
-  10. Automatic Licensing of Downstream Recipients.
-
-  Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License.  You are not responsible
-for enforcing compliance by third parties with this License.
-
-  An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations.  If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
-  You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License.  For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
-  11. Patents.
-
-  A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based.  The
-work thus licensed is called the contributor's "contributor version".
-
-  A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version.  For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
-  Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
-  In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement).  To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
-  If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients.  "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
-  If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
-  A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License.  You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
-  Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
-  12. No Surrender of Others' Freedom.
-
-  If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all.  For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
-  13. Use with the GNU Affero General Public License.
-
-  Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work.  The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
-  14. Revised Versions of this License.
-
-  The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-  Each version is given a distinguishing version number.  If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation.  If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
-  If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
-  Later license versions may give you additional or different
-permissions.  However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
-  15. Disclaimer of Warranty.
-
-  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. Limitation of Liability.
-
-  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
-  17. Interpretation of Sections 15 and 16.
-
-  If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
-                     END OF TERMS AND CONDITIONS
-
-            How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
-  If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
-    <program>  Copyright (C) <year>  <name of author>
-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
-  You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
-  The GNU General Public License does not permit incorporating your program
-into proprietary programs.  If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-2.1.txt b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-2.1.txt
deleted file mode 100644 (file)
index 4362b49..0000000
+++ /dev/null
@@ -1,502 +0,0 @@
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard.  To achieve this, non-free programs must be
-allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-                  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at
-    least three years, to give the same user the materials
-    specified in Subsection 6a, above, for a charge no more
-    than the cost of performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded.  In such case, this License incorporates the limitation as if
-written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-                            NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-3.0.txt b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-3.0.txt
deleted file mode 100644 (file)
index 65c5ca8..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-                   GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
-  This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
-  0. Additional Definitions.
-
-  As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
-  "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
-  An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
-  A "Combined Work" is a work produced by combining or linking an
-Application with the Library.  The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
-  The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
-  The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
-  1. Exception to Section 3 of the GNU GPL.
-
-  You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
-  2. Conveying Modified Versions.
-
-  If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
-   a) under this License, provided that you make a good faith effort to
-   ensure that, in the event an Application does not supply the
-   function or data, the facility still operates, and performs
-   whatever part of its purpose remains meaningful, or
-
-   b) under the GNU GPL, with none of the additional permissions of
-   this License applicable to that copy.
-
-  3. Object Code Incorporating Material from Library Header Files.
-
-  The object code form of an Application may incorporate material from
-a header file that is part of the Library.  You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
-   a) Give prominent notice with each copy of the object code that the
-   Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the object code with a copy of the GNU GPL and this license
-   document.
-
-  4. Combined Works.
-
-  You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
-   a) Give prominent notice with each copy of the Combined Work that
-   the Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the Combined Work with a copy of the GNU GPL and this license
-   document.
-
-   c) For a Combined Work that displays copyright notices during
-   execution, include the copyright notice for the Library among
-   these notices, as well as a reference directing the user to the
-   copies of the GNU GPL and this license document.
-
-   d) Do one of the following:
-
-       0) Convey the Minimal Corresponding Source under the terms of this
-       License, and the Corresponding Application Code in a form
-       suitable for, and under terms that permit, the user to
-       recombine or relink the Application with a modified version of
-       the Linked Version to produce a modified Combined Work, in the
-       manner specified by section 6 of the GNU GPL for conveying
-       Corresponding Source.
-
-       1) Use a suitable shared library mechanism for linking with the
-       Library.  A suitable mechanism is one that (a) uses at run time
-       a copy of the Library already present on the user's computer
-       system, and (b) will operate properly with a modified version
-       of the Library that is interface-compatible with the Linked
-       Version.
-
-   e) Provide Installation Information, but only if you would otherwise
-   be required to provide such information under section 6 of the
-   GNU GPL, and only to the extent that such information is
-   necessary to install and execute a modified version of the
-   Combined Work produced by recombining or relinking the
-   Application with a modified version of the Linked Version. (If
-   you use option 4d0, the Installation Information must accompany
-   the Minimal Corresponding Source and Corresponding Application
-   Code. If you use option 4d1, you must provide the Installation
-   Information in the manner specified by section 6 of the GNU GPL
-   for conveying Corresponding Source.)
-
-  5. Combined Libraries.
-
-  You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
-   a) Accompany the combined library with a copy of the same work based
-   on the Library, uncombined with any other library facilities,
-   conveyed under the terms of this License.
-
-   b) Give prominent notice with the combined library that part of it
-   is a work based on the Library, and explaining where to find the
-   accompanying uncombined form of the same work.
-
-  6. Revised Versions of the GNU Lesser General Public License.
-
-  The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
-  Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
-  If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/mit.txt b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/license/mit.txt
deleted file mode 100644 (file)
index e14c371..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/AetherUtils.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/AetherUtils.java
deleted file mode 100644 (file)
index e9360f9..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.argeo.slc.repo.maven;
-
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.graph.DependencyNode;
-
-/** Utilities related to Aether */
-public class AetherUtils {
-       public final static String SNAPSHOT = "SNAPSHOT";
-       // hacked from aether
-       public static final Pattern SNAPSHOT_TIMESTAMP = Pattern
-                       .compile("^(.*-)?([0-9]{8}.[0-9]{6}-[0-9]+)$");
-
-       private final static Log log = LogFactory.getLog(AetherUtils.class);
-
-       /** Logs a dependency node and its transitive dependencies as a tree. */
-       public static void logDependencyNode(int depth,
-                       DependencyNode dependencyNode) {
-               if (!log.isDebugEnabled())
-                       return;
-
-               StringBuffer prefix = new StringBuffer(depth * 2 + 2);
-               // prefix.append("|-");
-               for (int i = 0; i < depth * 2; i++) {
-                       prefix.append(' ');
-               }
-               Artifact artifact = dependencyNode.getDependency().getArtifact();
-               log.debug(prefix + "|-> " + artifact.getArtifactId() + " ["
-                               + artifact.getVersion() + "]"
-                               + (dependencyNode.getDependency().isOptional() ? " ?" : ""));
-               for (DependencyNode child : dependencyNode.getChildren()) {
-                       logDependencyNode(depth + 1, child);
-               }
-       }
-
-       /**
-        * Converts a path (relative to a repository root) to an {@link Artifact}.
-        * 
-        * @param path
-        *            the relative path
-        * @param type
-        *            the layout type, currently ignored because only the 'default'
-        *            Maven 2 layout is currently supported:
-        *            /my/group/id/artifactId/
-        *            version/artifactId-version[-classifier].extension
-        * @return the related artifact or null if the file is not an artifact
-        *         (Maven medata data XML files, check sums, etc.)
-        */
-       public static Artifact convertPathToArtifact(String path, String type) {
-               // TODO rewrite it with regexp (unit tests first!)
-
-               // normalize
-               if (path.startsWith("/"))
-                       path = path.substring(1);
-
-               // parse group id
-               String[] tokensSlash = path.split("/");
-               if (tokensSlash.length < 4)
-                       return null;
-               StringBuffer groupId = new StringBuffer(path.length());
-               for (int i = 0; i < tokensSlash.length - 3; i++) {
-                       if (i != 0)
-                               groupId.append('.');
-                       groupId.append(tokensSlash[i]);
-               }
-               String artifactId = tokensSlash[tokensSlash.length - 3];
-               String baseVersion = tokensSlash[tokensSlash.length - 2];
-               String fileName = tokensSlash[tokensSlash.length - 1];
-
-               if (!fileName.startsWith(artifactId))
-                       return null;
-               // FIXME make it configurable? (via an argument?)
-               if (FilenameUtils.isExtension(fileName, new String[] { "sha1", "md5" }))
-                       return null;
-
-               String extension = FilenameUtils.getExtension(fileName);
-               String baseName = FilenameUtils.getBaseName(fileName);
-
-               // check since we assume hereafter
-               if (!baseName.startsWith(artifactId))
-                       throw new SlcException("Base name '" + baseName
-                                       + " does not start with artifact id '" + artifactId
-                                       + "' in " + path);
-
-               boolean isSnapshot = baseVersion.endsWith("-" + SNAPSHOT);
-               String baseBaseVersion = isSnapshot ? baseVersion.substring(0,
-                               baseVersion.length() - SNAPSHOT.length() - 1) : baseVersion;
-               int artifactAndBaseBaseVersionLength = artifactId.length() + 1
-                               + baseBaseVersion.length() + 1;
-               String classifier = null;
-               if (baseName.length() > artifactAndBaseBaseVersionLength) {
-                       String dashRest = baseName
-                                       .substring(artifactAndBaseBaseVersionLength);
-                       String[] dashes = dashRest.split("-");
-
-                       if (isSnapshot) {
-                               if (dashes[0].equals(SNAPSHOT)) {
-                                       if (dashRest.length() > SNAPSHOT.length() + 1)
-                                               classifier = dashRest.substring(SNAPSHOT.length() + 1);
-
-                               } else {
-                                       if (dashes.length > 2)// assume no '-' in classifier
-                                               classifier = dashes[2];
-                               }
-                       } else {
-                               if (dashes.length > 0)
-                                       classifier = dashes[0];
-                       }
-               }
-
-               // classifier
-               // String classifier = null;
-               // int firstDash = baseName.indexOf('-');
-               // int classifierDash = baseName.lastIndexOf('-');
-               // if (classifierDash > 0 && classifierDash != firstDash) {
-               // classifier = baseName.substring(classifierDash + 1);
-               // }
-               // if (isSnapshot && classifier != null) {
-               // if (classifier.equals(SNAPSHOT))
-               // classifier = null;
-               // else
-               // try {
-               // Long.parseLong(classifier); // build number
-               // // if not failed this is a timestamped version
-               // classifier = null;
-               // } catch (NumberFormatException e) {
-               // // silent
-               // }
-               // }
-
-               // version
-               String version = baseName.substring(artifactId.length() + 1);
-               if (classifier != null)
-                       version = version.substring(0,
-                                       version.length() - classifier.length() - 1);
-
-               // consistency checks
-               if (!isSnapshot && !version.equals(baseVersion))
-                       throw new SlcException("Base version '" + baseVersion
-                                       + "' and version '" + version + "' not in line in " + path);
-               if (!isSnapshot && isSnapshotVersion(version))
-                       throw new SlcException("SNAPSHOT base version '" + baseVersion
-                                       + "' and version '" + version + "' not in line in " + path);
-
-               DefaultArtifact artifact = new DefaultArtifact(groupId.toString(),
-                               artifactId, classifier, extension, version);
-               return artifact;
-       }
-
-       /** Hacked from aether */
-       public static boolean isSnapshotVersion(String version) {
-               return version.endsWith(SNAPSHOT)
-                               || SNAPSHOT_TIMESTAMP.matcher(version).matches();
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ArtifactIdComparator.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ArtifactIdComparator.java
deleted file mode 100644 (file)
index 7aef78d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.argeo.slc.repo.maven;
-
-import java.util.Comparator;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * Compare two artifacts, for use in {@link TreeSet} / {@link TreeMap}, consider
- * artifactId first THEN groupId
- */
-public class ArtifactIdComparator implements Comparator<Artifact> {
-       public int compare(Artifact o1, Artifact o2) {
-               if (o1.getArtifactId().equals(o2.getArtifactId()))
-                       return o1.getGroupId().compareTo(o2.getGroupId());
-               return o1.getArtifactId().compareTo(o2.getArtifactId());
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ConvertPoms_01_03.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ConvertPoms_01_03.java
deleted file mode 100644 (file)
index d46375e..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-package org.argeo.slc.repo.maven;
-
-import java.io.File;
-import java.util.HashMap;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/** Recursively migrate all the POMs to Argeo Distribution v1.3 */
-public class ConvertPoms_01_03 implements Runnable {
-       final String SPRING_SOURCE_PREFIX = "com.springsource";
-
-       private HashMap<String, String> artifactMapping = new HashMap<String, String>();
-
-       private File rootDir;
-
-       public ConvertPoms_01_03(String rootDirPath) {
-               this(new File(rootDirPath));
-       }
-
-       public ConvertPoms_01_03(File rootDir) {
-               this.rootDir = rootDir;
-
-               artifactMapping.put("org.argeo.dep.jacob", "com.jacob");
-               artifactMapping.put("org.argeo.dep.jacob.win32.x86",
-                               "com.jacob.win32.x86");
-               artifactMapping.put("org.argeo.dep.osgi.activemq",
-                               "org.apache.activemq");
-               artifactMapping.put("org.argeo.dep.osgi.activemq.optional",
-                               "org.apache.activemq.optional");
-               artifactMapping.put("org.argeo.dep.osgi.activemq.xmpp",
-                               "org.apache.activemq.xmpp");
-               artifactMapping.put("org.argeo.dep.osgi.aether", "org.eclipse.aether");
-               artifactMapping.put("org.argeo.dep.osgi.boilerpipe",
-                               "de.l3s.boilerpipe");
-               artifactMapping.put("org.argeo.dep.osgi.commons.cli",
-                               "org.apache.commons.cli");
-               artifactMapping.put("org.argeo.dep.osgi.commons.exec",
-                               "org.apache.commons.exec");
-               artifactMapping.put("org.argeo.dep.osgi.directory.shared.asn.codec",
-                               "org.apache.directory.shared.asn.codec");
-               artifactMapping.put("org.argeo.dep.osgi.drewnoakes.metadata_extractor",
-                               "com.drewnoakes.metadata_extractor");
-               artifactMapping.put("org.argeo.dep.osgi.geoapi", "org.opengis");
-               artifactMapping.put("org.argeo.dep.osgi.geotools", "org.geotools");
-               artifactMapping.put("org.argeo.dep.osgi.google.collections",
-                               "com.google.collections");
-               artifactMapping.put("org.argeo.dep.osgi.hibernatespatial",
-                               "org.hibernatespatial");
-               artifactMapping.put("org.argeo.dep.osgi.jackrabbit",
-                               "org.apache.jackrabbit");
-               artifactMapping.put("org.argeo.dep.osgi.jai.imageio",
-                               "com.sun.media.jai.imageio");
-               artifactMapping.put("org.argeo.dep.osgi.java3d", "javax.vecmath");
-               artifactMapping.put("org.argeo.dep.osgi.jcr", "javax.jcr");
-               artifactMapping.put("org.argeo.dep.osgi.jsr275", "javax.measure");
-               artifactMapping.put("org.argeo.dep.osgi.jts", "com.vividsolutions.jts");
-               artifactMapping.put("org.argeo.dep.osgi.mina.filter.ssl",
-                               "org.apache.mina.filter.ssl");
-               artifactMapping.put("org.argeo.dep.osgi.modeshape", "org.modeshape");
-               artifactMapping.put("org.argeo.dep.osgi.netcdf",
-                               "edu.ucar.unidata.netcdf");
-               artifactMapping.put("org.argeo.dep.osgi.pdfbox", "org.apache.pdfbox");
-               artifactMapping.put("org.argeo.dep.osgi.poi", "org.apache.poi");
-               artifactMapping.put("org.argeo.dep.osgi.postgis.jdbc",
-                               "org.postgis.jdbc");
-               artifactMapping.put("org.argeo.dep.osgi.springframework.ldap",
-                               "org.springframework.ldap");
-               artifactMapping.put("org.argeo.dep.osgi.tagsoup",
-                               "org.ccil.cowan.tagsoup");
-               artifactMapping.put("org.argeo.dep.osgi.tika", "org.apache.tika");
-       }
-
-       public void run() {
-               traverse(rootDir);
-       }
-
-       protected void traverse(File dir) {
-               for (File file : dir.listFiles()) {
-                       String fileName = file.getName();
-                       if (file.isDirectory() && !skipDirName(fileName)) {
-                               traverse(file);
-                       } else if (fileName.equals("pom.xml")) {
-                               processPom(file);
-                       }
-               }
-       }
-
-       protected Boolean skipDirName(String fileName) {
-               return fileName.equals(".svn") || fileName.equals("target")
-                               || fileName.equals("META-INF") || fileName.equals("src");
-       }
-
-       protected void processPom(File pomFile) {
-               try {
-                       Boolean wasChanged = false;
-                       DocumentBuilderFactory dbFactory = DocumentBuilderFactory
-                                       .newInstance();
-                       DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
-                       Document doc = dBuilder.parse(pomFile);
-                       doc.getDocumentElement().normalize();
-
-                       Element dependenciesElement = null;
-                       NodeList rootChildren = doc.getDocumentElement().getChildNodes();
-                       for (int temp = 0; temp < rootChildren.getLength(); temp++) {
-                               Node n = rootChildren.item(temp);
-                               if (n.getNodeName().equals("dependencies"))
-                                       dependenciesElement = (Element) n;
-                       }
-
-                       if (dependenciesElement != null) {
-                               stdOut("\n## " + pomFile);
-                               NodeList dependencyElements = dependenciesElement
-                                               .getElementsByTagName("dependency");
-
-                               for (int temp = 0; temp < dependencyElements.getLength(); temp++) {
-                                       Element eElement = (Element) dependencyElements.item(temp);
-                                       String groupId = getTagValue(eElement, "groupId");
-                                       String artifactId = getTagValue(eElement, "artifactId");
-                                       // stdOut(groupId + ":" + artifactId);
-
-                                       String newGroupId = null;
-                                       String newArtifactId = null;
-                                       if (groupId.startsWith("org.argeo.dep")) {
-                                               newGroupId = "org.argeo.tp";
-                                       } else if (!(groupId.startsWith("org.argeo")
-                                                       || groupId.startsWith("com.capco")
-                                                       || groupId.startsWith("com.agfa") || groupId
-                                                       .startsWith("org.ibboost"))) {
-                                               newGroupId = "org.argeo.tp";
-                                       }
-
-                                       if (artifactMapping.containsKey(artifactId)) {
-                                               newArtifactId = artifactMapping.get(artifactId);
-                                       } else if (artifactId.startsWith(SPRING_SOURCE_PREFIX)
-                                                       && !artifactId.equals(SPRING_SOURCE_PREFIX
-                                                                       + ".json")) {
-                                               newArtifactId = artifactId
-                                                               .substring(SPRING_SOURCE_PREFIX.length() + 1);
-                                       }
-
-                                       // modify
-                                       if (newGroupId != null || newArtifactId != null) {
-                                               if (newGroupId == null)
-                                                       newGroupId = groupId;
-                                               if (newArtifactId == null)
-                                                       newArtifactId = artifactId;
-                                               stdOut(groupId + ":" + artifactId + " => " + newGroupId
-                                                               + ":" + newArtifactId);
-                                               setTagValue(eElement, "groupId", newGroupId);
-                                               setTagValue(eElement, "artifactId", newArtifactId);
-                                               wasChanged = true;
-                                       }
-                               }
-                       }
-
-                       if (wasChanged) {
-                               // pomFile.renameTo(new File(pomFile.getParentFile(),
-                               // "pom-old.xml"));
-                               // save in place
-                               Source source = new DOMSource(doc);
-                               Result result = new StreamResult(pomFile);
-                               Transformer xformer = TransformerFactory.newInstance()
-                                               .newTransformer();
-                               xformer.transform(source, result);
-                       }
-               } catch (Exception e) {
-                       throw new RuntimeException("Cannot process " + pomFile, e);
-               }
-
-       }
-
-       private String getTagValue(Element eElement, String sTag) {
-               NodeList nList = eElement.getElementsByTagName(sTag);
-               if (nList.getLength() > 0) {
-                       NodeList nlList = nList.item(0).getChildNodes();
-                       Node nValue = (Node) nlList.item(0);
-                       return nValue.getNodeValue();
-               } else
-                       return null;
-       }
-
-       private void setTagValue(Element eElement, String sTag, String value) {
-               NodeList nList = eElement.getElementsByTagName(sTag);
-               if (nList.getLength() > 0) {
-                       NodeList nlList = nList.item(0).getChildNodes();
-                       Node nValue = (Node) nlList.item(0);
-                       nValue.setNodeValue(value);
-               }
-       }
-
-       public static void stdOut(Object obj) {
-               System.out.println(obj);
-       }
-
-       public static void main(String argv[]) {
-               new ConvertPoms_01_03(argv[0]).run();
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/GenerateBinaries.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/GenerateBinaries.java
deleted file mode 100644 (file)
index 3ccc164..0000000
+++ /dev/null
@@ -1,568 +0,0 @@
-package org.argeo.slc.repo.maven;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.ArtifactIndexer;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.osgi.framework.Version;
-
-/**
- * Generates binaries-, sources- and sdk-version.pom artifacts for a given
- * group.
- */
-public class GenerateBinaries implements Runnable, SlcNames {
-       private final static Log log = LogFactory.getLog(GenerateBinaries.class);
-
-       // Connection info
-       private Repository repository;
-       private Credentials credentials;
-       private String workspace;
-
-       // Business info
-       private String groupId;
-       private String parentPomCoordinates;
-       private String version = null;
-
-       // Constants
-       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
-       private List<String> excludedSuffixes = new ArrayList<String>();
-
-       // Indexes
-       private Set<Artifact> binaries = new TreeSet<Artifact>(
-                       new ArtifactIdComparator());
-       private Set<Artifact> sources = new TreeSet<Artifact>(
-                       new ArtifactIdComparator());
-
-       // local cache
-       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
-       private Node allArtifactsHighestVersion;
-
-       public void run() {
-               Session session = null;
-               try {
-                       session = repository.login(credentials, workspace);
-                       Node groupNode = session.getNode(MavenConventionsUtils.groupPath(
-                                       artifactBasePath, groupId));
-                       internalPreProcessing(groupNode, null);
-                       internalProcessing(groupNode, null);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot normalize group " + groupId + " in "
-                                       + workspace, e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       /**
-        * Generates binaries-, sources- and sdk-version.pom artifacts for the given
-        * version (or the highest of all children version if none is precised).
-        * 
-        * By default, it includes each latest version of all artifact of this
-        * group.
-        * 
-        * The 3 generated artifacts are then marked as modular distributions and
-        * indexed.
-        */
-       public static void processGroupNode(Node groupNode, String version,
-                       JcrMonitor monitor) throws RepositoryException {
-               // TODO set artifactsBase based on group node
-               GenerateBinaries gb = new GenerateBinaries();
-               String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
-                               .getString();
-               gb.setGroupId(groupId);
-               gb.setVersion(version);
-               // TODO use already done pre-processing
-               gb.internalPreProcessing(groupNode, monitor);
-               gb.internalProcessing(groupNode, monitor);
-       }
-
-       /** Only builds local indexes. Does not change anything in the local Session */
-       public static GenerateBinaries preProcessGroupNode(Node groupNode,
-                       JcrMonitor monitor) throws RepositoryException {
-               // TODO set artifactsBase based on group node
-               GenerateBinaries gb = new GenerateBinaries();
-               String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
-                               .getString();
-               gb.setGroupId(groupId);
-               // gb.setVersion(version);
-               // gb.setOverridePoms(overridePoms);
-               gb.internalPreProcessing(groupNode, monitor);
-               return gb;
-       }
-
-       // exposes indexes. to display results of the pre-processing phase.
-       public Set<Artifact> getBinaries() {
-               return binaries;
-       }
-
-       public Artifact getHighestArtifactVersion() throws RepositoryException {
-               return allArtifactsHighestVersion == null ? null : RepoUtils
-                               .asArtifact(allArtifactsHighestVersion);
-       }
-
-       // //////////////////////////////////////
-       // INTERNAL METHODS
-
-       /**
-        * Browse all children of a Node considered as a folder that follows Aether
-        * conventions i.e that has Aether's artifact base as children.
-        * 
-        * Each of such child contains a set of Aether artifact versions. This
-        * methods build the binaries {@code Set<Artifact>} and other indexes. It
-        * does not impact the
-        */
-       protected void internalPreProcessing(Node groupNode, JcrMonitor monitor)
-                       throws RepositoryException {
-               if (monitor != null)
-                       monitor.subTask("Pre processing group " + groupId);
-
-               // Process all direct children nodes,
-               // gathering latest versions of each artifact
-               allArtifactsHighestVersion = null;
-
-               aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases
-                               .hasNext();) {
-                       Node aBase = aBases.nextNode();
-                       if (aBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
-                               Node highestAVersion = getArtifactLatestVersion(aBase);
-                               if (highestAVersion == null)
-                                       continue aBases;
-                               else {
-                                       // retrieve relevant child node
-                                       // Information is stored on the NT_FILE child node.
-                                       for (NodeIterator files = highestAVersion.getNodes(); files
-                                                       .hasNext();) {
-                                               Node file = files.nextNode();
-                                               if (file.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
-                                                       if (log.isDebugEnabled())
-                                                               log.debug("Pre-Processing " + file.getName());
-                                                       preProcessBundleArtifact(file);
-                                               }
-                                       }
-                               }
-                       }
-               }
-               // if (log.isDebugEnabled()) {
-               // int bundleCount = symbolicNamesToNodes.size();
-               // log.debug("" + bundleCount + " bundles have been indexed for "
-               // + groupId);
-               // }
-       }
-
-       /** Does the real job : writes JCR META-DATA and generates binaries */
-       protected void internalProcessing(Node groupNode, JcrMonitor monitor)
-                       throws RepositoryException {
-               if (monitor != null)
-                       monitor.subTask("Processing group " + groupId);
-
-               Session session = groupNode.getSession();
-
-               // if version not set or empty, use the highest version
-               // useful when indexing a product maven repository where
-               // all artifacts have the same version for a given release
-               // => the version can then be left empty
-               if (version == null || version.trim().equals(""))
-                       if (allArtifactsHighestVersion != null)
-                               version = allArtifactsHighestVersion.getProperty(
-                                               SLC_ARTIFACT_VERSION).getString();
-                       else
-                               throw new SlcException("Group version " + version
-                                               + " is empty.");
-
-               // int bundleCount = symbolicNamesToNodes.size();
-               // int count = 1;
-               // for (Node bundleNode : symbolicNamesToNodes.values()) {
-               // if (log.isDebugEnabled())
-               // log.debug("Processing " + bundleNode.getName() + " ( " + count
-               // + "/" + bundleCount + " )");
-               //
-               // // processBundleArtifact(bundleNode);
-               // // bundleNode.getSession().save();
-               // count++;
-               // }
-
-               // indexes
-               Set<Artifact> indexes = new TreeSet<Artifact>(
-                               new ArtifactIdComparator());
-
-               Artifact indexArtifact;
-               indexArtifact = writeIndex(session, RepoConstants.BINARIES_ARTIFACT_ID,
-                               binaries);
-               indexes.add(indexArtifact);
-
-               indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID,
-                               sources);
-               indexes.add(indexArtifact);
-
-               // sdk
-               writeIndex(session, RepoConstants.SDK_ARTIFACT_ID, indexes);
-
-               if (monitor != null)
-                       monitor.worked(1);
-       }
-
-       protected void preProcessBundleArtifact(Node bundleNode)
-                       throws RepositoryException {
-
-               String symbolicName = JcrUtils.get(bundleNode, SLC_SYMBOLIC_NAME);
-               // Sanity check.
-               if (symbolicName == null)
-                       log.warn("Symbolic name is null for bundle " + bundleNode);
-
-               // Manage source bundles
-               if (symbolicName.endsWith(".source")) {
-                       // TODO make a shared node with classifier 'sources'?
-                       String bundleName = RepoUtils
-                                       .extractBundleNameFromSourceName(symbolicName);
-                       for (String excludedSuffix : excludedSuffixes) {
-                               if (bundleName.endsWith(excludedSuffix))
-                                       return;// skip adding to sources
-                       }
-                       sources.add(RepoUtils.asArtifact(bundleNode));
-                       return;
-               }
-
-               // // Build indexes
-               // NodeIterator exportPackages = bundleNode.getNodes(SLC_
-               // + Constants.EXPORT_PACKAGE);
-               // while (exportPackages.hasNext()) {
-               // Node exportPackage = exportPackages.nextNode();
-               // String pkg = JcrUtils.get(exportPackage, SLC_NAME);
-               // packagesToSymbolicNames.put(pkg, symbolicName);
-               // }
-               //
-               // symbolicNamesToNodes.put(symbolicName, bundleNode);
-               // for (String excludedSuffix : excludedSuffixes) {
-               // if (symbolicName.endsWith(excludedSuffix))
-               // return;// skip adding to binaries
-               // }
-
-               binaries.add(RepoUtils.asArtifact(bundleNode));
-
-               // Extra check. to remove
-               if (bundleNode.getSession().hasPendingChanges())
-                       throw new SlcException("Pending changes in the session, "
-                                       + "this should not be true here.");
-       }
-
-       // protected void processBundleArtifact(Node bundleNode)
-       // throws RepositoryException {
-       // Node artifactFolder = bundleNode.getParent();
-       // String baseName = FilenameUtils.getBaseName(bundleNode.getName());
-       //
-       // // pom
-       // String pomName = baseName + ".pom";
-       // if (artifactFolder.hasNode(pomName) && !overridePoms)
-       // return;// skip
-       //
-       // String pom = generatePomForBundle(bundleNode);
-       // Node pomNode = JcrUtils.copyBytesAsFile(artifactFolder, pomName,
-       // pom.getBytes());
-       // // checksum
-       // String bundleSha = JcrUtils.checksumFile(bundleNode, "SHA-1");
-       // JcrUtils.copyBytesAsFile(artifactFolder,
-       // bundleNode.getName() + ".sha1", bundleSha.getBytes());
-       // String pomSha = JcrUtils.checksumFile(pomNode, "SHA-1");
-       // JcrUtils.copyBytesAsFile(artifactFolder, pomNode.getName() + ".sha1",
-       // pomSha.getBytes());
-       // }
-
-       // ////////////////////
-       // LOCAL WRITERS
-       //
-
-       private Artifact writeIndex(Session session, String artifactId,
-                       Set<Artifact> artifacts) throws RepositoryException {
-               Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
-                               version);
-               Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(
-                               parentPomCoordinates) : null;
-               String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
-                               artifacts, parentArtifact);
-               Node node = RepoUtils.copyBytesAsArtifact(
-                               session.getNode(artifactBasePath), artifact, pom.getBytes());
-               artifactIndexer.index(node);
-
-               // TODO factorize
-               String pomSha = JcrUtils.checksumFile(node, "SHA-1");
-               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
-                               pomSha.getBytes());
-               String pomMd5 = JcrUtils.checksumFile(node, "MD5");
-               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
-                               pomMd5.getBytes());
-               session.save();
-               return artifact;
-       }
-
-       // Helpers
-       private Node getArtifactLatestVersion(Node artifactBase) {
-               try {
-                       Node highestAVersion = null;
-                       for (NodeIterator aVersions = artifactBase.getNodes(); aVersions
-                                       .hasNext();) {
-                               Node aVersion = aVersions.nextNode();
-                               if (aVersion.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
-                                       if (highestAVersion == null) {
-                                               highestAVersion = aVersion;
-                                               if (allArtifactsHighestVersion == null)
-                                                       allArtifactsHighestVersion = aVersion;
-                                               // Correctly handle following arrival order:
-                                               // Name1 - V1, name2 - V3
-                                               else {
-                                                       Version cachedHighestVersion = extractOsgiVersion(allArtifactsHighestVersion);
-                                                       Version currVersion = extractOsgiVersion(aVersion);
-                                                       if (currVersion.compareTo(cachedHighestVersion) > 0)
-                                                               allArtifactsHighestVersion = aVersion;
-                                               }
-                                       } else {
-                                               Version currVersion = extractOsgiVersion(aVersion);
-                                               Version currentHighestVersion = extractOsgiVersion(highestAVersion);
-                                               if (currVersion.compareTo(currentHighestVersion) > 0) {
-                                                       highestAVersion = aVersion;
-                                               }
-                                               if (currVersion
-                                                               .compareTo(extractOsgiVersion(allArtifactsHighestVersion)) > 0) {
-                                                       allArtifactsHighestVersion = aVersion;
-                                               }
-                                       }
-
-                               }
-                       }
-                       return highestAVersion;
-               } catch (RepositoryException re) {
-                       throw new SlcException("Unable to get latest version for node "
-                                       + artifactBase, re);
-               }
-       }
-
-       private Version extractOsgiVersion(Node artifactVersion)
-                       throws RepositoryException {
-               String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION)
-                               .getString();
-               String cleanVersion = rawVersion.replace("-SNAPSHOT", ".SNAPSHOT");
-               Version osgiVersion = null;
-               // log invalid version value to enable tracking them
-               try {
-                       osgiVersion = new Version(cleanVersion);
-               } catch (IllegalArgumentException e) {
-                       log.error("Version string " + cleanVersion + " is invalid ");
-                       String twickedVersion = twickInvalidVersion(cleanVersion);
-                       osgiVersion = new Version(twickedVersion);
-                       log.error("Using " + twickedVersion + " instead");
-                       // throw e;
-               }
-               return osgiVersion;
-       }
-
-       private String twickInvalidVersion(String tmpVersion) {
-               String[] tokens = tmpVersion.split("\\.");
-               if (tokens.length == 3 && tokens[2].lastIndexOf("-") > 0) {
-                       String newSuffix = tokens[2].replaceFirst("-", ".");
-                       tmpVersion = tmpVersion.replaceFirst(tokens[2], newSuffix);
-               } else if (tokens.length > 4) {
-                       // FIXME manually remove other "."
-                       StringTokenizer st = new StringTokenizer(tmpVersion, ".", true);
-                       StringBuilder builder = new StringBuilder();
-                       // Major
-                       builder.append(st.nextToken()).append(st.nextToken());
-                       // Minor
-                       builder.append(st.nextToken()).append(st.nextToken());
-                       // Micro
-                       builder.append(st.nextToken()).append(st.nextToken());
-                       // Qualifier
-                       builder.append(st.nextToken());
-                       while (st.hasMoreTokens()) {
-                               // consume delimiter
-                               st.nextToken();
-                               if (st.hasMoreTokens())
-                                       builder.append("-").append(st.nextToken());
-                       }
-                       tmpVersion = builder.toString();
-               }
-               return tmpVersion;
-       }
-
-       // private String generatePomForBundle(Node n) throws RepositoryException {
-       // String ownSymbolicName = JcrUtils.get(n, SLC_SYMBOLIC_NAME);
-       //
-       // StringBuffer p = new StringBuffer();
-       //
-       // // XML header
-       // p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-       // p.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
-       // p.append("<modelVersion>4.0.0</modelVersion>");
-       //
-       // // Artifact
-       // p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
-       // .append("</groupId>\n");
-       // p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
-       // .append("</artifactId>\n");
-       // p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
-       // .append("</version>\n");
-       // p.append("<packaging>pom</packaging>\n");
-       // if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
-       // p.append("<name>")
-       // .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
-       // .append("</name>\n");
-       // if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
-       // p.append("<description>")
-       // .append(JcrUtils
-       // .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
-       // .append("</description>\n");
-       //
-       // // Dependencies
-       // Set<String> dependenciesSymbolicNames = new TreeSet<String>();
-       // Set<String> optionalSymbolicNames = new TreeSet<String>();
-       // NodeIterator importPackages = n.getNodes(SLC_
-       // + Constants.IMPORT_PACKAGE);
-       // while (importPackages.hasNext()) {
-       // Node importPackage = importPackages.nextNode();
-       // String pkg = JcrUtils.get(importPackage, SLC_NAME);
-       // if (packagesToSymbolicNames.containsKey(pkg)) {
-       // String dependencySymbolicName = packagesToSymbolicNames
-       // .get(pkg);
-       // if (JcrUtils.check(importPackage, SLC_OPTIONAL))
-       // optionalSymbolicNames.add(dependencySymbolicName);
-       // else
-       // dependenciesSymbolicNames.add(dependencySymbolicName);
-       // } else {
-       // if (!JcrUtils.check(importPackage, SLC_OPTIONAL)
-       // && !systemPackages.contains(pkg))
-       // log.warn("No bundle found for pkg " + pkg);
-       // }
-       // }
-       //
-       // if (n.hasNode(SLC_ + Constants.FRAGMENT_HOST)) {
-       // String fragmentHost = JcrUtils.get(
-       // n.getNode(SLC_ + Constants.FRAGMENT_HOST),
-       // SLC_SYMBOLIC_NAME);
-       // dependenciesSymbolicNames.add(fragmentHost);
-       // }
-       //
-       // // TODO require bundles
-       //
-       // List<Node> dependencyNodes = new ArrayList<Node>();
-       // for (String depSymbName : dependenciesSymbolicNames) {
-       // if (depSymbName.equals(ownSymbolicName))
-       // continue;// skip self
-       //
-       // if (symbolicNamesToNodes.containsKey(depSymbName))
-       // dependencyNodes.add(symbolicNamesToNodes.get(depSymbName));
-       // else
-       // log.warn("Could not find node for " + depSymbName);
-       // }
-       // List<Node> optionalDependencyNodes = new ArrayList<Node>();
-       // for (String depSymbName : optionalSymbolicNames) {
-       // if (symbolicNamesToNodes.containsKey(depSymbName))
-       // optionalDependencyNodes.add(symbolicNamesToNodes
-       // .get(depSymbName));
-       // else
-       // log.warn("Could not find node for " + depSymbName);
-       // }
-       //
-       // p.append("<dependencies>\n");
-       // for (Node dependencyNode : dependencyNodes) {
-       // p.append("<dependency>\n");
-       // p.append("\t<groupId>")
-       // .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
-       // .append("</groupId>\n");
-       // p.append("\t<artifactId>")
-       // .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
-       // .append("</artifactId>\n");
-       // p.append("</dependency>\n");
-       // }
-       //
-       // if (optionalDependencyNodes.size() > 0)
-       // p.append("<!-- OPTIONAL -->\n");
-       // for (Node dependencyNode : optionalDependencyNodes) {
-       // p.append("<dependency>\n");
-       // p.append("\t<groupId>")
-       // .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
-       // .append("</groupId>\n");
-       // p.append("\t<artifactId>")
-       // .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
-       // .append("</artifactId>\n");
-       // p.append("\t<optional>true</optional>\n");
-       // p.append("</dependency>\n");
-       // }
-       // p.append("</dependencies>\n");
-       //
-       // // Dependency management
-       // p.append("<dependencyManagement>\n");
-       // p.append("<dependencies>\n");
-       // p.append("<dependency>\n");
-       // p.append("\t<groupId>").append(groupId).append("</groupId>\n");
-       // p.append("\t<artifactId>")
-       // .append(ownSymbolicName.endsWith(".source") ?
-       // RepoConstants.SOURCES_ARTIFACT_ID
-       // : RepoConstants.BINARIES_ARTIFACT_ID)
-       // .append("</artifactId>\n");
-       // p.append("\t<version>").append(version).append("</version>\n");
-       // p.append("\t<type>pom</type>\n");
-       // p.append("\t<scope>import</scope>\n");
-       // p.append("</dependency>\n");
-       // p.append("</dependencies>\n");
-       // p.append("</dependencyManagement>\n");
-       //
-       // p.append("</project>\n");
-       // return p.toString();
-       // }
-
-       /* SETTERS */
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setCredentials(Credentials credentials) {
-               this.credentials = credentials;
-       }
-
-       public void setWorkspace(String workspace) {
-               this.workspace = workspace;
-       }
-
-       public void setGroupId(String groupId) {
-               this.groupId = groupId;
-       }
-
-       public void setParentPomCoordinates(String parentPomCoordinates) {
-               this.parentPomCoordinates = parentPomCoordinates;
-       }
-
-       public void setArtifactBasePath(String artifactBasePath) {
-               this.artifactBasePath = artifactBasePath;
-       }
-
-       public void setVersion(String version) {
-               this.version = version;
-       }
-
-       public void setExcludedSuffixes(List<String> excludedSuffixes) {
-               this.excludedSuffixes = excludedSuffixes;
-       }
-
-       public void setArtifactIndexer(ArtifactIndexer artifactIndexer) {
-               this.artifactIndexer = artifactIndexer;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/IndexDistribution.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/IndexDistribution.java
deleted file mode 100644 (file)
index 1d013f5..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.argeo.slc.repo.maven;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.aether.artifact.Artifact;
-
-/** Create a distribution node from a set of artifacts */
-public class IndexDistribution implements Runnable {
-       private final static Log log = LogFactory.getLog(IndexDistribution.class);
-       private Repository repository;
-       private String workspace;
-
-       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
-       private String distributionsBasePath = RepoConstants.DISTRIBUTIONS_BASE_PATH;
-       private String distributionName;
-
-       public void run() {
-               // TODO populate
-               Set<Artifact> artifacts = new HashSet<Artifact>();
-
-               // sync
-               Session session = null;
-               try {
-                       session = repository.login(workspace);
-                       syncDistribution(session, artifacts);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot import distribution", e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       protected void syncDistribution(Session jcrSession, Set<Artifact> artifacts) {
-               Long begin = System.currentTimeMillis();
-               try {
-                       JcrUtils.mkdirs(jcrSession, distributionsBasePath + '/'
-                                       + distributionName);
-                       artifacts: for (Artifact artifact : artifacts) {
-                               File file = artifact.getFile();
-                               if (file == null) {
-                                       file = MavenConventionsUtils.artifactToFile(artifact);
-                                       if (!file.exists()) {
-                                               log.warn("Generated file " + file + " for " + artifact
-                                                               + " does not exist");
-                                               continue artifacts;
-                                       }
-                               }
-
-                               try {
-                                       String parentPath = artifactBasePath
-                                                       + (artifactBasePath.endsWith("/") ? "" : "/")
-                                                       + artifactParentPath(artifact);
-                                       Node parentNode = jcrSession.getNode(parentPath);
-                                       Node fileNode = parentNode.getNode(file.getName());
-
-                                       if (fileNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME)) {
-                                               String distPath = bundleDistributionPath(fileNode);
-                                               if (!jcrSession.itemExists(distPath)
-                                                               && fileNode
-                                                                               .isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT))
-                                                       jcrSession.getWorkspace().clone(
-                                                                       jcrSession.getWorkspace().getName(),
-                                                                       fileNode.getPath(), distPath, false);
-                                               if (log.isDebugEnabled())
-                                                       log.debug("Indexed " + fileNode);
-                                       }
-                               } catch (Exception e) {
-                                       log.error("Could not index " + artifact, e);
-                                       jcrSession.refresh(false);
-                                       throw e;
-                               }
-                       }
-
-                       Long duration = (System.currentTimeMillis() - begin) / 1000;
-                       if (log.isDebugEnabled())
-                               log.debug("Indexed distribution in " + duration + "s");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot synchronize distribution", e);
-               }
-       }
-
-       private String artifactParentPath(Artifact artifact) {
-               return artifact.getGroupId().replace('.', '/') + '/'
-                               + artifact.getArtifactId() + '/' + artifact.getVersion();
-       }
-
-       private String bundleDistributionPath(Node fileNode) {
-               try {
-                       return distributionsBasePath
-                                       + '/'
-                                       + distributionName
-                                       + '/'
-                                       + fileNode.getProperty(SlcNames.SLC_SYMBOLIC_NAME)
-                                                       .getString()
-                                       + '_'
-                                       + fileNode.getProperty(SlcNames.SLC_BUNDLE_VERSION)
-                                                       .getString();
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot create distribution path for "
-                                       + fileNode, e);
-               }
-       }
-
-       public void setDistributionName(String distributionName) {
-               this.distributionName = distributionName;
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setWorkspace(String workspace) {
-               this.workspace = workspace;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java
deleted file mode 100644 (file)
index 9487e4d..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-package org.argeo.slc.repo.maven;
-
-import java.io.File;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * Static utilities around Maven which are NOT using the Maven APIs (conventions
- * based).
- */
-public class MavenConventionsUtils {
-       private final static Log log = LogFactory.getLog(MavenConventionsUtils.class);
-
-       /**
-        * Path to the file identified by this artifact <b>without</b> using Maven
-        * APIs (convention based). Default location of repository
-        * (~/.m2/repository) is used here.
-        * 
-        * @see MavenConventionsUtils#artifactToFile(String, Artifact)
-        */
-       public static File artifactToFile(Artifact artifact) {
-               return artifactToFile(System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository",
-                               artifact);
-       }
-
-       /**
-        * Path to the file identified by this artifact <b>without</b> using Maven
-        * APIs (convention based).
-        * 
-        * @param repositoryPath
-        *            path to the related local repository location
-        * @param artifact
-        *            the artifact
-        */
-       public static File artifactToFile(String repositoryPath, Artifact artifact) {
-               return new File(repositoryPath + File.separator + artifact.getGroupId().replace('.', File.separatorChar)
-                               + File.separator + artifact.getArtifactId() + File.separator + artifact.getVersion() + File.separator
-                               + artifactFileName(artifact)).getAbsoluteFile();
-       }
-
-       /** The file name of this artifact when stored */
-       public static String artifactFileName(Artifact artifact) {
-               return artifact.getArtifactId() + '-' + artifact.getVersion()
-                               + (artifact.getClassifier().equals("") ? "" : '-' + artifact.getClassifier()) + '.'
-                               + artifact.getExtension();
-       }
-
-       /** Absolute path to the file */
-       public static String artifactPath(String artifactBasePath, Artifact artifact) {
-               return artifactParentPath(artifactBasePath, artifact) + '/' + artifactFileName(artifact);
-       }
-
-       /** Absolute path to the file */
-       public static String artifactUrl(String repoUrl, Artifact artifact) {
-               if (repoUrl.endsWith("/"))
-                       return repoUrl + artifactPath("/", artifact).substring(1);
-               else
-                       return repoUrl + artifactPath("/", artifact);
-       }
-
-       /** Absolute path to the directories where the files will be stored */
-       public static String artifactParentPath(String artifactBasePath, Artifact artifact) {
-               return artifactBasePath + (artifactBasePath.endsWith("/") ? "" : "/") + artifactParentPath(artifact);
-       }
-
-       /** Absolute path to the directory of this group */
-       public static String groupPath(String artifactBasePath, String groupId) {
-               return artifactBasePath + (artifactBasePath.endsWith("/") ? "" : "/") + groupId.replace('.', '/');
-       }
-
-       /** Relative path to the directories where the files will be stored */
-       public static String artifactParentPath(Artifact artifact) {
-               return artifact.getGroupId().replace('.', '/') + '/' + artifact.getArtifactId() + '/'
-                               + artifact.getBaseVersion();
-       }
-
-       public static String artifactsAsDependencyPom(Artifact pomArtifact, Set<Artifact> artifacts, Artifact parent) {
-               StringBuffer p = new StringBuffer();
-
-               // XML header
-               p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-               p.append(
-                               "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
-               p.append("<modelVersion>4.0.0</modelVersion>\n");
-
-               // Artifact
-               if (parent != null) {
-                       p.append("<parent>\n");
-                       p.append("<groupId>").append(parent.getGroupId()).append("</groupId>\n");
-                       p.append("<artifactId>").append(parent.getArtifactId()).append("</artifactId>\n");
-                       p.append("<version>").append(parent.getVersion()).append("</version>\n");
-                       p.append("</parent>\n");
-               }
-               p.append("<groupId>").append(pomArtifact.getGroupId()).append("</groupId>\n");
-               p.append("<artifactId>").append(pomArtifact.getArtifactId()).append("</artifactId>\n");
-               p.append("<version>").append(pomArtifact.getVersion()).append("</version>\n");
-               p.append("<packaging>pom</packaging>\n");
-
-               // Dependencies
-               p.append("<dependencies>\n");
-               for (Artifact a : artifacts) {
-                       p.append("\t<dependency>");
-                       p.append("<artifactId>").append(a.getArtifactId()).append("</artifactId>");
-                       p.append("<groupId>").append(a.getGroupId()).append("</groupId>");
-                       if (!a.getExtension().equals("jar"))
-                               p.append("<type>").append(a.getExtension()).append("</type>");
-                       p.append("</dependency>\n");
-               }
-               p.append("</dependencies>\n");
-
-               // Dependency management
-               p.append("<dependencyManagement>\n");
-               p.append("<dependencies>\n");
-               for (Artifact a : artifacts) {
-                       p.append("\t<dependency>");
-                       p.append("<artifactId>").append(a.getArtifactId()).append("</artifactId>");
-                       p.append("<version>").append(a.getVersion()).append("</version>");
-                       p.append("<groupId>").append(a.getGroupId()).append("</groupId>");
-                       if (a.getExtension().equals("pom")) {
-                               p.append("<type>").append(a.getExtension()).append("</type>");
-                               p.append("<scope>import</scope>");
-                       }
-                       p.append("</dependency>\n");
-               }
-               p.append("</dependencies>\n");
-               p.append("</dependencyManagement>\n");
-
-               // Repositories
-               // p.append("<repositories>\n");
-               // p.append("<repository><id>argeo</id><url>http://maven.argeo.org/argeo</url></repository>\n");
-               // p.append("</repositories>\n");
-
-               p.append("</project>\n");
-               return p.toString();
-       }
-
-//     /**
-//      * Directly parses Maven POM XML format in order to find all artifacts
-//      * references under the dependency and dependencyManagement tags. This is
-//      * meant to migrate existing pom registering a lot of artifacts, not to
-//      * replace Maven resolving.
-//      */
-//     public static void gatherPomDependencies(AetherTemplate aetherTemplate, Set<Artifact> artifacts,
-//                     Artifact pomArtifact) {
-//             if (log.isDebugEnabled())
-//                     log.debug("Gather dependencies for " + pomArtifact);
-//
-//             try {
-//                     File file = aetherTemplate.getResolvedFile(pomArtifact);
-//                     DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-//                     Document doc = documentBuilder.parse(file);
-//
-//                     // properties
-//                     Properties props = new Properties();
-//                     props.setProperty("project.version", pomArtifact.getBaseVersion());
-//                     NodeList properties = doc.getElementsByTagName("properties");
-//                     if (properties.getLength() > 0) {
-//                             NodeList propertiesElems = properties.item(0).getChildNodes();
-//                             for (int i = 0; i < propertiesElems.getLength(); i++) {
-//                                     if (propertiesElems.item(i) instanceof Element) {
-//                                             Element property = (Element) propertiesElems.item(i);
-//                                             props.put(property.getNodeName(), property.getTextContent());
-//                                     }
-//                             }
-//                     }
-//
-//                     // dependencies (direct and dependencyManagement)
-//                     NodeList dependencies = doc.getElementsByTagName("dependency");
-//                     for (int i = 0; i < dependencies.getLength(); i++) {
-//                             Element dependency = (Element) dependencies.item(i);
-//                             String groupId = dependency.getElementsByTagName("groupId").item(0).getTextContent().trim();
-//                             String artifactId = dependency.getElementsByTagName("artifactId").item(0).getTextContent().trim();
-//                             String version = dependency.getElementsByTagName("version").item(0).getTextContent().trim();
-//                             if (version.startsWith("${")) {
-//                                     String versionKey = version.substring(0, version.length() - 1).substring(2);
-//                                     if (!props.containsKey(versionKey))
-//                                             throw new SlcException("Cannot interpret version " + version);
-//                                     version = props.getProperty(versionKey);
-//                             }
-//                             NodeList scopes = dependency.getElementsByTagName("scope");
-//                             if (scopes.getLength() > 0 && scopes.item(0).getTextContent().equals("import")) {
-//                                     // recurse
-//                                     gatherPomDependencies(aetherTemplate, artifacts,
-//                                                     new DefaultArtifact(groupId, artifactId, "pom", version));
-//                             } else {
-//                                     // TODO: deal with scope?
-//                                     // TODO: deal with type
-//                                     String type = "jar";
-//                                     Artifact artifact = new DefaultArtifact(groupId, artifactId, type, version);
-//                                     artifacts.add(artifact);
-//                             }
-//                     }
-//             } catch (Exception e) {
-//                     throw new SlcException("Cannot process " + pomArtifact, e);
-//             }
-//     }
-
-       /** Prevent instantiation */
-       private MavenConventionsUtils() {
-       }
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenProxyServiceImpl.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenProxyServiceImpl.java
deleted file mode 100644 (file)
index 9a88534..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.argeo.slc.repo.maven;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.security.AccessControlException;
-import javax.jcr.security.Privilege;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.jcr.proxy.AbstractUrlProxy;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.MavenProxyService;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/** Synchronises the node repository with remote Maven repositories */
-public class MavenProxyServiceImpl extends AbstractUrlProxy implements
-               MavenProxyService, ArgeoNames, SlcNames {
-       private final static Log log = LogFactory
-                       .getLog(MavenProxyServiceImpl.class);
-
-       private List<RemoteRepository> defaultRepositories = new ArrayList<RemoteRepository>();
-
-       /** Initialises the artifacts area. */
-       @Override
-       protected void beforeInitSessionSave(Session session)
-                       throws RepositoryException {
-               JcrUtils.addPrivilege(session, "/", SlcConstants.USER_ANONYMOUS, Privilege.JCR_READ);
-               try {
-                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
-                                       Privilege.JCR_ALL);
-               } catch (AccessControlException e) {
-                       if (log.isTraceEnabled())
-                               log.trace("Cannot give jcr:all privileges to "
-                                               + SlcConstants.ROLE_SLC);
-               }
-
-               JcrUtils.mkdirsSafe(session, RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH);
-               Node proxiedRepositories = JcrUtils.mkdirsSafe(session,
-                               RepoConstants.PROXIED_REPOSITORIES);
-               for (RemoteRepository repository : defaultRepositories) {
-                       if (!proxiedRepositories.hasNode(repository.getId())) {
-                               Node proxiedRepository = proxiedRepositories.addNode(repository
-                                               .getId());
-                               proxiedRepository.addMixin(NodeType.MIX_REFERENCEABLE);
-                               JcrUtils.urlToAddressProperties(proxiedRepository,
-                                               repository.getUrl());
-                               // proxiedRepository.setProperty(SLC_URL, repository.getUrl());
-                               proxiedRepository.setProperty(SLC_TYPE,
-                                               repository.getContentType());
-                       }
-               }
-       }
-
-       /**
-        * Retrieve and add this file to the repository
-        */
-       @Override
-       protected Node retrieve(Session session, String path) {
-               try {
-                       if (session.hasPendingChanges())
-                               throw new SlcException("Session has pending changed");
-                       Node node = null;
-                       for (Node proxiedRepository : getBaseUrls(session)) {
-                               String baseUrl = JcrUtils
-                                               .urlFromAddressProperties(proxiedRepository);
-                               node = proxyUrl(session, baseUrl, path);
-                               if (node != null) {
-                                       node.addMixin(SlcTypes.SLC_KNOWN_ORIGIN);
-                                       Node origin = node
-                                                       .addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
-                                       origin.setProperty(SLC_PROXY, proxiedRepository);
-                                       JcrUtils.urlToAddressProperties(origin, baseUrl + path);
-                                       if (log.isDebugEnabled())
-                                               log.debug("Imported " + baseUrl + path + " to " + node);
-                                       return node;
-                               }
-                       }
-                       if (log.isDebugEnabled())
-                               log.warn("No proxy found for " + path);
-                       return null;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot proxy " + path, e);
-               }
-       }
-
-       protected synchronized List<Node> getBaseUrls(Session session)
-                       throws RepositoryException {
-               List<Node> baseUrls = new ArrayList<Node>();
-               for (NodeIterator nit = session.getNode(
-                               RepoConstants.PROXIED_REPOSITORIES).getNodes(); nit.hasNext();) {
-                       Node proxiedRepository = nit.nextNode();
-                       baseUrls.add(proxiedRepository);
-               }
-               return baseUrls;
-       }
-
-       public void setDefaultRepositories(
-                       List<RemoteRepository> defaultRepositories) {
-               this.defaultRepositories = defaultRepositories;
-       }
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/Migration_01_03.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/Migration_01_03.java
deleted file mode 100644 (file)
index a7f7d16..0000000
+++ /dev/null
@@ -1,409 +0,0 @@
-package org.argeo.slc.repo.maven;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.jar.Attributes.Name;
-import java.util.jar.Manifest;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Ordering;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.ArtifactIndexer;
-import org.argeo.slc.repo.JarFileIndexer;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.osgi.OsgiProfile;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.osgi.framework.Constants;
-
-/**
- * Migrate the distribution from 1.2 to 1.4 by cleaning naming and dependencies.
- * The dependency to the SpringSource Enterprise Bundle repository is removed as
- * well as their naming conventions. All third party are move to org.argeo.tp
- * group IDs. Maven dependency for Eclipse artifacts don't use version ranges
- * anymore. Verison constraints on javax.* packages are removed (since they lead
- * to "use package conflicts" when Eclipse and Spring Security are used
- * together).
- */
-public class Migration_01_03 implements Runnable, SlcNames {
-       final String SPRING_SOURCE_PREFIX = "com.springsource";
-       private final static Log log = LogFactory.getLog(Migration_01_03.class);
-
-       private Repository repository;
-       private String sourceWorkspace;
-       private String targetWorkspace;
-
-       private List<String> excludedBundles = new ArrayList<String>();
-       private Map<String, String> symbolicNamesMapping = new HashMap<String, String>();
-
-       private Session origSession;
-       private Session targetSession;
-
-       private List<String> systemPackages = OsgiProfile.PROFILE_JAVA_SE_1_6
-                       .getSystemPackages();
-
-       private String artifactBasePath = "/";
-
-       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
-       private JarFileIndexer jarFileIndexer = new JarFileIndexer();
-
-       public void init() throws RepositoryException {
-               origSession = JcrUtils.loginOrCreateWorkspace(repository,
-                               sourceWorkspace);
-               targetSession = JcrUtils.loginOrCreateWorkspace(repository,
-                               targetWorkspace);
-
-               // works only in OSGi!!
-               // systemPackages = Arrays.asList(System.getProperty(
-               // "org.osgi.framework.system.packages").split(","));
-       }
-
-       public void destroy() {
-               JcrUtils.logoutQuietly(origSession);
-               JcrUtils.logoutQuietly(targetSession);
-       }
-
-       public void run() {
-
-               try {
-                       // clear target
-                       NodeIterator nit = targetSession.getNode(artifactBasePath)
-                                       .getNodes();
-                       while (nit.hasNext()) {
-                               Node node = nit.nextNode();
-                               if (node.isNodeType(NodeType.NT_FOLDER)
-                                               || node.isNodeType(NodeType.NT_UNSTRUCTURED)) {
-                                       node.remove();
-                                       node.getSession().save();
-                                       if (log.isDebugEnabled())
-                                               log.debug("Cleared " + node);
-                               }
-                       }
-
-                       NodeIterator origArtifacts = listArtifactVersions(origSession);
-                       // process
-                       while (origArtifacts.hasNext()) {
-                               Node origArtifactNode = origArtifacts.nextNode();
-                               if (log.isTraceEnabled())
-                                       log.trace(origArtifactNode);
-
-                               processOrigArtifactVersion(origArtifactNode);
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot perform v1.3 migration from "
-                                       + sourceWorkspace + " to " + targetWorkspace, e);
-               } finally {
-                       JcrUtils.discardQuietly(targetSession);
-               }
-       }
-
-       protected void processOrigArtifactVersion(Node origArtifactNode)
-                       throws RepositoryException, IOException {
-               Artifact origArtifact = RepoUtils.asArtifact(origArtifactNode);
-
-               // skip eclipse artifacts
-               if ((origArtifact.getGroupId().startsWith("org.eclipse") && !(origArtifact
-                               .getArtifactId().equals("org.eclipse.osgi")
-                               || origArtifact.getArtifactId().equals(
-                                               "org.eclipse.osgi.source") || origArtifact
-                               .getArtifactId().startsWith("org.eclipse.rwt.widgets.upload")))
-                               || origArtifact.getArtifactId().startsWith("com.ibm.icu")) {
-                       if (log.isDebugEnabled())
-                               log.debug("Skip " + origArtifact);
-                       return;
-               }
-
-               // skip SpringSource ActiveMQ
-               if (origArtifact.getArtifactId().startsWith(
-                               "com.springsource.org.apache.activemq"))
-                       return;
-
-               String origJarNodeName = MavenConventionsUtils
-                               .artifactFileName(origArtifact);
-               if (!origArtifactNode.hasNode(origJarNodeName))
-                       throw new SlcException("Cannot find jar node for "
-                                       + origArtifactNode);
-               Node origJarNode = origArtifactNode.getNode(origJarNodeName);
-
-               // read MANIFEST
-               Binary manifestBinary = origJarNode.getProperty(SLC_MANIFEST)
-                               .getBinary();
-               Manifest origManifest = new Manifest(manifestBinary.getStream());
-               JcrUtils.closeQuietly(manifestBinary);
-
-               Boolean manifestModified = false;
-               Manifest targetManifest = new Manifest(origManifest);
-
-               // transform symbolic name
-               String origSymbolicName = origManifest.getMainAttributes().getValue(
-                               Constants.BUNDLE_SYMBOLICNAME);
-               final String targetSymbolicName;
-               if (symbolicNamesMapping.containsKey(origSymbolicName)) {
-                       targetSymbolicName = symbolicNamesMapping.get(origSymbolicName);
-               } else if (origSymbolicName.startsWith(SPRING_SOURCE_PREFIX)
-                               && !origSymbolicName.equals(SPRING_SOURCE_PREFIX + ".json")) {
-                       targetSymbolicName = origSymbolicName
-                                       .substring(SPRING_SOURCE_PREFIX.length() + 1);
-               } else {
-                       targetSymbolicName = origSymbolicName;
-               }
-
-               if (!targetSymbolicName.equals(origSymbolicName)) {
-                       targetManifest.getMainAttributes().putValue(
-                                       Constants.BUNDLE_SYMBOLICNAME, targetSymbolicName);
-                       manifestModified = true;
-                       if (log.isDebugEnabled())
-                               log.debug(Constants.BUNDLE_SYMBOLICNAME + " to "
-                                               + targetSymbolicName + " \t\tfrom " + origSymbolicName);
-               }
-
-               // skip excluded bundles
-               if (excludedBundles.contains(targetSymbolicName))
-                       return;
-
-               // check fragment host
-               if (origManifest.getMainAttributes().containsKey(
-                               new Name(Constants.FRAGMENT_HOST))) {
-                       String origFragmentHost = origManifest.getMainAttributes()
-                                       .getValue(Constants.FRAGMENT_HOST);
-                       String targetFragmentHost;
-                       if (symbolicNamesMapping.containsKey(origFragmentHost)) {
-                               targetFragmentHost = symbolicNamesMapping.get(origFragmentHost);
-                       } else if (origFragmentHost.startsWith(SPRING_SOURCE_PREFIX)
-                                       && !origFragmentHost.equals(SPRING_SOURCE_PREFIX + ".json")) {
-                               targetFragmentHost = origFragmentHost
-                                               .substring(SPRING_SOURCE_PREFIX.length() + 1);
-                       } else if (origFragmentHost
-                                       .equals("org.argeo.dep.jacob;bundle-version=\"[1.14.3,1.14.4)\"")) {
-                               // this one for those who think I cannot be pragmatic - mbaudier
-                               targetFragmentHost = "com.jacob;bundle-version=\"[1.14.3,1.14.4)\"";
-                       } else {
-                               targetFragmentHost = origFragmentHost;
-                       }
-
-                       if (!targetFragmentHost.equals(origFragmentHost)) {
-                               targetManifest.getMainAttributes().putValue(
-                                               Constants.FRAGMENT_HOST, targetFragmentHost);
-                               manifestModified = true;
-                               if (log.isDebugEnabled())
-                                       log.debug(Constants.FRAGMENT_HOST + " to "
-                                                       + targetFragmentHost + " from " + origFragmentHost);
-                       }
-               }
-
-               // we assume there is no Require-Bundle in com.springsource.* bundles
-
-               // javax with versions
-               StringBuffer targetImportPackages = new StringBuffer("");
-               NodeIterator origImportPackages = origJarNode.getNodes(SLC_
-                               + Constants.IMPORT_PACKAGE);
-               Boolean importPackagesModified = false;
-               while (origImportPackages.hasNext()) {
-                       Node importPackage = origImportPackages.nextNode();
-                       String pkg = importPackage.getProperty(SLC_NAME).getString();
-                       targetImportPackages.append(pkg);
-                       if (importPackage.hasProperty(SLC_VERSION)) {
-                               String sourceVersion = importPackage.getProperty(SLC_VERSION)
-                                               .getString();
-                               String targetVersion = sourceVersion;
-                               if (systemPackages.contains(pkg)) {
-                                       if (!(sourceVersion.trim().equals("0") || sourceVersion
-                                                       .trim().equals("0.0.0"))) {
-                                               targetVersion = null;
-                                               importPackagesModified = true;
-                                               if (log.isDebugEnabled())
-                                                       log.debug(origSymbolicName
-                                                                       + ": Nullify version of " + pkg + " from "
-                                                                       + sourceVersion);
-                                       }
-                               }
-                               if (targetVersion != null)
-                                       targetImportPackages.append(";version=\"")
-                                                       .append(targetVersion).append("\"");
-                       }
-                       if (importPackage.hasProperty(SLC_OPTIONAL)) {
-                               Boolean optional = importPackage.getProperty(SLC_OPTIONAL)
-                                               .getBoolean();
-                               if (optional)
-                                       targetImportPackages.append(";resolution:=\"optional\"");
-
-                       }
-                       if (origImportPackages.hasNext())
-                               targetImportPackages.append(",");
-               }
-
-               if (importPackagesModified) {
-                       targetManifest.getMainAttributes().putValue(
-                                       Constants.IMPORT_PACKAGE, targetImportPackages.toString());
-                       manifestModified = true;
-               }
-
-               if (!manifestModified && log.isTraceEnabled()) {
-                       log.trace("MANIFEST of " + origSymbolicName + " was not modified");
-               }
-
-               // target coordinates
-               final String targetGroupId;
-               if (origArtifact.getArtifactId().startsWith(
-                               "org.eclipse.rwt.widgets.upload"))
-                       targetGroupId = "org.argeo.tp.rap";
-               else if (origArtifact.getArtifactId().startsWith("org.polymap"))
-                       targetGroupId = "org.argeo.tp.rap";
-               else if (origArtifact.getGroupId().startsWith("org.eclipse")
-                               && !origArtifact.getArtifactId().equals("org.eclipse.osgi"))
-                       throw new SlcException(origArtifact + " should have been excluded");// targetGroupId
-                                                                                                                                                               // =
-                                                                                                                                                               // "org.argeo.tp.eclipse";
-               else
-                       targetGroupId = "org.argeo.tp";
-
-               String targetArtifactId = targetSymbolicName.split(";")[0];
-               Artifact targetArtifact = new DefaultArtifact(targetGroupId,
-                               targetArtifactId, "jar", origArtifact.getVersion());
-               String targetParentPath = MavenConventionsUtils.artifactParentPath(
-                               artifactBasePath, targetArtifact);
-               String targetFileName = MavenConventionsUtils
-                               .artifactFileName(targetArtifact);
-               String targetJarPath = targetParentPath + '/' + targetFileName;
-
-               // copy
-               Node targetParentNode = JcrUtils.mkfolders(targetSession,
-                               targetParentPath);
-               targetSession.save();
-               if (manifestModified) {
-                       Binary origBinary = origJarNode.getNode(Node.JCR_CONTENT)
-                                       .getProperty(Property.JCR_DATA).getBinary();
-                       byte[] targetJarBytes = RepoUtils.modifyManifest(
-                                       origBinary.getStream(), targetManifest);
-                       JcrUtils.copyBytesAsFile(targetParentNode, targetFileName,
-                                       targetJarBytes);
-                       JcrUtils.closeQuietly(origBinary);
-               } else {// just copy
-                       targetSession.getWorkspace().copy(sourceWorkspace,
-                                       origJarNode.getPath(), targetJarPath);
-               }
-               targetSession.save();
-
-               // reindex
-               Node targetJarNode = targetSession.getNode(targetJarPath);
-               artifactIndexer.index(targetJarNode);
-               jarFileIndexer.index(targetJarNode);
-
-               targetSession.save();
-
-               // sources
-               Artifact origSourceArtifact = new DefaultArtifact(
-                               origArtifact.getGroupId(), origArtifact.getArtifactId()
-                                               + ".source", "jar", origArtifact.getVersion());
-               String origSourcePath = MavenConventionsUtils.artifactPath(
-                               artifactBasePath, origSourceArtifact);
-               if (origSession.itemExists(origSourcePath)) {
-                       Node origSourceJarNode = origSession.getNode(origSourcePath);
-
-                       Artifact targetSourceArtifact = new DefaultArtifact(targetGroupId,
-                                       targetArtifactId + ".source", "jar",
-                                       origArtifact.getVersion());
-                       String targetSourceParentPath = MavenConventionsUtils
-                                       .artifactParentPath(artifactBasePath, targetSourceArtifact);
-                       String targetSourceFileName = MavenConventionsUtils
-                                       .artifactFileName(targetSourceArtifact);
-                       String targetSourceJarPath = targetSourceParentPath + '/'
-                                       + targetSourceFileName;
-
-                       Node targetSourceParentNode = JcrUtils.mkfolders(targetSession,
-                                       targetSourceParentPath);
-                       targetSession.save();
-
-                       if (!targetSymbolicName.equals(origSymbolicName)) {
-                               Binary origBinary = origSourceJarNode.getNode(Node.JCR_CONTENT)
-                                               .getProperty(Property.JCR_DATA).getBinary();
-                               NameVersion targetNameVersion = RepoUtils
-                                               .readNameVersion(targetManifest);
-                               byte[] targetJarBytes = RepoUtils.packageAsPdeSource(
-                                               origBinary.getStream(), targetNameVersion);
-                               JcrUtils.copyBytesAsFile(targetSourceParentNode,
-                                               targetSourceFileName, targetJarBytes);
-                               JcrUtils.closeQuietly(origBinary);
-                       } else {// just copy
-                               targetSession.getWorkspace().copy(sourceWorkspace,
-                                               origSourceJarNode.getPath(), targetSourceJarPath);
-                       }
-                       targetSession.save();
-
-                       // reindex
-                       Node targetSourceJarNode = targetSession
-                                       .getNode(targetSourceJarPath);
-                       artifactIndexer.index(targetSourceJarNode);
-                       jarFileIndexer.index(targetSourceJarNode);
-
-                       targetSession.save();
-               }
-       }
-
-       /*
-        * UTILITIES
-        */
-
-       static NodeIterator listArtifactVersions(Session session)
-                       throws RepositoryException {
-               QueryManager queryManager = session.getWorkspace().getQueryManager();
-               QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
-               final String artifactVersionsSelector = "artifactVersions";
-               Selector source = factory.selector(SlcTypes.SLC_ARTIFACT_VERSION_BASE,
-                               artifactVersionsSelector);
-
-               Ordering orderByArtifactId = factory.ascending(factory.propertyValue(
-                               artifactVersionsSelector, SlcNames.SLC_ARTIFACT_ID));
-               Ordering[] orderings = { orderByArtifactId };
-
-               QueryObjectModel query = factory.createQuery(source, null, orderings,
-                               null);
-
-               QueryResult result = query.execute();
-               return result.getNodes();
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setSourceWorkspace(String sourceWorkspace) {
-               this.sourceWorkspace = sourceWorkspace;
-       }
-
-       public void setTargetWorkspace(String targetWorkspace) {
-               this.targetWorkspace = targetWorkspace;
-       }
-
-       public void setExcludedBundles(List<String> excludedBundles) {
-               this.excludedBundles = excludedBundles;
-       }
-
-       public void setSymbolicNamesMapping(Map<String, String> symbolicNamesMapping) {
-               this.symbolicNamesMapping = symbolicNamesMapping;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveSourcesProvider.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveSourcesProvider.java
deleted file mode 100644 (file)
index ab52c70..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.jar.JarEntry;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Session;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.OsgiFactory;
-
-public class ArchiveSourcesProvider implements SourcesProvider {
-       private final static Log log = LogFactory
-                       .getLog(ArchiveSourcesProvider.class);
-
-       private OsgiFactory osgiFactory;
-       private String uri;
-       private String base = "";
-
-       @Override
-       public void writeSources(List<String> packages, ZipOutputStream zout) {
-               Session distSession = null;
-               ZipInputStream zin = null;
-               try {
-                       distSession = osgiFactory.openDistSession();
-
-                       if (log.isDebugEnabled())
-                               log.debug("Wrapping " + uri);
-
-                       Node distNode = osgiFactory.getDist(distSession, uri);
-                       zin = new ZipInputStream(distNode.getNode(Node.JCR_CONTENT)
-                                       .getProperty(Property.JCR_DATA).getBinary().getStream());
-
-                       // prepare
-                       Set<String> directories = new TreeSet<String>();
-                       for (String pkg : packages)
-                               if (!pkg.equals("META-INF"))
-                                       directories.add(base + pkg.replace('.', '/') + '/');
-
-                       ZipEntry zentry = null;
-                       entries: while ((zentry = zin.getNextEntry()) != null) {
-                               String name = zentry.getName();
-                               if (!name.startsWith(base))
-                                       continue entries;
-
-                               String dirPath = FilenameUtils.getPath(name);
-                               if (name.equals(dirPath))// directory
-                                       continue entries;
-
-                               if (directories.contains(dirPath)) {
-                                       String path = name.substring(base.length());
-                                       zout.putNextEntry(new JarEntry(path));
-                                       IOUtils.copy(zin, zout);
-                                       zin.closeEntry();
-                                       zout.closeEntry();
-                                       continue entries;
-                               }
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot retrieve sources from " + uri, e);
-               } finally {
-                       IOUtils.closeQuietly(zin);
-                       JcrUtils.logoutQuietly(distSession);
-               }
-
-       }
-
-       public void setOsgiFactory(OsgiFactory osgiFactory) {
-               this.osgiFactory = osgiFactory;
-       }
-
-       public void setUri(String uri) {
-               this.uri = uri;
-       }
-
-       public void setBase(String base) {
-               this.base = base;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java
deleted file mode 100644 (file)
index 2a3e5b0..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.jar.JarInputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.CategoryNameVersion;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.ModuleSet;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.build.License;
-import org.argeo.slc.repo.OsgiFactory;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.internal.springutil.AntPathMatcher;
-import org.argeo.slc.repo.internal.springutil.PathMatcher;
-import org.argeo.slc.repo.maven.ArtifactIdComparator;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-import aQute.bnd.osgi.Jar;
-
-/**
- * Download a software distribution and generates the related OSGi bundles from
- * the jars, or import them directly if they are already OSGi bundles and don't
- * need further modification.
- */
-public class ArchiveWrapper implements Runnable, ModuleSet, Distribution {
-       private final static Log log = LogFactory.getLog(ArchiveWrapper.class);
-
-       private OsgiFactory osgiFactory;
-       private String version;
-       private License license;
-
-       private String uri;
-
-       /** Jars to wrap as OSGi bundles */
-       private Map<String, BndWrapper> wrappers = new HashMap<String, BndWrapper>();
-
-       private SourcesProvider sourcesProvider;
-
-       // pattern of OSGi bundles to import
-       private PathMatcher pathMatcher = new AntPathMatcher();
-       private Map<String, String> includes = new HashMap<String, String>();
-       private List<String> excludes = new ArrayList<String>();
-
-       private Boolean mavenGroupIndexes = false;
-
-       public void init() {
-               for (BndWrapper wrapper : wrappers.values()) {
-                       wrapper.setFactory(this);
-                       if (version != null && wrapper.getVersion() == null)
-                               wrapper.setVersion(version);
-                       if (license != null && wrapper.getLicense() == null)
-                               wrapper.setLicense(license);
-               }
-       }
-
-       public void destroy() {
-
-       }
-
-       public String getDistributionId() {
-               return uri;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       public License getLicense() {
-               return license;
-       }
-
-       public String getUri() {
-               return uri;
-       }
-
-       public Iterator<? extends NameVersion> nameVersions() {
-               if (wrappers.size() > 0)
-                       return wrappers.values().iterator();
-               else
-                       return osgiNameVersions();
-       }
-
-       @SuppressWarnings("resource")
-       protected Iterator<? extends NameVersion> osgiNameVersions() {
-               List<CategoryNameVersion> nvs = new ArrayList<CategoryNameVersion>();
-
-               Session distSession = null;
-               ZipInputStream zin = null;
-               try {
-                       distSession = osgiFactory.openDistSession();
-
-                       Node distNode = osgiFactory.getDist(distSession, uri);
-                       zin = new ZipInputStream(
-                                       distNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream());
-
-                       ZipEntry zentry = null;
-                       entries: while ((zentry = zin.getNextEntry()) != null) {
-                               String name = zentry.getName();
-                               if (log.isTraceEnabled())
-                                       log.trace("Zip entry " + name);
-                               for (String exclude : excludes)
-                                       if (pathMatcher.match(exclude, name))
-                                               continue entries;
-
-                               for (String include : includes.keySet()) {
-                                       if (pathMatcher.match(include, name)) {
-                                               String groupId = includes.get(include);
-                                               JarInputStream jis = new JarInputStream(zin);
-                                               if (jis.getManifest() == null) {
-                                                       log.warn("No MANIFEST in entry " + name + ", skipping...");
-                                                       continue entries;
-                                               }
-                                               NameVersion nv = RepoUtils.readNameVersion(jis.getManifest());
-                                               if (nv != null) {
-                                                       if (nv.getName().endsWith(".source"))
-                                                               continue entries;
-                                                       CategoryNameVersion cnv = new ArchiveWrapperCNV(groupId, nv.getName(), nv.getVersion(),
-                                                                       this);
-                                                       nvs.add(cnv);
-                                                       // no need to process further includes
-                                                       continue entries;
-                                               }
-                                       }
-                               }
-                       }
-                       return nvs.iterator();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot wrap distribution " + uri, e);
-               } finally {
-                       IOUtils.closeQuietly(zin);
-                       JcrUtils.logoutQuietly(distSession);
-               }
-       }
-
-       public void run() {
-               if (mavenGroupIndexes && (version == null))
-                       throw new SlcException("'mavenGroupIndexes' requires 'version' to be set");
-
-               Map<String, Set<Artifact>> binaries = new HashMap<String, Set<Artifact>>();
-               Map<String, Set<Artifact>> sources = new HashMap<String, Set<Artifact>>();
-
-               Session distSession = null;
-               Session javaSession = null;
-               ZipInputStream zin = null;
-               try {
-                       javaSession = osgiFactory.openJavaSession();
-                       distSession = osgiFactory.openDistSession();
-
-                       if (log.isDebugEnabled())
-                               log.debug("Wrapping " + uri);
-                       boolean nothingWasDone = true;
-
-                       Node distNode = osgiFactory.getDist(distSession, uri);
-                       zin = new ZipInputStream(
-                                       distNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream());
-
-                       ZipEntry zentry = null;
-                       entries: while ((zentry = zin.getNextEntry()) != null) {
-                               String name = zentry.getName();
-
-                               // sources autodetect
-                               String baseName = FilenameUtils.getBaseName(name);
-                               if (baseName.endsWith("-sources")) {
-                                       String bundle = baseName.substring(0, baseName.length() - "-sources".length());
-                                       // log.debug(name + "," + baseName + ", " + bundle);
-                                       String bundlePath = FilenameUtils.getPath(name) + bundle + ".jar";
-                                       if (wrappers.containsKey(bundlePath)) {
-                                               BndWrapper wrapper = wrappers.get(bundlePath);
-                                               NameVersion bundleNv = new DefaultNameVersion(wrapper.getName(), wrapper.getVersion());
-                                               byte[] pdeSource = RepoUtils.packageAsPdeSource(zin, bundleNv);
-                                               Artifact sourcesArtifact = new DefaultArtifact(wrapper.getCategory(),
-                                                               wrapper.getName() + ".source", "jar", wrapper.getVersion());
-                                               Node pdeSourceNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), sourcesArtifact,
-                                                               pdeSource);
-                                               osgiFactory.indexNode(pdeSourceNode);
-                                               pdeSourceNode.getSession().save();
-                                               if (log.isDebugEnabled())
-                                                       log.debug("Added sources " + sourcesArtifact + " for bundle " + wrapper.getArtifact()
-                                                                       + "from " + name + " in binary archive.");
-                                       }
-
-                               }
-                               // else if (baseName.endsWith(".source")) {
-                               // }
-
-                               // binaries
-                               if (wrappers.containsKey(name)) {
-                                       BndWrapper wrapper = (BndWrapper) wrappers.get(name);
-                                       // we must copy since the stream is closed by BND
-                                       byte[] origJarBytes = IOUtils.toByteArray(zin);
-                                       Artifact artifact = wrapZipEntry(javaSession, zentry, origJarBytes, wrapper);
-                                       nothingWasDone = false;
-                                       addArtifactToIndex(binaries, wrapper.getGroupId(), artifact);
-                               } else {
-                                       for (String wrapperKey : wrappers.keySet())
-                                               if (pathMatcher.match(wrapperKey, name)) {
-                                                       // first matched is taken
-                                                       BndWrapper wrapper = (BndWrapper) wrappers.get(wrapperKey);
-                                                       // we must copy since the stream is closed by BND
-                                                       byte[] origJarBytes = IOUtils.toByteArray(zin);
-                                                       Artifact artifact = wrapZipEntry(javaSession, zentry, origJarBytes, wrapper);
-                                                       nothingWasDone = false;
-                                                       addArtifactToIndex(binaries, wrapper.getGroupId(), artifact);
-                                                       continue entries;
-                                               } else {
-                                                       if (log.isTraceEnabled())
-                                                               log.trace(name + " not matched by " + wrapperKey);
-                                               }
-
-                                       for (String exclude : excludes)
-                                               if (pathMatcher.match(exclude, name))
-                                                       continue entries;
-
-                                       for (String include : includes.keySet()) {
-                                               if (pathMatcher.match(include, name)) {
-                                                       String groupId = includes.get(include);
-                                                       byte[] origJarBytes = IOUtils.toByteArray(zin);
-                                                       Artifact artifact = importZipEntry(javaSession, zentry, origJarBytes, groupId);
-                                                       if (artifact == null) {
-                                                               log.warn("Skipped non identified " + zentry);
-                                                               continue entries;
-                                                       }
-                                                       nothingWasDone = false;
-                                                       if (artifact.getArtifactId().endsWith(".source"))
-                                                               addArtifactToIndex(sources, groupId, artifact);
-                                                       else
-                                                               addArtifactToIndex(binaries, groupId, artifact);
-                                                       // no need to process this entry further
-                                                       continue entries;
-                                               }
-                                       }
-                               }
-                       }
-
-                       // indexes
-                       if (mavenGroupIndexes && version != null) {
-                               for (String groupId : binaries.keySet()) {
-                                       RepoUtils.writeGroupIndexes(javaSession, "/", groupId, version, binaries.get(groupId),
-                                                       sources.containsKey(groupId) ? sources.get(groupId) : null);
-                               }
-                       }
-
-                       if (nothingWasDone) {
-                               log.error("Nothing was done when wrapping " + uri + ". THE DISTRIBUTION IS INCONSISTENT.");
-                               // throw new SlcException("Nothing was done");
-                               // TODO Fail if not all wrappers matched
-                       }
-
-               } catch (Exception e) {
-                       throw new SlcException("Cannot wrap distribution " + uri, e);
-               } finally {
-                       IOUtils.closeQuietly(zin);
-                       JcrUtils.logoutQuietly(distSession);
-                       JcrUtils.logoutQuietly(javaSession);
-               }
-       }
-
-       protected Artifact wrapZipEntry(Session javaSession, ZipEntry zentry, byte[] origJarBytes, BndWrapper wrapper)
-                       throws RepositoryException {
-               ByteArrayOutputStream out = null;
-               ByteArrayInputStream in = null;
-               Node newJarNode;
-               Jar jar = null;
-               try {
-                       out = new ByteArrayOutputStream((int) zentry.getSize());
-                       in = new ByteArrayInputStream(origJarBytes);
-                       wrapper.wrapJar(in, out);
-
-                       Artifact artifact = wrapper.getArtifact();
-                       newJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), artifact, out.toByteArray());
-                       osgiFactory.indexNode(newJarNode);
-                       newJarNode.getSession().save();
-                       if (log.isDebugEnabled())
-                               log.debug("Wrapped jar " + zentry.getName() + " to " + newJarNode.getPath());
-
-                       if (sourcesProvider != null)
-                               addSource(javaSession, artifact, out.toByteArray());
-
-                       return artifact;
-               } finally {
-                       IOUtils.closeQuietly(in);
-                       IOUtils.closeQuietly(out);
-                       if (jar != null)
-                               jar.close();
-               }
-       }
-
-       protected void addSource(Session javaSession, Artifact artifact, byte[] binaryJarBytes) {
-               InputStream in = null;
-               ByteArrayOutputStream out = null;
-               Jar jar = null;
-               try {
-                       in = new ByteArrayInputStream(binaryJarBytes);
-                       jar = new Jar(null, in);
-                       List<String> packages = jar.getPackages();
-
-                       out = new ByteArrayOutputStream();
-                       sourcesProvider.writeSources(packages, new ZipOutputStream(out));
-
-                       IOUtils.closeQuietly(in);
-                       in = new ByteArrayInputStream(out.toByteArray());
-                       byte[] sourcesJar = RepoUtils.packageAsPdeSource(in,
-                                       new DefaultNameVersion(artifact.getArtifactId(), artifact.getVersion()));
-                       Artifact sourcesArtifact = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId() + ".source",
-                                       "jar", artifact.getVersion());
-                       Node sourcesJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), sourcesArtifact, sourcesJar);
-                       sourcesJarNode.getSession().save();
-
-                       if (log.isDebugEnabled())
-                               log.debug("Added sources " + sourcesArtifact + " for bundle " + artifact + "from source provider "
-                                               + sourcesProvider);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot get sources for " + artifact, e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-                       IOUtils.closeQuietly(out);
-                       if (jar != null)
-                               jar.close();
-               }
-       }
-
-       protected Artifact importZipEntry(Session javaSession, ZipEntry zentry, byte[] binaryJarBytes, String groupId)
-                       throws RepositoryException {
-               ByteArrayInputStream in = null;
-               Node newJarNode;
-               try {
-                       in = new ByteArrayInputStream(binaryJarBytes);
-                       NameVersion nameVersion = RepoUtils.readNameVersion(in);
-                       if (nameVersion == null) {
-                               log.warn("Cannot identify " + zentry.getName());
-                               return null;
-                       }
-                       Artifact artifact = new DefaultArtifact(groupId, nameVersion.getName(), "jar", nameVersion.getVersion());
-                       newJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), artifact, binaryJarBytes);
-                       osgiFactory.indexNode(newJarNode);
-                       newJarNode.getSession().save();
-                       if (log.isDebugEnabled()) {
-                               log.debug(zentry.getName() + " => " + artifact);
-                       }
-
-                       if (sourcesProvider != null)
-                               addSource(javaSession, artifact, binaryJarBytes);
-
-                       return artifact;
-               } finally {
-                       IOUtils.closeQuietly(in);
-               }
-       }
-
-       private void addArtifactToIndex(Map<String, Set<Artifact>> index, String groupId, Artifact artifact) {
-               if (!index.containsKey(groupId))
-                       index.put(groupId, new TreeSet<Artifact>(new ArtifactIdComparator()));
-               index.get(groupId).add(artifact);
-       }
-
-       public void setUri(String uri) {
-               this.uri = uri;
-       }
-
-       public void setWrappers(Map<String, BndWrapper> wrappers) {
-               this.wrappers = wrappers;
-       }
-
-       public void setOsgiFactory(OsgiFactory osgiFactory) {
-               this.osgiFactory = osgiFactory;
-       }
-
-       public void setVersion(String version) {
-               this.version = version;
-       }
-
-       public void setLicense(License license) {
-               this.license = license;
-       }
-
-       public void setPathMatcher(PathMatcher pathMatcher) {
-               this.pathMatcher = pathMatcher;
-       }
-
-       public void setIncludes(Map<String, String> includes) {
-               this.includes = includes;
-       }
-
-       public void setExcludes(List<String> excludes) {
-               this.excludes = excludes;
-       }
-
-       public void setMavenGroupIndexes(Boolean mavenGroupIndexes) {
-               this.mavenGroupIndexes = mavenGroupIndexes;
-       }
-
-       public void setSourcesProvider(SourcesProvider sourcesProvider) {
-               this.sourcesProvider = sourcesProvider;
-       }
-
-       public Map<String, BndWrapper> getWrappers() {
-               return wrappers;
-       }
-
-       public Map<String, String> getIncludes() {
-               return includes;
-       }
-
-       public List<String> getExcludes() {
-               return excludes;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapperCNV.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapperCNV.java
deleted file mode 100644 (file)
index 910d581..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import org.argeo.slc.DefaultCategoryNameVersion;
-
-/** A module within an archive. */
-public class ArchiveWrapperCNV extends DefaultCategoryNameVersion implements Runnable {
-       /** Build runnable */
-       private ArchiveWrapper build;
-
-       public ArchiveWrapperCNV(String category, String name, String version, ArchiveWrapper build) {
-               super(category, name, version);
-               this.build = build;
-       }
-
-       @Override
-       public void run() {
-               if (build != null)
-                       build.run();
-       }
-
-       public ArchiveWrapper getBuild() {
-               return build;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java
deleted file mode 100644 (file)
index 7e4a32e..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.CategoryNameVersion;
-import org.argeo.slc.ModuleSet;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.repo.ArgeoOsgiDistribution;
-import org.argeo.slc.repo.ArtifactDistribution;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.osgi.framework.Constants;
-
-/**
- * A consistent and versioned OSGi distribution, which can be built and tested.
- */
-public class ArgeoOsgiDistributionImpl extends ArtifactDistribution implements ArgeoOsgiDistribution {
-       private final static Log log = LogFactory.getLog(ArgeoOsgiDistributionImpl.class);
-
-       private List<Object> modules = new ArrayList<Object>();
-
-       public ArgeoOsgiDistributionImpl(String coords) {
-               super(coords);
-       }
-
-       public void init() {
-               if (log.isDebugEnabled())
-                       log.debug(describe());
-//             migrateTov2(Paths.get(System.getProperty("user.home"), "dev/git/gpl/argeo-tp/argeo-tp"));
-       }
-
-       public void destroy() {
-
-       }
-
-       public String describe() {
-               SortedSet<String> sort = new TreeSet<String>();
-               Iterator<? extends NameVersion> nvIt = nameVersions();
-               while (nvIt.hasNext()) {
-                       NameVersion nv = nvIt.next();
-                       String str = nv.toString();
-                       if (nv instanceof MavenWrapper)
-                               str = str + "\t(Maven)";
-                       else if (nv instanceof UriWrapper)
-                               str = str + "\t(URI)";
-                       else if (nv instanceof ArchiveWrapperCNV)
-                               str = str + "\t(OSGi from archive)";
-                       else if (nv instanceof BndWrapper)
-                               str = str + "\t(Plain BND from archive)";
-                       else
-                               str = str + "\t(UNKNOWN??)";
-                       sort.add(str);
-               }
-
-               StringBuffer buf = new StringBuffer("## DISTRIBUTION " + toString() + " ##\n");
-               for (String str : sort) {
-                       buf.append(str).append('\n');
-               }
-               return buf.toString();
-       }
-
-       public void migrateTov2(Path baseDir) {
-               Set<ArchiveWrapper> archiveWrappers = new HashSet<>();
-               Iterator<? extends NameVersion> nvIt = nameVersions();
-               while (nvIt.hasNext()) {
-                       NameVersion nv = nvIt.next();
-                       try {
-                               if (nv instanceof CategoryNameVersion) {
-                                       CategoryNameVersion cnv = (CategoryNameVersion) nv;
-                                       // TODO add branch?
-                                       Path categoryBase = baseDir.resolve(cnv.getCategory());
-                                       Files.createDirectories(categoryBase);
-                                       if (cnv instanceof BndWrapper) {
-                                               BndWrapper bw = (BndWrapper) cnv;
-                                               Path bndPath = categoryBase.resolve(cnv.getName() + ".bnd");
-                                               Map<String, String> props = new TreeMap<>();
-                                               for (Map.Entry<Object, Object> entry : ((BndWrapper) cnv).getBndProperties().entrySet()) {
-                                                       props.put(entry.getKey().toString(), entry.getValue().toString());
-                                               }
-                                               props.put(Constants.BUNDLE_SYMBOLICNAME, cnv.getName());
-                                               props.put(Constants.BUNDLE_VERSION, cnv.getVersion());
-                                               if (bw.getLicense() != null)
-                                                       props.put(Constants.BUNDLE_LICENSE, bw.getLicense().toString());
-                                               else
-                                                       log.warn("No license for " + cnv);
-                                               if (bw.getDoNotModify()) {
-                                                       props.put("SLC-Source-Original", "true");
-                                               }
-                                               // props.put("SLC-Category", cnv.getCategory());
-
-                                               if (cnv instanceof MavenWrapper) {
-                                                       MavenWrapper mw = (MavenWrapper) cnv;
-                                                       String sourceCoords = mw.getSourceCoords();
-                                                       props.put("SLC-Source-M2", sourceCoords);
-                                                       Artifact mavenCnv = new DefaultArtifact(sourceCoords);
-                                                       if (mavenCnv.getArtifactId().equals(cnv.getName()))
-                                                               props.remove(Constants.BUNDLE_SYMBOLICNAME);
-                                                       if (mavenCnv.getVersion().equals(cnv.getVersion()))
-                                                               props.remove(Constants.BUNDLE_VERSION);
-                                               } else if (cnv instanceof UriWrapper) {
-                                                       UriWrapper mw = (UriWrapper) cnv;
-                                                       props.put("SLC-Source-URI", mw.getEffectiveUri());
-                                                       if (mw.getUri() == null && mw.getBaseUri() != null) {
-                                                               log.warn("Base URI for " + cnv);
-                                                               props.put("SLC-Source-BaseURI", mw.getBaseUri());
-                                                               props.put("SLC-Source-VersionSeparator", mw.getVersionSeparator());
-                                                       }
-                                               } else {
-                                                       log.warn("Unidentified BND wrapper " + cnv);
-                                               }
-
-                                               // write BND file
-                                               try (Writer writer = Files.newBufferedWriter(bndPath)) {
-                                                       // writer.write("# " + cnv + "\n");
-                                                       props: for (String key : props.keySet()) {
-                                                               String value = props.get(key);
-                                                               if (Constants.EXPORT_PACKAGE.equals(key) && "*".equals(value.trim()))
-                                                                       continue props;
-
-                                                               writer.write(key + ": " + value + '\n');
-                                                       }
-                                                       if (log.isTraceEnabled())
-                                                               log.trace("Wrote " + bndPath);
-                                               }
-                                       } else if (cnv instanceof ArchiveWrapperCNV) {
-                                               ArchiveWrapperCNV onv = (ArchiveWrapperCNV) cnv;
-                                               ArchiveWrapper aw = onv.getBuild();
-                                               archiveWrappers.add(aw);
-                                               // TODO specify and implement archive wrapper support
-                                       } else {
-                                               log.warn("Unsupported wrapper " + cnv.getClass() + " for " + cnv);
-                                       }
-
-                               } else {
-                                       log.error("Category required for " + nv + ", skipping...");
-                               }
-                       } catch (IOException e) {
-                               log.error("Could not process " + nv, e);
-                       }
-               }
-               if (log.isDebugEnabled()) {
-                       for (ArchiveWrapper aw : archiveWrappers) {
-                               log.debug("Archive wrapper " + aw.getUri() + ":");
-                               log.debug(" includes: " + aw.getIncludes());
-                               log.debug(" excludes: " + aw.getExcludes());
-                               log.debug(" beans   : " + aw.getWrappers());
-                       }
-               }
-
-       }
-
-       public Iterator<NameVersion> nameVersions() {
-               List<NameVersion> nameVersions = new ArrayList<NameVersion>();
-               for (Object module : modules) {
-                       // extract runnable from execution flow
-                       if (module instanceof ExecutionFlow) {
-                               for (Iterator<Runnable> it = ((ExecutionFlow) module).runnables(); it.hasNext();) {
-                                       processModule(nameVersions, it.next());
-                               }
-                       } else {
-                               processModule(nameVersions, module);
-                       }
-               }
-               return nameVersions.iterator();
-       }
-
-       private void processModule(List<NameVersion> nameVersions, Object module) {
-               if (module instanceof ModuleSet)
-                       addNameVersions(nameVersions, (ModuleSet) module);
-               else if (module instanceof NameVersion) {
-                       NameVersion nv = (NameVersion) module;
-                       addNameVersion(nameVersions, nv);
-               } else
-                       log.warn("Ignored " + module);
-       }
-
-       private void addNameVersions(List<NameVersion> nameVersions, ModuleSet moduleSet) {
-               Iterator<? extends NameVersion> it = moduleSet.nameVersions();
-               while (it.hasNext()) {
-                       NameVersion nv = it.next();
-                       addNameVersion(nameVersions, nv);
-               }
-       }
-
-       protected void addNameVersion(List<NameVersion> nameVersions, NameVersion nv) {
-               if (!nameVersions.contains(nv)) {
-                       nameVersions.add(nv);
-               }
-       }
-
-       // Modular distribution interface methods. Not yet used.
-       public Distribution getModuleDistribution(String moduleName, String moduleVersion) {
-               throw new UnsupportedOperationException();
-       }
-
-       public Object getModulesDescriptor(String descriptorType) {
-               throw new UnsupportedOperationException();
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setModules(List<Object> modules) {
-               this.modules = modules;
-       }
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java
deleted file mode 100644 (file)
index ddb569b..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Properties;
-import java.util.jar.Manifest;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.CategoryNameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.build.License;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.osgi.framework.Version;
-
-import aQute.bnd.osgi.Builder;
-import aQute.bnd.osgi.Constants;
-import aQute.bnd.osgi.Jar;
-
-/** Utilities around the BND library, which manipulates OSGi metadata. */
-public class BndWrapper implements Constants, CategoryNameVersion, Distribution {
-       private final static Log log = LogFactory.getLog(BndWrapper.class);
-
-       private String groupId;
-       private String name;
-       private Properties bndProperties = new Properties();
-
-       private String version;
-       private License license;
-
-       private Boolean doNotModify = false;
-
-       private Runnable factory = null;
-
-       public void wrapJar(InputStream in, OutputStream out) {
-               Builder b = new Builder();
-               Jar jar = null;
-               try {
-                       byte[] jarBytes = IOUtils.toByteArray(in);
-
-                       jar = new Jar(name, new ByteArrayInputStream(jarBytes));
-                       Manifest sourceManifest = jar.getManifest();
-
-                       Version versionToUse;
-                       if (sourceManifest != null) {
-                               // Symbolic name
-                               String sourceSymbolicName = sourceManifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
-                               if (sourceSymbolicName != null && !sourceSymbolicName.equals(name))
-                                       log.info("The new symbolic name (" + name
-                                                       + ") is not consistant with the wrapped bundle symbolic name (" + sourceSymbolicName + ")");
-
-                               // Version
-                               String sourceVersion = sourceManifest.getMainAttributes().getValue(BUNDLE_VERSION);
-                               if (getVersion() == null && sourceVersion == null) {
-                                       throw new SlcException("A bundle version must be defined.");
-                               } else if (getVersion() == null && sourceVersion != null) {
-                                       versionToUse = new Version(sourceVersion);
-                                       version = sourceVersion; // set wrapper version
-                               } else if (getVersion() != null && sourceVersion == null) {
-                                       versionToUse = new Version(getVersion());
-                               } else {// both set
-                                       versionToUse = new Version(getVersion());
-                                       Version sv = new Version(sourceVersion);
-                                       if (versionToUse.getMajor() != sv.getMajor() || versionToUse.getMinor() != sv.getMinor()
-                                                       || versionToUse.getMicro() != sv.getMicro()) {
-                                               log.warn("The new version (" + versionToUse
-                                                               + ") is not consistant with the wrapped bundle version (" + sv + ")");
-                                       }
-                               }
-                       } else {
-                               versionToUse = new Version(getVersion());
-                       }
-
-                       if (doNotModify) {
-                               IOUtils.write(jarBytes, out);
-                               // jar.write(out);
-                       } else {
-
-                               Properties properties = new Properties();
-                               properties.putAll(bndProperties);
-                               properties.setProperty(BUNDLE_SYMBOLICNAME, name);
-                               properties.setProperty(BUNDLE_VERSION, versionToUse.toString());
-
-                               // License
-                               if (license != null) {
-                                       StringBuilder sb = new StringBuilder(license.getUri());
-                                       if (license.getName() != null)
-                                               sb.append(';').append("description=").append(license.getName());
-                                       if (license.getLink() != null)
-                                               sb.append(';').append("link=").append(license.getLink());
-                                       properties.setProperty(BUNDLE_LICENSE, sb.toString());
-                                       // TODO add LICENSE.TXT
-                               } else {
-                                       log.warn("No license set for " + toString());
-                               }
-
-                               // b.addIncluded(jarFile);
-                               b.addClasspath(jar);
-
-                               if (log.isDebugEnabled())
-                                       log.debug(properties);
-                               b.setProperties(properties);
-
-                               Jar newJar = b.build();
-                               newJar.write(out);
-                               newJar.close();
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot wrap jar", e);
-               } finally {
-                       try {
-                               b.close();
-                               if (jar != null)
-                                       jar.close();
-                       } catch (Exception e) {
-                               // silent
-                       }
-               }
-
-       }
-
-       public Runnable getFactory() {
-               return factory;
-       }
-
-       public void setFactory(Runnable factory) {
-               if (this.factory != null)
-                       throw new SlcException("Factory already set on " + name);
-               this.factory = factory;
-       }
-
-       public void setName(String bsn) {
-               this.name = bsn;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setVersion(String version) {
-               if (this.version != null)
-                       throw new SlcException("Version already set on " + name + " (" + this.version + ")");
-               this.version = version;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       public License getLicense() {
-               return license;
-       }
-
-       public void setLicense(License license) {
-               if (this.license != null)
-                       throw new SlcException("License already set on " + name);
-               this.license = license;
-       }
-
-       public Properties getBndProperties() {
-               return bndProperties;
-       }
-
-       public void setBndProperties(Properties bndProperties) {
-               this.bndProperties = bndProperties;
-       }
-
-       public String getGroupId() {
-               return groupId;
-       }
-
-       public String getCategory() {
-               return getGroupId();
-       }
-
-       public void setGroupId(String groupId) {
-               this.groupId = groupId;
-       }
-
-       public String getDistributionId() {
-               return getCategory() + ":" + getName() + ":" + getVersion();
-       }
-
-       public Artifact getArtifact() {
-               return new DefaultArtifact(groupId, name, "jar", getVersion());
-       }
-
-       @Override
-       public String toString() {
-               return getDistributionId();
-       }
-
-       @Override
-       public int hashCode() {
-               if (name != null)
-                       return name.hashCode();
-               return super.hashCode();
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               if (obj instanceof CategoryNameVersion) {
-                       CategoryNameVersion cnv = (CategoryNameVersion) obj;
-                       return getCategory().equals(cnv.getCategory()) && getName().equals(cnv.getName())
-                                       && getVersion().equals(cnv.getVersion());
-               } else
-                       return false;
-       }
-
-       public void setDoNotModify(Boolean doNotModify) {
-               this.doNotModify = doNotModify;
-       }
-
-       public Boolean getDoNotModify() {
-               return doNotModify;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ImportBundlesZip.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ImportBundlesZip.java
deleted file mode 100644 (file)
index 0518bbf..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.io.ByteArrayInputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.jar.JarInputStream;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.ArtifactIndexer;
-import org.argeo.slc.repo.JarFileIndexer;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-/**
- * Import all bundles in a zip file (typically an Eclipse distribution) into the
- * workspace.
- * 
- * @deprecated Use {@link ArchiveWrapper} instead.
- */
-@Deprecated
-public class ImportBundlesZip implements Runnable {
-       private final static Log log = LogFactory.getLog(ImportBundlesZip.class);
-       private Repository repository;
-       private String workspace;
-       private String groupId;
-       private String artifactBasePath = "/";
-
-       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
-       private JarFileIndexer jarFileIndexer = new JarFileIndexer();
-
-       private String zipFile;
-
-       private List<String> excludedBundles = new ArrayList<String>();
-
-       public void run() {
-               ZipInputStream zipIn = null;
-               JarInputStream jarIn = null;
-               Session session = null;
-               try {
-                       URL url = new URL(zipFile);
-                       session = repository.login(workspace);
-
-                       // clear
-                       // String groupPath = MavenConventionsUtils.groupPath(
-                       // artifactBasePath, groupId);
-                       // if (session.itemExists(groupPath)) {
-                       // session.getNode(groupPath).remove();
-                       // session.save();
-                       // if (log.isDebugEnabled())
-                       // log.debug("Cleared " + groupPath);
-                       // }
-
-                       zipIn = new ZipInputStream(url.openStream());
-                       ZipEntry zipEntry = null;
-                       entries: while ((zipEntry = zipIn.getNextEntry()) != null) {
-                               String entryName = zipEntry.getName();
-                               if (!entryName.endsWith(".jar")
-                                               || entryName.contains("feature"))
-                                       continue entries;// skip
-                               byte[] jarBytes = IOUtils.toByteArray(zipIn);
-                               zipIn.closeEntry();
-                               jarIn = new JarInputStream(new ByteArrayInputStream(jarBytes));
-                               Manifest manifest = jarIn.getManifest();
-                               IOUtils.closeQuietly(jarIn);
-                               if (manifest == null) {
-                                       log.warn(entryName + " has no MANIFEST");
-                                       continue entries;
-                               }
-                               NameVersion nv;
-                               try {
-                                       nv = RepoUtils.readNameVersion(manifest);
-                               } catch (Exception e) {
-                                       log.warn("Cannot read name version from " + entryName, e);
-                                       continue entries;
-                               }
-
-                               String bundleName = RepoUtils
-                                               .extractBundleNameFromSourceName(nv.getName());
-                               // skip excluded bundles and their sources
-                               if (excludedBundles.contains(bundleName))
-                                       continue entries;
-                               // for(String excludedBundle:excludedBundles){
-                               // if(bundleName.contains(excludedBundle))
-                               // continue entries;
-                               // }
-
-                               Artifact artifact = new DefaultArtifact(groupId, nv.getName(),
-                                               "jar", nv.getVersion());
-                               Node artifactNode = RepoUtils.copyBytesAsArtifact(
-                                               session.getNode(artifactBasePath), artifact, jarBytes);
-                               jarBytes = null;// superstition, in order to free memory
-
-                               // indexes
-                               artifactIndexer.index(artifactNode);
-                               jarFileIndexer.index(artifactNode);
-                               session.save();
-                               if (log.isDebugEnabled())
-                                       log.debug("Imported " + entryName + " to " + artifactNode);
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot import zip " + zipFile + " to "
-                                       + workspace, e);
-               } finally {
-                       IOUtils.closeQuietly(zipIn);
-                       IOUtils.closeQuietly(jarIn);
-                       JcrUtils.logoutQuietly(session);
-               }
-
-       }
-
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setWorkspace(String workspace) {
-               this.workspace = workspace;
-       }
-
-       public void setGroupId(String groupId) {
-               this.groupId = groupId;
-       }
-
-       public void setArtifactBasePath(String artifactBasePath) {
-               this.artifactBasePath = artifactBasePath;
-       }
-
-       public void setZipFile(String zipFile) {
-               this.zipFile = zipFile;
-       }
-
-       public void setExcludedBundles(List<String> excludedBundles) {
-               this.excludedBundles = excludedBundles;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.6.profile b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.6.profile
deleted file mode 100644 (file)
index 68e811f..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2008 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
-###############################################################################
-org.osgi.framework.system.packages = \
- javax.accessibility,\
- javax.activation,\
- javax.activity,\
- javax.annotation,\
- javax.annotation.processing,\
- javax.crypto,\
- javax.crypto.interfaces,\
- javax.crypto.spec,\
- javax.imageio,\
- javax.imageio.event,\
- javax.imageio.metadata,\
- javax.imageio.plugins.bmp,\
- javax.imageio.plugins.jpeg,\
- javax.imageio.spi,\
- javax.imageio.stream,\
- javax.jws,\
- javax.jws.soap,\
- javax.lang.model,\
- javax.lang.model.element,\
- javax.lang.model.type,\
- javax.lang.model.util,\
- javax.management,\
- javax.management.loading,\
- javax.management.modelmbean,\
- javax.management.monitor,\
- javax.management.openmbean,\
- javax.management.relation,\
- javax.management.remote,\
- javax.management.remote.rmi,\
- javax.management.timer,\
- javax.naming,\
- javax.naming.directory,\
- javax.naming.event,\
- javax.naming.ldap,\
- javax.naming.spi,\
- javax.net,\
- javax.net.ssl,\
- javax.print,\
- javax.print.attribute,\
- javax.print.attribute.standard,\
- javax.print.event,\
- javax.rmi,\
- javax.rmi.CORBA,\
- javax.rmi.ssl,\
- javax.script,\
- javax.security.auth,\
- javax.security.auth.callback,\
- javax.security.auth.kerberos,\
- javax.security.auth.login,\
- javax.security.auth.spi,\
- javax.security.auth.x500,\
- javax.security.cert,\
- javax.security.sasl,\
- javax.sound.midi,\
- javax.sound.midi.spi,\
- javax.sound.sampled,\
- javax.sound.sampled.spi,\
- javax.sql,\
- javax.sql.rowset,\
- javax.sql.rowset.serial,\
- javax.sql.rowset.spi,\
- javax.swing,\
- javax.swing.border,\
- javax.swing.colorchooser,\
- javax.swing.event,\
- javax.swing.filechooser,\
- javax.swing.plaf,\
- javax.swing.plaf.basic,\
- javax.swing.plaf.metal,\
- javax.swing.plaf.multi,\
- javax.swing.plaf.synth,\
- javax.swing.table,\
- javax.swing.text,\
- javax.swing.text.html,\
- javax.swing.text.html.parser,\
- javax.swing.text.rtf,\
- javax.swing.tree,\
- javax.swing.undo,\
- javax.tools,\
- javax.transaction,\
- javax.transaction.xa,\
- javax.xml,\
- javax.xml.bind,\
- javax.xml.bind.annotation,\
- javax.xml.bind.annotation.adapters,\
- javax.xml.bind.attachment,\
- javax.xml.bind.helpers,\
- javax.xml.bind.util,\
- javax.xml.crypto,\
- javax.xml.crypto.dom,\
- javax.xml.crypto.dsig,\
- javax.xml.crypto.dsig.dom,\
- javax.xml.crypto.dsig.keyinfo,\
- javax.xml.crypto.dsig.spec,\
- javax.xml.datatype,\
- javax.xml.namespace,\
- javax.xml.parsers,\
- javax.xml.soap,\
- javax.xml.stream,\
- javax.xml.stream.events,\
- javax.xml.stream.util,\
- javax.xml.transform,\
- javax.xml.transform.dom,\
- javax.xml.transform.sax,\
- javax.xml.transform.stax,\
- javax.xml.transform.stream,\
- javax.xml.validation,\
- javax.xml.ws,\
- javax.xml.ws.handler,\
- javax.xml.ws.handler.soap,\
- javax.xml.ws.http,\
- javax.xml.ws.soap,\
- javax.xml.ws.spi,\
- javax.xml.ws.wsaddressing,\
- javax.xml.xpath,\
- org.ietf.jgss,\
- org.omg.CORBA,\
- org.omg.CORBA_2_3,\
- org.omg.CORBA_2_3.portable,\
- org.omg.CORBA.DynAnyPackage,\
- org.omg.CORBA.ORBPackage,\
- org.omg.CORBA.portable,\
- org.omg.CORBA.TypeCodePackage,\
- org.omg.CosNaming,\
- org.omg.CosNaming.NamingContextExtPackage,\
- org.omg.CosNaming.NamingContextPackage,\
- org.omg.Dynamic,\
- org.omg.DynamicAny,\
- org.omg.DynamicAny.DynAnyFactoryPackage,\
- org.omg.DynamicAny.DynAnyPackage,\
- org.omg.IOP,\
- org.omg.IOP.CodecFactoryPackage,\
- org.omg.IOP.CodecPackage,\
- org.omg.Messaging,\
- org.omg.PortableInterceptor,\
- org.omg.PortableInterceptor.ORBInitInfoPackage,\
- org.omg.PortableServer,\
- org.omg.PortableServer.CurrentPackage,\
- org.omg.PortableServer.POAManagerPackage,\
- org.omg.PortableServer.POAPackage,\
- org.omg.PortableServer.portable,\
- org.omg.PortableServer.ServantLocatorPackage,\
- org.omg.SendingContext,\
- org.omg.stub.java.rmi,\
- org.w3c.dom,\
- org.w3c.dom.bootstrap,\
- org.w3c.dom.css,\
- org.w3c.dom.events,\
- org.w3c.dom.html,\
- org.w3c.dom.ls,\
- org.w3c.dom.ranges,\
- org.w3c.dom.stylesheets,\
- org.w3c.dom.traversal,\
- org.w3c.dom.views,\
- org.w3c.dom.xpath,\
- org.xml.sax,\
- org.xml.sax.ext,\
- org.xml.sax.helpers
-org.osgi.framework.bootdelegation = \
- javax.*,\
- org.ietf.jgss,\
- org.omg.*,\
- org.w3c.*,\
- org.xml.*,\
- sun.*,\
- com.sun.*
-org.osgi.framework.executionenvironment = \
- OSGi/Minimum-1.0,\
- OSGi/Minimum-1.1,\
- OSGi/Minimum-1.2,\
- JRE-1.1,\
- J2SE-1.2,\
- J2SE-1.3,\
- J2SE-1.4,\
- J2SE-1.5,\
- JavaSE-1.6
-osgi.java.profile.name = JavaSE-1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.7.profile b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.7.profile
deleted file mode 100644 (file)
index 192b46e..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-###############################################################################
-# Copyright (c) 2009, 2010 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
-###############################################################################
-org.osgi.framework.system.packages = \
- javax.accessibility,\
- javax.activation,\
- javax.activity,\
- javax.annotation,\
- javax.annotation.processing,\
- javax.crypto,\
- javax.crypto.interfaces,\
- javax.crypto.spec,\
- javax.imageio,\
- javax.imageio.event,\
- javax.imageio.metadata,\
- javax.imageio.plugins.bmp,\
- javax.imageio.plugins.jpeg,\
- javax.imageio.spi,\
- javax.imageio.stream,\
- javax.jws,\
- javax.jws.soap,\
- javax.lang.model,\
- javax.lang.model.element,\
- javax.lang.model.type,\
- javax.lang.model.util,\
- javax.management,\
- javax.management.event,\
- javax.management.loading,\
- javax.management.modelmbean,\
- javax.management.monitor,\
- javax.management.namespace,\
- javax.management.openmbean,\
- javax.management.relation,\
- javax.management.remote,\
- javax.management.remote.rmi,\
- javax.management.timer,\
- javax.naming,\
- javax.naming.directory,\
- javax.naming.event,\
- javax.naming.ldap,\
- javax.naming.spi,\
- javax.net,\
- javax.net.ssl,\
- javax.print,\
- javax.print.attribute,\
- javax.print.attribute.standard,\
- javax.print.event,\
- javax.rmi,\
- javax.rmi.CORBA,\
- javax.rmi.ssl,\
- javax.script,\
- javax.security.auth,\
- javax.security.auth.callback,\
- javax.security.auth.kerberos,\
- javax.security.auth.login,\
- javax.security.auth.spi,\
- javax.security.auth.x500,\
- javax.security.cert,\
- javax.security.sasl,\
- javax.sound.midi,\
- javax.sound.midi.spi,\
- javax.sound.sampled,\
- javax.sound.sampled.spi,\
- javax.sql,\
- javax.sql.rowset,\
- javax.sql.rowset.serial,\
- javax.sql.rowset.spi,\
- javax.swing,\
- javax.swing.border,\
- javax.swing.colorchooser,\
- javax.swing.event,\
- javax.swing.filechooser,\
- javax.swing.plaf,\
- javax.swing.plaf.basic,\
- javax.swing.plaf.metal,\
- javax.swing.plaf.multi,\
- javax.swing.plaf.nimbus,\
- javax.swing.plaf.synth,\
- javax.swing.table,\
- javax.swing.text,\
- javax.swing.text.html,\
- javax.swing.text.html.parser,\
- javax.swing.text.rtf,\
- javax.swing.tree,\
- javax.swing.undo,\
- javax.tools,\
- javax.transaction,\
- javax.transaction.xa,\
- javax.xml,\
- javax.xml.bind,\
- javax.xml.bind.annotation,\
- javax.xml.bind.annotation.adapters,\
- javax.xml.bind.attachment,\
- javax.xml.bind.helpers,\
- javax.xml.bind.util,\
- javax.xml.crypto,\
- javax.xml.crypto.dom,\
- javax.xml.crypto.dsig,\
- javax.xml.crypto.dsig.dom,\
- javax.xml.crypto.dsig.keyinfo,\
- javax.xml.crypto.dsig.spec,\
- javax.xml.datatype,\
- javax.xml.namespace,\
- javax.xml.parsers,\
- javax.xml.soap,\
- javax.xml.stream,\
- javax.xml.stream.events,\
- javax.xml.stream.util,\
- javax.xml.transform,\
- javax.xml.transform.dom,\
- javax.xml.transform.sax,\
- javax.xml.transform.stax,\
- javax.xml.transform.stream,\
- javax.xml.validation,\
- javax.xml.ws,\
- javax.xml.ws.handler,\
- javax.xml.ws.handler.soap,\
- javax.xml.ws.http,\
- javax.xml.ws.soap,\
- javax.xml.ws.spi,\
- javax.xml.ws.wsaddressing,\
- javax.xml.xpath,\
- org.ietf.jgss,\
- org.omg.CORBA,\
- org.omg.CORBA_2_3,\
- org.omg.CORBA_2_3.portable,\
- org.omg.CORBA.DynAnyPackage,\
- org.omg.CORBA.ORBPackage,\
- org.omg.CORBA.portable,\
- org.omg.CORBA.TypeCodePackage,\
- org.omg.CosNaming,\
- org.omg.CosNaming.NamingContextExtPackage,\
- org.omg.CosNaming.NamingContextPackage,\
- org.omg.Dynamic,\
- org.omg.DynamicAny,\
- org.omg.DynamicAny.DynAnyFactoryPackage,\
- org.omg.DynamicAny.DynAnyPackage,\
- org.omg.IOP,\
- org.omg.IOP.CodecFactoryPackage,\
- org.omg.IOP.CodecPackage,\
- org.omg.Messaging,\
- org.omg.PortableInterceptor,\
- org.omg.PortableInterceptor.ORBInitInfoPackage,\
- org.omg.PortableServer,\
- org.omg.PortableServer.CurrentPackage,\
- org.omg.PortableServer.POAManagerPackage,\
- org.omg.PortableServer.POAPackage,\
- org.omg.PortableServer.portable,\
- org.omg.PortableServer.ServantLocatorPackage,\
- org.omg.SendingContext,\
- org.omg.stub.java.rmi,\
- org.w3c.dom,\
- org.w3c.dom.bootstrap,\
- org.w3c.dom.css,\
- org.w3c.dom.events,\
- org.w3c.dom.html,\
- org.w3c.dom.ls,\
- org.w3c.dom.ranges,\
- org.w3c.dom.stylesheets,\
- org.w3c.dom.traversal,\
- org.w3c.dom.views,\
- org.w3c.dom.xpath,\
- org.xml.sax,\
- org.xml.sax.ext,\
- org.xml.sax.helpers
-org.osgi.framework.bootdelegation = \
- javax.*,\
- org.ietf.jgss,\
- org.omg.*,\
- org.w3c.*,\
- org.xml.*,\
- sun.*,\
- com.sun.*
-org.osgi.framework.executionenvironment = \
- OSGi/Minimum-1.0,\
- OSGi/Minimum-1.1,\
- OSGi/Minimum-1.2,\
- JRE-1.1,\
- J2SE-1.2,\
- J2SE-1.3,\
- J2SE-1.4,\
- J2SE-1.5,\
- JavaSE-1.6,\
- JavaSE-1.7
-osgi.java.profile.name = JavaSE-1.7
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/MavenWrapper.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/MavenWrapper.java
deleted file mode 100644 (file)
index 6ab2309..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Session;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.OsgiFactory;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-/**
- * BND wrapper based on a Maven artifact available from one of the configured
- * repositories.
- */
-public class MavenWrapper extends BndWrapper implements Runnable {
-       private final static Log log = LogFactory.getLog(MavenWrapper.class);
-
-       private String sourceCoords;
-
-       private OsgiFactory osgiFactory;
-
-       private Boolean doNotModifySources = false;
-
-       public MavenWrapper() {
-               setFactory(this);
-       }
-
-       @Override
-       public String getVersion() {
-               String version = super.getVersion();
-               if (version != null)
-                       return version;
-               return new DefaultArtifact(sourceCoords).getVersion();
-       }
-
-       public void run() {
-               Session distSession = null;
-               Session javaSession = null;
-               InputStream in = null;
-               ByteArrayOutputStream out = null;
-               try {
-                       distSession = osgiFactory.openDistSession();
-                       javaSession = osgiFactory.openJavaSession();
-                       Node origArtifact;
-                       try {
-                               origArtifact = osgiFactory.getMaven(distSession, sourceCoords);
-                       } catch (Exception e1) {
-                               origArtifact = osgiFactory.getMaven(distSession, sourceCoords + ":" + getVersion());
-                       }
-
-                       in = origArtifact.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream();
-                       out = new ByteArrayOutputStream();
-                       wrapJar(in, out);
-                       Node newJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), getArtifact(),
-                                       out.toByteArray());
-                       osgiFactory.indexNode(newJarNode);
-                       newJarNode.getSession().save();
-
-                       if (log.isDebugEnabled())
-                               log.debug("Wrapped Maven " + sourceCoords + " to " + newJarNode.getPath());
-
-                       // sources
-                       Artifact sourcesArtifact = new SubArtifact(new DefaultArtifact(sourceCoords), "sources", null);
-                       Node sourcesArtifactNode;
-                       try {
-
-                               sourcesArtifactNode = osgiFactory.getMaven(distSession, sourcesArtifact.toString());
-                       } catch (SlcException e) {
-                               // no sources available
-                               return;
-                       }
-
-                       IOUtils.closeQuietly(in);
-                       in = sourcesArtifactNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream();
-                       byte[] pdeSource;
-                       if (doNotModifySources)
-                               pdeSource = IOUtils.toByteArray(in);
-                       else
-                               pdeSource = RepoUtils.packageAsPdeSource(in, new DefaultNameVersion(getName(), getVersion()));
-                       Node pdeSourceNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(),
-                                       new DefaultArtifact(getCategory(), getName() + ".source", "jar", getVersion()), pdeSource);
-                       osgiFactory.indexNode(pdeSourceNode);
-                       pdeSourceNode.getSession().save();
-
-                       if (log.isDebugEnabled())
-                               log.debug("Wrapped Maven " + sourcesArtifact + " to PDE sources " + pdeSourceNode.getPath());
-               } catch (Exception e) {
-                       throw new SlcException("Cannot wrap Maven " + sourceCoords, e);
-               } finally {
-                       JcrUtils.logoutQuietly(distSession);
-                       JcrUtils.logoutQuietly(javaSession);
-                       IOUtils.closeQuietly(in);
-                       IOUtils.closeQuietly(out);
-               }
-       }
-
-       public void setSourceCoords(String sourceCoords) {
-               this.sourceCoords = sourceCoords;
-       }
-
-       public String getSourceCoords() {
-               return sourceCoords;
-       }
-
-       public void setOsgiFactory(OsgiFactory osgiFactory) {
-               this.osgiFactory = osgiFactory;
-       }
-
-       public void setDoNotModifySources(Boolean doNotModifySources) {
-               this.doNotModifySources = doNotModifySources;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/NormalizeGroup.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/NormalizeGroup.java
deleted file mode 100644 (file)
index 7a25c4b..0000000
+++ /dev/null
@@ -1,492 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.ArtifactIndexer;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.maven.ArtifactIdComparator;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-
-/**
- * Make sure that all JCR metadata and Maven metadata are consistent for this
- * group of OSGi bundles.
- * 
- * The job is now done via the various {@code NodeIndexer} of the
- * WorkspaceManager. TODO import dependencies in the workspace.
- */
-@Deprecated
-public class NormalizeGroup implements Runnable, SlcNames {
-       private final static Log log = LogFactory.getLog(NormalizeGroup.class);
-
-       private Repository repository;
-       private String workspace;
-       private String groupId;
-       private Boolean overridePoms = false;
-       private String artifactBasePath = "/";
-       private String version = null;
-       private String parentPomCoordinates;
-
-       private List<String> excludedSuffixes = new ArrayList<String>();
-
-       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
-       // private JarFileIndexer jarFileIndexer = new JarFileIndexer();
-
-       /** TODO make it more generic */
-       private List<String> systemPackages = OsgiProfile.PROFILE_JAVA_SE_1_6
-                       .getSystemPackages();
-
-       // indexes
-       private Map<String, String> packagesToSymbolicNames = new HashMap<String, String>();
-       private Map<String, Node> symbolicNamesToNodes = new HashMap<String, Node>();
-
-       private Set<Artifact> binaries = new TreeSet<Artifact>(
-                       new ArtifactIdComparator());
-       private Set<Artifact> sources = new TreeSet<Artifact>(
-                       new ArtifactIdComparator());
-
-       public void run() {
-               Session session = null;
-               try {
-                       session = repository.login(workspace);
-                       Node groupNode = session.getNode(MavenConventionsUtils.groupPath(
-                                       artifactBasePath, groupId));
-                       processGroupNode(groupNode, null);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot normalize group " + groupId + " in "
-                                       + workspace, e);
-               } finally {
-                       JcrUtils.logoutQuietly(session);
-               }
-       }
-
-       public static void processGroupNode(Node groupNode, String version,
-                       Boolean overridePoms, JcrMonitor monitor)
-                       throws RepositoryException {
-               // TODO set artifactsBase based on group node
-               NormalizeGroup ng = new NormalizeGroup();
-               String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
-                               .getString();
-               ng.setGroupId(groupId);
-               ng.setVersion(version);
-               ng.setOverridePoms(overridePoms);
-               ng.processGroupNode(groupNode, monitor);
-       }
-
-       protected void processGroupNode(Node groupNode, JcrMonitor monitor)
-                       throws RepositoryException {
-               if (monitor != null)
-                       monitor.subTask("Group " + groupId);
-               Node allArtifactsHighestVersion = null;
-               Session session = groupNode.getSession();
-               aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases
-                               .hasNext();) {
-                       Node aBase = aBases.nextNode();
-                       if (aBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
-                               Node highestAVersion = null;
-                               for (NodeIterator aVersions = aBase.getNodes(); aVersions
-                                               .hasNext();) {
-                                       Node aVersion = aVersions.nextNode();
-                                       if (aVersion.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
-                                               if (highestAVersion == null) {
-                                                       highestAVersion = aVersion;
-                                                       if (allArtifactsHighestVersion == null)
-                                                               allArtifactsHighestVersion = aVersion;
-
-                                                       // BS will fail if artifacts arrive in this order
-                                                       // Name1 - V1, name2 - V3, V1 will remain the
-                                                       // allArtifactsHighestVersion
-                                                       // Fixed below
-                                                       else {
-                                                               Version currVersion = extractOsgiVersion(aVersion);
-                                                               Version highestVersion = extractOsgiVersion(allArtifactsHighestVersion);
-                                                               if (currVersion.compareTo(highestVersion) > 0)
-                                                                       allArtifactsHighestVersion = aVersion;
-                                                       }
-
-                                               } else {
-                                                       Version currVersion = extractOsgiVersion(aVersion);
-                                                       Version currentHighestVersion = extractOsgiVersion(highestAVersion);
-                                                       if (currVersion.compareTo(currentHighestVersion) > 0) {
-                                                               highestAVersion = aVersion;
-                                                       }
-                                                       if (currVersion
-                                                                       .compareTo(extractOsgiVersion(allArtifactsHighestVersion)) > 0) {
-                                                               allArtifactsHighestVersion = aVersion;
-                                                       }
-                                               }
-
-                                       }
-
-                               }
-                               if (highestAVersion == null)
-                                       continue aBases;
-                               for (NodeIterator files = highestAVersion.getNodes(); files
-                                               .hasNext();) {
-                                       Node file = files.nextNode();
-                                       if (file.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
-                                               preProcessBundleArtifact(file);
-                                               file.getSession().save();
-                                               if (log.isDebugEnabled())
-                                                       log.debug("Pre-processed " + file.getName());
-                                       }
-
-                               }
-                       }
-               }
-
-               // if version not set or empty, use the highest version
-               // useful when indexing a product maven repository where
-               // all artifacts have the same version for a given release
-               // => the version can then be left empty
-               if (version == null || version.trim().equals(""))
-                       if (allArtifactsHighestVersion != null)
-                               version = allArtifactsHighestVersion.getProperty(
-                                               SLC_ARTIFACT_VERSION).getString();
-                       else
-                               version = "0.0";
-               // throw new SlcException("Group version " + version
-               // + " is empty.");
-
-               int bundleCount = symbolicNamesToNodes.size();
-               if (log.isDebugEnabled())
-                       log.debug("Indexed " + bundleCount + " bundles");
-
-               int count = 1;
-               for (Node bundleNode : symbolicNamesToNodes.values()) {
-                       processBundleArtifact(bundleNode);
-                       bundleNode.getSession().save();
-                       if (log.isDebugEnabled())
-                               log.debug(count + "/" + bundleCount + " Processed "
-                                               + bundleNode.getName());
-                       count++;
-               }
-
-               // indexes
-               Set<Artifact> indexes = new TreeSet<Artifact>(
-                               new ArtifactIdComparator());
-               Artifact indexArtifact = writeIndex(session,
-                               RepoConstants.BINARIES_ARTIFACT_ID, binaries);
-               indexes.add(indexArtifact);
-               indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID,
-                               sources);
-               indexes.add(indexArtifact);
-               // sdk
-               writeIndex(session, RepoConstants.SDK_ARTIFACT_ID, indexes);
-               if (monitor != null)
-                       monitor.worked(1);
-       }
-
-       private Version extractOsgiVersion(Node artifactVersion)
-                       throws RepositoryException {
-               String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION)
-                               .getString();
-               String cleanVersion = rawVersion.replace("-SNAPSHOT", ".SNAPSHOT");
-               Version osgiVersion = null;
-               // log invalid version value to enable tracking them
-               try {
-                       osgiVersion = new Version(cleanVersion);
-               } catch (IllegalArgumentException e) {
-                       log.error("Version string " + cleanVersion + " is invalid ");
-                       String twickedVersion = twickInvalidVersion(cleanVersion);
-                       osgiVersion = new Version(twickedVersion);
-                       log.error("Using " + twickedVersion + " instead");
-                       // throw e;
-               }
-               return osgiVersion;
-       }
-
-       private String twickInvalidVersion(String tmpVersion) {
-               String[] tokens = tmpVersion.split("\\.");
-               if (tokens.length == 3 && tokens[2].lastIndexOf("-") > 0) {
-                       String newSuffix = tokens[2].replaceFirst("-", ".");
-                       tmpVersion = tmpVersion.replaceFirst(tokens[2], newSuffix);
-               } else if (tokens.length > 4) {
-                       // FIXME manually remove other "."
-                       StringTokenizer st = new StringTokenizer(tmpVersion, ".", true);
-                       StringBuilder builder = new StringBuilder();
-                       // Major
-                       builder.append(st.nextToken()).append(st.nextToken());
-                       // Minor
-                       builder.append(st.nextToken()).append(st.nextToken());
-                       // Micro
-                       builder.append(st.nextToken()).append(st.nextToken());
-                       // Qualifier
-                       builder.append(st.nextToken());
-                       while (st.hasMoreTokens()) {
-                               // consume delimiter
-                               st.nextToken();
-                               if (st.hasMoreTokens())
-                                       builder.append("-").append(st.nextToken());
-                       }
-                       tmpVersion = builder.toString();
-               }
-               return tmpVersion;
-       }
-
-       private Artifact writeIndex(Session session, String artifactId,
-                       Set<Artifact> artifacts) throws RepositoryException {
-               Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
-                               version);
-               Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(
-                               parentPomCoordinates) : null;
-               String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
-                               artifacts, parentArtifact);
-               Node node = RepoUtils.copyBytesAsArtifact(
-                               session.getNode(artifactBasePath), artifact, pom.getBytes());
-               artifactIndexer.index(node);
-
-               // TODO factorize
-               String pomSha = JcrUtils.checksumFile(node, "SHA-1");
-               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
-                               pomSha.getBytes());
-               String pomMd5 = JcrUtils.checksumFile(node, "MD5");
-               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
-                               pomMd5.getBytes());
-               session.save();
-               return artifact;
-       }
-
-       protected void preProcessBundleArtifact(Node bundleNode)
-                       throws RepositoryException {
-
-               String symbolicName = JcrUtils.get(bundleNode, SLC_SYMBOLIC_NAME);
-               if (symbolicName.endsWith(".source")) {
-                       // TODO make a shared node with classifier 'sources'?
-                       String bundleName = RepoUtils
-                                       .extractBundleNameFromSourceName(symbolicName);
-                       for (String excludedSuffix : excludedSuffixes) {
-                               if (bundleName.endsWith(excludedSuffix))
-                                       return;// skip adding to sources
-                       }
-                       sources.add(RepoUtils.asArtifact(bundleNode));
-                       return;
-               }
-
-               NodeIterator exportPackages = bundleNode.getNodes(SLC_
-                               + Constants.EXPORT_PACKAGE);
-               while (exportPackages.hasNext()) {
-                       Node exportPackage = exportPackages.nextNode();
-                       String pkg = JcrUtils.get(exportPackage, SLC_NAME);
-                       packagesToSymbolicNames.put(pkg, symbolicName);
-               }
-
-               symbolicNamesToNodes.put(symbolicName, bundleNode);
-               for (String excludedSuffix : excludedSuffixes) {
-                       if (symbolicName.endsWith(excludedSuffix))
-                               return;// skip adding to binaries
-               }
-               binaries.add(RepoUtils.asArtifact(bundleNode));
-
-               if (bundleNode.getSession().hasPendingChanges())
-                       bundleNode.getSession().save();
-       }
-
-       protected void processBundleArtifact(Node bundleNode)
-                       throws RepositoryException {
-               Node artifactFolder = bundleNode.getParent();
-               String baseName = FilenameUtils.getBaseName(bundleNode.getName());
-
-               // pom
-               String pomName = baseName + ".pom";
-               if (artifactFolder.hasNode(pomName) && !overridePoms)
-                       return;// skip
-
-               String pom = generatePomForBundle(bundleNode);
-               Node pomNode = JcrUtils.copyBytesAsFile(artifactFolder, pomName,
-                               pom.getBytes());
-               // checksum
-               String bundleSha = JcrUtils.checksumFile(bundleNode, "SHA-1");
-               JcrUtils.copyBytesAsFile(artifactFolder,
-                               bundleNode.getName() + ".sha1", bundleSha.getBytes());
-               String pomSha = JcrUtils.checksumFile(pomNode, "SHA-1");
-               JcrUtils.copyBytesAsFile(artifactFolder, pomNode.getName() + ".sha1",
-                               pomSha.getBytes());
-       }
-
-       private String generatePomForBundle(Node n) throws RepositoryException {
-               String ownSymbolicName = JcrUtils.get(n, SLC_SYMBOLIC_NAME);
-
-               StringBuffer p = new StringBuffer();
-
-               // XML header
-               p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-               p.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
-               p.append("<modelVersion>4.0.0</modelVersion>");
-
-               // Artifact
-               p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
-                               .append("</groupId>\n");
-               p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
-                               .append("</artifactId>\n");
-               p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
-                               .append("</version>\n");
-               p.append("<packaging>pom</packaging>\n");
-               if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
-                       p.append("<name>")
-                                       .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
-                                       .append("</name>\n");
-               if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
-                       p.append("<description>")
-                                       .append(JcrUtils
-                                                       .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
-                                       .append("</description>\n");
-
-               // Dependencies
-               Set<String> dependenciesSymbolicNames = new TreeSet<String>();
-               Set<String> optionalSymbolicNames = new TreeSet<String>();
-               NodeIterator importPackages = n.getNodes(SLC_
-                               + Constants.IMPORT_PACKAGE);
-               while (importPackages.hasNext()) {
-                       Node importPackage = importPackages.nextNode();
-                       String pkg = JcrUtils.get(importPackage, SLC_NAME);
-                       if (packagesToSymbolicNames.containsKey(pkg)) {
-                               String dependencySymbolicName = packagesToSymbolicNames
-                                               .get(pkg);
-                               if (JcrUtils.check(importPackage, SLC_OPTIONAL))
-                                       optionalSymbolicNames.add(dependencySymbolicName);
-                               else
-                                       dependenciesSymbolicNames.add(dependencySymbolicName);
-                       } else {
-                               if (!JcrUtils.check(importPackage, SLC_OPTIONAL)
-                                               && !systemPackages.contains(pkg))
-                                       log.warn("No bundle found for pkg " + pkg);
-                       }
-               }
-
-               if (n.hasNode(SLC_ + Constants.FRAGMENT_HOST)) {
-                       String fragmentHost = JcrUtils.get(
-                                       n.getNode(SLC_ + Constants.FRAGMENT_HOST),
-                                       SLC_SYMBOLIC_NAME);
-                       dependenciesSymbolicNames.add(fragmentHost);
-               }
-
-               // TODO require bundles
-
-               List<Node> dependencyNodes = new ArrayList<Node>();
-               for (String depSymbName : dependenciesSymbolicNames) {
-                       if (depSymbName.equals(ownSymbolicName))
-                               continue;// skip self
-
-                       if (symbolicNamesToNodes.containsKey(depSymbName))
-                               dependencyNodes.add(symbolicNamesToNodes.get(depSymbName));
-                       else
-                               log.warn("Could not find node for " + depSymbName);
-               }
-               List<Node> optionalDependencyNodes = new ArrayList<Node>();
-               for (String depSymbName : optionalSymbolicNames) {
-                       if (symbolicNamesToNodes.containsKey(depSymbName))
-                               optionalDependencyNodes.add(symbolicNamesToNodes
-                                               .get(depSymbName));
-                       else
-                               log.warn("Could not find node for " + depSymbName);
-               }
-
-               p.append("<dependencies>\n");
-               for (Node dependencyNode : dependencyNodes) {
-                       p.append("<dependency>\n");
-                       p.append("\t<groupId>")
-                                       .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
-                                       .append("</groupId>\n");
-                       p.append("\t<artifactId>")
-                                       .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
-                                       .append("</artifactId>\n");
-                       p.append("</dependency>\n");
-               }
-
-               if (optionalDependencyNodes.size() > 0)
-                       p.append("<!-- OPTIONAL -->\n");
-               for (Node dependencyNode : optionalDependencyNodes) {
-                       p.append("<dependency>\n");
-                       p.append("\t<groupId>")
-                                       .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
-                                       .append("</groupId>\n");
-                       p.append("\t<artifactId>")
-                                       .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
-                                       .append("</artifactId>\n");
-                       p.append("\t<optional>true</optional>\n");
-                       p.append("</dependency>\n");
-               }
-               p.append("</dependencies>\n");
-
-               // Dependency management
-               p.append("<dependencyManagement>\n");
-               p.append("<dependencies>\n");
-               p.append("<dependency>\n");
-               p.append("\t<groupId>").append(groupId).append("</groupId>\n");
-               p.append("\t<artifactId>")
-                               .append(ownSymbolicName.endsWith(".source") ? RepoConstants.SOURCES_ARTIFACT_ID
-                                               : RepoConstants.BINARIES_ARTIFACT_ID)
-                               .append("</artifactId>\n");
-               p.append("\t<version>").append(version).append("</version>\n");
-               p.append("\t<type>pom</type>\n");
-               p.append("\t<scope>import</scope>\n");
-               p.append("</dependency>\n");
-               p.append("</dependencies>\n");
-               p.append("</dependencyManagement>\n");
-
-               p.append("</project>\n");
-               return p.toString();
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setRepository(Repository repository) {
-               this.repository = repository;
-       }
-
-       public void setWorkspace(String workspace) {
-               this.workspace = workspace;
-       }
-
-       public void setGroupId(String groupId) {
-               this.groupId = groupId;
-       }
-
-       public void setParentPomCoordinates(String parentPomCoordinates) {
-               this.parentPomCoordinates = parentPomCoordinates;
-       }
-
-       public void setArtifactBasePath(String artifactBasePath) {
-               this.artifactBasePath = artifactBasePath;
-       }
-
-       public void setVersion(String version) {
-               this.version = version;
-       }
-
-       public void setExcludedSuffixes(List<String> excludedSuffixes) {
-               this.excludedSuffixes = excludedSuffixes;
-       }
-
-       public void setOverridePoms(Boolean overridePoms) {
-               this.overridePoms = overridePoms;
-       }
-
-       public void setArtifactIndexer(ArtifactIndexer artifactIndexer) {
-               this.artifactIndexer = artifactIndexer;
-       }
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ObrWrapper.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ObrWrapper.java
deleted file mode 100644 (file)
index 4ace647..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-public class ObrWrapper {
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java
deleted file mode 100644 (file)
index e372afd..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.io.BufferedInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.NodeIndexer;
-import org.argeo.slc.repo.OsgiFactory;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-/** Default implementation of {@link OsgiFactory}. */
-public class OsgiFactoryImpl implements OsgiFactory, SlcNames {
-       private final static Log log = LogFactory.getLog(OsgiFactoryImpl.class);
-
-       private String workspace;
-       private Repository distRepository;
-       private Repository javaRepository;
-
-       private List<NodeIndexer> nodeIndexers = new ArrayList<NodeIndexer>();
-
-       /** key is URI prefix, value list of base URLs */
-       private Map<String, List<String>> mirrors = new HashMap<String, List<String>>();
-
-       private List<String> mavenRepositories = new ArrayList<String>();
-       private String downloadBase = RepoConstants.DIST_DOWNLOAD_BASEPATH;
-       private String mavenProxyBase = downloadBase + "/maven";
-
-       public void init() {
-               if (workspace == null)
-                       throw new SlcException("A workspace must be specified");
-
-               // default Maven repo
-               if (mavenRepositories.size() == 0) {
-                       // mavenRepositories
-                       // .add("http://search.maven.org/remotecontent?filepath=");
-                       mavenRepositories.add("http://repo1.maven.org/maven2");
-               }
-
-               Session javaSession = null;
-               Session distSession = null;
-               try {
-                       // TODO rather user a JavaRepoManager that will also implicitely
-                       // manage the indexing of newly created nodes.
-                       javaSession = JcrUtils.loginOrCreateWorkspace(javaRepository, workspace);
-                       distSession = JcrUtils.loginOrCreateWorkspace(distRepository, workspace);
-
-                       // Privileges
-                       JcrUtils.addPrivilege(javaSession, "/", SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
-                       JcrUtils.addPrivilege(distSession, "/", SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot initialize OSGi Factory " + workspace, e);
-               } finally {
-                       JcrUtils.logoutQuietly(javaSession);
-                       JcrUtils.logoutQuietly(distSession);
-               }
-       }
-
-       public void destroy() {
-
-       }
-
-       public Session openJavaSession() throws RepositoryException {
-               return javaRepository.login(workspace);
-       }
-
-       public Session openDistSession() throws RepositoryException {
-               return distRepository.login(workspace);
-       }
-
-       public void indexNode(Node node) {
-               for (NodeIndexer nodeIndexer : nodeIndexers) {
-                       nodeIndexer.index(node);
-               }
-       }
-
-       public Node getMaven(Session distSession, String coords) throws RepositoryException {
-               Artifact artifact = new DefaultArtifact(coords);
-               String path = MavenConventionsUtils.artifactPath(mavenProxyBase, artifact);
-
-               // exists
-               if (distSession.itemExists(path))
-                       return distSession.getNode(path);
-
-               for (String mavenRepo : mavenRepositories) {
-                       String url = MavenConventionsUtils.artifactUrl(mavenRepo, artifact);
-                       try {
-                               Node node = loadUrlToPath(url, distSession, path);
-                               if (node != null) {
-                                       // checksums
-                                       try {
-                                               loadUrlToPath(url + ".md5", distSession, path + ".md5");
-                                       } catch (FileNotFoundException e) {
-                                               // silent
-                                       }
-                                       try {
-                                               loadUrlToPath(url + ".sha1", distSession, path + ".sha1");
-                                       } catch (FileNotFoundException e) {
-                                               // silent
-                                       }
-                                       return node;
-                               }
-                       } catch (FileNotFoundException e) {
-                               if (log.isDebugEnabled())
-                                       log.debug("Maven " + coords + " could not be downloaded from " + url);
-                       }
-               }
-               throw new SlcException("Could not download Maven " + coords);
-       }
-
-       public Node getDist(Session distSession, String uri) throws RepositoryException {
-               String distPath = downloadBase + '/' + JcrUtils.urlAsPath(uri);
-
-               // already retrieved
-               if (distSession.itemExists(distPath))
-                       return distSession.getNode(distPath);
-
-               // find mirror
-               List<String> urlBases = null;
-               String uriPrefix = null;
-               uriPrefixes: for (String uriPref : mirrors.keySet()) {
-                       if (uri.startsWith(uriPref)) {
-                               if (mirrors.get(uriPref).size() > 0) {
-                                       urlBases = mirrors.get(uriPref);
-                                       uriPrefix = uriPref;
-                                       break uriPrefixes;
-                               }
-                       }
-               }
-               if (urlBases == null)
-                       try {
-                               return loadUrlToPath(uri, distSession, distPath);
-                       } catch (FileNotFoundException e) {
-                               throw new SlcException("Cannot download " + uri, e);
-                       }
-
-               // try to download
-               for (String urlBase : urlBases) {
-                       String relativePath = uri.substring(uriPrefix.length());
-                       String url = urlBase + relativePath;
-                       try {
-                               return loadUrlToPath(url, distSession, distPath);
-                       } catch (FileNotFoundException e) {
-                               if (log.isDebugEnabled())
-                                       log.debug("Cannot download " + url + ", trying another mirror");
-                       }
-               }
-
-               throw new SlcException("Could not download " + uri);
-       }
-
-       /** Actually downloads a file to an internal location */
-       protected Node loadUrlToPath(String url, Session distSession, String path)
-                       throws RepositoryException, FileNotFoundException {
-               if (log.isDebugEnabled())
-                       log.debug("Downloading " + url + "...");
-
-               InputStream in = null;
-               URLConnection conn = null;
-               Node folderNode = JcrUtils.mkfolders(distSession, JcrUtils.parentPath(path));
-               try {
-                       URL u = new URL(url);
-                       conn = u.openConnection();
-                       conn.connect();
-                       in = new BufferedInputStream(conn.getInputStream());
-                       // byte[] arr = IOUtils.toByteArray(in);
-                       // Node fileNode = JcrUtils.copyBytesAsFile(folderNode,
-                       // JcrUtils.nodeNameFromPath(path), arr);
-                       Node fileNode = JcrUtils.copyStreamAsFile(folderNode, JcrUtils.nodeNameFromPath(path), in);
-                       fileNode.addMixin(SlcTypes.SLC_KNOWN_ORIGIN);
-                       Node origin = fileNode.addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
-                       JcrUtils.urlToAddressProperties(origin, url);
-                       distSession.save();
-                       return fileNode;
-               } catch (MalformedURLException e) {
-                       throw new SlcException("URL " + url + " not valid.", e);
-               } catch (FileNotFoundException e) {
-                       throw e;
-               } catch (IOException e) {
-                       throw new SlcException("Cannot load " + url + " to " + path, e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-               }
-
-       }
-
-       public void setWorkspace(String workspace) {
-               this.workspace = workspace;
-       }
-
-       public void setDistRepository(Repository distRepository) {
-               this.distRepository = distRepository;
-       }
-
-       public void setJavaRepository(Repository javaRepository) {
-               this.javaRepository = javaRepository;
-       }
-
-       public void setNodeIndexers(List<NodeIndexer> nodeIndexers) {
-               this.nodeIndexers = nodeIndexers;
-       }
-
-       public void setMirrors(Map<String, List<String>> mirrors) {
-               this.mirrors = mirrors;
-       }
-
-       public void setMavenRepositories(List<String> mavenRepositories) {
-               this.mavenRepositories = mavenRepositories;
-       }
-
-       public void setMavenProxyBase(String mavenProxyBase) {
-               this.mavenProxyBase = mavenProxyBase;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiProfile.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiProfile.java
deleted file mode 100644 (file)
index b15ed5d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-
-/**
- * Wraps an OSGi profile, simplifying access to its values such as system
- * packages, etc.
- */
-public class OsgiProfile {
-       public final static String PROP_SYSTEM_PACKAGES = "org.osgi.framework.system.packages";
-
-       public final static OsgiProfile PROFILE_JAVA_SE_1_6 = new OsgiProfile(
-                       "JavaSE-1.6.profile");
-
-       private final URL url;
-       private final Properties properties;
-
-       public OsgiProfile(URL url) {
-               this.url = url;
-               properties = new Properties();
-               InputStream in = null;
-               try {
-                       properties.load(this.url.openStream());
-               } catch (Exception e) {
-                       throw new SlcException("Cannot initalize OSGi profile " + url, e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-               }
-       }
-
-       public OsgiProfile(String name) {
-               this(OsgiProfile.class.getClassLoader().getResource(
-                               '/'
-                                               + OsgiProfile.class.getPackage().getName()
-                                                               .replace('.', '/') + '/' + name));
-       }
-
-       public List<String> getSystemPackages() {
-               String[] splitted = properties.getProperty(PROP_SYSTEM_PACKAGES).split(
-                               ",");
-               List<String> res = new ArrayList<String>();
-               for (String pkg : splitted) {
-                       res.add(pkg.trim());
-               }
-               return Collections.unmodifiableList(res);
-       }
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java
deleted file mode 100644 (file)
index 7d5d779..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.util.Iterator;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.CategoryNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.ArgeoOsgiDistribution;
-import org.argeo.slc.repo.ModularDistributionFactory;
-import org.argeo.slc.repo.OsgiFactory;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-/** Executes the processes required so that all managed bundles are available. */
-public class ProcessDistribution implements Runnable {
-       private final static Log log = LogFactory.getLog(ProcessDistribution.class);
-
-       private ArgeoOsgiDistribution osgiDistribution;
-       private OsgiFactory osgiFactory;
-
-       public void run() {
-               Session javaSession = null;
-               try {
-                       javaSession = osgiFactory.openJavaSession();
-                       for (Iterator<? extends NameVersion> it = osgiDistribution
-                                       .nameVersions(); it.hasNext();)
-                               processNameVersion(javaSession, it.next());
-
-                       // Check sources
-                       for (Iterator<? extends NameVersion> it = osgiDistribution
-                                       .nameVersions(); it.hasNext();) {
-                               CategoryNameVersion nv = (CategoryNameVersion) it.next();
-                               Artifact artifact = new DefaultArtifact(nv.getCategory(),
-                                               nv.getName() + ".source", "jar", nv.getVersion());
-                               String path = MavenConventionsUtils.artifactPath("/", artifact);
-                               if (!javaSession.itemExists(path))
-                                       log.warn("No source available for " + nv);
-                       }
-
-                       // explicitly create the corresponding modular distribution as we
-                       // have here all necessary info.
-                       ModularDistributionFactory mdf = new ModularDistributionFactory(
-                                       osgiFactory, osgiDistribution);
-                       mdf.run();
-
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot process distribution "
-                                       + osgiDistribution, e);
-               } finally {
-                       JcrUtils.logoutQuietly(javaSession);
-               }
-       }
-
-       protected void processNameVersion(Session javaSession,
-                       NameVersion nameVersion) throws RepositoryException {
-               if (log.isTraceEnabled())
-                       log.trace("Check " + nameVersion + "...");
-               if (!(nameVersion instanceof CategoryNameVersion))
-                       throw new SlcException("Unsupported type " + nameVersion.getClass());
-               CategoryNameVersion nv = (CategoryNameVersion) nameVersion;
-               Artifact artifact = new DefaultArtifact(nv.getCategory(), nv.getName(),
-                               "jar", nv.getVersion());
-               String path = MavenConventionsUtils.artifactPath("/", artifact);
-               if (!javaSession.itemExists(path)) {
-                       if (nv instanceof BndWrapper) {
-                               if (log.isDebugEnabled())
-                                       log.debug("Run factory for   : " + nv + "...");
-                               ((BndWrapper) nv).getFactory().run();
-                       } else if (nv instanceof Runnable) {
-                               ((Runnable) nv).run();
-                       } else {
-                               log.warn("Skip unsupported   : " + nv);
-                       }
-               } else {
-                       if (log.isTraceEnabled())
-                               log.trace("Already available : " + nv);
-               }
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setOsgiDistribution(ArgeoOsgiDistribution osgiDistribution) {
-               this.osgiDistribution = osgiDistribution;
-       }
-
-       public void setOsgiFactory(OsgiFactory osgiFactory) {
-               this.osgiFactory = osgiFactory;
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SourcesProvider.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SourcesProvider.java
deleted file mode 100644 (file)
index a0a20f6..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.util.List;
-import java.util.zip.ZipOutputStream;
-
-/** Provides access to Java sources */
-public interface SourcesProvider {
-       /**
-        * Writes sources into a ZIP (or a JAR), under the same sirectory structure.
-        * 
-        * @param packages
-        *            the packages to import
-        * @param out
-        *            the ZIP or JAR to write to
-        */
-       public void writeSources(List<String> packages, ZipOutputStream zout);
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SubArtifact.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SubArtifact.java
deleted file mode 100644 (file)
index 9ce8455..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.io.File;
-import java.util.Map;
-
-import org.eclipse.aether.artifact.AbstractArtifact;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * An artifact whose identity is derived from another artifact. <em>Note:</em> Instances of this class are immutable and
- * the exposed mutators return new objects rather than changing the current instance.
- */
-final class SubArtifact
-    extends AbstractArtifact
-{
-
-    private final Artifact mainArtifact;
-
-    private final String classifier;
-
-    private final String extension;
-
-    private final File file;
-
-    private final Map<String, String> properties;
-
-    /**
-     * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
-     * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
-     * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
-     * used to refer to the GPG signature of an artifact.
-     * 
-     * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
-     * @param classifier The classifier for this artifact, may be {@code null} if none.
-     * @param extension The extension for this artifact, may be {@code null} if none.
-     */
-    public SubArtifact( Artifact mainArtifact, String classifier, String extension )
-    {
-        this( mainArtifact, classifier, extension, (File) null );
-    }
-
-    /**
-     * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
-     * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
-     * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
-     * used to refer to the GPG signature of an artifact.
-     * 
-     * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
-     * @param classifier The classifier for this artifact, may be {@code null} if none.
-     * @param extension The extension for this artifact, may be {@code null} if none.
-     * @param file The file for this artifact, may be {@code null} if unresolved.
-     */
-    public SubArtifact( Artifact mainArtifact, String classifier, String extension, File file )
-    {
-        this( mainArtifact, classifier, extension, null, file );
-    }
-
-    /**
-     * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
-     * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
-     * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
-     * used to refer to the GPG signature of an artifact.
-     * 
-     * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
-     * @param classifier The classifier for this artifact, may be {@code null} if none.
-     * @param extension The extension for this artifact, may be {@code null} if none.
-     * @param properties The properties of the artifact, may be {@code null}.
-     */
-    public SubArtifact( Artifact mainArtifact, String classifier, String extension, Map<String, String> properties )
-    {
-        this( mainArtifact, classifier, extension, properties, null );
-    }
-
-    /**
-     * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
-     * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
-     * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
-     * used to refer to the GPG signature of an artifact.
-     * 
-     * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
-     * @param classifier The classifier for this artifact, may be {@code null} if none.
-     * @param extension The extension for this artifact, may be {@code null} if none.
-     * @param properties The properties of the artifact, may be {@code null}.
-     * @param file The file for this artifact, may be {@code null} if unresolved.
-     */
-    public SubArtifact( Artifact mainArtifact, String classifier, String extension, Map<String, String> properties,
-                        File file )
-    {
-        if ( mainArtifact == null )
-        {
-            throw new IllegalArgumentException( "no artifact specified" );
-        }
-        this.mainArtifact = mainArtifact;
-        this.classifier = classifier;
-        this.extension = extension;
-        this.file = file;
-        this.properties = copyProperties( properties );
-    }
-
-    private SubArtifact( Artifact mainArtifact, String classifier, String extension, File file,
-                         Map<String, String> properties )
-    {
-        // NOTE: This constructor assumes immutability of the provided properties, for internal use only
-        this.mainArtifact = mainArtifact;
-        this.classifier = classifier;
-        this.extension = extension;
-        this.file = file;
-        this.properties = properties;
-    }
-
-    public String getGroupId()
-    {
-        return mainArtifact.getGroupId();
-    }
-
-    public String getArtifactId()
-    {
-        return mainArtifact.getArtifactId();
-    }
-
-    public String getVersion()
-    {
-        return mainArtifact.getVersion();
-    }
-
-    public String getBaseVersion()
-    {
-        return mainArtifact.getBaseVersion();
-    }
-
-    public boolean isSnapshot()
-    {
-        return mainArtifact.isSnapshot();
-    }
-
-    public String getClassifier()
-    {
-        return expand( classifier, mainArtifact.getClassifier() );
-    }
-
-    public String getExtension()
-    {
-        return expand( extension, mainArtifact.getExtension() );
-    }
-
-    public File getFile()
-    {
-        return file;
-    }
-
-    public Artifact setFile( File file )
-    {
-        if ( ( this.file == null ) ? file == null : this.file.equals( file ) )
-        {
-            return this;
-        }
-        return new SubArtifact( mainArtifact, classifier, extension, file, properties );
-    }
-
-    public Map<String, String> getProperties()
-    {
-        return properties;
-    }
-
-    public Artifact setProperties( Map<String, String> properties )
-    {
-        if ( this.properties.equals( properties ) || ( properties == null && this.properties.isEmpty() ) )
-        {
-            return this;
-        }
-        return new SubArtifact( mainArtifact, classifier, extension, properties, file );
-    }
-
-    private static String expand( String pattern, String replacement )
-    {
-        String result = "";
-        if ( pattern != null )
-        {
-            result = pattern.replace( "*", replacement );
-
-            if ( replacement.length() <= 0 )
-            {
-                if ( pattern.startsWith( "*" ) )
-                {
-                    int i = 0;
-                    for ( ; i < result.length(); i++ )
-                    {
-                        char c = result.charAt( i );
-                        if ( c != '-' && c != '.' )
-                        {
-                            break;
-                        }
-                    }
-                    result = result.substring( i );
-                }
-                if ( pattern.endsWith( "*" ) )
-                {
-                    int i = result.length() - 1;
-                    for ( ; i >= 0; i-- )
-                    {
-                        char c = result.charAt( i );
-                        if ( c != '-' && c != '.' )
-                        {
-                            break;
-                        }
-                    }
-                    result = result.substring( 0, i + 1 );
-                }
-            }
-        }
-        return result;
-    }
-
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/UriWrapper.java b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/UriWrapper.java
deleted file mode 100644 (file)
index 262246f..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.argeo.slc.repo.osgi;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.util.List;
-import java.util.zip.ZipOutputStream;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Session;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.OsgiFactory;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-
-import aQute.bnd.osgi.Jar;
-
-public class UriWrapper extends BndWrapper implements Runnable {
-       private final static Log log = LogFactory.getLog(UriWrapper.class);
-
-       private String uri;
-       private String baseUri;
-       private String versionSeparator = "-";
-       private String extension = "jar";
-
-       private OsgiFactory osgiFactory;
-
-       private SourcesProvider sourcesProvider;
-
-       public UriWrapper() {
-               setFactory(this);
-       }
-
-       public void run() {
-               Session distSession = null;
-               Session javaSession = null;
-               InputStream in = null;
-               ByteArrayOutputStream out = null;
-               Jar jar = null;
-               try {
-                       distSession = osgiFactory.openDistSession();
-                       javaSession = osgiFactory.openJavaSession();
-                       String uri = getEffectiveUri();
-//                     if (uri == null) {
-//                             uri = baseUri + '/' + getName() + versionSeparator + getVersion() + "." + extension;
-//                     }
-                       Node sourceArtifact = osgiFactory.getDist(distSession, uri);
-
-                       // TODO factorize with Maven
-                       in = sourceArtifact.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream();
-                       out = new ByteArrayOutputStream();
-                       wrapJar(in, out);
-                       Node newJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), getArtifact(),
-                                       out.toByteArray());
-                       osgiFactory.indexNode(newJarNode);
-                       newJarNode.getSession().save();
-                       if (log.isDebugEnabled())
-                               log.debug("Wrapped " + uri + " to " + newJarNode.getPath());
-
-                       // sources
-                       if (sourcesProvider != null) {
-                               IOUtils.closeQuietly(in);
-                               in = new ByteArrayInputStream(out.toByteArray());
-                               jar = new Jar(null, in);
-                               List<String> packages = jar.getPackages();
-
-                               IOUtils.closeQuietly(out);
-                               out = new ByteArrayOutputStream();
-                               sourcesProvider.writeSources(packages, new ZipOutputStream(out));
-
-                               IOUtils.closeQuietly(in);
-                               in = new ByteArrayInputStream(out.toByteArray());
-                               byte[] sourcesJar = RepoUtils.packageAsPdeSource(in, new DefaultNameVersion(this));
-                               Artifact sourcesArtifact = new DefaultArtifact(getArtifact().getGroupId(),
-                                               getArtifact().getArtifactId() + ".source", "jar", getArtifact().getVersion());
-                               Node sourcesJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), sourcesArtifact,
-                                               sourcesJar);
-                               sourcesJarNode.getSession().save();
-
-                               if (log.isDebugEnabled())
-                                       log.debug("Added sources " + sourcesArtifact + " for bundle " + getArtifact());
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot wrap URI " + uri, e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-                       IOUtils.closeQuietly(out);
-                       JcrUtils.logoutQuietly(distSession);
-                       JcrUtils.logoutQuietly(javaSession);
-                       if (jar != null)
-                               jar.close();
-               }
-       }
-
-       public void setUri(String sourceCoords) {
-               this.uri = sourceCoords;
-       }
-
-       public String getEffectiveUri() {
-               if (uri == null) {
-                       return baseUri + '/' + getName() + versionSeparator + getVersion() + "." + extension;
-               } else
-                       return uri;
-       }
-
-       public void setOsgiFactory(OsgiFactory osgiFactory) {
-               this.osgiFactory = osgiFactory;
-       }
-
-       public void setBaseUri(String baseUri) {
-               this.baseUri = baseUri;
-       }
-
-       public void setVersionSeparator(String versionSeparator) {
-               this.versionSeparator = versionSeparator;
-       }
-
-       public void setSourcesProvider(SourcesProvider sourcesProvider) {
-               this.sourcesProvider = sourcesProvider;
-       }
-
-       public String getUri() {
-               return uri;
-       }
-
-       public String getBaseUri() {
-               return baseUri;
-       }
-
-       public String getVersionSeparator() {
-               return versionSeparator;
-       }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/repo.cnd b/cms/org.argeo.slc.repo/src/org/argeo/slc/repo/repo.cnd
deleted file mode 100644 (file)
index dacffbb..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-<repo = 'http://www.argeo.org/ns/repo'>
-
-// Argeo Commons 1 node types
-[argeo:references] > nt:unstructured
-- * (REFERENCE) *
-
-// AETHER
-[slc:artifact] > mix:referenceable, mix:created, mix:lastModified
-mixin
-- slc:artifactId (STRING) m
-- slc:groupId (STRING) m
-- slc:artifactVersion (STRING) m
-- slc:artifactExtension (STRING) m
-- slc:artifactClassifier (STRING) ='' m a
-
-[slc:artifactVersion] > mix:referenceable, mix:created, mix:lastModified, mix:title
-mixin
-- slc:artifactId (STRING) m
-- slc:groupId (STRING) m
-- slc:artifactVersion (STRING) m
-
-[slc:artifactBase] > mix:referenceable, mix:created, mix:lastModified
-mixin
-- slc:artifactId (STRING) m
-- slc:groupId (STRING) m
-
-[slc:groupBase] > mix:referenceable, mix:created, mix:lastModified
-mixin
-// it is possible to have groupBase being artifact base (e.g. org.argeo.commons.basic)
-// so using groupId would conflict 
-- slc:groupBaseId (STRING) m
-
-// Mark a given group base as relevant to create modular distribution in the current workspace  
-// [slc:category]
-// mixin
-
-[slc:distribution] > slc:artifactVersion
-mixin
-+ slc:artifactVersions (argeo:references) m
-
-
-[slc:modularDistributionBase]
-mixin
-
-// Question: Extend slc:categorizedNameVersion ? (not possible without migration)
-[slc:modularDistribution] 
-mixin
-+ slc:modules (nt:unstructured) m
-
-[slc:moduleCoordinates] > nt:unstructured
-- slc:category (STRING)
-- slc:name (STRING)
-- slc:version (STRING)
-
-
-// ORIGINS
-[slc:knownOrigin] > nt:base
-mixin
-+ slc:origin (nt:address)
-
-[slc:proxied] > nt:address
-- slc:proxy (REFERENCE)
-
-// JAVA
-[slc:jarFile] > mix:referenceable
-mixin
-- 'slc:manifest' (BINARY) m
-- 'slc:Manifest-Version' (STRING)
-- 'slc:Signature-Version' (STRING)
-- 'slc:Class-Path'  (STRING)
-- 'slc:Main-Class' (STRING)
-- 'slc:Extension-Name' (STRING)
-- 'slc:Implementation-Version' (STRING)
-- 'slc:Implementation-Vendor' (STRING)
-- 'slc:Implementation-Vendor-Id' (STRING)
-- 'slc:Implementation-URL' (STRING)
-- 'slc:Specification-Title' (STRING)
-- 'slc:Specification-Version' (STRING)
-- 'slc:Specification-Vendor' (STRING)
-- 'slc:Sealed' (STRING)
-
-// OSGi
-// see http://www.osgi.org/Specifications/Reference
-
-[slc:javaPackage] > mix:referenceable
-- slc:name (STRING) primary m
-
-[slc:osgiBaseVersion] > mix:referenceable
-- slc:asString (STRING) primary m
-- slc:major (LONG) m
-- slc:minor (LONG) m
-- slc:micro (LONG) m
-
-[slc:osgiVersion] > slc:osgiBaseVersion
-- slc:qualifier (STRING)
-
-[slc:exportedPackage] > slc:javaPackage
-+ slc:uses (slc:javaPackage) multiple
-+ slc:version (slc:osgiVersion)
-
-[slc:importedPackage] > slc:javaPackage
-- slc:version (STRING) ='0.0.0' m a
-- slc:optional (BOOLEAN) ='false' m a
-
-[slc:dynamicImportedPackage] > slc:javaPackage
-- slc:version (STRING) ='0.0.0' m a
-- slc:optional (BOOLEAN) ='false' m a
-
-[slc:requiredBundle] > mix:referenceable
-- 'slc:symbolic-name' (STRING) primary m
-- 'slc:bundle-version' (STRING) ='0.0.0' m a
-- slc:optional (BOOLEAN) ='false' m a
-
-[slc:fragmentHost] > mix:referenceable
-- 'slc:symbolic-name' (STRING) m
-- 'slc:bundle-version' (STRING) ='0.0.0' m a
-
-[slc:bundleNativeCode] > mix:referenceable
-- slc:path (STRING) primary m
-- slc:osname (STRING)
-- slc:processor (STRING)
-
-// see http://www.osgi.org/Specifications/ReferenceHeaders
-[slc:bundle] > mix:referenceable
-mixin
-- 'slc:symbolic-name' (STRING) primary m
-- 'slc:bundle-version' (STRING) m
-- 'slc:Bundle-SymbolicName' (STRING) m
-- 'slc:Bundle-Name' (STRING)
-- 'slc:Bundle-Description' (STRING)
-- 'slc:Bundle-ManifestVersion' (STRING)
-- 'slc:Bundle-Category' (STRING)
-- 'slc:Bundle-ActivationPolicy' (STRING)
-- 'slc:Bundle-Copyright' (STRING)
-- 'slc:Bundle-Vendor' (STRING)
-- 'slc:Bundle-License' (STRING)
-- 'slc:Bundle-DocURL' (STRING)
-- 'slc:Bundle-ContactAddress' (STRING)
-- 'slc:Bundle-Activator' (STRING)
-- 'slc:Bundle-UpdateLocation' (STRING)
-- 'slc:Bundle-Localization' (STRING)
-- 'slc:Bundle-ClassPath' (STRING) *
-// see http://wiki.eclipse.org/EE  < 'OSGi/Minimum-1.0','OSGi/Minimum-1.1','CDC-1.0/Foundation-1.0','CDC-1.1/Foundation-1.1','JRE-1.1','J2SE-1.2','J2SE-1.3','J2SE-1.4','J2SE-1.5','JavaSE-1.6','JavaSE-1.7'
-- 'slc:Bundle-RequiredExecutionEnvironment' (STRING) *
-+ 'slc:Bundle-Version' (slc:osgiVersion) m
-+ 'slc:Fragment-Host' (slc:fragmentHost)
-+ 'slc:Import-Package' (slc:importedPackage) multiple
-+ 'slc:Export-Package' (slc:exportedPackage) multiple
-+ 'slc:Require-Bundle' (slc:requiredBundle) multiple
-+ 'slc:Bundle-NativeCode' (slc:bundleNativeCode) multiple
-+ 'slc:DynamicImport-Package' (slc:dynamicImportedPackage) multiple
-
-[slc:bundleArtifact] > slc:artifact,slc:jarFile,slc:bundle
-mixin
-
-// RPM
-[slc:rpm] > mix:referenceable, mix:created, mix:lastModified, mix:title
-mixin
-- slc:name (STRING)
-- slc:version (STRING)
-- slc:rpmVersion (STRING)
-- slc:rpmRelease (STRING)
-- slc:rpmArch (STRING)
-- slc:rpmArchivaeSize (STRING)
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java
deleted file mode 100644 (file)
index 590ad28..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-import java.util.Map;
-
-import org.eclipse.aether.artifact.ArtifactTypeRegistry;
-import org.eclipse.aether.collection.DependencyGraphTransformer;
-import org.eclipse.aether.collection.DependencyManager;
-import org.eclipse.aether.collection.DependencySelector;
-import org.eclipse.aether.collection.DependencyTraverser;
-import org.eclipse.aether.collection.VersionFilter;
-import org.eclipse.aether.repository.AuthenticationSelector;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.LocalRepositoryManager;
-import org.eclipse.aether.repository.MirrorSelector;
-import org.eclipse.aether.repository.ProxySelector;
-import org.eclipse.aether.repository.WorkspaceReader;
-import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
-import org.eclipse.aether.resolution.ResolutionErrorPolicy;
-import org.eclipse.aether.transfer.TransferListener;
-
-/**
- * A special repository system session to enable decorating or proxying another session. To do so, clients have to
- * create a subclass and implement {@link #getSession()}.
- */
-public abstract class AbstractForwardingRepositorySystemSession
-    implements RepositorySystemSession
-{
-
-    /**
-     * Creates a new forwarding session.
-     */
-    protected AbstractForwardingRepositorySystemSession()
-    {
-    }
-
-    /**
-     * Gets the repository system session to which this instance forwards calls. It's worth noting that this class does
-     * not save/cache the returned reference but queries this method before each forwarding. Hence, the session
-     * forwarded to may change over time or depending on the context (e.g. calling thread).
-     * 
-     * @return The repository system session to forward calls to, never {@code null}.
-     */
-    protected abstract RepositorySystemSession getSession();
-
-    public boolean isOffline()
-    {
-        return getSession().isOffline();
-    }
-
-    public boolean isIgnoreArtifactDescriptorRepositories()
-    {
-        return getSession().isIgnoreArtifactDescriptorRepositories();
-    }
-
-    public ResolutionErrorPolicy getResolutionErrorPolicy()
-    {
-        return getSession().getResolutionErrorPolicy();
-    }
-
-    public ArtifactDescriptorPolicy getArtifactDescriptorPolicy()
-    {
-        return getSession().getArtifactDescriptorPolicy();
-    }
-
-    public String getChecksumPolicy()
-    {
-        return getSession().getChecksumPolicy();
-    }
-
-    public String getUpdatePolicy()
-    {
-        return getSession().getUpdatePolicy();
-    }
-
-    public LocalRepository getLocalRepository()
-    {
-        return getSession().getLocalRepository();
-    }
-
-    public LocalRepositoryManager getLocalRepositoryManager()
-    {
-        return getSession().getLocalRepositoryManager();
-    }
-
-    public WorkspaceReader getWorkspaceReader()
-    {
-        return getSession().getWorkspaceReader();
-    }
-
-    public RepositoryListener getRepositoryListener()
-    {
-        return getSession().getRepositoryListener();
-    }
-
-    public TransferListener getTransferListener()
-    {
-        return getSession().getTransferListener();
-    }
-
-    public Map<String, String> getSystemProperties()
-    {
-        return getSession().getSystemProperties();
-    }
-
-    public Map<String, String> getUserProperties()
-    {
-        return getSession().getUserProperties();
-    }
-
-    public Map<String, Object> getConfigProperties()
-    {
-        return getSession().getConfigProperties();
-    }
-
-    public MirrorSelector getMirrorSelector()
-    {
-        return getSession().getMirrorSelector();
-    }
-
-    public ProxySelector getProxySelector()
-    {
-        return getSession().getProxySelector();
-    }
-
-    public AuthenticationSelector getAuthenticationSelector()
-    {
-        return getSession().getAuthenticationSelector();
-    }
-
-    public ArtifactTypeRegistry getArtifactTypeRegistry()
-    {
-        return getSession().getArtifactTypeRegistry();
-    }
-
-    public DependencyTraverser getDependencyTraverser()
-    {
-        return getSession().getDependencyTraverser();
-    }
-
-    public DependencyManager getDependencyManager()
-    {
-        return getSession().getDependencyManager();
-    }
-
-    public DependencySelector getDependencySelector()
-    {
-        return getSession().getDependencySelector();
-    }
-
-    public VersionFilter getVersionFilter()
-    {
-        return getSession().getVersionFilter();
-    }
-
-    public DependencyGraphTransformer getDependencyGraphTransformer()
-    {
-        return getSession().getDependencyGraphTransformer();
-    }
-
-    public SessionData getData()
-    {
-        return getSession().getData();
-    }
-
-    public RepositoryCache getCache()
-    {
-        return getSession().getCache();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/AbstractRepositoryListener.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/AbstractRepositoryListener.java
deleted file mode 100644 (file)
index eaaffc1..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-/**
- * A skeleton implementation for custom repository listeners. The callback methods in this class do nothing.
- */
-public abstract class AbstractRepositoryListener
-    implements RepositoryListener
-{
-
-    /**
-     * Enables subclassing.
-     */
-    protected AbstractRepositoryListener()
-    {
-    }
-
-    public void artifactDeployed( RepositoryEvent event )
-    {
-    }
-
-    public void artifactDeploying( RepositoryEvent event )
-    {
-    }
-
-    public void artifactDescriptorInvalid( RepositoryEvent event )
-    {
-    }
-
-    public void artifactDescriptorMissing( RepositoryEvent event )
-    {
-    }
-
-    public void artifactDownloaded( RepositoryEvent event )
-    {
-    }
-
-    public void artifactDownloading( RepositoryEvent event )
-    {
-    }
-
-    public void artifactInstalled( RepositoryEvent event )
-    {
-    }
-
-    public void artifactInstalling( RepositoryEvent event )
-    {
-    }
-
-    public void artifactResolved( RepositoryEvent event )
-    {
-    }
-
-    public void artifactResolving( RepositoryEvent event )
-    {
-    }
-
-    public void metadataDeployed( RepositoryEvent event )
-    {
-    }
-
-    public void metadataDeploying( RepositoryEvent event )
-    {
-    }
-
-    public void metadataDownloaded( RepositoryEvent event )
-    {
-    }
-
-    public void metadataDownloading( RepositoryEvent event )
-    {
-    }
-
-    public void metadataInstalled( RepositoryEvent event )
-    {
-    }
-
-    public void metadataInstalling( RepositoryEvent event )
-    {
-    }
-
-    public void metadataInvalid( RepositoryEvent event )
-    {
-    }
-
-    public void metadataResolved( RepositoryEvent event )
-    {
-    }
-
-    public void metadataResolving( RepositoryEvent event )
-    {
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/ConfigurationProperties.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/ConfigurationProperties.java
deleted file mode 100644 (file)
index 3cbd59c..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-/**
- * The keys and defaults for common configuration properties.
- * 
- * @see RepositorySystemSession#getConfigProperties()
- */
-public final class ConfigurationProperties
-{
-
-    private static final String PREFIX_AETHER = "aether.";
-
-    private static final String PREFIX_CONNECTOR = PREFIX_AETHER + "connector.";
-
-    /**
-     * The prefix for properties that control the priority of pluggable extensions like transporters. For example, for
-     * an extension with the fully qualified class name "org.eclipse.MyExtensionFactory", the configuration properties
-     * "aether.priority.org.eclipse.MyExtensionFactory", "aether.priority.MyExtensionFactory" and
-     * "aether.priority.MyExtension" will be consulted for the priority, in that order (obviously, the last key is only
-     * tried if the class name ends with "Factory"). The corresponding value is a float and the special value
-     * {@link Float#NaN} or "NaN" (case-sensitive) can be used to disable the extension.
-     */
-    public static final String PREFIX_PRIORITY = PREFIX_AETHER + "priority.";
-
-    /**
-     * A flag indicating whether the priorities of pluggable extensions are implicitly given by their iteration order
-     * such that the first extension has the highest priority. If set, an extension's built-in priority as well as any
-     * corresponding {@code aether.priority.*} configuration properties are ignored when searching for a suitable
-     * implementation among the available extensions. This priority mode is meant for cases where the application will
-     * present/inject extensions in the desired search order.
-     * 
-     * @see #DEFAULT_IMPLICIT_PRIORITIES
-     */
-    public static final String IMPLICIT_PRIORITIES = PREFIX_PRIORITY + "implicit";
-
-    /**
-     * The default extension priority mode if {@link #IMPLICIT_PRIORITIES} isn't set.
-     */
-    public static final boolean DEFAULT_IMPLICIT_PRIORITIES = false;
-
-    /**
-     * A flag indicating whether interaction with the user is allowed.
-     * 
-     * @see #DEFAULT_INTERACTIVE
-     */
-    public static final String INTERACTIVE = PREFIX_AETHER + "interactive";
-
-    /**
-     * The default interactive mode if {@link #INTERACTIVE} isn't set.
-     */
-    public static final boolean DEFAULT_INTERACTIVE = false;
-
-    /**
-     * The user agent that repository connectors should report to servers.
-     * 
-     * @see #DEFAULT_USER_AGENT
-     */
-    public static final String USER_AGENT = PREFIX_CONNECTOR + "userAgent";
-
-    /**
-     * The default user agent to use if {@link #USER_AGENT} isn't set.
-     */
-    public static final String DEFAULT_USER_AGENT = "Aether";
-
-    /**
-     * The maximum amount of time (in milliseconds) to wait for a successful connection to a remote server. Non-positive
-     * values indicate no timeout.
-     * 
-     * @see #DEFAULT_CONNECT_TIMEOUT
-     */
-    public static final String CONNECT_TIMEOUT = PREFIX_CONNECTOR + "connectTimeout";
-
-    /**
-     * The default connect timeout to use if {@link #CONNECT_TIMEOUT} isn't set.
-     */
-    public static final int DEFAULT_CONNECT_TIMEOUT = 10 * 1000;
-
-    /**
-     * The maximum amount of time (in milliseconds) to wait for remaining data to arrive from a remote server. Note that
-     * this timeout does not restrict the overall duration of a request, it only restricts the duration of inactivity
-     * between consecutive data packets. Non-positive values indicate no timeout.
-     * 
-     * @see #DEFAULT_REQUEST_TIMEOUT
-     */
-    public static final String REQUEST_TIMEOUT = PREFIX_CONNECTOR + "requestTimeout";
-
-    /**
-     * The default request timeout to use if {@link #REQUEST_TIMEOUT} isn't set.
-     */
-    public static final int DEFAULT_REQUEST_TIMEOUT = 1800 * 1000;
-
-    /**
-     * The request headers to use for HTTP-based repository connectors. The headers are specified using a
-     * {@code Map<String, String>}, mapping a header name to its value. Besides this general key, clients may also
-     * specify headers for a specific remote repository by appending the suffix {@code .<repoId>} to this key when
-     * storing the headers map. The repository-specific headers map is supposed to be complete, i.e. is not merged with
-     * the general headers map.
-     */
-    public static final String HTTP_HEADERS = PREFIX_CONNECTOR + "http.headers";
-
-    /**
-     * The encoding/charset to use when exchanging credentials with HTTP servers. Besides this general key, clients may
-     * also specify the encoding for a specific remote repository by appending the suffix {@code .<repoId>} to this key
-     * when storing the charset name.
-     * 
-     * @see #DEFAULT_HTTP_CREDENTIAL_ENCODING
-     */
-    public static final String HTTP_CREDENTIAL_ENCODING = PREFIX_CONNECTOR + "http.credentialEncoding";
-
-    /**
-     * The default encoding/charset to use if {@link #HTTP_CREDENTIAL_ENCODING} isn't set.
-     */
-    public static final String DEFAULT_HTTP_CREDENTIAL_ENCODING = "ISO-8859-1";
-
-    /**
-     * An option indicating whether authentication configured for a HTTP repository should also be used with any host
-     * that the original server might redirect requests to. Unless enabled, credentials are only exchanged with the
-     * original host from the repository URL and not supplied to different hosts encountered during redirects. The
-     * option value can either be a boolean flag or a comma-separated list of host names denoting the whitelist of
-     * original hosts whose redirects can be trusted and should use the configured authentication no matter the
-     * destination host(s). Alternatively, the suffix {@code .<repoId>} can be appended to this configuration key to
-     * control the behavior for a specific repository id.
-     * 
-     * @see #DEFAULT_HTTP_REDIRECTED_AUTHENTICATION
-     * @since 1.1.0
-     */
-    public static final String HTTP_REDIRECTED_AUTHENTICATION = PREFIX_CONNECTOR + "http.redirectedAuthentication";
-
-    /**
-     * The default handling of authentication during HTTP redirects if {@link #HTTP_REDIRECTED_AUTHENTICATION} isn't
-     * set.
-     * 
-     * @since 1.1.0
-     */
-    public static final String DEFAULT_HTTP_REDIRECTED_AUTHENTICATION = "false";
-
-    /**
-     * A flag indicating whether checksums which are retrieved during checksum validation should be persisted in the
-     * local filesystem next to the file they provide the checksum for.
-     * 
-     * @see #DEFAULT_PERSISTED_CHECKSUMS
-     */
-    public static final String PERSISTED_CHECKSUMS = PREFIX_CONNECTOR + "persistedChecksums";
-
-    /**
-     * The default checksum persistence mode if {@link #PERSISTED_CHECKSUMS} isn't set.
-     */
-    public static final boolean DEFAULT_PERSISTED_CHECKSUMS = true;
-
-    private ConfigurationProperties()
-    {
-        // hide constructor
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositoryCache.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositoryCache.java
deleted file mode 100644 (file)
index 12d2789..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * A simplistic repository cache backed by a thread-safe map. The simplistic nature of this cache makes it only suitable
- * for use with short-lived repository system sessions where pruning of cache data is not required.
- */
-public final class DefaultRepositoryCache
-    implements RepositoryCache
-{
-
-    private final Map<Object, Object> cache = new ConcurrentHashMap<Object, Object>( 256 );
-
-    public Object get( RepositorySystemSession session, Object key )
-    {
-        return cache.get( key );
-    }
-
-    public void put( RepositorySystemSession session, Object key, Object data )
-    {
-        if ( data != null )
-        {
-            cache.put( key, data );
-        }
-        else
-        {
-            cache.remove( key );
-        }
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositorySystemSession.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositorySystemSession.java
deleted file mode 100644 (file)
index 363ede6..0000000
+++ /dev/null
@@ -1,825 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.aether.artifact.ArtifactType;
-import org.eclipse.aether.artifact.ArtifactTypeRegistry;
-import org.eclipse.aether.collection.DependencyGraphTransformer;
-import org.eclipse.aether.collection.DependencyManager;
-import org.eclipse.aether.collection.DependencySelector;
-import org.eclipse.aether.collection.DependencyTraverser;
-import org.eclipse.aether.collection.VersionFilter;
-import org.eclipse.aether.repository.Authentication;
-import org.eclipse.aether.repository.AuthenticationSelector;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.LocalRepositoryManager;
-import org.eclipse.aether.repository.MirrorSelector;
-import org.eclipse.aether.repository.Proxy;
-import org.eclipse.aether.repository.ProxySelector;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.repository.RepositoryPolicy;
-import org.eclipse.aether.repository.WorkspaceReader;
-import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
-import org.eclipse.aether.resolution.ResolutionErrorPolicy;
-import org.eclipse.aether.transfer.TransferListener;
-
-/**
- * A simple repository system session.
- * <p>
- * <strong>Note:</strong> This class is not thread-safe. It is assumed that the mutators get only called during an
- * initialization phase and that the session itself is not changed once initialized and being used by the repository
- * system. It is recommended to call {@link #setReadOnly()} once the session has been fully initialized to prevent
- * accidental manipulation of it afterwards.
- */
-public final class DefaultRepositorySystemSession
-    implements RepositorySystemSession
-{
-
-    private boolean readOnly;
-
-    private boolean offline;
-
-    private boolean ignoreArtifactDescriptorRepositories;
-
-    private ResolutionErrorPolicy resolutionErrorPolicy;
-
-    private ArtifactDescriptorPolicy artifactDescriptorPolicy;
-
-    private String checksumPolicy;
-
-    private String updatePolicy;
-
-    private LocalRepositoryManager localRepositoryManager;
-
-    private WorkspaceReader workspaceReader;
-
-    private RepositoryListener repositoryListener;
-
-    private TransferListener transferListener;
-
-    private Map<String, String> systemProperties;
-
-    private Map<String, String> systemPropertiesView;
-
-    private Map<String, String> userProperties;
-
-    private Map<String, String> userPropertiesView;
-
-    private Map<String, Object> configProperties;
-
-    private Map<String, Object> configPropertiesView;
-
-    private MirrorSelector mirrorSelector;
-
-    private ProxySelector proxySelector;
-
-    private AuthenticationSelector authenticationSelector;
-
-    private ArtifactTypeRegistry artifactTypeRegistry;
-
-    private DependencyTraverser dependencyTraverser;
-
-    private DependencyManager dependencyManager;
-
-    private DependencySelector dependencySelector;
-
-    private VersionFilter versionFilter;
-
-    private DependencyGraphTransformer dependencyGraphTransformer;
-
-    private SessionData data;
-
-    private RepositoryCache cache;
-
-    /**
-     * Creates an uninitialized session. <em>Note:</em> The new session is not ready to use, as a bare minimum,
-     * {@link #setLocalRepositoryManager(LocalRepositoryManager)} needs to be called but usually other settings also
-     * need to be customized to achieve meaningful behavior.
-     */
-    public DefaultRepositorySystemSession()
-    {
-        systemProperties = new HashMap<String, String>();
-        systemPropertiesView = Collections.unmodifiableMap( systemProperties );
-        userProperties = new HashMap<String, String>();
-        userPropertiesView = Collections.unmodifiableMap( userProperties );
-        configProperties = new HashMap<String, Object>();
-        configPropertiesView = Collections.unmodifiableMap( configProperties );
-        mirrorSelector = NullMirrorSelector.INSTANCE;
-        proxySelector = NullProxySelector.INSTANCE;
-        authenticationSelector = NullAuthenticationSelector.INSTANCE;
-        artifactTypeRegistry = NullArtifactTypeRegistry.INSTANCE;
-        data = new DefaultSessionData();
-    }
-
-    /**
-     * Creates a shallow copy of the specified session. Actually, the copy is not completely shallow, all maps holding
-     * system/user/config properties are copied as well. In other words, invoking any mutator on the new session itself
-     * has no effect on the original session. Other mutable objects like the session data and cache (if any) are not
-     * copied and will be shared with the original session unless reconfigured.
-     * 
-     * @param session The session to copy, must not be {@code null}.
-     */
-    public DefaultRepositorySystemSession( RepositorySystemSession session )
-    {
-        if ( session == null )
-        {
-            throw new IllegalArgumentException( "repository system session not specified" );
-        }
-
-        setOffline( session.isOffline() );
-        setIgnoreArtifactDescriptorRepositories( session.isIgnoreArtifactDescriptorRepositories() );
-        setResolutionErrorPolicy( session.getResolutionErrorPolicy() );
-        setArtifactDescriptorPolicy( session.getArtifactDescriptorPolicy() );
-        setChecksumPolicy( session.getChecksumPolicy() );
-        setUpdatePolicy( session.getUpdatePolicy() );
-        setLocalRepositoryManager( session.getLocalRepositoryManager() );
-        setWorkspaceReader( session.getWorkspaceReader() );
-        setRepositoryListener( session.getRepositoryListener() );
-        setTransferListener( session.getTransferListener() );
-        setSystemProperties( session.getSystemProperties() );
-        setUserProperties( session.getUserProperties() );
-        setConfigProperties( session.getConfigProperties() );
-        setMirrorSelector( session.getMirrorSelector() );
-        setProxySelector( session.getProxySelector() );
-        setAuthenticationSelector( session.getAuthenticationSelector() );
-        setArtifactTypeRegistry( session.getArtifactTypeRegistry() );
-        setDependencyTraverser( session.getDependencyTraverser() );
-        setDependencyManager( session.getDependencyManager() );
-        setDependencySelector( session.getDependencySelector() );
-        setVersionFilter( session.getVersionFilter() );
-        setDependencyGraphTransformer( session.getDependencyGraphTransformer() );
-        setData( session.getData() );
-        setCache( session.getCache() );
-    }
-
-    public boolean isOffline()
-    {
-        return offline;
-    }
-
-    /**
-     * Controls whether the repository system operates in offline mode and avoids/refuses any access to remote
-     * repositories.
-     * 
-     * @param offline {@code true} if the repository system is in offline mode, {@code false} otherwise.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setOffline( boolean offline )
-    {
-        failIfReadOnly();
-        this.offline = offline;
-        return this;
-    }
-
-    public boolean isIgnoreArtifactDescriptorRepositories()
-    {
-        return ignoreArtifactDescriptorRepositories;
-    }
-
-    /**
-     * Controls whether repositories declared in artifact descriptors should be ignored during transitive dependency
-     * collection. If enabled, only the repositories originally provided with the collect request will be considered.
-     * 
-     * @param ignoreArtifactDescriptorRepositories {@code true} to ignore additional repositories from artifact
-     *            descriptors, {@code false} to merge those with the originally specified repositories.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setIgnoreArtifactDescriptorRepositories( boolean ignoreArtifactDescriptorRepositories )
-    {
-        failIfReadOnly();
-        this.ignoreArtifactDescriptorRepositories = ignoreArtifactDescriptorRepositories;
-        return this;
-    }
-
-    public ResolutionErrorPolicy getResolutionErrorPolicy()
-    {
-        return resolutionErrorPolicy;
-    }
-
-    /**
-     * Sets the policy which controls whether resolutions errors from remote repositories should be cached.
-     * 
-     * @param resolutionErrorPolicy The resolution error policy for this session, may be {@code null} if resolution
-     *            errors should generally not be cached.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setResolutionErrorPolicy( ResolutionErrorPolicy resolutionErrorPolicy )
-    {
-        failIfReadOnly();
-        this.resolutionErrorPolicy = resolutionErrorPolicy;
-        return this;
-    }
-
-    public ArtifactDescriptorPolicy getArtifactDescriptorPolicy()
-    {
-        return artifactDescriptorPolicy;
-    }
-
-    /**
-     * Sets the policy which controls how errors related to reading artifact descriptors should be handled.
-     * 
-     * @param artifactDescriptorPolicy The descriptor error policy for this session, may be {@code null} if descriptor
-     *            errors should generally not be tolerated.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setArtifactDescriptorPolicy( ArtifactDescriptorPolicy artifactDescriptorPolicy )
-    {
-        failIfReadOnly();
-        this.artifactDescriptorPolicy = artifactDescriptorPolicy;
-        return this;
-    }
-
-    public String getChecksumPolicy()
-    {
-        return checksumPolicy;
-    }
-
-    /**
-     * Sets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
-     * repositories being used for resolution.
-     * 
-     * @param checksumPolicy The global checksum policy, may be {@code null}/empty to apply the per-repository policies.
-     * @return This session for chaining, never {@code null}.
-     * @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
-     * @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
-     * @see RepositoryPolicy#CHECKSUM_POLICY_WARN
-     */
-    public DefaultRepositorySystemSession setChecksumPolicy( String checksumPolicy )
-    {
-        failIfReadOnly();
-        this.checksumPolicy = checksumPolicy;
-        return this;
-    }
-
-    public String getUpdatePolicy()
-    {
-        return updatePolicy;
-    }
-
-    /**
-     * Sets the global update policy. If set, the global update policy overrides the update policies of the remote
-     * repositories being used for resolution.
-     * 
-     * @param updatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies.
-     * @return This session for chaining, never {@code null}.
-     * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
-     * @see RepositoryPolicy#UPDATE_POLICY_DAILY
-     * @see RepositoryPolicy#UPDATE_POLICY_NEVER
-     */
-    public DefaultRepositorySystemSession setUpdatePolicy( String updatePolicy )
-    {
-        failIfReadOnly();
-        this.updatePolicy = updatePolicy;
-        return this;
-    }
-
-    public LocalRepository getLocalRepository()
-    {
-        LocalRepositoryManager lrm = getLocalRepositoryManager();
-        return ( lrm != null ) ? lrm.getRepository() : null;
-    }
-
-    public LocalRepositoryManager getLocalRepositoryManager()
-    {
-        return localRepositoryManager;
-    }
-
-    /**
-     * Sets the local repository manager used during this session. <em>Note:</em> Eventually, a valid session must have
-     * a local repository manager set.
-     * 
-     * @param localRepositoryManager The local repository manager used during this session, may be {@code null}.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setLocalRepositoryManager( LocalRepositoryManager localRepositoryManager )
-    {
-        failIfReadOnly();
-        this.localRepositoryManager = localRepositoryManager;
-        return this;
-    }
-
-    public WorkspaceReader getWorkspaceReader()
-    {
-        return workspaceReader;
-    }
-
-    /**
-     * Sets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
-     * to resolve artifacts.
-     * 
-     * @param workspaceReader The workspace reader for this session, may be {@code null} if none.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setWorkspaceReader( WorkspaceReader workspaceReader )
-    {
-        failIfReadOnly();
-        this.workspaceReader = workspaceReader;
-        return this;
-    }
-
-    public RepositoryListener getRepositoryListener()
-    {
-        return repositoryListener;
-    }
-
-    /**
-     * Sets the listener being notified of actions in the repository system.
-     * 
-     * @param repositoryListener The repository listener, may be {@code null} if none.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setRepositoryListener( RepositoryListener repositoryListener )
-    {
-        failIfReadOnly();
-        this.repositoryListener = repositoryListener;
-        return this;
-    }
-
-    public TransferListener getTransferListener()
-    {
-        return transferListener;
-    }
-
-    /**
-     * Sets the listener being notified of uploads/downloads by the repository system.
-     * 
-     * @param transferListener The transfer listener, may be {@code null} if none.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setTransferListener( TransferListener transferListener )
-    {
-        failIfReadOnly();
-        this.transferListener = transferListener;
-        return this;
-    }
-
-    private <T> Map<String, T> copySafe( Map<?, ?> table, Class<T> valueType )
-    {
-        Map<String, T> map;
-        if ( table == null || table.isEmpty() )
-        {
-            map = new HashMap<String, T>();
-        }
-        else
-        {
-            map = new HashMap<String, T>( (int) ( table.size() / 0.75f ) + 1 );
-            for ( Map.Entry<?, ?> entry : table.entrySet() )
-            {
-                Object key = entry.getKey();
-                if ( key instanceof String )
-                {
-                    Object value = entry.getValue();
-                    if ( valueType.isInstance( value ) )
-                    {
-                        map.put( key.toString(), valueType.cast( value ) );
-                    }
-                }
-            }
-        }
-        return map;
-    }
-
-    public Map<String, String> getSystemProperties()
-    {
-        return systemPropertiesView;
-    }
-
-    /**
-     * Sets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
-     * collected from the runtime environment like {@link System#getProperties()} and environment variables.
-     * <p>
-     * <em>Note:</em> System properties are of type {@code Map<String, String>} and any key-value pair in the input map
-     * that doesn't match this type will be silently ignored.
-     * 
-     * @param systemProperties The system properties, may be {@code null} or empty if none.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setSystemProperties( Map<?, ?> systemProperties )
-    {
-        failIfReadOnly();
-        this.systemProperties = copySafe( systemProperties, String.class );
-        systemPropertiesView = Collections.unmodifiableMap( this.systemProperties );
-        return this;
-    }
-
-    /**
-     * Sets the specified system property.
-     * 
-     * @param key The property key, must not be {@code null}.
-     * @param value The property value, may be {@code null} to remove/unset the property.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setSystemProperty( String key, String value )
-    {
-        failIfReadOnly();
-        if ( value != null )
-        {
-            systemProperties.put( key, value );
-        }
-        else
-        {
-            systemProperties.remove( key );
-        }
-        return this;
-    }
-
-    public Map<String, String> getUserProperties()
-    {
-        return userPropertiesView;
-    }
-
-    /**
-     * Sets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
-     * system properties but are set on the discretion of the user and hence are considered of higher priority than
-     * system properties in case of conflicts.
-     * <p>
-     * <em>Note:</em> User properties are of type {@code Map<String, String>} and any key-value pair in the input map
-     * that doesn't match this type will be silently ignored.
-     * 
-     * @param userProperties The user properties, may be {@code null} or empty if none.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setUserProperties( Map<?, ?> userProperties )
-    {
-        failIfReadOnly();
-        this.userProperties = copySafe( userProperties, String.class );
-        userPropertiesView = Collections.unmodifiableMap( this.userProperties );
-        return this;
-    }
-
-    /**
-     * Sets the specified user property.
-     * 
-     * @param key The property key, must not be {@code null}.
-     * @param value The property value, may be {@code null} to remove/unset the property.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setUserProperty( String key, String value )
-    {
-        failIfReadOnly();
-        if ( value != null )
-        {
-            userProperties.put( key, value );
-        }
-        else
-        {
-            userProperties.remove( key );
-        }
-        return this;
-    }
-
-    public Map<String, Object> getConfigProperties()
-    {
-        return configPropertiesView;
-    }
-
-    /**
-     * Sets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
-     * connector-specific behavior, etc.).
-     * <p>
-     * <em>Note:</em> Configuration properties are of type {@code Map<String, Object>} and any key-value pair in the
-     * input map that doesn't match this type will be silently ignored.
-     * 
-     * @param configProperties The configuration properties, may be {@code null} or empty if none.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setConfigProperties( Map<?, ?> configProperties )
-    {
-        failIfReadOnly();
-        this.configProperties = copySafe( configProperties, Object.class );
-        configPropertiesView = Collections.unmodifiableMap( this.configProperties );
-        return this;
-    }
-
-    /**
-     * Sets the specified configuration property.
-     * 
-     * @param key The property key, must not be {@code null}.
-     * @param value The property value, may be {@code null} to remove/unset the property.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setConfigProperty( String key, Object value )
-    {
-        failIfReadOnly();
-        if ( value != null )
-        {
-            configProperties.put( key, value );
-        }
-        else
-        {
-            configProperties.remove( key );
-        }
-        return this;
-    }
-
-    public MirrorSelector getMirrorSelector()
-    {
-        return mirrorSelector;
-    }
-
-    /**
-     * Sets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
-     * not used for remote repositories which are passed as request parameters to the repository system, those
-     * repositories are supposed to denote the effective repositories.
-     * 
-     * @param mirrorSelector The mirror selector to use, may be {@code null}.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setMirrorSelector( MirrorSelector mirrorSelector )
-    {
-        failIfReadOnly();
-        this.mirrorSelector = mirrorSelector;
-        if ( this.mirrorSelector == null )
-        {
-            this.mirrorSelector = NullMirrorSelector.INSTANCE;
-        }
-        return this;
-    }
-
-    public ProxySelector getProxySelector()
-    {
-        return proxySelector;
-    }
-
-    /**
-     * Sets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
-     * not used for remote repositories which are passed as request parameters to the repository system, those
-     * repositories are supposed to have their proxy (if any) already set.
-     * 
-     * @param proxySelector The proxy selector to use, may be {@code null}.
-     * @return This session for chaining, never {@code null}.
-     * @see org.eclipse.aether.repository.RemoteRepository#getProxy()
-     */
-    public DefaultRepositorySystemSession setProxySelector( ProxySelector proxySelector )
-    {
-        failIfReadOnly();
-        this.proxySelector = proxySelector;
-        if ( this.proxySelector == null )
-        {
-            this.proxySelector = NullProxySelector.INSTANCE;
-        }
-        return this;
-    }
-
-    public AuthenticationSelector getAuthenticationSelector()
-    {
-        return authenticationSelector;
-    }
-
-    /**
-     * Sets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
-     * selector is not used for remote repositories which are passed as request parameters to the repository system,
-     * those repositories are supposed to have their authentication (if any) already set.
-     * 
-     * @param authenticationSelector The authentication selector to use, may be {@code null}.
-     * @return This session for chaining, never {@code null}.
-     * @see org.eclipse.aether.repository.RemoteRepository#getAuthentication()
-     */
-    public DefaultRepositorySystemSession setAuthenticationSelector( AuthenticationSelector authenticationSelector )
-    {
-        failIfReadOnly();
-        this.authenticationSelector = authenticationSelector;
-        if ( this.authenticationSelector == null )
-        {
-            this.authenticationSelector = NullAuthenticationSelector.INSTANCE;
-        }
-        return this;
-    }
-
-    public ArtifactTypeRegistry getArtifactTypeRegistry()
-    {
-        return artifactTypeRegistry;
-    }
-
-    /**
-     * Sets the registry of artifact types recognized by this session.
-     * 
-     * @param artifactTypeRegistry The artifact type registry, may be {@code null}.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setArtifactTypeRegistry( ArtifactTypeRegistry artifactTypeRegistry )
-    {
-        failIfReadOnly();
-        this.artifactTypeRegistry = artifactTypeRegistry;
-        if ( this.artifactTypeRegistry == null )
-        {
-            this.artifactTypeRegistry = NullArtifactTypeRegistry.INSTANCE;
-        }
-        return this;
-    }
-
-    public DependencyTraverser getDependencyTraverser()
-    {
-        return dependencyTraverser;
-    }
-
-    /**
-     * Sets the dependency traverser to use for building dependency graphs.
-     * 
-     * @param dependencyTraverser The dependency traverser to use for building dependency graphs, may be {@code null}.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setDependencyTraverser( DependencyTraverser dependencyTraverser )
-    {
-        failIfReadOnly();
-        this.dependencyTraverser = dependencyTraverser;
-        return this;
-    }
-
-    public DependencyManager getDependencyManager()
-    {
-        return dependencyManager;
-    }
-
-    /**
-     * Sets the dependency manager to use for building dependency graphs.
-     * 
-     * @param dependencyManager The dependency manager to use for building dependency graphs, may be {@code null}.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setDependencyManager( DependencyManager dependencyManager )
-    {
-        failIfReadOnly();
-        this.dependencyManager = dependencyManager;
-        return this;
-    }
-
-    public DependencySelector getDependencySelector()
-    {
-        return dependencySelector;
-    }
-
-    /**
-     * Sets the dependency selector to use for building dependency graphs.
-     * 
-     * @param dependencySelector The dependency selector to use for building dependency graphs, may be {@code null}.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setDependencySelector( DependencySelector dependencySelector )
-    {
-        failIfReadOnly();
-        this.dependencySelector = dependencySelector;
-        return this;
-    }
-
-    public VersionFilter getVersionFilter()
-    {
-        return versionFilter;
-    }
-
-    /**
-     * Sets the version filter to use for building dependency graphs.
-     * 
-     * @param versionFilter The version filter to use for building dependency graphs, may be {@code null} to not filter
-     *            versions.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setVersionFilter( VersionFilter versionFilter )
-    {
-        failIfReadOnly();
-        this.versionFilter = versionFilter;
-        return this;
-    }
-
-    public DependencyGraphTransformer getDependencyGraphTransformer()
-    {
-        return dependencyGraphTransformer;
-    }
-
-    /**
-     * Sets the dependency graph transformer to use for building dependency graphs.
-     * 
-     * @param dependencyGraphTransformer The dependency graph transformer to use for building dependency graphs, may be
-     *            {@code null}.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setDependencyGraphTransformer( DependencyGraphTransformer dependencyGraphTransformer )
-    {
-        failIfReadOnly();
-        this.dependencyGraphTransformer = dependencyGraphTransformer;
-        return this;
-    }
-
-    public SessionData getData()
-    {
-        return data;
-    }
-
-    /**
-     * Sets the custom data associated with this session.
-     * 
-     * @param data The session data, may be {@code null}.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setData( SessionData data )
-    {
-        failIfReadOnly();
-        this.data = data;
-        if ( this.data == null )
-        {
-            this.data = new DefaultSessionData();
-        }
-        return this;
-    }
-
-    public RepositoryCache getCache()
-    {
-        return cache;
-    }
-
-    /**
-     * Sets the cache the repository system may use to save data for future reuse during the session.
-     * 
-     * @param cache The repository cache, may be {@code null} if none.
-     * @return This session for chaining, never {@code null}.
-     */
-    public DefaultRepositorySystemSession setCache( RepositoryCache cache )
-    {
-        failIfReadOnly();
-        this.cache = cache;
-        return this;
-    }
-
-    /**
-     * Marks this session as read-only such that any future attempts to call its mutators will fail with an exception.
-     * Marking an already read-only session as read-only has no effect. The session's data and cache remain writable
-     * though.
-     */
-    public void setReadOnly()
-    {
-        readOnly = true;
-    }
-
-    private void failIfReadOnly()
-    {
-        if ( readOnly )
-        {
-            throw new IllegalStateException( "repository system session is read-only" );
-        }
-    }
-
-    static class NullProxySelector
-        implements ProxySelector
-    {
-
-        public static final ProxySelector INSTANCE = new NullProxySelector();
-
-        public Proxy getProxy( RemoteRepository repository )
-        {
-            return repository.getProxy();
-        }
-
-    }
-
-    static class NullMirrorSelector
-        implements MirrorSelector
-    {
-
-        public static final MirrorSelector INSTANCE = new NullMirrorSelector();
-
-        public RemoteRepository getMirror( RemoteRepository repository )
-        {
-            return null;
-        }
-
-    }
-
-    static class NullAuthenticationSelector
-        implements AuthenticationSelector
-    {
-
-        public static final AuthenticationSelector INSTANCE = new NullAuthenticationSelector();
-
-        public Authentication getAuthentication( RemoteRepository repository )
-        {
-            return repository.getAuthentication();
-        }
-
-    }
-
-    static final class NullArtifactTypeRegistry
-        implements ArtifactTypeRegistry
-    {
-
-        public static final ArtifactTypeRegistry INSTANCE = new NullArtifactTypeRegistry();
-
-        public ArtifactType get( String typeId )
-        {
-            return null;
-        }
-
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/DefaultSessionData.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/DefaultSessionData.java
deleted file mode 100644 (file)
index 738cebc..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * A simple session data storage backed by a thread-safe map.
- */
-public final class DefaultSessionData
-    implements SessionData
-{
-
-    private final ConcurrentMap<Object, Object> data;
-
-    public DefaultSessionData()
-    {
-        data = new ConcurrentHashMap<Object, Object>();
-    }
-
-    public void set( Object key, Object value )
-    {
-        if ( key == null )
-        {
-            throw new IllegalArgumentException( "key must not be null" );
-        }
-
-        if ( value != null )
-        {
-            data.put( key, value );
-        }
-        else
-        {
-            data.remove( key );
-        }
-    }
-
-    public boolean set( Object key, Object oldValue, Object newValue )
-    {
-        if ( key == null )
-        {
-            throw new IllegalArgumentException( "key must not be null" );
-        }
-
-        if ( newValue != null )
-        {
-            if ( oldValue == null )
-            {
-                return data.putIfAbsent( key, newValue ) == null;
-            }
-            return data.replace( key, oldValue, newValue );
-        }
-        else
-        {
-            if ( oldValue == null )
-            {
-                return !data.containsKey( key );
-            }
-            return data.remove( key, oldValue );
-        }
-    }
-
-    public Object get( Object key )
-    {
-        if ( key == null )
-        {
-            throw new IllegalArgumentException( "key must not be null" );
-        }
-
-        return data.get( key );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryCache.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryCache.java
deleted file mode 100644 (file)
index 7363844..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-/**
- * Caches auxiliary data used during repository access like already processed metadata. The data in the cache is meant
- * for exclusive consumption by the repository system and is opaque to the cache implementation. <strong>Note:</strong>
- * Actual cache implementations must be thread-safe.
- * 
- * @see RepositorySystemSession#getCache()
- */
-public interface RepositoryCache
-{
-
-    /**
-     * Puts the specified data into the cache. It is entirely up to the cache implementation how long this data will be
-     * kept before being purged, i.e. callers must not make any assumptions about the lifetime of cached data.
-     * <p>
-     * <em>Warning:</em> The cache will directly save the provided reference. If the cached data is mutable, i.e. could
-     * be modified after being put into the cache, the caller is responsible for creating a copy of the original data
-     * and store the copy in the cache.
-     * 
-     * @param session The repository session during which the cache is accessed, must not be {@code null}.
-     * @param key The key to use for lookup of the data, must not be {@code null}.
-     * @param data The data to store in the cache, may be {@code null}.
-     */
-    void put( RepositorySystemSession session, Object key, Object data );
-
-    /**
-     * Gets the specified data from the cache.
-     * <p>
-     * <em>Warning:</em> The cache will directly return the saved reference. If the cached data is to be modified after
-     * its retrieval, the caller is responsible to create a copy of the returned data and use this instead of the cache
-     * record.
-     * 
-     * @param session The repository session during which the cache is accessed, must not be {@code null}.
-     * @param key The key to use for lookup of the data, must not be {@code null}.
-     * @return The requested data or {@code null} if none was present in the cache.
-     */
-    Object get( RepositorySystemSession session, Object key );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryEvent.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryEvent.java
deleted file mode 100644 (file)
index 2abd800..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.repository.ArtifactRepository;
-
-/**
- * An event describing an action performed by the repository system. Note that events which indicate the end of an
- * action like {@link EventType#ARTIFACT_RESOLVED} are generally fired in both the success and the failure case. Use
- * {@link #getException()} to check whether an event denotes success or failure.
- * 
- * @see RepositoryListener
- * @see RepositoryEvent.Builder
- */
-public final class RepositoryEvent
-{
-
-    /**
-     * The type of the repository event.
-     */
-    public enum EventType
-    {
-
-        /**
-         * @see RepositoryListener#artifactDescriptorInvalid(RepositoryEvent)
-         */
-        ARTIFACT_DESCRIPTOR_INVALID,
-
-        /**
-         * @see RepositoryListener#artifactDescriptorMissing(RepositoryEvent)
-         */
-        ARTIFACT_DESCRIPTOR_MISSING,
-
-        /**
-         * @see RepositoryListener#metadataInvalid(RepositoryEvent)
-         */
-        METADATA_INVALID,
-
-        /**
-         * @see RepositoryListener#artifactResolving(RepositoryEvent)
-         */
-        ARTIFACT_RESOLVING,
-
-        /**
-         * @see RepositoryListener#artifactResolved(RepositoryEvent)
-         */
-        ARTIFACT_RESOLVED,
-
-        /**
-         * @see RepositoryListener#metadataResolving(RepositoryEvent)
-         */
-        METADATA_RESOLVING,
-
-        /**
-         * @see RepositoryListener#metadataResolved(RepositoryEvent)
-         */
-        METADATA_RESOLVED,
-
-        /**
-         * @see RepositoryListener#artifactDownloading(RepositoryEvent)
-         */
-        ARTIFACT_DOWNLOADING,
-
-        /**
-         * @see RepositoryListener#artifactDownloaded(RepositoryEvent)
-         */
-        ARTIFACT_DOWNLOADED,
-
-        /**
-         * @see RepositoryListener#metadataDownloading(RepositoryEvent)
-         */
-        METADATA_DOWNLOADING,
-
-        /**
-         * @see RepositoryListener#metadataDownloaded(RepositoryEvent)
-         */
-        METADATA_DOWNLOADED,
-
-        /**
-         * @see RepositoryListener#artifactInstalling(RepositoryEvent)
-         */
-        ARTIFACT_INSTALLING,
-
-        /**
-         * @see RepositoryListener#artifactInstalled(RepositoryEvent)
-         */
-        ARTIFACT_INSTALLED,
-
-        /**
-         * @see RepositoryListener#metadataInstalling(RepositoryEvent)
-         */
-        METADATA_INSTALLING,
-
-        /**
-         * @see RepositoryListener#metadataInstalled(RepositoryEvent)
-         */
-        METADATA_INSTALLED,
-
-        /**
-         * @see RepositoryListener#artifactDeploying(RepositoryEvent)
-         */
-        ARTIFACT_DEPLOYING,
-
-        /**
-         * @see RepositoryListener#artifactDeployed(RepositoryEvent)
-         */
-        ARTIFACT_DEPLOYED,
-
-        /**
-         * @see RepositoryListener#metadataDeploying(RepositoryEvent)
-         */
-        METADATA_DEPLOYING,
-
-        /**
-         * @see RepositoryListener#metadataDeployed(RepositoryEvent)
-         */
-        METADATA_DEPLOYED
-
-    }
-
-    private final EventType type;
-
-    private final RepositorySystemSession session;
-
-    private final Artifact artifact;
-
-    private final Metadata metadata;
-
-    private final ArtifactRepository repository;
-
-    private final File file;
-
-    private final List<Exception> exceptions;
-
-    private final RequestTrace trace;
-
-    RepositoryEvent( Builder builder )
-    {
-        type = builder.type;
-        session = builder.session;
-        artifact = builder.artifact;
-        metadata = builder.metadata;
-        repository = builder.repository;
-        file = builder.file;
-        exceptions = builder.exceptions;
-        trace = builder.trace;
-    }
-
-    /**
-     * Gets the type of the event.
-     * 
-     * @return The type of the event, never {@code null}.
-     */
-    public EventType getType()
-    {
-        return type;
-    }
-
-    /**
-     * Gets the repository system session during which the event occurred.
-     * 
-     * @return The repository system session during which the event occurred, never {@code null}.
-     */
-    public RepositorySystemSession getSession()
-    {
-        return session;
-    }
-
-    /**
-     * Gets the artifact involved in the event (if any).
-     * 
-     * @return The involved artifact or {@code null} if none.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Gets the metadata involved in the event (if any).
-     * 
-     * @return The involved metadata or {@code null} if none.
-     */
-    public Metadata getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Gets the file involved in the event (if any).
-     * 
-     * @return The involved file or {@code null} if none.
-     */
-    public File getFile()
-    {
-        return file;
-    }
-
-    /**
-     * Gets the repository involved in the event (if any).
-     * 
-     * @return The involved repository or {@code null} if none.
-     */
-    public ArtifactRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Gets the exception that caused the event (if any). As a rule of thumb, an event accompanied by an exception
-     * indicates a failure of the corresponding action. If multiple exceptions occurred, this method returns the first
-     * exception.
-     * 
-     * @return The exception or {@code null} if none.
-     */
-    public Exception getException()
-    {
-        return exceptions.isEmpty() ? null : exceptions.get( 0 );
-    }
-
-    /**
-     * Gets the exceptions that caused the event (if any). As a rule of thumb, an event accompanied by exceptions
-     * indicates a failure of the corresponding action.
-     * 
-     * @return The exceptions, never {@code null}.
-     */
-    public List<Exception> getExceptions()
-    {
-        return exceptions;
-    }
-
-    /**
-     * Gets the trace information about the request during which the event occurred.
-     * 
-     * @return The trace information or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder buffer = new StringBuilder( 256 );
-        buffer.append( getType() );
-        if ( getArtifact() != null )
-        {
-            buffer.append( " " ).append( getArtifact() );
-        }
-        if ( getMetadata() != null )
-        {
-            buffer.append( " " ).append( getMetadata() );
-        }
-        if ( getFile() != null )
-        {
-            buffer.append( " (" ).append( getFile() ).append( ")" );
-        }
-        if ( getRepository() != null )
-        {
-            buffer.append( " @ " ).append( getRepository() );
-        }
-        return buffer.toString();
-    }
-
-    /**
-     * A builder to create events.
-     */
-    public static final class Builder
-    {
-
-        EventType type;
-
-        RepositorySystemSession session;
-
-        Artifact artifact;
-
-        Metadata metadata;
-
-        ArtifactRepository repository;
-
-        File file;
-
-        List<Exception> exceptions = Collections.emptyList();
-
-        RequestTrace trace;
-
-        /**
-         * Creates a new event builder for the specified session and event type.
-         * 
-         * @param session The repository system session, must not be {@code null}.
-         * @param type The type of the event, must not be {@code null}.
-         */
-        public Builder( RepositorySystemSession session, EventType type )
-        {
-            if ( session == null )
-            {
-                throw new IllegalArgumentException( "session not specified" );
-            }
-            this.session = session;
-            if ( type == null )
-            {
-                throw new IllegalArgumentException( "event type not specified" );
-            }
-            this.type = type;
-        }
-
-        /**
-         * Sets the artifact involved in the event.
-         * 
-         * @param artifact The involved artifact, may be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setArtifact( Artifact artifact )
-        {
-            this.artifact = artifact;
-            return this;
-        }
-
-        /**
-         * Sets the metadata involved in the event.
-         * 
-         * @param metadata The involved metadata, may be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setMetadata( Metadata metadata )
-        {
-            this.metadata = metadata;
-            return this;
-        }
-
-        /**
-         * Sets the repository involved in the event.
-         * 
-         * @param repository The involved repository, may be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setRepository( ArtifactRepository repository )
-        {
-            this.repository = repository;
-            return this;
-        }
-
-        /**
-         * Sets the file involved in the event.
-         * 
-         * @param file The involved file, may be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setFile( File file )
-        {
-            this.file = file;
-            return this;
-        }
-
-        /**
-         * Sets the exception causing the event.
-         * 
-         * @param exception The exception causing the event, may be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setException( Exception exception )
-        {
-            if ( exception != null )
-            {
-                this.exceptions = Collections.singletonList( exception );
-            }
-            else
-            {
-                this.exceptions = Collections.emptyList();
-            }
-            return this;
-        }
-
-        /**
-         * Sets the exceptions causing the event.
-         * 
-         * @param exceptions The exceptions causing the event, may be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setExceptions( List<Exception> exceptions )
-        {
-            if ( exceptions != null )
-            {
-                this.exceptions = exceptions;
-            }
-            else
-            {
-                this.exceptions = Collections.emptyList();
-            }
-            return this;
-        }
-
-        /**
-         * Sets the trace information about the request during which the event occurred.
-         * 
-         * @param trace The trace information, may be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setTrace( RequestTrace trace )
-        {
-            this.trace = trace;
-            return this;
-        }
-
-        /**
-         * Builds a new event from the current values of this builder. The state of the builder itself remains
-         * unchanged.
-         * 
-         * @return The event, never {@code null}.
-         */
-        public RepositoryEvent build()
-        {
-            return new RepositoryEvent( this );
-        }
-
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryException.java
deleted file mode 100644 (file)
index 35f0cfd..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-/**
- * The base class for exceptions thrown by the repository system. <em>Note:</em> Unless otherwise noted, instances of
- * this class and its subclasses will not persist fields carrying extended error information during serialization.
- */
-public class RepositoryException
-    extends Exception
-{
-
-    /**
-     * Creates a new exception with the specified detail message.
-     * 
-     * @param message The detail message, may be {@code null}.
-     */
-    public RepositoryException( String message )
-    {
-        super( message );
-    }
-
-    /**
-     * Creates a new exception with the specified detail message and cause.
-     * 
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public RepositoryException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-    /**
-     * @noreference This method is not intended to be used by clients.
-     * @param prefix A message prefix for the cause.
-     * @param cause The error cause.
-     * @return The error message for the cause.
-     */
-    protected static String getMessage( String prefix, Throwable cause )
-    {
-        String msg = "";
-        if ( cause != null )
-        {
-            msg = cause.getMessage();
-            if ( msg == null || msg.length() <= 0 )
-            {
-                msg = cause.getClass().getSimpleName();
-            }
-            msg = prefix + msg;
-        }
-        return msg;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryListener.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryListener.java
deleted file mode 100644 (file)
index 5f83923..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-/**
- * A listener being notified of events from the repository system. In general, the system sends events upon termination
- * of an operation like {@link #artifactResolved(RepositoryEvent)} regardless whether it succeeded or failed so
- * listeners need to inspect the event details carefully. Also, the listener may be called from an arbitrary thread.
- * <em>Note:</em> Implementors are strongly advised to inherit from {@link AbstractRepositoryListener} instead of
- * directly implementing this interface.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getRepositoryListener()
- * @see org.eclipse.aether.transfer.TransferListener
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface RepositoryListener
-{
-
-    /**
-     * Notifies the listener of a syntactically or semantically invalid artifact descriptor.
-     * {@link RepositoryEvent#getArtifact()} indicates the artifact whose descriptor is invalid and
-     * {@link RepositoryEvent#getExceptions()} carries the encountered errors. Depending on the session's
-     * {@link org.eclipse.aether.resolution.ArtifactDescriptorPolicy}, the underlying repository operation might abort
-     * with an exception or ignore the invalid descriptor.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactDescriptorInvalid( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of a missing artifact descriptor. {@link RepositoryEvent#getArtifact()} indicates the
-     * artifact whose descriptor is missing. Depending on the session's
-     * {@link org.eclipse.aether.resolution.ArtifactDescriptorPolicy}, the underlying repository operation might abort
-     * with an exception or ignore the missing descriptor.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactDescriptorMissing( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of syntactically or semantically invalid metadata. {@link RepositoryEvent#getMetadata()}
-     * indicates the invalid metadata and {@link RepositoryEvent#getExceptions()} carries the encountered errors. The
-     * underlying repository operation might still succeed, depending on whether the metadata in question is actually
-     * needed to carry out the resolution process.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void metadataInvalid( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of an artifact that is about to be resolved. {@link RepositoryEvent#getArtifact()} denotes
-     * the artifact in question. Unlike the {@link #artifactDownloading(RepositoryEvent)} event, this event is fired
-     * regardless whether the artifact already exists locally or not.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactResolving( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of an artifact whose resolution has been completed, either successfully or not.
-     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
-     * {@link RepositoryEvent#getExceptions()} indicates whether the resolution succeeded or failed. Unlike the
-     * {@link #artifactDownloaded(RepositoryEvent)} event, this event is fired regardless whether the artifact already
-     * exists locally or not.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactResolved( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of some metadata that is about to be resolved. {@link RepositoryEvent#getMetadata()}
-     * denotes the metadata in question. Unlike the {@link #metadataDownloading(RepositoryEvent)} event, this event is
-     * fired regardless whether the metadata already exists locally or not.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void metadataResolving( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of some metadata whose resolution has been completed, either successfully or not.
-     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
-     * {@link RepositoryEvent#getExceptions()} indicates whether the resolution succeeded or failed. Unlike the
-     * {@link #metadataDownloaded(RepositoryEvent)} event, this event is fired regardless whether the metadata already
-     * exists locally or not.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void metadataResolved( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of an artifact that is about to be downloaded from a remote repository.
-     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
-     * {@link RepositoryEvent#getRepository()} the source repository. Unlike the
-     * {@link #artifactResolving(RepositoryEvent)} event, this event is only fired when the artifact does not already
-     * exist locally.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactDownloading( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of an artifact whose download has been completed, either successfully or not.
-     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
-     * {@link RepositoryEvent#getExceptions()} indicates whether the download succeeded or failed. Unlike the
-     * {@link #artifactResolved(RepositoryEvent)} event, this event is only fired when the artifact does not already
-     * exist locally.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactDownloaded( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of some metadata that is about to be downloaded from a remote repository.
-     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
-     * {@link RepositoryEvent#getRepository()} the source repository. Unlike the
-     * {@link #metadataResolving(RepositoryEvent)} event, this event is only fired when the metadata does not already
-     * exist locally.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void metadataDownloading( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of some metadata whose download has been completed, either successfully or not.
-     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
-     * {@link RepositoryEvent#getExceptions()} indicates whether the download succeeded or failed. Unlike the
-     * {@link #metadataResolved(RepositoryEvent)} event, this event is only fired when the metadata does not already
-     * exist locally.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void metadataDownloaded( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of an artifact that is about to be installed to the local repository.
-     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactInstalling( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of an artifact whose installation to the local repository has been completed, either
-     * successfully or not. {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
-     * {@link RepositoryEvent#getExceptions()} indicates whether the installation succeeded or failed.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactInstalled( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of some metadata that is about to be installed to the local repository.
-     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void metadataInstalling( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of some metadata whose installation to the local repository has been completed, either
-     * successfully or not. {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
-     * {@link RepositoryEvent#getExceptions()} indicates whether the installation succeeded or failed.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void metadataInstalled( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of an artifact that is about to be uploaded to a remote repository.
-     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
-     * {@link RepositoryEvent#getRepository()} the destination repository.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactDeploying( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of an artifact whose upload to a remote repository has been completed, either successfully
-     * or not. {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
-     * {@link RepositoryEvent#getExceptions()} indicates whether the upload succeeded or failed.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void artifactDeployed( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of some metadata that is about to be uploaded to a remote repository.
-     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
-     * {@link RepositoryEvent#getRepository()} the destination repository.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void metadataDeploying( RepositoryEvent event );
-
-    /**
-     * Notifies the listener of some metadata whose upload to a remote repository has been completed, either
-     * successfully or not. {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
-     * {@link RepositoryEvent#getExceptions()} indicates whether the upload succeeded or failed.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void metadataDeployed( RepositoryEvent event );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystem.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystem.java
deleted file mode 100644 (file)
index debdb7d..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.collection.CollectRequest;
-import org.eclipse.aether.collection.CollectResult;
-import org.eclipse.aether.collection.DependencyCollectionException;
-import org.eclipse.aether.deployment.DeployRequest;
-import org.eclipse.aether.deployment.DeployResult;
-import org.eclipse.aether.deployment.DeploymentException;
-import org.eclipse.aether.installation.InstallRequest;
-import org.eclipse.aether.installation.InstallResult;
-import org.eclipse.aether.installation.InstallationException;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.LocalRepositoryManager;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.resolution.ArtifactDescriptorException;
-import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
-import org.eclipse.aether.resolution.ArtifactDescriptorResult;
-import org.eclipse.aether.resolution.ArtifactRequest;
-import org.eclipse.aether.resolution.ArtifactResolutionException;
-import org.eclipse.aether.resolution.ArtifactResult;
-import org.eclipse.aether.resolution.DependencyRequest;
-import org.eclipse.aether.resolution.DependencyResolutionException;
-import org.eclipse.aether.resolution.DependencyResult;
-import org.eclipse.aether.resolution.MetadataRequest;
-import org.eclipse.aether.resolution.MetadataResult;
-import org.eclipse.aether.resolution.VersionRangeRequest;
-import org.eclipse.aether.resolution.VersionRangeResolutionException;
-import org.eclipse.aether.resolution.VersionRangeResult;
-import org.eclipse.aether.resolution.VersionRequest;
-import org.eclipse.aether.resolution.VersionResolutionException;
-import org.eclipse.aether.resolution.VersionResult;
-
-/**
- * The main entry point to the repository system and its functionality. Note that obtaining a concrete implementation of
- * this interface (e.g. via dependency injection, service locator, etc.) is dependent on the application and its
- * specific needs, please consult the online documentation for examples and directions on booting the system.
- * 
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface RepositorySystem
-{
-
-    /**
-     * Expands a version range to a list of matching versions, in ascending order. For example, resolves "[3.8,4.0)" to
-     * "3.8", "3.8.1", "3.8.2". Note that the returned list of versions is only dependent on the configured repositories
-     * and their contents, the list is not processed by the {@link RepositorySystemSession#getVersionFilter() session's
-     * version filter}.
-     * <p>
-     * The supplied request may also refer to a single concrete version rather than a version range. In this case
-     * though, the result contains simply the (parsed) input version, regardless of the repositories and their contents.
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param request The version range request, must not be {@code null}.
-     * @return The version range result, never {@code null}.
-     * @throws VersionRangeResolutionException If the requested range could not be parsed. Note that an empty range does
-     *             not raise an exception.
-     * @see #newResolutionRepositories(RepositorySystemSession, List)
-     */
-    VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
-        throws VersionRangeResolutionException;
-
-    /**
-     * Resolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT" to
-     * "1.0-20090208.132618-23".
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param request The version request, must not be {@code null}.
-     * @return The version result, never {@code null}.
-     * @throws VersionResolutionException If the metaversion could not be resolved.
-     * @see #newResolutionRepositories(RepositorySystemSession, List)
-     */
-    VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
-        throws VersionResolutionException;
-
-    /**
-     * Gets information about an artifact like its direct dependencies and potential relocations.
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param request The descriptor request, must not be {@code null}.
-     * @return The descriptor result, never {@code null}.
-     * @throws ArtifactDescriptorException If the artifact descriptor could not be read.
-     * @see RepositorySystemSession#getArtifactDescriptorPolicy()
-     * @see #newResolutionRepositories(RepositorySystemSession, List)
-     */
-    ArtifactDescriptorResult readArtifactDescriptor( RepositorySystemSession session, ArtifactDescriptorRequest request )
-        throws ArtifactDescriptorException;
-
-    /**
-     * Collects the transitive dependencies of an artifact and builds a dependency graph. Note that this operation is
-     * only concerned about determining the coordinates of the transitive dependencies. To also resolve the actual
-     * artifact files, use {@link #resolveDependencies(RepositorySystemSession, DependencyRequest)}.
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param request The collection request, must not be {@code null}.
-     * @return The collection result, never {@code null}.
-     * @throws DependencyCollectionException If the dependency tree could not be built.
-     * @see RepositorySystemSession#getDependencyTraverser()
-     * @see RepositorySystemSession#getDependencyManager()
-     * @see RepositorySystemSession#getDependencySelector()
-     * @see RepositorySystemSession#getVersionFilter()
-     * @see RepositorySystemSession#getDependencyGraphTransformer()
-     * @see #newResolutionRepositories(RepositorySystemSession, List)
-     */
-    CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request )
-        throws DependencyCollectionException;
-
-    /**
-     * Collects and resolves the transitive dependencies of an artifact. This operation is essentially a combination of
-     * {@link #collectDependencies(RepositorySystemSession, CollectRequest)} and
-     * {@link #resolveArtifacts(RepositorySystemSession, Collection)}.
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param request The dependency request, must not be {@code null}.
-     * @return The dependency result, never {@code null}.
-     * @throws DependencyResolutionException If the dependency tree could not be built or any dependency artifact could
-     *             not be resolved.
-     * @see #newResolutionRepositories(RepositorySystemSession, List)
-     */
-    DependencyResult resolveDependencies( RepositorySystemSession session, DependencyRequest request )
-        throws DependencyResolutionException;
-
-    /**
-     * Resolves the path for an artifact. The artifact will be downloaded to the local repository if necessary. An
-     * artifact that is already resolved will be skipped and is not re-resolved. In general, callers must not assume any
-     * relationship between an artifact's resolved filename and its coordinates. Note that this method assumes that any
-     * relocations have already been processed.
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param request The resolution request, must not be {@code null}.
-     * @return The resolution result, never {@code null}.
-     * @throws ArtifactResolutionException If the artifact could not be resolved.
-     * @see Artifact#getFile()
-     * @see #newResolutionRepositories(RepositorySystemSession, List)
-     */
-    ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request )
-        throws ArtifactResolutionException;
-
-    /**
-     * Resolves the paths for a collection of artifacts. Artifacts will be downloaded to the local repository if
-     * necessary. Artifacts that are already resolved will be skipped and are not re-resolved. In general, callers must
-     * not assume any relationship between an artifact's filename and its coordinates. Note that this method assumes
-     * that any relocations have already been processed.
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param requests The resolution requests, must not be {@code null}.
-     * @return The resolution results (in request order), never {@code null}.
-     * @throws ArtifactResolutionException If any artifact could not be resolved.
-     * @see Artifact#getFile()
-     * @see #newResolutionRepositories(RepositorySystemSession, List)
-     */
-    List<ArtifactResult> resolveArtifacts( RepositorySystemSession session,
-                                           Collection<? extends ArtifactRequest> requests )
-        throws ArtifactResolutionException;
-
-    /**
-     * Resolves the paths for a collection of metadata. Metadata will be downloaded to the local repository if
-     * necessary, e.g. because it hasn't been cached yet or the cache is deemed outdated.
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param requests The resolution requests, must not be {@code null}.
-     * @return The resolution results (in request order), never {@code null}.
-     * @see Metadata#getFile()
-     * @see #newResolutionRepositories(RepositorySystemSession, List)
-     */
-    List<MetadataResult> resolveMetadata( RepositorySystemSession session,
-                                          Collection<? extends MetadataRequest> requests );
-
-    /**
-     * Installs a collection of artifacts and their accompanying metadata to the local repository.
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param request The installation request, must not be {@code null}.
-     * @return The installation result, never {@code null}.
-     * @throws InstallationException If any artifact/metadata from the request could not be installed.
-     */
-    InstallResult install( RepositorySystemSession session, InstallRequest request )
-        throws InstallationException;
-
-    /**
-     * Uploads a collection of artifacts and their accompanying metadata to a remote repository.
-     * 
-     * @param session The repository session, must not be {@code null}.
-     * @param request The deployment request, must not be {@code null}.
-     * @return The deployment result, never {@code null}.
-     * @throws DeploymentException If any artifact/metadata from the request could not be deployed.
-     * @see #newDeploymentRepository(RepositorySystemSession, RemoteRepository)
-     */
-    DeployResult deploy( RepositorySystemSession session, DeployRequest request )
-        throws DeploymentException;
-
-    /**
-     * Creates a new manager for the specified local repository. If the specified local repository has no type, the
-     * default local repository type of the system will be used. <em>Note:</em> It is expected that this method
-     * invocation is one of the last steps of setting up a new session, in particular any configuration properties
-     * should have been set already.
-     * 
-     * @param session The repository system session from which to configure the manager, must not be {@code null}.
-     * @param localRepository The local repository to create a manager for, must not be {@code null}.
-     * @return The local repository manager, never {@code null}.
-     * @throws IllegalArgumentException If the specified repository type is not recognized or no base directory is
-     *             given.
-     */
-    LocalRepositoryManager newLocalRepositoryManager( RepositorySystemSession session, LocalRepository localRepository );
-
-    /**
-     * Creates a new synchronization context.
-     * 
-     * @param session The repository session during which the context will be used, must not be {@code null}.
-     * @param shared A flag indicating whether access to the artifacts/metadata associated with the new context can be
-     *            shared among concurrent readers or whether access needs to be exclusive to the calling thread.
-     * @return The synchronization context, never {@code null}.
-     */
-    SyncContext newSyncContext( RepositorySystemSession session, boolean shared );
-
-    /**
-     * Forms remote repositories suitable for artifact resolution by applying the session's authentication selector and
-     * similar network configuration to the given repository prototypes. As noted for
-     * {@link RepositorySystemSession#getAuthenticationSelector()} etc. the remote repositories passed to e.g.
-     * {@link #resolveArtifact(RepositorySystemSession, ArtifactRequest) resolveArtifact()} are used as is and expected
-     * to already carry any required authentication or proxy configuration. This method can be used to apply the
-     * authentication/proxy configuration from a session to a bare repository definition to obtain the complete
-     * repository definition for use in the resolution request.
-     * 
-     * @param session The repository system session from which to configure the repositories, must not be {@code null}.
-     * @param repositories The repository prototypes from which to derive the resolution repositories, must not be
-     *            {@code null} or contain {@code null} elements.
-     * @return The resolution repositories, never {@code null}. Note that there is generally no 1:1 relationship of the
-     *         obtained repositories to the original inputs due to mirror selection potentially aggregating multiple
-     *         repositories.
-     * @see #newDeploymentRepository(RepositorySystemSession, RemoteRepository)
-     */
-    List<RemoteRepository> newResolutionRepositories( RepositorySystemSession session,
-                                                      List<RemoteRepository> repositories );
-
-    /**
-     * Forms a remote repository suitable for artifact deployment by applying the session's authentication selector and
-     * similar network configuration to the given repository prototype. As noted for
-     * {@link RepositorySystemSession#getAuthenticationSelector()} etc. the remote repository passed to
-     * {@link #deploy(RepositorySystemSession, DeployRequest) deploy()} is used as is and expected to already carry any
-     * required authentication or proxy configuration. This method can be used to apply the authentication/proxy
-     * configuration from a session to a bare repository definition to obtain the complete repository definition for use
-     * in the deploy request.
-     * 
-     * @param session The repository system session from which to configure the repository, must not be {@code null}.
-     * @param repository The repository prototype from which to derive the deployment repository, must not be
-     *            {@code null}.
-     * @return The deployment repository, never {@code null}.
-     * @see #newResolutionRepositories(RepositorySystemSession, List)
-     */
-    RemoteRepository newDeploymentRepository( RepositorySystemSession session, RemoteRepository repository );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystemSession.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystemSession.java
deleted file mode 100644 (file)
index 96f51c1..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-import java.util.Map;
-
-import org.eclipse.aether.artifact.ArtifactTypeRegistry;
-import org.eclipse.aether.collection.DependencyGraphTransformer;
-import org.eclipse.aether.collection.DependencyManager;
-import org.eclipse.aether.collection.DependencySelector;
-import org.eclipse.aether.collection.DependencyTraverser;
-import org.eclipse.aether.collection.VersionFilter;
-import org.eclipse.aether.repository.AuthenticationSelector;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.LocalRepositoryManager;
-import org.eclipse.aether.repository.MirrorSelector;
-import org.eclipse.aether.repository.ProxySelector;
-import org.eclipse.aether.repository.RepositoryPolicy;
-import org.eclipse.aether.repository.WorkspaceReader;
-import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
-import org.eclipse.aether.resolution.ResolutionErrorPolicy;
-import org.eclipse.aether.transfer.TransferListener;
-
-/**
- * Defines settings and components that control the repository system. Once initialized, the session object itself is
- * supposed to be immutable and hence can safely be shared across an entire application and any concurrent threads
- * reading it. Components that wish to tweak some aspects of an existing session should use the copy constructor of
- * {@link DefaultRepositorySystemSession} and its mutators to derive a custom session.
- * 
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface RepositorySystemSession
-{
-
-    /**
-     * Indicates whether the repository system operates in offline mode and avoids/refuses any access to remote
-     * repositories.
-     * 
-     * @return {@code true} if the repository system is in offline mode, {@code false} otherwise.
-     */
-    boolean isOffline();
-
-    /**
-     * Indicates whether repositories declared in artifact descriptors should be ignored during transitive dependency
-     * collection. If enabled, only the repositories originally provided with the collect request will be considered.
-     * 
-     * @return {@code true} if additional repositories from artifact descriptors are ignored, {@code false} to merge
-     *         those with the originally specified repositories.
-     */
-    boolean isIgnoreArtifactDescriptorRepositories();
-
-    /**
-     * Gets the policy which controls whether resolutions errors from remote repositories should be cached.
-     * 
-     * @return The resolution error policy for this session or {@code null} if resolution errors should generally not be
-     *         cached.
-     */
-    ResolutionErrorPolicy getResolutionErrorPolicy();
-
-    /**
-     * Gets the policy which controls how errors related to reading artifact descriptors should be handled.
-     * 
-     * @return The descriptor error policy for this session or {@code null} if descriptor errors should generally not be
-     *         tolerated.
-     */
-    ArtifactDescriptorPolicy getArtifactDescriptorPolicy();
-
-    /**
-     * Gets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
-     * repositories being used for resolution.
-     * 
-     * @return The global checksum policy or {@code null}/empty if not set and the per-repository policies apply.
-     * @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
-     * @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
-     * @see RepositoryPolicy#CHECKSUM_POLICY_WARN
-     */
-    String getChecksumPolicy();
-
-    /**
-     * Gets the global update policy. If set, the global update policy overrides the update policies of the remote
-     * repositories being used for resolution.
-     * 
-     * @return The global update policy or {@code null}/empty if not set and the per-repository policies apply.
-     * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
-     * @see RepositoryPolicy#UPDATE_POLICY_DAILY
-     * @see RepositoryPolicy#UPDATE_POLICY_NEVER
-     */
-    String getUpdatePolicy();
-
-    /**
-     * Gets the local repository used during this session. This is a convenience method for
-     * {@link LocalRepositoryManager#getRepository()}.
-     * 
-     * @return The local repository being during this session, never {@code null}.
-     */
-    LocalRepository getLocalRepository();
-
-    /**
-     * Gets the local repository manager used during this session.
-     * 
-     * @return The local repository manager used during this session, never {@code null}.
-     */
-    LocalRepositoryManager getLocalRepositoryManager();
-
-    /**
-     * Gets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
-     * to resolve artifacts.
-     * 
-     * @return The workspace reader for this session or {@code null} if none.
-     */
-    WorkspaceReader getWorkspaceReader();
-
-    /**
-     * Gets the listener being notified of actions in the repository system.
-     * 
-     * @return The repository listener or {@code null} if none.
-     */
-    RepositoryListener getRepositoryListener();
-
-    /**
-     * Gets the listener being notified of uploads/downloads by the repository system.
-     * 
-     * @return The transfer listener or {@code null} if none.
-     */
-    TransferListener getTransferListener();
-
-    /**
-     * Gets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
-     * collected from the runtime environment like {@link System#getProperties()} and environment variables.
-     * 
-     * @return The (read-only) system properties, never {@code null}.
-     */
-    Map<String, String> getSystemProperties();
-
-    /**
-     * Gets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
-     * system properties but are set on the discretion of the user and hence are considered of higher priority than
-     * system properties.
-     * 
-     * @return The (read-only) user properties, never {@code null}.
-     */
-    Map<String, String> getUserProperties();
-
-    /**
-     * Gets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
-     * connector-specific behavior, etc.)
-     * 
-     * @return The (read-only) configuration properties, never {@code null}.
-     * @see ConfigurationProperties
-     */
-    Map<String, Object> getConfigProperties();
-
-    /**
-     * Gets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
-     * not used for remote repositories which are passed as request parameters to the repository system, those
-     * repositories are supposed to denote the effective repositories.
-     * 
-     * @return The mirror selector to use, never {@code null}.
-     * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
-     */
-    MirrorSelector getMirrorSelector();
-
-    /**
-     * Gets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
-     * not used for remote repositories which are passed as request parameters to the repository system, those
-     * repositories are supposed to have their proxy (if any) already set.
-     * 
-     * @return The proxy selector to use, never {@code null}.
-     * @see org.eclipse.aether.repository.RemoteRepository#getProxy()
-     * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
-     */
-    ProxySelector getProxySelector();
-
-    /**
-     * Gets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
-     * selector is not used for remote repositories which are passed as request parameters to the repository system,
-     * those repositories are supposed to have their authentication (if any) already set.
-     * 
-     * @return The authentication selector to use, never {@code null}.
-     * @see org.eclipse.aether.repository.RemoteRepository#getAuthentication()
-     * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
-     */
-    AuthenticationSelector getAuthenticationSelector();
-
-    /**
-     * Gets the registry of artifact types recognized by this session, for instance when processing artifact
-     * descriptors.
-     * 
-     * @return The artifact type registry, never {@code null}.
-     */
-    ArtifactTypeRegistry getArtifactTypeRegistry();
-
-    /**
-     * Gets the dependency traverser to use for building dependency graphs.
-     * 
-     * @return The dependency traverser to use for building dependency graphs or {@code null} if dependencies are
-     *         unconditionally traversed.
-     */
-    DependencyTraverser getDependencyTraverser();
-
-    /**
-     * Gets the dependency manager to use for building dependency graphs.
-     * 
-     * @return The dependency manager to use for building dependency graphs or {@code null} if dependency management is
-     *         not performed.
-     */
-    DependencyManager getDependencyManager();
-
-    /**
-     * Gets the dependency selector to use for building dependency graphs.
-     * 
-     * @return The dependency selector to use for building dependency graphs or {@code null} if dependencies are
-     *         unconditionally included.
-     */
-    DependencySelector getDependencySelector();
-
-    /**
-     * Gets the version filter to use for building dependency graphs.
-     * 
-     * @return The version filter to use for building dependency graphs or {@code null} if versions aren't filtered.
-     */
-    VersionFilter getVersionFilter();
-
-    /**
-     * Gets the dependency graph transformer to use for building dependency graphs.
-     * 
-     * @return The dependency graph transformer to use for building dependency graphs or {@code null} if none.
-     */
-    DependencyGraphTransformer getDependencyGraphTransformer();
-
-    /**
-     * Gets the custom data associated with this session.
-     * 
-     * @return The session data, never {@code null}.
-     */
-    SessionData getData();
-
-    /**
-     * Gets the cache the repository system may use to save data for future reuse during the session.
-     * 
-     * @return The repository cache or {@code null} if none.
-     */
-    RepositoryCache getCache();
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/RequestTrace.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/RequestTrace.java
deleted file mode 100644 (file)
index c6afa8e..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-/**
- * A trace of nested requests that are performed by the repository system. This trace information can be used to
- * correlate repository events with higher level operations in the application code that eventually caused the events. A
- * single trace can carry an arbitrary object as data which is meant to describe a request/operation that is currently
- * executed. For call hierarchies within the repository system itself, this data will usually be the {@code *Request}
- * object that is currently processed. When invoking methods on the repository system, client code may provide a request
- * trace that has been prepopulated with whatever data is useful for the application to indicate its state for later
- * evaluation when processing the repository events.
- * 
- * @see RepositoryEvent#getTrace()
- */
-public class RequestTrace
-{
-
-    private final RequestTrace parent;
-
-    private final Object data;
-
-    /**
-     * Creates a child of the specified request trace. This method is basically a convenience that will invoke
-     * {@link RequestTrace#newChild(Object) parent.newChild()} when the specified parent trace is not {@code null} or
-     * otherwise instantiante a new root trace.
-     * 
-     * @param parent The parent request trace, may be {@code null}.
-     * @param data The data to associate with the child trace, may be {@code null}.
-     * @return The child trace, never {@code null}.
-     */
-    public static RequestTrace newChild( RequestTrace parent, Object data )
-    {
-        if ( parent == null )
-        {
-            return new RequestTrace( data );
-        }
-        return parent.newChild( data );
-    }
-
-    /**
-     * Creates a new root trace with the specified data.
-     * 
-     * @param data The data to associate with the trace, may be {@code null}.
-     */
-    public RequestTrace( Object data )
-    {
-        this( null, data );
-    }
-
-    /**
-     * Creates a new trace with the specified data and parent
-     * 
-     * @param parent The parent trace, may be {@code null} for a root trace.
-     * @param data The data to associate with the trace, may be {@code null}.
-     */
-    protected RequestTrace( RequestTrace parent, Object data )
-    {
-        this.parent = parent;
-        this.data = data;
-    }
-
-    /**
-     * Gets the data associated with this trace.
-     * 
-     * @return The data associated with this trace or {@code null} if none.
-     */
-    public final Object getData()
-    {
-        return data;
-    }
-
-    /**
-     * Gets the parent of this trace.
-     * 
-     * @return The parent of this trace or {@code null} if this is the root of the trace stack.
-     */
-    public final RequestTrace getParent()
-    {
-        return parent;
-    }
-
-    /**
-     * Creates a new child of this trace.
-     * 
-     * @param data The data to associate with the child, may be {@code null}.
-     * @return The child trace, never {@code null}.
-     */
-    public RequestTrace newChild( Object data )
-    {
-        return new RequestTrace( this, data );
-    }
-
-    @Override
-    public String toString()
-    {
-        return String.valueOf( getData() );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/SessionData.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/SessionData.java
deleted file mode 100644 (file)
index 92930e7..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-/**
- * A container for data that is specific to a repository system session. Both components within the repository system
- * and clients of the system may use this storage to associate arbitrary data with a session.
- * <p>
- * Unlike a cache, this session data is not subject to purging. For this same reason, session data should also not be
- * abused as a cache (i.e. for storing values that can be re-calculated) to avoid memory exhaustion.
- * <p>
- * <strong>Note:</strong> Actual implementations must be thread-safe.
- * 
- * @see RepositorySystemSession#getData()
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface SessionData
-{
-
-    /**
-     * Associates the specified session data with the given key.
-     * 
-     * @param key The key under which to store the session data, must not be {@code null}.
-     * @param value The data to associate with the key, may be {@code null} to remove the mapping.
-     */
-    void set( Object key, Object value );
-
-    /**
-     * Associates the specified session data with the given key if the key is currently mapped to the given value. This
-     * method provides an atomic compare-and-update of some key's value.
-     * 
-     * @param key The key under which to store the session data, must not be {@code null}.
-     * @param oldValue The expected data currently associated with the key, may be {@code null}.
-     * @param newValue The data to associate with the key, may be {@code null} to remove the mapping.
-     * @return {@code true} if the key mapping was successfully updated from the old value to the new value,
-     *         {@code false} if the current key mapping didn't match the expected value and was not updated.
-     */
-    boolean set( Object key, Object oldValue, Object newValue );
-
-    /**
-     * Gets the session data associated with the specified key.
-     * 
-     * @param key The key for which to retrieve the session data, must not be {@code null}.
-     * @return The session data associated with the key or {@code null} if none.
-     */
-    Object get( Object key );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/SyncContext.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/SyncContext.java
deleted file mode 100644 (file)
index a05d512..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether;
-
-import java.io.Closeable;
-import java.util.Collection;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * A synchronization context used to coordinate concurrent access to artifacts or metadatas. The typical usage of a
- * synchronization context looks like this:
- * 
- * <pre>
- * SyncContext syncContext = repositorySystem.newSyncContext( ... );
- * try {
- *     syncContext.acquire( artifacts, metadatas );
- *     // work with the artifacts and metadatas
- * } finally {
- *     syncContext.close();
- * }
- * </pre>
- * 
- * Within one thread, synchronization contexts may be nested which can naturally happen in a hierarchy of method calls.
- * The nested synchronization contexts may also acquire overlapping sets of artifacts/metadatas as long as the following
- * conditions are met. If the outer-most context holding a particular resource is exclusive, that resource can be
- * reacquired in any nested context. If however the outer-most context is shared, the resource may only be reacquired by
- * nested contexts if these are also shared.
- * <p>
- * A synchronization context is meant to be utilized by only one thread and as such is not thread-safe.
- * <p>
- * Note that the level of actual synchronization is subject to the implementation and might range from OS-wide to none.
- * 
- * @see RepositorySystem#newSyncContext(RepositorySystemSession, boolean)
- */
-public interface SyncContext
-    extends Closeable
-{
-
-    /**
-     * Acquires synchronized access to the specified artifacts and metadatas. The invocation will potentially block
-     * until all requested resources can be acquired by the calling thread. Acquiring resources that are already
-     * acquired by this synchronization context has no effect. Please also see the class-level documentation for
-     * information regarding reentrancy. The method may be invoked multiple times on a synchronization context until all
-     * desired resources have been acquired.
-     * 
-     * @param artifacts The artifacts to acquire, may be {@code null} or empty if none.
-     * @param metadatas The metadatas to acquire, may be {@code null} or empty if none.
-     */
-    void acquire( Collection<? extends Artifact> artifacts, Collection<? extends Metadata> metadatas );
-
-    /**
-     * Releases all previously acquired artifacts/metadatas. If no resources have been acquired before or if this
-     * synchronization context has already been closed, this method does nothing.
-     */
-    void close();
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/AbstractArtifact.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/AbstractArtifact.java
deleted file mode 100644 (file)
index 2944ff8..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.artifact;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * A skeleton class for artifacts.
- */
-public abstract class AbstractArtifact
-    implements Artifact
-{
-
-    private static final String SNAPSHOT = "SNAPSHOT";
-
-    private static final Pattern SNAPSHOT_TIMESTAMP = Pattern.compile( "^(.*-)?([0-9]{8}\\.[0-9]{6}-[0-9]+)$" );
-
-    public boolean isSnapshot()
-    {
-        return isSnapshot( getVersion() );
-    }
-
-    private static boolean isSnapshot( String version )
-    {
-        return version.endsWith( SNAPSHOT ) || SNAPSHOT_TIMESTAMP.matcher( version ).matches();
-    }
-
-    public String getBaseVersion()
-    {
-        return toBaseVersion( getVersion() );
-    }
-
-    private static String toBaseVersion( String version )
-    {
-        String baseVersion;
-
-        if ( version == null )
-        {
-            baseVersion = version;
-        }
-        else if ( version.startsWith( "[" ) || version.startsWith( "(" ) )
-        {
-            baseVersion = version;
-        }
-        else
-        {
-            Matcher m = SNAPSHOT_TIMESTAMP.matcher( version );
-            if ( m.matches() )
-            {
-                if ( m.group( 1 ) != null )
-                {
-                    baseVersion = m.group( 1 ) + SNAPSHOT;
-                }
-                else
-                {
-                    baseVersion = SNAPSHOT;
-                }
-            }
-            else
-            {
-                baseVersion = version;
-            }
-        }
-
-        return baseVersion;
-    }
-
-    /**
-     * Creates a new artifact with the specified coordinates, properties and file.
-     * 
-     * @param version The version of the artifact, may be {@code null}.
-     * @param properties The properties of the artifact, may be {@code null} if none. The method may assume immutability
-     *            of the supplied map, i.e. need not copy it.
-     * @param file The resolved file of the artifact, may be {@code null}.
-     * @return The new artifact instance, never {@code null}.
-     */
-    private Artifact newInstance( String version, Map<String, String> properties, File file )
-    {
-        return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), version, file,
-                                    properties );
-    }
-
-    public Artifact setVersion( String version )
-    {
-        String current = getVersion();
-        if ( current.equals( version ) || ( version == null && current.length() <= 0 ) )
-        {
-            return this;
-        }
-        return newInstance( version, getProperties(), getFile() );
-    }
-
-    public Artifact setFile( File file )
-    {
-        File current = getFile();
-        if ( ( current == null ) ? file == null : current.equals( file ) )
-        {
-            return this;
-        }
-        return newInstance( getVersion(), getProperties(), file );
-    }
-
-    public Artifact setProperties( Map<String, String> properties )
-    {
-        Map<String, String> current = getProperties();
-        if ( current.equals( properties ) || ( properties == null && current.isEmpty() ) )
-        {
-            return this;
-        }
-        return newInstance( getVersion(), copyProperties( properties ), getFile() );
-    }
-
-    public String getProperty( String key, String defaultValue )
-    {
-        String value = getProperties().get( key );
-        return ( value != null ) ? value : defaultValue;
-    }
-
-    /**
-     * Copies the specified artifact properties. This utility method should be used when creating new artifact instances
-     * with caller-supplied properties.
-     * 
-     * @param properties The properties to copy, may be {@code null}.
-     * @return The copied and read-only properties, never {@code null}.
-     */
-    protected static Map<String, String> copyProperties( Map<String, String> properties )
-    {
-        if ( properties != null && !properties.isEmpty() )
-        {
-            return Collections.unmodifiableMap( new HashMap<String, String>( properties ) );
-        }
-        else
-        {
-            return Collections.emptyMap();
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder buffer = new StringBuilder( 128 );
-        buffer.append( getGroupId() );
-        buffer.append( ':' ).append( getArtifactId() );
-        buffer.append( ':' ).append( getExtension() );
-        if ( getClassifier().length() > 0 )
-        {
-            buffer.append( ':' ).append( getClassifier() );
-        }
-        buffer.append( ':' ).append( getVersion() );
-        return buffer.toString();
-    }
-
-    /**
-     * Compares this artifact with the specified object.
-     * 
-     * @param obj The object to compare this artifact against, may be {@code null}.
-     * @return {@code true} if and only if the specified object is another {@link Artifact} with equal coordinates,
-     *         properties and file, {@code false} otherwise.
-     */
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( obj == this )
-        {
-            return true;
-        }
-        else if ( !( obj instanceof Artifact ) )
-        {
-            return false;
-        }
-
-        Artifact that = (Artifact) obj;
-
-        return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() )
-            && getVersion().equals( that.getVersion() ) && getExtension().equals( that.getExtension() )
-            && getClassifier().equals( that.getClassifier() ) && eq( getFile(), that.getFile() )
-            && getProperties().equals( that.getProperties() );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
-    }
-
-    /**
-     * Returns a hash code for this artifact.
-     * 
-     * @return A hash code for the artifact.
-     */
-    @Override
-    public int hashCode()
-    {
-        int hash = 17;
-        hash = hash * 31 + getGroupId().hashCode();
-        hash = hash * 31 + getArtifactId().hashCode();
-        hash = hash * 31 + getExtension().hashCode();
-        hash = hash * 31 + getClassifier().hashCode();
-        hash = hash * 31 + getVersion().hashCode();
-        hash = hash * 31 + hash( getFile() );
-        return hash;
-    }
-
-    private static int hash( Object obj )
-    {
-        return ( obj != null ) ? obj.hashCode() : 0;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/Artifact.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/Artifact.java
deleted file mode 100644 (file)
index 5eef695..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.artifact;
-
-import java.io.File;
-import java.util.Map;
-
-/**
- * A specific artifact. In a nutshell, an artifact has identifying coordinates and optionally a file that denotes its
- * data. <em>Note:</em> Artifact instances are supposed to be immutable, e.g. any exposed mutator method returns a new
- * artifact instance and leaves the original instance unchanged. <em>Note:</em> Implementors are strongly advised to
- * inherit from {@link AbstractArtifact} instead of directly implementing this interface.
- * 
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface Artifact
-{
-
-    /**
-     * Gets the group identifier of this artifact, for example "org.apache.maven".
-     * 
-     * @return The group identifier, never {@code null}.
-     */
-    String getGroupId();
-
-    /**
-     * Gets the artifact identifier of this artifact, for example "maven-model".
-     * 
-     * @return The artifact identifier, never {@code null}.
-     */
-    String getArtifactId();
-
-    /**
-     * Gets the version of this artifact, for example "1.0-20100529-1213". Note that in case of meta versions like
-     * "1.0-SNAPSHOT", the artifact's version depends on the state of the artifact. Artifacts that have been resolved or
-     * deployed will usually have the meta version expanded.
-     * 
-     * @return The version, never {@code null}.
-     */
-    String getVersion();
-
-    /**
-     * Sets the version of the artifact.
-     * 
-     * @param version The version of this artifact, may be {@code null} or empty.
-     * @return The new artifact, never {@code null}.
-     */
-    Artifact setVersion( String version );
-
-    /**
-     * Gets the base version of this artifact, for example "1.0-SNAPSHOT". In contrast to the {@link #getVersion()}, the
-     * base version will always refer to the unresolved meta version.
-     * 
-     * @return The base version, never {@code null}.
-     */
-    String getBaseVersion();
-
-    /**
-     * Determines whether this artifact uses a snapshot version.
-     * 
-     * @return {@code true} if the artifact is a snapshot, {@code false} otherwise.
-     */
-    boolean isSnapshot();
-
-    /**
-     * Gets the classifier of this artifact, for example "sources".
-     * 
-     * @return The classifier or an empty string if none, never {@code null}.
-     */
-    String getClassifier();
-
-    /**
-     * Gets the (file) extension of this artifact, for example "jar" or "tar.gz".
-     * 
-     * @return The file extension (without leading period), never {@code null}.
-     */
-    String getExtension();
-
-    /**
-     * Gets the file of this artifact. Note that only resolved artifacts have a file associated with them. In general,
-     * callers must not assume any relationship between an artifact's filename and its coordinates.
-     * 
-     * @return The file or {@code null} if the artifact isn't resolved.
-     */
-    File getFile();
-
-    /**
-     * Sets the file of the artifact.
-     * 
-     * @param file The file of the artifact, may be {@code null}
-     * @return The new artifact, never {@code null}.
-     */
-    Artifact setFile( File file );
-
-    /**
-     * Gets the specified property.
-     * 
-     * @param key The name of the property, must not be {@code null}.
-     * @param defaultValue The default value to return in case the property is not set, may be {@code null}.
-     * @return The requested property value or {@code null} if the property is not set and no default value was
-     *         provided.
-     * @see ArtifactProperties
-     */
-    String getProperty( String key, String defaultValue );
-
-    /**
-     * Gets the properties of this artifact. Clients may use these properties to associate non-persistent values with an
-     * artifact that help later processing when the artifact gets passed around within the application.
-     * 
-     * @return The (read-only) properties, never {@code null}.
-     * @see ArtifactProperties
-     */
-    Map<String, String> getProperties();
-
-    /**
-     * Sets the properties for the artifact. Note that these properties exist merely in memory and are not persisted
-     * when the artifact gets installed/deployed to a repository.
-     * 
-     * @param properties The properties for the artifact, may be {@code null}.
-     * @return The new artifact, never {@code null}.
-     * @see ArtifactProperties
-     */
-    Artifact setProperties( Map<String, String> properties );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactProperties.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactProperties.java
deleted file mode 100644 (file)
index 7fbea04..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.artifact;
-
-/**
- * The keys for common properties of artifacts.
- * 
- * @see Artifact#getProperties()
- */
-public final class ArtifactProperties
-{
-
-    /**
-     * A high-level characterization of the artifact, e.g. "maven-plugin" or "test-jar".
-     * 
-     * @see ArtifactType#getId()
-     */
-    public static final String TYPE = "type";
-
-    /**
-     * The programming language this artifact is relevant for, e.g. "java" or "none".
-     */
-    public static final String LANGUAGE = "language";
-
-    /**
-     * The (expected) path to the artifact on the local filesystem. An artifact which has this property set is assumed
-     * to be not present in any regular repository and likewise has no artifact descriptor. Artifact resolution will
-     * verify the path and resolve the artifact if the path actually denotes an existing file. If the path isn't valid,
-     * resolution will fail and no attempts to search local/remote repositories are made.
-     */
-    public static final String LOCAL_PATH = "localPath";
-
-    /**
-     * A boolean flag indicating whether the artifact presents some kind of bundle that physically includes its
-     * dependencies, e.g. a fat WAR.
-     */
-    public static final String INCLUDES_DEPENDENCIES = "includesDependencies";
-
-    /**
-     * A boolean flag indicating whether the artifact is meant to be used for the compile/runtime/test build path of a
-     * consumer project.
-     */
-    public static final String CONSTITUTES_BUILD_PATH = "constitutesBuildPath";
-
-    /**
-     * The URL to a web page from which the artifact can be manually downloaded. This URL is not contacted by the
-     * repository system but serves as a pointer for the end user to assist in getting artifacts that are not published
-     * in a proper repository.
-     */
-    public static final String DOWNLOAD_URL = "downloadUrl";
-
-    private ArtifactProperties()
-    {
-        // hide constructor
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactType.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactType.java
deleted file mode 100644 (file)
index 174c3c5..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.artifact;
-
-import java.util.Map;
-
-/**
- * An artifact type describing artifact characteristics/properties that are common for certain artifacts. Artifact types
- * are a means to simplify the description of an artifact by referring to an artifact type instead of specifying the
- * various properties individually.
- * 
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- * @see ArtifactTypeRegistry
- * @see DefaultArtifact#DefaultArtifact(String, String, String, String, String, ArtifactType)
- */
-public interface ArtifactType
-{
-
-    /**
-     * Gets the identifier of this type, e.g. "maven-plugin" or "test-jar".
-     * 
-     * @return The identifier of this type, never {@code null}.
-     * @see ArtifactProperties#TYPE
-     */
-    String getId();
-
-    /**
-     * Gets the file extension to use for artifacts of this type (unless explicitly overridden by the artifact).
-     * 
-     * @return The usual file extension, never {@code null}.
-     */
-    String getExtension();
-
-    /**
-     * Gets the classifier to use for artifacts of this type (unless explicitly overridden by the artifact).
-     * 
-     * @return The usual classifier or an empty string if none, never {@code null}.
-     */
-    String getClassifier();
-
-    /**
-     * Gets the properties to use for artifacts of this type (unless explicitly overridden by the artifact).
-     * 
-     * @return The (read-only) properties, never {@code null}.
-     * @see ArtifactProperties
-     */
-    Map<String, String> getProperties();
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactTypeRegistry.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactTypeRegistry.java
deleted file mode 100644 (file)
index 2addff1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.artifact;
-
-/**
- * A registry of known artifact types.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getArtifactTypeRegistry()
- */
-public interface ArtifactTypeRegistry
-{
-
-    /**
-     * Gets the artifact type with the specified identifier.
-     * 
-     * @param typeId The identifier of the type, must not be {@code null}.
-     * @return The artifact type or {@code null} if no type with the requested identifier exists.
-     */
-    ArtifactType get( String typeId );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifact.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifact.java
deleted file mode 100644 (file)
index 9971034..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.artifact;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * A simple artifact. <em>Note:</em> Instances of this class are immutable and the exposed mutators return new objects
- * rather than changing the current instance.
- */
-public final class DefaultArtifact
-    extends AbstractArtifact
-{
-
-    private final String groupId;
-
-    private final String artifactId;
-
-    private final String version;
-
-    private final String classifier;
-
-    private final String extension;
-
-    private final File file;
-
-    private final Map<String, String> properties;
-
-    /**
-     * Creates a new artifact with the specified coordinates. If not specified in the artifact coordinates, the
-     * artifact's extension defaults to {@code jar} and classifier to an empty string.
-     * 
-     * @param coords The artifact coordinates in the format
-     *            {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null}.
-     */
-    public DefaultArtifact( String coords )
-    {
-        this( coords, Collections.<String, String> emptyMap() );
-    }
-
-    /**
-     * Creates a new artifact with the specified coordinates and properties. If not specified in the artifact
-     * coordinates, the artifact's extension defaults to {@code jar} and classifier to an empty string.
-     * 
-     * @param coords The artifact coordinates in the format
-     *            {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null}.
-     * @param properties The artifact properties, may be {@code null}.
-     */
-    public DefaultArtifact( String coords, Map<String, String> properties )
-    {
-        Pattern p = Pattern.compile( "([^: ]+):([^: ]+)(:([^: ]*)(:([^: ]+))?)?:([^: ]+)" );
-        Matcher m = p.matcher( coords );
-        if ( !m.matches() )
-        {
-            throw new IllegalArgumentException( "Bad artifact coordinates " + coords
-                + ", expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>" );
-        }
-        groupId = m.group( 1 );
-        artifactId = m.group( 2 );
-        extension = get( m.group( 4 ), "jar" );
-        classifier = get( m.group( 6 ), "" );
-        version = m.group( 7 );
-        file = null;
-        this.properties = copyProperties( properties );
-    }
-
-    private static String get( String value, String defaultValue )
-    {
-        return ( value == null || value.length() <= 0 ) ? defaultValue : value;
-    }
-
-    /**
-     * Creates a new artifact with the specified coordinates and no classifier. Passing {@code null} for any of the
-     * coordinates is equivalent to specifying an empty string.
-     * 
-     * @param groupId The group identifier of the artifact, may be {@code null}.
-     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
-     * @param extension The file extension of the artifact, may be {@code null}.
-     * @param version The version of the artifact, may be {@code null}.
-     */
-    public DefaultArtifact( String groupId, String artifactId, String extension, String version )
-    {
-        this( groupId, artifactId, "", extension, version );
-    }
-
-    /**
-     * Creates a new artifact with the specified coordinates. Passing {@code null} for any of the coordinates is
-     * equivalent to specifying an empty string.
-     * 
-     * @param groupId The group identifier of the artifact, may be {@code null}.
-     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
-     * @param classifier The classifier of the artifact, may be {@code null}.
-     * @param extension The file extension of the artifact, may be {@code null}.
-     * @param version The version of the artifact, may be {@code null}.
-     */
-    public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version )
-    {
-        this( groupId, artifactId, classifier, extension, version, null, (File) null );
-    }
-
-    /**
-     * Creates a new artifact with the specified coordinates. Passing {@code null} for any of the coordinates is
-     * equivalent to specifying an empty string. The optional artifact type provided to this constructor will be used to
-     * determine the artifact's classifier and file extension if the corresponding arguments for this constructor are
-     * {@code null}.
-     * 
-     * @param groupId The group identifier of the artifact, may be {@code null}.
-     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
-     * @param classifier The classifier of the artifact, may be {@code null}.
-     * @param extension The file extension of the artifact, may be {@code null}.
-     * @param version The version of the artifact, may be {@code null}.
-     * @param type The artifact type from which to query classifier, file extension and properties, may be {@code null}.
-     */
-    public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
-                            ArtifactType type )
-    {
-        this( groupId, artifactId, classifier, extension, version, null, type );
-    }
-
-    /**
-     * Creates a new artifact with the specified coordinates and properties. Passing {@code null} for any of the
-     * coordinates is equivalent to specifying an empty string. The optional artifact type provided to this constructor
-     * will be used to determine the artifact's classifier and file extension if the corresponding arguments for this
-     * constructor are {@code null}. If the artifact type specifies properties, those will get merged with the
-     * properties passed directly into the constructor, with the latter properties taking precedence.
-     * 
-     * @param groupId The group identifier of the artifact, may be {@code null}.
-     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
-     * @param classifier The classifier of the artifact, may be {@code null}.
-     * @param extension The file extension of the artifact, may be {@code null}.
-     * @param version The version of the artifact, may be {@code null}.
-     * @param properties The properties of the artifact, may be {@code null} if none.
-     * @param type The artifact type from which to query classifier, file extension and properties, may be {@code null}.
-     */
-    public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
-                            Map<String, String> properties, ArtifactType type )
-    {
-        this.groupId = emptify( groupId );
-        this.artifactId = emptify( artifactId );
-        if ( classifier != null || type == null )
-        {
-            this.classifier = emptify( classifier );
-        }
-        else
-        {
-            this.classifier = emptify( type.getClassifier() );
-        }
-        if ( extension != null || type == null )
-        {
-            this.extension = emptify( extension );
-        }
-        else
-        {
-            this.extension = emptify( type.getExtension() );
-        }
-        this.version = emptify( version );
-        this.file = null;
-        this.properties = merge( properties, ( type != null ) ? type.getProperties() : null );
-    }
-
-    private static Map<String, String> merge( Map<String, String> dominant, Map<String, String> recessive )
-    {
-        Map<String, String> properties;
-
-        if ( ( dominant == null || dominant.isEmpty() ) && ( recessive == null || recessive.isEmpty() ) )
-        {
-            properties = Collections.emptyMap();
-        }
-        else
-        {
-            properties = new HashMap<String, String>();
-            if ( recessive != null )
-            {
-                properties.putAll( recessive );
-            }
-            if ( dominant != null )
-            {
-                properties.putAll( dominant );
-            }
-            properties = Collections.unmodifiableMap( properties );
-        }
-
-        return properties;
-    }
-
-    /**
-     * Creates a new artifact with the specified coordinates, properties and file. Passing {@code null} for any of the
-     * coordinates is equivalent to specifying an empty string.
-     * 
-     * @param groupId The group identifier of the artifact, may be {@code null}.
-     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
-     * @param classifier The classifier of the artifact, may be {@code null}.
-     * @param extension The file extension of the artifact, may be {@code null}.
-     * @param version The version of the artifact, may be {@code null}.
-     * @param properties The properties of the artifact, may be {@code null} if none.
-     * @param file The resolved file of the artifact, may be {@code null}.
-     */
-    public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
-                            Map<String, String> properties, File file )
-    {
-        this.groupId = emptify( groupId );
-        this.artifactId = emptify( artifactId );
-        this.classifier = emptify( classifier );
-        this.extension = emptify( extension );
-        this.version = emptify( version );
-        this.file = file;
-        this.properties = copyProperties( properties );
-    }
-
-    DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version, File file,
-                     Map<String, String> properties )
-    {
-        // NOTE: This constructor assumes immutability of the provided properties, for internal use only
-        this.groupId = emptify( groupId );
-        this.artifactId = emptify( artifactId );
-        this.classifier = emptify( classifier );
-        this.extension = emptify( extension );
-        this.version = emptify( version );
-        this.file = file;
-        this.properties = properties;
-    }
-
-    private static String emptify( String str )
-    {
-        return ( str == null ) ? "" : str;
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public String getVersion()
-    {
-        return version;
-    }
-
-    public String getClassifier()
-    {
-        return classifier;
-    }
-
-    public String getExtension()
-    {
-        return extension;
-    }
-
-    public File getFile()
-    {
-        return file;
-    }
-
-    public Map<String, String> getProperties()
-    {
-        return properties;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifactType.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifactType.java
deleted file mode 100644 (file)
index b30cd12..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.artifact;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A simple artifact type.
- */
-public final class DefaultArtifactType
-    implements ArtifactType
-{
-
-    private final String id;
-
-    private final String extension;
-
-    private final String classifier;
-
-    private final Map<String, String> properties;
-
-    /**
-     * Creates a new artifact type with the specified identifier. This constructor assumes the usual file extension
-     * equals the given type id and that the usual classifier is empty. Additionally, the properties
-     * {@link ArtifactProperties#LANGUAGE}, {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} and
-     * {@link ArtifactProperties#INCLUDES_DEPENDENCIES} will be set to {@code "none"}, {@code true} and {@code false},
-     * respectively.
-     * 
-     * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
-     *            property, must not be {@code null} or empty.
-     */
-    public DefaultArtifactType( String id )
-    {
-        this( id, id, "", "none", false, false );
-    }
-
-    /**
-     * Creates a new artifact type with the specified properties. Additionally, the properties
-     * {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} and {@link ArtifactProperties#INCLUDES_DEPENDENCIES} will be
-     * set to {@code true} and {@code false}, respectively.
-     * 
-     * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
-     *            property, must not be {@code null} or empty.
-     * @param extension The usual file extension for artifacts of this type, may be {@code null}.
-     * @param classifier The usual classifier for artifacts of this type, may be {@code null}.
-     * @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}.
-     */
-    public DefaultArtifactType( String id, String extension, String classifier, String language )
-    {
-        this( id, extension, classifier, language, true, false );
-    }
-
-    /**
-     * Creates a new artifact type with the specified properties.
-     * 
-     * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
-     *            property, must not be {@code null} or empty.
-     * @param extension The usual file extension for artifacts of this type, may be {@code null}.
-     * @param classifier The usual classifier for artifacts of this type, may be {@code null}.
-     * @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}.
-     * @param constitutesBuildPath The value for the {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} property.
-     * @param includesDependencies The value for the {@link ArtifactProperties#INCLUDES_DEPENDENCIES} property.
-     */
-    public DefaultArtifactType( String id, String extension, String classifier, String language,
-                                boolean constitutesBuildPath, boolean includesDependencies )
-    {
-        if ( id == null || id.length() < 0 )
-        {
-            throw new IllegalArgumentException( "no type id specified" );
-        }
-        this.id = id;
-        this.extension = emptify( extension );
-        this.classifier = emptify( classifier );
-        Map<String, String> props = new HashMap<String, String>();
-        props.put( ArtifactProperties.TYPE, id );
-        props.put( ArtifactProperties.LANGUAGE, ( language != null && language.length() > 0 ) ? language : "none" );
-        props.put( ArtifactProperties.INCLUDES_DEPENDENCIES, Boolean.toString( includesDependencies ) );
-        props.put( ArtifactProperties.CONSTITUTES_BUILD_PATH, Boolean.toString( constitutesBuildPath ) );
-        properties = Collections.unmodifiableMap( props );
-    }
-
-    /**
-     * Creates a new artifact type with the specified properties.
-     * 
-     * @param id The identifier of the type, must not be {@code null} or empty.
-     * @param extension The usual file extension for artifacts of this type, may be {@code null}.
-     * @param classifier The usual classifier for artifacts of this type, may be {@code null}.
-     * @param properties The properties for artifacts of this type, may be {@code null}.
-     */
-    public DefaultArtifactType( String id, String extension, String classifier, Map<String, String> properties )
-    {
-        if ( id == null || id.length() < 0 )
-        {
-            throw new IllegalArgumentException( "no type id specified" );
-        }
-        this.id = id;
-        this.extension = emptify( extension );
-        this.classifier = emptify( classifier );
-        this.properties = AbstractArtifact.copyProperties( properties );
-    }
-
-    private static String emptify( String str )
-    {
-        return ( str == null ) ? "" : str;
-    }
-
-    public String getId()
-    {
-        return id;
-    }
-
-    public String getExtension()
-    {
-        return extension;
-    }
-
-    public String getClassifier()
-    {
-        return classifier;
-    }
-
-    public Map<String, String> getProperties()
-    {
-        return properties;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/artifact/package-info.java
deleted file mode 100644 (file)
index 6d676d1..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The definition of an artifact, that is the primary entity managed by the repository system.
- */
-package org.eclipse.aether.artifact;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectRequest.java
deleted file mode 100644 (file)
index 8568385..0000000
+++ /dev/null
@@ -1,347 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * A request to collect the transitive dependencies and to build a dependency graph from them. There are three ways to
- * create a dependency graph. First, only the root dependency can be given. Second, a root dependency and direct
- * dependencies can be specified in which case the specified direct dependencies are merged with the direct dependencies
- * retrieved from the artifact descriptor of the root dependency. And last, only direct dependencies can be specified in
- * which case the root node of the resulting graph has no associated dependency.
- * 
- * @see RepositorySystem#collectDependencies(RepositorySystemSession, CollectRequest)
- */
-public final class CollectRequest
-{
-
-    private Artifact rootArtifact;
-
-    private Dependency root;
-
-    private List<Dependency> dependencies = Collections.emptyList();
-
-    private List<Dependency> managedDependencies = Collections.emptyList();
-
-    private List<RemoteRepository> repositories = Collections.emptyList();
-
-    private String context = "";
-
-    private RequestTrace trace;
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public CollectRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a request with the specified properties.
-     * 
-     * @param root The root dependency whose transitive dependencies should be collected, may be {@code null}.
-     * @param repositories The repositories to use for the collection, may be {@code null}.
-     */
-    public CollectRequest( Dependency root, List<RemoteRepository> repositories )
-    {
-        setRoot( root );
-        setRepositories( repositories );
-    }
-
-    /**
-     * Creates a new request with the specified properties.
-     * 
-     * @param root The root dependency whose transitive dependencies should be collected, may be {@code null}.
-     * @param dependencies The direct dependencies to merge with the direct dependencies from the root dependency's
-     *            artifact descriptor.
-     * @param repositories The repositories to use for the collection, may be {@code null}.
-     */
-    public CollectRequest( Dependency root, List<Dependency> dependencies, List<RemoteRepository> repositories )
-    {
-        setRoot( root );
-        setDependencies( dependencies );
-        setRepositories( repositories );
-    }
-
-    /**
-     * Creates a new request with the specified properties.
-     * 
-     * @param dependencies The direct dependencies of some imaginary root, may be {@code null}.
-     * @param managedDependencies The dependency management information to apply to the transitive dependencies, may be
-     *            {@code null}.
-     * @param repositories The repositories to use for the collection, may be {@code null}.
-     */
-    public CollectRequest( List<Dependency> dependencies, List<Dependency> managedDependencies,
-                           List<RemoteRepository> repositories )
-    {
-        setDependencies( dependencies );
-        setManagedDependencies( managedDependencies );
-        setRepositories( repositories );
-    }
-
-    /**
-     * Gets the root artifact for the dependency graph.
-     * 
-     * @return The root artifact for the dependency graph or {@code null} if none.
-     */
-    public Artifact getRootArtifact()
-    {
-        return rootArtifact;
-    }
-
-    /**
-     * Sets the root artifact for the dependency graph. This must not be confused with {@link #setRoot(Dependency)}: The
-     * root <em>dependency</em>, like any other specified dependency, will be subject to dependency
-     * collection/resolution, i.e. should have an artifact descriptor and a corresponding artifact file. The root
-     * <em>artifact</em> on the other hand is only used as a label for the root node of the graph in case no root
-     * dependency was specified. As such, the configured root artifact is ignored if {@link #getRoot()} does not return
-     * {@code null}.
-     * 
-     * @param rootArtifact The root artifact for the dependency graph, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest setRootArtifact( Artifact rootArtifact )
-    {
-        this.rootArtifact = rootArtifact;
-        return this;
-    }
-
-    /**
-     * Gets the root dependency of the graph.
-     * 
-     * @return The root dependency of the graph or {@code null} if none.
-     */
-    public Dependency getRoot()
-    {
-        return root;
-    }
-
-    /**
-     * Sets the root dependency of the graph.
-     * 
-     * @param root The root dependency of the graph, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest setRoot( Dependency root )
-    {
-        this.root = root;
-        return this;
-    }
-
-    /**
-     * Gets the direct dependencies.
-     * 
-     * @return The direct dependencies, never {@code null}.
-     */
-    public List<Dependency> getDependencies()
-    {
-        return dependencies;
-    }
-
-    /**
-     * Sets the direct dependencies. If both a root dependency and direct dependencies are given in the request, the
-     * direct dependencies from the request will be merged with the direct dependencies from the root dependency's
-     * artifact descriptor, giving higher priority to the dependencies from the request.
-     * 
-     * @param dependencies The direct dependencies, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest setDependencies( List<Dependency> dependencies )
-    {
-        if ( dependencies == null )
-        {
-            this.dependencies = Collections.emptyList();
-        }
-        else
-        {
-            this.dependencies = dependencies;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified direct dependency.
-     * 
-     * @param dependency The dependency to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest addDependency( Dependency dependency )
-    {
-        if ( dependency != null )
-        {
-            if ( this.dependencies.isEmpty() )
-            {
-                this.dependencies = new ArrayList<Dependency>();
-            }
-            this.dependencies.add( dependency );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the dependency management to apply to transitive dependencies.
-     * 
-     * @return The dependency management to apply to transitive dependencies, never {@code null}.
-     */
-    public List<Dependency> getManagedDependencies()
-    {
-        return managedDependencies;
-    }
-
-    /**
-     * Sets the dependency management to apply to transitive dependencies. To clarify, this management does not apply to
-     * the direct dependencies of the root node.
-     * 
-     * @param managedDependencies The dependency management, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest setManagedDependencies( List<Dependency> managedDependencies )
-    {
-        if ( managedDependencies == null )
-        {
-            this.managedDependencies = Collections.emptyList();
-        }
-        else
-        {
-            this.managedDependencies = managedDependencies;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified managed dependency.
-     * 
-     * @param managedDependency The managed dependency to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest addManagedDependency( Dependency managedDependency )
-    {
-        if ( managedDependency != null )
-        {
-            if ( this.managedDependencies.isEmpty() )
-            {
-                this.managedDependencies = new ArrayList<Dependency>();
-            }
-            this.managedDependencies.add( managedDependency );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the repositories to use for the collection.
-     * 
-     * @return The repositories to use for the collection, never {@code null}.
-     */
-    public List<RemoteRepository> getRepositories()
-    {
-        return repositories;
-    }
-
-    /**
-     * Sets the repositories to use for the collection.
-     * 
-     * @param repositories The repositories to use for the collection, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest setRepositories( List<RemoteRepository> repositories )
-    {
-        if ( repositories == null )
-        {
-            this.repositories = Collections.emptyList();
-        }
-        else
-        {
-            this.repositories = repositories;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified repository for collection.
-     * 
-     * @param repository The repository to collect dependency information from, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest addRepository( RemoteRepository repository )
-    {
-        if ( repository != null )
-        {
-            if ( this.repositories.isEmpty() )
-            {
-                this.repositories = new ArrayList<RemoteRepository>();
-            }
-            this.repositories.add( repository );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the context in which this request is made.
-     * 
-     * @return The context, never {@code null}.
-     */
-    public String getRequestContext()
-    {
-        return context;
-    }
-
-    /**
-     * Sets the context in which this request is made.
-     * 
-     * @param context The context, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest setRequestContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-        return this;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    /**
-     * Sets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @param trace The trace information about the higher level operation, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public CollectRequest setTrace( RequestTrace trace )
-    {
-        this.trace = trace;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getRoot() + " -> " + getDependencies() + " < " + getRepositories();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectResult.java
deleted file mode 100644 (file)
index 4975190..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.graph.DependencyCycle;
-import org.eclipse.aether.graph.DependencyNode;
-
-/**
- * The result of a dependency collection request.
- * 
- * @see RepositorySystem#collectDependencies(RepositorySystemSession, CollectRequest)
- */
-public final class CollectResult
-{
-
-    private final CollectRequest request;
-
-    private List<Exception> exceptions;
-
-    private List<DependencyCycle> cycles;
-
-    private DependencyNode root;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The resolution request, must not be {@code null}.
-     */
-    public CollectResult( CollectRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "dependency collection request has not been specified" );
-        }
-        this.request = request;
-        exceptions = Collections.emptyList();
-        cycles = Collections.emptyList();
-    }
-
-    /**
-     * Gets the collection request that was made.
-     * 
-     * @return The collection request, never {@code null}.
-     */
-    public CollectRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the exceptions that occurred while building the dependency graph.
-     * 
-     * @return The exceptions that occurred, never {@code null}.
-     */
-    public List<Exception> getExceptions()
-    {
-        return exceptions;
-    }
-
-    /**
-     * Records the specified exception while building the dependency graph.
-     * 
-     * @param exception The exception to record, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public CollectResult addException( Exception exception )
-    {
-        if ( exception != null )
-        {
-            if ( exceptions.isEmpty() )
-            {
-                exceptions = new ArrayList<Exception>();
-            }
-            exceptions.add( exception );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the dependency cycles that were encountered while building the dependency graph.
-     * 
-     * @return The dependency cycles in the (raw) graph, never {@code null}.
-     */
-    public List<DependencyCycle> getCycles()
-    {
-        return cycles;
-    }
-
-    /**
-     * Records the specified dependency cycle.
-     * 
-     * @param cycle The dependency cycle to record, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public CollectResult addCycle( DependencyCycle cycle )
-    {
-        if ( cycle != null )
-        {
-            if ( cycles.isEmpty() )
-            {
-                cycles = new ArrayList<DependencyCycle>();
-            }
-            cycles.add( cycle );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the root node of the dependency graph.
-     * 
-     * @return The root node of the dependency graph or {@code null} if none.
-     */
-    public DependencyNode getRoot()
-    {
-        return root;
-    }
-
-    /**
-     * Sets the root node of the dependency graph.
-     * 
-     * @param root The root node of the dependency graph, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public CollectResult setRoot( DependencyNode root )
-    {
-        this.root = root;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return String.valueOf( getRoot() );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionContext.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionContext.java
deleted file mode 100644 (file)
index 3b8fbc2..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.graph.Dependency;
-
-/**
- * A context used during dependency collection to update the dependency manager, selector and traverser.
- * 
- * @see DependencyManager#deriveChildManager(DependencyCollectionContext)
- * @see DependencyTraverser#deriveChildTraverser(DependencyCollectionContext)
- * @see DependencySelector#deriveChildSelector(DependencyCollectionContext)
- * @see VersionFilter#deriveChildFilter(DependencyCollectionContext)
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface DependencyCollectionContext
-{
-
-    /**
-     * Gets the repository system session during which the dependency collection happens.
-     * 
-     * @return The repository system session, never {@code null}.
-     */
-    RepositorySystemSession getSession();
-
-    /**
-     * Gets the artifact whose children are to be processed next during dependency collection. For all nodes but the
-     * root, this is simply shorthand for {@code getDependency().getArtifact()}. In case of the root node however,
-     * {@link #getDependency()} might be {@code null} while the node still has an artifact which serves as its label and
-     * is not to be resolved.
-     * 
-     * @return The artifact whose children are going to be processed or {@code null} in case of the root node without
-     *         dependency and label.
-     */
-    Artifact getArtifact();
-
-    /**
-     * Gets the dependency whose children are to be processed next during dependency collection.
-     * 
-     * @return The dependency whose children are going to be processed or {@code null} in case of the root node without
-     *         dependency.
-     */
-    Dependency getDependency();
-
-    /**
-     * Gets the dependency management information that was contributed by the artifact descriptor of the current
-     * dependency.
-     * 
-     * @return The dependency management information, never {@code null}.
-     */
-    List<Dependency> getManagedDependencies();
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionException.java
deleted file mode 100644 (file)
index 0d26674..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case of bad artifact descriptors, version ranges or other issues encountered during calculation of the
- * dependency graph.
- */
-public class DependencyCollectionException
-    extends RepositoryException
-{
-
-    private final transient CollectResult result;
-
-    /**
-     * Creates a new exception with the specified result.
-     * 
-     * @param result The collection result at the point the exception occurred, may be {@code null}.
-     */
-    public DependencyCollectionException( CollectResult result )
-    {
-        super( "Failed to collect dependencies for " + getSource( result ), getCause( result ) );
-        this.result = result;
-    }
-
-    /**
-     * Creates a new exception with the specified result and detail message.
-     * 
-     * @param result The collection result at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public DependencyCollectionException( CollectResult result, String message )
-    {
-        super( message, getCause( result ) );
-        this.result = result;
-    }
-
-    /**
-     * Creates a new exception with the specified result, detail message and cause.
-     * 
-     * @param result The collection result at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public DependencyCollectionException( CollectResult result, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.result = result;
-    }
-
-    /**
-     * Gets the collection result at the point the exception occurred. Despite being incomplete, callers might want to
-     * use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
-     * 
-     * @return The collection result or {@code null} if unknown.
-     */
-    public CollectResult getResult()
-    {
-        return result;
-    }
-
-    private static String getSource( CollectResult result )
-    {
-        if ( result == null )
-        {
-            return "";
-        }
-
-        CollectRequest request = result.getRequest();
-        if ( request.getRoot() != null )
-        {
-            return request.getRoot().toString();
-        }
-        if ( request.getRootArtifact() != null )
-        {
-            return request.getRootArtifact().toString();
-        }
-
-        return request.getDependencies().toString();
-    }
-
-    private static Throwable getCause( CollectResult result )
-    {
-        Throwable cause = null;
-        if ( result != null && !result.getExceptions().isEmpty() )
-        {
-            cause = result.getExceptions().get( 0 );
-        }
-        return cause;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformationContext.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformationContext.java
deleted file mode 100644 (file)
index d3980da..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * A context used during dependency collection to exchange information within a chain of dependency graph transformers.
- * 
- * @see DependencyGraphTransformer
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface DependencyGraphTransformationContext
-{
-
-    /**
-     * Gets the repository system session during which the graph transformation happens.
-     * 
-     * @return The repository system session, never {@code null}.
-     */
-    RepositorySystemSession getSession();
-
-    /**
-     * Gets a keyed value from the context.
-     * 
-     * @param key The key used to query the value, must not be {@code null}.
-     * @return The queried value or {@code null} if none.
-     */
-    Object get( Object key );
-
-    /**
-     * Puts a keyed value into the context.
-     * 
-     * @param key The key used to store the value, must not be {@code null}.
-     * @param value The value to store, may be {@code null} to remove the mapping.
-     * @return The previous value associated with the key or {@code null} if none.
-     */
-    Object put( Object key, Object value );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformer.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformer.java
deleted file mode 100644 (file)
index b3deebe..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.graph.DependencyNode;
-
-/**
- * Transforms a given dependency graph.
- * <p>
- * <strong>Note:</strong> Implementations must be stateless.
- * <p>
- * <em>Warning:</em> Dependency graphs may generally contain cycles. As such a graph transformer that cannot assume for
- * sure that cycles have already been eliminated must gracefully handle cyclic graphs, e.g. guard against infinite
- * recursion.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getDependencyGraphTransformer()
- */
-public interface DependencyGraphTransformer
-{
-
-    /**
-     * Transforms the dependency graph denoted by the specified root node. The transformer may directly change the
-     * provided input graph or create a new graph, the former is recommended for performance reasons.
-     * 
-     * @param node The root node of the (possibly cyclic!) graph to transform, must not be {@code null}.
-     * @param context The graph transformation context, must not be {@code null}.
-     * @return The result graph of the transformation, never {@code null}.
-     * @throws RepositoryException If the transformation failed.
-     */
-    DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context )
-        throws RepositoryException;
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManagement.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManagement.java
deleted file mode 100644 (file)
index f0aac73..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.graph.Exclusion;
-
-/**
- * The management updates to apply to a dependency.
- * 
- * @see DependencyManager#manageDependency(Dependency)
- */
-public final class DependencyManagement
-{
-
-    private String version;
-
-    private String scope;
-
-    private Boolean optional;
-
-    private Collection<Exclusion> exclusions;
-
-    private Map<String, String> properties;
-
-    /**
-     * Creates an empty management update.
-     */
-    public DependencyManagement()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Gets the new version to apply to the dependency.
-     * 
-     * @return The new version or {@code null} if the version is not managed and the existing dependency version should
-     *         remain unchanged.
-     */
-    public String getVersion()
-    {
-        return version;
-    }
-
-    /**
-     * Sets the new version to apply to the dependency.
-     * 
-     * @param version The new version, may be {@code null} if the version is not managed.
-     * @return This management update for chaining, never {@code null}.
-     */
-    public DependencyManagement setVersion( String version )
-    {
-        this.version = version;
-        return this;
-    }
-
-    /**
-     * Gets the new scope to apply to the dependency.
-     * 
-     * @return The new scope or {@code null} if the scope is not managed and the existing dependency scope should remain
-     *         unchanged.
-     */
-    public String getScope()
-    {
-        return scope;
-    }
-
-    /**
-     * Sets the new scope to apply to the dependency.
-     * 
-     * @param scope The new scope, may be {@code null} if the scope is not managed.
-     * @return This management update for chaining, never {@code null}.
-     */
-    public DependencyManagement setScope( String scope )
-    {
-        this.scope = scope;
-        return this;
-    }
-
-    /**
-     * Gets the new optional flag to apply to the dependency.
-     * 
-     * @return The new optional flag or {@code null} if the flag is not managed and the existing optional flag of the
-     *         dependency should remain unchanged.
-     */
-    public Boolean getOptional()
-    {
-        return optional;
-    }
-
-    /**
-     * Sets the new optional flag to apply to the dependency.
-     * 
-     * @param optional The optional flag, may be {@code null} if the flag is not managed.
-     * @return This management update for chaining, never {@code null}.
-     */
-    public DependencyManagement setOptional( Boolean optional )
-    {
-        this.optional = optional;
-        return this;
-    }
-
-    /**
-     * Gets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
-     * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
-     * with information from dependency management or overridden by it.
-     * 
-     * @return The new exclusions or {@code null} if the exclusions are not managed and the existing dependency
-     *         exclusions should remain unchanged.
-     */
-    public Collection<Exclusion> getExclusions()
-    {
-        return exclusions;
-    }
-
-    /**
-     * Sets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
-     * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
-     * with information from dependency management or overridden by it.
-     * 
-     * @param exclusions The new exclusions, may be {@code null} if the exclusions are not managed.
-     * @return This management update for chaining, never {@code null}.
-     */
-    public DependencyManagement setExclusions( Collection<Exclusion> exclusions )
-    {
-        this.exclusions = exclusions;
-        return this;
-    }
-
-    /**
-     * Gets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
-     * i.e. the dependency manager controls whether any existing properties get merged with the information from
-     * dependency management or overridden by it.
-     * 
-     * @return The new artifact properties or {@code null} if the properties are not managed and the existing properties
-     *         should remain unchanged.
-     */
-    public Map<String, String> getProperties()
-    {
-        return properties;
-    }
-
-    /**
-     * Sets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
-     * i.e. the dependency manager controls whether any existing properties get merged with the information from
-     * dependency management or overridden by it.
-     * 
-     * @param properties The new artifact properties, may be {@code null} if the properties are not managed.
-     * @return This management update for chaining, never {@code null}.
-     */
-    public DependencyManagement setProperties( Map<String, String> properties )
-    {
-        this.properties = properties;
-        return this;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManager.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManager.java
deleted file mode 100644 (file)
index e214f66..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import org.eclipse.aether.graph.Dependency;
-
-/**
- * Applies dependency management to the dependencies of a dependency node.
- * <p>
- * <strong>Note:</strong> Implementations must be stateless.
- * <p>
- * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
- * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getDependencyManager()
- * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
- *      CollectRequest)
- */
-public interface DependencyManager
-{
-
-    /**
-     * Applies dependency management to the specified dependency.
-     * 
-     * @param dependency The dependency to manage, must not be {@code null}.
-     * @return The management update to apply to the dependency or {@code null} if the dependency is not managed at all.
-     */
-    DependencyManagement manageDependency( Dependency dependency );
-
-    /**
-     * Derives a dependency manager for the specified collection context. When calculating the child manager,
-     * implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
-     * 
-     * @param context The dependency collection context, must not be {@code null}.
-     * @return The dependency manager for the dependencies of the target node or {@code null} if dependency management
-     *         should no longer be applied.
-     */
-    DependencyManager deriveChildManager( DependencyCollectionContext context );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencySelector.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencySelector.java
deleted file mode 100644 (file)
index de503be..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import org.eclipse.aether.graph.Dependency;
-
-/**
- * Decides what dependencies to include in the dependency graph.
- * <p>
- * <strong>Note:</strong> Implementations must be stateless.
- * <p>
- * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
- * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getDependencySelector()
- * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
- *      CollectRequest)
- */
-public interface DependencySelector
-{
-
-    /**
-     * Decides whether the specified dependency should be included in the dependency graph.
-     * 
-     * @param dependency The dependency to check, must not be {@code null}.
-     * @return {@code false} if the dependency should be excluded from the children of the current node, {@code true}
-     *         otherwise.
-     */
-    boolean selectDependency( Dependency dependency );
-
-    /**
-     * Derives a dependency selector for the specified collection context. When calculating the child selector,
-     * implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
-     * 
-     * @param context The dependency collection context, must not be {@code null}.
-     * @return The dependency selector for the target node or {@code null} if dependencies should be unconditionally
-     *         included in the sub graph.
-     */
-    DependencySelector deriveChildSelector( DependencyCollectionContext context );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyTraverser.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyTraverser.java
deleted file mode 100644 (file)
index 8140395..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import org.eclipse.aether.graph.Dependency;
-
-/**
- * Decides whether the dependencies of a dependency node should be traversed as well.
- * <p>
- * <strong>Note:</strong> Implementations must be stateless.
- * <p>
- * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
- * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getDependencyTraverser()
- * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
- *      CollectRequest)
- */
-public interface DependencyTraverser
-{
-
-    /**
-     * Decides whether the dependencies of the specified dependency should be traversed.
-     * 
-     * @param dependency The dependency to check, must not be {@code null}.
-     * @return {@code true} if the dependency graph builder should recurse into the specified dependency and process its
-     *         dependencies, {@code false} otherwise.
-     */
-    boolean traverseDependency( Dependency dependency );
-
-    /**
-     * Derives a dependency traverser that will be used to decide whether the transitive dependencies of the dependency
-     * given in the collection context shall be traversed. When calculating the child traverser, implementors are
-     * strongly advised to simply return the current instance if nothing changed to help save memory.
-     * 
-     * @param context The dependency collection context, must not be {@code null}.
-     * @return The dependency traverser for the target node or {@code null} if dependencies should be unconditionally
-     *         traversed in the sub graph.
-     */
-    DependencyTraverser deriveChildTraverser( DependencyCollectionContext context );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/UnsolvableVersionConflictException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/UnsolvableVersionConflictException.java
deleted file mode 100644 (file)
index 8db5590..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.version.VersionConstraint;
-
-/**
- * Thrown in case of an unsolvable conflict between different version constraints for a dependency.
- */
-public class UnsolvableVersionConflictException
-    extends RepositoryException
-{
-
-    private final transient Collection<String> versions;
-
-    private final transient Collection<? extends List<? extends DependencyNode>> paths;
-
-    /**
-     * Creates a new exception with the specified paths to conflicting nodes in the dependency graph.
-     * 
-     * @param paths The paths to the dependency nodes that participate in the version conflict, may be {@code null}.
-     */
-    public UnsolvableVersionConflictException( Collection<? extends List<? extends DependencyNode>> paths )
-    {
-        super( "Could not resolve version conflict among " + toPaths( paths ) );
-        if ( paths == null )
-        {
-            this.paths = Collections.emptyList();
-            this.versions = Collections.emptyList();
-        }
-        else
-        {
-            this.paths = paths;
-            this.versions = new LinkedHashSet<String>();
-            for ( List<? extends DependencyNode> path : paths )
-            {
-                VersionConstraint constraint = path.get( path.size() - 1 ).getVersionConstraint();
-                if ( constraint != null && constraint.getRange() != null )
-                {
-                    versions.add( constraint.toString() );
-                }
-            }
-        }
-    }
-
-    private static String toPaths( Collection<? extends List<? extends DependencyNode>> paths )
-    {
-        String result = "";
-
-        if ( paths != null )
-        {
-            Collection<String> strings = new LinkedHashSet<String>();
-
-            for ( List<? extends DependencyNode> path : paths )
-            {
-                strings.add( toPath( path ) );
-            }
-
-            result = strings.toString();
-        }
-
-        return result;
-    }
-
-    private static String toPath( List<? extends DependencyNode> path )
-    {
-        StringBuilder buffer = new StringBuilder( 256 );
-
-        for ( Iterator<? extends DependencyNode> it = path.iterator(); it.hasNext(); )
-        {
-            DependencyNode node = it.next();
-            if ( node.getDependency() == null )
-            {
-                continue;
-            }
-
-            Artifact artifact = node.getDependency().getArtifact();
-            buffer.append( artifact.getGroupId() );
-            buffer.append( ':' ).append( artifact.getArtifactId() );
-            buffer.append( ':' ).append( artifact.getExtension() );
-            if ( artifact.getClassifier().length() > 0 )
-            {
-                buffer.append( ':' ).append( artifact.getClassifier() );
-            }
-            buffer.append( ':' ).append( node.getVersionConstraint() );
-
-            if ( it.hasNext() )
-            {
-                buffer.append( " -> " );
-            }
-        }
-
-        return buffer.toString();
-    }
-
-    /**
-     * Gets the paths leading to the conflicting dependencies.
-     * 
-     * @return The (read-only) paths leading to the conflicting dependencies, never {@code null}.
-     */
-    public Collection<? extends List<? extends DependencyNode>> getPaths()
-    {
-        return paths;
-    }
-
-    /**
-     * Gets the conflicting version constraints of the dependency.
-     * 
-     * @return The (read-only) conflicting version constraints, never {@code null}.
-     */
-    public Collection<String> getVersions()
-    {
-        return versions;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/VersionFilter.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/VersionFilter.java
deleted file mode 100644 (file)
index 02e7ab3..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.collection;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.repository.ArtifactRepository;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionConstraint;
-
-/**
- * Decides which versions matching a version range should actually be considered for the dependency graph. The version
- * filter is not invoked for dependencies that do not declare a version range but a single version.
- * <p>
- * <strong>Note:</strong> Implementations must be stateless.
- * <p>
- * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
- * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getVersionFilter()
- * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
- *      CollectRequest)
- */
-public interface VersionFilter
-{
-
-    /**
-     * A context used during version filtering to hold relevant data.
-     * 
-     * @noimplement This interface is not intended to be implemented by clients.
-     * @noextend This interface is not intended to be extended by clients.
-     */
-    interface VersionFilterContext
-        extends Iterable<Version>
-    {
-
-        /**
-         * Gets the repository system session during which the version filtering happens.
-         * 
-         * @return The repository system session, never {@code null}.
-         */
-        RepositorySystemSession getSession();
-
-        /**
-         * Gets the dependency whose version range is being filtered.
-         * 
-         * @return The dependency, never {@code null}.
-         */
-        Dependency getDependency();
-
-        /**
-         * Gets the total number of available versions. This count reflects any removals made during version filtering.
-         * 
-         * @return The total number of available versions.
-         */
-        int getCount();
-
-        /**
-         * Gets an iterator over the available versions of the dependency. The iterator returns versions in ascending
-         * order. Use {@link Iterator#remove()} to exclude a version from further consideration in the dependency graph.
-         * 
-         * @return The iterator of available versions, never {@code null}.
-         */
-        Iterator<Version> iterator();
-
-        /**
-         * Gets the version constraint that was parsed from the dependency's version string.
-         * 
-         * @return The parsed version constraint, never {@code null}.
-         */
-        VersionConstraint getVersionConstraint();
-
-        /**
-         * Gets the repository from which the specified version was resolved.
-         * 
-         * @param version The version whose source repository should be retrieved, must not be {@code null}.
-         * @return The repository from which the version was resolved or {@code null} if unknown.
-         */
-        ArtifactRepository getRepository( Version version );
-
-        /**
-         * Gets the remote repositories from which the versions were resolved.
-         * 
-         * @return The (read-only) list of repositories, never {@code null}.
-         */
-        List<RemoteRepository> getRepositories();
-
-    }
-
-    /**
-     * Filters the available versions for a given dependency. Implementations will usually call
-     * {@link VersionFilterContext#iterator() context.iterator()} to inspect the available versions and use
-     * {@link java.util.Iterator#remove()} to delete unacceptable versions. If no versions remain after all filtering
-     * has been performed, the dependency collection process will automatically fail, i.e. implementations need not
-     * handle this situation on their own.
-     * 
-     * @param context The version filter context, must not be {@code null}.
-     * @throws RepositoryException If the filtering could not be performed.
-     */
-    void filterVersions( VersionFilterContext context )
-        throws RepositoryException;
-
-    /**
-     * Derives a version filter for the specified collection context. The derived filter will be used to handle version
-     * ranges encountered in child dependencies of the current node. When calculating the child filter, implementors are
-     * strongly advised to simply return the current instance if nothing changed to help save memory.
-     * 
-     * @param context The dependency collection context, must not be {@code null}.
-     * @return The version filter for the target node or {@code null} if versions should not be filtered any more.
-     */
-    VersionFilter deriveChildFilter( DependencyCollectionContext context );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/collection/package-info.java
deleted file mode 100644 (file)
index dd7df2e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The types and extension points for collecting the transitive dependencies of an artifact and building a dependency
- * graph.
- */
-package org.eclipse.aether.collection;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployRequest.java
deleted file mode 100644 (file)
index a5372dd..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.deployment;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * A request to deploy artifacts and their accompanying metadata into the a remote repository.
- * 
- * @see RepositorySystem#deploy(RepositorySystemSession, DeployRequest)
- */
-public final class DeployRequest
-{
-
-    private Collection<Artifact> artifacts = Collections.emptyList();
-
-    private Collection<Metadata> metadata = Collections.emptyList();
-
-    private RemoteRepository repository;
-
-    private RequestTrace trace;
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public DeployRequest()
-    {
-    }
-
-    /**
-     * Gets the artifact to deploy.
-     * 
-     * @return The artifacts to deploy, never {@code null}.
-     */
-    public Collection<Artifact> getArtifacts()
-    {
-        return artifacts;
-    }
-
-    /**
-     * Sets the artifacts to deploy.
-     * 
-     * @param artifacts The artifacts to deploy, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DeployRequest setArtifacts( Collection<Artifact> artifacts )
-    {
-        if ( artifacts == null )
-        {
-            this.artifacts = Collections.emptyList();
-        }
-        else
-        {
-            this.artifacts = artifacts;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified artifacts for deployment.
-     * 
-     * @param artifact The artifact to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DeployRequest addArtifact( Artifact artifact )
-    {
-        if ( artifact != null )
-        {
-            if ( artifacts.isEmpty() )
-            {
-                artifacts = new ArrayList<Artifact>();
-            }
-            artifacts.add( artifact );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the metadata to deploy.
-     * 
-     * @return The metadata to deploy, never {@code null}.
-     */
-    public Collection<Metadata> getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Sets the metadata to deploy.
-     * 
-     * @param metadata The metadata to deploy, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DeployRequest setMetadata( Collection<Metadata> metadata )
-    {
-        if ( metadata == null )
-        {
-            this.metadata = Collections.emptyList();
-        }
-        else
-        {
-            this.metadata = metadata;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified metadata for deployment.
-     * 
-     * @param metadata The metadata to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DeployRequest addMetadata( Metadata metadata )
-    {
-        if ( metadata != null )
-        {
-            if ( this.metadata.isEmpty() )
-            {
-                this.metadata = new ArrayList<Metadata>();
-            }
-            this.metadata.add( metadata );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the repository to deploy to.
-     * 
-     * @return The repository to deploy to or {@code null} if not set.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the repository to deploy to.
-     * 
-     * @param repository The repository to deploy to, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DeployRequest setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    /**
-     * Sets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @param trace The trace information about the higher level operation, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DeployRequest setTrace( RequestTrace trace )
-    {
-        this.trace = trace;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifacts() + ", " + getMetadata() + " > " + getRepository();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployResult.java
deleted file mode 100644 (file)
index fcda3ca..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.deployment;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * The result of deploying artifacts and their accompanying metadata into the a remote repository.
- * 
- * @see RepositorySystem#deploy(RepositorySystemSession, DeployRequest)
- */
-public final class DeployResult
-{
-
-    private final DeployRequest request;
-
-    private Collection<Artifact> artifacts;
-
-    private Collection<Metadata> metadata;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The deployment request, must not be {@code null}.
-     */
-    public DeployResult( DeployRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "deploy request has not been specified" );
-        }
-        this.request = request;
-        artifacts = Collections.emptyList();
-        metadata = Collections.emptyList();
-    }
-
-    /**
-     * Gets the deploy request that was made.
-     * 
-     * @return The deploy request, never {@code null}.
-     */
-    public DeployRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the artifacts that got deployed.
-     * 
-     * @return The deployed artifacts, never {@code null}.
-     */
-    public Collection<Artifact> getArtifacts()
-    {
-        return artifacts;
-    }
-
-    /**
-     * Sets the artifacts that got deployed.
-     * 
-     * @param artifacts The deployed artifacts, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public DeployResult setArtifacts( Collection<Artifact> artifacts )
-    {
-        if ( artifacts == null )
-        {
-            this.artifacts = Collections.emptyList();
-        }
-        else
-        {
-            this.artifacts = artifacts;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified artifacts to the result.
-     * 
-     * @param artifact The deployed artifact to add, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public DeployResult addArtifact( Artifact artifact )
-    {
-        if ( artifact != null )
-        {
-            if ( artifacts.isEmpty() )
-            {
-                artifacts = new ArrayList<Artifact>();
-            }
-            artifacts.add( artifact );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the metadata that got deployed. Note that due to automatically generated metadata, there might have been
-     * more metadata deployed than originally specified in the deploy request.
-     * 
-     * @return The deployed metadata, never {@code null}.
-     */
-    public Collection<Metadata> getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Sets the metadata that got deployed.
-     * 
-     * @param metadata The deployed metadata, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public DeployResult setMetadata( Collection<Metadata> metadata )
-    {
-        if ( metadata == null )
-        {
-            this.metadata = Collections.emptyList();
-        }
-        else
-        {
-            this.metadata = metadata;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified metadata to this result.
-     * 
-     * @param metadata The deployed metadata to add, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public DeployResult addMetadata( Metadata metadata )
-    {
-        if ( metadata != null )
-        {
-            if ( this.metadata.isEmpty() )
-            {
-                this.metadata = new ArrayList<Metadata>();
-            }
-            this.metadata.add( metadata );
-        }
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifacts() + ", " + getMetadata();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeploymentException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeploymentException.java
deleted file mode 100644 (file)
index f631530..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.deployment;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case of a deployment error like authentication failure.
- */
-public class DeploymentException
-    extends RepositoryException
-{
-
-    /**
-     * Creates a new exception with the specified detail message.
-     * 
-     * @param message The detail message, may be {@code null}.
-     */
-    public DeploymentException( String message )
-    {
-        super( message );
-    }
-
-    /**
-     * Creates a new exception with the specified detail message and cause.
-     * 
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public DeploymentException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/deployment/package-info.java
deleted file mode 100644 (file)
index dd5a35d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The types supporting the publishing of artifacts to a remote repository.
- */
-package org.eclipse.aether.deployment;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DefaultDependencyNode.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DefaultDependencyNode.java
deleted file mode 100644 (file)
index c702d23..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.graph;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionConstraint;
-
-/**
- * A node within a dependency graph.
- */
-public final class DefaultDependencyNode
-    implements DependencyNode
-{
-
-    private List<DependencyNode> children;
-
-    private Dependency dependency;
-
-    private Artifact artifact;
-
-    private List<? extends Artifact> relocations;
-
-    private Collection<? extends Artifact> aliases;
-
-    private VersionConstraint versionConstraint;
-
-    private Version version;
-
-    private byte managedBits;
-
-    private List<RemoteRepository> repositories;
-
-    private String context;
-
-    private Map<Object, Object> data;
-
-    /**
-     * Creates a new node with the specified dependency.
-     * 
-     * @param dependency The dependency associated with this node, may be {@code null} for a root node.
-     */
-    public DefaultDependencyNode( Dependency dependency )
-    {
-        this.dependency = dependency;
-        artifact = ( dependency != null ) ? dependency.getArtifact() : null;
-        children = new ArrayList<DependencyNode>( 0 );
-        aliases = relocations = Collections.emptyList();
-        repositories = Collections.emptyList();
-        context = "";
-        data = Collections.emptyMap();
-    }
-
-    /**
-     * Creates a new root node with the specified artifact as its label. Note that the new node has no dependency, i.e.
-     * {@link #getDependency()} will return {@code null}. Put differently, the specified artifact will not be subject to
-     * dependency collection/resolution.
-     * 
-     * @param artifact The artifact to use as label for this node, may be {@code null}.
-     */
-    public DefaultDependencyNode( Artifact artifact )
-    {
-        this.artifact = artifact;
-        children = new ArrayList<DependencyNode>( 0 );
-        aliases = relocations = Collections.emptyList();
-        repositories = Collections.emptyList();
-        context = "";
-        data = Collections.emptyMap();
-    }
-
-    /**
-     * Creates a mostly shallow clone of the specified node. The new node has its own copy of any custom data and
-     * initially no children.
-     * 
-     * @param node The node to copy, must not be {@code null}.
-     */
-    public DefaultDependencyNode( DependencyNode node )
-    {
-        dependency = node.getDependency();
-        artifact = node.getArtifact();
-        children = new ArrayList<DependencyNode>( 0 );
-        setAliases( node.getAliases() );
-        setRequestContext( node.getRequestContext() );
-        setManagedBits( node.getManagedBits() );
-        setRelocations( node.getRelocations() );
-        setRepositories( node.getRepositories() );
-        setVersion( node.getVersion() );
-        setVersionConstraint( node.getVersionConstraint() );
-        Map<?, ?> data = node.getData();
-        setData( data.isEmpty() ? null : new HashMap<Object, Object>( data ) );
-    }
-
-    public List<DependencyNode> getChildren()
-    {
-        return children;
-    }
-
-    public void setChildren( List<DependencyNode> children )
-    {
-        if ( children == null )
-        {
-            this.children = new ArrayList<DependencyNode>( 0 );
-        }
-        else
-        {
-            this.children = children;
-        }
-    }
-
-    public Dependency getDependency()
-    {
-        return dependency;
-    }
-
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    public void setArtifact( Artifact artifact )
-    {
-        if ( dependency == null )
-        {
-            throw new UnsupportedOperationException( "node does not have a dependency" );
-        }
-        dependency = dependency.setArtifact( artifact );
-        this.artifact = dependency.getArtifact();
-    }
-
-    public List<? extends Artifact> getRelocations()
-    {
-        return relocations;
-    }
-
-    /**
-     * Sets the sequence of relocations that was followed to resolve this dependency's artifact.
-     * 
-     * @param relocations The sequence of relocations, may be {@code null}.
-     */
-    public void setRelocations( List<? extends Artifact> relocations )
-    {
-        if ( relocations == null || relocations.isEmpty() )
-        {
-            this.relocations = Collections.emptyList();
-        }
-        else
-        {
-            this.relocations = relocations;
-        }
-    }
-
-    public Collection<? extends Artifact> getAliases()
-    {
-        return aliases;
-    }
-
-    /**
-     * Sets the known aliases for this dependency's artifact.
-     * 
-     * @param aliases The known aliases, may be {@code null}.
-     */
-    public void setAliases( Collection<? extends Artifact> aliases )
-    {
-        if ( aliases == null || aliases.isEmpty() )
-        {
-            this.aliases = Collections.emptyList();
-        }
-        else
-        {
-            this.aliases = aliases;
-        }
-    }
-
-    public VersionConstraint getVersionConstraint()
-    {
-        return versionConstraint;
-    }
-
-    /**
-     * Sets the version constraint that was parsed from the dependency's version declaration.
-     * 
-     * @param versionConstraint The version constraint for this node, may be {@code null}.
-     */
-    public void setVersionConstraint( VersionConstraint versionConstraint )
-    {
-        this.versionConstraint = versionConstraint;
-    }
-
-    public Version getVersion()
-    {
-        return version;
-    }
-
-    /**
-     * Sets the version that was selected for the dependency's target artifact.
-     * 
-     * @param version The parsed version, may be {@code null}.
-     */
-    public void setVersion( Version version )
-    {
-        this.version = version;
-    }
-
-    public void setScope( String scope )
-    {
-        if ( dependency == null )
-        {
-            throw new UnsupportedOperationException( "node does not have a dependency" );
-        }
-        dependency = dependency.setScope( scope );
-    }
-
-    public void setOptional( Boolean optional )
-    {
-        if ( dependency == null )
-        {
-            throw new UnsupportedOperationException( "node does not have a dependency" );
-        }
-        dependency = dependency.setOptional( optional );
-    }
-
-    public int getManagedBits()
-    {
-        return managedBits;
-    }
-
-    /**
-     * Sets a bit field indicating which attributes of this node were subject to dependency management.
-     * 
-     * @param managedBits The bit field indicating the managed attributes or {@code 0} if dependency management wasn't
-     *            applied.
-     */
-    public void setManagedBits( int managedBits )
-    {
-        this.managedBits = (byte) ( managedBits & 0x1F );
-    }
-
-    public List<RemoteRepository> getRepositories()
-    {
-        return repositories;
-    }
-
-    /**
-     * Sets the remote repositories from which this node's artifact shall be resolved.
-     * 
-     * @param repositories The remote repositories to use for artifact resolution, may be {@code null}.
-     */
-    public void setRepositories( List<RemoteRepository> repositories )
-    {
-        if ( repositories == null || repositories.isEmpty() )
-        {
-            this.repositories = Collections.emptyList();
-        }
-        else
-        {
-            this.repositories = repositories;
-        }
-    }
-
-    public String getRequestContext()
-    {
-        return context;
-    }
-
-    public void setRequestContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-    }
-
-    public Map<Object, Object> getData()
-    {
-        return data;
-    }
-
-    public void setData( Map<Object, Object> data )
-    {
-        if ( data == null )
-        {
-            this.data = Collections.emptyMap();
-        }
-        else
-        {
-            this.data = data;
-        }
-    }
-
-    public void setData( Object key, Object value )
-    {
-        if ( key == null )
-        {
-            throw new IllegalArgumentException( "key must not be null" );
-        }
-
-        if ( value == null )
-        {
-            if ( !data.isEmpty() )
-            {
-                data.remove( key );
-
-                if ( data.isEmpty() )
-                {
-                    data = Collections.emptyMap();
-                }
-            }
-        }
-        else
-        {
-            if ( data.isEmpty() )
-            {
-                data = new HashMap<Object, Object>( 1, 2 ); // nodes can be numerous so let's be space conservative
-            }
-            data.put( key, value );
-        }
-    }
-
-    public boolean accept( DependencyVisitor visitor )
-    {
-        if ( visitor.visitEnter( this ) )
-        {
-            for ( DependencyNode child : children )
-            {
-                if ( !child.accept( visitor ) )
-                {
-                    break;
-                }
-            }
-        }
-
-        return visitor.visitLeave( this );
-    }
-
-    @Override
-    public String toString()
-    {
-        Dependency dep = getDependency();
-        if ( dep == null )
-        {
-            return String.valueOf( getArtifact() );
-        }
-        return dep.toString();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/Dependency.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/Dependency.java
deleted file mode 100644 (file)
index 72ea0f6..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.graph;
-
-import java.util.AbstractSet;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * A dependency to some artifact. <em>Note:</em> Instances of this class are immutable and the exposed mutators return
- * new objects rather than changing the current instance.
- */
-public final class Dependency
-{
-
-    private final Artifact artifact;
-
-    private final String scope;
-
-    private final Boolean optional;
-
-    private final Set<Exclusion> exclusions;
-
-    /**
-     * Creates a mandatory dependency on the specified artifact with the given scope.
-     * 
-     * @param artifact The artifact being depended on, must not be {@code null}.
-     * @param scope The scope of the dependency, may be {@code null}.
-     */
-    public Dependency( Artifact artifact, String scope )
-    {
-        this( artifact, scope, false );
-    }
-
-    /**
-     * Creates a dependency on the specified artifact with the given scope.
-     * 
-     * @param artifact The artifact being depended on, must not be {@code null}.
-     * @param scope The scope of the dependency, may be {@code null}.
-     * @param optional A flag whether the dependency is optional or mandatory, may be {@code null}.
-     */
-    public Dependency( Artifact artifact, String scope, Boolean optional )
-    {
-        this( artifact, scope, optional, null );
-    }
-
-    /**
-     * Creates a dependency on the specified artifact with the given scope and exclusions.
-     * 
-     * @param artifact The artifact being depended on, must not be {@code null}.
-     * @param scope The scope of the dependency, may be {@code null}.
-     * @param optional A flag whether the dependency is optional or mandatory, may be {@code null}.
-     * @param exclusions The exclusions that apply to transitive dependencies, may be {@code null} if none.
-     */
-    public Dependency( Artifact artifact, String scope, Boolean optional, Collection<Exclusion> exclusions )
-    {
-        this( artifact, scope, Exclusions.copy( exclusions ), optional );
-    }
-
-    private Dependency( Artifact artifact, String scope, Set<Exclusion> exclusions, Boolean optional )
-    {
-        // NOTE: This constructor assumes immutability of the provided exclusion collection, for internal use only
-        if ( artifact == null )
-        {
-            throw new IllegalArgumentException( "no artifact specified for dependency" );
-        }
-        this.artifact = artifact;
-        this.scope = ( scope != null ) ? scope : "";
-        this.optional = optional;
-        this.exclusions = exclusions;
-    }
-
-    /**
-     * Gets the artifact being depended on.
-     * 
-     * @return The artifact, never {@code null}.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the artifact being depended on.
-     * 
-     * @param artifact The artifact, must not be {@code null}.
-     * @return The new dependency, never {@code null}.
-     */
-    public Dependency setArtifact( Artifact artifact )
-    {
-        if ( this.artifact.equals( artifact ) )
-        {
-            return this;
-        }
-        return new Dependency( artifact, scope, exclusions, optional );
-    }
-
-    /**
-     * Gets the scope of the dependency. The scope defines in which context this dependency is relevant.
-     * 
-     * @return The scope or an empty string if not set, never {@code null}.
-     */
-    public String getScope()
-    {
-        return scope;
-    }
-
-    /**
-     * Sets the scope of the dependency, e.g. "compile".
-     * 
-     * @param scope The scope of the dependency, may be {@code null}.
-     * @return The new dependency, never {@code null}.
-     */
-    public Dependency setScope( String scope )
-    {
-        if ( this.scope.equals( scope ) || ( scope == null && this.scope.length() <= 0 ) )
-        {
-            return this;
-        }
-        return new Dependency( artifact, scope, exclusions, optional );
-    }
-
-    /**
-     * Indicates whether this dependency is optional or not. Optional dependencies can be ignored in some contexts.
-     * 
-     * @return {@code true} if the dependency is (definitively) optional, {@code false} otherwise.
-     */
-    public boolean isOptional()
-    {
-        return Boolean.TRUE.equals( optional );
-    }
-
-    /**
-     * Gets the optional flag for the dependency. Note: Most clients will usually call {@link #isOptional()} to
-     * determine the optional flag, this method is for advanced use cases where three-valued logic is required.
-     * 
-     * @return The optional flag or {@code null} if unspecified.
-     */
-    public Boolean getOptional()
-    {
-        return optional;
-    }
-
-    /**
-     * Sets the optional flag for the dependency.
-     * 
-     * @param optional {@code true} if the dependency is optional, {@code false} if the dependency is mandatory, may be
-     *            {@code null} if unspecified.
-     * @return The new dependency, never {@code null}.
-     */
-    public Dependency setOptional( Boolean optional )
-    {
-        if ( eq( this.optional, optional ) )
-        {
-            return this;
-        }
-        return new Dependency( artifact, scope, exclusions, optional );
-    }
-
-    /**
-     * Gets the exclusions for this dependency. Exclusions can be used to remove transitive dependencies during
-     * resolution.
-     * 
-     * @return The (read-only) exclusions, never {@code null}.
-     */
-    public Collection<Exclusion> getExclusions()
-    {
-        return exclusions;
-    }
-
-    /**
-     * Sets the exclusions for the dependency.
-     * 
-     * @param exclusions The exclusions, may be {@code null}.
-     * @return The new dependency, never {@code null}.
-     */
-    public Dependency setExclusions( Collection<Exclusion> exclusions )
-    {
-        if ( hasEquivalentExclusions( exclusions ) )
-        {
-            return this;
-        }
-        return new Dependency( artifact, scope, optional, exclusions );
-    }
-
-    private boolean hasEquivalentExclusions( Collection<Exclusion> exclusions )
-    {
-        if ( exclusions == null || exclusions.isEmpty() )
-        {
-            return this.exclusions.isEmpty();
-        }
-        if ( exclusions instanceof Set )
-        {
-            return this.exclusions.equals( exclusions );
-        }
-        return exclusions.size() >= this.exclusions.size() && this.exclusions.containsAll( exclusions )
-            && exclusions.containsAll( this.exclusions );
-    }
-
-    @Override
-    public String toString()
-    {
-        return String.valueOf( getArtifact() ) + " (" + getScope() + ( isOptional() ? "?" : "" ) + ")";
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( obj == this )
-        {
-            return true;
-        }
-        else if ( obj == null || !getClass().equals( obj.getClass() ) )
-        {
-            return false;
-        }
-
-        Dependency that = (Dependency) obj;
-
-        return artifact.equals( that.artifact ) && scope.equals( that.scope ) && eq( optional, that.optional )
-            && exclusions.equals( that.exclusions );
-    }
-
-    private static <T> boolean eq( T o1, T o2 )
-    {
-        return ( o1 != null ) ? o1.equals( o2 ) : o2 == null;
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = 17;
-        hash = hash * 31 + artifact.hashCode();
-        hash = hash * 31 + scope.hashCode();
-        hash = hash * 31 + ( optional != null ? optional.hashCode() : 0 );
-        hash = hash * 31 + exclusions.size();
-        return hash;
-    }
-
-    private static class Exclusions
-        extends AbstractSet<Exclusion>
-    {
-
-        private final Exclusion[] exclusions;
-
-        public static Set<Exclusion> copy( Collection<Exclusion> exclusions )
-        {
-            if ( exclusions == null || exclusions.isEmpty() )
-            {
-                return Collections.emptySet();
-            }
-            return new Exclusions( exclusions );
-        }
-
-        private Exclusions( Collection<Exclusion> exclusions )
-        {
-            if ( exclusions.size() > 1 && !( exclusions instanceof Set ) )
-            {
-                exclusions = new LinkedHashSet<Exclusion>( exclusions );
-            }
-            this.exclusions = exclusions.toArray( new Exclusion[exclusions.size()] );
-        }
-
-        @Override
-        public Iterator<Exclusion> iterator()
-        {
-            return new Iterator<Exclusion>()
-            {
-
-                private int cursor = 0;
-
-                public boolean hasNext()
-                {
-                    return cursor < exclusions.length;
-                }
-
-                public Exclusion next()
-                {
-                    try
-                    {
-                        Exclusion exclusion = exclusions[cursor];
-                        cursor++;
-                        return exclusion;
-                    }
-                    catch ( IndexOutOfBoundsException e )
-                    {
-                        throw new NoSuchElementException();
-                    }
-                }
-
-                public void remove()
-                {
-                    throw new UnsupportedOperationException();
-                }
-
-            };
-        }
-
-        @Override
-        public int size()
-        {
-            return exclusions.length;
-        }
-
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyCycle.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyCycle.java
deleted file mode 100644 (file)
index 68f9a32..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.graph;
-
-import java.util.List;
-
-/**
- * A cycle within a dependency graph, that is a sequence of dependencies d_1, d_2, ..., d_n where d_1 and d_n have the
- * same versionless coordinates. In more practical terms, a cycle occurs when a project directly or indirectly depends
- * on its own output artifact.
- * 
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface DependencyCycle
-{
-
-    /**
-     * Gets the dependencies that lead to the first dependency on the cycle, starting from the root of the dependency
-     * graph.
-     * 
-     * @return The (read-only) sequence of dependencies that precedes the cycle in the graph, potentially empty but
-     *         never {@code null}.
-     */
-    List<Dependency> getPrecedingDependencies();
-
-    /**
-     * Gets the dependencies that actually form the cycle. For example, a -&gt; b -&gt; c -&gt; a, i.e. the last
-     * dependency in this sequence duplicates the first element and closes the cycle. Hence the length of the cycle is
-     * the size of the returned sequence minus 1.
-     * 
-     * @return The (read-only) sequence of dependencies that forms the cycle, never {@code null}.
-     */
-    List<Dependency> getCyclicDependencies();
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyFilter.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyFilter.java
deleted file mode 100644 (file)
index c776ddc..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.graph;
-
-import java.util.List;
-
-/**
- * A filter to include/exclude dependency nodes during other operations.
- */
-public interface DependencyFilter
-{
-
-    /**
-     * Indicates whether the specified dependency node shall be included or excluded.
-     * 
-     * @param node The dependency node to filter, must not be {@code null}.
-     * @param parents The (read-only) chain of parent nodes that leads to the node to be filtered, must not be
-     *            {@code null}. Iterating this (possibly empty) list walks up the dependency graph towards the root
-     *            node, i.e. the immediate parent node (if any) is the first node in the list. The size of the list also
-     *            denotes the zero-based depth of the filtered node.
-     * @return {@code true} to include the dependency node, {@code false} to exclude it.
-     */
-    boolean accept( DependencyNode node, List<DependencyNode> parents );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyNode.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyNode.java
deleted file mode 100644 (file)
index 4e34597..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.graph;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionConstraint;
-
-/**
- * A node within a dependency graph. To conserve memory, dependency graphs may reuse a given node instance multiple
- * times to represent reoccurring dependencies. As such clients traversing a dependency graph should be prepared to
- * discover multiple paths leading to the same node instance unless the input graph is known to be a duplicate-free
- * tree. <em>Note:</em> Unless otherwise noted, implementation classes are not thread-safe and dependency nodes should
- * not be mutated by concurrent threads.
- * 
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface DependencyNode
-{
-
-    /**
-     * A bit flag indicating the dependency version was subject to dependency management
-     * 
-     * @see #getManagedBits()
-     */
-    int MANAGED_VERSION = 0x01;
-
-    /**
-     * A bit flag indicating the dependency scope was subject to dependency management
-     * 
-     * @see #getManagedBits()
-     */
-    int MANAGED_SCOPE = 0x02;
-
-    /**
-     * A bit flag indicating the optional flag was subject to dependency management
-     * 
-     * @see #getManagedBits()
-     */
-    int MANAGED_OPTIONAL = 0x04;
-
-    /**
-     * A bit flag indicating the artifact properties were subject to dependency management
-     * 
-     * @see #getManagedBits()
-     */
-    int MANAGED_PROPERTIES = 0x08;
-
-    /**
-     * A bit flag indicating the exclusions were subject to dependency management
-     * 
-     * @see #getManagedBits()
-     */
-    int MANAGED_EXCLUSIONS = 0x10;
-
-    /**
-     * Gets the child nodes of this node. To conserve memory, dependency nodes with equal dependencies may share the
-     * same child list instance. Hence clients mutating the child list need to be aware that these changes might affect
-     * more than this node. Where this is not desired, the child list should be copied before mutation if the client
-     * cannot be sure whether it might be shared with other nodes in the graph.
-     * 
-     * @return The child nodes of this node, never {@code null}.
-     */
-    List<DependencyNode> getChildren();
-
-    /**
-     * Sets the child nodes of this node.
-     * 
-     * @param children The child nodes, may be {@code null}
-     */
-    void setChildren( List<DependencyNode> children );
-
-    /**
-     * Gets the dependency associated with this node. <em>Note:</em> For dependency graphs that have been constructed
-     * without a root dependency, this method will yield {@code null} when invoked on the graph's root node. The root
-     * node of such graphs may however still have a label as returned by {@link #getArtifact()}.
-     * 
-     * @return The dependency or {@code null} if none.
-     */
-    Dependency getDependency();
-
-    /**
-     * Gets the artifact associated with this node. If this node is associated with a dependency, this is equivalent to
-     * {@code getDependency().getArtifact()}. Otherwise the artifact merely provides a label for this node in which case
-     * the artifact must not be subjected to dependency collection/resolution.
-     * 
-     * @return The associated artifact or {@code null} if none.
-     */
-    Artifact getArtifact();
-
-    /**
-     * Updates the artifact of the dependency after resolution. The new artifact must have the same coordinates as the
-     * original artifact. This method may only be invoked if this node actually has a dependency, i.e. if
-     * {@link #getDependency()} is not null.
-     * 
-     * @param artifact The artifact satisfying the dependency, must not be {@code null}.
-     */
-    void setArtifact( Artifact artifact );
-
-    /**
-     * Gets the sequence of relocations that was followed to resolve the artifact referenced by the dependency.
-     * 
-     * @return The (read-only) sequence of relocations, never {@code null}.
-     */
-    List<? extends Artifact> getRelocations();
-
-    /**
-     * Gets the known aliases for this dependency's artifact. An alias can be used to mark a patched rebuild of some
-     * other artifact as such, thereby allowing conflict resolution to consider the patched and the original artifact as
-     * a conflict.
-     * 
-     * @return The (read-only) set of known aliases, never {@code null}.
-     */
-    Collection<? extends Artifact> getAliases();
-
-    /**
-     * Gets the version constraint that was parsed from the dependency's version declaration.
-     * 
-     * @return The version constraint for this node or {@code null}.
-     */
-    VersionConstraint getVersionConstraint();
-
-    /**
-     * Gets the version that was selected for the dependency's target artifact.
-     * 
-     * @return The parsed version or {@code null}.
-     */
-    Version getVersion();
-
-    /**
-     * Sets the scope of the dependency. This method may only be invoked if this node actually has a dependency, i.e. if
-     * {@link #getDependency()} is not null.
-     * 
-     * @param scope The scope, may be {@code null}.
-     */
-    void setScope( String scope );
-
-    /**
-     * Sets the optional flag of the dependency. This method may only be invoked if this node actually has a dependency,
-     * i.e. if {@link #getDependency()} is not null.
-     * 
-     * @param optional The optional flag, may be {@code null}.
-     */
-    void setOptional( Boolean optional );
-
-    /**
-     * Gets a bit field indicating which attributes of this node were subject to dependency management.
-     * 
-     * @return A bit field containing any of the bits {@link #MANAGED_VERSION}, {@link #MANAGED_SCOPE},
-     *         {@link #MANAGED_OPTIONAL}, {@link #MANAGED_PROPERTIES} and {@link #MANAGED_EXCLUSIONS} if the
-     *         corresponding attribute was set via dependency management.
-     */
-    int getManagedBits();
-
-    /**
-     * Gets the remote repositories from which this node's artifact shall be resolved.
-     * 
-     * @return The (read-only) list of remote repositories to use for artifact resolution, never {@code null}.
-     */
-    List<RemoteRepository> getRepositories();
-
-    /**
-     * Gets the request context in which this dependency node was created.
-     * 
-     * @return The request context, never {@code null}.
-     */
-    String getRequestContext();
-
-    /**
-     * Sets the request context in which this dependency node was created.
-     * 
-     * @param context The context, may be {@code null}.
-     */
-    void setRequestContext( String context );
-
-    /**
-     * Gets the custom data associated with this dependency node. Clients of the repository system can use this data to
-     * annotate dependency nodes with domain-specific information. Note that the returned map is read-only and
-     * {@link #setData(Object, Object)} needs to be used to update the custom data.
-     * 
-     * @return The (read-only) key-value mappings, never {@code null}.
-     */
-    Map<?, ?> getData();
-
-    /**
-     * Sets the custom data associated with this dependency node.
-     * 
-     * @param data The new custom data, may be {@code null}.
-     */
-    void setData( Map<Object, Object> data );
-
-    /**
-     * Associates the specified dependency node data with the given key. <em>Note:</em> This method must not be called
-     * while {@link #getData()} is being iterated.
-     * 
-     * @param key The key under which to store the data, must not be {@code null}.
-     * @param value The data to associate with the key, may be {@code null} to remove the mapping.
-     */
-    void setData( Object key, Object value );
-
-    /**
-     * Traverses this node and potentially its children using the specified visitor.
-     * 
-     * @param visitor The visitor to call back, must not be {@code null}.
-     * @return {@code true} to visit siblings nodes of this node as well, {@code false} to skip siblings.
-     */
-    boolean accept( DependencyVisitor visitor );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyVisitor.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyVisitor.java
deleted file mode 100644 (file)
index d4ba213..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.graph;
-
-/**
- * A visitor for nodes of the dependency graph.
- * 
- * @see DependencyNode#accept(DependencyVisitor)
- */
-public interface DependencyVisitor
-{
-
-    /**
-     * Notifies the visitor of a node visit before its children have been processed.
-     * 
-     * @param node The dependency node being visited, must not be {@code null}.
-     * @return {@code true} to visit child nodes of the specified node as well, {@code false} to skip children.
-     */
-    boolean visitEnter( DependencyNode node );
-
-    /**
-     * Notifies the visitor of a node visit after its children have been processed. Note that this method is always
-     * invoked regardless whether any children have actually been visited.
-     * 
-     * @param node The dependency node being visited, must not be {@code null}.
-     * @return {@code true} to visit siblings nodes of the specified node as well, {@code false} to skip siblings.
-     */
-    boolean visitLeave( DependencyNode node );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/Exclusion.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/Exclusion.java
deleted file mode 100644 (file)
index 4d6b7ba..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.graph;
-
-/**
- * An exclusion of one or more transitive dependencies. <em>Note:</em> Instances of this class are immutable and the
- * exposed mutators return new objects rather than changing the current instance.
- * 
- * @see Dependency#getExclusions()
- */
-public final class Exclusion
-{
-
-    private final String groupId;
-
-    private final String artifactId;
-
-    private final String classifier;
-
-    private final String extension;
-
-    /**
-     * Creates an exclusion for artifacts with the specified coordinates.
-     * 
-     * @param groupId The group identifier, may be {@code null}.
-     * @param artifactId The artifact identifier, may be {@code null}.
-     * @param classifier The classifier, may be {@code null}.
-     * @param extension The file extension, may be {@code null}.
-     */
-    public Exclusion( String groupId, String artifactId, String classifier, String extension )
-    {
-        this.groupId = ( groupId != null ) ? groupId : "";
-        this.artifactId = ( artifactId != null ) ? artifactId : "";
-        this.classifier = ( classifier != null ) ? classifier : "";
-        this.extension = ( extension != null ) ? extension : "";
-    }
-
-    /**
-     * Gets the group identifier for artifacts to exclude.
-     * 
-     * @return The group identifier, never {@code null}.
-     */
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    /**
-     * Gets the artifact identifier for artifacts to exclude.
-     * 
-     * @return The artifact identifier, never {@code null}.
-     */
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    /**
-     * Gets the classifier for artifacts to exclude.
-     * 
-     * @return The classifier, never {@code null}.
-     */
-    public String getClassifier()
-    {
-        return classifier;
-    }
-
-    /**
-     * Gets the file extension for artifacts to exclude.
-     * 
-     * @return The file extension of artifacts to exclude, never {@code null}.
-     */
-    public String getExtension()
-    {
-        return extension;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getGroupId() + ':' + getArtifactId() + ':' + getExtension()
-            + ( getClassifier().length() > 0 ? ':' + getClassifier() : "" );
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( obj == this )
-        {
-            return true;
-        }
-        else if ( obj == null || !getClass().equals( obj.getClass() ) )
-        {
-            return false;
-        }
-
-        Exclusion that = (Exclusion) obj;
-
-        return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId )
-            && extension.equals( that.extension ) && classifier.equals( that.classifier );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = 17;
-        hash = hash * 31 + artifactId.hashCode();
-        hash = hash * 31 + groupId.hashCode();
-        hash = hash * 31 + classifier.hashCode();
-        hash = hash * 31 + extension.hashCode();
-        return hash;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/graph/package-info.java
deleted file mode 100644 (file)
index 70879a3..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The representation of a dependency graph by means of connected dependency nodes.
- */
-package org.eclipse.aether.graph;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallRequest.java
deleted file mode 100644 (file)
index 330f85a..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.installation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * A request to install artifacts and their accompanying metadata into the local repository.
- * 
- * @see RepositorySystem#install(RepositorySystemSession, InstallRequest)
- */
-public final class InstallRequest
-{
-
-    private Collection<Artifact> artifacts = Collections.emptyList();
-
-    private Collection<Metadata> metadata = Collections.emptyList();
-
-    private RequestTrace trace;
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public InstallRequest()
-    {
-    }
-
-    /**
-     * Gets the artifact to install.
-     * 
-     * @return The artifacts to install, never {@code null}.
-     */
-    public Collection<Artifact> getArtifacts()
-    {
-        return artifacts;
-    }
-
-    /**
-     * Sets the artifacts to install.
-     * 
-     * @param artifacts The artifacts to install, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public InstallRequest setArtifacts( Collection<Artifact> artifacts )
-    {
-        if ( artifacts == null )
-        {
-            this.artifacts = Collections.emptyList();
-        }
-        else
-        {
-            this.artifacts = artifacts;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified artifacts for installation.
-     * 
-     * @param artifact The artifact to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public InstallRequest addArtifact( Artifact artifact )
-    {
-        if ( artifact != null )
-        {
-            if ( artifacts.isEmpty() )
-            {
-                artifacts = new ArrayList<Artifact>();
-            }
-            artifacts.add( artifact );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the metadata to install.
-     * 
-     * @return The metadata to install, never {@code null}.
-     */
-    public Collection<Metadata> getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Sets the metadata to install.
-     * 
-     * @param metadata The metadata to install.
-     * @return This request for chaining, never {@code null}.
-     */
-    public InstallRequest setMetadata( Collection<Metadata> metadata )
-    {
-        if ( metadata == null )
-        {
-            this.metadata = Collections.emptyList();
-        }
-        else
-        {
-            this.metadata = metadata;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified metadata for installation.
-     * 
-     * @param metadata The metadata to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public InstallRequest addMetadata( Metadata metadata )
-    {
-        if ( metadata != null )
-        {
-            if ( this.metadata.isEmpty() )
-            {
-                this.metadata = new ArrayList<Metadata>();
-            }
-            this.metadata.add( metadata );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    /**
-     * Sets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @param trace The trace information about the higher level operation, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public InstallRequest setTrace( RequestTrace trace )
-    {
-        this.trace = trace;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifacts() + ", " + getMetadata();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallResult.java
deleted file mode 100644 (file)
index fe3ade1..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.installation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * The result of installing artifacts and their accompanying metadata into the a remote repository.
- * 
- * @see RepositorySystem#install(RepositorySystemSession, InstallRequest)
- */
-public final class InstallResult
-{
-
-    private final InstallRequest request;
-
-    private Collection<Artifact> artifacts;
-
-    private Collection<Metadata> metadata;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The installation request, must not be {@code null}.
-     */
-    public InstallResult( InstallRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "install request has not been specified" );
-        }
-        this.request = request;
-        artifacts = Collections.emptyList();
-        metadata = Collections.emptyList();
-    }
-
-    /**
-     * Gets the install request that was made.
-     * 
-     * @return The install request, never {@code null}.
-     */
-    public InstallRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the artifacts that got installed.
-     * 
-     * @return The installed artifacts, never {@code null}.
-     */
-    public Collection<Artifact> getArtifacts()
-    {
-        return artifacts;
-    }
-
-    /**
-     * Sets the artifacts that got installed.
-     * 
-     * @param artifacts The installed artifacts, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public InstallResult setArtifacts( Collection<Artifact> artifacts )
-    {
-        if ( artifacts == null )
-        {
-            this.artifacts = Collections.emptyList();
-        }
-        else
-        {
-            this.artifacts = artifacts;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified artifacts to the result.
-     * 
-     * @param artifact The installed artifact to add, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public InstallResult addArtifact( Artifact artifact )
-    {
-        if ( artifact != null )
-        {
-            if ( artifacts.isEmpty() )
-            {
-                artifacts = new ArrayList<Artifact>();
-            }
-            artifacts.add( artifact );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the metadata that got installed. Note that due to automatically generated metadata, there might have been
-     * more metadata installed than originally specified in the install request.
-     * 
-     * @return The installed metadata, never {@code null}.
-     */
-    public Collection<Metadata> getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Sets the metadata that got installed.
-     * 
-     * @param metadata The installed metadata, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public InstallResult setMetadata( Collection<Metadata> metadata )
-    {
-        if ( metadata == null )
-        {
-            this.metadata = Collections.emptyList();
-        }
-        else
-        {
-            this.metadata = metadata;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified metadata to this result.
-     * 
-     * @param metadata The installed metadata to add, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public InstallResult addMetadata( Metadata metadata )
-    {
-        if ( metadata != null )
-        {
-            if ( this.metadata.isEmpty() )
-            {
-                this.metadata = new ArrayList<Metadata>();
-            }
-            this.metadata.add( metadata );
-        }
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifacts() + ", " + getMetadata();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallationException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallationException.java
deleted file mode 100644 (file)
index e976665..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.installation;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case of an installation error like an IO error.
- */
-public class InstallationException
-    extends RepositoryException
-{
-
-    /**
-     * Creates a new exception with the specified detail message.
-     * 
-     * @param message The detail message, may be {@code null}.
-     */
-    public InstallationException( String message )
-    {
-        super( message );
-    }
-
-    /**
-     * Creates a new exception with the specified detail message and cause.
-     * 
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public InstallationException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/installation/package-info.java
deleted file mode 100644 (file)
index 35b910b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The types supporting the publishing of artifacts to a local repository.
- */
-package org.eclipse.aether.installation;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/AbstractMetadata.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/AbstractMetadata.java
deleted file mode 100644 (file)
index d95eb54..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.metadata;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A skeleton class for metadata.
- */
-public abstract class AbstractMetadata
-    implements Metadata
-{
-
-    private Metadata newInstance( Map<String, String> properties, File file )
-    {
-        return new DefaultMetadata( getGroupId(), getArtifactId(), getVersion(), getType(), getNature(), file,
-                                    properties );
-    }
-
-    public Metadata setFile( File file )
-    {
-        File current = getFile();
-        if ( ( current == null ) ? file == null : current.equals( file ) )
-        {
-            return this;
-        }
-        return newInstance( getProperties(), file );
-    }
-
-    public Metadata setProperties( Map<String, String> properties )
-    {
-        Map<String, String> current = getProperties();
-        if ( current.equals( properties ) || ( properties == null && current.isEmpty() ) )
-        {
-            return this;
-        }
-        return newInstance( copyProperties( properties ), getFile() );
-    }
-
-    public String getProperty( String key, String defaultValue )
-    {
-        String value = getProperties().get( key );
-        return ( value != null ) ? value : defaultValue;
-    }
-
-    /**
-     * Copies the specified metadata properties. This utility method should be used when creating new metadata instances
-     * with caller-supplied properties.
-     * 
-     * @param properties The properties to copy, may be {@code null}.
-     * @return The copied and read-only properties, never {@code null}.
-     */
-    protected static Map<String, String> copyProperties( Map<String, String> properties )
-    {
-        if ( properties != null && !properties.isEmpty() )
-        {
-            return Collections.unmodifiableMap( new HashMap<String, String>( properties ) );
-        }
-        else
-        {
-            return Collections.emptyMap();
-        }
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder buffer = new StringBuilder( 128 );
-        if ( getGroupId().length() > 0 )
-        {
-            buffer.append( getGroupId() );
-        }
-        if ( getArtifactId().length() > 0 )
-        {
-            buffer.append( ':' ).append( getArtifactId() );
-        }
-        if ( getVersion().length() > 0 )
-        {
-            buffer.append( ':' ).append( getVersion() );
-        }
-        buffer.append( '/' ).append( getType() );
-        return buffer.toString();
-    }
-
-    /**
-     * Compares this metadata with the specified object.
-     * 
-     * @param obj The object to compare this metadata against, may be {@code null}.
-     * @return {@code true} if and only if the specified object is another {@link Metadata} with equal coordinates,
-     *         type, nature, properties and file, {@code false} otherwise.
-     */
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( obj == this )
-        {
-            return true;
-        }
-        else if ( !( obj instanceof Metadata ) )
-        {
-            return false;
-        }
-
-        Metadata that = (Metadata) obj;
-
-        return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() )
-            && getVersion().equals( that.getVersion() ) && getType().equals( that.getType() )
-            && getNature().equals( that.getNature() ) && eq( getFile(), that.getFile() )
-            && eq( getProperties(), that.getProperties() );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
-    }
-
-    /**
-     * Returns a hash code for this metadata.
-     * 
-     * @return A hash code for the metadata.
-     */
-    @Override
-    public int hashCode()
-    {
-        int hash = 17;
-        hash = hash * 31 + getGroupId().hashCode();
-        hash = hash * 31 + getArtifactId().hashCode();
-        hash = hash * 31 + getType().hashCode();
-        hash = hash * 31 + getNature().hashCode();
-        hash = hash * 31 + getVersion().hashCode();
-        hash = hash * 31 + hash( getFile() );
-        return hash;
-    }
-
-    private static int hash( Object obj )
-    {
-        return ( obj != null ) ? obj.hashCode() : 0;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/DefaultMetadata.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/DefaultMetadata.java
deleted file mode 100644 (file)
index aa9c830..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.metadata;
-
-import java.io.File;
-import java.util.Map;
-
-/**
- * A basic metadata instance. <em>Note:</em> Instances of this class are immutable and the exposed mutators return new
- * objects rather than changing the current instance.
- */
-public final class DefaultMetadata
-    extends AbstractMetadata
-{
-
-    private final String groupId;
-
-    private final String artifactId;
-
-    private final String version;
-
-    private final String type;
-
-    private final Nature nature;
-
-    private final File file;
-
-    private final Map<String, String> properties;
-
-    /**
-     * Creates a new metadata for the repository root with the specific type and nature.
-     * 
-     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
-     * @param nature The nature of the metadata, must not be {@code null}.
-     */
-    public DefaultMetadata( String type, Nature nature )
-    {
-        this( "", "", "", type, nature, null, (File) null );
-    }
-
-    /**
-     * Creates a new metadata for the groupId level with the specific type and nature.
-     * 
-     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
-     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
-     * @param nature The nature of the metadata, must not be {@code null}.
-     */
-    public DefaultMetadata( String groupId, String type, Nature nature )
-    {
-        this( groupId, "", "", type, nature, null, (File) null );
-    }
-
-    /**
-     * Creates a new metadata for the groupId:artifactId level with the specific type and nature.
-     * 
-     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
-     * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
-     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
-     * @param nature The nature of the metadata, must not be {@code null}.
-     */
-    public DefaultMetadata( String groupId, String artifactId, String type, Nature nature )
-    {
-        this( groupId, artifactId, "", type, nature, null, (File) null );
-    }
-
-    /**
-     * Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
-     * 
-     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
-     * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
-     * @param version The version to which this metadata applies, may be {@code null}.
-     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
-     * @param nature The nature of the metadata, must not be {@code null}.
-     */
-    public DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature )
-    {
-        this( groupId, artifactId, version, type, nature, null, (File) null );
-    }
-
-    /**
-     * Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
-     * 
-     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
-     * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
-     * @param version The version to which this metadata applies, may be {@code null}.
-     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
-     * @param nature The nature of the metadata, must not be {@code null}.
-     * @param file The resolved file of the metadata, may be {@code null}.
-     */
-    public DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature, File file )
-    {
-        this( groupId, artifactId, version, type, nature, null, file );
-    }
-
-    /**
-     * Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
-     * 
-     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
-     * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
-     * @param version The version to which this metadata applies, may be {@code null}.
-     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
-     * @param nature The nature of the metadata, must not be {@code null}.
-     * @param properties The properties of the metadata, may be {@code null} if none.
-     * @param file The resolved file of the metadata, may be {@code null}.
-     */
-    public DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature,
-                            Map<String, String> properties, File file )
-    {
-        this.groupId = emptify( groupId );
-        this.artifactId = emptify( artifactId );
-        this.version = emptify( version );
-        this.type = emptify( type );
-        if ( nature == null )
-        {
-            throw new IllegalArgumentException( "metadata nature was not specified" );
-        }
-        this.nature = nature;
-        this.file = file;
-        this.properties = copyProperties( properties );
-    }
-
-    DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature, File file,
-                     Map<String, String> properties )
-    {
-        // NOTE: This constructor assumes immutability of the provided properties, for internal use only
-        this.groupId = emptify( groupId );
-        this.artifactId = emptify( artifactId );
-        this.version = emptify( version );
-        this.type = emptify( type );
-        this.nature = nature;
-        this.file = file;
-        this.properties = properties;
-    }
-
-    private static String emptify( String str )
-    {
-        return ( str == null ) ? "" : str;
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public String getVersion()
-    {
-        return version;
-    }
-
-    public String getType()
-    {
-        return type;
-    }
-
-    public Nature getNature()
-    {
-        return nature;
-    }
-
-    public File getFile()
-    {
-        return file;
-    }
-
-    public Map<String, String> getProperties()
-    {
-        return properties;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/MergeableMetadata.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/MergeableMetadata.java
deleted file mode 100644 (file)
index 25f15df..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.metadata;
-
-import java.io.File;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * A piece of metadata that needs to be merged with any current metadata before installation/deployment.
- */
-public interface MergeableMetadata
-    extends Metadata
-{
-
-    /**
-     * Merges this metadata into the current metadata (if any). Note that this method will be invoked regardless whether
-     * metadata currently exists or not.
-     * 
-     * @param current The path to the current metadata file, may not exist but must not be {@code null}.
-     * @param result The path to the result file where the merged metadata should be stored, must not be {@code null}.
-     * @throws RepositoryException If the metadata could not be merged.
-     */
-    void merge( File current, File result )
-        throws RepositoryException;
-
-    /**
-     * Indicates whether this metadata has been merged.
-     * 
-     * @return {@code true} if the metadata has been merged, {@code false} otherwise.
-     */
-    boolean isMerged();
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/Metadata.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/Metadata.java
deleted file mode 100644 (file)
index 328544a..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.metadata;
-
-import java.io.File;
-import java.util.Map;
-
-/**
- * A piece of repository metadata, e.g. an index of available versions. In contrast to an artifact, which usually exists
- * in only one repository, metadata usually exists in multiple repositories and each repository contains a different
- * copy of the metadata. <em>Note:</em> Metadata instances are supposed to be immutable, e.g. any exposed mutator method
- * returns a new metadata instance and leaves the original instance unchanged. Implementors are strongly advised to obey
- * this contract. <em>Note:</em> Implementors are strongly advised to inherit from {@link AbstractMetadata} instead of
- * directly implementing this interface.
- * 
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface Metadata
-{
-
-    /**
-     * The nature of the metadata.
-     */
-    enum Nature
-    {
-        /**
-         * The metadata refers to release artifacts only.
-         */
-        RELEASE,
-
-        /**
-         * The metadata refers to snapshot artifacts only.
-         */
-        SNAPSHOT,
-
-        /**
-         * The metadata refers to either release or snapshot artifacts.
-         */
-        RELEASE_OR_SNAPSHOT
-    }
-
-    /**
-     * Gets the group identifier of this metadata.
-     * 
-     * @return The group identifier or an empty string if the metadata applies to the entire repository, never
-     *         {@code null}.
-     */
-    String getGroupId();
-
-    /**
-     * Gets the artifact identifier of this metadata.
-     * 
-     * @return The artifact identifier or an empty string if the metadata applies to the groupId level only, never
-     *         {@code null}.
-     */
-    String getArtifactId();
-
-    /**
-     * Gets the version of this metadata.
-     * 
-     * @return The version or an empty string if the metadata applies to the groupId:artifactId level only, never
-     *         {@code null}.
-     */
-    String getVersion();
-
-    /**
-     * Gets the type of the metadata, e.g. "maven-metadata.xml".
-     * 
-     * @return The type of the metadata, never {@code null}.
-     */
-    String getType();
-
-    /**
-     * Gets the nature of this metadata. The nature indicates to what artifact versions the metadata refers.
-     * 
-     * @return The nature, never {@code null}.
-     */
-    Nature getNature();
-
-    /**
-     * Gets the file of this metadata. Note that only resolved metadata has a file associated with it.
-     * 
-     * @return The file or {@code null} if none.
-     */
-    File getFile();
-
-    /**
-     * Sets the file of the metadata.
-     * 
-     * @param file The file of the metadata, may be {@code null}
-     * @return The new metadata, never {@code null}.
-     */
-    Metadata setFile( File file );
-
-    /**
-     * Gets the specified property.
-     * 
-     * @param key The name of the property, must not be {@code null}.
-     * @param defaultValue The default value to return in case the property is not set, may be {@code null}.
-     * @return The requested property value or {@code null} if the property is not set and no default value was
-     *         provided.
-     */
-    String getProperty( String key, String defaultValue );
-
-    /**
-     * Gets the properties of this metadata.
-     * 
-     * @return The (read-only) properties, never {@code null}.
-     */
-    Map<String, String> getProperties();
-
-    /**
-     * Sets the properties for the metadata.
-     * 
-     * @param properties The properties for the metadata, may be {@code null}.
-     * @return The new metadata, never {@code null}.
-     */
-    Metadata setProperties( Map<String, String> properties );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/metadata/package-info.java
deleted file mode 100644 (file)
index 141a837..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The definition of metadata, that is an auxiliary entity managed by the repository system to locate artifacts.
- */
-package org.eclipse.aether.metadata;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/package-info.java
deleted file mode 100644 (file)
index 7268b46..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The primary API of the {@link org.eclipse.aether.RepositorySystem} and its functionality.
- */
-package org.eclipse.aether;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/ArtifactRepository.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/ArtifactRepository.java
deleted file mode 100644 (file)
index 2000f8b..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-/**
- * A repository hosting artifacts.
- * 
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface ArtifactRepository
-{
-
-    /**
-     * Gets the type of the repository, for example "default".
-     * 
-     * @return The (case-sensitive) type of the repository, never {@code null}.
-     */
-    String getContentType();
-
-    /**
-     * Gets the identifier of this repository.
-     * 
-     * @return The (case-sensitive) identifier, never {@code null}.
-     */
-    String getId();
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/Authentication.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/Authentication.java
deleted file mode 100644 (file)
index c1eaac0..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.util.Map;
-
-/**
- * The authentication to use for accessing a protected resource. This acts basically as an extensible callback mechanism
- * from which network operations can request authentication data like username and password when needed.
- */
-public interface Authentication
-{
-
-    /**
-     * Fills the given authentication context with the data from this authentication callback. To do so, implementors
-     * have to call {@link AuthenticationContext#put(String, Object)}. <br>
-     * <br>
-     * The {@code key} parameter supplied to this method acts merely as a hint for interactive callbacks that want to
-     * prompt the user for only that authentication data which is required. Implementations are free to ignore this
-     * parameter and put all the data they have into the authentication context at once.
-     * 
-     * @param context The authentication context to populate, must not be {@code null}.
-     * @param key The key denoting a specific piece of authentication data that is being requested for a network
-     *            operation, may be {@code null}.
-     * @param data Any (read-only) extra data in form of key value pairs that might be useful when getting the
-     *            authentication data, may be {@code null}.
-     */
-    void fill( AuthenticationContext context, String key, Map<String, String> data );
-
-    /**
-     * Updates the given digest with data from this authentication callback. To do so, implementors have to call the
-     * {@code update()} methods in {@link AuthenticationDigest}.
-     * 
-     * @param digest The digest to update, must not be {@code null}.
-     */
-    void digest( AuthenticationDigest digest );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationContext.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationContext.java
deleted file mode 100644 (file)
index 5b1ba2c..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.io.Closeable;
-import java.io.File;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * A glorified map of key value pairs holding (cleartext) authentication data. Authentication contexts are used
- * internally when network operations need to access secured repositories or proxies. Each authentication context
- * manages the credentials required to access a single host. Unlike {@link Authentication} callbacks which exist for a
- * potentially long time like the duration of a repository system session, an authentication context has a supposedly
- * short lifetime and should be {@link #close() closed} as soon as the corresponding network operation has finished:
- * 
- * <pre>
- * AuthenticationContext context = AuthenticationContext.forRepository( session, repository );
- * try {
- *     // get credentials
- *     char[] password = context.get( AuthenticationContext.PASSWORD, char[].class );
- *     // perform network operation using retrieved credentials
- *     ...
- * } finally {
- *     // erase confidential authentication data from heap memory
- *     AuthenticationContext.close( context );
- * }
- * </pre>
- * 
- * The same authentication data can often be presented using different data types, e.g. a password can be presented
- * using a character array or (less securely) using a string. For ease of use, an authentication context treats the
- * following groups of data types as equivalent and converts values automatically during retrieval:
- * <ul>
- * <li>{@code String}, {@code char[]}</li>
- * <li>{@code String}, {@code File}</li>
- * </ul>
- * An authentication context is thread-safe.
- */
-public final class AuthenticationContext
-    implements Closeable
-{
-
-    /**
-     * The key used to store the username. The corresponding authentication data should be of type {@link String}.
-     */
-    public static final String USERNAME = "username";
-
-    /**
-     * The key used to store the password. The corresponding authentication data should be of type {@code char[]} or
-     * {@link String}.
-     */
-    public static final String PASSWORD = "password";
-
-    /**
-     * The key used to store the NTLM domain. The corresponding authentication data should be of type {@link String}.
-     */
-    public static final String NTLM_DOMAIN = "ntlm.domain";
-
-    /**
-     * The key used to store the NTML workstation. The corresponding authentication data should be of type
-     * {@link String}.
-     */
-    public static final String NTLM_WORKSTATION = "ntlm.workstation";
-
-    /**
-     * The key used to store the pathname to a private key file. The corresponding authentication data should be of type
-     * {@link String} or {@link File}.
-     */
-    public static final String PRIVATE_KEY_PATH = "privateKey.path";
-
-    /**
-     * The key used to store the passphrase protecting the private key. The corresponding authentication data should be
-     * of type {@code char[]} or {@link String}.
-     */
-    public static final String PRIVATE_KEY_PASSPHRASE = "privateKey.passphrase";
-
-    /**
-     * The key used to store the acceptance policy for unknown host keys. The corresponding authentication data should
-     * be of type {@link Boolean}. When querying this authentication data, the extra data should provide
-     * {@link #HOST_KEY_REMOTE} and {@link #HOST_KEY_LOCAL}, e.g. to enable a well-founded decision of the user during
-     * an interactive prompt.
-     */
-    public static final String HOST_KEY_ACCEPTANCE = "hostKey.acceptance";
-
-    /**
-     * The key used to store the fingerprint of the public key advertised by remote host. Note that this key is used to
-     * query the extra data passed to {@link #get(String, Map, Class)} when getting {@link #HOST_KEY_ACCEPTANCE}, not
-     * the authentication data in a context.
-     */
-    public static final String HOST_KEY_REMOTE = "hostKey.remote";
-
-    /**
-     * The key used to store the fingerprint of the public key expected from remote host as recorded in a known hosts
-     * database. Note that this key is used to query the extra data passed to {@link #get(String, Map, Class)} when
-     * getting {@link #HOST_KEY_ACCEPTANCE}, not the authentication data in a context.
-     */
-    public static final String HOST_KEY_LOCAL = "hostKey.local";
-
-    /**
-     * The key used to store the SSL context. The corresponding authentication data should be of type
-     * {@link javax.net.ssl.SSLContext}.
-     */
-    public static final String SSL_CONTEXT = "ssl.context";
-
-    /**
-     * The key used to store the SSL hostname verifier. The corresponding authentication data should be of type
-     * {@link javax.net.ssl.HostnameVerifier}.
-     */
-    public static final String SSL_HOSTNAME_VERIFIER = "ssl.hostnameVerifier";
-
-    private final RepositorySystemSession session;
-
-    private final RemoteRepository repository;
-
-    private final Proxy proxy;
-
-    private final Authentication auth;
-
-    private final Map<String, Object> authData;
-
-    private boolean fillingAuthData;
-
-    /**
-     * Gets an authentication context for the specified repository.
-     * 
-     * @param session The repository system session during which the repository is accessed, must not be {@code null}.
-     * @param repository The repository for which to create an authentication context, must not be {@code null}.
-     * @return An authentication context for the repository or {@code null} if no authentication is configured for it.
-     */
-    public static AuthenticationContext forRepository( RepositorySystemSession session, RemoteRepository repository )
-    {
-        return newInstance( session, repository, null, repository.getAuthentication() );
-    }
-
-    /**
-     * Gets an authentication context for the proxy of the specified repository.
-     * 
-     * @param session The repository system session during which the repository is accessed, must not be {@code null}.
-     * @param repository The repository for whose proxy to create an authentication context, must not be {@code null}.
-     * @return An authentication context for the proxy or {@code null} if no proxy is set or no authentication is
-     *         configured for it.
-     */
-    public static AuthenticationContext forProxy( RepositorySystemSession session, RemoteRepository repository )
-    {
-        Proxy proxy = repository.getProxy();
-        return newInstance( session, repository, proxy, ( proxy != null ) ? proxy.getAuthentication() : null );
-    }
-
-    private static AuthenticationContext newInstance( RepositorySystemSession session, RemoteRepository repository,
-                                                      Proxy proxy, Authentication auth )
-    {
-        if ( auth == null )
-        {
-            return null;
-        }
-        return new AuthenticationContext( session, repository, proxy, auth );
-    }
-
-    private AuthenticationContext( RepositorySystemSession session, RemoteRepository repository, Proxy proxy,
-                                   Authentication auth )
-    {
-        if ( session == null )
-        {
-            throw new IllegalArgumentException( "repository system session missing" );
-        }
-        this.session = session;
-        this.repository = repository;
-        this.proxy = proxy;
-        this.auth = auth;
-        authData = new HashMap<String, Object>();
-    }
-
-    /**
-     * Gets the repository system session during which the authentication happens.
-     * 
-     * @return The repository system session, never {@code null}.
-     */
-    public RepositorySystemSession getSession()
-    {
-        return session;
-    }
-
-    /**
-     * Gets the repository requiring authentication. If {@link #getProxy()} is not {@code null}, the data gathered by
-     * this authentication context does not apply to the repository's host but rather the proxy.
-     * 
-     * @return The repository to be contacted, never {@code null}.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Gets the proxy (if any) to be authenticated with.
-     * 
-     * @return The proxy or {@code null} if authenticating directly with the repository's host.
-     */
-    public Proxy getProxy()
-    {
-        return proxy;
-    }
-
-    /**
-     * Gets the authentication data for the specified key.
-     * 
-     * @param key The key whose authentication data should be retrieved, must not be {@code null}.
-     * @return The requested authentication data or {@code null} if none.
-     */
-    public String get( String key )
-    {
-        return get( key, null, String.class );
-    }
-
-    /**
-     * Gets the authentication data for the specified key.
-     * 
-     * @param <T> The data type of the authentication data.
-     * @param key The key whose authentication data should be retrieved, must not be {@code null}.
-     * @param type The expected type of the authentication data, must not be {@code null}.
-     * @return The requested authentication data or {@code null} if none or if the data doesn't match the expected type.
-     */
-    public <T> T get( String key, Class<T> type )
-    {
-        return get( key, null, type );
-    }
-
-    /**
-     * Gets the authentication data for the specified key.
-     * 
-     * @param <T> The data type of the authentication data.
-     * @param key The key whose authentication data should be retrieved, must not be {@code null}.
-     * @param data Any (read-only) extra data in form of key value pairs that might be useful when getting the
-     *            authentication data, may be {@code null}.
-     * @param type The expected type of the authentication data, must not be {@code null}.
-     * @return The requested authentication data or {@code null} if none or if the data doesn't match the expected type.
-     */
-    public <T> T get( String key, Map<String, String> data, Class<T> type )
-    {
-        if ( key == null )
-        {
-            throw new IllegalArgumentException( "authentication data key missing" );
-        }
-        Object value;
-        synchronized ( authData )
-        {
-            value = authData.get( key );
-            if ( value == null && !authData.containsKey( key ) && !fillingAuthData )
-            {
-                if ( auth != null )
-                {
-                    try
-                    {
-                        fillingAuthData = true;
-                        auth.fill( this, key, data );
-                    }
-                    finally
-                    {
-                        fillingAuthData = false;
-                    }
-                    value = authData.get( key );
-                }
-                if ( value == null )
-                {
-                    authData.put( key, value );
-                }
-            }
-        }
-
-        return convert( value, type );
-    }
-
-    private <T> T convert( Object value, Class<T> type )
-    {
-        if ( !type.isInstance( value ) )
-        {
-            if ( String.class.equals( type ) )
-            {
-                if ( value instanceof File )
-                {
-                    value = ( (File) value ).getPath();
-                }
-                else if ( value instanceof char[] )
-                {
-                    value = new String( (char[]) value );
-                }
-            }
-            else if ( File.class.equals( type ) )
-            {
-                if ( value instanceof String )
-                {
-                    value = new File( (String) value );
-                }
-            }
-            else if ( char[].class.equals( type ) )
-            {
-                if ( value instanceof String )
-                {
-                    value = ( (String) value ).toCharArray();
-                }
-            }
-        }
-
-        if ( type.isInstance( value ) )
-        {
-            return type.cast( value );
-        }
-
-        return null;
-    }
-
-    /**
-     * Puts the specified authentication data into this context. This method should only be called from implementors of
-     * {@link Authentication#fill(AuthenticationContext, String, Map)}. Passed in character arrays are not cloned and
-     * become owned by this context, i.e. get erased when the context gets closed.
-     * 
-     * @param key The key to associate the authentication data with, must not be {@code null}.
-     * @param value The (cleartext) authentication data to store, may be {@code null}.
-     */
-    public void put( String key, Object value )
-    {
-        if ( key == null )
-        {
-            throw new IllegalArgumentException( "authentication data key missing" );
-        }
-        synchronized ( authData )
-        {
-            Object oldValue = authData.put( key, value );
-            if ( oldValue instanceof char[] )
-            {
-                Arrays.fill( (char[]) oldValue, '\0' );
-            }
-        }
-    }
-
-    /**
-     * Closes this authentication context and erases sensitive authentication data from heap memory. Closing an already
-     * closed context has no effect.
-     */
-    public void close()
-    {
-        synchronized ( authData )
-        {
-            for ( Object value : authData.values() )
-            {
-                if ( value instanceof char[] )
-                {
-                    Arrays.fill( (char[]) value, '\0' );
-                }
-            }
-            authData.clear();
-        }
-    }
-
-    /**
-     * Closes the specified authentication context. This is a convenience method doing a {@code null} check before
-     * calling {@link #close()} on the given context.
-     * 
-     * @param context The authentication context to close, may be {@code null}.
-     */
-    public static void close( AuthenticationContext context )
-    {
-        if ( context != null )
-        {
-            context.close();
-        }
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationDigest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationDigest.java
deleted file mode 100644 (file)
index f702b4a..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.io.UnsupportedEncodingException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * A helper to calculate a fingerprint/digest for the authentication data of a repository/proxy. Such a fingerprint can
- * be used to detect changes in the authentication data across JVM restarts without exposing sensitive information.
- */
-public final class AuthenticationDigest
-{
-
-    private final MessageDigest digest;
-
-    private final RepositorySystemSession session;
-
-    private final RemoteRepository repository;
-
-    private final Proxy proxy;
-
-    /**
-     * Gets the fingerprint for the authentication of the specified repository.
-     * 
-     * @param session The repository system session during which the fingerprint is requested, must not be {@code null}.
-     * @param repository The repository whose authentication is to be fingerprinted, must not be {@code null}.
-     * @return The fingerprint of the repository authentication or an empty string if no authentication is configured,
-     *         never {@code null}.
-     */
-    public static String forRepository( RepositorySystemSession session, RemoteRepository repository )
-    {
-        String digest = "";
-        Authentication auth = repository.getAuthentication();
-        if ( auth != null )
-        {
-            AuthenticationDigest authDigest = new AuthenticationDigest( session, repository, null );
-            auth.digest( authDigest );
-            digest = authDigest.digest();
-        }
-        return digest;
-    }
-
-    /**
-     * Gets the fingerprint for the authentication of the specified repository's proxy.
-     * 
-     * @param session The repository system session during which the fingerprint is requested, must not be {@code null}.
-     * @param repository The repository whose proxy authentication is to be fingerprinted, must not be {@code null}.
-     * @return The fingerprint of the proxy authentication or an empty string if no proxy is present or if no proxy
-     *         authentication is configured, never {@code null}.
-     */
-    public static String forProxy( RepositorySystemSession session, RemoteRepository repository )
-    {
-        String digest = "";
-        Proxy proxy = repository.getProxy();
-        if ( proxy != null )
-        {
-            Authentication auth = proxy.getAuthentication();
-            if ( auth != null )
-            {
-                AuthenticationDigest authDigest = new AuthenticationDigest( session, repository, proxy );
-                auth.digest( authDigest );
-                digest = authDigest.digest();
-            }
-        }
-        return digest;
-    }
-
-    private AuthenticationDigest( RepositorySystemSession session, RemoteRepository repository, Proxy proxy )
-    {
-        this.session = session;
-        this.repository = repository;
-        this.proxy = proxy;
-        digest = newDigest();
-    }
-
-    private static MessageDigest newDigest()
-    {
-        try
-        {
-            return MessageDigest.getInstance( "SHA-1" );
-        }
-        catch ( NoSuchAlgorithmException e )
-        {
-            try
-            {
-                return MessageDigest.getInstance( "MD5" );
-            }
-            catch ( NoSuchAlgorithmException ne )
-            {
-                throw new IllegalStateException( ne );
-            }
-        }
-    }
-
-    /**
-     * Gets the repository system session during which the authentication fingerprint is calculated.
-     * 
-     * @return The repository system session, never {@code null}.
-     */
-    public RepositorySystemSession getSession()
-    {
-        return session;
-    }
-
-    /**
-     * Gets the repository requiring authentication. If {@link #getProxy()} is not {@code null}, the data gathered by
-     * this authentication digest does not apply to the repository's host but rather the proxy.
-     * 
-     * @return The repository to be contacted, never {@code null}.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Gets the proxy (if any) to be authenticated with.
-     * 
-     * @return The proxy or {@code null} if authenticating directly with the repository's host.
-     */
-    public Proxy getProxy()
-    {
-        return proxy;
-    }
-
-    /**
-     * Updates the digest with the specified strings.
-     * 
-     * @param strings The strings to update the digest with, may be {@code null} or contain {@code null} elements.
-     */
-    public void update( String... strings )
-    {
-        if ( strings != null )
-        {
-            for ( String string : strings )
-            {
-                if ( string != null )
-                {
-                    try
-                    {
-                        digest.update( string.getBytes( "UTF-8" ) );
-                    }
-                    catch ( UnsupportedEncodingException e )
-                    {
-                        throw new IllegalStateException( e );
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * Updates the digest with the specified characters.
-     * 
-     * @param chars The characters to update the digest with, may be {@code null}.
-     */
-    public void update( char... chars )
-    {
-        if ( chars != null )
-        {
-            for ( char c : chars )
-            {
-                digest.update( (byte) ( c >> 8 ) );
-                digest.update( (byte) ( c & 0xFF ) );
-            }
-        }
-    }
-
-    /**
-     * Updates the digest with the specified bytes.
-     * 
-     * @param bytes The bytes to update the digest with, may be {@code null}.
-     */
-    public void update( byte... bytes )
-    {
-        if ( bytes != null )
-        {
-            digest.update( bytes );
-        }
-    }
-
-    private String digest()
-    {
-        byte[] bytes = digest.digest();
-        StringBuilder buffer = new StringBuilder( bytes.length * 2 );
-        for ( byte aByte : bytes )
-        {
-            int b = aByte & 0xFF;
-            if ( b < 0x10 )
-            {
-                buffer.append( '0' );
-            }
-            buffer.append( Integer.toHexString( b ) );
-        }
-        return buffer.toString();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationSelector.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationSelector.java
deleted file mode 100644 (file)
index 46c9bab..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-/**
- * Selects authentication for a given remote repository.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getAuthenticationSelector()
- */
-public interface AuthenticationSelector
-{
-
-    /**
-     * Selects authentication for the specified remote repository.
-     * 
-     * @param repository The repository for which to select authentication, must not be {@code null}.
-     * @return The selected authentication or {@code null} if none.
-     */
-    Authentication getAuthentication( RemoteRepository repository );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRegistration.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRegistration.java
deleted file mode 100644 (file)
index af6ea4e..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * A request to register an artifact within the local repository. Certain local repository implementations can refuse to
- * serve physically present artifacts if those haven't been previously registered to them.
- * 
- * @see LocalRepositoryManager#add(RepositorySystemSession, LocalArtifactRegistration)
- */
-public final class LocalArtifactRegistration
-{
-
-    private Artifact artifact;
-
-    private RemoteRepository repository;
-
-    private Collection<String> contexts = Collections.emptyList();
-
-    /**
-     * Creates an uninitialized registration.
-     */
-    public LocalArtifactRegistration()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a registration request for the specified (locally installed) artifact.
-     * 
-     * @param artifact The artifact to register, may be {@code null}.
-     */
-    public LocalArtifactRegistration( Artifact artifact )
-    {
-        setArtifact( artifact );
-    }
-
-    /**
-     * Creates a registration request for the specified artifact.
-     * 
-     * @param artifact The artifact to register, may be {@code null}.
-     * @param repository The remote repository from which the artifact was resolved or {@code null} if the artifact was
-     *            locally installed.
-     * @param contexts The resolution contexts, may be {@code null}.
-     */
-    public LocalArtifactRegistration( Artifact artifact, RemoteRepository repository, Collection<String> contexts )
-    {
-        setArtifact( artifact );
-        setRepository( repository );
-        setContexts( contexts );
-    }
-
-    /**
-     * Gets the artifact to register.
-     * 
-     * @return The artifact or {@code null} if not set.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the artifact to register.
-     * 
-     * @param artifact The artifact, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public LocalArtifactRegistration setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-        return this;
-    }
-
-    /**
-     * Gets the remote repository from which the artifact was resolved.
-     * 
-     * @return The remote repository or {@code null} if the artifact was locally installed.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the remote repository from which the artifact was resolved.
-     * 
-     * @param repository The remote repository or {@code null} if the artifact was locally installed.
-     * @return This request for chaining, never {@code null}.
-     */
-    public LocalArtifactRegistration setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    /**
-     * Gets the resolution contexts in which the artifact is available.
-     * 
-     * @return The resolution contexts in which the artifact is available, never {@code null}.
-     */
-    public Collection<String> getContexts()
-    {
-        return contexts;
-    }
-
-    /**
-     * Sets the resolution contexts in which the artifact is available.
-     * 
-     * @param contexts The resolution contexts, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public LocalArtifactRegistration setContexts( Collection<String> contexts )
-    {
-        if ( contexts != null )
-        {
-            this.contexts = contexts;
-        }
-        else
-        {
-            this.contexts = Collections.emptyList();
-        }
-        return this;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRequest.java
deleted file mode 100644 (file)
index 3cc67f8..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * A query to the local repository for the existence of an artifact.
- * 
- * @see LocalRepositoryManager#find(RepositorySystemSession, LocalArtifactRequest)
- */
-public final class LocalArtifactRequest
-{
-
-    private Artifact artifact;
-
-    private String context = "";
-
-    private List<RemoteRepository> repositories = Collections.emptyList();
-
-    /**
-     * Creates an uninitialized query.
-     */
-    public LocalArtifactRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a query with the specified properties.
-     * 
-     * @param artifact The artifact to query for, may be {@code null}.
-     * @param repositories The remote repositories that should be considered as potential sources for the artifact, may
-     *            be {@code null} or empty to only consider locally installed artifacts.
-     * @param context The resolution context for the artifact, may be {@code null}.
-     */
-    public LocalArtifactRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
-    {
-        setArtifact( artifact );
-        setRepositories( repositories );
-        setContext( context );
-    }
-
-    /**
-     * Gets the artifact to query for.
-     * 
-     * @return The artifact or {@code null} if not set.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the artifact to query for.
-     * 
-     * @param artifact The artifact, may be {@code null}.
-     * @return This query for chaining, never {@code null}.
-     */
-    public LocalArtifactRequest setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-        return this;
-    }
-
-    /**
-     * Gets the resolution context.
-     * 
-     * @return The resolution context, never {@code null}.
-     */
-    public String getContext()
-    {
-        return context;
-    }
-
-    /**
-     * Sets the resolution context.
-     * 
-     * @param context The resolution context, may be {@code null}.
-     * @return This query for chaining, never {@code null}.
-     */
-    public LocalArtifactRequest setContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-        return this;
-    }
-
-    /**
-     * Gets the remote repositories to consider as sources of the artifact.
-     * 
-     * @return The remote repositories, never {@code null}.
-     */
-    public List<RemoteRepository> getRepositories()
-    {
-        return repositories;
-    }
-
-    /**
-     * Sets the remote repositories to consider as sources of the artifact.
-     * 
-     * @param repositories The remote repositories, may be {@code null} or empty to only consider locally installed
-     *            artifacts.
-     * @return This query for chaining, never {@code null}.
-     */
-    public LocalArtifactRequest setRepositories( List<RemoteRepository> repositories )
-    {
-        if ( repositories != null )
-        {
-            this.repositories = repositories;
-        }
-        else
-        {
-            this.repositories = Collections.emptyList();
-        }
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifact() + " @ " + getRepositories();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactResult.java
deleted file mode 100644 (file)
index 065b823..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.io.File;
-
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * A result from the local repository about the existence of an artifact.
- * 
- * @see LocalRepositoryManager#find(RepositorySystemSession, LocalArtifactRequest)
- */
-public final class LocalArtifactResult
-{
-
-    private final LocalArtifactRequest request;
-
-    private File file;
-
-    private boolean available;
-
-    private RemoteRepository repository;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The local artifact request, must not be {@code null}.
-     */
-    public LocalArtifactResult( LocalArtifactRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "local artifact request has not been specified" );
-        }
-        this.request = request;
-    }
-
-    /**
-     * Gets the request corresponding to this result.
-     * 
-     * @return The corresponding request, never {@code null}.
-     */
-    public LocalArtifactRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the file to the requested artifact. Note that this file must not be used unless {@link #isAvailable()}
-     * returns {@code true}. An artifact file can be found but considered unavailable if the artifact was cached from a
-     * remote repository that is not part of the list of remote repositories used for the query.
-     * 
-     * @return The file to the requested artifact or {@code null} if the artifact does not exist locally.
-     */
-    public File getFile()
-    {
-        return file;
-    }
-
-    /**
-     * Sets the file to requested artifact.
-     * 
-     * @param file The artifact file, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public LocalArtifactResult setFile( File file )
-    {
-        this.file = file;
-        return this;
-    }
-
-    /**
-     * Indicates whether the requested artifact is available for use. As a minimum, the file needs to be physically
-     * existent in the local repository to be available. Additionally, a local repository manager can consider the list
-     * of supplied remote repositories to determine whether the artifact is logically available and mark an artifact
-     * unavailable (despite its physical existence) if it is not known to be hosted by any of the provided repositories.
-     * 
-     * @return {@code true} if the artifact is available, {@code false} otherwise.
-     * @see LocalArtifactRequest#getRepositories()
-     */
-    public boolean isAvailable()
-    {
-        return available;
-    }
-
-    /**
-     * Sets whether the artifact is available.
-     * 
-     * @param available {@code true} if the artifact is available, {@code false} otherwise.
-     * @return This result for chaining, never {@code null}.
-     */
-    public LocalArtifactResult setAvailable( boolean available )
-    {
-        this.available = available;
-        return this;
-    }
-
-    /**
-     * Gets the (first) remote repository from which the artifact was cached (if any).
-     * 
-     * @return The remote repository from which the artifact was originally retrieved or {@code null} if unknown or if
-     *         the artifact has been locally installed.
-     * @see LocalArtifactRequest#getRepositories()
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the (first) remote repository from which the artifact was cached.
-     * 
-     * @param repository The remote repository from which the artifact was originally retrieved, may be {@code null} if
-     *            unknown or if the artifact has been locally installed.
-     * @return This result for chaining, never {@code null}.
-     */
-    public LocalArtifactResult setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getFile() + " (" + ( isAvailable() ? "available" : "unavailable" ) + ")";
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRegistration.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRegistration.java
deleted file mode 100644 (file)
index a01ba3e..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * A request to register metadata within the local repository.
- * 
- * @see LocalRepositoryManager#add(RepositorySystemSession, LocalMetadataRegistration)
- */
-public final class LocalMetadataRegistration
-{
-
-    private Metadata metadata;
-
-    private RemoteRepository repository;
-
-    private Collection<String> contexts = Collections.emptyList();
-
-    /**
-     * Creates an uninitialized registration.
-     */
-    public LocalMetadataRegistration()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a registration request for the specified metadata accompanying a locally installed artifact.
-     * 
-     * @param metadata The metadata to register, may be {@code null}.
-     */
-    public LocalMetadataRegistration( Metadata metadata )
-    {
-        setMetadata( metadata );
-    }
-
-    /**
-     * Creates a registration request for the specified metadata.
-     * 
-     * @param metadata The metadata to register, may be {@code null}.
-     * @param repository The remote repository from which the metadata was resolved or {@code null} if the metadata
-     *            accompanies a locally installed artifact.
-     * @param contexts The resolution contexts, may be {@code null}.
-     */
-    public LocalMetadataRegistration( Metadata metadata, RemoteRepository repository, Collection<String> contexts )
-    {
-        setMetadata( metadata );
-        setRepository( repository );
-        setContexts( contexts );
-    }
-
-    /**
-     * Gets the metadata to register.
-     * 
-     * @return The metadata or {@code null} if not set.
-     */
-    public Metadata getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Sets the metadata to register.
-     * 
-     * @param metadata The metadata, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public LocalMetadataRegistration setMetadata( Metadata metadata )
-    {
-        this.metadata = metadata;
-        return this;
-    }
-
-    /**
-     * Gets the remote repository from which the metadata was resolved.
-     * 
-     * @return The remote repository or {@code null} if the metadata was locally installed.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the remote repository from which the metadata was resolved.
-     * 
-     * @param repository The remote repository or {@code null} if the metadata accompanies a locally installed artifact.
-     * @return This request for chaining, never {@code null}.
-     */
-    public LocalMetadataRegistration setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    /**
-     * Gets the resolution contexts in which the metadata is available.
-     * 
-     * @return The resolution contexts in which the metadata is available, never {@code null}.
-     */
-    public Collection<String> getContexts()
-    {
-        return contexts;
-    }
-
-    /**
-     * Sets the resolution contexts in which the metadata is available.
-     * 
-     * @param contexts The resolution contexts, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public LocalMetadataRegistration setContexts( Collection<String> contexts )
-    {
-        if ( contexts != null )
-        {
-            this.contexts = contexts;
-        }
-        else
-        {
-            this.contexts = Collections.emptyList();
-        }
-        return this;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRequest.java
deleted file mode 100644 (file)
index 0ee4dc5..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * A query to the local repository for the existence of metadata.
- * 
- * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest)
- */
-public final class LocalMetadataRequest
-{
-
-    private Metadata metadata;
-
-    private String context = "";
-
-    private RemoteRepository repository = null;
-
-    /**
-     * Creates an uninitialized query.
-     */
-    public LocalMetadataRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a query with the specified properties.
-     * 
-     * @param metadata The metadata to query for, may be {@code null}.
-     * @param repository The source remote repository for the metadata, may be {@code null} for local metadata.
-     * @param context The resolution context for the metadata, may be {@code null}.
-     */
-    public LocalMetadataRequest( Metadata metadata, RemoteRepository repository, String context )
-    {
-        setMetadata( metadata );
-        setRepository( repository );
-        setContext( context );
-    }
-
-    /**
-     * Gets the metadata to query for.
-     * 
-     * @return The metadata or {@code null} if not set.
-     */
-    public Metadata getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Sets the metadata to query for.
-     * 
-     * @param metadata The metadata, may be {@code null}.
-     * @return This query for chaining, never {@code null}.
-     */
-    public LocalMetadataRequest setMetadata( Metadata metadata )
-    {
-        this.metadata = metadata;
-        return this;
-    }
-
-    /**
-     * Gets the resolution context.
-     * 
-     * @return The resolution context, never {@code null}.
-     */
-    public String getContext()
-    {
-        return context;
-    }
-
-    /**
-     * Sets the resolution context.
-     * 
-     * @param context The resolution context, may be {@code null}.
-     * @return This query for chaining, never {@code null}.
-     */
-    public LocalMetadataRequest setContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-        return this;
-    }
-
-    /**
-     * Gets the remote repository to use as source of the metadata.
-     * 
-     * @return The remote repositories, may be {@code null} for local metadata.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the remote repository to use as sources of the metadata.
-     * 
-     * @param repository The remote repository, may be {@code null}.
-     * @return This query for chaining, may be {@code null} for local metadata.
-     */
-    public LocalMetadataRequest setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getMetadata() + " @ " + getRepository();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataResult.java
deleted file mode 100644 (file)
index 6f3687a..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.io.File;
-
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * A result from the local repository about the existence of metadata.
- * 
- * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest)
- */
-public final class LocalMetadataResult
-{
-
-    private final LocalMetadataRequest request;
-
-    private File file;
-
-    private boolean stale;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The local metadata request, must not be {@code null}.
-     */
-    public LocalMetadataResult( LocalMetadataRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "local metadata request has not been specified" );
-        }
-        this.request = request;
-    }
-
-    /**
-     * Gets the request corresponding to this result.
-     * 
-     * @return The corresponding request, never {@code null}.
-     */
-    public LocalMetadataRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the file to the requested metadata if the metadata is available in the local repository.
-     * 
-     * @return The file to the requested metadata or {@code null}.
-     */
-    public File getFile()
-    {
-        return file;
-    }
-
-    /**
-     * Sets the file to requested metadata.
-     * 
-     * @param file The metadata file, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public LocalMetadataResult setFile( File file )
-    {
-        this.file = file;
-        return this;
-    }
-
-    /**
-     * This value indicates whether the metadata is stale and should be updated.
-     * 
-     * @return {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
-     */
-    public boolean isStale()
-    {
-        return stale;
-    }
-
-    /**
-     * Sets whether the metadata is stale.
-     * 
-     * @param stale {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
-     * @return This result for chaining, never {@code null}.
-     */
-    public LocalMetadataResult setStale( boolean stale )
-    {
-        this.stale = stale;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return request.toString() + "(" + getFile() + ")";
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepository.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepository.java
deleted file mode 100644 (file)
index 91b09d8..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.io.File;
-
-/**
- * A repository on the local file system used to cache contents of remote repositories and to store locally installed
- * artifacts. Note that this class merely describes such a repository, actual access to the contained artifacts is
- * handled by a {@link LocalRepositoryManager} which is usually determined from the {@link #getContentType() type} of
- * the repository.
- */
-public final class LocalRepository
-    implements ArtifactRepository
-{
-
-    private final File basedir;
-
-    private final String type;
-
-    /**
-     * Creates a new local repository with the specified base directory and unknown type.
-     * 
-     * @param basedir The base directory of the repository, may be {@code null}.
-     */
-    public LocalRepository( String basedir )
-    {
-        this( ( basedir != null ) ? new File( basedir ) : null, "" );
-    }
-
-    /**
-     * Creates a new local repository with the specified base directory and unknown type.
-     * 
-     * @param basedir The base directory of the repository, may be {@code null}.
-     */
-    public LocalRepository( File basedir )
-    {
-        this( basedir, "" );
-    }
-
-    /**
-     * Creates a new local repository with the specified properties.
-     * 
-     * @param basedir The base directory of the repository, may be {@code null}.
-     * @param type The type of the repository, may be {@code null}.
-     */
-    public LocalRepository( File basedir, String type )
-    {
-        this.basedir = basedir;
-        this.type = ( type != null ) ? type : "";
-    }
-
-    public String getContentType()
-    {
-        return type;
-    }
-
-    public String getId()
-    {
-        return "local";
-    }
-
-    /**
-     * Gets the base directory of the repository.
-     * 
-     * @return The base directory or {@code null} if none.
-     */
-    public File getBasedir()
-    {
-        return basedir;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getBasedir() + " (" + getContentType() + ")";
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( this == obj )
-        {
-            return true;
-        }
-        if ( obj == null || !getClass().equals( obj.getClass() ) )
-        {
-            return false;
-        }
-
-        LocalRepository that = (LocalRepository) obj;
-
-        return eq( basedir, that.basedir ) && eq( type, that.type );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = 17;
-        hash = hash * 31 + hash( basedir );
-        hash = hash * 31 + hash( type );
-        return hash;
-    }
-
-    private static int hash( Object obj )
-    {
-        return obj != null ? obj.hashCode() : 0;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepositoryManager.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepositoryManager.java
deleted file mode 100644 (file)
index d9d8777..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * Manages access to a local repository.
- * 
- * @see RepositorySystemSession#getLocalRepositoryManager()
- * @see org.eclipse.aether.RepositorySystem#newLocalRepositoryManager(RepositorySystemSession, LocalRepository)
- */
-public interface LocalRepositoryManager
-{
-
-    /**
-     * Gets the description of the local repository being managed.
-     * 
-     * @return The description of the local repository, never {@code null}.
-     */
-    LocalRepository getRepository();
-
-    /**
-     * Gets the relative path for a locally installed artifact. Note that the artifact need not actually exist yet at
-     * the returned location, the path merely indicates where the artifact would eventually be stored. The path uses the
-     * forward slash as directory separator regardless of the underlying file system.
-     * 
-     * @param artifact The artifact for which to determine the path, must not be {@code null}.
-     * @return The path, relative to the local repository's base directory.
-     */
-    String getPathForLocalArtifact( Artifact artifact );
-
-    /**
-     * Gets the relative path for an artifact cached from a remote repository. Note that the artifact need not actually
-     * exist yet at the returned location, the path merely indicates where the artifact would eventually be stored. The
-     * path uses the forward slash as directory separator regardless of the underlying file system.
-     * 
-     * @param artifact The artifact for which to determine the path, must not be {@code null}.
-     * @param repository The source repository of the artifact, must not be {@code null}.
-     * @param context The resolution context in which the artifact is being requested, may be {@code null}.
-     * @return The path, relative to the local repository's base directory.
-     */
-    String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context );
-
-    /**
-     * Gets the relative path for locally installed metadata. Note that the metadata need not actually exist yet at the
-     * returned location, the path merely indicates where the metadata would eventually be stored. The path uses the
-     * forward slash as directory separator regardless of the underlying file system.
-     * 
-     * @param metadata The metadata for which to determine the path, must not be {@code null}.
-     * @return The path, relative to the local repository's base directory.
-     */
-    String getPathForLocalMetadata( Metadata metadata );
-
-    /**
-     * Gets the relative path for metadata cached from a remote repository. Note that the metadata need not actually
-     * exist yet at the returned location, the path merely indicates where the metadata would eventually be stored. The
-     * path uses the forward slash as directory separator regardless of the underlying file system.
-     * 
-     * @param metadata The metadata for which to determine the path, must not be {@code null}.
-     * @param repository The source repository of the metadata, must not be {@code null}.
-     * @param context The resolution context in which the metadata is being requested, may be {@code null}.
-     * @return The path, relative to the local repository's base directory.
-     */
-    String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context );
-
-    /**
-     * Queries for the existence of an artifact in the local repository. The request could be satisfied by a locally
-     * installed artifact or a previously downloaded artifact.
-     * 
-     * @param session The repository system session during which the request is made, must not be {@code null}.
-     * @param request The artifact request, must not be {@code null}.
-     * @return The result of the request, never {@code null}.
-     */
-    LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request );
-
-    /**
-     * Registers an installed or resolved artifact with the local repository. Note that artifact registration is merely
-     * concerned about updating the local repository's internal state, not about actually installing the artifact or its
-     * accompanying metadata.
-     * 
-     * @param session The repository system session during which the registration is made, must not be {@code null}.
-     * @param request The registration request, must not be {@code null}.
-     */
-    void add( RepositorySystemSession session, LocalArtifactRegistration request );
-
-    /**
-     * Queries for the existence of metadata in the local repository. The request could be satisfied by locally
-     * installed or previously downloaded metadata.
-     * 
-     * @param session The repository system session during which the request is made, must not be {@code null}.
-     * @param request The metadata request, must not be {@code null}.
-     * @return The result of the request, never {@code null}.
-     */
-    LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request );
-
-    /**
-     * Registers installed or resolved metadata with the local repository. Note that metadata registration is merely
-     * concerned about updating the local repository's internal state, not about actually installing the metadata.
-     * However, this method MUST be called after the actual install to give the repository manager the opportunity to
-     * inspect the added metadata.
-     * 
-     * @param session The repository system session during which the registration is made, must not be {@code null}.
-     * @param request The registration request, must not be {@code null}.
-     */
-    void add( RepositorySystemSession session, LocalMetadataRegistration request );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/MirrorSelector.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/MirrorSelector.java
deleted file mode 100644 (file)
index 1614acc..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-/**
- * Selects a mirror for a given remote repository.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getMirrorSelector()
- */
-public interface MirrorSelector
-{
-
-    /**
-     * Selects a mirror for the specified repository.
-     * 
-     * @param repository The repository to select a mirror for, must not be {@code null}.
-     * @return The selected mirror or {@code null} if none.
-     * @see RemoteRepository#getMirroredRepositories()
-     */
-    RemoteRepository getMirror( RemoteRepository repository );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/NoLocalRepositoryManagerException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/NoLocalRepositoryManagerException.java
deleted file mode 100644 (file)
index 203ccfb..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case of an unsupported local repository type.
- */
-public class NoLocalRepositoryManagerException
-    extends RepositoryException
-{
-
-    private final transient LocalRepository repository;
-
-    /**
-     * Creates a new exception with the specified repository.
-     * 
-     * @param repository The local repository for which no support is available, may be {@code null}.
-     */
-    public NoLocalRepositoryManagerException( LocalRepository repository )
-    {
-        this( repository, toMessage( repository ) );
-    }
-
-    /**
-     * Creates a new exception with the specified repository and detail message.
-     * 
-     * @param repository The local repository for which no support is available, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public NoLocalRepositoryManagerException( LocalRepository repository, String message )
-    {
-        super( message );
-        this.repository = repository;
-    }
-
-    /**
-     * Creates a new exception with the specified repository and cause.
-     * 
-     * @param repository The local repository for which no support is available, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public NoLocalRepositoryManagerException( LocalRepository repository, Throwable cause )
-    {
-        this( repository, toMessage( repository ), cause );
-    }
-
-    /**
-     * Creates a new exception with the specified repository, detail message and cause.
-     * 
-     * @param repository The local repository for which no support is available, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public NoLocalRepositoryManagerException( LocalRepository repository, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.repository = repository;
-    }
-
-    private static String toMessage( LocalRepository repository )
-    {
-        if ( repository != null )
-        {
-            return "No manager available for local repository (" + repository.getBasedir().getAbsolutePath()
-                + ") of type " + repository.getContentType();
-        }
-        else
-        {
-            return "No manager available for local repository";
-        }
-    }
-
-    /**
-     * Gets the local repository whose content type is not supported.
-     * 
-     * @return The unsupported local repository or {@code null} if unknown.
-     */
-    public LocalRepository getRepository()
-    {
-        return repository;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/Proxy.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/Proxy.java
deleted file mode 100644 (file)
index b575bbc..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-/**
- * A proxy to use for connections to a repository.
- */
-public final class Proxy
-{
-
-    /**
-     * Type denoting a proxy for HTTP transfers.
-     */
-    public static final String TYPE_HTTP = "http";
-
-    /**
-     * Type denoting a proxy for HTTPS transfers.
-     */
-    public static final String TYPE_HTTPS = "https";
-
-    private final String type;
-
-    private final String host;
-
-    private final int port;
-
-    private final Authentication auth;
-
-    /**
-     * Creates a new proxy with the specified properties and no authentication.
-     * 
-     * @param type The type of the proxy, e.g. "http", may be {@code null}.
-     * @param host The host of the proxy, may be {@code null}.
-     * @param port The port of the proxy.
-     */
-    public Proxy( String type, String host, int port )
-    {
-        this( type, host, port, null );
-    }
-
-    /**
-     * Creates a new proxy with the specified properties.
-     * 
-     * @param type The type of the proxy, e.g. "http", may be {@code null}.
-     * @param host The host of the proxy, may be {@code null}.
-     * @param port The port of the proxy.
-     * @param auth The authentication to use for the proxy connection, may be {@code null}.
-     */
-    public Proxy( String type, String host, int port, Authentication auth )
-    {
-        this.type = ( type != null ) ? type : "";
-        this.host = ( host != null ) ? host : "";
-        this.port = port;
-        this.auth = auth;
-    }
-
-    /**
-     * Gets the type of this proxy.
-     * 
-     * @return The type of this proxy, never {@code null}.
-     */
-    public String getType()
-    {
-        return type;
-    }
-
-    /**
-     * Gets the host for this proxy.
-     * 
-     * @return The host for this proxy, never {@code null}.
-     */
-    public String getHost()
-    {
-        return host;
-    }
-
-    /**
-     * Gets the port number for this proxy.
-     * 
-     * @return The port number for this proxy.
-     */
-    public int getPort()
-    {
-        return port;
-    }
-
-    /**
-     * Gets the authentication to use for the proxy connection.
-     * 
-     * @return The authentication to use or {@code null} if none.
-     */
-    public Authentication getAuthentication()
-    {
-        return auth;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getHost() + ':' + getPort();
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( this == obj )
-        {
-            return true;
-        }
-        if ( obj == null || !getClass().equals( obj.getClass() ) )
-        {
-            return false;
-        }
-
-        Proxy that = (Proxy) obj;
-
-        return eq( type, that.type ) && eq( host, that.host ) && port == that.port && eq( auth, that.auth );
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = 17;
-        hash = hash * 31 + hash( host );
-        hash = hash * 31 + hash( type );
-        hash = hash * 31 + port;
-        hash = hash * 31 + hash( auth );
-        return hash;
-    }
-
-    private static int hash( Object obj )
-    {
-        return obj != null ? obj.hashCode() : 0;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/ProxySelector.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/ProxySelector.java
deleted file mode 100644 (file)
index 680474c..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-/**
- * Selects a proxy for a given remote repository.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getProxySelector()
- */
-public interface ProxySelector
-{
-
-    /**
-     * Selects a proxy for the specified remote repository.
-     * 
-     * @param repository The repository for which to select a proxy, must not be {@code null}.
-     * @return The selected proxy or {@code null} if none.
-     */
-    Proxy getProxy( RemoteRepository repository );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/RemoteRepository.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/RemoteRepository.java
deleted file mode 100644 (file)
index aaa9acc..0000000
+++ /dev/null
@@ -1,573 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * A repository on a remote server.
- */
-public final class RemoteRepository
-    implements ArtifactRepository
-{
-
-    private static final Pattern URL_PATTERN =
-        Pattern.compile( "([^:/]+(:[^:/]{2,}+(?=://))?):(//([^@/]*@)?([^/:]+))?.*" );
-
-    private final String id;
-
-    private final String type;
-
-    private final String url;
-
-    private final String host;
-
-    private final String protocol;
-
-    private final RepositoryPolicy releasePolicy;
-
-    private final RepositoryPolicy snapshotPolicy;
-
-    private final Proxy proxy;
-
-    private final Authentication authentication;
-
-    private final List<RemoteRepository> mirroredRepositories;
-
-    private final boolean repositoryManager;
-
-    RemoteRepository( Builder builder )
-    {
-        if ( builder.prototype != null )
-        {
-            id = ( builder.delta & Builder.ID ) != 0 ? builder.id : builder.prototype.id;
-            type = ( builder.delta & Builder.TYPE ) != 0 ? builder.type : builder.prototype.type;
-            url = ( builder.delta & Builder.URL ) != 0 ? builder.url : builder.prototype.url;
-            releasePolicy =
-                ( builder.delta & Builder.RELEASES ) != 0 ? builder.releasePolicy : builder.prototype.releasePolicy;
-            snapshotPolicy =
-                ( builder.delta & Builder.SNAPSHOTS ) != 0 ? builder.snapshotPolicy : builder.prototype.snapshotPolicy;
-            proxy = ( builder.delta & Builder.PROXY ) != 0 ? builder.proxy : builder.prototype.proxy;
-            authentication =
-                ( builder.delta & Builder.AUTH ) != 0 ? builder.authentication : builder.prototype.authentication;
-            repositoryManager =
-                ( builder.delta & Builder.REPOMAN ) != 0 ? builder.repositoryManager
-                                : builder.prototype.repositoryManager;
-            mirroredRepositories =
-                ( builder.delta & Builder.MIRRORED ) != 0 ? copy( builder.mirroredRepositories )
-                                : builder.prototype.mirroredRepositories;
-        }
-        else
-        {
-            id = builder.id;
-            type = builder.type;
-            url = builder.url;
-            releasePolicy = builder.releasePolicy;
-            snapshotPolicy = builder.snapshotPolicy;
-            proxy = builder.proxy;
-            authentication = builder.authentication;
-            repositoryManager = builder.repositoryManager;
-            mirroredRepositories = copy( builder.mirroredRepositories );
-        }
-
-        Matcher m = URL_PATTERN.matcher( url );
-        if ( m.matches() )
-        {
-            protocol = m.group( 1 );
-            String host = m.group( 5 );
-            this.host = ( host != null ) ? host : "";
-        }
-        else
-        {
-            protocol = host = "";
-        }
-    }
-
-    private static List<RemoteRepository> copy( List<RemoteRepository> repos )
-    {
-        if ( repos == null || repos.isEmpty() )
-        {
-            return Collections.emptyList();
-        }
-        return Collections.unmodifiableList( Arrays.asList( repos.toArray( new RemoteRepository[repos.size()] ) ) );
-    }
-
-    public String getId()
-    {
-        return id;
-    }
-
-    public String getContentType()
-    {
-        return type;
-    }
-
-    /**
-     * Gets the (base) URL of this repository.
-     * 
-     * @return The (base) URL of this repository, never {@code null}.
-     */
-    public String getUrl()
-    {
-        return url;
-    }
-
-    /**
-     * Gets the protocol part from the repository's URL, for example {@code file} or {@code http}. As suggested by RFC
-     * 2396, section 3.1 "Scheme Component", the protocol name should be treated case-insensitively.
-     * 
-     * @return The protocol or an empty string if none, never {@code null}.
-     */
-    public String getProtocol()
-    {
-        return protocol;
-    }
-
-    /**
-     * Gets the host part from the repository's URL.
-     * 
-     * @return The host or an empty string if none, never {@code null}.
-     */
-    public String getHost()
-    {
-        return host;
-    }
-
-    /**
-     * Gets the policy to apply for snapshot/release artifacts.
-     * 
-     * @param snapshot {@code true} to retrieve the snapshot policy, {@code false} to retrieve the release policy.
-     * @return The requested repository policy, never {@code null}.
-     */
-    public RepositoryPolicy getPolicy( boolean snapshot )
-    {
-        return snapshot ? snapshotPolicy : releasePolicy;
-    }
-
-    /**
-     * Gets the proxy that has been selected for this repository.
-     * 
-     * @return The selected proxy or {@code null} if none.
-     */
-    public Proxy getProxy()
-    {
-        return proxy;
-    }
-
-    /**
-     * Gets the authentication that has been selected for this repository.
-     * 
-     * @return The selected authentication or {@code null} if none.
-     */
-    public Authentication getAuthentication()
-    {
-        return authentication;
-    }
-
-    /**
-     * Gets the repositories that this repository serves as a mirror for.
-     * 
-     * @return The (read-only) repositories being mirrored by this repository, never {@code null}.
-     */
-    public List<RemoteRepository> getMirroredRepositories()
-    {
-        return mirroredRepositories;
-    }
-
-    /**
-     * Indicates whether this repository refers to a repository manager or not.
-     * 
-     * @return {@code true} if this repository is a repository manager, {@code false} otherwise.
-     */
-    public boolean isRepositoryManager()
-    {
-        return repositoryManager;
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder buffer = new StringBuilder( 256 );
-        buffer.append( getId() );
-        buffer.append( " (" ).append( getUrl() );
-        buffer.append( ", " ).append( getContentType() );
-        boolean r = getPolicy( false ).isEnabled(), s = getPolicy( true ).isEnabled();
-        if ( r && s )
-        {
-            buffer.append( ", releases+snapshots" );
-        }
-        else if ( r )
-        {
-            buffer.append( ", releases" );
-        }
-        else if ( s )
-        {
-            buffer.append( ", snapshots" );
-        }
-        else
-        {
-            buffer.append( ", disabled" );
-        }
-        if ( isRepositoryManager() )
-        {
-            buffer.append( ", managed" );
-        }
-        buffer.append( ")" );
-        return buffer.toString();
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( this == obj )
-        {
-            return true;
-        }
-        if ( obj == null || !getClass().equals( obj.getClass() ) )
-        {
-            return false;
-        }
-
-        RemoteRepository that = (RemoteRepository) obj;
-
-        return eq( url, that.url ) && eq( type, that.type ) && eq( id, that.id )
-            && eq( releasePolicy, that.releasePolicy ) && eq( snapshotPolicy, that.snapshotPolicy )
-            && eq( proxy, that.proxy ) && eq( authentication, that.authentication )
-            && eq( mirroredRepositories, that.mirroredRepositories ) && repositoryManager == that.repositoryManager;
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = 17;
-        hash = hash * 31 + hash( url );
-        hash = hash * 31 + hash( type );
-        hash = hash * 31 + hash( id );
-        hash = hash * 31 + hash( releasePolicy );
-        hash = hash * 31 + hash( snapshotPolicy );
-        hash = hash * 31 + hash( proxy );
-        hash = hash * 31 + hash( authentication );
-        hash = hash * 31 + hash( mirroredRepositories );
-        hash = hash * 31 + ( repositoryManager ? 1 : 0 );
-        return hash;
-    }
-
-    private static int hash( Object obj )
-    {
-        return obj != null ? obj.hashCode() : 0;
-    }
-
-    /**
-     * A builder to create remote repositories.
-     */
-    public static final class Builder
-    {
-
-        private static final RepositoryPolicy DEFAULT_POLICY = new RepositoryPolicy();
-
-        static final int ID = 0x0001, TYPE = 0x0002, URL = 0x0004, RELEASES = 0x0008, SNAPSHOTS = 0x0010,
-                        PROXY = 0x0020, AUTH = 0x0040, MIRRORED = 0x0080, REPOMAN = 0x0100;
-
-        int delta;
-
-        RemoteRepository prototype;
-
-        String id;
-
-        String type;
-
-        String url;
-
-        RepositoryPolicy releasePolicy = DEFAULT_POLICY;
-
-        RepositoryPolicy snapshotPolicy = DEFAULT_POLICY;
-
-        Proxy proxy;
-
-        Authentication authentication;
-
-        List<RemoteRepository> mirroredRepositories;
-
-        boolean repositoryManager;
-
-        /**
-         * Creates a new repository builder.
-         * 
-         * @param id The identifier of the repository, may be {@code null}.
-         * @param type The type of the repository, may be {@code null}.
-         * @param url The (base) URL of the repository, may be {@code null}.
-         */
-        public Builder( String id, String type, String url )
-        {
-            this.id = ( id != null ) ? id : "";
-            this.type = ( type != null ) ? type : "";
-            this.url = ( url != null ) ? url : "";
-        }
-
-        /**
-         * Creates a new repository builder which uses the specified remote repository as a prototype for the new one.
-         * All properties which have not been set on the builder will be copied from the prototype when building the
-         * repository.
-         * 
-         * @param prototype The remote repository to use as prototype, must not be {@code null}.
-         */
-        public Builder( RemoteRepository prototype )
-        {
-            if ( prototype == null )
-            {
-                throw new IllegalArgumentException( "repository prototype missing" );
-            }
-            this.prototype = prototype;
-        }
-
-        /**
-         * Builds a new remote repository from the current values of this builder. The state of the builder itself
-         * remains unchanged.
-         * 
-         * @return The remote repository, never {@code null}.
-         */
-        public RemoteRepository build()
-        {
-            if ( prototype != null && delta == 0 )
-            {
-                return prototype;
-            }
-            return new RemoteRepository( this );
-        }
-
-        private <T> void delta( int flag, T builder, T prototype )
-        {
-            boolean equal = ( builder != null ) ? builder.equals( prototype ) : prototype == null;
-            if ( equal )
-            {
-                delta &= ~flag;
-            }
-            else
-            {
-                delta |= flag;
-            }
-        }
-
-        /**
-         * Sets the identifier of the repository.
-         * 
-         * @param id The identifier of the repository, may be {@code null}.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setId( String id )
-        {
-            this.id = ( id != null ) ? id : "";
-            if ( prototype != null )
-            {
-                delta( ID, this.id, prototype.getId() );
-            }
-            return this;
-        }
-
-        /**
-         * Sets the type of the repository, e.g. "default".
-         * 
-         * @param type The type of the repository, may be {@code null}.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setContentType( String type )
-        {
-            this.type = ( type != null ) ? type : "";
-            if ( prototype != null )
-            {
-                delta( TYPE, this.type, prototype.getContentType() );
-            }
-            return this;
-        }
-
-        /**
-         * Sets the (base) URL of the repository.
-         * 
-         * @param url The URL of the repository, may be {@code null}.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setUrl( String url )
-        {
-            this.url = ( url != null ) ? url : "";
-            if ( prototype != null )
-            {
-                delta( URL, this.url, prototype.getUrl() );
-            }
-            return this;
-        }
-
-        /**
-         * Sets the policy to apply for snapshot and release artifacts.
-         * 
-         * @param policy The repository policy to set, may be {@code null} to use a default policy.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setPolicy( RepositoryPolicy policy )
-        {
-            this.releasePolicy = this.snapshotPolicy = ( policy != null ) ? policy : DEFAULT_POLICY;
-            if ( prototype != null )
-            {
-                delta( RELEASES, this.releasePolicy, prototype.getPolicy( false ) );
-                delta( SNAPSHOTS, this.snapshotPolicy, prototype.getPolicy( true ) );
-            }
-            return this;
-        }
-
-        /**
-         * Sets the policy to apply for release artifacts.
-         * 
-         * @param releasePolicy The repository policy to set, may be {@code null} to use a default policy.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setReleasePolicy( RepositoryPolicy releasePolicy )
-        {
-            this.releasePolicy = ( releasePolicy != null ) ? releasePolicy : DEFAULT_POLICY;
-            if ( prototype != null )
-            {
-                delta( RELEASES, this.releasePolicy, prototype.getPolicy( false ) );
-            }
-            return this;
-        }
-
-        /**
-         * Sets the policy to apply for snapshot artifacts.
-         * 
-         * @param snapshotPolicy The repository policy to set, may be {@code null} to use a default policy.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setSnapshotPolicy( RepositoryPolicy snapshotPolicy )
-        {
-            this.snapshotPolicy = ( snapshotPolicy != null ) ? snapshotPolicy : DEFAULT_POLICY;
-            if ( prototype != null )
-            {
-                delta( SNAPSHOTS, this.snapshotPolicy, prototype.getPolicy( true ) );
-            }
-            return this;
-        }
-
-        /**
-         * Sets the proxy to use in order to access the repository.
-         * 
-         * @param proxy The proxy to use, may be {@code null}.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setProxy( Proxy proxy )
-        {
-            this.proxy = proxy;
-            if ( prototype != null )
-            {
-                delta( PROXY, this.proxy, prototype.getProxy() );
-            }
-            return this;
-        }
-
-        /**
-         * Sets the authentication to use in order to access the repository.
-         * 
-         * @param authentication The authentication to use, may be {@code null}.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setAuthentication( Authentication authentication )
-        {
-            this.authentication = authentication;
-            if ( prototype != null )
-            {
-                delta( AUTH, this.authentication, prototype.getAuthentication() );
-            }
-            return this;
-        }
-
-        /**
-         * Sets the repositories being mirrored by the repository.
-         * 
-         * @param mirroredRepositories The repositories being mirrored by the repository, may be {@code null}.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setMirroredRepositories( List<RemoteRepository> mirroredRepositories )
-        {
-            if ( this.mirroredRepositories == null )
-            {
-                this.mirroredRepositories = new ArrayList<RemoteRepository>();
-            }
-            else
-            {
-                this.mirroredRepositories.clear();
-            }
-            if ( mirroredRepositories != null )
-            {
-                this.mirroredRepositories.addAll( mirroredRepositories );
-            }
-            if ( prototype != null )
-            {
-                delta( MIRRORED, this.mirroredRepositories, prototype.getMirroredRepositories() );
-            }
-            return this;
-        }
-
-        /**
-         * Adds the specified repository to the list of repositories being mirrored by the repository. If this builder
-         * was {@link #RemoteRepository.Builder(RemoteRepository) constructed from a prototype}, the given repository
-         * will be added to the list of mirrored repositories from the prototype.
-         * 
-         * @param mirroredRepository The repository being mirrored by the repository, may be {@code null}.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder addMirroredRepository( RemoteRepository mirroredRepository )
-        {
-            if ( mirroredRepository != null )
-            {
-                if ( this.mirroredRepositories == null )
-                {
-                    this.mirroredRepositories = new ArrayList<RemoteRepository>();
-                    if ( prototype != null )
-                    {
-                        mirroredRepositories.addAll( prototype.getMirroredRepositories() );
-                    }
-                }
-                mirroredRepositories.add( mirroredRepository );
-                if ( prototype != null )
-                {
-                    delta |= MIRRORED;
-                }
-            }
-            return this;
-        }
-
-        /**
-         * Marks the repository as a repository manager or not.
-         * 
-         * @param repositoryManager {@code true} if the repository points at a repository manager, {@code false} if the
-         *            repository is just serving static contents.
-         * @return This builder for chaining, never {@code null}.
-         */
-        public Builder setRepositoryManager( boolean repositoryManager )
-        {
-            this.repositoryManager = repositoryManager;
-            if ( prototype != null )
-            {
-                delta( REPOMAN, this.repositoryManager, prototype.isRepositoryManager() );
-            }
-            return this;
-        }
-
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/RepositoryPolicy.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/RepositoryPolicy.java
deleted file mode 100644 (file)
index 05224a8..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-/**
- * A policy controlling access to a repository.
- */
-public final class RepositoryPolicy
-{
-
-    /**
-     * Never update locally cached data.
-     */
-    public static final String UPDATE_POLICY_NEVER = "never";
-
-    /**
-     * Always update locally cached data.
-     */
-    public static final String UPDATE_POLICY_ALWAYS = "always";
-
-    /**
-     * Update locally cached data once a day.
-     */
-    public static final String UPDATE_POLICY_DAILY = "daily";
-
-    /**
-     * Update locally cached data every X minutes as given by "interval:X".
-     */
-    public static final String UPDATE_POLICY_INTERVAL = "interval";
-
-    /**
-     * Verify checksums and fail the resolution if they do not match.
-     */
-    public static final String CHECKSUM_POLICY_FAIL = "fail";
-
-    /**
-     * Verify checksums and warn if they do not match.
-     */
-    public static final String CHECKSUM_POLICY_WARN = "warn";
-
-    /**
-     * Do not verify checksums.
-     */
-    public static final String CHECKSUM_POLICY_IGNORE = "ignore";
-
-    private final boolean enabled;
-
-    private final String updatePolicy;
-
-    private final String checksumPolicy;
-
-    /**
-     * Creates a new policy with checksum warnings and daily update checks.
-     */
-    public RepositoryPolicy()
-    {
-        this( true, UPDATE_POLICY_DAILY, CHECKSUM_POLICY_WARN );
-    }
-
-    /**
-     * Creates a new policy with the specified settings.
-     * 
-     * @param enabled A flag whether the associated repository should be accessed or not.
-     * @param updatePolicy The update interval after which locally cached data from the repository is considered stale
-     *            and should be refetched, may be {@code null}.
-     * @param checksumPolicy The way checksum verification should be handled, may be {@code null}.
-     */
-    public RepositoryPolicy( boolean enabled, String updatePolicy, String checksumPolicy )
-    {
-        this.enabled = enabled;
-        this.updatePolicy = ( updatePolicy != null ) ? updatePolicy : "";
-        this.checksumPolicy = ( checksumPolicy != null ) ? checksumPolicy : "";
-    }
-
-    /**
-     * Indicates whether the associated repository should be contacted or not.
-     * 
-     * @return {@code true} if the repository should be contacted, {@code false} otherwise.
-     */
-    public boolean isEnabled()
-    {
-        return enabled;
-    }
-
-    /**
-     * Gets the update policy for locally cached data from the repository.
-     * 
-     * @return The update policy, never {@code null}.
-     */
-    public String getUpdatePolicy()
-    {
-        return updatePolicy;
-    }
-
-    /**
-     * Gets the policy for checksum validation.
-     * 
-     * @return The checksum policy, never {@code null}.
-     */
-    public String getChecksumPolicy()
-    {
-        return checksumPolicy;
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder buffer = new StringBuilder( 256 );
-        buffer.append( "enabled=" ).append( isEnabled() );
-        buffer.append( ", checksums=" ).append( getChecksumPolicy() );
-        buffer.append( ", updates=" ).append( getUpdatePolicy() );
-        return buffer.toString();
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( this == obj )
-        {
-            return true;
-        }
-
-        if ( obj == null || !getClass().equals( obj.getClass() ) )
-        {
-            return false;
-        }
-
-        RepositoryPolicy that = (RepositoryPolicy) obj;
-
-        return enabled == that.enabled && updatePolicy.equals( that.updatePolicy )
-            && checksumPolicy.equals( that.checksumPolicy );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = 17;
-        hash = hash * 31 + ( enabled ? 1 : 0 );
-        hash = hash * 31 + updatePolicy.hashCode();
-        hash = hash * 31 + checksumPolicy.hashCode();
-        return hash;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceReader.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceReader.java
deleted file mode 100644 (file)
index 570f6b6..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.io.File;
-import java.util.List;
-
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * Manages a repository backed by the IDE workspace, a build session or a similar ad-hoc collection of artifacts.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getWorkspaceReader()
- */
-public interface WorkspaceReader
-{
-
-    /**
-     * Gets a description of the workspace repository.
-     * 
-     * @return The repository description, never {@code null}.
-     */
-    WorkspaceRepository getRepository();
-
-    /**
-     * Locates the specified artifact.
-     * 
-     * @param artifact The artifact to locate, must not be {@code null}.
-     * @return The path to the artifact or {@code null} if the artifact is not available.
-     */
-    File findArtifact( Artifact artifact );
-
-    /**
-     * Determines all available versions of the specified artifact.
-     * 
-     * @param artifact The artifact whose versions should be listed, must not be {@code null}.
-     * @return The available versions of the artifact, must not be {@code null}.
-     */
-    List<String> findVersions( Artifact artifact );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceRepository.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceRepository.java
deleted file mode 100644 (file)
index 811c589..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.repository;
-
-import java.util.UUID;
-
-/**
- * A repository backed by an IDE workspace, the output of a build session or similar ad-hoc collection of artifacts. As
- * far as the repository system is concerned, a workspace repository is read-only, i.e. can only be used for artifact
- * resolution but not installation/deployment. Note that this class merely describes such a repository, actual access to
- * the contained artifacts is handled by a {@link WorkspaceReader}.
- */
-public final class WorkspaceRepository
-    implements ArtifactRepository
-{
-
-    private final String type;
-
-    private final Object key;
-
-    /**
-     * Creates a new workspace repository of type {@code "workspace"} and a random key.
-     */
-    public WorkspaceRepository()
-    {
-        this( "workspace" );
-    }
-
-    /**
-     * Creates a new workspace repository with the specified type and a random key.
-     * 
-     * @param type The type of the repository, may be {@code null}.
-     */
-    public WorkspaceRepository( String type )
-    {
-        this( type, null );
-    }
-
-    /**
-     * Creates a new workspace repository with the specified type and key. The key is used to distinguish one workspace
-     * from another and should be sensitive to the artifacts that are (potentially) available in the workspace.
-     * 
-     * @param type The type of the repository, may be {@code null}.
-     * @param key The (comparison) key for the repository, may be {@code null} to generate a unique random key.
-     */
-    public WorkspaceRepository( String type, Object key )
-    {
-        this.type = ( type != null ) ? type : "";
-        this.key = ( key != null ) ? key : UUID.randomUUID().toString().replace( "-", "" );
-    }
-
-    public String getContentType()
-    {
-        return type;
-    }
-
-    public String getId()
-    {
-        return "workspace";
-    }
-
-    /**
-     * Gets the key of this workspace repository. The key is used to distinguish one workspace from another and should
-     * be sensitive to the artifacts that are (potentially) available in the workspace.
-     * 
-     * @return The (comparison) key for this workspace repository, never {@code null}.
-     */
-    public Object getKey()
-    {
-        return key;
-    }
-
-    @Override
-    public String toString()
-    {
-        return "(" + getContentType() + ")";
-    }
-
-    @Override
-    public boolean equals( Object obj )
-    {
-        if ( this == obj )
-        {
-            return true;
-        }
-        if ( obj == null || !getClass().equals( obj.getClass() ) )
-        {
-            return false;
-        }
-
-        WorkspaceRepository that = (WorkspaceRepository) obj;
-
-        return getContentType().equals( that.getContentType() ) && getKey().equals( that.getKey() );
-    }
-
-    @Override
-    public int hashCode()
-    {
-        int hash = 17;
-        hash = hash * 31 + getKey().hashCode();
-        hash = hash * 31 + getContentType().hashCode();
-        return hash;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/repository/package-info.java
deleted file mode 100644 (file)
index 21ab2bc..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The definition of various kinds of repositories that host artifacts.
- */
-package org.eclipse.aether.repository;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorException.java
deleted file mode 100644 (file)
index 7dae7f4..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case of an unreadable or unresolvable artifact descriptor.
- */
-public class ArtifactDescriptorException
-    extends RepositoryException
-{
-
-    private final transient ArtifactDescriptorResult result;
-
-    /**
-     * Creates a new exception with the specified result.
-     * 
-     * @param result The descriptor result at the point the exception occurred, may be {@code null}.
-     */
-    public ArtifactDescriptorException( ArtifactDescriptorResult result )
-    {
-        super( "Failed to read artifact descriptor"
-            + ( result != null ? " for " + result.getRequest().getArtifact() : "" ), getCause( result ) );
-        this.result = result;
-    }
-
-    /**
-     * Creates a new exception with the specified result and detail message.
-     * 
-     * @param result The descriptor result at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public ArtifactDescriptorException( ArtifactDescriptorResult result, String message )
-    {
-        super( message, getCause( result ) );
-        this.result = result;
-    }
-
-    /**
-     * Creates a new exception with the specified result, detail message and cause.
-     * 
-     * @param result The descriptor result at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public ArtifactDescriptorException( ArtifactDescriptorResult result, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.result = result;
-    }
-
-    /**
-     * Gets the descriptor result at the point the exception occurred. Despite being incomplete, callers might want to
-     * use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
-     * 
-     * @return The descriptor result or {@code null} if unknown.
-     */
-    public ArtifactDescriptorResult getResult()
-    {
-        return result;
-    }
-
-    private static Throwable getCause( ArtifactDescriptorResult result )
-    {
-        Throwable cause = null;
-        if ( result != null && !result.getExceptions().isEmpty() )
-        {
-            cause = result.getExceptions().get( 0 );
-        }
-        return cause;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicy.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicy.java
deleted file mode 100644 (file)
index ec519fe..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * Controls the handling of errors related to reading an artifact descriptor.
- * 
- * @see RepositorySystemSession#getArtifactDescriptorPolicy()
- */
-public interface ArtifactDescriptorPolicy
-{
-
-    /**
-     * Bit mask indicating that errors while reading the artifact descriptor should not be tolerated.
-     */
-    int STRICT = 0x00;
-
-    /**
-     * Bit flag indicating that missing artifact descriptors should be silently ignored.
-     */
-    int IGNORE_MISSING = 0x01;
-
-    /**
-     * Bit flag indicating that existent but invalid artifact descriptors should be silently ignored.
-     */
-    int IGNORE_INVALID = 0x02;
-
-    /**
-     * Bit mask indicating that all errors should be silently ignored.
-     */
-    int IGNORE_ERRORS = IGNORE_MISSING | IGNORE_INVALID;
-
-    /**
-     * Gets the error policy for an artifact's descriptor.
-     * 
-     * @param session The repository session during which the policy is determined, must not be {@code null}.
-     * @param request The policy request holding further details, must not be {@code null}.
-     * @return The bit mask describing the desired error policy.
-     */
-    int getPolicy( RepositorySystemSession session, ArtifactDescriptorPolicyRequest request );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicyRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicyRequest.java
deleted file mode 100644 (file)
index 2edf0c5..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.artifact.Artifact;
-
-/**
- * A query for the error policy for a given artifact's descriptor.
- * 
- * @see ArtifactDescriptorPolicy
- */
-public final class ArtifactDescriptorPolicyRequest
-{
-
-    private Artifact artifact;
-
-    private String context = "";
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public ArtifactDescriptorPolicyRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a request for the specified artifact.
-     * 
-     * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
-     * @param context The context in which this request is made, may be {@code null}.
-     */
-    public ArtifactDescriptorPolicyRequest( Artifact artifact, String context )
-    {
-        setArtifact( artifact );
-        setRequestContext( context );
-    }
-
-    /**
-     * Gets the artifact for whose descriptor to determine the error policy.
-     * 
-     * @return The artifact for whose descriptor to determine the error policy or {@code null} if not set.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the artifact for whose descriptor to determine the error policy.
-     * 
-     * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorPolicyRequest setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-        return this;
-    }
-
-    /**
-     * Gets the context in which this request is made.
-     * 
-     * @return The context, never {@code null}.
-     */
-    public String getRequestContext()
-    {
-        return context;
-    }
-
-    /**
-     * Sets the context in which this request is made.
-     * 
-     * @param context The context, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorPolicyRequest setRequestContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return String.valueOf( getArtifact() );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorRequest.java
deleted file mode 100644 (file)
index 9a1ba65..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * A request to read an artifact descriptor.
- * 
- * @see RepositorySystem#readArtifactDescriptor(RepositorySystemSession, ArtifactDescriptorRequest)
- */
-public final class ArtifactDescriptorRequest
-{
-
-    private Artifact artifact;
-
-    private List<RemoteRepository> repositories = Collections.emptyList();
-
-    private String context = "";
-
-    private RequestTrace trace;
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public ArtifactDescriptorRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a request with the specified properties.
-     * 
-     * @param artifact The artifact whose descriptor should be read, may be {@code null}.
-     * @param repositories The repositories to resolve the descriptor from, may be {@code null}.
-     * @param context The context in which this request is made, may be {@code null}.
-     */
-    public ArtifactDescriptorRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
-    {
-        setArtifact( artifact );
-        setRepositories( repositories );
-        setRequestContext( context );
-    }
-
-    /**
-     * Gets the artifact whose descriptor shall be read.
-     * 
-     * @return The artifact or {@code null} if not set.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the artifact whose descriptor shall be read. Eventually, a valid request must have an artifact set.
-     * 
-     * @param artifact The artifact, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorRequest setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-        return this;
-    }
-
-    /**
-     * Gets the repositories to resolve the descriptor from.
-     * 
-     * @return The repositories, never {@code null}.
-     */
-    public List<RemoteRepository> getRepositories()
-    {
-        return repositories;
-    }
-
-    /**
-     * Sets the repositories to resolve the descriptor from.
-     * 
-     * @param repositories The repositories, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorRequest setRepositories( List<RemoteRepository> repositories )
-    {
-        if ( repositories == null )
-        {
-            this.repositories = Collections.emptyList();
-        }
-        else
-        {
-            this.repositories = repositories;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified repository for the resolution of the artifact descriptor.
-     * 
-     * @param repository The repository to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorRequest addRepository( RemoteRepository repository )
-    {
-        if ( repository != null )
-        {
-            if ( this.repositories.isEmpty() )
-            {
-                this.repositories = new ArrayList<RemoteRepository>();
-            }
-            this.repositories.add( repository );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the context in which this request is made.
-     * 
-     * @return The context, never {@code null}.
-     */
-    public String getRequestContext()
-    {
-        return context;
-    }
-
-    /**
-     * Sets the context in which this request is made.
-     * 
-     * @param context The context, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorRequest setRequestContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-        return this;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    /**
-     * Sets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @param trace The trace information about the higher level operation, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorRequest setTrace( RequestTrace trace )
-    {
-        this.trace = trace;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifact() + " < " + getRepositories();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorResult.java
deleted file mode 100644 (file)
index 3de8d5e..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.repository.ArtifactRepository;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * The result from reading an artifact descriptor.
- * 
- * @see RepositorySystem#readArtifactDescriptor(RepositorySystemSession, ArtifactDescriptorRequest)
- */
-public final class ArtifactDescriptorResult
-{
-
-    private final ArtifactDescriptorRequest request;
-
-    private List<Exception> exceptions;
-
-    private List<Artifact> relocations;
-
-    private Collection<Artifact> aliases;
-
-    private Artifact artifact;
-
-    private ArtifactRepository repository;
-
-    private List<Dependency> dependencies;
-
-    private List<Dependency> managedDependencies;
-
-    private List<RemoteRepository> repositories;
-
-    private Map<String, Object> properties;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The descriptor request, must not be {@code null}.
-     */
-    public ArtifactDescriptorResult( ArtifactDescriptorRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "artifact descriptor request has not been specified" );
-        }
-        this.request = request;
-        artifact = request.getArtifact();
-        exceptions = Collections.emptyList();
-        relocations = Collections.emptyList();
-        aliases = Collections.emptyList();
-        dependencies = managedDependencies = Collections.emptyList();
-        repositories = Collections.emptyList();
-        properties = Collections.emptyMap();
-    }
-
-    /**
-     * Gets the descriptor request that was made.
-     * 
-     * @return The descriptor request, never {@code null}.
-     */
-    public ArtifactDescriptorRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the exceptions that occurred while reading the artifact descriptor.
-     * 
-     * @return The exceptions that occurred, never {@code null}.
-     */
-    public List<Exception> getExceptions()
-    {
-        return exceptions;
-    }
-
-    /**
-     * Sets the exceptions that occurred while reading the artifact descriptor.
-     * 
-     * @param exceptions The exceptions that occurred, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult setExceptions( List<Exception> exceptions )
-    {
-        if ( exceptions == null )
-        {
-            this.exceptions = Collections.emptyList();
-        }
-        else
-        {
-            this.exceptions = exceptions;
-        }
-        return this;
-    }
-
-    /**
-     * Records the specified exception while reading the artifact descriptor.
-     * 
-     * @param exception The exception to record, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult addException( Exception exception )
-    {
-        if ( exception != null )
-        {
-            if ( exceptions.isEmpty() )
-            {
-                exceptions = new ArrayList<Exception>();
-            }
-            exceptions.add( exception );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the relocations that were processed to read the artifact descriptor. The returned list denotes the hops that
-     * lead to the final artifact coordinates as given by {@link #getArtifact()}.
-     * 
-     * @return The relocations that were processed, never {@code null}.
-     */
-    public List<Artifact> getRelocations()
-    {
-        return relocations;
-    }
-
-    /**
-     * Sets the relocations that were processed to read the artifact descriptor.
-     * 
-     * @param relocations The relocations that were processed, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult setRelocations( List<Artifact> relocations )
-    {
-        if ( relocations == null )
-        {
-            this.relocations = Collections.emptyList();
-        }
-        else
-        {
-            this.relocations = relocations;
-        }
-        return this;
-    }
-
-    /**
-     * Records the specified relocation hop while locating the artifact descriptor.
-     * 
-     * @param artifact The artifact that got relocated, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult addRelocation( Artifact artifact )
-    {
-        if ( artifact != null )
-        {
-            if ( relocations.isEmpty() )
-            {
-                relocations = new ArrayList<Artifact>();
-            }
-            relocations.add( artifact );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the known aliases for this artifact. An alias denotes a different artifact with (almost) the same contents
-     * and can be used to mark a patched rebuild of some other artifact as such, thereby allowing conflict resolution to
-     * consider the patched and the original artifact as a conflict.
-     * 
-     * @return The aliases of the artifact, never {@code null}.
-     */
-    public Collection<Artifact> getAliases()
-    {
-        return aliases;
-    }
-
-    /**
-     * Sets the aliases of the artifact.
-     * 
-     * @param aliases The aliases of the artifact, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult setAliases( Collection<Artifact> aliases )
-    {
-        if ( aliases == null )
-        {
-            this.aliases = Collections.emptyList();
-        }
-        else
-        {
-            this.aliases = aliases;
-        }
-        return this;
-    }
-
-    /**
-     * Records the specified alias.
-     * 
-     * @param alias The alias for the artifact, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult addAlias( Artifact alias )
-    {
-        if ( alias != null )
-        {
-            if ( aliases.isEmpty() )
-            {
-                aliases = new ArrayList<Artifact>();
-            }
-            aliases.add( alias );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the artifact whose descriptor was read. This can be a different artifact than originally requested in case
-     * relocations were encountered.
-     * 
-     * @return The artifact after following any relocations, never {@code null}.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the artifact whose descriptor was read.
-     * 
-     * @param artifact The artifact whose descriptor was read, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-        return this;
-    }
-
-    /**
-     * Gets the repository from which the descriptor was eventually resolved.
-     * 
-     * @return The repository from which the descriptor was resolved or {@code null} if unknown.
-     */
-    public ArtifactRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the repository from which the descriptor was resolved.
-     * 
-     * @param repository The repository from which the descriptor was resolved, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult setRepository( ArtifactRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    /**
-     * Gets the list of direct dependencies of the artifact.
-     * 
-     * @return The list of direct dependencies, never {@code null}
-     */
-    public List<Dependency> getDependencies()
-    {
-        return dependencies;
-    }
-
-    /**
-     * Sets the list of direct dependencies of the artifact.
-     * 
-     * @param dependencies The list of direct dependencies, may be {@code null}
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult setDependencies( List<Dependency> dependencies )
-    {
-        if ( dependencies == null )
-        {
-            this.dependencies = Collections.emptyList();
-        }
-        else
-        {
-            this.dependencies = dependencies;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified direct dependency.
-     * 
-     * @param dependency The direct dependency to add, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult addDependency( Dependency dependency )
-    {
-        if ( dependency != null )
-        {
-            if ( dependencies.isEmpty() )
-            {
-                dependencies = new ArrayList<Dependency>();
-            }
-            dependencies.add( dependency );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the dependency management information.
-     * 
-     * @return The dependency management information.
-     */
-    public List<Dependency> getManagedDependencies()
-    {
-        return managedDependencies;
-    }
-
-    /**
-     * Sets the dependency management information.
-     * 
-     * @param dependencies The dependency management information, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult setManagedDependencies( List<Dependency> dependencies )
-    {
-        if ( dependencies == null )
-        {
-            this.managedDependencies = Collections.emptyList();
-        }
-        else
-        {
-            this.managedDependencies = dependencies;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified managed dependency.
-     * 
-     * @param dependency The managed dependency to add, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult addManagedDependency( Dependency dependency )
-    {
-        if ( dependency != null )
-        {
-            if ( managedDependencies.isEmpty() )
-            {
-                managedDependencies = new ArrayList<Dependency>();
-            }
-            managedDependencies.add( dependency );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the remote repositories listed in the artifact descriptor.
-     * 
-     * @return The remote repositories listed in the artifact descriptor, never {@code null}.
-     */
-    public List<RemoteRepository> getRepositories()
-    {
-        return repositories;
-    }
-
-    /**
-     * Sets the remote repositories listed in the artifact descriptor.
-     * 
-     * @param repositories The remote repositories listed in the artifact descriptor, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult setRepositories( List<RemoteRepository> repositories )
-    {
-        if ( repositories == null )
-        {
-            this.repositories = Collections.emptyList();
-        }
-        else
-        {
-            this.repositories = repositories;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified remote repository.
-     * 
-     * @param repository The remote repository to add, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult addRepository( RemoteRepository repository )
-    {
-        if ( repository != null )
-        {
-            if ( repositories.isEmpty() )
-            {
-                repositories = new ArrayList<RemoteRepository>();
-            }
-            repositories.add( repository );
-        }
-        return this;
-    }
-
-    /**
-     * Gets any additional information about the artifact in form of key-value pairs. <em>Note:</em> Regardless of their
-     * actual type, all property values must be treated as being read-only.
-     * 
-     * @return The additional information about the artifact, never {@code null}.
-     */
-    public Map<String, Object> getProperties()
-    {
-        return properties;
-    }
-
-    /**
-     * Sets any additional information about the artifact in form of key-value pairs.
-     * 
-     * @param properties The additional information about the artifact, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactDescriptorResult setProperties( Map<String, Object> properties )
-    {
-        if ( properties == null )
-        {
-            this.properties = Collections.emptyMap();
-        }
-        else
-        {
-            this.properties = properties;
-        }
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifact() + " -> " + getDependencies();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactRequest.java
deleted file mode 100644 (file)
index 6076ea5..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * A request to resolve an artifact.
- * 
- * @see RepositorySystem#resolveArtifacts(RepositorySystemSession, java.util.Collection)
- * @see Artifact#getFile()
- */
-public final class ArtifactRequest
-{
-
-    private Artifact artifact;
-
-    private DependencyNode node;
-
-    private List<RemoteRepository> repositories = Collections.emptyList();
-
-    private String context = "";
-
-    private RequestTrace trace;
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public ArtifactRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a request with the specified properties.
-     * 
-     * @param artifact The artifact to resolve, may be {@code null}.
-     * @param repositories The repositories to resolve the artifact from, may be {@code null}.
-     * @param context The context in which this request is made, may be {@code null}.
-     */
-    public ArtifactRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
-    {
-        setArtifact( artifact );
-        setRepositories( repositories );
-        setRequestContext( context );
-    }
-
-    /**
-     * Creates a request from the specified dependency node.
-     * 
-     * @param node The dependency node to resolve, may be {@code null}.
-     */
-    public ArtifactRequest( DependencyNode node )
-    {
-        setDependencyNode( node );
-        setRepositories( node.getRepositories() );
-        setRequestContext( node.getRequestContext() );
-    }
-
-    /**
-     * Gets the artifact to resolve.
-     * 
-     * @return The artifact to resolve or {@code null}.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the artifact to resolve.
-     * 
-     * @param artifact The artifact to resolve, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactRequest setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-        return this;
-    }
-
-    /**
-     * Gets the dependency node (if any) for which to resolve the artifact.
-     * 
-     * @return The dependency node to resolve or {@code null} if unknown.
-     */
-    public DependencyNode getDependencyNode()
-    {
-        return node;
-    }
-
-    /**
-     * Sets the dependency node to resolve.
-     * 
-     * @param node The dependency node to resolve, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactRequest setDependencyNode( DependencyNode node )
-    {
-        this.node = node;
-        if ( node != null )
-        {
-            setArtifact( node.getDependency().getArtifact() );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the repositories to resolve the artifact from.
-     * 
-     * @return The repositories, never {@code null}.
-     */
-    public List<RemoteRepository> getRepositories()
-    {
-        return repositories;
-    }
-
-    /**
-     * Sets the repositories to resolve the artifact from.
-     * 
-     * @param repositories The repositories, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactRequest setRepositories( List<RemoteRepository> repositories )
-    {
-        if ( repositories == null )
-        {
-            this.repositories = Collections.emptyList();
-        }
-        else
-        {
-            this.repositories = repositories;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified repository for the resolution.
-     * 
-     * @param repository The repository to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactRequest addRepository( RemoteRepository repository )
-    {
-        if ( repository != null )
-        {
-            if ( this.repositories.isEmpty() )
-            {
-                this.repositories = new ArrayList<RemoteRepository>();
-            }
-            this.repositories.add( repository );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the context in which this request is made.
-     * 
-     * @return The context, never {@code null}.
-     */
-    public String getRequestContext()
-    {
-        return context;
-    }
-
-    /**
-     * Sets the context in which this request is made.
-     * 
-     * @param context The context, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactRequest setRequestContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-        return this;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    /**
-     * Sets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @param trace The trace information about the higher level operation, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ArtifactRequest setTrace( RequestTrace trace )
-    {
-        this.trace = trace;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifact() + " < " + getRepositories();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResolutionException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResolutionException.java
deleted file mode 100644 (file)
index 67d0514..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.transfer.ArtifactNotFoundException;
-import org.eclipse.aether.transfer.RepositoryOfflineException;
-
-/**
- * Thrown in case of a unresolvable artifacts.
- */
-public class ArtifactResolutionException
-    extends RepositoryException
-{
-
-    private final transient List<ArtifactResult> results;
-
-    /**
-     * Creates a new exception with the specified results.
-     * 
-     * @param results The resolution results at the point the exception occurred, may be {@code null}.
-     */
-    public ArtifactResolutionException( List<ArtifactResult> results )
-    {
-        super( getMessage( results ), getCause( results ) );
-        this.results = ( results != null ) ? results : Collections.<ArtifactResult> emptyList();
-    }
-
-    /**
-     * Creates a new exception with the specified results and detail message.
-     * 
-     * @param results The resolution results at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public ArtifactResolutionException( List<ArtifactResult> results, String message )
-    {
-        super( message, getCause( results ) );
-        this.results = ( results != null ) ? results : Collections.<ArtifactResult> emptyList();
-    }
-
-    /**
-     * Creates a new exception with the specified results, detail message and cause.
-     * 
-     * @param results The resolution results at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public ArtifactResolutionException( List<ArtifactResult> results, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.results = ( results != null ) ? results : Collections.<ArtifactResult> emptyList();
-    }
-
-    /**
-     * Gets the resolution results at the point the exception occurred. Despite being incomplete, callers might want to
-     * use these results to fail gracefully and continue their operation with whatever interim data has been gathered.
-     * 
-     * @return The resolution results or {@code null} if unknown.
-     */
-    public List<ArtifactResult> getResults()
-    {
-        return results;
-    }
-
-    /**
-     * Gets the first result from {@link #getResults()}. This is a convenience method for cases where callers know only
-     * a single result/request is involved.
-     * 
-     * @return The (first) resolution result or {@code null} if none.
-     */
-    public ArtifactResult getResult()
-    {
-        return ( results != null && !results.isEmpty() ) ? results.get( 0 ) : null;
-    }
-
-    private static String getMessage( List<? extends ArtifactResult> results )
-    {
-        StringBuilder buffer = new StringBuilder( 256 );
-
-        buffer.append( "The following artifacts could not be resolved: " );
-
-        int unresolved = 0;
-
-        String sep = "";
-        for ( ArtifactResult result : results )
-        {
-            if ( !result.isResolved() )
-            {
-                unresolved++;
-
-                buffer.append( sep );
-                buffer.append( result.getRequest().getArtifact() );
-                sep = ", ";
-            }
-        }
-
-        Throwable cause = getCause( results );
-        if ( cause != null )
-        {
-            if ( unresolved == 1 )
-            {
-                buffer.setLength( 0 );
-                buffer.append( cause.getMessage() );
-            }
-            else
-            {
-                buffer.append( ": " ).append( cause.getMessage() );
-            }
-        }
-
-        return buffer.toString();
-    }
-
-    private static Throwable getCause( List<? extends ArtifactResult> results )
-    {
-        for ( ArtifactResult result : results )
-        {
-            if ( !result.isResolved() )
-            {
-                Throwable notFound = null, offline = null;
-                for ( Throwable t : result.getExceptions() )
-                {
-                    if ( t instanceof ArtifactNotFoundException )
-                    {
-                        if ( notFound == null )
-                        {
-                            notFound = t;
-                        }
-                        if ( offline == null && t.getCause() instanceof RepositoryOfflineException )
-                        {
-                            offline = t;
-                        }
-                    }
-                    else
-                    {
-                        return t;
-                    }
-
-                }
-                if ( offline != null )
-                {
-                    return offline;
-                }
-                if ( notFound != null )
-                {
-                    return notFound;
-                }
-            }
-        }
-        return null;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResult.java
deleted file mode 100644 (file)
index 106ffe0..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.ArtifactRepository;
-import org.eclipse.aether.transfer.ArtifactNotFoundException;
-
-/**
- * The result of an artifact resolution request.
- * 
- * @see RepositorySystem#resolveArtifacts(RepositorySystemSession, java.util.Collection)
- * @see Artifact#getFile()
- */
-public final class ArtifactResult
-{
-
-    private final ArtifactRequest request;
-
-    private List<Exception> exceptions;
-
-    private Artifact artifact;
-
-    private ArtifactRepository repository;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The resolution request, must not be {@code null}.
-     */
-    public ArtifactResult( ArtifactRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "resolution request has not been specified" );
-        }
-        this.request = request;
-        exceptions = Collections.emptyList();
-    }
-
-    /**
-     * Gets the resolution request that was made.
-     * 
-     * @return The resolution request, never {@code null}.
-     */
-    public ArtifactRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the resolved artifact (if any). Use {@link #getExceptions()} to query the errors that occurred while trying
-     * to resolve the artifact.
-     * 
-     * @return The resolved artifact or {@code null} if the resolution failed.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the resolved artifact.
-     * 
-     * @param artifact The resolved artifact, may be {@code null} if the resolution failed.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactResult setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-        return this;
-    }
-
-    /**
-     * Gets the exceptions that occurred while resolving the artifact. Note that this list can be non-empty even if the
-     * artifact was successfully resolved, e.g. when one of the contacted remote repositories didn't contain the
-     * artifact but a later repository eventually contained it.
-     * 
-     * @return The exceptions that occurred, never {@code null}.
-     * @see #isResolved()
-     */
-    public List<Exception> getExceptions()
-    {
-        return exceptions;
-    }
-
-    /**
-     * Records the specified exception while resolving the artifact.
-     * 
-     * @param exception The exception to record, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactResult addException( Exception exception )
-    {
-        if ( exception != null )
-        {
-            if ( exceptions.isEmpty() )
-            {
-                exceptions = new ArrayList<Exception>();
-            }
-            exceptions.add( exception );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the repository from which the artifact was eventually resolved. Note that successive resolutions of the same
-     * artifact might yield different results if the employed local repository does not track the origin of an artifact.
-     * 
-     * @return The repository from which the artifact was resolved or {@code null} if unknown.
-     */
-    public ArtifactRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the repository from which the artifact was resolved.
-     * 
-     * @param repository The repository from which the artifact was resolved, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public ArtifactResult setRepository( ArtifactRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    /**
-     * Indicates whether the requested artifact was resolved. Note that the artifact might have been successfully
-     * resolved despite {@link #getExceptions()} indicating transfer errors while trying to fetch the artifact from some
-     * of the specified remote repositories.
-     * 
-     * @return {@code true} if the artifact was resolved, {@code false} otherwise.
-     * @see Artifact#getFile()
-     */
-    public boolean isResolved()
-    {
-        return getArtifact() != null && getArtifact().getFile() != null;
-    }
-
-    /**
-     * Indicates whether the requested artifact is not present in any of the specified repositories.
-     * 
-     * @return {@code true} if the artifact is not present in any repository, {@code false} otherwise.
-     */
-    public boolean isMissing()
-    {
-        for ( Exception e : getExceptions() )
-        {
-            if ( !( e instanceof ArtifactNotFoundException ) )
-            {
-                return false;
-            }
-        }
-        return !isResolved();
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifact() + " < " + getRepository();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyRequest.java
deleted file mode 100644 (file)
index f55aff7..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.collection.CollectRequest;
-import org.eclipse.aether.graph.DependencyFilter;
-import org.eclipse.aether.graph.DependencyNode;
-
-/**
- * A request to resolve transitive dependencies. This request can either be supplied with a {@link CollectRequest} to
- * calculate the transitive dependencies or with an already resolved dependency graph.
- * 
- * @see RepositorySystem#resolveDependencies(RepositorySystemSession, DependencyRequest)
- * @see Artifact#getFile()
- */
-public final class DependencyRequest
-{
-
-    private DependencyNode root;
-
-    private CollectRequest collectRequest;
-
-    private DependencyFilter filter;
-
-    private RequestTrace trace;
-
-    /**
-     * Creates an uninitialized request. Note that either {@link #setRoot(DependencyNode)} or
-     * {@link #setCollectRequest(CollectRequest)} must eventually be called to create a valid request.
-     */
-    public DependencyRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a request for the specified dependency graph and with the given resolution filter.
-     * 
-     * @param node The root node of the dependency graph whose artifacts should be resolved, may be {@code null}.
-     * @param filter The resolution filter to use, may be {@code null}.
-     */
-    public DependencyRequest( DependencyNode node, DependencyFilter filter )
-    {
-        setRoot( node );
-        setFilter( filter );
-    }
-
-    /**
-     * Creates a request for the specified collect request and with the given resolution filter.
-     * 
-     * @param request The collect request used to calculate the dependency graph whose artifacts should be resolved, may
-     *            be {@code null}.
-     * @param filter The resolution filter to use, may be {@code null}.
-     */
-    public DependencyRequest( CollectRequest request, DependencyFilter filter )
-    {
-        setCollectRequest( request );
-        setFilter( filter );
-    }
-
-    /**
-     * Gets the root node of the dependency graph whose artifacts should be resolved.
-     * 
-     * @return The root node of the dependency graph or {@code null} if none.
-     */
-    public DependencyNode getRoot()
-    {
-        return root;
-    }
-
-    /**
-     * Sets the root node of the dependency graph whose artifacts should be resolved. When this request is processed,
-     * the nodes of the given dependency graph will be updated to refer to the resolved artifacts. Eventually, either
-     * {@link #setRoot(DependencyNode)} or {@link #setCollectRequest(CollectRequest)} must be called to create a valid
-     * request.
-     * 
-     * @param root The root node of the dependency graph, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DependencyRequest setRoot( DependencyNode root )
-    {
-        this.root = root;
-        return this;
-    }
-
-    /**
-     * Gets the collect request used to calculate the dependency graph whose artifacts should be resolved.
-     * 
-     * @return The collect request or {@code null} if none.
-     */
-    public CollectRequest getCollectRequest()
-    {
-        return collectRequest;
-    }
-
-    /**
-     * Sets the collect request used to calculate the dependency graph whose artifacts should be resolved. Eventually,
-     * either {@link #setRoot(DependencyNode)} or {@link #setCollectRequest(CollectRequest)} must be called to create a
-     * valid request. If this request is supplied with a dependency node via {@link #setRoot(DependencyNode)}, the
-     * collect request is ignored.
-     * 
-     * @param collectRequest The collect request, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DependencyRequest setCollectRequest( CollectRequest collectRequest )
-    {
-        this.collectRequest = collectRequest;
-        return this;
-    }
-
-    /**
-     * Gets the resolution filter used to select which artifacts of the dependency graph should be resolved.
-     * 
-     * @return The resolution filter or {@code null} to resolve all artifacts of the dependency graph.
-     */
-    public DependencyFilter getFilter()
-    {
-        return filter;
-    }
-
-    /**
-     * Sets the resolution filter used to select which artifacts of the dependency graph should be resolved. For
-     * example, use this filter to restrict resolution to dependencies of a certain scope.
-     * 
-     * @param filter The resolution filter, may be {@code null} to resolve all artifacts of the dependency graph.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DependencyRequest setFilter( DependencyFilter filter )
-    {
-        this.filter = filter;
-        return this;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    /**
-     * Sets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @param trace The trace information about the higher level operation, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public DependencyRequest setTrace( RequestTrace trace )
-    {
-        this.trace = trace;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        if ( root != null )
-        {
-            return String.valueOf( root );
-        }
-        return String.valueOf( collectRequest );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResolutionException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResolutionException.java
deleted file mode 100644 (file)
index 27d9bb2..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case of a unresolvable dependencies.
- */
-public class DependencyResolutionException
-    extends RepositoryException
-{
-
-    private final transient DependencyResult result;
-
-    /**
-     * Creates a new exception with the specified result and cause.
-     * 
-     * @param result The dependency result at the point the exception occurred, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public DependencyResolutionException( DependencyResult result, Throwable cause )
-    {
-        super( getMessage( cause ), cause );
-        this.result = result;
-    }
-
-    /**
-     * Creates a new exception with the specified result, detail message and cause.
-     * 
-     * @param result The dependency result at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public DependencyResolutionException( DependencyResult result, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.result = result;
-    }
-
-    private static String getMessage( Throwable cause )
-    {
-        String msg = null;
-        if ( cause != null )
-        {
-            msg = cause.getMessage();
-        }
-        if ( msg == null || msg.length() <= 0 )
-        {
-            msg = "Could not resolve transitive dependencies";
-        }
-        return msg;
-    }
-
-    /**
-     * Gets the dependency result at the point the exception occurred. Despite being incomplete, callers might want to
-     * use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
-     * 
-     * @return The dependency result or {@code null} if unknown.
-     */
-    public DependencyResult getResult()
-    {
-        return result;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResult.java
deleted file mode 100644 (file)
index 3cc8d3a..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.graph.DependencyCycle;
-import org.eclipse.aether.graph.DependencyNode;
-
-/**
- * The result of a dependency resolution request.
- * 
- * @see RepositorySystem#resolveDependencies(RepositorySystemSession, DependencyRequest)
- */
-public final class DependencyResult
-{
-
-    private final DependencyRequest request;
-
-    private DependencyNode root;
-
-    private List<DependencyCycle> cycles;
-
-    private List<Exception> collectExceptions;
-
-    private List<ArtifactResult> artifactResults;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The resolution request, must not be {@code null}.
-     */
-    public DependencyResult( DependencyRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "dependency request has not been specified" );
-        }
-        this.request = request;
-        root = request.getRoot();
-        cycles = Collections.emptyList();
-        collectExceptions = Collections.emptyList();
-        artifactResults = Collections.emptyList();
-    }
-
-    /**
-     * Gets the resolution request that was made.
-     * 
-     * @return The resolution request, never {@code null}.
-     */
-    public DependencyRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the root node of the resolved dependency graph. Note that this dependency graph might be
-     * incomplete/unfinished in case of {@link #getCollectExceptions()} indicating errors during its calculation.
-     * 
-     * @return The root node of the resolved dependency graph or {@code null} if none.
-     */
-    public DependencyNode getRoot()
-    {
-        return root;
-    }
-
-    /**
-     * Sets the root node of the resolved dependency graph.
-     * 
-     * @param root The root node of the resolved dependency graph, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public DependencyResult setRoot( DependencyNode root )
-    {
-        this.root = root;
-        return this;
-    }
-
-    /**
-     * Gets the dependency cycles that were encountered while building the dependency graph. Note that dependency cycles
-     * will only be reported here if the underlying request was created from a
-     * {@link org.eclipse.aether.collection.CollectRequest CollectRequest}. If the underlying {@link DependencyRequest}
-     * was created from an existing dependency graph, information about cycles will not be available in this result.
-     * 
-     * @return The dependency cycles in the (raw) graph, never {@code null}.
-     */
-    public List<DependencyCycle> getCycles()
-    {
-        return cycles;
-    }
-
-    /**
-     * Records the specified dependency cycles while building the dependency graph.
-     * 
-     * @param cycles The dependency cycles to record, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public DependencyResult setCycles( List<DependencyCycle> cycles )
-    {
-        if ( cycles == null )
-        {
-            this.cycles = Collections.emptyList();
-        }
-        else
-        {
-            this.cycles = cycles;
-        }
-        return this;
-    }
-
-    /**
-     * Gets the exceptions that occurred while building the dependency graph.
-     * 
-     * @return The exceptions that occurred, never {@code null}.
-     */
-    public List<Exception> getCollectExceptions()
-    {
-        return collectExceptions;
-    }
-
-    /**
-     * Records the specified exceptions while building the dependency graph.
-     * 
-     * @param exceptions The exceptions to record, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public DependencyResult setCollectExceptions( List<Exception> exceptions )
-    {
-        if ( exceptions == null )
-        {
-            this.collectExceptions = Collections.emptyList();
-        }
-        else
-        {
-            this.collectExceptions = exceptions;
-        }
-        return this;
-    }
-
-    /**
-     * Gets the resolution results for the dependency artifacts that matched {@link DependencyRequest#getFilter()}.
-     * 
-     * @return The resolution results for the dependency artifacts, never {@code null}.
-     */
-    public List<ArtifactResult> getArtifactResults()
-    {
-        return artifactResults;
-    }
-
-    /**
-     * Sets the resolution results for the artifacts that matched {@link DependencyRequest#getFilter()}.
-     * 
-     * @param results The resolution results for the artifacts, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public DependencyResult setArtifactResults( List<ArtifactResult> results )
-    {
-        if ( results == null )
-        {
-            this.artifactResults = Collections.emptyList();
-        }
-        else
-        {
-            this.artifactResults = results;
-        }
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return String.valueOf( artifactResults );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataRequest.java
deleted file mode 100644 (file)
index 2f6c5f1..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * A request to resolve metadata from either a remote repository or the local repository.
- * 
- * @see RepositorySystem#resolveMetadata(RepositorySystemSession, java.util.Collection)
- * @see Metadata#getFile()
- */
-public final class MetadataRequest
-{
-
-    private Metadata metadata;
-
-    private RemoteRepository repository;
-
-    private String context = "";
-
-    private boolean deleteLocalCopyIfMissing;
-
-    private boolean favorLocalRepository;
-
-    private RequestTrace trace;
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public MetadataRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a request to resolve the specified metadata from the local repository.
-     * 
-     * @param metadata The metadata to resolve, may be {@code null}.
-     */
-    public MetadataRequest( Metadata metadata )
-    {
-        setMetadata( metadata );
-    }
-
-    /**
-     * Creates a request with the specified properties.
-     * 
-     * @param metadata The metadata to resolve, may be {@code null}.
-     * @param repository The repository to resolve the metadata from, may be {@code null} to resolve from the local
-     *            repository.
-     * @param context The context in which this request is made, may be {@code null}.
-     */
-    public MetadataRequest( Metadata metadata, RemoteRepository repository, String context )
-    {
-        setMetadata( metadata );
-        setRepository( repository );
-        setRequestContext( context );
-    }
-
-    /**
-     * Gets the metadata to resolve.
-     * 
-     * @return The metadata or {@code null} if not set.
-     */
-    public Metadata getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Sets the metadata to resolve.
-     * 
-     * @param metadata The metadata, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public MetadataRequest setMetadata( Metadata metadata )
-    {
-        this.metadata = metadata;
-        return this;
-    }
-
-    /**
-     * Gets the repository from which the metadata should be resolved.
-     * 
-     * @return The repository or {@code null} to resolve from the local repository.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the repository from which the metadata should be resolved.
-     * 
-     * @param repository The repository, may be {@code null} to resolve from the local repository.
-     * @return This request for chaining, never {@code null}.
-     */
-    public MetadataRequest setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    /**
-     * Gets the context in which this request is made.
-     * 
-     * @return The context, never {@code null}.
-     */
-    public String getRequestContext()
-    {
-        return context;
-    }
-
-    /**
-     * Sets the context in which this request is made.
-     * 
-     * @param context The context, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public MetadataRequest setRequestContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-        return this;
-    }
-
-    /**
-     * Indicates whether the locally cached copy of the metadata should be removed if the corresponding file does not
-     * exist (any more) in the remote repository.
-     * 
-     * @return {@code true} if locally cached metadata should be deleted if no corresponding remote file exists,
-     *         {@code false} to keep the local copy.
-     */
-    public boolean isDeleteLocalCopyIfMissing()
-    {
-        return deleteLocalCopyIfMissing;
-    }
-
-    /**
-     * Controls whether the locally cached copy of the metadata should be removed if the corresponding file does not
-     * exist (any more) in the remote repository.
-     * 
-     * @param deleteLocalCopyIfMissing {@code true} if locally cached metadata should be deleted if no corresponding
-     *            remote file exists, {@code false} to keep the local copy.
-     * @return This request for chaining, never {@code null}.
-     */
-    public MetadataRequest setDeleteLocalCopyIfMissing( boolean deleteLocalCopyIfMissing )
-    {
-        this.deleteLocalCopyIfMissing = deleteLocalCopyIfMissing;
-        return this;
-    }
-
-    /**
-     * Indicates whether the metadata resolution should be suppressed if the corresponding metadata of the local
-     * repository is up-to-date according to the update policy of the remote repository. In this case, the metadata
-     * resolution will even be suppressed if no local copy of the remote metadata exists yet.
-     * 
-     * @return {@code true} to suppress resolution of remote metadata if the corresponding metadata of the local
-     *         repository is up-to-date, {@code false} to resolve the remote metadata normally according to the update
-     *         policy.
-     */
-    public boolean isFavorLocalRepository()
-    {
-        return favorLocalRepository;
-    }
-
-    /**
-     * Controls resolution of remote metadata when already corresponding metadata of the local repository exists. In
-     * cases where the local repository's metadata is sufficient and going to be preferred, resolution of the remote
-     * metadata can be suppressed to avoid unnecessary network access.
-     * 
-     * @param favorLocalRepository {@code true} to suppress resolution of remote metadata if the corresponding metadata
-     *            of the local repository is up-to-date, {@code false} to resolve the remote metadata normally according
-     *            to the update policy.
-     * @return This request for chaining, never {@code null}.
-     */
-    public MetadataRequest setFavorLocalRepository( boolean favorLocalRepository )
-    {
-        this.favorLocalRepository = favorLocalRepository;
-        return this;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    /**
-     * Sets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @param trace The trace information about the higher level operation, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public MetadataRequest setTrace( RequestTrace trace )
-    {
-        this.trace = trace;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getMetadata() + " < " + getRepository();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataResult.java
deleted file mode 100644 (file)
index 3e5a7b8..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.transfer.MetadataNotFoundException;
-
-/**
- * The result of a metadata resolution request.
- * 
- * @see RepositorySystem#resolveMetadata(RepositorySystemSession, java.util.Collection)
- */
-public final class MetadataResult
-{
-
-    private final MetadataRequest request;
-
-    private Exception exception;
-
-    private boolean updated;
-
-    private Metadata metadata;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The resolution request, must not be {@code null}.
-     */
-    public MetadataResult( MetadataRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "metadata request has not been specified" );
-        }
-        this.request = request;
-    }
-
-    /**
-     * Gets the resolution request that was made.
-     * 
-     * @return The resolution request, never {@code null}.
-     */
-    public MetadataRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the resolved metadata (if any).
-     * 
-     * @return The resolved metadata or {@code null} if the resolution failed.
-     */
-    public Metadata getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Sets the resolved metadata.
-     * 
-     * @param metadata The resolved metadata, may be {@code null} if the resolution failed.
-     * @return This result for chaining, never {@code null}.
-     */
-    public MetadataResult setMetadata( Metadata metadata )
-    {
-        this.metadata = metadata;
-        return this;
-    }
-
-    /**
-     * Records the specified exception while resolving the metadata.
-     * 
-     * @param exception The exception to record, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public MetadataResult setException( Exception exception )
-    {
-        this.exception = exception;
-        return this;
-    }
-
-    /**
-     * Gets the exception that occurred while resolving the metadata.
-     * 
-     * @return The exception that occurred or {@code null} if none.
-     */
-    public Exception getException()
-    {
-        return exception;
-    }
-
-    /**
-     * Sets the updated flag for the metadata.
-     * 
-     * @param updated {@code true} if the metadata was actually fetched from the remote repository during the
-     *            resolution, {@code false} if the metadata was resolved from a locally cached copy.
-     * @return This result for chaining, never {@code null}.
-     */
-    public MetadataResult setUpdated( boolean updated )
-    {
-        this.updated = updated;
-        return this;
-    }
-
-    /**
-     * Indicates whether the metadata was actually fetched from the remote repository or resolved from the local cache.
-     * If metadata has been locally cached during a previous resolution request and this local copy is still up-to-date
-     * according to the remote repository's update policy, no remote access is made.
-     * 
-     * @return {@code true} if the metadata was actually fetched from the remote repository during the resolution,
-     *         {@code false} if the metadata was resolved from a locally cached copy.
-     */
-    public boolean isUpdated()
-    {
-        return updated;
-    }
-
-    /**
-     * Indicates whether the requested metadata was resolved. Note that the metadata might have been successfully
-     * resolved (from the local cache) despite {@link #getException()} indicating a transfer error while trying to
-     * refetch the metadata from the remote repository.
-     * 
-     * @return {@code true} if the metadata was resolved, {@code false} otherwise.
-     * @see Metadata#getFile()
-     */
-    public boolean isResolved()
-    {
-        return getMetadata() != null && getMetadata().getFile() != null;
-    }
-
-    /**
-     * Indicates whether the requested metadata is not present in the remote repository.
-     * 
-     * @return {@code true} if the metadata is not present in the remote repository, {@code false} otherwise.
-     */
-    public boolean isMissing()
-    {
-        return getException() instanceof MetadataNotFoundException;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getMetadata() + ( isUpdated() ? " (updated)" : " (cached)" );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicy.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicy.java
deleted file mode 100644 (file)
index 50d1a01..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.metadata.Metadata;
-
-/**
- * Controls the caching of resolution errors for artifacts/metadata from remote repositories. If caching is enabled for
- * a given resource, a marker will be set (usually somewhere in the local repository) to suppress repeated resolution
- * attempts for the broken resource, thereby avoiding expensive but useless network IO. The error marker is considered
- * stale once the repository's update policy has expired at which point a future resolution attempt will be allowed.
- * Error caching considers the current network settings such that fixes to the configuration like authentication or
- * proxy automatically trigger revalidation with the remote side regardless of the time elapsed since the previous
- * resolution error.
- * 
- * @see RepositorySystemSession#getResolutionErrorPolicy()
- */
-public interface ResolutionErrorPolicy
-{
-
-    /**
-     * Bit mask indicating that resolution errors should not be cached in the local repository. This forces the system
-     * to always query the remote repository for locally missing artifacts/metadata.
-     */
-    int CACHE_DISABLED = 0x00;
-
-    /**
-     * Bit flag indicating whether missing artifacts/metadata should be cached in the local repository. If caching is
-     * enabled, resolution will not be reattempted until the update policy for the affected resource has expired.
-     */
-    int CACHE_NOT_FOUND = 0x01;
-
-    /**
-     * Bit flag indicating whether connectivity/transfer errors (e.g. unreachable host, bad authentication) should be
-     * cached in the local repository. If caching is enabled, resolution will not be reattempted until the update policy
-     * for the affected resource has expired.
-     */
-    int CACHE_TRANSFER_ERROR = 0x02;
-
-    /**
-     * Bit mask indicating that all resolution errors should be cached in the local repository.
-     */
-    int CACHE_ALL = CACHE_NOT_FOUND | CACHE_TRANSFER_ERROR;
-
-    /**
-     * Gets the error policy for an artifact.
-     * 
-     * @param session The repository session during which the policy is determined, must not be {@code null}.
-     * @param request The policy request holding further details, must not be {@code null}.
-     * @return The bit mask describing the desired error policy.
-     */
-    int getArtifactPolicy( RepositorySystemSession session, ResolutionErrorPolicyRequest<Artifact> request );
-
-    /**
-     * Gets the error policy for some metadata.
-     * 
-     * @param session The repository session during which the policy is determined, must not be {@code null}.
-     * @param request The policy request holding further details, must not be {@code null}.
-     * @return The bit mask describing the desired error policy.
-     */
-    int getMetadataPolicy( RepositorySystemSession session, ResolutionErrorPolicyRequest<Metadata> request );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicyRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicyRequest.java
deleted file mode 100644 (file)
index 6d05cf3..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * A query for the resolution error policy for a given artifact/metadata.
- * 
- * @param <T> The type of the affected repository item (artifact or metadata).
- * @see ResolutionErrorPolicy
- */
-public final class ResolutionErrorPolicyRequest<T>
-{
-
-    private T item;
-
-    private RemoteRepository repository;
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public ResolutionErrorPolicyRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a request for the specified artifact/metadata and remote repository.
-     * 
-     * @param item The artifact/metadata for which to determine the error policy, may be {@code null}.
-     * @param repository The repository from which the resolution is attempted, may be {@code null}.
-     */
-    public ResolutionErrorPolicyRequest( T item, RemoteRepository repository )
-    {
-        setItem( item );
-        setRepository( repository );
-    }
-
-    /**
-     * Gets the artifact/metadata for which to determine the error policy.
-     * 
-     * @return The artifact/metadata for which to determine the error policy or {@code null} if not set.
-     */
-    public T getItem()
-    {
-        return item;
-    }
-
-    /**
-     * Sets the artifact/metadata for which to determine the error policy.
-     * 
-     * @param item The artifact/metadata for which to determine the error policy, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ResolutionErrorPolicyRequest<T> setItem( T item )
-    {
-        this.item = item;
-        return this;
-    }
-
-    /**
-     * Gets the remote repository from which the resolution of the artifact/metadata is attempted.
-     * 
-     * @return The involved remote repository or {@code null} if not set.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the remote repository from which the resolution of the artifact/metadata is attempted.
-     * 
-     * @param repository The repository from which the resolution is attempted, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public ResolutionErrorPolicyRequest<T> setRepository( RemoteRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getItem() + " < " + getRepository();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeRequest.java
deleted file mode 100644 (file)
index b40feb6..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * A request to resolve a version range.
- * 
- * @see RepositorySystem#resolveVersionRange(RepositorySystemSession, VersionRangeRequest)
- */
-public final class VersionRangeRequest
-{
-
-    private Artifact artifact;
-
-    private List<RemoteRepository> repositories = Collections.emptyList();
-
-    private String context = "";
-
-    private RequestTrace trace;
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public VersionRangeRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a request with the specified properties.
-     * 
-     * @param artifact The artifact whose version range should be resolved, may be {@code null}.
-     * @param repositories The repositories to resolve the version from, may be {@code null}.
-     * @param context The context in which this request is made, may be {@code null}.
-     */
-    public VersionRangeRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
-    {
-        setArtifact( artifact );
-        setRepositories( repositories );
-        setRequestContext( context );
-    }
-
-    /**
-     * Gets the artifact whose version range shall be resolved.
-     * 
-     * @return The artifact or {@code null} if not set.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the artifact whose version range shall be resolved.
-     * 
-     * @param artifact The artifact, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRangeRequest setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-        return this;
-    }
-
-    /**
-     * Gets the repositories to resolve the version range from.
-     * 
-     * @return The repositories, never {@code null}.
-     */
-    public List<RemoteRepository> getRepositories()
-    {
-        return repositories;
-    }
-
-    /**
-     * Sets the repositories to resolve the version range from.
-     * 
-     * @param repositories The repositories, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRangeRequest setRepositories( List<RemoteRepository> repositories )
-    {
-        if ( repositories == null )
-        {
-            this.repositories = Collections.emptyList();
-        }
-        else
-        {
-            this.repositories = repositories;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified repository for the resolution.
-     * 
-     * @param repository The repository to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRangeRequest addRepository( RemoteRepository repository )
-    {
-        if ( repository != null )
-        {
-            if ( this.repositories.isEmpty() )
-            {
-                this.repositories = new ArrayList<RemoteRepository>();
-            }
-            this.repositories.add( repository );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the context in which this request is made.
-     * 
-     * @return The context, never {@code null}.
-     */
-    public String getRequestContext()
-    {
-        return context;
-    }
-
-    /**
-     * Sets the context in which this request is made.
-     * 
-     * @param context The context, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRangeRequest setRequestContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-        return this;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    /**
-     * Sets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @param trace The trace information about the higher level operation, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRangeRequest setTrace( RequestTrace trace )
-    {
-        this.trace = trace;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifact() + " < " + getRepositories();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResolutionException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResolutionException.java
deleted file mode 100644 (file)
index 6e62e3f..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case of an unparseable or unresolvable version range.
- */
-public class VersionRangeResolutionException
-    extends RepositoryException
-{
-
-    private final transient VersionRangeResult result;
-
-    /**
-     * Creates a new exception with the specified result.
-     * 
-     * @param result The version range result at the point the exception occurred, may be {@code null}.
-     */
-    public VersionRangeResolutionException( VersionRangeResult result )
-    {
-        super( getMessage( result ), getCause( result ) );
-        this.result = result;
-    }
-
-    private static String getMessage( VersionRangeResult result )
-    {
-        StringBuilder buffer = new StringBuilder( 256 );
-        buffer.append( "Failed to resolve version range" );
-        if ( result != null )
-        {
-            buffer.append( " for " ).append( result.getRequest().getArtifact() );
-            if ( !result.getExceptions().isEmpty() )
-            {
-                buffer.append( ": " ).append( result.getExceptions().iterator().next().getMessage() );
-            }
-        }
-        return buffer.toString();
-    }
-
-    private static Throwable getCause( VersionRangeResult result )
-    {
-        Throwable cause = null;
-        if ( result != null && !result.getExceptions().isEmpty() )
-        {
-            cause = result.getExceptions().get( 0 );
-        }
-        return cause;
-    }
-
-    /**
-     * Creates a new exception with the specified result and detail message.
-     * 
-     * @param result The version range result at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public VersionRangeResolutionException( VersionRangeResult result, String message )
-    {
-        super( message );
-        this.result = result;
-    }
-
-    /**
-     * Creates a new exception with the specified result, detail message and cause.
-     * 
-     * @param result The version range result at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public VersionRangeResolutionException( VersionRangeResult result, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.result = result;
-    }
-
-    /**
-     * Gets the version range result at the point the exception occurred. Despite being incomplete, callers might want
-     * to use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
-     * 
-     * @return The version range result or {@code null} if unknown.
-     */
-    public VersionRangeResult getResult()
-    {
-        return result;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResult.java
deleted file mode 100644 (file)
index fd233f1..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.ArtifactRepository;
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionConstraint;
-
-/**
- * The result of a version range resolution request.
- * 
- * @see RepositorySystem#resolveVersionRange(RepositorySystemSession, VersionRangeRequest)
- */
-public final class VersionRangeResult
-{
-
-    private final VersionRangeRequest request;
-
-    private List<Exception> exceptions;
-
-    private List<Version> versions;
-
-    private Map<Version, ArtifactRepository> repositories;
-
-    private VersionConstraint versionConstraint;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The resolution request, must not be {@code null}.
-     */
-    public VersionRangeResult( VersionRangeRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "version range request has not been specified" );
-        }
-        this.request = request;
-        exceptions = Collections.emptyList();
-        versions = Collections.emptyList();
-        repositories = Collections.emptyMap();
-    }
-
-    /**
-     * Gets the resolution request that was made.
-     * 
-     * @return The resolution request, never {@code null}.
-     */
-    public VersionRangeRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the exceptions that occurred while resolving the version range.
-     * 
-     * @return The exceptions that occurred, never {@code null}.
-     */
-    public List<Exception> getExceptions()
-    {
-        return exceptions;
-    }
-
-    /**
-     * Records the specified exception while resolving the version range.
-     * 
-     * @param exception The exception to record, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public VersionRangeResult addException( Exception exception )
-    {
-        if ( exception != null )
-        {
-            if ( exceptions.isEmpty() )
-            {
-                exceptions = new ArrayList<Exception>();
-            }
-            exceptions.add( exception );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the versions (in ascending order) that matched the requested range.
-     * 
-     * @return The matching versions (if any), never {@code null}.
-     */
-    public List<Version> getVersions()
-    {
-        return versions;
-    }
-
-    /**
-     * Adds the specified version to the result. Note that versions must be added in ascending order.
-     * 
-     * @param version The version to add, must not be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public VersionRangeResult addVersion( Version version )
-    {
-        if ( versions.isEmpty() )
-        {
-            versions = new ArrayList<Version>();
-        }
-        versions.add( version );
-        return this;
-    }
-
-    /**
-     * Sets the versions (in ascending order) matching the requested range.
-     * 
-     * @param versions The matching versions, may be empty or {@code null} if none.
-     * @return This result for chaining, never {@code null}.
-     */
-    public VersionRangeResult setVersions( List<Version> versions )
-    {
-        if ( versions == null )
-        {
-            this.versions = Collections.emptyList();
-        }
-        else
-        {
-            this.versions = versions;
-        }
-        return this;
-    }
-
-    /**
-     * Gets the lowest version matching the requested range.
-     * 
-     * @return The lowest matching version or {@code null} if no versions matched the requested range.
-     */
-    public Version getLowestVersion()
-    {
-        if ( versions.isEmpty() )
-        {
-            return null;
-        }
-        return versions.get( 0 );
-    }
-
-    /**
-     * Gets the highest version matching the requested range.
-     * 
-     * @return The highest matching version or {@code null} if no versions matched the requested range.
-     */
-    public Version getHighestVersion()
-    {
-        if ( versions.isEmpty() )
-        {
-            return null;
-        }
-        return versions.get( versions.size() - 1 );
-    }
-
-    /**
-     * Gets the repository from which the specified version was resolved.
-     * 
-     * @param version The version whose source repository should be retrieved, must not be {@code null}.
-     * @return The repository from which the version was resolved or {@code null} if unknown.
-     */
-    public ArtifactRepository getRepository( Version version )
-    {
-        return repositories.get( version );
-    }
-
-    /**
-     * Records the repository from which the specified version was resolved
-     * 
-     * @param version The version whose source repository is to be recorded, must not be {@code null}.
-     * @param repository The repository from which the version was resolved, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public VersionRangeResult setRepository( Version version, ArtifactRepository repository )
-    {
-        if ( repository != null )
-        {
-            if ( repositories.isEmpty() )
-            {
-                repositories = new HashMap<Version, ArtifactRepository>();
-            }
-            repositories.put( version, repository );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the version constraint that was parsed from the artifact's version string.
-     * 
-     * @return The parsed version constraint or {@code null}.
-     */
-    public VersionConstraint getVersionConstraint()
-    {
-        return versionConstraint;
-    }
-
-    /**
-     * Sets the version constraint that was parsed from the artifact's version string.
-     * 
-     * @param versionConstraint The parsed version constraint, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public VersionRangeResult setVersionConstraint( VersionConstraint versionConstraint )
-    {
-        this.versionConstraint = versionConstraint;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return String.valueOf( repositories );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRequest.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRequest.java
deleted file mode 100644 (file)
index e18701b..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.RequestTrace;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * A request to resolve a metaversion.
- * 
- * @see RepositorySystem#resolveVersion(RepositorySystemSession, VersionRequest)
- */
-public final class VersionRequest
-{
-
-    private Artifact artifact;
-
-    private List<RemoteRepository> repositories = Collections.emptyList();
-
-    private String context = "";
-
-    private RequestTrace trace;
-
-    /**
-     * Creates an uninitialized request.
-     */
-    public VersionRequest()
-    {
-        // enables default constructor
-    }
-
-    /**
-     * Creates a request with the specified properties.
-     * 
-     * @param artifact The artifact whose (meta-)version should be resolved, may be {@code null}.
-     * @param repositories The repositories to resolve the version from, may be {@code null}.
-     * @param context The context in which this request is made, may be {@code null}.
-     */
-    public VersionRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
-    {
-        setArtifact( artifact );
-        setRepositories( repositories );
-        setRequestContext( context );
-    }
-
-    /**
-     * Gets the artifact whose (meta-)version shall be resolved.
-     * 
-     * @return The artifact or {@code null} if not set.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Sets the artifact whose (meta-)version shall be resolved.
-     * 
-     * @param artifact The artifact, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRequest setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-        return this;
-    }
-
-    /**
-     * Gets the repositories to resolve the version from.
-     * 
-     * @return The repositories, never {@code null}.
-     */
-    public List<RemoteRepository> getRepositories()
-    {
-        return repositories;
-    }
-
-    /**
-     * Sets the repositories to resolve the version from.
-     * 
-     * @param repositories The repositories, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRequest setRepositories( List<RemoteRepository> repositories )
-    {
-        if ( repositories == null )
-        {
-            this.repositories = Collections.emptyList();
-        }
-        else
-        {
-            this.repositories = repositories;
-        }
-        return this;
-    }
-
-    /**
-     * Adds the specified repository for the resolution.
-     * 
-     * @param repository The repository to add, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRequest addRepository( RemoteRepository repository )
-    {
-        if ( repository != null )
-        {
-            if ( this.repositories.isEmpty() )
-            {
-                this.repositories = new ArrayList<RemoteRepository>();
-            }
-            this.repositories.add( repository );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the context in which this request is made.
-     * 
-     * @return The context, never {@code null}.
-     */
-    public String getRequestContext()
-    {
-        return context;
-    }
-
-    /**
-     * Sets the context in which this request is made.
-     * 
-     * @param context The context, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRequest setRequestContext( String context )
-    {
-        this.context = ( context != null ) ? context : "";
-        return this;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    /**
-     * Sets the trace information that describes the higher level request/operation in which this request is issued.
-     * 
-     * @param trace The trace information about the higher level operation, may be {@code null}.
-     * @return This request for chaining, never {@code null}.
-     */
-    public VersionRequest setTrace( RequestTrace trace )
-    {
-        this.trace = trace;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getArtifact() + " < " + getRepositories();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResolutionException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResolutionException.java
deleted file mode 100644 (file)
index 25f381e..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case of an unresolvable metaversion.
- */
-public class VersionResolutionException
-    extends RepositoryException
-{
-
-    private final transient VersionResult result;
-
-    /**
-     * Creates a new exception with the specified result.
-     * 
-     * @param result The version result at the point the exception occurred, may be {@code null}.
-     */
-    public VersionResolutionException( VersionResult result )
-    {
-        super( getMessage( result ), getCause( result ) );
-        this.result = result;
-    }
-
-    private static String getMessage( VersionResult result )
-    {
-        StringBuilder buffer = new StringBuilder( 256 );
-        buffer.append( "Failed to resolve version" );
-        if ( result != null )
-        {
-            buffer.append( " for " ).append( result.getRequest().getArtifact() );
-            if ( !result.getExceptions().isEmpty() )
-            {
-                buffer.append( ": " ).append( result.getExceptions().iterator().next().getMessage() );
-            }
-        }
-        return buffer.toString();
-    }
-
-    private static Throwable getCause( VersionResult result )
-    {
-        Throwable cause = null;
-        if ( result != null && !result.getExceptions().isEmpty() )
-        {
-            cause = result.getExceptions().get( 0 );
-        }
-        return cause;
-    }
-
-    /**
-     * Creates a new exception with the specified result and detail message.
-     * 
-     * @param result The version result at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public VersionResolutionException( VersionResult result, String message )
-    {
-        super( message, getCause( result ) );
-        this.result = result;
-    }
-
-    /**
-     * Creates a new exception with the specified result, detail message and cause.
-     * 
-     * @param result The version result at the point the exception occurred, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public VersionResolutionException( VersionResult result, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.result = result;
-    }
-
-    /**
-     * Gets the version result at the point the exception occurred. Despite being incomplete, callers might want to use
-     * this result to fail gracefully and continue their operation with whatever interim data has been gathered.
-     * 
-     * @return The version result or {@code null} if unknown.
-     */
-    public VersionResult getResult()
-    {
-        return result;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResult.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResult.java
deleted file mode 100644 (file)
index 2e76b1c..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.resolution;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.repository.ArtifactRepository;
-
-/**
- * The result of a version resolution request.
- * 
- * @see RepositorySystem#resolveVersion(RepositorySystemSession, VersionRequest)
- */
-public final class VersionResult
-{
-
-    private final VersionRequest request;
-
-    private List<Exception> exceptions;
-
-    private String version;
-
-    private ArtifactRepository repository;
-
-    /**
-     * Creates a new result for the specified request.
-     * 
-     * @param request The resolution request, must not be {@code null}.
-     */
-    public VersionResult( VersionRequest request )
-    {
-        if ( request == null )
-        {
-            throw new IllegalArgumentException( "version request has not been specified" );
-        }
-        this.request = request;
-        exceptions = Collections.emptyList();
-    }
-
-    /**
-     * Gets the resolution request that was made.
-     * 
-     * @return The resolution request, never {@code null}.
-     */
-    public VersionRequest getRequest()
-    {
-        return request;
-    }
-
-    /**
-     * Gets the exceptions that occurred while resolving the version.
-     * 
-     * @return The exceptions that occurred, never {@code null}.
-     */
-    public List<Exception> getExceptions()
-    {
-        return exceptions;
-    }
-
-    /**
-     * Records the specified exception while resolving the version.
-     * 
-     * @param exception The exception to record, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public VersionResult addException( Exception exception )
-    {
-        if ( exception != null )
-        {
-            if ( exceptions.isEmpty() )
-            {
-                exceptions = new ArrayList<Exception>();
-            }
-            exceptions.add( exception );
-        }
-        return this;
-    }
-
-    /**
-     * Gets the resolved version.
-     * 
-     * @return The resolved version or {@code null} if the resolution failed.
-     */
-    public String getVersion()
-    {
-        return version;
-    }
-
-    /**
-     * Sets the resolved version.
-     * 
-     * @param version The resolved version, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public VersionResult setVersion( String version )
-    {
-        this.version = version;
-        return this;
-    }
-
-    /**
-     * Gets the repository from which the version was eventually resolved.
-     * 
-     * @return The repository from which the version was resolved or {@code null} if unknown.
-     */
-    public ArtifactRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Sets the repository from which the version was resolved.
-     * 
-     * @param repository The repository from which the version was resolved, may be {@code null}.
-     * @return This result for chaining, never {@code null}.
-     */
-    public VersionResult setRepository( ArtifactRepository repository )
-    {
-        this.repository = repository;
-        return this;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getVersion() + " @ " + getRepository();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/resolution/package-info.java
deleted file mode 100644 (file)
index 84b825b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The types supporting the resolution of artifacts and metadata from repositories.
- */
-package org.eclipse.aether.resolution;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/AbstractTransferListener.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/AbstractTransferListener.java
deleted file mode 100644 (file)
index 01aff17..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-/**
- * A skeleton implementation for custom transfer listeners. The callback methods in this class do nothing.
- */
-public abstract class AbstractTransferListener
-    implements TransferListener
-{
-
-    /**
-     * Enables subclassing.
-     */
-    protected AbstractTransferListener()
-    {
-    }
-
-    public void transferInitiated( TransferEvent event )
-        throws TransferCancelledException
-    {
-    }
-
-    public void transferStarted( TransferEvent event )
-        throws TransferCancelledException
-    {
-    }
-
-    public void transferProgressed( TransferEvent event )
-        throws TransferCancelledException
-    {
-    }
-
-    public void transferCorrupted( TransferEvent event )
-        throws TransferCancelledException
-    {
-    }
-
-    public void transferSucceeded( TransferEvent event )
-    {
-    }
-
-    public void transferFailed( TransferEvent event )
-    {
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactNotFoundException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactNotFoundException.java
deleted file mode 100644 (file)
index 3813743..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.ArtifactProperties;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * Thrown when an artifact was not found in a particular repository.
- */
-public class ArtifactNotFoundException
-    extends ArtifactTransferException
-{
-
-    /**
-     * Creates a new exception with the specified artifact and repository.
-     * 
-     * @param artifact The missing artifact, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     */
-    public ArtifactNotFoundException( Artifact artifact, RemoteRepository repository )
-    {
-        super( artifact, repository, getMessage( artifact, repository ) );
-    }
-
-    private static String getMessage( Artifact artifact, RemoteRepository repository )
-    {
-        StringBuilder buffer = new StringBuilder( 256 );
-        buffer.append( "Could not find artifact " ).append( artifact );
-        buffer.append( getString( " in ", repository ) );
-        if ( artifact != null )
-        {
-            String localPath = artifact.getProperty( ArtifactProperties.LOCAL_PATH, null );
-            if ( localPath != null && repository == null )
-            {
-                buffer.append( " at specified path " ).append( localPath );
-            }
-            String downloadUrl = artifact.getProperty( ArtifactProperties.DOWNLOAD_URL, null );
-            if ( downloadUrl != null )
-            {
-                buffer.append( ", try downloading from " ).append( downloadUrl );
-            }
-        }
-        return buffer.toString();
-    }
-
-    /**
-     * Creates a new exception with the specified artifact, repository and detail message.
-     * 
-     * @param artifact The missing artifact, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public ArtifactNotFoundException( Artifact artifact, RemoteRepository repository, String message )
-    {
-        super( artifact, repository, message );
-    }
-
-    /**
-     * Creates a new exception with the specified artifact, repository and detail message.
-     * 
-     * @param artifact The missing artifact, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
-     *            exception actually just occurred.
-     */
-    public ArtifactNotFoundException( Artifact artifact, RemoteRepository repository, String message, boolean fromCache )
-    {
-        super( artifact, repository, message, fromCache );
-    }
-
-    /**
-     * Creates a new exception with the specified artifact, repository, detail message and cause.
-     * 
-     * @param artifact The missing artifact, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public ArtifactNotFoundException( Artifact artifact, RemoteRepository repository, String message, Throwable cause )
-    {
-        super( artifact, repository, message, cause );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactTransferException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactTransferException.java
deleted file mode 100644 (file)
index 5a481ee..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * Thrown when an artifact could not be uploaded/downloaded to/from a particular remote repository.
- */
-public class ArtifactTransferException
-    extends RepositoryException
-{
-
-    private final transient Artifact artifact;
-
-    private final transient RemoteRepository repository;
-
-    private final boolean fromCache;
-
-    static String getString( String prefix, RemoteRepository repository )
-    {
-        if ( repository == null )
-        {
-            return "";
-        }
-        else
-        {
-            return prefix + repository.getId() + " (" + repository.getUrl() + ")";
-        }
-    }
-
-    /**
-     * Creates a new exception with the specified artifact, repository and detail message.
-     * 
-     * @param artifact The untransferable artifact, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public ArtifactTransferException( Artifact artifact, RemoteRepository repository, String message )
-    {
-        this( artifact, repository, message, false );
-    }
-
-    /**
-     * Creates a new exception with the specified artifact, repository and detail message.
-     * 
-     * @param artifact The untransferable artifact, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
-     *            exception actually just occurred.
-     */
-    public ArtifactTransferException( Artifact artifact, RemoteRepository repository, String message, boolean fromCache )
-    {
-        super( message );
-        this.artifact = artifact;
-        this.repository = repository;
-        this.fromCache = fromCache;
-    }
-
-    /**
-     * Creates a new exception with the specified artifact, repository and cause.
-     * 
-     * @param artifact The untransferable artifact, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public ArtifactTransferException( Artifact artifact, RemoteRepository repository, Throwable cause )
-    {
-        this( artifact, repository, "Could not transfer artifact " + artifact + getString( " from/to ", repository )
-            + getMessage( ": ", cause ), cause );
-    }
-
-    /**
-     * Creates a new exception with the specified artifact, repository, detail message and cause.
-     * 
-     * @param artifact The untransferable artifact, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public ArtifactTransferException( Artifact artifact, RemoteRepository repository, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.artifact = artifact;
-        this.repository = repository;
-        this.fromCache = false;
-    }
-
-    /**
-     * Gets the artifact that could not be transferred.
-     * 
-     * @return The troublesome artifact or {@code null} if unknown.
-     */
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    /**
-     * Gets the remote repository involved in the transfer.
-     * 
-     * @return The involved remote repository or {@code null} if unknown.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Indicates whether this exception actually just occurred or was played back from the error cache.
-     * 
-     * @return {@code true} if the exception was played back from the error cache, {@code false} if the exception
-     *         actually occurred just now.
-     */
-    public boolean isFromCache()
-    {
-        return fromCache;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ChecksumFailureException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ChecksumFailureException.java
deleted file mode 100644 (file)
index e3f248a..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case of a checksum failure during an artifact/metadata download.
- */
-public class ChecksumFailureException
-    extends RepositoryException
-{
-
-    private final String expected;
-
-    private final String actual;
-
-    private final boolean retryWorthy;
-
-    /**
-     * Creates a new exception with the specified expected and actual checksum. The resulting exception is
-     * {@link #isRetryWorthy() retry-worthy}.
-     * 
-     * @param expected The expected checksum as declared by the hosting repository, may be {@code null}.
-     * @param actual The actual checksum as computed from the local bytes, may be {@code null}.
-     */
-    public ChecksumFailureException( String expected, String actual )
-    {
-        super( "Checksum validation failed, expected " + expected + " but is " + actual );
-        this.expected = expected;
-        this.actual = actual;
-        retryWorthy = true;
-    }
-
-    /**
-     * Creates a new exception with the specified detail message. The resulting exception is not
-     * {@link #isRetryWorthy() retry-worthy}.
-     * 
-     * @param message The detail message, may be {@code null}.
-     */
-    public ChecksumFailureException( String message )
-    {
-        this( false, message, null );
-    }
-
-    /**
-     * Creates a new exception with the specified cause. The resulting exception is not {@link #isRetryWorthy()
-     * retry-worthy}.
-     * 
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public ChecksumFailureException( Throwable cause )
-    {
-        this( "Checksum validation failed" + getMessage( ": ", cause ), cause );
-    }
-
-    /**
-     * Creates a new exception with the specified detail message and cause. The resulting exception is not
-     * {@link #isRetryWorthy() retry-worthy}.
-     * 
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public ChecksumFailureException( String message, Throwable cause )
-    {
-        this( false, message, cause );
-    }
-
-    /**
-     * Creates a new exception with the specified retry flag, detail message and cause.
-     * 
-     * @param retryWorthy {@code true} if the exception is retry-worthy, {@code false} otherwise.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public ChecksumFailureException( boolean retryWorthy, String message, Throwable cause )
-    {
-        super( message, cause );
-        expected = actual = "";
-        this.retryWorthy = retryWorthy;
-    }
-
-    /**
-     * Gets the expected checksum for the downloaded artifact/metadata.
-     * 
-     * @return The expected checksum as declared by the hosting repository or {@code null} if unknown.
-     */
-    public String getExpected()
-    {
-        return expected;
-    }
-
-    /**
-     * Gets the actual checksum for the downloaded artifact/metadata.
-     * 
-     * @return The actual checksum as computed from the local bytes or {@code null} if unknown.
-     */
-    public String getActual()
-    {
-        return actual;
-    }
-
-    /**
-     * Indicates whether the corresponding download is retry-worthy.
-     * 
-     * @return {@code true} if retrying the download might solve the checksum failure, {@code false} if the checksum
-     *         failure is non-recoverable.
-     */
-    public boolean isRetryWorthy()
-    {
-        return retryWorthy;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataNotFoundException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataNotFoundException.java
deleted file mode 100644 (file)
index af9a840..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * Thrown when metadata was not found in a particular repository.
- */
-public class MetadataNotFoundException
-    extends MetadataTransferException
-{
-
-    /**
-     * Creates a new exception with the specified metadata and local repository.
-     * 
-     * @param metadata The missing metadata, may be {@code null}.
-     * @param repository The involved local repository, may be {@code null}.
-     */
-    public MetadataNotFoundException( Metadata metadata, LocalRepository repository )
-    {
-        super( metadata, null, "Could not find metadata " + metadata + getString( " in ", repository ) );
-    }
-
-    private static String getString( String prefix, LocalRepository repository )
-    {
-        if ( repository == null )
-        {
-            return "";
-        }
-        else
-        {
-            return prefix + repository.getId() + " (" + repository.getBasedir() + ")";
-        }
-    }
-
-    /**
-     * Creates a new exception with the specified metadata and repository.
-     * 
-     * @param metadata The missing metadata, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     */
-    public MetadataNotFoundException( Metadata metadata, RemoteRepository repository )
-    {
-        super( metadata, repository, "Could not find metadata " + metadata + getString( " in ", repository ) );
-    }
-
-    /**
-     * Creates a new exception with the specified metadata, repository and detail message.
-     * 
-     * @param metadata The missing metadata, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message )
-    {
-        super( metadata, repository, message );
-    }
-
-    /**
-     * Creates a new exception with the specified metadata, repository and detail message.
-     * 
-     * @param metadata The missing metadata, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
-     *            exception actually just occurred.
-     */
-    public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message, boolean fromCache )
-    {
-        super( metadata, repository, message, fromCache );
-    }
-
-    /**
-     * Creates a new exception with the specified metadata, repository, detail message and cause.
-     * 
-     * @param metadata The missing metadata, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message, Throwable cause )
-    {
-        super( metadata, repository, message, cause );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataTransferException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataTransferException.java
deleted file mode 100644 (file)
index f86b986..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * Thrown when metadata could not be uploaded/downloaded to/from a particular remote repository.
- */
-public class MetadataTransferException
-    extends RepositoryException
-{
-
-    private final transient Metadata metadata;
-
-    private final transient RemoteRepository repository;
-
-    private final boolean fromCache;
-
-    static String getString( String prefix, RemoteRepository repository )
-    {
-        if ( repository == null )
-        {
-            return "";
-        }
-        else
-        {
-            return prefix + repository.getId() + " (" + repository.getUrl() + ")";
-        }
-    }
-
-    /**
-     * Creates a new exception with the specified metadata, repository and detail message.
-     * 
-     * @param metadata The untransferable metadata, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public MetadataTransferException( Metadata metadata, RemoteRepository repository, String message )
-    {
-        this( metadata, repository, message, false );
-    }
-
-    /**
-     * Creates a new exception with the specified metadata, repository and detail message.
-     * 
-     * @param metadata The untransferable metadata, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
-     *            exception actually just occurred.
-     */
-    public MetadataTransferException( Metadata metadata, RemoteRepository repository, String message, boolean fromCache )
-    {
-        super( message );
-        this.metadata = metadata;
-        this.repository = repository;
-        this.fromCache = fromCache;
-    }
-
-    /**
-     * Creates a new exception with the specified metadata, repository and cause.
-     * 
-     * @param metadata The untransferable metadata, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public MetadataTransferException( Metadata metadata, RemoteRepository repository, Throwable cause )
-    {
-        this( metadata, repository, "Could not transfer metadata " + metadata + getString( " from/to ", repository )
-            + getMessage( ": ", cause ), cause );
-    }
-
-    /**
-     * Creates a new exception with the specified metadata, repository, detail message and cause.
-     * 
-     * @param metadata The untransferable metadata, may be {@code null}.
-     * @param repository The involved remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public MetadataTransferException( Metadata metadata, RemoteRepository repository, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.metadata = metadata;
-        this.repository = repository;
-        this.fromCache = false;
-    }
-
-    /**
-     * Gets the metadata that could not be transferred.
-     * 
-     * @return The troublesome metadata or {@code null} if unknown.
-     */
-    public Metadata getMetadata()
-    {
-        return metadata;
-    }
-
-    /**
-     * Gets the remote repository involved in the transfer.
-     * 
-     * @return The involved remote repository or {@code null} if unknown.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-    /**
-     * Indicates whether this exception actually just occurred or was played back from the error cache.
-     * 
-     * @return {@code true} if the exception was played back from the error cache, {@code false} if the exception
-     *         actually occurred just now.
-     */
-    public boolean isFromCache()
-    {
-        return fromCache;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryConnectorException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryConnectorException.java
deleted file mode 100644 (file)
index c91be2b..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * Thrown in case of an unsupported remote repository type.
- */
-public class NoRepositoryConnectorException
-    extends RepositoryException
-{
-
-    private final transient RemoteRepository repository;
-
-    /**
-     * Creates a new exception with the specified repository.
-     * 
-     * @param repository The remote repository whose content type is not supported, may be {@code null}.
-     */
-    public NoRepositoryConnectorException( RemoteRepository repository )
-    {
-        this( repository, toMessage( repository ) );
-    }
-
-    /**
-     * Creates a new exception with the specified repository and detail message.
-     * 
-     * @param repository The remote repository whose content type is not supported, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public NoRepositoryConnectorException( RemoteRepository repository, String message )
-    {
-        super( message );
-        this.repository = repository;
-    }
-
-    /**
-     * Creates a new exception with the specified repository and cause.
-     * 
-     * @param repository The remote repository whose content type is not supported, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public NoRepositoryConnectorException( RemoteRepository repository, Throwable cause )
-    {
-        this( repository, toMessage( repository ), cause );
-    }
-
-    /**
-     * Creates a new exception with the specified repository, detail message and cause.
-     * 
-     * @param repository The remote repository whose content type is not supported, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public NoRepositoryConnectorException( RemoteRepository repository, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.repository = repository;
-    }
-
-    private static String toMessage( RemoteRepository repository )
-    {
-        if ( repository != null )
-        {
-            return "No connector available to access repository " + repository.getId() + " (" + repository.getUrl()
-                + ") of type " + repository.getContentType();
-        }
-        else
-        {
-            return "No connector available to access repository";
-        }
-    }
-
-    /**
-     * Gets the remote repository whose content type is not supported.
-     * 
-     * @return The unsupported remote repository or {@code null} if unknown.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryLayoutException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryLayoutException.java
deleted file mode 100644 (file)
index 3176601..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * Thrown in case of an unsupported repository layout.
- */
-public class NoRepositoryLayoutException
-    extends RepositoryException
-{
-
-    private final transient RemoteRepository repository;
-
-    /**
-     * Creates a new exception with the specified repository.
-     * 
-     * @param repository The remote repository whose layout is not supported, may be {@code null}.
-     */
-    public NoRepositoryLayoutException( RemoteRepository repository )
-    {
-        this( repository, toMessage( repository ) );
-    }
-
-    /**
-     * Creates a new exception with the specified repository and detail message.
-     * 
-     * @param repository The remote repository whose layout is not supported, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public NoRepositoryLayoutException( RemoteRepository repository, String message )
-    {
-        super( message );
-        this.repository = repository;
-    }
-
-    /**
-     * Creates a new exception with the specified repository and cause.
-     * 
-     * @param repository The remote repository whose layout is not supported, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public NoRepositoryLayoutException( RemoteRepository repository, Throwable cause )
-    {
-        this( repository, toMessage( repository ), cause );
-    }
-
-    /**
-     * Creates a new exception with the specified repository, detail message and cause.
-     * 
-     * @param repository The remote repository whose layout is not supported, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public NoRepositoryLayoutException( RemoteRepository repository, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.repository = repository;
-    }
-
-    private static String toMessage( RemoteRepository repository )
-    {
-        if ( repository != null )
-        {
-            return "Unsupported repository layout " + repository.getContentType();
-        }
-        else
-        {
-            return "Unsupported repository layout";
-        }
-    }
-
-    /**
-     * Gets the remote repository whose layout is not supported.
-     * 
-     * @return The unsupported remote repository or {@code null} if unknown.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoTransporterException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoTransporterException.java
deleted file mode 100644 (file)
index 895b066..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * Thrown in case of an unsupported transport protocol.
- */
-public class NoTransporterException
-    extends RepositoryException
-{
-
-    private final transient RemoteRepository repository;
-
-    /**
-     * Creates a new exception with the specified repository.
-     * 
-     * @param repository The remote repository whose transport layout is not supported, may be {@code null}.
-     */
-    public NoTransporterException( RemoteRepository repository )
-    {
-        this( repository, toMessage( repository ) );
-    }
-
-    /**
-     * Creates a new exception with the specified repository and detail message.
-     * 
-     * @param repository The remote repository whose transport layout is not supported, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public NoTransporterException( RemoteRepository repository, String message )
-    {
-        super( message );
-        this.repository = repository;
-    }
-
-    /**
-     * Creates a new exception with the specified repository and cause.
-     * 
-     * @param repository The remote repository whose transport layout is not supported, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public NoTransporterException( RemoteRepository repository, Throwable cause )
-    {
-        this( repository, toMessage( repository ), cause );
-    }
-
-    /**
-     * Creates a new exception with the specified repository, detail message and cause.
-     * 
-     * @param repository The remote repository whose transport layout is not supported, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public NoTransporterException( RemoteRepository repository, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.repository = repository;
-    }
-
-    private static String toMessage( RemoteRepository repository )
-    {
-        if ( repository != null )
-        {
-            return "Unsupported transport protocol " + repository.getProtocol();
-        }
-        else
-        {
-            return "Unsupported transport protocol";
-        }
-    }
-
-    /**
-     * Gets the remote repository whose transport protocol is not supported.
-     * 
-     * @return The unsupported remote repository or {@code null} if unknown.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/RepositoryOfflineException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/RepositoryOfflineException.java
deleted file mode 100644 (file)
index 1115054..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.RepositoryException;
-import org.eclipse.aether.repository.RemoteRepository;
-
-/**
- * Thrown when a transfer could not be performed because a remote repository is not accessible in offline mode.
- */
-public class RepositoryOfflineException
-    extends RepositoryException
-{
-
-    private final transient RemoteRepository repository;
-
-    private static String getMessage( RemoteRepository repository )
-    {
-        if ( repository == null )
-        {
-            return "Cannot access remote repositories in offline mode";
-        }
-        else
-        {
-            return "Cannot access " + repository.getId() + " (" + repository.getUrl() + ") in offline mode";
-        }
-    }
-
-    /**
-     * Creates a new exception with the specified repository.
-     * 
-     * @param repository The inaccessible remote repository, may be {@code null}.
-     */
-    public RepositoryOfflineException( RemoteRepository repository )
-    {
-        super( getMessage( repository ) );
-        this.repository = repository;
-    }
-
-    /**
-     * Creates a new exception with the specified repository and detail message.
-     * 
-     * @param repository The inaccessible remote repository, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public RepositoryOfflineException( RemoteRepository repository, String message )
-    {
-        super( message );
-        this.repository = repository;
-    }
-
-    /**
-     * Gets the remote repository that could not be accessed due to offline mode.
-     * 
-     * @return The inaccessible remote repository or {@code null} if unknown.
-     */
-    public RemoteRepository getRepository()
-    {
-        return repository;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferCancelledException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferCancelledException.java
deleted file mode 100644 (file)
index 5f4ed5b..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown in case an upload/download was cancelled (e.g. due to user request).
- */
-public class TransferCancelledException
-    extends RepositoryException
-{
-
-    /**
-     * Creates a new exception with a stock detail message.
-     */
-    public TransferCancelledException()
-    {
-        super( "The operation was cancelled." );
-    }
-
-    /**
-     * Creates a new exception with the specified detail message.
-     * 
-     * @param message The detail message, may be {@code null}.
-     */
-    public TransferCancelledException( String message )
-    {
-        super( message );
-    }
-
-    /**
-     * Creates a new exception with the specified detail message and cause.
-     * 
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public TransferCancelledException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferEvent.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferEvent.java
deleted file mode 100644 (file)
index 9be298f..0000000
+++ /dev/null
@@ -1,423 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import java.nio.ByteBuffer;
-
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * An event fired to a transfer listener during an artifact/metadata transfer.
- * 
- * @see TransferListener
- * @see TransferEvent.Builder
- */
-public final class TransferEvent
-{
-
-    /**
-     * The type of the event.
-     */
-    public enum EventType
-    {
-
-        /**
-         * @see TransferListener#transferInitiated(TransferEvent)
-         */
-        INITIATED,
-
-        /**
-         * @see TransferListener#transferStarted(TransferEvent)
-         */
-        STARTED,
-
-        /**
-         * @see TransferListener#transferProgressed(TransferEvent)
-         */
-        PROGRESSED,
-
-        /**
-         * @see TransferListener#transferCorrupted(TransferEvent)
-         */
-        CORRUPTED,
-
-        /**
-         * @see TransferListener#transferSucceeded(TransferEvent)
-         */
-        SUCCEEDED,
-
-        /**
-         * @see TransferListener#transferFailed(TransferEvent)
-         */
-        FAILED
-
-    }
-
-    /**
-     * The type of the request/transfer being performed.
-     */
-    public enum RequestType
-    {
-
-        /**
-         * Download artifact/metadata.
-         */
-        GET,
-
-        /**
-         * Check artifact/metadata existence only.
-         */
-        GET_EXISTENCE,
-
-        /**
-         * Upload artifact/metadata.
-         */
-        PUT,
-
-    }
-
-    private final EventType type;
-
-    private final RequestType requestType;
-
-    private final RepositorySystemSession session;
-
-    private final TransferResource resource;
-
-    private final ByteBuffer dataBuffer;
-
-    private final long transferredBytes;
-
-    private final Exception exception;
-
-    TransferEvent( Builder builder )
-    {
-        type = builder.type;
-        requestType = builder.requestType;
-        session = builder.session;
-        resource = builder.resource;
-        dataBuffer = builder.dataBuffer;
-        transferredBytes = builder.transferredBytes;
-        exception = builder.exception;
-    }
-
-    /**
-     * Gets the type of the event.
-     * 
-     * @return The type of the event, never {@code null}.
-     */
-    public EventType getType()
-    {
-        return type;
-    }
-
-    /**
-     * Gets the type of the request/transfer.
-     * 
-     * @return The type of the request/transfer, never {@code null}.
-     */
-    public RequestType getRequestType()
-    {
-        return requestType;
-    }
-
-    /**
-     * Gets the repository system session during which the event occurred.
-     * 
-     * @return The repository system session during which the event occurred, never {@code null}.
-     */
-    public RepositorySystemSession getSession()
-    {
-        return session;
-    }
-
-    /**
-     * Gets the resource that is being transferred.
-     * 
-     * @return The resource being transferred, never {@code null}.
-     */
-    public TransferResource getResource()
-    {
-        return resource;
-    }
-
-    /**
-     * Gets the total number of bytes that have been transferred since the download/upload of the resource was started.
-     * If a download has been resumed, the returned count includes the bytes that were already downloaded during the
-     * previous attempt. In other words, the ratio of transferred bytes to the content length of the resource indicates
-     * the percentage of transfer completion.
-     * 
-     * @return The total number of bytes that have been transferred since the transfer started, never negative.
-     * @see #getDataLength()
-     * @see TransferResource#getResumeOffset()
-     */
-    public long getTransferredBytes()
-    {
-        return transferredBytes;
-    }
-
-    /**
-     * Gets the byte buffer holding the transferred bytes since the last event. A listener must assume this buffer to be
-     * owned by the event source and must not change any byte in this buffer. Also, the buffer is only valid for the
-     * duration of the event callback, i.e. the next event might reuse the same buffer (with updated contents).
-     * Therefore, if the actual event processing is deferred, the byte buffer would have to be cloned to create an
-     * immutable snapshot of its contents.
-     * 
-     * @return The (read-only) byte buffer or {@code null} if not applicable to the event, i.e. if the event type is not
-     *         {@link EventType#PROGRESSED}.
-     */
-    public ByteBuffer getDataBuffer()
-    {
-        return ( dataBuffer != null ) ? dataBuffer.asReadOnlyBuffer() : null;
-    }
-
-    /**
-     * Gets the number of bytes that have been transferred since the last event.
-     * 
-     * @return The number of bytes that have been transferred since the last event, possibly zero but never negative.
-     * @see #getTransferredBytes()
-     */
-    public int getDataLength()
-    {
-        return ( dataBuffer != null ) ? dataBuffer.remaining() : 0;
-    }
-
-    /**
-     * Gets the error that occurred during the transfer.
-     * 
-     * @return The error that occurred or {@code null} if none.
-     */
-    public Exception getException()
-    {
-        return exception;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getRequestType() + " " + getType() + " " + getResource();
-    }
-
-    /**
-     * A builder to create transfer events.
-     */
-    public static final class Builder
-    {
-
-        EventType type;
-
-        RequestType requestType;
-
-        RepositorySystemSession session;
-
-        TransferResource resource;
-
-        ByteBuffer dataBuffer;
-
-        long transferredBytes;
-
-        Exception exception;
-
-        /**
-         * Creates a new transfer event builder for the specified session and the given resource.
-         * 
-         * @param session The repository system session, must not be {@code null}.
-         * @param resource The resource being transferred, must not be {@code null}.
-         */
-        public Builder( RepositorySystemSession session, TransferResource resource )
-        {
-            if ( session == null )
-            {
-                throw new IllegalArgumentException( "session not specified" );
-            }
-            if ( resource == null )
-            {
-                throw new IllegalArgumentException( "transfer resource not specified" );
-            }
-            this.session = session;
-            this.resource = resource;
-            type = EventType.INITIATED;
-            requestType = RequestType.GET;
-        }
-
-        private Builder( Builder prototype )
-        {
-            session = prototype.session;
-            resource = prototype.resource;
-            type = prototype.type;
-            requestType = prototype.requestType;
-            dataBuffer = prototype.dataBuffer;
-            transferredBytes = prototype.transferredBytes;
-            exception = prototype.exception;
-        }
-
-        /**
-         * Creates a new transfer event builder from the current values of this builder. The state of this builder
-         * remains unchanged.
-         * 
-         * @return The new event builder, never {@code null}.
-         */
-        public Builder copy()
-        {
-            return new Builder( this );
-        }
-
-        /**
-         * Sets the type of the event and resets event-specific fields. In more detail, the data buffer and the
-         * exception fields are set to {@code null}. Furthermore, the total number of transferred bytes is set to
-         * {@code 0} if the event type is {@link EventType#STARTED}.
-         * 
-         * @param type The type of the event, must not be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder resetType( EventType type )
-        {
-            if ( type == null )
-            {
-                throw new IllegalArgumentException( "event type not specified" );
-            }
-            this.type = type;
-            dataBuffer = null;
-            exception = null;
-            switch ( type )
-            {
-                case INITIATED:
-                case STARTED:
-                    transferredBytes = 0;
-                default:
-            }
-            return this;
-        }
-
-        /**
-         * Sets the type of the event. When re-using the same builder to generate a sequence of events for one transfer,
-         * {@link #resetType(TransferEvent.EventType)} might be more handy.
-         * 
-         * @param type The type of the event, must not be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setType( EventType type )
-        {
-            if ( type == null )
-            {
-                throw new IllegalArgumentException( "event type not specified" );
-            }
-            this.type = type;
-            return this;
-        }
-
-        /**
-         * Sets the type of the request/transfer.
-         * 
-         * @param requestType The request/transfer type, must not be {@code null}.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setRequestType( RequestType requestType )
-        {
-            if ( requestType == null )
-            {
-                throw new IllegalArgumentException( "request type not specified" );
-            }
-            this.requestType = requestType;
-            return this;
-        }
-
-        /**
-         * Sets the total number of bytes that have been transferred so far during the download/upload of the resource.
-         * If a download is being resumed, the count must include the bytes that were already downloaded in the previous
-         * attempt and from which the current transfer started. In this case, the event type {@link EventType#STARTED}
-         * should indicate from what byte the download resumes.
-         * 
-         * @param transferredBytes The total number of bytes that have been transferred so far during the
-         *            download/upload of the resource, must not be negative.
-         * @return This event builder for chaining, never {@code null}.
-         * @see TransferResource#setResumeOffset(long)
-         */
-        public Builder setTransferredBytes( long transferredBytes )
-        {
-            if ( transferredBytes < 0 )
-            {
-                throw new IllegalArgumentException( "number of transferred bytes cannot be negative" );
-            }
-            this.transferredBytes = transferredBytes;
-            return this;
-        }
-
-        /**
-         * Increments the total number of bytes that have been transferred so far during the download/upload.
-         * 
-         * @param transferredBytes The number of bytes that have been transferred since the last event, must not be
-         *            negative.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder addTransferredBytes( long transferredBytes )
-        {
-            if ( transferredBytes < 0 )
-            {
-                throw new IllegalArgumentException( "number of transferred bytes cannot be negative" );
-            }
-            this.transferredBytes += transferredBytes;
-            return this;
-        }
-
-        /**
-         * Sets the byte buffer holding the transferred bytes since the last event.
-         * 
-         * @param buffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if not
-         *            applicable to the event.
-         * @param offset The starting point of valid bytes in the array.
-         * @param length The number of valid bytes, must not be negative.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setDataBuffer( byte[] buffer, int offset, int length )
-        {
-            return setDataBuffer( ( buffer != null ) ? ByteBuffer.wrap( buffer, offset, length ) : null );
-        }
-
-        /**
-         * Sets the byte buffer holding the transferred bytes since the last event.
-         * 
-         * @param dataBuffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if
-         *            not applicable to the event.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setDataBuffer( ByteBuffer dataBuffer )
-        {
-            this.dataBuffer = dataBuffer;
-            return this;
-        }
-
-        /**
-         * Sets the error that occurred during the transfer.
-         * 
-         * @param exception The error that occurred during the transfer, may be {@code null} if none.
-         * @return This event builder for chaining, never {@code null}.
-         */
-        public Builder setException( Exception exception )
-        {
-            this.exception = exception;
-            return this;
-        }
-
-        /**
-         * Builds a new transfer event from the current values of this builder. The state of the builder itself remains
-         * unchanged.
-         * 
-         * @return The transfer event, never {@code null}.
-         */
-        public TransferEvent build()
-        {
-            return new TransferEvent( this );
-        }
-
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferListener.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferListener.java
deleted file mode 100644 (file)
index 26c016d..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-/**
- * A listener being notified of artifact/metadata transfers from/to remote repositories. The listener may be called from
- * an arbitrary thread. Reusing common regular expression syntax, the sequence of events is roughly as follows:
- * 
- * <pre>
- * INITIATED ( STARTED PROGRESSED* CORRUPTED? )* ( SUCCEEDED | FAILED )
- * </pre>
- * 
- * <em>Note:</em> Implementors are strongly advised to inherit from {@link AbstractTransferListener} instead of directly
- * implementing this interface.
- * 
- * @see org.eclipse.aether.RepositorySystemSession#getTransferListener()
- * @see org.eclipse.aether.RepositoryListener
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface TransferListener
-{
-
-    /**
-     * Notifies the listener about the initiation of a transfer. This event gets fired before any actual network access
-     * to the remote repository and usually indicates some thread is now about to perform the transfer. For a given
-     * transfer request, this event is the first one being fired and it must be emitted exactly once.
-     * 
-     * @param event The event details, must not be {@code null}.
-     * @throws TransferCancelledException If the transfer should be aborted.
-     */
-    void transferInitiated( TransferEvent event )
-        throws TransferCancelledException;
-
-    /**
-     * Notifies the listener about the start of a data transfer. This event indicates a successful connection to the
-     * remote repository. In case of a download, the requested remote resource exists and its size is given by
-     * {@link TransferResource#getContentLength()} if possible. This event may be fired multiple times for given
-     * transfer request if said transfer needs to be repeated (e.g. in response to an authentication challenge).
-     * 
-     * @param event The event details, must not be {@code null}.
-     * @throws TransferCancelledException If the transfer should be aborted.
-     */
-    void transferStarted( TransferEvent event )
-        throws TransferCancelledException;
-
-    /**
-     * Notifies the listener about some progress in the data transfer. This event may even be fired if actually zero
-     * bytes have been transferred since the last event, for instance to enable cancellation.
-     * 
-     * @param event The event details, must not be {@code null}.
-     * @throws TransferCancelledException If the transfer should be aborted.
-     */
-    void transferProgressed( TransferEvent event )
-        throws TransferCancelledException;
-
-    /**
-     * Notifies the listener that a checksum validation failed. {@link TransferEvent#getException()} will be of type
-     * {@link ChecksumFailureException} and can be used to query further details about the expected/actual checksums.
-     * 
-     * @param event The event details, must not be {@code null}.
-     * @throws TransferCancelledException If the transfer should be aborted.
-     */
-    void transferCorrupted( TransferEvent event )
-        throws TransferCancelledException;
-
-    /**
-     * Notifies the listener about the successful completion of a transfer. This event must be fired exactly once for a
-     * given transfer request unless said request failed.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void transferSucceeded( TransferEvent event );
-
-    /**
-     * Notifies the listener about the unsuccessful termination of a transfer. {@link TransferEvent#getException()} will
-     * provide further information about the failure.
-     * 
-     * @param event The event details, must not be {@code null}.
-     */
-    void transferFailed( TransferEvent event );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferResource.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferResource.java
deleted file mode 100644 (file)
index b9510fb..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.transfer;
-
-import java.io.File;
-
-import org.eclipse.aether.RequestTrace;
-
-/**
- * Describes a resource being uploaded or downloaded by the repository system.
- */
-public final class TransferResource
-{
-
-    private final String repositoryUrl;
-
-    private final String resourceName;
-
-    private final File file;
-
-    private final long startTime;
-
-    private final RequestTrace trace;
-
-    private long contentLength = -1;
-
-    private long resumeOffset;
-
-    /**
-     * Creates a new transfer resource with the specified properties.
-     * 
-     * @param repositoryUrl The base URL of the repository, may be {@code null} or empty if unknown. If not empty, a
-     *            trailing slash will automatically be added if missing.
-     * @param resourceName The relative path to the resource within the repository, may be {@code null}. A leading slash
-     *            (if any) will be automatically removed.
-     * @param file The source/target file involved in the transfer, may be {@code null}.
-     * @param trace The trace information, may be {@code null}.
-     */
-    public TransferResource( String repositoryUrl, String resourceName, File file, RequestTrace trace )
-    {
-        if ( repositoryUrl == null || repositoryUrl.length() <= 0 )
-        {
-            this.repositoryUrl = "";
-        }
-        else if ( repositoryUrl.endsWith( "/" ) )
-        {
-            this.repositoryUrl = repositoryUrl;
-        }
-        else
-        {
-            this.repositoryUrl = repositoryUrl + '/';
-        }
-
-        if ( resourceName == null || resourceName.length() <= 0 )
-        {
-            this.resourceName = "";
-        }
-        else if ( resourceName.startsWith( "/" ) )
-        {
-            this.resourceName = resourceName.substring( 1 );
-        }
-        else
-        {
-            this.resourceName = resourceName;
-        }
-
-        this.file = file;
-
-        this.trace = trace;
-
-        startTime = System.currentTimeMillis();
-    }
-
-    /**
-     * The base URL of the repository, e.g. "http://repo1.maven.org/maven2/". Unless the URL is unknown, it will be
-     * terminated by a trailing slash.
-     * 
-     * @return The base URL of the repository or an empty string if unknown, never {@code null}.
-     */
-    public String getRepositoryUrl()
-    {
-        return repositoryUrl;
-    }
-
-    /**
-     * The path of the resource relative to the repository's base URL, e.g. "org/apache/maven/maven/3.0/maven-3.0.pom".
-     * 
-     * @return The path of the resource, never {@code null}.
-     */
-    public String getResourceName()
-    {
-        return resourceName;
-    }
-
-    /**
-     * Gets the local file being uploaded or downloaded. When the repository system merely checks for the existence of a
-     * remote resource, no local file will be involved in the transfer.
-     * 
-     * @return The source/target file involved in the transfer or {@code null} if none.
-     */
-    public File getFile()
-    {
-        return file;
-    }
-
-    /**
-     * The size of the resource in bytes. Note that the size of a resource during downloads might be unknown to the
-     * client which is usually the case when transfers employ compression like gzip. In general, the content length is
-     * not known until the transfer has {@link TransferListener#transferStarted(TransferEvent) started}.
-     * 
-     * @return The size of the resource in bytes or a negative value if unknown.
-     */
-    public long getContentLength()
-    {
-        return contentLength;
-    }
-
-    /**
-     * Sets the size of the resource in bytes.
-     * 
-     * @param contentLength The size of the resource in bytes or a negative value if unknown.
-     * @return This resource for chaining, never {@code null}.
-     */
-    public TransferResource setContentLength( long contentLength )
-    {
-        this.contentLength = contentLength;
-        return this;
-    }
-
-    /**
-     * Gets the byte offset within the resource from which the download starts. A positive offset indicates a previous
-     * download attempt is being resumed, {@code 0} means the transfer starts at the first byte.
-     * 
-     * @return The zero-based index of the first byte being transferred, never negative.
-     */
-    public long getResumeOffset()
-    {
-        return resumeOffset;
-    }
-
-    /**
-     * Sets the byte offset within the resource at which the download starts.
-     * 
-     * @param resumeOffset The zero-based index of the first byte being transferred, must not be negative.
-     * @return This resource for chaining, never {@code null}.
-     */
-    public TransferResource setResumeOffset( long resumeOffset )
-    {
-        if ( resumeOffset < 0 )
-        {
-            throw new IllegalArgumentException( "resume offset cannot be negative" );
-        }
-        this.resumeOffset = resumeOffset;
-        return this;
-    }
-
-    /**
-     * Gets the timestamp when the transfer of this resource was started.
-     * 
-     * @return The timestamp when the transfer of this resource was started.
-     */
-    public long getTransferStartTime()
-    {
-        return startTime;
-    }
-
-    /**
-     * Gets the trace information that describes the higher level request/operation during which this resource is
-     * transferred.
-     * 
-     * @return The trace information about the higher level operation or {@code null} if none.
-     */
-    public RequestTrace getTrace()
-    {
-        return trace;
-    }
-
-    @Override
-    public String toString()
-    {
-        return getRepositoryUrl() + getResourceName() + " <> " + getFile();
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/transfer/package-info.java
deleted file mode 100644 (file)
index 5ce9ff3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * A listener and various exception types dealing with the transfer of a resource between the local system and a remote
- * repository.
- */
-package org.eclipse.aether.transfer;
-
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/InvalidVersionSpecificationException.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/InvalidVersionSpecificationException.java
deleted file mode 100644 (file)
index b3690c5..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.version;
-
-import org.eclipse.aether.RepositoryException;
-
-/**
- * Thrown when a version or version range could not be parsed.
- */
-public class InvalidVersionSpecificationException
-    extends RepositoryException
-{
-
-    private final String version;
-
-    /**
-     * Creates a new exception with the specified version and detail message.
-     * 
-     * @param version The invalid version specification, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     */
-    public InvalidVersionSpecificationException( String version, String message )
-    {
-        super( message );
-        this.version = version;
-    }
-
-    /**
-     * Creates a new exception with the specified version and cause.
-     * 
-     * @param version The invalid version specification, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public InvalidVersionSpecificationException( String version, Throwable cause )
-    {
-        super( "Could not parse version specification " + version + getMessage( ": ", cause ), cause );
-        this.version = version;
-    }
-
-    /**
-     * Creates a new exception with the specified version, detail message and cause.
-     * 
-     * @param version The invalid version specification, may be {@code null}.
-     * @param message The detail message, may be {@code null}.
-     * @param cause The exception that caused this one, may be {@code null}.
-     */
-    public InvalidVersionSpecificationException( String version, String message, Throwable cause )
-    {
-        super( message, cause );
-        this.version = version;
-    }
-
-    /**
-     * Gets the version or version range that could not be parsed.
-     * 
-     * @return The invalid version specification or {@code null} if unknown.
-     */
-    public String getVersion()
-    {
-        return version;
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/Version.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/Version.java
deleted file mode 100644 (file)
index 4aceba6..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.version;
-
-/**
- * A parsed artifact version.
- */
-public interface Version
-    extends Comparable<Version>
-{
-
-    /**
-     * Gets the original string representation of the version.
-     * 
-     * @return The string representation of the version, never {@code null}.
-     */
-    String toString();
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionConstraint.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionConstraint.java
deleted file mode 100644 (file)
index dcb3b68..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.version;
-
-/**
- * A constraint on versions for a dependency. A constraint can either consist of a version range (e.g. "[1, ]") or a
- * single version (e.g. "1.1"). In the first case, the constraint expresses a hard requirement on a version matching the
- * range. In the second case, the constraint expresses a soft requirement on a specific version (i.e. a recommendation).
- */
-public interface VersionConstraint
-{
-
-    /**
-     * Gets the version range of this constraint.
-     * 
-     * @return The version range or {@code null} if none.
-     */
-    VersionRange getRange();
-
-    /**
-     * Gets the version recommended by this constraint.
-     * 
-     * @return The recommended version or {@code null} if none.
-     */
-    Version getVersion();
-
-    /**
-     * Determines whether the specified version satisfies this constraint. In more detail, a version satisfies this
-     * constraint if it matches its version range or if this constraint has no version range and the specified version
-     * equals the version recommended by the constraint.
-     * 
-     * @param version The version to test, must not be {@code null}.
-     * @return {@code true} if the specified version satisfies this constraint, {@code false} otherwise.
-     */
-    boolean containsVersion( Version version );
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionRange.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionRange.java
deleted file mode 100644 (file)
index cbc2405..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.version;
-
-/**
- * A range of versions.
- */
-public interface VersionRange
-{
-
-    /**
-     * Determines whether the specified version is contained within this range.
-     * 
-     * @param version The version to test, must not be {@code null}.
-     * @return {@code true} if this range contains the specified version, {@code false} otherwise.
-     */
-    boolean containsVersion( Version version );
-
-    /**
-     * Gets a lower bound (if any) for this range. If existent, this range does not contain any version smaller than its
-     * lower bound. Note that complex version ranges might exclude some versions even within their bounds.
-     * 
-     * @return A lower bound for this range or {@code null} is there is none.
-     */
-    Bound getLowerBound();
-
-    /**
-     * Gets an upper bound (if any) for this range. If existent, this range does not contain any version greater than
-     * its upper bound. Note that complex version ranges might exclude some versions even within their bounds.
-     * 
-     * @return An upper bound for this range or {@code null} is there is none.
-     */
-    Bound getUpperBound();
-
-    /**
-     * A bound of a version range.
-     */
-    static final class Bound
-    {
-
-        private final Version version;
-
-        private final boolean inclusive;
-
-        /**
-         * Creates a new bound with the specified properties.
-         * 
-         * @param version The bounding version, must not be {@code null}.
-         * @param inclusive A flag whether the specified version is included in the range or not.
-         */
-        public Bound( Version version, boolean inclusive )
-        {
-            if ( version == null )
-            {
-                throw new IllegalArgumentException( "version missing" );
-            }
-            this.version = version;
-            this.inclusive = inclusive;
-        }
-
-        /**
-         * Gets the bounding version.
-         * 
-         * @return The bounding version, never {@code null}.
-         */
-        public Version getVersion()
-        {
-            return version;
-        }
-
-        /**
-         * Indicates whether the bounding version is included in the range or not.
-         * 
-         * @return {@code true} if the bounding version is included in the range, {@code false} if not.
-         */
-        public boolean isInclusive()
-        {
-            return inclusive;
-        }
-
-        @Override
-        public boolean equals( Object obj )
-        {
-            if ( obj == this )
-            {
-                return true;
-            }
-            else if ( obj == null || !getClass().equals( obj.getClass() ) )
-            {
-                return false;
-            }
-
-            Bound that = (Bound) obj;
-            return inclusive == that.inclusive && version.equals( that.version );
-        }
-
-        @Override
-        public int hashCode()
-        {
-            int hash = 17;
-            hash = hash * 31 + version.hashCode();
-            hash = hash * 31 + ( inclusive ? 1 : 0 );
-            return hash;
-        }
-
-        @Override
-        public String toString()
-        {
-            return String.valueOf( version );
-        }
-
-    }
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionScheme.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionScheme.java
deleted file mode 100644 (file)
index c19177a..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.aether.version;
-
-/**
- * A version scheme that handles interpretation of version strings to facilitate their comparison.
- */
-public interface VersionScheme
-{
-
-    /**
-     * Parses the specified version string, for example "1.0".
-     * 
-     * @param version The version string to parse, must not be {@code null}.
-     * @return The parsed version, never {@code null}.
-     * @throws InvalidVersionSpecificationException If the string violates the syntax rules of this scheme.
-     */
-    Version parseVersion( String version )
-        throws InvalidVersionSpecificationException;
-
-    /**
-     * Parses the specified version range specification, for example "[1.0,2.0)".
-     * 
-     * @param range The range specification to parse, must not be {@code null}.
-     * @return The parsed version range, never {@code null}.
-     * @throws InvalidVersionSpecificationException If the range specification violates the syntax rules of this scheme.
-     */
-    VersionRange parseVersionRange( String range )
-        throws InvalidVersionSpecificationException;
-
-    /**
-     * Parses the specified version constraint specification, for example "1.0" or "[1.0,2.0),(2.0,)".
-     * 
-     * @param constraint The constraint specification to parse, must not be {@code null}.
-     * @return The parsed version constraint, never {@code null}.
-     * @throws InvalidVersionSpecificationException If the constraint specification violates the syntax rules of this
-     *             scheme.
-     */
-    VersionConstraint parseVersionConstraint( final String constraint )
-        throws InvalidVersionSpecificationException;
-
-}
diff --git a/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/package-info.java b/cms/org.argeo.slc.repo/src/org/eclipse/aether/version/package-info.java
deleted file mode 100644 (file)
index 7ef8c85..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Sonatype, Inc.
- * 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:
- *    Sonatype, Inc. - initial API and implementation
- *******************************************************************************/
-/**
- * The definition of a version scheme for parsing and comparing versions.
- */
-package org.eclipse.aether.version;
-
diff --git a/cms/org.argeo.slc.runtime/.classpath b/cms/org.argeo.slc.runtime/.classpath
deleted file mode 100644 (file)
index e801ebf..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/cms/org.argeo.slc.runtime/.gitignore b/cms/org.argeo.slc.runtime/.gitignore
deleted file mode 100644 (file)
index 09e3bc9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/bin/
-/target/
diff --git a/cms/org.argeo.slc.runtime/.project b/cms/org.argeo.slc.runtime/.project
deleted file mode 100644 (file)
index 10ad5da..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.runtime</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/cms/org.argeo.slc.runtime/META-INF/.gitignore b/cms/org.argeo.slc.runtime/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.runtime/bnd.bnd b/cms/org.argeo.slc.runtime/bnd.bnd
deleted file mode 100644 (file)
index 9384c2a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Import-Package: org.argeo.slc.deploy,\
-*
\ No newline at end of file
diff --git a/cms/org.argeo.slc.runtime/build.properties b/cms/org.argeo.slc.runtime/build.properties
deleted file mode 100644 (file)
index 34d2e4d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
-               .
diff --git a/cms/org.argeo.slc.runtime/pom.xml b/cms/org.argeo.slc.runtime/pom.xml
deleted file mode 100644 (file)
index 5cdaff5..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.runtime</artifactId>
-       <name>SLC Runtime</name>
-       <dependencies>
-               <!-- SLC -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.api</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/AbstractExecutionModulesManager.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/AbstractExecutionModulesManager.java
deleted file mode 100644 (file)
index a31f18c..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.RealizedFlow;
-
-/** Provides the base feature of an execution module manager. */
-public abstract class AbstractExecutionModulesManager implements
-               ExecutionModulesManager {
-       private final static Log log = LogFactory
-                       .getLog(AbstractExecutionModulesManager.class);
-
-       // private List<FilteredNotifier> filteredNotifiers = Collections
-       // .synchronizedList(new ArrayList<FilteredNotifier>());
-
-       protected abstract ExecutionFlow findExecutionFlow(String moduleName,
-                       String moduleVersion, String flowName);
-
-       protected abstract ExecutionContext findExecutionContext(String moduleName,
-                       String moduleVersion);
-
-       protected abstract ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
-                       String moduleName, String moduleVersion);
-
-       public void execute(RealizedFlow realizedFlow) {
-               if (log.isTraceEnabled())
-                       log.trace("Executing " + realizedFlow);
-
-               String moduleName = realizedFlow.getModuleName();
-               String moduleVersion = realizedFlow.getModuleVersion();
-
-               Map<? extends String, ? extends Object> variablesToAdd = getExecutionFlowDescriptorConverter(
-                               moduleName, moduleVersion).convertValues(
-                               realizedFlow.getFlowDescriptor());
-               ExecutionContext executionContext = findExecutionContext(moduleName,
-                               moduleVersion);
-               for (String key : variablesToAdd.keySet())
-                       executionContext.setVariable(key, variablesToAdd.get(key));
-
-               ExecutionFlow flow = findExecutionFlow(moduleName, moduleVersion,
-                               realizedFlow.getFlowDescriptor().getName());
-
-               //
-               // Actually runs the flow, IN THIS THREAD
-               //
-               executionContext.beforeFlow(flow);
-               try {
-                       flow.run();
-               } finally {
-                       executionContext.afterFlow(flow);
-               }
-               //
-               //
-               //
-       }
-
-       // public void dispatchUpdateStatus(ExecutionProcess process,
-       // String oldStatus, String newStatus) {
-       // // filtered notifiers
-       // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
-       // .hasNext();) {
-       // FilteredNotifier filteredNotifier = it.next();
-       // if (filteredNotifier.receiveFrom(process))
-       // filteredNotifier.getNotifier().updateStatus(process, oldStatus,
-       // newStatus);
-       // }
-       //
-       // }
-
-       // public void dispatchAddSteps(ExecutionProcess process,
-       // List<ExecutionStep> steps) {
-       // process.addSteps(steps);
-       // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
-       // .hasNext();) {
-       // FilteredNotifier filteredNotifier = it.next();
-       // if (filteredNotifier.receiveFrom(process))
-       // filteredNotifier.getNotifier().addSteps(process, steps);
-       // }
-       // }
-
-       // public void registerProcessNotifier(ExecutionProcessNotifier notifier,
-       // Map<String, String> properties) {
-       // filteredNotifiers.add(new FilteredNotifier(notifier, properties));
-       // }
-       //
-       // public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
-       // Map<String, String> properties) {
-       // filteredNotifiers.remove(notifier);
-       // }
-
-       // protected class FilteredNotifier {
-       // private final ExecutionProcessNotifier notifier;
-       // private final String processId;
-       //
-       // public FilteredNotifier(ExecutionProcessNotifier notifier,
-       // Map<String, String> properties) {
-       // super();
-       // this.notifier = notifier;
-       // if (properties == null)
-       // properties = new HashMap<String, String>();
-       // if (properties.containsKey(SLC_PROCESS_ID))
-       // processId = properties.get(SLC_PROCESS_ID);
-       // else
-       // processId = null;
-       // }
-       //
-       // /**
-       // * Whether event from this process should be received by this listener.
-       // */
-       // public Boolean receiveFrom(ExecutionProcess process) {
-       // if (processId != null)
-       // if (process.getUuid().equals(processId))
-       // return true;
-       // else
-       // return false;
-       // return true;
-       // }
-       //
-       // @Override
-       // public int hashCode() {
-       // return notifier.hashCode();
-       // }
-       //
-       // @Override
-       // public boolean equals(Object obj) {
-       // if (obj instanceof FilteredNotifier) {
-       // FilteredNotifier fn = (FilteredNotifier) obj;
-       // return notifier.equals(fn.notifier);
-       // } else if (obj instanceof ExecutionProcessNotifier) {
-       // ExecutionProcessNotifier epn = (ExecutionProcessNotifier) obj;
-       // return notifier.equals(epn);
-       // } else
-       // return false;
-       // }
-       //
-       // public ExecutionProcessNotifier getNotifier() {
-       // return notifier;
-       // }
-       //
-       // }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgent.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgent.java
deleted file mode 100644 (file)
index 6fc255a..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLDecoder;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionModuleDescriptor;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.execution.SlcAgent;
-
-/** Implements the base methods of an SLC agent. */
-public class DefaultAgent implements SlcAgent {
-       // private final static Log log = LogFactory.getLog(DefaultAgent.class);
-       /** UTF-8 charset for encoding. */
-       private final static String UTF8 = "UTF-8";
-
-       private String agentUuid = null;
-       private ExecutionModulesManager modulesManager;
-
-       private ThreadGroup processesThreadGroup;
-       private Map<String, ProcessThread> runningProcesses = Collections
-                       .synchronizedMap(new HashMap<String, ProcessThread>());
-
-       private String defaultModulePrefix = null;
-
-       /*
-        * LIFECYCLE
-        */
-       /** Initialization */
-       public void init() {
-               agentUuid = initAgentUuid();
-               processesThreadGroup = new ThreadGroup("SLC Processes of Agent #"
-                               + agentUuid);
-       }
-
-       /** Clean up (needs to be called by overriding method) */
-       public void destroy() {
-       }
-
-       /**
-        * Called during initialization in order to determines the agent UUID. To be
-        * overridden. By default creates a new one per instance.
-        */
-       protected String initAgentUuid() {
-               return UUID.randomUUID().toString();
-       }
-
-       /*
-        * SLC AGENT
-        */
-       public void process(ExecutionProcess process) {
-               ProcessThread processThread = createProcessThread(processesThreadGroup,
-                               modulesManager, process);
-               processThread.start();
-               runningProcesses.put(process.getUuid(), processThread);
-
-               // clean up old processes
-               Iterator<ProcessThread> it = runningProcesses.values().iterator();
-               while (it.hasNext()) {
-                       ProcessThread pThread = it.next();
-                       if (!pThread.isAlive())
-                               it.remove();
-               }
-       }
-
-       public String process(List<URI> uris) {
-               DefaultProcess process = new DefaultProcess();
-               for (URI uri : uris) {
-                       String[] path = uri.getPath().split("/");
-                       if (path.length < 3)
-                               throw new SlcException("Badly formatted URI: " + uri);
-                       NameVersion nameVersion = new DefaultNameVersion(path[1]);
-                       StringBuilder flow = new StringBuilder();
-                       for (int i = 2; i < path.length; i++)
-                               flow.append('/').append(path[i]);
-
-                       Map<String, Object> values = getQueryMap(uri.getQuery());
-                       // Get execution module descriptor
-                       ExecutionModuleDescriptor emd = getExecutionModuleDescriptor(
-                                       nameVersion.getName(), nameVersion.getVersion());
-                       process.getRealizedFlows().add(
-                                       emd.asRealizedFlow(flow.toString(), values));
-               }
-               process(process);
-               return process.getUuid();
-       }
-
-       public void kill(String processUuid) {
-               if (runningProcesses.containsKey(processUuid)) {
-                       runningProcesses.get(processUuid).interrupt();
-               } else {
-                       // assume is finished
-               }
-       }
-
-       public void waitFor(String processUuid, Long millis) {
-               if (runningProcesses.containsKey(processUuid)) {
-                       try {
-                               if (millis != null)
-                                       runningProcesses.get(processUuid).join(millis);
-                               else
-                                       runningProcesses.get(processUuid).join();
-                       } catch (InterruptedException e) {
-                               // silent
-                       }
-               } else {
-                       // assume is finished
-               }
-       }
-
-       /** Creates the thread which will coordinate the execution for this agent. */
-       protected ProcessThread createProcessThread(
-                       ThreadGroup processesThreadGroup,
-                       ExecutionModulesManager modulesManager, ExecutionProcess process) {
-               ProcessThread processThread = new ProcessThread(processesThreadGroup,
-                               modulesManager, process);
-               return processThread;
-       }
-
-       public ExecutionModuleDescriptor getExecutionModuleDescriptor(
-                       String moduleName, String moduleVersion) {
-               // Get execution module descriptor
-               ExecutionModuleDescriptor emd;
-               try {
-                       modulesManager
-                                       .start(new DefaultNameVersion(moduleName, moduleVersion));
-                       emd = modulesManager.getExecutionModuleDescriptor(moduleName,
-                                       moduleVersion);
-               } catch (SlcException e) {
-                       if (defaultModulePrefix != null) {
-                               moduleName = defaultModulePrefix + "." + moduleName;
-                               modulesManager.start(new DefaultNameVersion(moduleName,
-                                               moduleVersion));
-                               emd = modulesManager.getExecutionModuleDescriptor(moduleName,
-                                               moduleVersion);
-                       } else
-                               throw e;
-               }
-               return emd;
-       }
-
-       public List<ExecutionModuleDescriptor> listExecutionModuleDescriptors() {
-               return modulesManager.listExecutionModules();
-       }
-
-       public boolean ping() {
-               return true;
-       }
-
-       /*
-        * UTILITIES
-        */
-       /**
-        * @param query
-        *            can be null
-        */
-       static Map<String, Object> getQueryMap(String query) {
-               Map<String, Object> map = new LinkedHashMap<String, Object>();
-               if (query == null)
-                       return map;
-               String[] params = query.split("&");
-               for (String param : params) {
-                       String[] arr = param.split("=");
-                       String name = arr[0];
-                       Object value = arr.length > 1 ? param.split("=")[1] : Boolean.TRUE;
-                       try {
-                               map.put(URLDecoder.decode(name, UTF8),
-                                               URLDecoder.decode(value.toString(), UTF8));
-                       } catch (UnsupportedEncodingException e) {
-                               throw new SlcException("Cannot decode '" + param + "'", e);
-                       }
-               }
-               return map;
-       }
-
-       /*
-        * BEAN
-        */
-       public void setModulesManager(ExecutionModulesManager modulesManager) {
-               this.modulesManager = modulesManager;
-       }
-
-       public void setDefaultModulePrefix(String defaultModulePrefix) {
-               this.defaultModulePrefix = defaultModulePrefix;
-       }
-
-       public String getAgentUuid() {
-               return agentUuid;
-       }
-
-       @Override
-       public String toString() {
-               return "Agent #" + getAgentUuid();
-       }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgentCli.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgentCli.java
deleted file mode 100644 (file)
index 2e6d7f1..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.net.URI;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionModuleDescriptor;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.SlcAgent;
-import org.argeo.slc.execution.SlcAgentCli;
-
-/**
- * Authenticates thread and executes synchronously a command line execution.
- * Reference implementation of args to URIs algorithm.
- */
-public class DefaultAgentCli implements SlcAgentCli {
-       private final static Log log = LogFactory.getLog(DefaultAgentCli.class);
-
-       private final static String UTF8 = "UTF-8";
-       private SlcAgent agent;
-//     private AuthenticationManager authenticationManager;
-
-       private Long timeout = 24 * 60 * 60 * 1000l;
-
-       public String process(String[] args) {
-//             if (SecurityContextHolder.getContext().getAuthentication() == null) {
-//                     OsAuthenticationToken oat = new OsAuthenticationToken();
-//                     Authentication authentication = authenticationManager
-//                                     .authenticate(oat);
-//                     SecurityContextHolder.getContext()
-//                                     .setAuthentication(authentication);
-//             }
-
-               if (args.length > 0 && args[0].equals("help")) {
-                       StringBuilder buf = new StringBuilder();
-                       help(args, buf);
-                       log.info("\n" + buf);
-                       return buf.toString();
-               } else {
-                       List<URI> uris = asURIs(args);
-                       String processUuid = agent.process(uris);
-                       agent.waitFor(processUuid, timeout);
-                       return processUuid;
-               }
-       }
-
-       protected void help(String[] rawArgs, StringBuilder buf) {
-               String[] args = Arrays.copyOfRange(rawArgs, 1, rawArgs.length);
-               if (args.length == 0) {// modules
-                       for (ExecutionModuleDescriptor emd : agent
-                                       .listExecutionModuleDescriptors()) {
-                               appendModule(emd, buf);
-                       }
-               } else if (args.length == 1 && !args[0].contains("/")) {// single module
-                       NameVersion nameVersion = new DefaultNameVersion(args[0]);
-                       ExecutionModuleDescriptor emd = agent.getExecutionModuleDescriptor(
-                                       nameVersion.getName(), nameVersion.getVersion());
-                       appendModule(emd, buf);
-
-                       // flows
-                       for (ExecutionFlowDescriptor efd : emd.getExecutionFlows()) {
-                               buf.append(" ").append(efd.getName());
-                               if (efd.getDescription() != null
-                                               && !efd.getDescription().trim().equals(""))
-                                       buf.append(" : ").append(" ").append(efd.getDescription());
-                               buf.append('\n');
-                       }
-                       return;
-               } else {
-                       List<URI> uris = asURIs(args);
-                       for (URI uri : uris) {
-                               appendUriHelp(uri, buf);
-                       }
-               }
-       }
-
-       protected void appendUriHelp(URI uri, StringBuilder buf) {
-               String[] path = uri.getPath().split("/");
-               NameVersion nameVersion = new DefaultNameVersion(path[1]);
-               ExecutionModuleDescriptor emd = agent.getExecutionModuleDescriptor(
-                               nameVersion.getName(), nameVersion.getVersion());
-
-               StringBuilder flow = new StringBuilder();
-               for (int i = 2; i < path.length; i++)
-                       flow.append('/').append(path[i]);
-               String flowPath = flow.toString();
-               ExecutionFlowDescriptor efd = findExecutionFlowDescriptor(emd, flowPath);
-               if (efd == null)
-                       throw new SlcException("Flow " + uri + " not found");
-
-               appendModule(emd, buf);
-
-               buf.append(" ").append(efd.getName());
-               if (efd.getDescription() != null
-                               && !efd.getDescription().trim().equals(""))
-                       buf.append(" : ").append(" ").append(efd.getDescription());
-               buf.append('\n');
-               Map<String, Object> values = DefaultAgent.getQueryMap(uri.getQuery());
-               ExecutionSpec spec = efd.getExecutionSpec();
-               for (String attrKey : spec.getAttributes().keySet()) {
-                       ExecutionSpecAttribute esa = spec.getAttributes().get(attrKey);
-                       buf.append("  --").append(attrKey);
-                       if (values.containsKey(attrKey))
-                               buf.append(" ").append(values.get(attrKey));
-                       if (esa.getValue() != null)
-                               buf.append(" (").append(esa.getValue()).append(')');
-                       buf.append('\n');
-               }
-       }
-
-       private void appendModule(ExecutionModuleDescriptor emd, StringBuilder buf) {
-               buf.append("# ").append(emd.getName());
-               if (emd.getDescription() != null
-                               && !emd.getDescription().trim().equals(""))
-                       buf.append(" : ").append(emd.getDescription());
-               if (emd.getVersion() != null)
-                       buf.append(" (v").append(emd.getVersion()).append(")");
-               buf.append('\n');
-       }
-
-       public static List<URI> asURIs(String[] args) {
-               try {
-                       List<URI> uris = new ArrayList<URI>();
-                       List<String> leftOvers = new ArrayList<String>();
-
-                       Boolean hasArgs = false;
-                       String currKey = null;
-                       StringBuilder currUri = null;
-                       Iterator<String> argIt = Arrays.asList(args).iterator();
-                       while (argIt.hasNext()) {
-                               String arg = argIt.next();
-                               if (!arg.startsWith("-")) {
-                                       if (currKey != null) {// value
-                                               currUri.append(URLEncoder.encode(arg, UTF8));
-                                               currKey = null;
-                                       } else { // module
-                                               if (currUri != null) {
-                                                       uris.add(new URI(currUri.toString()));
-                                               }
-                                               currUri = new StringBuilder("flow:");
-
-                                               String currModule = arg;
-                                               currUri.append('/').append(currModule);
-                                               if (!arg.contains("/")) {
-                                                       // flow path not in arg go to next arg
-                                                       if (!argIt.hasNext())
-                                                               throw new SlcException("No flow found");
-                                                       String currFlow = argIt.next();
-                                                       if (!currFlow.startsWith("/"))
-                                                               currFlow = "/" + currFlow;
-                                                       currUri.append(currFlow);
-                                               }
-                                       }
-                               } else {
-                                       if (currUri == null) {// first args
-                                               leftOvers.add(arg);
-                                       } else {
-                                               String key;
-                                               if (arg.startsWith("--"))
-                                                       key = arg.substring(2);
-                                               else if (arg.startsWith("-"))
-                                                       key = arg.substring(1);
-                                               else {
-                                                       throw new SlcException("Cannot intepret key: "
-                                                                       + arg);
-                                               }
-
-                                               if (!hasArgs) {
-                                                       currUri.append('?');
-                                                       hasArgs = true;
-                                               } else {
-                                                       currUri.append('&');
-                                               }
-
-                                               // deal with boolean keys
-                                               if (currKey != null) {// value
-                                                       currUri.append(URLEncoder.encode("true", UTF8));
-                                                       currKey = null;
-                                               }
-
-                                               currKey = key;
-                                               currUri.append(URLEncoder.encode(key, UTF8))
-                                                               .append('=');
-                                       }
-                               }
-                       }
-                       if (currUri != null)
-                               uris.add(new URI(currUri.toString()));
-                       return uris;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot convert " + Arrays.toString(args)
-                                       + " to flow URI", e);
-               }
-       }
-
-       private ExecutionFlowDescriptor findExecutionFlowDescriptor(
-                       ExecutionModuleDescriptor emd, String flowPath) {
-               ExecutionFlowDescriptor flowDescriptor = null;
-               for (ExecutionFlowDescriptor efd : emd.getExecutionFlows()) {
-                       String name = efd.getName();
-                       // normalize name as flow path
-                       if (!name.startsWith("/"))
-                               name = "/" + name;
-                       if (name.endsWith("/"))
-                               name = name.substring(0, name.length() - 1);
-                       if (name.equals(flowPath)) {
-                               flowDescriptor = efd;
-                               break;
-                       }
-               }
-               return flowDescriptor;
-       }
-
-       public void setAgent(SlcAgent agent) {
-               this.agent = agent;
-       }
-
-//     public void setAuthenticationManager(
-//                     AuthenticationManager authenticationManager) {
-//             this.authenticationManager = authenticationManager;
-//     }
-
-       public void setTimeout(Long timeout) {
-               this.timeout = timeout;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionFlow.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionFlow.java
deleted file mode 100644 (file)
index f99ce9d..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-
-/** Default implementation of an execution flow. */
-public class DefaultExecutionFlow implements ExecutionFlow {
-       private final static Log log = LogFactory.getLog(DefaultExecutionFlow.class);
-
-       private final ExecutionSpec executionSpec;
-       private String name = null;
-       private Map<String, Object> parameters = new HashMap<String, Object>();
-       private List<Runnable> executables = new ArrayList<Runnable>();
-
-       private String path;
-
-       private Boolean failOnError = true;
-
-       // Only needed if stacked execution flows are used
-       private ExecutionContext executionContext = null;
-
-       public DefaultExecutionFlow() {
-               this.executionSpec = new DefaultExecutionSpec();
-       }
-
-       public DefaultExecutionFlow(ExecutionSpec executionSpec) {
-               this.executionSpec = executionSpec;
-       }
-
-       public DefaultExecutionFlow(ExecutionSpec executionSpec, Map<String, Object> parameters) {
-               // be sure to have an execution spec
-               this.executionSpec = (executionSpec == null) ? new DefaultExecutionSpec() : executionSpec;
-
-               // only parameters contained in the executionSpec can be set
-               for (String parameter : parameters.keySet()) {
-                       if (!executionSpec.getAttributes().containsKey(parameter)) {
-                               throw new SlcException("Parameter " + parameter + " is not defined in the ExecutionSpec");
-                       }
-               }
-
-               // set the parameters
-               this.parameters.putAll(parameters);
-
-               // check that all the required parameters are defined
-//             MapBindingResult errors = new MapBindingResult(parameters, "execution#"
-//                             + getName());
-               Map<String, String> errors = new HashMap<>();
-               for (String key : executionSpec.getAttributes().keySet()) {
-                       ExecutionSpecAttribute attr = executionSpec.getAttributes().get(key);
-
-                       if (attr.getIsImmutable() && !isSetAsParameter(key)) {
-                               errors.put(key, "Immutable but not set");
-                               break;
-                       }
-
-                       if (attr.getIsConstant() && !isSetAsParameter(key)) {
-                               errors.put(key, "Constant but not set as parameter");
-                               break;
-                       }
-
-                       if (attr.getIsHidden() && !isSetAsParameter(key)) {
-                               errors.put(key, "Hidden but not set as parameter");
-                               break;
-                       }
-               }
-
-               if (!errors.isEmpty())
-                       throw new SlcException("Could not prepare execution flow: " + errors.toString());
-
-       }
-
-       public void run() {
-               try {
-                       for (Runnable executable : executables) {
-                               if (Thread.interrupted()) {
-                                       log.error("Flow '" + getName() + "' killed before '" + executable + "'");
-                                       Thread.currentThread().interrupt();
-                                       return;
-                                       // throw new ThreadDeath();
-                               }
-                               this.doExecuteRunnable(executable);
-                       }
-               } catch (RuntimeException e) {
-                       if (Thread.interrupted()) {
-                               log.error("Flow '" + getName() + "' killed while receiving an unrelated exception", e);
-                               Thread.currentThread().interrupt();
-                               return;
-                               // throw new ThreadDeath();
-                       }
-                       if (failOnError)
-                               throw e;
-                       else {
-                               log.error("Execution flow failed," + " but process did not fail" + " because failOnError property"
-                                               + " is set to false: " + e);
-                               if (log.isTraceEnabled())
-                                       e.printStackTrace();
-                       }
-               }
-       }
-
-       /**
-        * List sub-runnables that would be executed if run() method would be called.
-        */
-       public Iterator<Runnable> runnables() {
-               return executables.iterator();
-       }
-
-       /**
-        * If there is one and only one runnable wrapped return it, throw an exeception
-        * otherwise.
-        */
-       public Runnable getRunnable() {
-               if (executables.size() == 1)
-                       return executables.get(0);
-               else
-                       throw new SlcException("There are " + executables.size() + " runnables in flow " + getName());
-       }
-
-       public void doExecuteRunnable(Runnable runnable) {
-               try {
-                       if (executionContext != null)
-                               if (runnable instanceof ExecutionFlow)
-                                       executionContext.beforeFlow((ExecutionFlow) runnable);
-                       runnable.run();
-               } finally {
-                       if (executionContext != null)
-                               if (runnable instanceof ExecutionFlow)
-                                       executionContext.afterFlow((ExecutionFlow) runnable);
-               }
-       }
-
-       public void init() throws Exception {
-               if (path == null) {
-                       if (name.charAt(0) == '/') {
-                               path = name.substring(0, name.lastIndexOf('/'));
-                       }
-               }
-
-               if (path != null) {
-                       for (Runnable executable : executables) {
-                               if (executable instanceof DefaultExecutionFlow) {
-                                       // so we don't need to have DefaultExecutionFlow
-                                       // implementing StructureAware
-                                       // FIXME: probably has side effects
-                                       DefaultExecutionFlow flow = (DefaultExecutionFlow) executable;
-                                       String newPath = path + '/' + flow.getName();
-                                       flow.setPath(newPath);
-                                       log.warn(newPath + " was forcibly set on " + flow);
-                               }
-                       }
-               }
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public void setExecutables(List<Runnable> executables) {
-               this.executables = executables;
-       }
-
-       public void setParameters(Map<String, Object> attributes) {
-               this.parameters = attributes;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public ExecutionSpec getExecutionSpec() {
-               return executionSpec;
-       }
-
-       public Object getParameter(String parameterName) {
-               // Verify that there is a spec attribute
-               ExecutionSpecAttribute specAttr = null;
-               if (executionSpec.getAttributes().containsKey(parameterName)) {
-                       specAttr = executionSpec.getAttributes().get(parameterName);
-               } else {
-                       throw new SlcException("Key " + parameterName + " is not defined in the specifications of " + toString());
-               }
-
-               if (parameters.containsKey(parameterName)) {
-                       Object paramValue = parameters.get(parameterName);
-                       return paramValue;
-               } else {
-                       if (specAttr.getValue() != null) {
-                               return specAttr.getValue();
-                       }
-               }
-               throw new SlcException("Key " + parameterName + " is not set as parameter in " + toString());
-       }
-
-       public Boolean isSetAsParameter(String key) {
-               return parameters.containsKey(key) || (executionSpec.getAttributes().containsKey(key)
-                               && executionSpec.getAttributes().get(key).getValue() != null);
-       }
-
-       @Override
-       public String toString() {
-               return new StringBuffer("Execution flow ").append(name).toString();
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               return ((ExecutionFlow) obj).getName().equals(name);
-       }
-
-       @Override
-       public int hashCode() {
-               return name.hashCode();
-       }
-
-       public String getPath() {
-               return path;
-       }
-
-       public void setPath(String path) {
-               this.path = path;
-       }
-
-       public Boolean getFailOnError() {
-               return failOnError;
-       }
-
-       public void setFailOnError(Boolean failOnError) {
-               this.failOnError = failOnError;
-       }
-
-       public void setExecutionContext(ExecutionContext executionContext) {
-               this.executionContext = executionContext;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionSpec.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionSpec.java
deleted file mode 100644 (file)
index 16790a4..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValueChoice;
-
-/** Spring based implementation of execution specifications. */
-public class DefaultExecutionSpec implements ExecutionSpec, Serializable {
-       private static final long serialVersionUID = 7042162759380893595L;
-       private String description;
-       private Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
-
-       private String name = INTERNAL_NAME;
-
-       public Map<String, ExecutionSpecAttribute> getAttributes() {
-               return attributes;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-
-       public void setAttributes(Map<String, ExecutionSpecAttribute> attributes) {
-               this.attributes = attributes;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       /**
-        * The Spring bean name (only relevant for specs declared has high-level beans)
-        */
-       public String getName() {
-               return name;
-       }
-
-       public boolean equals(Object obj) {
-               return ((ExecutionSpec) obj).getName().equals(name);
-       }
-
-       /**
-        * The Spring bean description (only relevant for specs declared has high-level
-        * beans)
-        */
-       public String getDescription() {
-               return description;
-       }
-
-       /**
-        * Generates a list of ref value choices based on the bean available in the
-        * application ocntext.
-        */
-       protected List<RefValueChoice> buildRefValueChoices(RefSpecAttribute rsa) {
-               List<RefValueChoice> choices = new ArrayList<RefValueChoice>();
-               // FIXME implement something
-               return choices;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionStack.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionStack.java
deleted file mode 100644 (file)
index af98a16..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-import java.util.UUID;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.ExecutionStack;
-
-/** Canonical implementation of an execution stack. */
-public class DefaultExecutionStack implements ExecutionStack {
-
-       private final static Log log = LogFactory
-                       .getLog(DefaultExecutionStack.class);
-
-       private final Stack<ExecutionFlowRuntime> stack = new Stack<ExecutionFlowRuntime>();
-
-       public synchronized void enterFlow(ExecutionFlow executionFlow) {
-               ExecutionFlowRuntime runtime = new ExecutionFlowRuntime(executionFlow);
-               stack.push(runtime);
-
-               Map<String, ExecutionSpecAttribute> specAttrs = executionFlow
-                               .getExecutionSpec().getAttributes();
-               for (String key : specAttrs.keySet()) {
-                       if (executionFlow.isSetAsParameter(key)) {
-                               runtime.getLocalVariables().put(key,
-                                               executionFlow.getParameter(key));
-                       }
-               }
-       }
-
-       public synchronized String getCurrentStackLevelUuid() {
-               return stack.peek().getUuid();
-       }
-
-       public synchronized Integer getStackSize() {
-               return stack.size();
-       }
-
-       /**
-        * Looks for a set variable in the stack, starting at the upper flows
-        * 
-        * @return the variable or <code>null</code> if not found
-        */
-       public synchronized Object findLocalVariable(String key) {
-               Object obj = null;
-               for (int i = 0; i < stack.size(); i++) {
-                       if (stack.get(i).getLocalVariables().containsKey(key)) {
-                               obj = stack.get(i).getLocalVariables().get(key);
-                               break;
-                       }
-               }
-               return obj;
-       }
-
-       public synchronized void leaveFlow(ExecutionFlow executionFlow) {
-               ExecutionFlowRuntime leftEf = stack.pop();
-
-               if (!leftEf.getExecutionFlow().getName()
-                               .equals(executionFlow.getName()))
-                       throw new SlcException("Asked to leave " + executionFlow
-                                       + " but last is " + leftEf);
-
-               leftEf.getScopedObjects().clear();
-               leftEf.getLocalVariables().clear();
-       }
-
-       public synchronized void addScopedObject(String name, Object obj) {
-               ExecutionFlowRuntime runtime = stack.peek();
-               // TODO: check that the object is not set yet ?
-               if (log.isDebugEnabled()) {
-                       Object existing = findScopedObject(name);
-                       if (existing != null)
-                               log.warn("Scoped object " + name + " of type " + obj.getClass()
-                                               + " already registered in " + runtime);
-               }
-               runtime.getScopedObjects().put(name, obj);
-       }
-
-       /** @return </code>null<code> if not found */
-       public synchronized Object findScopedObject(String name) {
-               Object obj = null;
-               for (int i = stack.size() - 1; i >= 0; i--) {
-                       if (stack.get(i).getScopedObjects().containsKey(name)) {
-                               obj = stack.get(i).getScopedObjects().get(name);
-                               break;
-                       }
-               }
-               return obj;
-       }
-
-       protected static class ExecutionFlowRuntime {
-               private final ExecutionFlow executionFlow;
-               private final Map<String, Object> scopedObjects = new HashMap<String, Object>();
-               private final Map<String, Object> localVariables = new HashMap<String, Object>();
-               private final String uuid = UUID.randomUUID().toString();
-
-               public ExecutionFlowRuntime(ExecutionFlow executionFlow) {
-                       this.executionFlow = executionFlow;
-               }
-
-               public ExecutionFlow getExecutionFlow() {
-                       return executionFlow;
-               }
-
-               public Map<String, Object> getScopedObjects() {
-                       return scopedObjects;
-               }
-
-               public String getUuid() {
-                       return uuid;
-               }
-
-               public Map<String, Object> getLocalVariables() {
-                       return localVariables;
-               }
-
-               @Override
-               public String toString() {
-                       return "Stack Level #" + uuid;
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultProcess.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultProcess.java
deleted file mode 100644 (file)
index 9e98685..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.execution.ExecutionStep;
-import org.argeo.slc.execution.RealizedFlow;
-
-/** Canonical implementation of an {@link ExecutionProcess} as a bean. */
-public class DefaultProcess implements ExecutionProcess {
-       private String uuid = UUID.randomUUID().toString();
-       private String status = ExecutionProcess.NEW;
-
-       private List<ExecutionStep> steps = new ArrayList<ExecutionStep>();
-       private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();
-
-       public String getUuid() {
-               return uuid;
-       }
-
-       public String getStatus() {
-               return status;
-       }
-
-       public void setStatus(String status) {
-               this.status = status;
-       }
-
-       public void addSteps(List<ExecutionStep> steps) {
-               steps.addAll(steps);
-       }
-
-       public List<RealizedFlow> getRealizedFlows() {
-               return realizedFlows;
-       }
-
-       public List<ExecutionStep> getSteps() {
-               return steps;
-       }
-
-       public void setSteps(List<ExecutionStep> steps) {
-               this.steps = steps;
-       }
-
-       public void setUuid(String uuid) {
-               this.uuid = uuid;
-       }
-
-       public void setRealizedFlows(List<RealizedFlow> realizedFlows) {
-               this.realizedFlows = realizedFlows;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ExecutionThread.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ExecutionThread.java
deleted file mode 100644 (file)
index d940905..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.ExecutionStep;
-import org.argeo.slc.execution.FlowConfigurationException;
-import org.argeo.slc.execution.RealizedFlow;
-
-/** Thread of a single execution */
-public class ExecutionThread extends Thread {
-       public final static String SYSPROP_EXECUTION_AUTO_UPGRADE = "slc.execution.autoupgrade";
-       private final static Log log = LogFactory.getLog(ExecutionThread.class);
-
-       private ExecutionModulesManager executionModulesManager;
-       private final RealizedFlow realizedFlow;
-       private final AccessControlContext accessControlContext;
-
-       private List<Runnable> destructionCallbacks = new ArrayList<Runnable>();
-
-       public ExecutionThread(ProcessThreadGroup processThreadGroup, ExecutionModulesManager executionModulesManager,
-                       RealizedFlow realizedFlow) {
-               super(processThreadGroup, "Flow " + realizedFlow.getFlowDescriptor().getName());
-               this.realizedFlow = realizedFlow;
-               this.executionModulesManager = executionModulesManager;
-               accessControlContext = AccessController.getContext();
-       }
-
-       public void run() {
-               // authenticate thread
-               // Authentication authentication = getProcessThreadGroup()
-               // .getAuthentication();
-               // if (authentication == null)
-               // throw new SlcException("Can only execute authenticated threads");
-               // SecurityContextHolder.getContext().setAuthentication(authentication);
-
-               // Retrieve execution flow descriptor
-               ExecutionFlowDescriptor executionFlowDescriptor = realizedFlow.getFlowDescriptor();
-               String flowName = executionFlowDescriptor.getName();
-
-               getProcessThreadGroup().dispatchAddStep(
-                               new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.PHASE_START, "Flow " + flowName));
-
-               try {
-                       Subject subject = Subject.getSubject(accessControlContext);
-                       try {
-                               Subject.doAs(subject, new PrivilegedExceptionAction<Void>() {
-
-                                       @Override
-                                       public Void run() throws Exception {
-                                               String autoUpgrade = System.getProperty(SYSPROP_EXECUTION_AUTO_UPGRADE);
-                                               if (autoUpgrade != null && autoUpgrade.equals("true"))
-                                                       executionModulesManager.upgrade(realizedFlow.getModuleNameVersion());
-                                               executionModulesManager.start(realizedFlow.getModuleNameVersion());
-                                               //
-                                               // START FLOW
-                                               //
-                                               executionModulesManager.execute(realizedFlow);
-                                               // END FLOW
-                                               return null;
-                                       }
-
-                               });
-                       } catch (PrivilegedActionException privilegedActionException) {
-                               throw (Exception) privilegedActionException.getCause();
-                       }
-               } catch (FlowConfigurationException e) {
-                       String msg = "Configuration problem with flow " + flowName + ":\n" + e.getMessage();
-                       log.error(msg);
-                       getProcessThreadGroup().dispatchAddStep(
-                                       new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.ERROR, msg + " " + e.getMessage()));
-               } catch (Exception e) {
-                       // TODO: re-throw exception ?
-                       String msg = "Execution of flow " + flowName + " failed.";
-                       log.error(msg, e);
-                       getProcessThreadGroup().dispatchAddStep(
-                                       new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.ERROR, msg + " " + e.getMessage()));
-               } finally {
-                       getProcessThreadGroup().dispatchAddStep(
-                                       new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.PHASE_END, "Flow " + flowName));
-                       processDestructionCallbacks();
-               }
-       }
-
-       private synchronized void processDestructionCallbacks() {
-               for (int i = destructionCallbacks.size() - 1; i >= 0; i--) {
-                       try {
-                               destructionCallbacks.get(i).run();
-                       } catch (Exception e) {
-                               log.warn("Could not process destruction callback " + i + " in thread " + getName(), e);
-                       }
-               }
-       }
-
-       /**
-        * Gather object destruction callback to be called in reverse order at the
-        * end of the thread
-        */
-       public synchronized void registerDestructionCallback(String name, Runnable callback) {
-               destructionCallbacks.add(callback);
-       }
-
-       protected ProcessThreadGroup getProcessThreadGroup() {
-               return (ProcessThreadGroup) getThreadGroup();
-       }
-}
\ No newline at end of file
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/InstantiationManager.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/InstantiationManager.java
deleted file mode 100644 (file)
index 4aea94f..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.util.Stack;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveUtils;
-
-/** Manage parameters that need to be set during the instantiation of a flow */
-public class InstantiationManager {
-
-       private final static Log log = LogFactory
-                       .getLog(InstantiationManager.class);
-
-       private ThreadLocal<Stack<ExecutionFlow>> flowStack = new ThreadLocal<Stack<ExecutionFlow>>();
-
-       public Object createRef(String name) {
-
-               if ((flowStack.get() == null) || flowStack.get().empty()) {
-                       throw new SlcException("No flow is currently initializing."
-                                       + " Declare ParameterRef as inner beans or prototypes.");
-               }
-
-               return getInitializingFlowParameter(name);
-       }
-
-       public void flowInitializationStarted(ExecutionFlow flow, String flowName) {
-               // set the flow name if it is DefaultExecutionFlow
-               if (flow instanceof DefaultExecutionFlow) {
-                       ((DefaultExecutionFlow) flow).setName(flowName);
-               }
-
-               if (log.isTraceEnabled())
-                       log.trace("Start initialization of " + flow.hashCode() + " ("
-                                       + flow + " - " + flow.getClass() + ")");
-
-               // log.info("# flowInitializationStarted " + flowName);
-               // create a stack for this thread if there is none
-               if (flowStack.get() == null) {
-                       flowStack.set(new Stack<ExecutionFlow>());
-               }
-               flowStack.get().push(flow);
-       }
-
-       public void flowInitializationFinished(ExecutionFlow flow, String flowName) {
-               if (log.isTraceEnabled())
-                       log.trace("Finish initialization of " + flow.hashCode() + " ("
-                                       + flow + " - " + flow.getClass() + ")");
-
-               if (flowStack.get() != null) {
-                       ExecutionFlow registeredFlow = flowStack.get().pop();
-                       if (registeredFlow != null) {
-                               if (!flow.getName().equals(registeredFlow.getName()))
-                                       throw new SlcException("Current flow is " + flow);
-                               // log.info("# flowInitializationFinished " + flowName);
-                               // initializingFlow.set(null);
-                       }
-               } else {
-                       // happens for flows imported as services
-                       log.warn("flowInitializationFinished - Flow Stack is null");
-               }
-       }
-
-       protected ExecutionFlow findInitializingFlowWithParameter(String key) {
-               if ((flowStack.get() == null) || flowStack.get().empty())
-                       throw new SlcException("No initializing flow available.");
-
-               // first look in the outer flow (that may override parameters)
-               for (int i = 0; i < flowStack.get().size(); i++) {
-                       if (flowStack.get().elementAt(i).isSetAsParameter(key)) {
-                               return flowStack.get().elementAt(i);
-                       }
-               }
-               throw new SlcException("Key " + key + " is not set as parameter in "
-                               + flowStack.get().firstElement().toString() + " (stack size="
-                               + flowStack.get().size() + ")");
-
-       }
-
-       public Object getInitializingFlowParameter(String key) {
-               return findInitializingFlowWithParameter(key).getParameter(key);
-       }
-
-       public Class<?> getInitializingFlowParameterClass(String key) {
-               ExecutionSpecAttribute attr = findInitializingFlowWithParameter(key)
-                               .getExecutionSpec().getAttributes().get(key);
-               if (attr instanceof RefSpecAttribute)
-                       return ((RefSpecAttribute) attr).getTargetClass();
-               else if (attr instanceof PrimitiveSpecAttribute) {
-                       String type = ((PrimitiveSpecAttribute) attr).getType();
-                       Class<?> clss = PrimitiveUtils.typeAsClass(type);
-                       if (clss == null)
-                               throw new SlcException("Cannot convert type " + type
-                                               + " to class.");
-                       return clss;
-               } else
-                       return null;
-       }
-
-       public Boolean isInFlowInitialization() {
-               return (flowStack.get() != null) && !flowStack.get().empty();
-       }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThread.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThread.java
deleted file mode 100644 (file)
index 2c4f73c..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.execution.ExecutionStep;
-import org.argeo.slc.execution.RealizedFlow;
-
-/**
- * Main thread coordinating an {@link ExecutionProcess}, launching parallel or
- * sequential {@link ExecutionThread}s.
- */
-public class ProcessThread extends Thread {
-       private final static Log log = LogFactory.getLog(ProcessThread.class);
-
-       private final ExecutionModulesManager executionModulesManager;
-       private final ExecutionProcess process;
-       private final ProcessThreadGroup processThreadGroup;
-
-       private Set<ExecutionThread> executionThreads = Collections.synchronizedSet(new HashSet<ExecutionThread>());
-
-       // private Boolean hadAnError = false;
-       private Boolean killed = false;
-
-       private final AccessControlContext accessControlContext;
-
-       public ProcessThread(ThreadGroup processesThreadGroup, ExecutionModulesManager executionModulesManager,
-                       ExecutionProcess process) {
-               super(processesThreadGroup, "SLC Process #" + process.getUuid());
-               this.executionModulesManager = executionModulesManager;
-               this.process = process;
-               processThreadGroup = new ProcessThreadGroup(process);
-               accessControlContext = AccessController.getContext();
-       }
-
-       public final void run() {
-               // authenticate thread
-               // Authentication authentication = getProcessThreadGroup()
-               // .getAuthentication();
-               // if (authentication == null)
-               // throw new SlcException("Can only execute authenticated threads");
-               // SecurityContextHolder.getContext().setAuthentication(authentication);
-
-               log.info("\n##\n## SLC Process #" + process.getUuid() + " STARTED\n##\n");
-
-               // Start logging
-               new LoggingThread().start();
-
-               process.setStatus(ExecutionProcess.RUNNING);
-               try {
-                       Subject subject = Subject.getSubject(accessControlContext);
-                       try {
-                               Subject.doAs(subject, new PrivilegedExceptionAction<Void>() {
-
-                                       @Override
-                                       public Void run() throws Exception {
-                                               process();
-                                               return null;
-                                       }
-
-                               });
-                       } catch (PrivilegedActionException privilegedActionException) {
-                               Throwable cause = privilegedActionException.getCause();
-                               if (cause instanceof InterruptedException)
-                                       throw (InterruptedException) cause;
-                               else
-                                       throw new SlcException("Cannot process", cause);
-                       }
-                       // process();
-               } catch (InterruptedException e) {
-                       die();
-                       return;
-               } catch (Exception e) {
-                       String msg = "Process " + getProcess().getUuid() + " failed unexpectedly.";
-                       log.error(msg, e);
-                       getProcessThreadGroup()
-                                       .dispatchAddStep(new ExecutionStep("Process", ExecutionStep.ERROR, msg + " " + e.getMessage()));
-               }
-
-               // waits for all execution threads to complete (in case they were
-               // started asynchronously)
-               for (ExecutionThread executionThread : executionThreads) {
-                       if (executionThread.isAlive()) {
-                               try {
-                                       executionThread.join();
-                               } catch (InterruptedException e) {
-                                       die();
-                                       return;
-                               }
-                       }
-               }
-
-               computeFinalStatus();
-       }
-
-       /** Make sure this is called BEFORE all the threads are interrupted. */
-       private void computeFinalStatus() {
-               // String oldStatus = process.getStatus();
-               // TODO: error management at flow level?
-               if (killed)
-                       process.setStatus(ExecutionProcess.KILLED);
-               else if (processThreadGroup.hadAnError())
-                       process.setStatus(ExecutionProcess.ERROR);
-               else
-                       process.setStatus(ExecutionProcess.COMPLETED);
-               // executionModulesManager.dispatchUpdateStatus(process, oldStatus,
-               // process.getStatus());
-               log.info("\n## SLC Process #" + process.getUuid() + " " + process.getStatus() + "\n");
-       }
-
-       /** Called when being killed */
-       private synchronized void die() {
-               killed = true;
-               computeFinalStatus();
-               for (ExecutionThread executionThread : executionThreads) {
-                       try {
-                               executionThread.interrupt();
-                       } catch (Exception e) {
-                               log.error("Cannot interrupt " + executionThread);
-                       }
-               }
-               processThreadGroup.interrupt();
-       }
-
-       /**
-        * Implementation specific execution. To be overridden in order to deal with
-        * custom process types. Default expects an {@link SlcExecution}.
-        */
-       protected void process() throws InterruptedException {
-               List<RealizedFlow> flowsToProcess = new ArrayList<RealizedFlow>();
-               flowsToProcess.addAll(process.getRealizedFlows());
-               while (flowsToProcess.size() > 0) {
-                       RealizedFlow realizedFlow = flowsToProcess.remove(0);
-                       execute(realizedFlow, true);
-               }
-       }
-
-       /** @return the (distinct) thread used for this execution */
-       protected final void execute(RealizedFlow realizedFlow, Boolean synchronous) throws InterruptedException {
-               if (killed)
-                       return;
-
-               ExecutionThread thread = new ExecutionThread(processThreadGroup, executionModulesManager, realizedFlow);
-               executionThreads.add(thread);
-               thread.start();
-
-               if (synchronous)
-                       thread.join();
-
-               return;
-       }
-
-       // public void notifyError() {
-       // hadAnError = true;
-       // }
-       //
-       // public synchronized void flowCompleted() {
-       // // notifyAll();
-       // }
-
-       public ExecutionProcess getProcess() {
-               return process;
-       }
-
-       public ProcessThreadGroup getProcessThreadGroup() {
-               return processThreadGroup;
-       }
-
-       public ExecutionModulesManager getExecutionModulesManager() {
-               return executionModulesManager;
-       }
-
-       private class LoggingThread extends Thread {
-
-               public LoggingThread() {
-                       super("SLC Process Logger #" + process.getUuid());
-               }
-
-               public void run() {
-                       boolean run = true;
-                       while (run) {
-                               List<ExecutionStep> newSteps = new ArrayList<ExecutionStep>();
-                               processThreadGroup.getSteps().drainTo(newSteps);
-                               if (newSteps.size() > 0) {
-                                       // System.out.println(steps.size() + " steps");
-                                       process.addSteps(newSteps);
-                               }
-
-                               try {
-                                       Thread.sleep(1000);
-                               } catch (InterruptedException e) {
-                                       break;
-                               }
-
-                               if (!ProcessThread.this.isAlive() && processThreadGroup.getSteps().size() == 0)
-                                       run = false;
-                       }
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThreadGroup.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThreadGroup.java
deleted file mode 100644 (file)
index 79f38d7..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.argeo.slc.runtime;
-
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.execution.ExecutionStep;
-
-/** The thread group attached to a given {@link SlcExecution}. */
-public class ProcessThreadGroup extends ThreadGroup {
-//     private final Authentication authentication;
-       private final static Integer STEPS_BUFFER_CAPACITY = 5000;
-
-       private BlockingQueue<ExecutionStep> steps = new ArrayBlockingQueue<ExecutionStep>(
-                       STEPS_BUFFER_CAPACITY);
-
-       private Boolean hadAnError = false;
-
-       public ProcessThreadGroup(ExecutionProcess executionProcess) {
-               super("SLC Process #" + executionProcess.getUuid() + " thread group");
-//             this.authentication = SecurityContextHolder.getContext()
-//                             .getAuthentication();
-       }
-
-//     public Authentication getAuthentication() {
-//             return authentication;
-//     }
-
-       public void dispatchAddStep(ExecutionStep step) {
-               // ExecutionProcess slcProcess = processThread.getProcess();
-               // List<ExecutionStep> steps = new ArrayList<ExecutionStep>();
-               // steps.add(step);
-               // TODO clarify why we don't dispatch steps, must be a reason
-               // dispatchAddSteps(steps);
-               // slcProcess.addSteps(steps);
-               if (step.getType().equals(ExecutionStep.ERROR))
-                       hadAnError = true;
-               this.steps.add(step);
-       }
-
-       // public void dispatchAddSteps(List<ExecutionStep> steps) {
-       // ExecutionProcess slcProcess = processThread.getProcess();
-       // executionModulesManager.dispatchAddSteps(slcProcess, steps);
-       // }
-
-       public BlockingQueue<ExecutionStep> getSteps() {
-               return steps;
-       }
-
-       public Boolean hadAnError() {
-               return hadAnError;
-       }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/CloseTestResult.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/CloseTestResult.java
deleted file mode 100644 (file)
index 2bb48b8..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.argeo.slc.runtime.tasks;
-
-import org.argeo.slc.test.TestResult;
-
-public class CloseTestResult implements Runnable {
-       private TestResult testResult;
-
-       public void run() {
-               testResult.close();
-       }
-
-       public void setTestResult(TestResult testResult) {
-               this.testResult = testResult;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/Echo.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/Echo.java
deleted file mode 100644 (file)
index a6e60d3..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.argeo.slc.runtime.tasks;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-
-public class Echo implements Runnable {
-       private final static Log defaultLog = LogFactory.getLog(Echo.class);
-       private Path writeTo = null;
-
-       private Log log;
-       private Object message;
-
-       public void run() {
-               log().info(message);
-
-               if (writeTo != null) {
-                       try {
-                               File file = writeTo.toFile();
-                               if (log().isDebugEnabled())
-                                       log().debug("Write to " + file);
-                               if (message != null)
-                                       FileUtils.writeStringToFile(file, message.toString());
-                       } catch (IOException e) {
-                               throw new SlcException("Could not write to " + writeTo, e);
-                       }
-               }
-       }
-
-       private Log log() {
-               return log != null ? log : defaultLog;
-       }
-
-       public void setMessage(Object message) {
-               this.message = message;
-       }
-
-       public void setWriteTo(Path writeTo) {
-               this.writeTo = writeTo;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/If.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/If.java
deleted file mode 100644 (file)
index 08eb804..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.argeo.slc.runtime.tasks;
-
-import org.argeo.slc.SlcException;
-
-/** Conditional execution */
-public class If implements Runnable {
-       private Boolean is;
-       private Boolean not;
-       private Runnable then;
-       private Runnable els;
-
-       public void run() {
-               if (is == null && not == null)
-                       throw new SlcException("No condition set");
-               if (is != null && not != null)
-                       throw new SlcException("Both is and not cannot be set");
-
-               boolean bool = (is != null ? is : !not);
-               if (bool) {
-                       if (then != null)
-                               then.run();
-               } else {
-                       if (els != null)
-                               els.run();
-               }
-
-       }
-
-       public void setIs(Boolean bool) {
-               this.is = bool;
-       }
-
-       public void setThen(Runnable then) {
-               this.then = then;
-       }
-
-       public void setEls(Runnable els) {
-               this.els = els;
-       }
-
-       public Boolean getNot() {
-               return not;
-       }
-
-       public void setNot(Boolean not) {
-               this.not = not;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/JvmProcess.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/JvmProcess.java
deleted file mode 100644 (file)
index c89f2b8..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-package org.argeo.slc.runtime.tasks;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-
-/** A Java Virtual Machine process. */
-public class JvmProcess extends SystemCall {
-       private Properties systemProperties = new Properties();
-       private List<Path> classpath = new ArrayList<Path>();
-       private List<Path> pBootClasspath = new ArrayList<Path>();
-       private Path jvm = null;
-       private String mainClass;
-       private String mainJar;
-       private List<String> jvmArgs = new ArrayList<String>();
-       private List<String> args = new ArrayList<String>();
-
-       private String systemPropertiesFileProperty = null;
-       private String systemPropertiesFileDir = null;
-       private String systemPropertiesFileName = null;
-
-       public void init() throws Exception {
-               List<Object> command = new ArrayList<Object>();
-               if (jvm != null)
-                       command.add(asFile(jvm).getPath());
-               else
-                       command.add("java");
-
-               if (pBootClasspath.size() > 0) {
-                       StringBuffer buf = new StringBuffer("-Xbootclasspath/p:");
-                       Boolean first = true;
-                       for (Path res : pBootClasspath) {
-                               if (first)
-                                       first = false;
-                               else
-                                       buf.append(File.pathSeparatorChar);
-
-                               buf.append(asFile(res));
-                       }
-                       command.add(buf.toString());
-               }
-
-               for (String jvmArg : jvmArgs) {
-                       command.add(jvmArg);
-               }
-
-               if (classpath.size() > 0) {
-                       command.add("-cp");
-                       StringBuffer buf = new StringBuffer("");
-                       for (Path res : classpath) {
-                               if (buf.length() != 0)
-                                       buf.append(File.pathSeparatorChar);
-                               buf.append(asFile(res));
-                       }
-                       command.add(buf.toString());
-               }
-
-               if (systemPropertiesFileProperty == null) {
-                       // pass system properties as argument
-                       for (Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
-                               command.add("-D" + entry.getKey() + "=" + entry.getValue());
-                       }
-               } else {
-                       // write system properties in a file to work around OS limitations
-                       // with command line (e.g. Win XP)
-                       String dir = systemPropertiesFileDir;
-                       if (dir == null)
-                               dir = getExecDirToUse();
-                       String fileName = systemPropertiesFileName;
-                       if (fileName == null)
-                               fileName = systemPropertiesFileProperty + ".properties";
-
-                       // Write file
-                       FileOutputStream fos = null;
-                       File file = new File(dir + File.separator + fileName);
-                       try {
-
-                               if (!file.getParentFile().exists())
-                                       file.getParentFile().mkdirs();
-                               fos = new FileOutputStream(file);
-                               systemProperties.store(fos, "Automatically generated by " + getClass());
-                               command.add("-D" + systemPropertiesFileProperty + "=" + file.getCanonicalPath());
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot write to system properties to " + file, e);
-                       } finally {
-                               IOUtils.closeQuietly(fos);
-                       }
-               }
-
-               // Program
-               if (mainClass != null) {
-                       command.add(mainClass);
-               } else if (mainJar != null) {
-                       command.add("-jar");
-                       command.add(mainJar);
-               } else {
-                       throw new SlcException("No main class or jar defined");
-               }
-
-               for (String arg : args) {
-                       command.add(arg);
-               }
-
-               setCommand(command);
-       }
-
-       protected File asFile(Path res) {
-               File file = res.toFile();
-               if (!file.exists())
-                       return copyToTempFile(res);
-               else
-                       return res.toFile();
-       }
-
-       protected File copyToTempFile(Path res) {
-               File tempFile;
-               FileOutputStream fos;
-               try {
-                       tempFile = File.createTempFile("slcJvmProcess-", res.getFileName().toString());
-                       tempFile.deleteOnExit();
-                       fos = new FileOutputStream(tempFile);
-                       IOUtils.copy(Files.newInputStream(res), fos);
-               } catch (IOException e) {
-                       throw new SlcException("Cannot copy " + res + " to temp file.", e);
-               }
-               IOUtils.closeQuietly(fos);
-               return tempFile;
-       }
-
-       /** Append the argument (for chaining) */
-       @Override
-       public SystemCall arg(String arg) {
-               args.add(arg);
-               return this;
-       }
-
-       /** Append the argument (for chaining) */
-       @Override
-       public SystemCall arg(String arg, String value) {
-               args.add(arg);
-               args.add(value);
-               return this;
-       }
-
-       public Properties getSystemProperties() {
-               return systemProperties;
-       }
-
-       public void setSystemProperties(Properties systemProperties) {
-               this.systemProperties = systemProperties;
-       }
-
-       public List<Path> getClasspath() {
-               return classpath;
-       }
-
-       public void setClasspath(List<Path> classpath) {
-               this.classpath = classpath;
-       }
-
-       public List<Path> getPBootClasspath() {
-               return pBootClasspath;
-       }
-
-       public void setPBootClasspath(List<Path> bootClasspath) {
-               pBootClasspath = bootClasspath;
-       }
-
-       public Path getJvm() {
-               return jvm;
-       }
-
-       public void setJvm(Path jvm) {
-               this.jvm = jvm;
-       }
-
-       public String getMainClass() {
-               return mainClass;
-       }
-
-       public void setMainClass(String mainClass) {
-               this.mainClass = mainClass;
-       }
-
-       public String getMainJar() {
-               return mainJar;
-       }
-
-       public void setMainJar(String mainJar) {
-               this.mainJar = mainJar;
-       }
-
-       public List<String> getJvmArgs() {
-               return jvmArgs;
-       }
-
-       public void setJvmArgs(List<String> jvmArgs) {
-               this.jvmArgs = jvmArgs;
-       }
-
-       public List<String> getArgs() {
-               return args;
-       }
-
-       public void setArgs(List<String> args) {
-               this.args = args;
-       }
-
-       public void setSystemPropertiesFileProperty(String systemPropertiesFilePropertyName) {
-               this.systemPropertiesFileProperty = systemPropertiesFilePropertyName;
-       }
-
-       public void setSystemPropertiesFileDir(String systemPropertiesFileDir) {
-               this.systemPropertiesFileDir = systemPropertiesFileDir;
-       }
-
-       public void setSystemPropertiesFileName(String systemPropertiesFileName) {
-               this.systemPropertiesFileName = systemPropertiesFileName;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCall.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCall.java
deleted file mode 100644 (file)
index f5e8502..0000000
+++ /dev/null
@@ -1,746 +0,0 @@
-package org.argeo.slc.runtime.tasks;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.io.Writer;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.security.auth.callback.CallbackHandler;
-
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.ExecuteException;
-import org.apache.commons.exec.ExecuteResultHandler;
-import org.apache.commons.exec.ExecuteStreamHandler;
-import org.apache.commons.exec.ExecuteWatchdog;
-import org.apache.commons.exec.Executor;
-import org.apache.commons.exec.LogOutputStream;
-import org.apache.commons.exec.PumpStreamHandler;
-import org.apache.commons.exec.ShutdownHookProcessDestroyer;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.execution.ExecutionResources;
-import org.argeo.slc.runtime.test.SimpleResultPart;
-import org.argeo.slc.test.TestResult;
-import org.argeo.slc.test.TestStatus;
-
-/** Execute an OS specific system call. */
-public class SystemCall implements Runnable {
-       public final static String LOG_STDOUT = "System.out";
-
-       private final Log log = LogFactory.getLog(getClass());
-
-       private String execDir;
-
-       private String cmd = null;
-       private List<Object> command = null;
-
-       private Executor executor = new DefaultExecutor();
-       private Boolean synchronous = true;
-
-       private String stdErrLogLevel = "ERROR";
-       private String stdOutLogLevel = "INFO";
-
-       private Path stdOutFile = null;
-       private Path stdErrFile = null;
-
-       private Path stdInFile = null;
-       /**
-        * If no {@link #stdInFile} provided, writing to this stream will write to the
-        * stdin of the process.
-        */
-       private OutputStream stdInSink = null;
-
-       private Boolean redirectStdOut = false;
-
-       private List<SystemCallOutputListener> outputListeners = Collections
-                       .synchronizedList(new ArrayList<SystemCallOutputListener>());
-
-       private Map<String, List<Object>> osCommands = new HashMap<String, List<Object>>();
-       private Map<String, String> osCmds = new HashMap<String, String>();
-       private Map<String, String> environmentVariables = new HashMap<String, String>();
-
-       private Boolean logCommand = false;
-       private Boolean redirectStreams = true;
-       private Boolean exceptionOnFailed = true;
-       private Boolean mergeEnvironmentVariables = true;
-
-//     private Authentication authentication;
-
-       private String osConsole = null;
-       private String generateScript = null;
-
-       /** 24 hours */
-       private Long watchdogTimeout = 24 * 60 * 60 * 1000l;
-
-       private TestResult testResult;
-
-       private ExecutionResources executionResources;
-
-       /** Sudo the command, as root if empty or as user if not. */
-       private String sudo = null;
-       // TODO make it more secure and robust, test only once
-       private final String sudoPrompt = UUID.randomUUID().toString();
-       private String askPassProgram = "/usr/libexec/openssh/ssh-askpass";
-       @SuppressWarnings("unused")
-       private boolean firstLine = true;
-       @SuppressWarnings("unused")
-       private CallbackHandler callbackHandler;
-       /** Chroot to the this path (must not be empty) */
-       private String chroot = null;
-
-       // Current
-       /** Current watchdog, null if process is completed */
-       ExecuteWatchdog currentWatchdog = null;
-
-       /** Empty constructor */
-       public SystemCall() {
-
-       }
-
-       /**
-        * Constructor based on the provided command list.
-        * 
-        * @param command the command list
-        */
-       public SystemCall(List<Object> command) {
-               this.command = command;
-       }
-
-       /**
-        * Constructor based on the provided command.
-        * 
-        * @param cmd the command. If the provided string contains no space a command
-        *            list is initialized with the argument as first component (useful
-        *            for chained construction)
-        */
-       public SystemCall(String cmd) {
-               if (cmd.indexOf(' ') < 0) {
-                       command = new ArrayList<Object>();
-                       command.add(cmd);
-               } else {
-                       this.cmd = cmd;
-               }
-       }
-
-       /** Executes the system call. */
-       public void run() {
-//             authentication = SecurityContextHolder.getContext().getAuthentication();
-
-               // Manage streams
-               Writer stdOutWriter = null;
-               OutputStream stdOutputStream = null;
-               Writer stdErrWriter = null;
-               InputStream stdInStream = null;
-               if (stdOutFile != null)
-                       if (redirectStdOut)
-                               stdOutputStream = createOutputStream(stdOutFile);
-                       else
-                               stdOutWriter = createWriter(stdOutFile, true);
-
-               if (stdErrFile != null) {
-                       stdErrWriter = createWriter(stdErrFile, true);
-               } else {
-                       if (stdOutFile != null && !redirectStdOut)
-                               stdErrWriter = createWriter(stdOutFile, true);
-               }
-
-               try {
-                       if (stdInFile != null)
-                               stdInStream = Files.newInputStream(stdInFile);
-                       else {
-                               stdInStream = new PipedInputStream();
-                               stdInSink = new PipedOutputStream((PipedInputStream) stdInStream);
-                       }
-               } catch (IOException e2) {
-                       throw new SlcException("Cannot open a stream for " + stdInFile, e2);
-               }
-
-               if (log.isTraceEnabled()) {
-                       log.debug("os.name=" + System.getProperty("os.name"));
-                       log.debug("os.arch=" + System.getProperty("os.arch"));
-                       log.debug("os.version=" + System.getProperty("os.version"));
-               }
-
-               // Execution directory
-               File dir = new File(getExecDirToUse());
-               // if (!dir.exists())
-               // dir.mkdirs();
-
-               // Watchdog to check for lost processes
-               Executor executorToUse;
-               if (executor != null)
-                       executorToUse = executor;
-               else
-                       executorToUse = new DefaultExecutor();
-               executorToUse.setWatchdog(createWatchdog());
-
-               if (redirectStreams) {
-                       // Redirect standard streams
-                       executorToUse.setStreamHandler(
-                                       createExecuteStreamHandler(stdOutWriter, stdOutputStream, stdErrWriter, stdInStream));
-               } else {
-                       // Dummy stream handler (otherwise pump is used)
-                       executorToUse.setStreamHandler(new DummyexecuteStreamHandler());
-               }
-
-               executorToUse.setProcessDestroyer(new ShutdownHookProcessDestroyer());
-               executorToUse.setWorkingDirectory(dir);
-
-               // Command line to use
-               final CommandLine commandLine = createCommandLine();
-               if (logCommand)
-                       log.info("Execute command:\n" + commandLine + "\n in working directory: \n" + dir + "\n");
-
-               // Env variables
-               Map<String, String> environmentVariablesToUse = null;
-               environmentVariablesToUse = new HashMap<String, String>();
-               if (mergeEnvironmentVariables)
-                       environmentVariablesToUse.putAll(System.getenv());
-               if (environmentVariables.size() > 0)
-                       environmentVariablesToUse.putAll(environmentVariables);
-
-               // Execute
-               ExecuteResultHandler executeResultHandler = createExecuteResultHandler(commandLine);
-
-               //
-               // THE EXECUTION PROPER
-               //
-               try {
-                       if (synchronous)
-                               try {
-                                       int exitValue = executorToUse.execute(commandLine, environmentVariablesToUse);
-                                       executeResultHandler.onProcessComplete(exitValue);
-                               } catch (ExecuteException e1) {
-                                       if (e1.getExitValue() == Executor.INVALID_EXITVALUE) {
-                                               Thread.currentThread().interrupt();
-                                               return;
-                                       }
-                                       // Sleep 1s in order to make sure error logs are flushed
-                                       Thread.sleep(1000);
-                                       executeResultHandler.onProcessFailed(e1);
-                               }
-                       else
-                               executorToUse.execute(commandLine, environmentVariablesToUse, executeResultHandler);
-               } catch (SlcException e) {
-                       throw e;
-               } catch (Exception e) {
-                       throw new SlcException("Could not execute command " + commandLine, e);
-               } finally {
-                       IOUtils.closeQuietly(stdOutWriter);
-                       IOUtils.closeQuietly(stdErrWriter);
-                       IOUtils.closeQuietly(stdInStream);
-                       IOUtils.closeQuietly(stdInSink);
-               }
-
-       }
-
-       public synchronized String function() {
-               final StringBuffer buf = new StringBuffer("");
-               SystemCallOutputListener tempOutputListener = new SystemCallOutputListener() {
-                       private Long lineCount = 0l;
-
-                       public void newLine(SystemCall systemCall, String line, Boolean isError) {
-                               if (!isError) {
-                                       if (lineCount != 0l)
-                                               buf.append('\n');
-                                       buf.append(line);
-                                       lineCount++;
-                               }
-                       }
-               };
-               addOutputListener(tempOutputListener);
-               run();
-               removeOutputListener(tempOutputListener);
-               return buf.toString();
-       }
-
-       public String asCommand() {
-               return createCommandLine().toString();
-       }
-
-       @Override
-       public String toString() {
-               return asCommand();
-       }
-
-       /**
-        * Build a command line based on the properties. Can be overridden by specific
-        * command wrappers.
-        */
-       protected CommandLine createCommandLine() {
-               // Check if an OS specific command overrides
-               String osName = System.getProperty("os.name");
-               List<Object> commandToUse = null;
-               if (osCommands.containsKey(osName))
-                       commandToUse = osCommands.get(osName);
-               else
-                       commandToUse = command;
-               String cmdToUse = null;
-               if (osCmds.containsKey(osName))
-                       cmdToUse = osCmds.get(osName);
-               else
-                       cmdToUse = cmd;
-
-               CommandLine commandLine = null;
-
-               // Which command definition to use
-               if (commandToUse == null && cmdToUse == null)
-                       throw new SlcException("Please specify a command.");
-               else if (commandToUse != null && cmdToUse != null)
-                       throw new SlcException("Specify the command either as a line or as a list.");
-               else if (cmdToUse != null) {
-                       if (chroot != null && !chroot.trim().equals(""))
-                               cmdToUse = "chroot \"" + chroot + "\" " + cmdToUse;
-                       if (sudo != null) {
-                               environmentVariables.put("SUDO_ASKPASS", askPassProgram);
-                               if (!sudo.trim().equals(""))
-                                       cmdToUse = "sudo -p " + sudoPrompt + " -u " + sudo + " " + cmdToUse;
-                               else
-                                       cmdToUse = "sudo -p " + sudoPrompt + " " + cmdToUse;
-                       }
-
-                       // GENERATE COMMAND LINE
-                       commandLine = CommandLine.parse(cmdToUse);
-               } else if (commandToUse != null) {
-                       if (commandToUse.size() == 0)
-                               throw new SlcException("Command line is empty.");
-
-                       if (chroot != null && sudo != null) {
-                               commandToUse.add(0, "chroot");
-                               commandToUse.add(1, chroot);
-                       }
-
-                       if (sudo != null) {
-                               environmentVariables.put("SUDO_ASKPASS", askPassProgram);
-                               commandToUse.add(0, "sudo");
-                               commandToUse.add(1, "-p");
-                               commandToUse.add(2, sudoPrompt);
-                               if (!sudo.trim().equals("")) {
-                                       commandToUse.add(3, "-u");
-                                       commandToUse.add(4, sudo);
-                               }
-                       }
-
-                       // GENERATE COMMAND LINE
-                       commandLine = new CommandLine(commandToUse.get(0).toString());
-
-                       for (int i = 1; i < commandToUse.size(); i++) {
-                               if (log.isTraceEnabled())
-                                       log.debug(commandToUse.get(i));
-                               commandLine.addArgument(commandToUse.get(i).toString());
-                       }
-               } else {
-                       // all cases covered previously
-                       throw new UnsupportedException();
-               }
-
-               if (generateScript != null) {
-                       File scriptFile = new File(getExecDirToUse() + File.separator + generateScript);
-                       try {
-                               FileUtils.writeStringToFile(scriptFile,
-                                               (osConsole != null ? osConsole + " " : "") + commandLine.toString());
-                       } catch (IOException e) {
-                               throw new SlcException("Could not generate script " + scriptFile, e);
-                       }
-                       commandLine = new CommandLine(scriptFile);
-               } else {
-                       if (osConsole != null)
-                               commandLine = CommandLine.parse(osConsole + " " + commandLine.toString());
-               }
-
-               return commandLine;
-       }
-
-       /**
-        * Creates a {@link PumpStreamHandler} which redirects streams to the custom
-        * logging mechanism.
-        */
-       protected ExecuteStreamHandler createExecuteStreamHandler(final Writer stdOutWriter,
-                       final OutputStream stdOutputStream, final Writer stdErrWriter, final InputStream stdInStream) {
-
-               // Log writers
-               OutputStream stdout = stdOutputStream != null ? stdOutputStream : new LogOutputStream() {
-                       protected void processLine(String line, int level) {
-                               // if (firstLine) {
-                               // if (sudo != null && callbackHandler != null
-                               // && line.startsWith(sudoPrompt)) {
-                               // try {
-                               // PasswordCallback pc = new PasswordCallback(
-                               // "sudo password", false);
-                               // Callback[] cbs = { pc };
-                               // callbackHandler.handle(cbs);
-                               // char[] pwd = pc.getPassword();
-                               // char[] arr = Arrays.copyOf(pwd,
-                               // pwd.length + 1);
-                               // arr[arr.length - 1] = '\n';
-                               // IOUtils.write(arr, stdInSink);
-                               // stdInSink.flush();
-                               // } catch (Exception e) {
-                               // throw new SlcException(
-                               // "Cannot retrieve sudo password", e);
-                               // }
-                               // }
-                               // firstLine = false;
-                               // }
-
-                               if (line != null && !line.trim().equals(""))
-                                       logStdOut(line);
-
-                               if (stdOutWriter != null)
-                                       appendLineToFile(stdOutWriter, line);
-                       }
-               };
-
-               OutputStream stderr = new LogOutputStream() {
-                       protected void processLine(String line, int level) {
-                               if (line != null && !line.trim().equals(""))
-                                       logStdErr(line);
-                               if (stdErrWriter != null)
-                                       appendLineToFile(stdErrWriter, line);
-                       }
-               };
-
-               PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(stdout, stderr, stdInStream) {
-
-                       @Override
-                       public void stop() throws IOException {
-                               // prevents the method to block when joining stdin
-                               if (stdInSink != null)
-                                       IOUtils.closeQuietly(stdInSink);
-
-                               super.stop();
-                       }
-               };
-               return pumpStreamHandler;
-       }
-
-       /** Creates the default {@link ExecuteResultHandler}. */
-       protected ExecuteResultHandler createExecuteResultHandler(final CommandLine commandLine) {
-               return new ExecuteResultHandler() {
-
-                       public void onProcessComplete(int exitValue) {
-                               String msg = "System call '" + commandLine + "' properly completed.";
-                               if (log.isTraceEnabled())
-                                       log.trace(msg);
-                               if (testResult != null) {
-                                       forwardPath(testResult);
-                                       testResult.addResultPart(new SimpleResultPart(TestStatus.PASSED, msg));
-                               }
-                               releaseWatchdog();
-                       }
-
-                       public void onProcessFailed(ExecuteException e) {
-
-                               String msg = "System call '" + commandLine + "' failed.";
-                               if (testResult != null) {
-                                       forwardPath(testResult);
-                                       testResult.addResultPart(new SimpleResultPart(TestStatus.ERROR, msg, e));
-                               } else {
-                                       if (exceptionOnFailed)
-                                               throw new SlcException(msg, e);
-                                       else
-                                               log.error(msg, e);
-                               }
-                               releaseWatchdog();
-                       }
-               };
-       }
-
-       @Deprecated
-       protected void forwardPath(TestResult testResult) {
-               // TODO: allocate a TreeSPath
-       }
-
-       /**
-        * Shortcut method getting the execDir to use
-        */
-       protected String getExecDirToUse() {
-               try {
-                       if (execDir != null) {
-                               return execDir;
-                       }
-                       return System.getProperty("user.dir");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot find exec dir", e);
-               }
-       }
-
-       protected void logStdOut(String line) {
-               for (SystemCallOutputListener outputListener : outputListeners)
-                       outputListener.newLine(this, line, false);
-               log(stdOutLogLevel, line);
-       }
-
-       protected void logStdErr(String line) {
-               for (SystemCallOutputListener outputListener : outputListeners)
-                       outputListener.newLine(this, line, true);
-               log(stdErrLogLevel, line);
-       }
-
-       /** Log from the underlying streams. */
-       protected void log(String logLevel, String line) {
-               // TODO optimize
-//             if (SecurityContextHolder.getContext().getAuthentication() == null) {
-//                     SecurityContextHolder.getContext()
-//                                     .setAuthentication(authentication);
-//             }
-
-               if ("ERROR".equals(logLevel))
-                       log.error(line);
-               else if ("WARN".equals(logLevel))
-                       log.warn(line);
-               else if ("INFO".equals(logLevel))
-                       log.info(line);
-               else if ("DEBUG".equals(logLevel))
-                       log.debug(line);
-               else if ("TRACE".equals(logLevel))
-                       log.trace(line);
-               else if (LOG_STDOUT.equals(logLevel))
-                       System.out.println(line);
-               else if ("System.err".equals(logLevel))
-                       System.err.println(line);
-               else
-                       throw new SlcException("Unknown log level " + logLevel);
-       }
-
-       /** Append line to a log file. */
-       protected void appendLineToFile(Writer writer, String line) {
-               try {
-                       writer.append(line).append('\n');
-               } catch (IOException e) {
-                       log.error("Cannot write to log file", e);
-               }
-       }
-
-       /** Creates the writer for the output/err files. */
-       protected Writer createWriter(Path target, Boolean append) {
-               FileWriter writer = null;
-               try {
-
-                       final File file;
-                       if (executionResources != null)
-                               file = new File(executionResources.getAsOsPath(target, true));
-                       else
-                               file = target.toFile();
-                       writer = new FileWriter(file, append);
-               } catch (IOException e) {
-                       log.error("Cannot get file for " + target, e);
-                       IOUtils.closeQuietly(writer);
-               }
-               return writer;
-       }
-
-       /** Creates an outputstream for the output/err files. */
-       protected OutputStream createOutputStream(Path target) {
-               FileOutputStream out = null;
-               try {
-
-                       final File file;
-                       if (executionResources != null)
-                               file = new File(executionResources.getAsOsPath(target, true));
-                       else
-                               file = target.toFile();
-                       out = new FileOutputStream(file, false);
-               } catch (IOException e) {
-                       log.error("Cannot get file for " + target, e);
-                       IOUtils.closeQuietly(out);
-               }
-               return out;
-       }
-
-       /** Append the argument (for chaining) */
-       public SystemCall arg(String arg) {
-               if (command == null)
-                       command = new ArrayList<Object>();
-               command.add(arg);
-               return this;
-       }
-
-       /** Append the argument (for chaining) */
-       public SystemCall arg(String arg, String value) {
-               if (command == null)
-                       command = new ArrayList<Object>();
-               command.add(arg);
-               command.add(value);
-               return this;
-       }
-
-       // CONTROL
-       public synchronized Boolean isRunning() {
-               return currentWatchdog != null;
-       }
-
-       private synchronized ExecuteWatchdog createWatchdog() {
-//             if (currentWatchdog != null)
-//                     throw new SlcException("A process is already being monitored");
-               currentWatchdog = new ExecuteWatchdog(watchdogTimeout);
-               return currentWatchdog;
-       }
-
-       private synchronized void releaseWatchdog() {
-               currentWatchdog = null;
-       }
-
-       public synchronized void kill() {
-               if (currentWatchdog != null)
-                       currentWatchdog.destroyProcess();
-       }
-
-       /** */
-       public void setCmd(String command) {
-               this.cmd = command;
-       }
-
-       public void setCommand(List<Object> command) {
-               this.command = command;
-       }
-
-       public void setExecDir(String execdir) {
-               this.execDir = execdir;
-       }
-
-       public void setStdErrLogLevel(String stdErrLogLevel) {
-               this.stdErrLogLevel = stdErrLogLevel;
-       }
-
-       public void setStdOutLogLevel(String stdOutLogLevel) {
-               this.stdOutLogLevel = stdOutLogLevel;
-       }
-
-       public void setSynchronous(Boolean synchronous) {
-               this.synchronous = synchronous;
-       }
-
-       public void setOsCommands(Map<String, List<Object>> osCommands) {
-               this.osCommands = osCommands;
-       }
-
-       public void setOsCmds(Map<String, String> osCmds) {
-               this.osCmds = osCmds;
-       }
-
-       public void setEnvironmentVariables(Map<String, String> environmentVariables) {
-               this.environmentVariables = environmentVariables;
-       }
-
-       public Map<String, String> getEnvironmentVariables() {
-               return environmentVariables;
-       }
-
-       public void setWatchdogTimeout(Long watchdogTimeout) {
-               this.watchdogTimeout = watchdogTimeout;
-       }
-
-       public void setStdOutFile(Path stdOutFile) {
-               this.stdOutFile = stdOutFile;
-       }
-
-       public void setStdErrFile(Path stdErrFile) {
-               this.stdErrFile = stdErrFile;
-       }
-
-       public void setStdInFile(Path stdInFile) {
-               this.stdInFile = stdInFile;
-       }
-
-       public void setTestResult(TestResult testResult) {
-               this.testResult = testResult;
-       }
-
-       public void setLogCommand(Boolean logCommand) {
-               this.logCommand = logCommand;
-       }
-
-       public void setRedirectStreams(Boolean redirectStreams) {
-               this.redirectStreams = redirectStreams;
-       }
-
-       public void setExceptionOnFailed(Boolean exceptionOnFailed) {
-               this.exceptionOnFailed = exceptionOnFailed;
-       }
-
-       public void setMergeEnvironmentVariables(Boolean mergeEnvironmentVariables) {
-               this.mergeEnvironmentVariables = mergeEnvironmentVariables;
-       }
-
-       public void setOsConsole(String osConsole) {
-               this.osConsole = osConsole;
-       }
-
-       public void setGenerateScript(String generateScript) {
-               this.generateScript = generateScript;
-       }
-
-       public void setExecutionResources(ExecutionResources executionResources) {
-               this.executionResources = executionResources;
-       }
-
-       public void setRedirectStdOut(Boolean redirectStdOut) {
-               this.redirectStdOut = redirectStdOut;
-       }
-
-       public void addOutputListener(SystemCallOutputListener outputListener) {
-               outputListeners.add(outputListener);
-       }
-
-       public void removeOutputListener(SystemCallOutputListener outputListener) {
-               outputListeners.remove(outputListener);
-       }
-
-       public void setOutputListeners(List<SystemCallOutputListener> outputListeners) {
-               this.outputListeners = outputListeners;
-       }
-
-       public void setExecutor(Executor executor) {
-               this.executor = executor;
-       }
-
-       public void setSudo(String sudo) {
-               this.sudo = sudo;
-       }
-
-       public void setCallbackHandler(CallbackHandler callbackHandler) {
-               this.callbackHandler = callbackHandler;
-       }
-
-       public void setChroot(String chroot) {
-               this.chroot = chroot;
-       }
-
-       private class DummyexecuteStreamHandler implements ExecuteStreamHandler {
-
-               public void setProcessErrorStream(InputStream is) throws IOException {
-               }
-
-               public void setProcessInputStream(OutputStream os) throws IOException {
-               }
-
-               public void setProcessOutputStream(InputStream is) throws IOException {
-               }
-
-               public void start() throws IOException {
-               }
-
-               public void stop() {
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCallOutputListener.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCallOutputListener.java
deleted file mode 100644 (file)
index bedd15a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.runtime.tasks;
-
-public interface SystemCallOutputListener {
-       public void newLine(SystemCall systemCall, String line, Boolean isError);
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestData.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestData.java
deleted file mode 100644 (file)
index ec6261d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.argeo.slc.runtime.test;
-
-import org.argeo.slc.test.TestData;
-
-public class BasicTestData implements TestData {
-       private Object expected;
-       private Object reached;
-
-       public Object getExpected() {
-               return expected;
-       }
-
-       public void setExpected(Object expected) {
-               this.expected = expected;
-       }
-
-       public Object getReached() {
-               return reached;
-       }
-
-       public void setReached(Object reached) {
-               this.reached = reached;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestDefinition.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestDefinition.java
deleted file mode 100644 (file)
index 3bc49f6..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.argeo.slc.runtime.test;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.test.IncompatibleTestDataException;
-import org.argeo.slc.test.TestData;
-import org.argeo.slc.test.TestDefinition;
-import org.argeo.slc.test.TestResult;
-import org.argeo.slc.test.TestRun;
-import org.argeo.slc.test.TestStatus;
-import org.argeo.slc.test.context.ContextAware;
-
-/** Understands basic test data and context aware test data. */
-public class BasicTestDefinition implements TestDefinition {
-
-       public void execute(TestRun testRun) {
-               if (testRun.<TestData> getTestData() instanceof BasicTestData) {
-                       BasicTestData testData = testRun.getTestData();
-                       TestResult result = testRun.getTestResult();
-
-                       if (result == null)
-                               throw new SlcException("No test result defined.");
-
-                       try {
-                               if (testData.getExpected().equals(testData.getReached())) {
-                                       result.addResultPart(new SimpleResultPart(
-                                                       TestStatus.PASSED, "Reached and expected equals"));
-                               } else {
-                                       result.addResultPart(new SimpleResultPart(
-                                                       TestStatus.FAILED, "Expected "
-                                                                       + testData.getExpected() + " but reached "
-                                                                       + testData.getReached()));
-                               }
-                       } catch (Exception e) {
-                               result.addResultPart(new SimpleResultPart(TestStatus.ERROR,
-                                               "Could not compare", e));
-                       }
-               } else if (testRun.<TestData> getTestData() instanceof ContextAware) {
-                       TestData testData = testRun.getTestData();
-                       ContextUtils.compareReachedExpected((ContextAware) testData,
-                                       testRun.getTestResult());
-               } else {
-                       throw new IncompatibleTestDataException(testRun);
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/ContextUtils.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/ContextUtils.java
deleted file mode 100644 (file)
index 97d7305..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.argeo.slc.runtime.test;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.test.TestResult;
-import org.argeo.slc.test.TestStatus;
-import org.argeo.slc.test.context.ContextAware;
-import org.argeo.slc.test.context.ParentContextAware;
-
-/** Utilities for comparing and synchronising contexts. */
-public class ContextUtils {
-       private final static Log log = LogFactory.getLog(ContextUtils.class);
-
-       public static void compareReachedExpected(ContextAware contextAware,
-                       TestResult testResult) {
-               for (String key : contextAware.getExpectedValues().keySet()) {
-
-                       // Compare expected values with reached ones
-                       Object expectedValue = contextAware.getExpectedValues().get(key);
-
-                       if (expectedValue.toString().equals(
-                                       contextAware.getContextSkipFlag())) {
-                               if (log.isDebugEnabled())
-                                       log.debug("Skipped check for key '" + key + "'");
-                               continue;
-                       }
-
-                       if (contextAware.getValues().containsKey(key)) {
-                               Object reachedValue = contextAware.getValues().get(key);
-
-                               if (expectedValue.equals(contextAware.getContextAnyFlag())) {
-                                       testResult.addResultPart(new SimpleResultPart(
-                                                       TestStatus.PASSED, "Expected any value for key '"
-                                                                       + key + "'"));
-                               } else if (expectedValue.equals(reachedValue)) {
-                                       testResult.addResultPart(new SimpleResultPart(
-                                                       TestStatus.PASSED, "Values matched for key '" + key
-                                                                       + "'"));
-                               } else {
-                                       testResult.addResultPart(new SimpleResultPart(
-                                                       TestStatus.FAILED, "Mismatch for key '" + key
-                                                                       + "': expected '" + expectedValue
-                                                                       + "' but reached '" + reachedValue + "'"));
-                               }
-                       } else {
-                               testResult.addResultPart(new SimpleResultPart(
-                                               TestStatus.FAILED, "No value reached for key '" + key
-                                                               + "'"));
-                       }
-               }
-       }
-
-       /**
-        * Makes sure that all children and sub-children of parent share the same
-        * maps for values and expected values.
-        */
-       public static void synchronize(ParentContextAware parent) {
-               Map<String, Object> expectedValuesCommon = new TreeMap<String, Object>(
-                               parent.getExpectedValues());
-               synchronize(parent, expectedValuesCommon);
-               if (log.isDebugEnabled())
-                       log.debug("Synchronized context " + parent);
-
-       }
-
-       private static void synchronize(ParentContextAware parent,
-                       Map<String, Object> expectedValuesCommon) {
-               for (ContextAware child : parent.getChildContexts()) {
-                       // Values
-                       putNotContained(parent.getValues(), child.getValues());
-                       child.setValues(parent.getValues());
-
-                       // Expected Values
-                       // Expected values reference is not overridden: each child has its
-                       // own expected values map.
-                       overrideContained(expectedValuesCommon, child.getExpectedValues());
-
-                       // Creates a new Map in order not to disturb other context using the
-                       // same keys
-                       Map<String, Object> expectedValuesCommonChild = new TreeMap<String, Object>(
-                                       expectedValuesCommon);
-                       putNotContained(expectedValuesCommonChild,
-                                       child.getExpectedValues());
-
-                       if (child instanceof ParentContextAware) {
-                               // Recursive sync
-                               synchronize((ParentContextAware) child,
-                                               expectedValuesCommonChild);
-                       }
-               }
-
-       }
-
-       /**
-        * Put into common map the values from child map which are not already
-        * defined in common map.
-        */
-       public static void putNotContained(Map<String, Object> commonMap,
-                       Map<String, Object> childMap) {
-               for (String key : childMap.keySet()) {
-                       if (!commonMap.containsKey(key)) {
-                               commonMap.put(key, childMap.get(key));
-                       }
-               }
-       }
-
-       /** Overrides child map values with the values already set in common map */
-       public static void overrideContained(Map<String, Object> commonMap,
-                       Map<String, Object> childMap) {
-               for (String key : childMap.keySet()) {
-                       if (commonMap.containsKey(key)) {
-                               childMap.put(key, commonMap.get(key));
-                       }
-               }
-       }
-
-       /** Makes sure this cannot be instantiated. */
-       private ContextUtils() {
-
-       }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleResultPart.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleResultPart.java
deleted file mode 100644 (file)
index 7ba7464..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-package org.argeo.slc.runtime.test;
-
-import java.io.Serializable;
-
-import org.argeo.slc.test.TestResultPart;
-import org.argeo.slc.test.TestRun;
-import org.argeo.slc.test.TestRunAware;
-import org.argeo.slc.test.TestStatus;
-
-/**
- * <p>
- * Basic implementation of a result part, implementing the standard three status
- * approach for test results.
- * </p>
- * 
- * @see TestStatus
- */
-public class SimpleResultPart implements TestResultPart, TestStatus,
-               TestRunAware, Serializable {
-       private static final long serialVersionUID = 6669675957685071901L;
-
-       private Long tid;
-
-       private String testRunUuid;
-
-       /** The status. Default to ERROR since it should always be explicitely set. */
-       private Integer status = ERROR;
-       private String message;
-       private String exceptionMessage;
-
-       public SimpleResultPart() {
-       }
-
-       public SimpleResultPart(Integer status, String message) {
-               this(status, message, null);
-       }
-
-       public SimpleResultPart(Integer status, String message, Exception exception) {
-               this.status = status;
-               this.message = message;
-               setException(exception);
-       }
-
-       public String getMessage() {
-               return message;
-       }
-
-       public void setMessage(String message) {
-               this.message = message;
-       }
-
-       public void setStatus(Integer status) {
-               this.status = status;
-       }
-
-       public Integer getStatus() {
-               return status;
-       }
-
-       public String getExceptionMessage() {
-               return exceptionMessage;
-       }
-
-       public void setException(Exception exception) {
-               if (exception == null)
-                       return;
-
-               StringBuffer buf = new StringBuffer("");
-               buf.append(exception.toString());
-               buf.append('\n');
-               for (StackTraceElement elem : exception.getStackTrace()) {
-                       buf.append('\t').append(elem.toString()).append('\n');
-               }
-
-               if (exception.getCause() != null)
-                       addRootCause(buf, exception.getCause());
-
-               this.exceptionMessage = buf.toString();
-       }
-
-       protected void addRootCause(StringBuffer buf, Throwable cause) {
-               if (cause == null)
-                       return;
-
-               buf.append("Caused by: " + cause.getMessage());
-               for (StackTraceElement elem : cause.getStackTrace()) {
-                       buf.append('\t').append(elem.toString()).append('\n');
-               }
-
-               if (cause.getCause() != null) {
-                       addRootCause(buf, cause.getCause());
-               }
-       }
-
-       @Override
-       public String toString() {
-               StringBuffer buf = new StringBuffer("");
-               buf.append(SlcTestUtils.statusToString(status));
-               if (status == PASSED || status == FAILED) {
-                       buf.append(' ');
-               } else if (status == ERROR) {
-                       buf.append("  ");
-               }
-               buf.append(message);
-               return buf.toString();
-       }
-
-       /** @deprecated */
-       Long getTid() {
-               return tid;
-       }
-
-       /** @deprecated */
-       void setTid(Long tid) {
-               this.tid = tid;
-       }
-
-       public String getTestRunUuid() {
-               return testRunUuid;
-       }
-
-       /** For ORM */
-       public void setTestRunUuid(String testRunUuid) {
-               this.testRunUuid = testRunUuid;
-       }
-
-       public void notifyTestRun(TestRun testRun) {
-               testRunUuid = testRun.getUuid();
-       }
-
-       public void setExceptionMessage(String exceptionMessage) {
-               this.exceptionMessage = exceptionMessage;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestResult.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestResult.java
deleted file mode 100644 (file)
index 3791a7e..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.argeo.slc.runtime.test;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.UUID;
-import java.util.Vector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.test.TestResult;
-import org.argeo.slc.test.TestResultPart;
-import org.argeo.slc.test.TestRun;
-
-/**
- * Basic implementation of a test result containing only a list of result parts.
- */
-public class SimpleTestResult implements TestResult {
-       private static Log log = LogFactory.getLog(SimpleTestResult.class);
-
-       private String uuid;
-       private String currentTestRunUuid;
-
-       private Boolean throwError = true;
-
-       private Date closeDate;
-       private List<TestResultPart> parts = new Vector<TestResultPart>();
-
-       private Map<String, String> attributes = new TreeMap<String, String>();
-
-       public void addResultPart(TestResultPart part) {
-               if (throwError && part.getStatus() == ERROR) {
-                       throw new SlcException(
-                                       "There was an error in the underlying test: "
-                                                       + part.getExceptionMessage());
-               }
-               parts.add(part);
-               if (log.isDebugEnabled())
-                       log.debug(part);
-       }
-
-       public void close() {
-               parts.clear();
-               closeDate = new Date();
-       }
-
-       public List<TestResultPart> getParts() {
-               return parts;
-       }
-
-       public Date getCloseDate() {
-               return closeDate;
-       }
-
-       public void setThrowError(Boolean throwError) {
-               this.throwError = throwError;
-       }
-
-       public void notifyTestRun(TestRun testRun) {
-               currentTestRunUuid = testRun.getUuid();
-       }
-
-       public String getUuid() {
-               if (uuid == null) {
-                       uuid = UUID.randomUUID().toString();
-               }
-               return uuid;
-       }
-
-       public void setUuid(String uuid) {
-               this.uuid = uuid;
-       }
-
-       public String getCurrentTestRunUuid() {
-               return currentTestRunUuid;
-       }
-
-       public Map<String, String> getAttributes() {
-               return attributes;
-       }
-
-       public void setAttributes(Map<String, String> attributes) {
-               this.attributes = attributes;
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestRun.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestRun.java
deleted file mode 100644 (file)
index bc01452..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.argeo.slc.runtime.test;
-
-import java.util.UUID;
-
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.test.ExecutableTestRun;
-import org.argeo.slc.test.TestData;
-import org.argeo.slc.test.TestDefinition;
-import org.argeo.slc.test.TestResult;
-import org.argeo.slc.test.WritableTestRun;
-
-/**
- * A basic bean implementation of a <code>WritableTestRun</code>, holding
- * references to the various parts of a test run.
- */
-public class SimpleTestRun implements WritableTestRun, ExecutableTestRun {
-       private String uuid;
-
-       // private String slcExecutionUuid;
-       // private String slcExecutionStepUuid;
-
-       private DeployedSystem deployedSystem;
-       private TestData testData;
-       private TestDefinition testDefinition;
-       private TestResult testResult;
-
-       /** Executes the underlying test definition. */
-       public void run() {
-               uuid = UUID.randomUUID().toString();
-               if (testResult != null)
-                       testResult.notifyTestRun(this);
-
-               testDefinition.execute(this);
-       }
-
-       @SuppressWarnings("unchecked")
-       public <T extends DeployedSystem> T getDeployedSystem() {
-               return (T) deployedSystem;
-       }
-
-       public void setDeployedSystem(DeployedSystem deployedSystem) {
-               this.deployedSystem = deployedSystem;
-       }
-
-       @SuppressWarnings("unchecked")
-       public <T extends TestData> T getTestData() {
-               return (T) testData;
-       }
-
-       public void setTestData(TestData testData) {
-               this.testData = testData;
-       }
-
-       @SuppressWarnings("unchecked")
-       public <T extends TestDefinition> T getTestDefinition() {
-               return (T) testDefinition;
-       }
-
-       public void setTestDefinition(TestDefinition testDefinition) {
-               this.testDefinition = testDefinition;
-       }
-
-       @SuppressWarnings("unchecked")
-       public <T extends TestResult> T getTestResult() {
-               return (T) testResult;
-       }
-
-       public void setTestResult(TestResult testResult) {
-               this.testResult = testResult;
-       }
-
-       public String getUuid() {
-               return uuid;
-       }
-
-       public void setUuid(String uuid) {
-               this.uuid = uuid;
-       }
-
-       // public String getSlcExecutionUuid() {
-       // return slcExecutionUuid;
-       // }
-       //
-       // public void setSlcExecutionUuid(String slcExecutionUuid) {
-       // this.slcExecutionUuid = slcExecutionUuid;
-       // }
-       //
-       // public String getSlcExecutionStepUuid() {
-       // return slcExecutionStepUuid;
-       // }
-       //
-       // public void setSlcExecutionStepUuid(String slcExecutionStepUuid) {
-       // this.slcExecutionStepUuid = slcExecutionStepUuid;
-       // }
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SlcTestUtils.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SlcTestUtils.java
deleted file mode 100644 (file)
index 5275d0f..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.argeo.slc.runtime.test;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.test.TestStatus;
-
-public abstract class SlcTestUtils {
-       public static String statusToString(Integer status) {
-               if (status.equals(TestStatus.PASSED)) {
-                       return TestStatus.STATUSSTR_PASSED;
-               } else if (status.equals(TestStatus.FAILED)) {
-                       return TestStatus.STATUSSTR_FAILED;
-               } else if (status.equals(TestStatus.ERROR)) {
-                       return TestStatus.STATUSSTR_ERROR;
-               } else {
-                       throw new SlcException("Unrecognized status " + status);
-               }
-       }
-
-       public static Integer stringToStatus(String statusStr) {
-               if (statusStr.equals(TestStatus.STATUSSTR_PASSED)) {
-                       return TestStatus.PASSED;
-               } else if (statusStr.equals(TestStatus.STATUSSTR_FAILED)) {
-                       return TestStatus.FAILED;
-               } else if (statusStr.equals(TestStatus.STATUSSTR_ERROR)) {
-                       return TestStatus.ERROR;
-               } else {
-                       throw new SlcException("Unrecognized status string " + statusStr);
-               }
-       }
-
-       private SlcTestUtils() {
-
-       }
-
-}
diff --git a/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java b/cms/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java
deleted file mode 100644 (file)
index 872f1a5..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.argeo.slc.runtime.test;
-
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.test.TestData;
-import org.argeo.slc.test.TestDataProvider;
-
-/** Utilities for dealing with test datas. */
-public class TestDataUtils {
-       /** Extracts the test data from the given provider. */
-       public static <T extends TestData> T getFromProvider(Object obj,
-                       Class<T> clss, String key) {
-               if (obj instanceof TestDataProvider) {
-                       TestDataProvider testDataProvider = (TestDataProvider) obj;
-                       return testDataProvider.getTestData(clss, key);
-               } else {
-                       throw new UnsupportedException("test data provider", obj);
-               }
-       }
-
-       /**
-        * Extracts the test data from the given provider using <code>null</code>
-        * as key.
-        */
-       public static <T extends TestData> T getFromProvider(Object obj,
-                       Class<T> clss) {
-               return getFromProvider(obj, clss, null);
-       }
-
-       /**
-        * Returns it self after making the proper checks. Used for test data being
-        * their own data providers.
-        */
-       @SuppressWarnings("unchecked")
-       public static <T extends TestData> T getItSelf(Class<T> clss,
-                       TestData testDataObject) {
-               if (clss.isAssignableFrom(testDataObject.getClass())) {
-                       return (T) testDataObject;
-               } else {
-                       throw new UnsupportedException("test data", testDataObject);
-               }
-
-       }
-
-       /** Makes sure this is an utility class. */
-       private TestDataUtils() {
-
-       }
-}
diff --git a/cms/org.argeo.slc.server.repo/.gitignore b/cms/org.argeo.slc.server.repo/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/cms/org.argeo.slc.server.repo/.project b/cms/org.argeo.slc.server.repo/.project
deleted file mode 100644 (file)
index 8cec3fd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.server.repo</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <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>
-       </natures>
-</projectDescription>
diff --git a/cms/org.argeo.slc.server.repo/.settings/org.eclipse.pde.core.prefs b/cms/org.argeo.slc.server.repo/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644 (file)
index b3540fa..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#Sun Feb 06 14:17:19 CET 2011
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
diff --git a/cms/org.argeo.slc.server.repo/META-INF/.gitignore b/cms/org.argeo.slc.server.repo/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.server.repo/META-INF/spring/jcr.xml b/cms/org.argeo.slc.server.repo/META-INF/spring/jcr.xml
deleted file mode 100644 (file)
index 423779b..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <!-- JCR repositories -->\r
-       <!-- <bean id="javaRepository" parent="template.jcrRepository"> -->\r
-       <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/java" \r
-               /> -->\r
-       <!-- <property name="configuration" value="${slc.repo.jcr.configuration.java}" \r
-               /> -->\r
-       <!-- </bean> -->\r
-       <!-- <bean id="distRepository" parent="template.jcrRepository"> -->\r
-       <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/dist" \r
-               /> -->\r
-       <!-- <property name="configuration" value="${slc.repo.jcr.configuration.dist}" \r
-               /> -->\r
-       <!-- </bean> -->\r
-       <!-- <bean id="rpmRepository" parent="template.jcrRepository"> -->\r
-       <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/rpm" \r
-               /> -->\r
-       <!-- <property name="configuration" value="${slc.repo.jcr.configuration.rpm}" \r
-               /> -->\r
-       <!-- </bean> -->\r
-       <!-- <bean id="docsRepository" parent="template.jcrRepository"> -->\r
-       <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/docs" \r
-               /> -->\r
-       <!-- <property name="configuration" value="${slc.repo.jcr.configuration.docs}" \r
-               /> -->\r
-       <!-- </bean> -->\r
-\r
-       <!-- JCR authorizations -->\r
-       <bean parent="template.jcrAuthorizations">\r
-               <property name="repository" ref="javaRepository" />\r
-       </bean>\r
-       <bean parent="template.jcrAuthorizations">\r
-               <property name="repository" ref="distRepository" />\r
-       </bean>\r
-       <bean parent="template.jcrAuthorizations">\r
-               <property name="repository" ref="rpmRepository" />\r
-       </bean>\r
-       <bean parent="template.jcrAuthorizations">\r
-               <property name="repository" ref="docsRepository" />\r
-       </bean>\r
-\r
-       <!-- Templates -->\r
-       <!-- <bean id="template.jcrRepository" abstract="true" -->\r
-       <!-- class="org.argeo.jackrabbit.JackrabbitContainer" init-method="init" -->\r
-       <!-- destroy-method="destroy"> -->\r
-       <!-- <property name="variables" value="osgibundle:/repo.properties" /> -->\r
-       <!-- <property name="cndFiles"> -->\r
-       <!-- <list> -->\r
-       <!-- <value>/org/argeo/jcr/argeo.cnd</value> -->\r
-       <!-- <value>/org/argeo/slc/jcr/slc.cnd</value> -->\r
-       <!-- <value>/org/argeo/slc/repo/repo.cnd</value> -->\r
-       <!-- </list> -->\r
-       <!-- </property> -->\r
-       <!-- <property name="bundleContext" ref="bundleContext" /> -->\r
-       <!-- <property name="forceCndImport" value="${slc.repo.jcr.forceCndImport}" \r
-               /> -->\r
-       <!-- </bean> -->\r
-\r
-       <bean id="template.jcrAuthorizations" abstract="true"\r
-               class="org.argeo.jcr.JcrAuthorizations" init-method="run">\r
-               <property name="principalPrivileges">\r
-                       <map>\r
-                               <entry key="jcr:all" value="cn=org.argeo.slc.user,ou=roles,ou=node" />\r
-                       </map>\r
-               </property>\r
-               <property name="workspace" value="*" />\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.server.repo/META-INF/spring/repo-osgi.xml b/cms/org.argeo.slc.server.repo/META-INF/spring/repo-osgi.xml
deleted file mode 100644 (file)
index 830303c..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xmlns:security="http://www.springframework.org/schema/security"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd">\r
-\r
-       <!-- REFERENCES -->\r
-       <reference id="userAdmin" interface="org.osgi.service.useradmin.UserAdmin" />\r
-       <reference id="userTransaction" interface="javax.transaction.UserTransaction" />\r
-\r
-       <set id="defaultRpmRepositories" cardinality="0..N"\r
-               interface="org.argeo.slc.rpmfactory.RpmRepository" />\r
-\r
-       <reference id="javaRepository" interface="javax.jcr.Repository"\r
-               filter="(cn=java)" />\r
-       <reference id="distRepository" interface="javax.jcr.Repository"\r
-               filter="(cn=dist)" />\r
-       <reference id="rpmRepository" interface="javax.jcr.Repository"\r
-               filter="(cn=rpm)" />\r
-       <reference id="docsRepository" interface="javax.jcr.Repository"\r
-               filter="(cn=docs)" />\r
-\r
-       <!-- SERVICES -->\r
-       <service ref="slcRepoManager" interface="org.argeo.slc.repo.SlcRepoManager" />\r
-\r
-<!--   <service ref="mavenProxyService" interface="org.argeo.slc.repo.MavenProxyService" /> -->\r
-<!--   <service ref="rpmProxyService" interface="org.argeo.slc.rpmfactory.RpmProxyService" /> -->\r
-\r
-       <!-- LABEL -->\r
-       <beans:bean class="org.argeo.cms.spring.osgi.OsgiModuleLabel">\r
-               <beans:property name="bundleContext" ref="bundleContext" />\r
-       </beans:bean>\r
-\r
-       <!-- ROLES -->\r
-       <beans:bean id="ROLE_SLC"\r
-               class="org.argeo.cms.spring.SimpleRoleRegistration" init-method="run">\r
-               <beans:property name="role" value="org.argeo.slc.user" />\r
-               <beans:property name="userAdmin" ref="userAdmin" />\r
-               <beans:property name="userTransaction" ref="userTransaction" />\r
-       </beans:bean>\r
-\r
-       <beans:bean\r
-               class="org.argeo.cms.spring.AuthenticatedApplicationContextInitialization">\r
-       </beans:bean>\r
-</beans:beans>\r
-\r
-<!-- <reference id="mavenRepositorySystem" interface="org.sonatype.aether.RepositorySystem" -->\r
-<!-- filter="(aether.repositorySystemType=maven)" /> -->\r
-<!-- <reference id="mavenRepositorySystemSession" interface="org.sonatype.aether.RepositorySystemSession" -->\r
-<!-- filter="(aether.repositorySystemType=maven)" /> -->\r
-\r
diff --git a/cms/org.argeo.slc.server.repo/META-INF/spring/services.xml b/cms/org.argeo.slc.server.repo/META-INF/spring/services.xml
deleted file mode 100644 (file)
index 454009e..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:util="http://www.springframework.org/schema/util"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
-       ">
-
-       <bean
-               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
-               <property name="locations">
-                       <value>osgibundle:repo.properties</value>
-               </property>
-       </bean>
-
-       <bean id="slcRepoManager" class="org.argeo.slc.repo.core.SlcRepoManagerImpl"
-               init-method="init" destroy-method="destroy">
-               <property name="javaRepoManager" ref="javaRepoManager" />
-       </bean>
-
-       <!-- Java -->
-       <bean id="javaRepoManager" class="org.argeo.slc.repo.core.JavaRepoManagerImpl"
-               init-method="init" destroy-method="destroy" depends-on="ROLE_SLC">
-               <property name="nodeIndexers">
-                       <list>
-                               <bean class="org.argeo.slc.repo.ModularDistributionIndexer" />
-                               <bean class="org.argeo.slc.repo.JarFileIndexer" />
-                               <bean class="org.argeo.slc.repo.ArtifactIndexer" />
-                               <bean class="org.argeo.slc.repo.PdeSourcesIndexer" />
-                       </list>
-               </property>
-               <property name="jcrRepository" ref="javaRepository" />
-       </bean>
-
-       <!-- <bean id="mavenProxyService" class="org.argeo.slc.repo.maven.MavenProxyServiceImpl" -->
-       <!-- init-method="init" destroy-method="destroy" depends-on="ROLE_SLC"> -->
-       <!-- <property name="jcrRepository" ref="javaRepository" /> -->
-       <!-- <property name="proxyWorkspace" value="${slc.repo.jcr.proxyWorkspace}" 
-               /> -->
-       <!-- <property name="defaultRepositories" ref="defaultMavenRepositories" 
-               /> -->
-       <!-- </bean> -->
-
-       <!-- RPM -->
-       <bean id="rpmRepoManager" class="org.argeo.slc.repo.core.RpmRepoManagerImpl"
-               init-method="init" destroy-method="destroy" depends-on="ROLE_SLC">
-               <property name="nodeIndexers">
-                       <list>
-                               <bean class="org.argeo.slc.repo.RpmIndexer" />
-                       </list>
-               </property>
-               <property name="jcrRepository" ref="rpmRepository" />
-       </bean>
-
-       <!-- <bean id="rpmProxyService" class="org.argeo.slc.rpmfactory.core.RpmProxyServiceImpl" -->
-       <!-- init-method="init" destroy-method="destroy" depends-on="ROLE_SLC"> -->
-       <!-- <property name="jcrRepository" ref="rpmRepository" /> -->
-       <!-- <property name="proxyWorkspace" value="${slc.repo.jcr.proxyWorkspace}" 
-               /> -->
-       <!-- <property name="defaultRepositories" ref="defaultRpmRepositories" /> -->
-       <!-- </bean> -->
-
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.server.repo/bnd.bnd b/cms/org.argeo.slc.server.repo/bnd.bnd
deleted file mode 100644 (file)
index 45f2f02..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-Import-Package: org.argeo.jcr,\
-org.argeo.security.jackrabbit,\
-org.argeo.slc.jcr,\
-org.argeo.slc.repo,\
-org.h2;resolution:=optional,\
-org.postgresql;resolution:=optional,\
-org.osgi.*;version=0.0.0,\
-*
diff --git a/cms/org.argeo.slc.server.repo/build.properties b/cms/org.argeo.slc.server.repo/build.properties
deleted file mode 100644 (file)
index ba1e43a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-bin.includes = META-INF/,\
-               repo.properties,\
-               repository-h2.xml
diff --git a/cms/org.argeo.slc.server.repo/pom.xml b/cms/org.argeo.slc.server.repo/pom.xml
deleted file mode 100644 (file)
index 5d95bd5..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.server.repo</artifactId>
-       <name>SLC Repo</name>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.server.repo/repo.properties b/cms/org.argeo.slc.server.repo/repo.properties
deleted file mode 100644 (file)
index 8c10e86..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-slc.repo.jcr.reposBase=${osgi.instance.area}/repos
-slc.repo.jcr.forceCndImport=true
-slc.repo.jcr.proxyWorkspace=proxy
-
-slc.repo.jcr.configuration.java=osgibundle:repository-localfs.xml
-slc.repo.jcr.configuration.dist=osgibundle:repository-localfs.xml
-slc.repo.jcr.configuration.rpm=osgibundle:repository-localfs.xml
-slc.repo.jcr.configuration.docs=osgibundle:repository-localfs.xml
-argeo.node.repo.defaultWorkspace=main
-argeo.node.repo.bundleCacheMB=8
-argeo.node.repo.extractorPoolSize=0
-argeo.node.repo.searchCacheSize=1000
-argeo.node.repo.maxVolatileIndexSize=1048576
-
-slc.repo.jcr.dbuser=sa
-slc.repo.jcr.dbpassword=
-slc.repo.jcr.maxPoolSize=10
-
-# Postgres
-slc.repo.jcr.dburl.java=jdbc:postgresql://localhost/slc_repo_java
-slc.repo.jcr.dburl.dist=jdbc:postgresql://localhost/slc_repo_dist
-slc.repo.jcr.dburl.rpm=jdbc:postgresql://localhost/slc_repo_rpm
-slc.repo.jcr.dburl.docs=jdbc:postgresql://localhost/slc_repo_docs
diff --git a/cms/org.argeo.slc.spring/.classpath b/cms/org.argeo.slc.spring/.classpath
deleted file mode 100644 (file)
index 70b08e8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" output="target/classes" path="src"/>
-       <classpathentry kind="src" path="ext/test"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/cms/org.argeo.slc.spring/.gitignore b/cms/org.argeo.slc.spring/.gitignore
deleted file mode 100644 (file)
index 09e3bc9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/bin/
-/target/
diff --git a/cms/org.argeo.slc.spring/.project b/cms/org.argeo.slc.spring/.project
deleted file mode 100644 (file)
index c45aff2..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.spring</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.jdt.core.javanature</nature>
-               <nature>org.eclipse.pde.PluginNature</nature>
-       </natures>
-</projectDescription>
diff --git a/cms/org.argeo.slc.spring/META-INF/.gitignore b/cms/org.argeo.slc.spring/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.spring/META-INF/spring.handlers b/cms/org.argeo.slc.spring/META-INF/spring.handlers
deleted file mode 100644 (file)
index 417a952..0000000
+++ /dev/null
@@ -1 +0,0 @@
-http\://www.argeo.org/schema/slc-flow=org.argeo.slc.core.execution.xml.FlowNamespaceHandler
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/META-INF/spring.schemas b/cms/org.argeo.slc.spring/META-INF/spring.schemas
deleted file mode 100644 (file)
index 229d4c5..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-http\://www.argeo.org/schema/slc-flow.xsd=org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd
-http\://www.argeo.org/schema/slc-flow-1.2.xsd=org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd
-http\://www.argeo.org/schema/slc-flow-0.12.xsd=org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd
diff --git a/cms/org.argeo.slc.spring/bnd.bnd b/cms/org.argeo.slc.spring/bnd.bnd
deleted file mode 100644 (file)
index 682a5ea..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-Import-Package: javax.jcr.nodetype,\
-javax.jcr.security,\
-org.argeo.api,\
-aQute.bnd.osgi,\
-org.apache.tools.ant.*;resolution:="optional",\
-junit.framework;resolution:="optional",\
-org.osgi.*;version=0.0.0,\
-*
-
-Export-Package: org.argeo.slc.core.test,\
-*
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/build.properties b/cms/org.argeo.slc.spring/build.properties
deleted file mode 100644 (file)
index 25c77f2..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-additional.bundles = org.springframework.context,\
-                     org.slf4j.api,\
-                     org.slf4j.commons.logging,\
-                     org.slf4j.log4j12,\
-                     org.apache.log4j,\
-                     org.springframework.aop,\
-                     org.springframework.aspects,\
-                     org.springframework.beans,\
-                     org.springframework.context.support,\
-                     org.springframework.core,\
-                     org.springframework.expression,\
-                     org.springframework.instrument,\
-                     org.aopalliance
-bin.includes = META-INF/,.
-source.. = src/,\
-           ext/test/
diff --git a/cms/org.argeo.slc.spring/ext/test/log4j.properties b/cms/org.argeo.slc.spring/ext/test/log4j.properties
deleted file mode 100644 (file)
index 0133bab..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# Set root logger level to DEBUG and its only appender to A1.\r
-log4j.rootLogger=WARN, console\r
-\r
-## Levels\r
-# Slc\r
-log4j.logger.org.argeo=DEBUG\r
-\r
-# Castor\r
-log4j.logger.org.exolab.castor=WARN\r
-\r
-# Spring\r
-log4j.logger.org.springframework=WARN\r
-\r
-\r
-## Appenders\r
-# A1 is set to be a ConsoleAppender.\r
-log4j.appender.console=org.apache.log4j.ConsoleAppender\r
-\r
-# A1 uses PatternLayout.\r
-log4j.appender.console.layout=org.apache.log4j.PatternLayout\r
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n\r
-\r
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/DefaultResourceSetTest.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/DefaultResourceSetTest.java
deleted file mode 100644 (file)
index e433d66..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.argeo.slc.core.deploy;
-
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.core.test.context.AbstractInternalSpringTestCase;
-import org.springframework.core.io.Resource;
-
-public class DefaultResourceSetTest extends AbstractInternalSpringTestCase {
-       private final static Log log = LogFactory
-                       .getLog(DefaultResourceSetTest.class);
-
-       public void testListResources() {
-               DefaultResourceSet rrs = getBean("relativeResourceSet");
-               Map<String, Resource> res = rrs.listResources();
-               for (String relativePath : res.keySet())
-                       log.debug(relativePath + "=" + res.get(relativePath));
-               assertEquals(2, res.size());
-       }
-
-       @Override
-       protected String getApplicationContextLocation() {
-               return inPackage("relativeResourceSet.xml");
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/file1.txt b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/file1.txt
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/subdir/file2.txt b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/subdir/file2.txt
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/relativeResourceSet.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/relativeResourceSet.xml
deleted file mode 100644 (file)
index 074c205..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <bean id="relativeResourceSet" class="org.argeo.slc.core.deploy.DefaultResourceSet">\r
-               <property name="base" value="classpath:/org/argeo/slc/core/deploy/data" />\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/AbstractExecutionFlowTestCase.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/AbstractExecutionFlowTestCase.java
deleted file mode 100644 (file)
index 3a5e8a7..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.argeo.slc.test.TestResultPart;
-import org.argeo.slc.test.TestStatus;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public abstract class AbstractExecutionFlowTestCase extends TestCase {
-
-       protected final Log log = LogFactory.getLog(getClass());
-
-       protected void logException(Throwable ex) {
-               log.info("Got Exception of class " + ex.getClass().toString()
-                               + " with message '" + ex.getMessage() + "'.");
-       }
-
-       protected void validateTestResult(SimpleTestResult testResult) {
-               validateTestResult(testResult, TestStatus.PASSED);
-       }
-
-       protected void validateTestResult(SimpleTestResult testResult,
-                       int expectedStatus) {
-               for (TestResultPart part : testResult.getParts()) {
-                       if (part.getStatus() != expectedStatus) {
-                               fail("Error found in TestResult: " + part.getMessage());
-                       }
-               }
-       }
-
-       protected ConfigurableApplicationContext createApplicationContext(
-                       String applicationContextSuffix) {
-               ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext(
-                               inPackage(applicationContextSuffix));
-               // applicationContext.start();
-               return applicationContext;
-       }
-
-       protected void configureAndExecuteSlcFlow(String applicationContextSuffix,
-                       String beanName) {
-               ConfigurableApplicationContext applicationContext = createApplicationContext(applicationContextSuffix);
-               ExecutionContext executionContext = (ExecutionContext) applicationContext
-                               .getBean("executionContext");
-               ExecutionFlow executionFlow = (ExecutionFlow) applicationContext
-                               .getBean(beanName);
-               if (executionFlow instanceof DefaultExecutionFlow)
-                       ((DefaultExecutionFlow) executionFlow)
-                                       .setExecutionContext(executionContext);
-               try {
-                       executionContext.beforeFlow(executionFlow);
-                       executionFlow.run();
-               } finally {
-                       executionContext.afterFlow(executionFlow);
-               }
-               applicationContext.close();
-       }
-
-       protected String inPackage(String suffix) {
-               String prefix = getClass().getPackage().getName().replace('.', '/');
-               return prefix + '/' + suffix;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/BasicExecutionFlowTest.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/BasicExecutionFlowTest.java
deleted file mode 100644 (file)
index b79fe44..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.argeo.slc.test.TestStatus;
-import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.context.ConfigurableApplicationContext;
-
-public class BasicExecutionFlowTest extends AbstractExecutionFlowTestCase {
-       // TO TEST
-       // - post-processing for @{} replacement in beans with complex properties
-       // - bean of scope other than execution are not resolved at execution
-
-       // public void testMyTest() throws Exception {
-       // ConfigurableApplicationContext applicationContext =
-       // createApplicationContext("test.xml");
-       // log.info("Start Execution");
-       // ((ExecutionFlow) applicationContext.getBean("flow1")).execute();
-       // applicationContext.close();
-       // }
-
-       public void XXXtestSpecOverriding() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("specOverriding.xml");
-               ((ExecutionFlow) applicationContext.getBean("flow2")).run();
-               SimpleTestResult res = (SimpleTestResult) applicationContext
-                               .getBean("myTestResult");
-               validateTestResult(res);
-       }
-
-       public void testMultipleFlows() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("multipleFlow.xml");
-               ((ExecutionFlow) applicationContext.getBean("flow1")).run();
-               SimpleTestResult res = (SimpleTestResult) applicationContext
-                               .getBean("myTestResult");
-               validateTestResult(res);
-               res.getParts().clear();
-               ((ExecutionFlow) applicationContext.getBean("flow2")).run();
-               validateTestResult(res, TestStatus.FAILED);
-               applicationContext.close();
-       }
-
-       /**
-        * Test placeholder resolution in a context without scope execution or proxy
-        * and with cascading flows (the flow A contains the flow B)
-        * 
-        * @throws Exception
-        */
-       public void testPlaceHolders() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.xml");
-               ((ExecutionFlow) applicationContext.getBean("flowA")).run();
-               validateTestResult((SimpleTestResult) applicationContext
-                               .getBean("myTestResult"));
-               applicationContext.close();
-       }
-
-       /**
-        * Test placeholder resolution in a context without scope execution or proxy
-        * and with cascading flows (the flow A contains the flow B) setting
-        * execution values (should have no effect)
-        * 
-        * @throws Exception
-        */
-       public void testPlaceHoldersWithExecutionValues() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.xml");
-
-               ExecutionContext executionContext = (ExecutionContext) applicationContext
-                               .getBean("executionContext");
-               Map<String, String> executionParameters = new HashMap<String, String>();
-               executionParameters.put("p1", "e1");
-               executionParameters.put("p2", "e2");
-               executionParameters.put("p3", "e3");
-               executionParameters.put("p4", "e4");
-               executionParameters.put("p5", "e5");
-               executionParameters.put("p6", "e6");
-               executionParameters.put("p7", "e7");
-               executionParameters.put("p8", "e8");
-               addVariables(executionContext, executionParameters);
-
-               ((ExecutionFlow) applicationContext.getBean("flowA")).run();
-               validateTestResult((SimpleTestResult) applicationContext
-                               .getBean("myTestResult"));
-               applicationContext.close();
-       }
-
-       public void XXXtestPlaceHoldersExec() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.exec.xml");
-
-               ExecutionContext executionContext = (ExecutionContext) applicationContext
-                               .getBean("executionContext");
-               Map<String, String> executionParameters = new HashMap<String, String>();
-               executionParameters.put("p1", "e1");
-               executionParameters.put("p2", "e2");
-               executionParameters.put("p3", "e3");
-               executionParameters.put("p4", "e4");
-               executionParameters.put("p5", "e5");
-               executionParameters.put("p6", "e6");
-               addVariables(executionContext, executionParameters);
-
-               ((ExecutionFlow) applicationContext.getBean("flowA")).run();
-               validateTestResult((SimpleTestResult) applicationContext
-                               .getBean("myTestResult"));
-               applicationContext.close();
-       }
-
-       public void testCanonicFlowParameters() throws Exception {
-               configureAndExecuteSlcFlow("canonic-001.xml", "canonic.001");
-       }
-
-       public void testCanonicDefaultValues() throws Exception {
-               configureAndExecuteSlcFlow("canonic-002.xml", "canonic.002");
-       }
-
-       public void testCanonicMissingValues() throws Exception {
-               try {
-                       configureAndExecuteSlcFlow("canonic-003.error.xml", "canonic.003");
-                       fail("Parameter not set - should be rejected.");
-               } catch (BeanCreationException e) {
-                       // exception expected
-                       logException(e);
-               }
-       }
-
-       public void testCanonicUnknownParameter() throws Exception {
-               try {
-                       configureAndExecuteSlcFlow("canonic-004.error.xml", "canonic.004");
-                       fail("Unknown parameter set - should be rejected.");
-               } catch (BeanCreationException e) {
-                       // exception expected
-                       logException(e);
-               }
-       }
-
-       public void testListSetMap() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("listSetMap.xml");
-               ExecutionFlow executionFlow = (ExecutionFlow) applicationContext
-                               .getBean("myFlow");
-               executionFlow.run();
-
-               validateTestResult((SimpleTestResult) applicationContext
-                               .getBean("myTestResult"));
-
-               // BasicTestData res = (BasicTestData)
-               // applicationContext.getBean("cascadingComplex.testData");
-               // log.info("res=" + res.getReached().toString());
-
-               applicationContext.close();
-       }
-
-       public void testListSetMapMultipleFlows() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("listSetMapMultipleFlow.xml");
-               ((ExecutionFlow) applicationContext.getBean("flow1")).run();
-               SimpleTestResult res = (SimpleTestResult) applicationContext
-                               .getBean("myTestResult");
-               validateTestResult(res);
-               res.getParts().clear();
-               ((ExecutionFlow) applicationContext.getBean("flow2")).run();
-               validateTestResult(res, TestStatus.FAILED);
-               applicationContext.close();
-       }
-
-       protected void addVariables(ExecutionContext executionContext,
-                       Map<String, String> vars) {
-               for (String key : vars.keySet())
-                       executionContext.setVariable(key, vars.get(key));
-       }
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/DefaultAgentCliTest.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/DefaultAgentCliTest.java
deleted file mode 100644 (file)
index a7d9b8b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.net.URI;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class DefaultAgentCliTest extends TestCase {
-       public void testArgsToUris() {
-               String[] args = { "org.argeo.slc.demo.minimal", "HelloWorld/WithVar",
-                               "--testKey", "555" };
-               List<URI> uris = DefaultAgentCli.asURIs(args);
-               assertEquals(1, uris.size());
-               assertEquals(
-                               "flow:/org.argeo.slc.demo.minimal/HelloWorld/WithVar?testKey=555",
-                               uris.get(0).toString());
-       }
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ExceptionIfInitCalledTwice.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ExceptionIfInitCalledTwice.java
deleted file mode 100644 (file)
index 7ba7c82..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.InitializingBean;
-
-public class ExceptionIfInitCalledTwice implements Runnable, InitializingBean {
-       private final static Log log = LogFactory
-                       .getLog(ExceptionIfInitCalledTwice.class);
-
-       private Boolean calledOnce = false;
-
-       public void run() {
-               log.info(getClass().getSimpleName() + " ran properly");
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               log.info(getClass().getSimpleName() + " init method called");
-
-               if (calledOnce)
-                       throw new SlcException(getClass().getSimpleName()
-                                       + "init method called twice.");
-               else
-                       calledOnce = true;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesSpringTest.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesSpringTest.java
deleted file mode 100644 (file)
index 0d1223a..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-
-public class FileExecutionResourcesSpringTest extends
-               AbstractExecutionFlowTestCase {
-       private String basePath = FileExecutionResources.DEFAULT_EXECUTION_RESOURCES_TMP_PATH;
-
-       public void testSimple() throws Exception {
-               File file = getFile("subdir/writeTo");
-               try {
-                       assertFalse(file.exists());
-                       configureAndExecuteSlcFlow("executionResources.xml",
-                                       "executionResources.simple");
-                       assertTrue(file.exists());
-               } finally {
-                       file.deleteOnExit();
-               }
-       }
-
-       public void testPlaceholderPass() throws Exception {
-               File file = getFile("subdir/60");
-               try {
-                       assertFalse(file.exists());
-                       configureAndExecuteSlcFlow("executionResources.xml",
-                                       "executionResources.placeholderPass");
-                       assertTrue(file.exists());
-               } finally {
-                       file.deleteOnExit();
-               }
-       }
-
-       /**
-        * Test that it generate the wrong file because of issue when using
-        * execution placeholder in contructor-arg
-        */
-       public void testPlaceholderFail() throws Exception {
-               File file = getFile("subdir/@{var}");
-               try {
-                       assertFalse(file.exists());
-                       configureAndExecuteSlcFlow("executionResources.xml",
-                                       "executionResources.placeholderFail");
-                       assertTrue(file.exists());
-               } finally {
-                       file.deleteOnExit();
-               }
-       }
-
-       protected File getFile(String relativePath) {
-               return new File(basePath + File.separator
-                               + relativePath.replace('/', File.separatorChar));
-       }
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesTest.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesTest.java
deleted file mode 100644 (file)
index 63bd58c..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.io.FileUtils;
-import org.argeo.slc.execution.ExecutionContext;
-import org.springframework.core.io.Resource;
-
-public class FileExecutionResourcesTest extends TestCase {
-       public void testGetWritableFile() throws Exception {
-               FileExecutionResources executionResources = new FileExecutionResources();
-               ExecutionContext executionContext = new MapExecutionContext();
-               executionResources.setExecutionContext(executionContext);
-
-               String expected = "TEST";
-               String reached = "";
-               try {
-                       // Resource
-                       Resource resource = executionResources
-                                       .getWritableResource("subdir1/textRes.txt");
-                       assertTrue(resource.getFile().getParentFile().exists());
-                       assertFalse(resource.getFile().exists());
-                       FileUtils.writeStringToFile(resource.getFile(), expected);
-                       reached = FileUtils.readFileToString(resource.getFile());
-                       assertEquals(expected, reached);
-
-                       // File
-                       File file = executionResources.getFile("subdir2/textFile.txt");
-                       assertFalse(file.getParentFile().exists());
-                       assertFalse(file.exists());
-                       FileUtils.writeStringToFile(file, expected);
-                       reached = FileUtils.readFileToString(file);
-                       assertEquals(expected, reached);
-               } finally {
-                       if (executionResources.getBaseDir() != null
-                                       && executionResources.getBaseDir().exists())
-                               FileUtils.deleteDirectory(executionResources.getBaseDir());
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ParameterRefTest.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ParameterRefTest.java
deleted file mode 100644 (file)
index 6b954b9..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.argeo.slc.test.TestStatus;
-import org.springframework.context.ConfigurableApplicationContext;
-
-public class ParameterRefTest extends AbstractExecutionFlowTestCase {
-       public void test001() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("parameterRef.xml");
-               ((ExecutionFlow) applicationContext.getBean("parameterRef.001")).run();
-
-               SimpleTestResult res = (SimpleTestResult) applicationContext
-                               .getBean("parameterRef.testResult");
-               assertEquals(res.getParts().get(0).getStatus(), TestStatus.PASSED);
-               assertEquals(res.getParts().get(1).getStatus(), TestStatus.FAILED);
-
-               applicationContext.close();
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/applicationContext.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/applicationContext.xml
deleted file mode 100644 (file)
index d83c2c1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" /> \r
-\r
-       <bean id="executionModule_1" class="org.argeo.slc.core.execution.SimpleSpringExecutionModule" >\r
-               <property name="executionContext">\r
-                       <ref bean="executionContext" />\r
-               </property>     \r
-               <property name="name" value="dummyname" />\r
-               <property name="version" value="dummyversion" />\r
-       </bean>\r
\r
-       <bean id="main" parent="slcTemplate.simpleFlow">\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="testKey">\r
-                                                       <bean parent="specAttr.primitive" p:value="660" />\r
-                                               </entry>\r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-               <property name="executables">\r
-                       <list>\r
-                               <ref local="echo1" />\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="echo1" parent="task.echo" scope="execution">\r
-               <property name="message"\r
-                       value="From main! @{testKey}" />\r
-               <aop:scoped-proxy />\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-001.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-001.xml
deleted file mode 100644 (file)
index a1c59c9..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="canonic.xml" />\r
-\r
-       <bean id="canonic.001" parent="canonic.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="parameterAtInstantiation" value="1" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-</beans>\r
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-002.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-002.xml
deleted file mode 100644 (file)
index 57f0c8a..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="canonic.xml" />\r
-\r
-       <bean id="canonic.002" parent="canonic.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="parameterAtInstantiation" value="2" />\r
-                               <entry key="displayWithoutControl" value="102" />\r
-                               <entry key="displayWithControl" value="202" />\r
-                               <entry key="hide" value="202" />\r
-                               <entry key="notParameterAtInstantiation" value="202" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-</beans>\r
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-003.error.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-003.error.xml
deleted file mode 100644 (file)
index 6de8810..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="canonic.xml" />\r
-\r
-       <bean id="canonic.003" parent="canonic.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <!-- missing parameter -->\r
-                               <entry key="displayWithoutControl" value="102" />\r
-                               <entry key="displayWithControl" value="202" />\r
-                               <entry key="hide" value="202" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-</beans>\r
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-004.error.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-004.error.xml
deleted file mode 100644 (file)
index 2638ed6..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="canonic.xml" />\r
-\r
-       <bean id="canonic.004" parent="canonic.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="parameterAtInstantiation" value="2" />\r
-                               <entry key="displayWithoutControl" value="102" />\r
-                               <entry key="displayWithControl" value="202" />\r
-                               <entry key="hide" value="202" />\r
-                               <entry key="unknownParameter" value="1" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-</beans>\r
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic.xml
deleted file mode 100644 (file)
index 8d6af0e..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" />\r
-\r
-       <bean id="canonic.spec" parent="slcTemplate.simpleSpec">\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="parameterAtInstantiation">\r
-                                       <bean parent="specAttr.primitive" p:isParameter="true" p:type="integer" />\r
-                               </entry>\r
-                               <entry key="displayWithoutControl">\r
-                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
-                                               p:isFrozen="true" p:type="integer" />\r
-                               </entry>\r
-                               <entry key="displayWithControl">\r
-                                       <bean parent="specAttr.primitive" p:value="200" p:isParameter="true"\r
-                                               p:isFrozen="false" p:type="integer" />\r
-                               </entry>\r
-                               <entry key="hide">\r
-                                       <bean parent="specAttr.primitive" p:value="300" p:isParameter="true"\r
-                                               p:isFrozen="false" p:isHidden="true" p:type="integer" />\r
-                               </entry>                        \r
-                               <entry key="notParameterAtInstantiation">\r
-                                       <bean parent="specAttr.primitive" p:value="400" p:isParameter="false"\r
-                                               p:isFrozen="false" p:isHidden="false" p:type="integer" />\r
-                               </entry>                                                        \r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="canonic.flowTemplate" parent="slcTemplate.simpleFlow"\r
-               abstract="true">\r
-               <constructor-arg ref="canonic.spec" />\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo"\r
-                                       p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}">\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/executionResources.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/executionResources.xml
deleted file mode 100644 (file)
index 654f8b4..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" />\r
-\r
-       <bean id="executionResources.spec" parent="slcTemplate.simpleSpec">\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="var">\r
-                                       <bean parent="specAttr.primitive" p:isParameter="false"\r
-                                               p:type="integer" p:value="60" />\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="executionResources.placeholderPass" parent="slcTemplate.simpleFlow">\r
-               <constructor-arg ref="executionResources.spec" />\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo">\r
-                                       <property name="message" value="DATA" />\r
-                                       <property name="writeTo">\r
-                                               <bean parent="slcTemplate.resourcesFactoryBean" scope="execution">\r
-                                                       <property name="executionResources" ref="executionResources" />\r
-                                                       <property name="relativePath" value="subdir/@{var}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="executionResources.placeholderFail" parent="slcTemplate.simpleFlow">\r
-               <constructor-arg ref="executionResources.spec" />\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo">\r
-                                       <property name="message" value="DATA" />\r
-                                       <property name="writeTo">\r
-                                               <bean factory-bean="executionResources" factory-method="getWritableResource"\r
-                                                       scope="execution">\r
-                                                       <constructor-arg value="subdir/@{var}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="executionResources.simple" parent="slcTemplate.simpleFlow">\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo">\r
-                                       <property name="message" value="DATA" />\r
-                                       <property name="writeTo">\r
-                                               <bean factory-bean="executionResources" factory-method="getWritableResource"\r
-                                                       scope="execution">\r
-                                                       <constructor-arg value="subdir/writeTo" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="executionResources" parent="slcTemplate.fileResources">\r
-               <property name="executionContext" ref="executionContext" />\r
-               <property name="withExecutionSubdirectory" value="false" />\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/imports.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/imports.xml
deleted file mode 100644 (file)
index 7ddb4ea..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-            http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<!-- Copyright (C) 2007-2012 Mathieu Baudier Licensed under the Apache License, 
-       Version 2.0 (the "License"); you may not use this file except in compliance 
-       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
-       Unless required by applicable law or agreed to in writing, software distributed 
-       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
-       OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
-       the specific language governing permissions and limitations under the License. -->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:aop="http://www.springframework.org/schema/aop"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
-       <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />
-       <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />
-
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMap.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMap.xml
deleted file mode 100644 (file)
index 8aaed84..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" /> \r
-\r
-       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
-               <property name="testDefinition" ref="basic.testDef" />\r
-               <property name="testResult" ref="myTestResult"/>\r
-       </bean>         \r
-\r
-       <bean id="myFlow" parent="slcTemplate.simpleFlow">\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="testKey">\r
-                                                       <bean parent="specAttr.primitive" p:value="myValue" />\r
-                                               </entry>\r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-               <property name="executables">\r
-                       <list>\r
-                               <ref local="echo1" />\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="simpleMap.testData" />\r
-                               </bean>                         \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingMap.testData" />\r
-                               </bean>                         \r
-                                               \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="simpleList.testData" />\r
-                               </bean>                         \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingList.testData" />\r
-                               </bean>                         \r
-                                                       \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="simpleSet.testData" />\r
-                               </bean>                         \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingSet.testData" />\r
-                               </bean> \r
-                                                       \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingListMap.testData" />\r
-                               </bean>                         \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingSetMap.testData" />\r
-                               </bean> \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingComplex.testData" />\r
-                               </bean>                                 \r
-       \r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-\r
-       <bean id="simpleMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <map>\r
-                               <entry key="key1" value="myValue_myValue" />\r
-                       </map>\r
-               </property>\r
-               <property name="reached">\r
-                       <map>\r
-                               <entry key="key1" value="@{testKey}_@{testKey}" />\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-       \r
-       <bean id="cascadingMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <map>\r
-                               <entry key="key3">\r
-                                       <map>\r
-                                               <entry key="key2">\r
-                                                       <map>\r
-                                                               <entry key="key1" value="myValue" />\r
-                                                       </map>\r
-                                               </entry>\r
-                                               <entry key="key2bis" value="myValue" />\r
-                                       </map>\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-               <property name="reached">\r
-                       <map>\r
-                               <entry key="key3">\r
-                                       <map>\r
-                                               <entry key="key2">\r
-                                                       <map>\r
-                                                               <entry key="key1" value="@{testKey}" />\r
-                                                       </map>\r
-                                               </entry>\r
-                                               <entry key="key2bis" value="@{testKey}" />\r
-                                       </map>\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean> \r
-       \r
-       <bean id="simpleList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <list>\r
-                               <value>myValue</value>\r
-                               <value>_myValue_</value>\r
-                       </list>\r
-               </property>\r
-               <property name="reached">\r
-                       <list>\r
-                               <value>@{testKey}</value>\r
-                               <value>_@{testKey}_</value>                             \r
-                       </list>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="cascadingList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <list>\r
-                               <list>\r
-                                       <value>myValue</value>\r
-                                       <value>_myValue_</value>\r
-                               </list>\r
-                               <value>myValue</value>\r
-                       </list>\r
-               </property>\r
-               <property name="reached">\r
-                       <list>\r
-                               <list>\r
-                                       <value>@{testKey}</value>\r
-                                       <value>_@{testKey}_</value>\r
-                               </list>\r
-                               <value>@{testKey}</value>\r
-                       </list>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="simpleSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <set>\r
-                               <value>myValue</value>\r
-                               <value>_myValue_</value>\r
-                       </set>\r
-               </property>\r
-               <property name="reached">\r
-                       <set>\r
-                               <value>@{testKey}</value>\r
-                               <value>_@{testKey}_</value>                             \r
-                       </set>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="cascadingSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <set>\r
-                               <set>\r
-                                       <value>myValue</value>\r
-                                       <value>_myValue_</value>\r
-                               </set>\r
-                               <value>myValue</value>\r
-                       </set>\r
-               </property>\r
-               <property name="reached">\r
-                       <set>\r
-                               <set>\r
-                                       <value>@{testKey}</value>\r
-                                       <value>_@{testKey}_</value>\r
-                               </set>\r
-                               <value>@{testKey}</value>\r
-                       </set>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="cascadingListMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <list>\r
-                               <map>\r
-                                       <entry key="key1" value="myValue" />\r
-                               </map>                                          \r
-                       </list>\r
-               </property>\r
-               <property name="reached">\r
-                       <list>\r
-                               <map>\r
-                                       <entry key="key1" value="@{testKey}" />\r
-                               </map>                                  \r
-                       </list>\r
-               </property>\r
-       </bean> \r
-       \r
-       <bean id="cascadingSetMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <set>\r
-                               <map>\r
-                                       <entry key="key1" value="myValue" />\r
-                               </map>                                          \r
-                       </set>\r
-               </property>\r
-               <property name="reached">\r
-                       <set>\r
-                               <map>\r
-                                       <entry key="key1" value="@{testKey}" />\r
-                               </map>                                  \r
-                       </set>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="cascadingComplex.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <set>\r
-                               <map>\r
-                                       <entry key="key1" value="myValue" />\r
-                               </map>  \r
-                               <list>\r
-                                       <map>\r
-                                               <entry key="key1" value="myValue" />\r
-                                       </map>          \r
-                                       <set>\r
-                                               <set>\r
-                                                       <value>myValue</value>\r
-                                                       <value>_myValue_</value>\r
-                                                       <list>\r
-                                                               <list>\r
-                                                                       <value>myValue</value>\r
-                                                                       <value>_myValue_</value>\r
-                                                               </list>\r
-                                                               <value>myValue</value>\r
-                                                       </list>                                                 \r
-                                               </set>\r
-                                               <value>myValue</value>\r
-                                       </set>                                                                  \r
-                               </list> \r
-                               <set>\r
-                                       <map>\r
-                                               <entry key="key1" value="myValue" />\r
-                                       </map>  \r
-                               </set>                                                                                          \r
-                       </set>\r
-               </property>\r
-               <property name="reached">\r
-                       <set>\r
-                               <map>\r
-                                       <entry key="key1" value="@{testKey}" />\r
-                               </map>  \r
-                               <list>\r
-                                       <map>\r
-                                               <entry key="key1" value="@{testKey}" />\r
-                                       </map>          \r
-                                       <set>\r
-                                               <set>\r
-                                                       <value>@{testKey}</value>\r
-                                                       <value>_@{testKey}_</value>\r
-                                                       <list>\r
-                                                               <list>\r
-                                                                       <value>@{testKey}</value>\r
-                                                                       <value>_@{testKey}_</value>\r
-                                                               </list>\r
-                                                               <value>@{testKey}</value>\r
-                                                       </list>                                                 \r
-                                               </set>\r
-                                               <value>@{testKey}</value>\r
-                                       </set>                                                                  \r
-                               </list> \r
-                               <set>\r
-                                       <map>\r
-                                               <entry key="key1" value="@{testKey}" />\r
-                                       </map>  \r
-                               </set>                                                                                          \r
-                       </set>\r
-               </property>\r
-       </bean>                 \r
-       \r
-       <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition">\r
-       </bean> \r
-\r
-\r
-       <bean id="echo1" parent="task.echo" scope="prototype">\r
-               <property name="message"\r
-                       value="testKey=@{testKey}" />\r
-       </bean>\r
-       \r
-       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMapMultipleFlow.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMapMultipleFlow.xml
deleted file mode 100644 (file)
index 94ddd35..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" /> \r
-\r
-       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
-               <property name="testDefinition" ref="basic.testDef" />\r
-               <property name="testResult" ref="myTestResult"/>\r
-       </bean>         \r
-\r
-       <bean id="abstractFlow" parent="slcTemplate.simpleFlow" abstract="true">\r
-               <property name="executables">\r
-                       <list>\r
-                               <ref local="echo1" />\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="simpleMap.testData" />\r
-                               </bean>                         \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingMap.testData" />\r
-                               </bean>                         \r
-                                               \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="simpleList.testData" />\r
-                               </bean>                         \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingList.testData" />\r
-                               </bean>                         \r
-                                                       \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="simpleSet.testData" />\r
-                               </bean>                         \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingSet.testData" />\r
-                               </bean> \r
-                                                       \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingListMap.testData" />\r
-                               </bean>                         \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingSetMap.testData" />\r
-                               </bean> \r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData" ref="cascadingComplex.testData" />\r
-                               </bean>                                 \r
-       \r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="flow1" parent="abstractFlow" scope="prototype">\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="testKey">\r
-                                                       <bean parent="specAttr.primitive" p:value="myValue" />\r
-                                               </entry>\r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-       </bean> \r
-\r
-       <bean id="flow2" parent="abstractFlow" scope="prototype">\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="testKey">\r
-                                                       <bean parent="specAttr.primitive" p:value="myValue2" />\r
-                                               </entry>\r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-       </bean> \r
-\r
-\r
-       <bean id="simpleMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <map>\r
-                               <entry key="key1" value="myValue_myValue" />\r
-                       </map>\r
-               </property>\r
-               <property name="reached">\r
-                       <map>\r
-                               <entry key="key1" value="@{testKey}_@{testKey}" />\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-       \r
-       <bean id="cascadingMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <map>\r
-                               <entry key="key3">\r
-                                       <map>\r
-                                               <entry key="key2">\r
-                                                       <map>\r
-                                                               <entry key="key1" value="myValue" />\r
-                                                       </map>\r
-                                               </entry>\r
-                                               <entry key="key2bis" value="myValue" />\r
-                                       </map>\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-               <property name="reached">\r
-                       <map>\r
-                               <entry key="key3">\r
-                                       <map>\r
-                                               <entry key="key2">\r
-                                                       <map>\r
-                                                               <entry key="key1" value="@{testKey}" />\r
-                                                       </map>\r
-                                               </entry>\r
-                                               <entry key="key2bis" value="@{testKey}" />\r
-                                       </map>\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean> \r
-       \r
-       <bean id="simpleList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <list>\r
-                               <value>myValue</value>\r
-                               <value>_myValue_</value>\r
-                       </list>\r
-               </property>\r
-               <property name="reached">\r
-                       <list>\r
-                               <value>@{testKey}</value>\r
-                               <value>_@{testKey}_</value>                             \r
-                       </list>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="cascadingList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <list>\r
-                               <list>\r
-                                       <value>myValue</value>\r
-                                       <value>_myValue_</value>\r
-                               </list>\r
-                               <value>myValue</value>\r
-                       </list>\r
-               </property>\r
-               <property name="reached">\r
-                       <list>\r
-                               <list>\r
-                                       <value>@{testKey}</value>\r
-                                       <value>_@{testKey}_</value>\r
-                               </list>\r
-                               <value>@{testKey}</value>\r
-                       </list>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="simpleSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <set>\r
-                               <value>myValue</value>\r
-                               <value>_myValue_</value>\r
-                       </set>\r
-               </property>\r
-               <property name="reached">\r
-                       <set>\r
-                               <value>@{testKey}</value>\r
-                               <value>_@{testKey}_</value>                             \r
-                       </set>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="cascadingSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <set>\r
-                               <set>\r
-                                       <value>myValue</value>\r
-                                       <value>_myValue_</value>\r
-                               </set>\r
-                               <value>myValue</value>\r
-                       </set>\r
-               </property>\r
-               <property name="reached">\r
-                       <set>\r
-                               <set>\r
-                                       <value>@{testKey}</value>\r
-                                       <value>_@{testKey}_</value>\r
-                               </set>\r
-                               <value>@{testKey}</value>\r
-                       </set>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="cascadingListMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <list>\r
-                               <map>\r
-                                       <entry key="key1" value="myValue" />\r
-                               </map>                                          \r
-                       </list>\r
-               </property>\r
-               <property name="reached">\r
-                       <list>\r
-                               <map>\r
-                                       <entry key="key1" value="@{testKey}" />\r
-                               </map>                                  \r
-                       </list>\r
-               </property>\r
-       </bean> \r
-       \r
-       <bean id="cascadingSetMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <set>\r
-                               <map>\r
-                                       <entry key="key1" value="myValue" />\r
-                               </map>                                          \r
-                       </set>\r
-               </property>\r
-               <property name="reached">\r
-                       <set>\r
-                               <map>\r
-                                       <entry key="key1" value="@{testKey}" />\r
-                               </map>                                  \r
-                       </set>\r
-               </property>\r
-       </bean>         \r
-       \r
-       <bean id="cascadingComplex.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
-               <property name="expected">\r
-                       <set>\r
-                               <map>\r
-                                       <entry key="key1" value="myValue" />\r
-                               </map>  \r
-                               <list>\r
-                                       <map>\r
-                                               <entry key="key1" value="myValue" />\r
-                                       </map>          \r
-                                       <set>\r
-                                               <set>\r
-                                                       <value>myValue</value>\r
-                                                       <value>_myValue_</value>\r
-                                                       <list>\r
-                                                               <list>\r
-                                                                       <value>myValue</value>\r
-                                                                       <value>_myValue_</value>\r
-                                                               </list>\r
-                                                               <value>myValue</value>\r
-                                                       </list>                                                 \r
-                                               </set>\r
-                                               <value>myValue</value>\r
-                                       </set>                                                                  \r
-                               </list> \r
-                               <set>\r
-                                       <map>\r
-                                               <entry key="key1" value="myValue" />\r
-                                       </map>  \r
-                               </set>                                                                                          \r
-                       </set>\r
-               </property>\r
-               <property name="reached">\r
-                       <set>\r
-                               <map>\r
-                                       <entry key="key1" value="@{testKey}" />\r
-                               </map>  \r
-                               <list>\r
-                                       <map>\r
-                                               <entry key="key1" value="@{testKey}" />\r
-                                       </map>          \r
-                                       <set>\r
-                                               <set>\r
-                                                       <value>@{testKey}</value>\r
-                                                       <value>_@{testKey}_</value>\r
-                                                       <list>\r
-                                                               <list>\r
-                                                                       <value>@{testKey}</value>\r
-                                                                       <value>_@{testKey}_</value>\r
-                                                               </list>\r
-                                                               <value>@{testKey}</value>\r
-                                                       </list>                                                 \r
-                                               </set>\r
-                                               <value>@{testKey}</value>\r
-                                       </set>                                                                  \r
-                               </list> \r
-                               <set>\r
-                                       <map>\r
-                                               <entry key="key1" value="@{testKey}" />\r
-                                       </map>  \r
-                               </set>                                                                                          \r
-                       </set>\r
-               </property>\r
-       </bean>                 \r
-               \r
-       <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition">\r
-       </bean> \r
-\r
-\r
-       <bean id="echo1" parent="task.echo" scope="prototype">\r
-               <property name="message"\r
-                       value="testKey=@{testKey}" />\r
-       </bean>\r
-       \r
-       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/minimal.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/minimal.xml
deleted file mode 100644 (file)
index 5b16697..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" /> \r
-\r
-       <bean id="minimal" parent="slcTemplate.simpleFlow">\r
-               <property name="executionSpec">\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-<!--                           <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="testKey">\r
-                                                       <bean parent="specAttr.primitive" p:value="660" />\r
-                                               </entry>\r
-                                       </map>\r
-                               </property> -->\r
-                       </bean>\r
-               </property>\r
-               <property name="executables">\r
-                       <list>\r
-                               <ref local="echo1" />\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="echo1" parent="task.echo" scope="execution">\r
-               <property name="message"\r
-                       value="From minimal" />\r
-               <aop:scoped-proxy />\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/multipleFlow.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/multipleFlow.xml
deleted file mode 100644 (file)
index 69b3efe..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" /> \r
-\r
-       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
-       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
-               <property name="testDefinition" ref="myTestDef" />\r
-               <property name="testResult" ref="myTestResult"/>\r
-       </bean>         \r
-\r
-       <bean id="fileDiff.spec" parent="slcTemplate.simpleSpec">\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="fileName">\r
-                                       <bean parent="specAttr.primitive" p:isParameter="true" p:type="string"\r
-                                               p:isFrozen="true" />\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-\r
-       <bean id="fileDiff.flowTemplate" parent="slcTemplate.simpleFlow"\r
-               abstract="true">\r
-               <property name="path" value="/fileDiff/testcases" />\r
-               <constructor-arg ref="fileDiff.spec" />\r
-               <property name="executables">\r
-                       <list>                  \r
-                               <bean parent="task.echo">\r
-                                       <property name="message" value="fileName=@{fileName}" />\r
-                               </bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="file1" />\r
-                                                       <property name="reached" value="@{fileName}" />\r
-                                               </bean>\r
-                                       </property>     \r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-       \r
-       <bean id="echo" parent="task.echo" scope="prototype">\r
-               <property name="message" value="fileName=@{fileName}" />\r
-       </bean>                 \r
-       \r
-       <bean id="flow1" parent="fileDiff.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="fileName" value="file1" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean> \r
-\r
-       <bean id="flow2" parent="fileDiff.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="fileName" value="file2" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean> \r
\r
\r
- <!-- \r
-       <bean id="flow1" parent="slcTemplate.simpleFlow">\r
-               <property name="path" value="/fileDiff/testcases" />\r
-               <constructor-arg ref="fileDiff.spec" />\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="fileName" value="file1" />\r
-                       </map>\r
-               </constructor-arg>              \r
-               <property name="executables">\r
-                       <list>                  \r
-                               <bean parent="task.echo" scope="execution">\r
-                                       <property name="message" value="fileName=@{fileName}" />\r
-                                       <aop:scoped-proxy />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="flow2" parent="slcTemplate.simpleFlow">\r
-               <property name="path" value="/fileDiff/testcases" />\r
-               <constructor-arg ref="fileDiff.spec" />\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="fileName" value="file2" />\r
-                       </map>\r
-               </constructor-arg>              \r
-               <property name="executables">\r
-                       <list>                  \r
-                               <bean parent="task.echo" scope="execution">\r
-                                       <property name="message" value="fileName=@{fileName}" />\r
-                                       <aop:scoped-proxy />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
- -->\r
-<!-- \r
-       <bean id="main" parent="slcTemplate.simpleFlow">\r
-               <property name="executables">\r
-                       <list>          \r
-                               <ref bean="flow1"/>     \r
-                               <ref bean="flow2"/>     \r
-                       </list>\r
-               </property>\r
-       </bean>\r
- -->\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/parameterRef.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/parameterRef.xml
deleted file mode 100644 (file)
index e9e389a..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" />\r
-\r
-       <!-- DEFINITIONS -->\r
-       <bean id="parameterRef.spec" parent="slcTemplate.simpleSpec">\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="exceptionIfInitCalledTwice">\r
-                                       <bean parent="specAttr.ref"\r
-                                               p:targetClass="org.argeo.slc.core.execution.ExceptionIfInitCalledTwice"\r
-                                               p:isParameter="true" p:isFrozen="true" />\r
-                               </entry>\r
-                               <entry key="testData1">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:isParameter="true" p:isFrozen="true" />\r
-                               </entry>\r
-                               <entry key="testData2">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:isParameter="true" p:isFrozen="true" />\r
-                               </entry>\r
-                               <entry key="testedComponentId">\r
-                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
-                                               p:type="integer" />\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="parameterRef.flowTemplate" parent="slcTemplate.simpleFlow"\r
-               abstract="true">\r
-               <constructor-arg ref="parameterRef.spec" />\r
-               <property name="executables">\r
-                       <list>\r
-                               <!-- Primitive -->\r
-                               <bean parent="task.echo" scope="execution">\r
-                                       <property name="message" value="testedComponentId=@{testedComponentId}" />\r
-                               </bean>\r
-\r
-                               <!-- Exception if init called twice -->\r
-                               <bean parent="parameterRef">\r
-                                       <constructor-arg value="exceptionIfInitCalledTwice" />\r
-                               </bean>\r
-                               <bean parent="parameterRef">\r
-                                       <property name="name" value="exceptionIfInitCalledTwice" />\r
-                               </bean>\r
-\r
-                               <!-- Basic tests -->\r
-                               <bean parent="parameterRef.testRun">\r
-                                       <property name="testData">\r
-                                               <bean parent="parameterRef">\r
-                                                       <constructor-arg value="testData1" />\r
-                                               </bean>\r
-                                       </property>\r
-                               </bean>\r
-                               <bean parent="parameterRef.testRun">\r
-                                       <property name="testData" ref="ref1" />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <!-- TEST CASES -->\r
-       <bean id="parameterRef.001" parent="parameterRef.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="exceptionIfInitCalledTwice">\r
-                                       <bean class="org.argeo.slc.core.execution.ExceptionIfInitCalledTwice" />\r
-                               </entry>\r
-                               <entry key="testData1">\r
-                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                               <property name="expected" value="toto" />\r
-                                               <property name="reached" value="toto" />\r
-                                       </bean>\r
-                               </entry>\r
-                               <entry key="testData2">\r
-                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                               <property name="expected" value="tata" />\r
-                                               <property name="reached" value="toto" />\r
-                                       </bean>\r
-                               </entry>\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-\r
-       <!-- UTILITIES -->\r
-\r
-       <bean id="ref1" parent="parameterRef">\r
-               <constructor-arg value="testData2" />\r
-       </bean>\r
-\r
-       <bean id="parameterRef.testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-       <bean id="parameterRef.testRun" class="org.argeo.slc.runtime.test.SimpleTestRun"\r
-               abstract="true">\r
-               <property name="testResult" ref="parameterRef.testResult" />\r
-               <property name="testDefinition">\r
-                       <bean class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-               </property>\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.exec.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.exec.xml
deleted file mode 100644 (file)
index 6481d96..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" /> \r
-\r
-       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
-       <bean id="echo1" parent="task.echo">\r
-               <property name="message" value="From minimal" />\r
-       </bean>\r
-\r
-       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
-               <property name="testDefinition" ref="myTestDef" />\r
-               <property name="testResult" ref="myTestResult"/>\r
-       </bean>         \r
-\r
-       <!-- \r
-               The Flow A contains the flow B as executable.\r
-       \r
-               Parameters\r
-               p1: flow A: default - flow B: - \r
-               p2: flow A: set     - flow B: - \r
-               p3: flow A: default - flow B: default \r
-               p4: flow A: set     - flow B: default\r
-               p5: flow A: default - flow B: set \r
-               p6: flow A: set     - flow B: set\r
-               p7: flow A: -       - flow B: default\r
-               p8: flow A: -       - flow B: set\r
-                \r
-               \r
-        -->\r
-\r
-       <bean id="flowA" parent="slcTemplate.simpleFlow">\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="p1"><bean parent="specAttr.primitive" p:value="da1" /></entry>\r
-                                               <entry key="p2"><bean parent="specAttr.primitive" p:value="da2" /></entry>                                              \r
-                                               <entry key="p3"><bean parent="specAttr.primitive" p:value="da3" /></entry>                                              \r
-                                               <entry key="p4"><bean parent="specAttr.primitive" p:value="da4" /></entry>                                              \r
-                                               <entry key="p5"><bean parent="specAttr.primitive" p:value="da5" /></entry>                                              \r
-                                               <entry key="p6"><bean parent="specAttr.primitive" p:value="da6" /></entry>                                              \r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-               <constructor-arg>               \r
-                       <map>\r
-                               <entry key="p2" value="va2"/>\r
-                               <entry key="p4" value="va4"/>\r
-                               <entry key="p6" value="va6"/>\r
-                       </map>\r
-               </constructor-arg>\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da1" />\r
-                                                       <property name="reached" value="@{p1}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>\r
-                               <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va2" />\r
-                                                       <property name="reached" value="@{p2}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da3" />\r
-                                                       <property name="reached" value="@{p3}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va4" />\r
-                                                       <property name="reached" value="@{p4}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                 \r
-                               <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da5" />\r
-                                                       <property name="reached" value="@{p5}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va6" />\r
-                                                       <property name="reached" value="@{p6}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                 \r
-                               <ref bean="flowB"/>                             \r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="flowB" parent="slcTemplate.simpleFlow" scope="prototype">\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="p3"><bean parent="specAttr.primitive" p:value="db3" /></entry>                                              \r
-                                               <entry key="p4"><bean parent="specAttr.primitive" p:value="db4" /></entry>\r
-                                               <entry key="p5"><bean parent="specAttr.primitive" p:value="db5" /></entry>                                              \r
-                                               <entry key="p6"><bean parent="specAttr.primitive" p:value="db6" /></entry>\r
-                                               <entry key="p7"><bean parent="specAttr.primitive" p:value="db7" /></entry>                                              \r
-                                               <entry key="p8"><bean parent="specAttr.primitive" p:value="db8" /></entry>\r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-               <constructor-arg>               \r
-                       <map>\r
-                               <entry key="p3" value="vb3"/>\r
-                               <entry key="p4" value="vb4"/>\r
-                               <entry key="p7" value="vb7"/>\r
-                       </map>\r
-               </constructor-arg>              \r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da1" />\r
-                                                       <property name="reached" value="@{p1}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>\r
-                               <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va2" />\r
-                                                       <property name="reached" value="@{p2}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da3" />\r
-                                                       <property name="reached" value="@{p3}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va4" />\r
-                                                       <property name="reached" value="@{p4}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                 \r
-                               <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da5" />\r
-                                                       <property name="reached" value="@{p5}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va6" />\r
-                                                       <property name="reached" value="@{p6}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p7=@{p7}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="vb7" />\r
-                                                       <property name="reached" value="@{p7}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                                         \r
-                               <bean parent="task.echo"><property name="message" value="p8=@{p8}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="db8" />\r
-                                                       <property name="reached" value="@{p8}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean> \r
-                               \r
-                               <!-- test in scope execution -->\r
-                               <bean parent="task.echo" scope="execution"><property name="message" value="p1=@{p1}" /><aop:scoped-proxy /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                                       <property name="expected" value="e1" />\r
-                                                       <property name="reached" value="@{p1}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>\r
-                               <bean parent="task.echo" scope="execution"><property name="message" value="p2=@{p2}" /><aop:scoped-proxy /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                                       <property name="expected" value="e2" />\r
-                                                       <property name="reached" value="@{p2}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo" scope="execution"><property name="message" value="p3=@{p3}" /><aop:scoped-proxy /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                                       <property name="expected" value="e3" />\r
-                                                       <property name="reached" value="@{p3}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo" scope="execution"><property name="message" value="p4=@{p4}" /><aop:scoped-proxy /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                                       <property name="expected" value="e4" />\r
-                                                       <property name="reached" value="@{p4}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                 \r
-                               <bean parent="task.echo" scope="execution"><property name="message" value="p5=@{p5}" /><aop:scoped-proxy /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                                       <property name="expected" value="e5" />\r
-                                                       <property name="reached" value="@{p5}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo" scope="execution"><property name="message" value="p6=@{p6}" /><aop:scoped-proxy /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                                       <property name="expected" value="e6" />\r
-                                                       <property name="reached" value="@{p6}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>\r
-                                                               \r
-                               <!-- \r
-                                       p7 and p8 are not in the spec of FlowA and therefore can not be overridden\r
-                                       at the execution\r
-                                -->\r
-                               <bean parent="task.echo" scope="execution"><property name="message" value="p7=@{p7}" /><aop:scoped-proxy /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                                       <property name="expected" value="vb7" />\r
-                                                       <property name="reached" value="@{p7}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                                         \r
-                               <bean parent="task.echo" scope="execution"><property name="message" value="p8=@{p8}" /><aop:scoped-proxy /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                                       <property name="expected" value="db8" />\r
-                                                       <property name="reached" value="@{p8}" />\r
-                                                       <aop:scoped-proxy />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>         \r
-                                                                                       \r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.xml
deleted file mode 100644 (file)
index ba72f88..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" /> \r
-\r
-       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
-       <bean id="echo1" parent="task.echo">\r
-               <property name="message" value="From minimal" />\r
-       </bean>\r
-\r
-       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
-               <property name="testDefinition" ref="myTestDef" />\r
-               <property name="testResult" ref="myTestResult"/>\r
-       </bean>         \r
-\r
-       <!-- \r
-               The Flow A contains the flow B as executable.\r
-       \r
-               Parameters\r
-               p1: flow A: default - flow B: - \r
-               p2: flow A: set     - flow B: - \r
-               p3: flow A: default - flow B: default \r
-               p4: flow A: set     - flow B: default\r
-               p5: flow A: default - flow B: set \r
-               p6: flow A: set     - flow B: set\r
-               p7: flow A: -       - flow B: default\r
-               p8: flow A: -       - flow B: set\r
-                \r
-               \r
-        -->\r
-\r
-       <bean id="flowA" parent="slcTemplate.simpleFlow">\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="p1"><bean parent="specAttr.primitive" p:value="da1" /></entry>\r
-                                               <entry key="p2"><bean parent="specAttr.primitive" p:value="da2" /></entry>                                              \r
-                                               <entry key="p3"><bean parent="specAttr.primitive" p:value="da3" /></entry>                                              \r
-                                               <entry key="p4"><bean parent="specAttr.primitive" p:value="da4" /></entry>                                              \r
-                                               <entry key="p5"><bean parent="specAttr.primitive" p:value="da5" /></entry>                                              \r
-                                               <entry key="p6"><bean parent="specAttr.primitive" p:value="da6" /></entry>                                              \r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-               <constructor-arg>               \r
-                       <map>\r
-                               <entry key="p2" value="va2"/>\r
-                               <entry key="p4" value="va4"/>\r
-                               <entry key="p6" value="va6"/>\r
-                       </map>\r
-               </constructor-arg>\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da1" />\r
-                                                       <property name="reached" value="@{p1}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>\r
-                               <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va2" />\r
-                                                       <property name="reached" value="@{p2}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da3" />\r
-                                                       <property name="reached" value="@{p3}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va4" />\r
-                                                       <property name="reached" value="@{p4}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                 \r
-                               <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da5" />\r
-                                                       <property name="reached" value="@{p5}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va6" />\r
-                                                       <property name="reached" value="@{p6}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                 \r
-                               <ref bean="flowB"/>                             \r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="flowB" parent="slcTemplate.simpleFlow" scope="prototype">\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="p3"><bean parent="specAttr.primitive" p:value="db3" /></entry>                                              \r
-                                               <entry key="p4"><bean parent="specAttr.primitive" p:value="db4" /></entry>\r
-                                               <entry key="p5"><bean parent="specAttr.primitive" p:value="db5" /></entry>                                              \r
-                                               <entry key="p6"><bean parent="specAttr.primitive" p:value="db6" /></entry>\r
-                                               <entry key="p7"><bean parent="specAttr.primitive" p:value="db7" /></entry>                                              \r
-                                               <entry key="p8"><bean parent="specAttr.primitive" p:value="db8" /></entry>\r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-               <constructor-arg>               \r
-                       <map>\r
-                               <entry key="p3" value="vb3"/>\r
-                               <entry key="p4" value="vb4"/>\r
-                               <entry key="p7" value="vb7"/>\r
-                       </map>\r
-               </constructor-arg>              \r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da1" />\r
-                                                       <property name="reached" value="@{p1}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>\r
-                               <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va2" />\r
-                                                       <property name="reached" value="@{p2}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da3" />\r
-                                                       <property name="reached" value="@{p3}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va4" />\r
-                                                       <property name="reached" value="@{p4}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                 \r
-                               <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="da5" />\r
-                                                       <property name="reached" value="@{p5}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="va6" />\r
-                                                       <property name="reached" value="@{p6}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                         \r
-                               <bean parent="task.echo"><property name="message" value="p7=@{p7}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="vb7" />\r
-                                                       <property name="reached" value="@{p7}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean>                                                         \r
-                               <bean parent="task.echo"><property name="message" value="p8=@{p8}" /></bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                       <property name="expected" value="db8" />\r
-                                                       <property name="reached" value="@{p8}" />\r
-                                               </bean>\r
-                                       </property>                                     \r
-                               </bean> \r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/specOverriding.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/specOverriding.xml
deleted file mode 100644 (file)
index 7a70f71..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" /> \r
\r
-       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
-       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
-               <property name="testDefinition" ref="myTestDef" />\r
-               <property name="testResult" ref="myTestResult"/>\r
-       </bean>         \r
\r
-       <bean id="spec1" parent="slcTemplate.simpleSpec">\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="testedComponentId">\r
-                                       <bean parent="specAttr.primitive" p:isParameter="true"\r
-                                               p:type="integer" />\r
-                               </entry>\r
-                               <entry key="testData1">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:isParameter="true" p:isFrozen="true" />\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="flowTemplate1" parent="slcTemplate.simpleFlow"\r
-               abstract="true">\r
-               <constructor-arg ref="spec1" />\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo" scope="execution">\r
-                                       <property name="message" value="From basic @{testedComponentId}" />\r
-                                       <aop:scoped-proxy />\r
-                               </bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean parent="parameterRef">\r
-                                                       <constructor-arg value="testData1" />\r
-                                               </bean>\r
-                                       </property>\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="flow1" parent="flowTemplate1" scope="prototype">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="testedComponentId" value="200" />\r
-                               <entry key="testData1">\r
-                                       <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                               <aop:scoped-proxy/>\r
-                                               <property name="expected" value="tata101" />\r
-                                               <property name="reached" value="tata@{testedComponentId}" />\r
-                                       </bean>\r
-                               </entry>\r
-                       </map>                  \r
-               </constructor-arg>\r
-       </bean>\r
-\r
-       <bean id="spec2" parent="slcTemplate.simpleSpec">\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="testData1">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:isParameter="true" p:isFrozen="true" />\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="flowTemplate2" parent="slcTemplate.simpleFlow" abstract="true">\r
-               <constructor-arg ref="spec2" />\r
-               <property name="executables">\r
-                       <list>\r
-                               <ref bean="flow1"/>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-       \r
-       <bean id="flow2" parent="flowTemplate2">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="testData1">\r
-                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                               <property name="expected" value="tata100" />\r
-                                               <property name="reached" value="tata100" />\r
-                                       </bean>\r
-                               </entry>\r
-                       </map>                  \r
-               </constructor-arg>\r
-       </bean> \r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/SystemCallTest.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/SystemCallTest.java
deleted file mode 100644 (file)
index b007b9a..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.core.execution.AbstractExecutionFlowTestCase;
-
-public class SystemCallTest extends AbstractExecutionFlowTestCase {
-       private final static Log log = LogFactory.getLog(SystemCallTest.class);
-
-       private final String defFile = "systemCall.xml";
-
-       public void testSystemCallSimple() throws Exception {
-               if (isOsSupported())
-                       configureAndExecuteSlcFlow(defFile, "systemCallSimple");
-       }
-
-       public void testSystemCallList() throws Exception {
-               if (isOsSupported())
-                       configureAndExecuteSlcFlow(defFile, "systemCallList");
-       }
-
-       public void testSystemCallOsSpecific() throws Exception {
-               if (isOsSupported())
-                       configureAndExecuteSlcFlow(defFile, "systemCallOsSpecific");
-       }
-
-       public void testSystemCallWithVar() throws Exception {
-               if (isOsSupported())
-                       configureAndExecuteSlcFlow(defFile, "systemCallWithVar");
-       }
-
-       protected boolean isOsSupported() {
-               String osName = System.getProperty("os.name");
-               final Boolean ret;
-               if (osName.contains("Windows"))
-                       ret = false;
-               else
-                       ret = true;
-
-               if (ret == false)
-                       log.warn("Skip test because OS '" + osName + "' is not supported.");
-               return ret;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/systemCall.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/systemCall.xml
deleted file mode 100644 (file)
index 8d35650..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="../imports.xml" />\r
-\r
-       <bean id="systemCallSimple" parent="slcTemplate.simpleFlow">\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo">\r
-                                       <property name="message" value="os.name=${os.name}" />\r
-                               </bean>\r
-                               <bean parent="task.systemCall">\r
-                                       <property name="cmd" value="echo Hello World" />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="systemCallList" parent="slcTemplate.simpleFlow">\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.systemCall">\r
-                                       <property name="command">\r
-                                               <list>\r
-                                                       <value>echo</value>\r
-                                                       <value>Hello</value>\r
-                                                       <value>World</value>\r
-                                               </list>\r
-                                       </property>\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="systemCallOsSpecific" parent="slcTemplate.simpleFlow">\r
-               <!-- Direct call to dir under Windows isnot working -->\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.systemCall">\r
-                                       <property name="cmd" value="dir" />\r
-                                       <property name="execDir" value="../.." />\r
-                                       <property name="osCmds">\r
-                                               <map>\r
-                                                       <entry key="Linux" value="ls" />\r
-                                                       <entry key="Mac OS X" value="ls" />\r
-                                               </map>\r
-                                       </property>\r
-                               </bean>\r
-                               <bean parent="task.systemCall">\r
-                                       <property name="command">\r
-                                               <list>\r
-                                                       <value>dir</value>\r
-                                               </list>\r
-                                       </property>\r
-                                       <property name="osCommands">\r
-                                               <map>\r
-                                                       <entry key="Linux">\r
-                                                               <list>\r
-                                                                       <value>ls</value>\r
-                                                               </list>\r
-                                                       </entry>\r
-                                                       <entry key="Mac OS X">\r
-                                                               <list>\r
-                                                                       <value>ls</value>\r
-                                                               </list>\r
-                                                       </entry>\r
-                                               </map>\r
-                                       </property>\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="systemCallWithVar" parent="slcTemplate.simpleFlow">\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="var">\r
-                                                       <bean parent="specAttr.primitive" p:value="660" />\r
-                                               </entry>\r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.systemCall" scope="execution">\r
-                                       <property name="cmd" value="echo var=@{var}" />\r
-                                       <aop:scoped-proxy />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/test.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/test.xml
deleted file mode 100644 (file)
index 5ae7501..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <import resource="imports.xml" /> \r
-\r
-       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
-       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
-               <property name="testDefinition" ref="myTestDef" />\r
-               <property name="testResult" ref="myTestResult"/>\r
-       </bean>         \r
\r
-       <bean id="spec1" parent="slcTemplate.simpleSpec">\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="testedComponentId">\r
-                                       <bean parent="specAttr.primitive" p:isParameter="true"\r
-                                               p:type="integer" />\r
-                               </entry>\r
-                               <entry key="testData1">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:isParameter="true" p:isFrozen="true" />\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="flowTemplate1" parent="slcTemplate.simpleFlow"\r
-               abstract="true">\r
-               <constructor-arg ref="spec1" />\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo">\r
-                                       <property name="message" value="From basic @{testedComponentId}" />\r
-                               </bean>\r
-                               <bean parent="myTestRunTemplate">\r
-                                       <property name="testData">\r
-                                               <bean parent="parameterRef">\r
-                                                       <constructor-arg value="testData1" />\r
-                                               </bean>\r
-                                       </property>\r
-                               </bean>\r
-                               <bean parent="task.echo">\r
-                                       <property name="message"><value>From basic @{testedComponentId}</value></property>\r
-                               </bean>         \r
-                               <bean parent="task.echo">\r
-                                       <property name="message"><value>testData1='@{testData1}'</value></property>\r
-                               </bean>                                                 \r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="flow1" parent="flowTemplate1" scope="prototype">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="testedComponentId" value="200" />\r
-                               <entry key="testData1">\r
-                                       <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                               <aop:scoped-proxy/>\r
-                                               <property name="expected" value="tata101" />\r
-                                               <property name="reached" value="tata@{testedComponentId}" />\r
-                                       </bean>\r
-                               </entry>\r
-                       </map>                  \r
-               </constructor-arg>\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/FlowNamespaceTest.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/FlowNamespaceTest.java
deleted file mode 100644 (file)
index 4ebb667..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.argeo.slc.core.execution.xml;
-
-import org.argeo.slc.core.execution.AbstractExecutionFlowTestCase;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.springframework.context.ConfigurableApplicationContext;
-
-public abstract class FlowNamespaceTest extends AbstractExecutionFlowTestCase {
-       public void XXXtestCanonical() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("canonic-ns.xml");
-               ((ExecutionFlow) applicationContext.getBean("canonic-ns.001")).run();
-               ((ExecutionFlow) applicationContext.getBean("canonic-ns.002")).run();
-       }
-
-       public void XXXtestAdvanced() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("advanced.xml");
-               ((ExecutionFlow) applicationContext.getBean("flow1")).run();
-               ((ExecutionFlow) applicationContext.getBean("flow2")).run();
-               ((ExecutionFlow) applicationContext.getBean("flow3")).run();
-
-               validateTestResult((SimpleTestResult) applicationContext
-                               .getBean("testResult"));
-       }
-
-       public void XXXtestAdvancedExecution() throws Exception {
-               ConfigurableApplicationContext applicationContext = createApplicationContext("advanced.xml");
-
-               ExecutionContext executionContext = (ExecutionContext) applicationContext
-                               .getBean("executionContext");
-               executionContext.setVariable("param2", 4);
-
-               ((ExecutionFlow) applicationContext.getBean("flow4")).run();
-
-               validateTestResult((SimpleTestResult) applicationContext
-                               .getBean("testResult"));
-       }
-
-       // These tests causes pb when using Spring 3
-       
-       // public void testContainers() throws Exception {
-       // ConfigurableApplicationContext applicationContext =
-       // createApplicationContext("containers.xml");
-       // ((ExecutionFlow) applicationContext.getBean("test.list.flow1")).run();
-       // ((ExecutionFlow) applicationContext.getBean("test.list.flow2")).run();
-       //
-       // validateTestResult((SimpleTestResult) applicationContext
-       // .getBean("testResult"));
-       // }
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/advanced.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/advanced.xml
deleted file mode 100644 (file)
index c316de6..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
-       <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
-\r
-       <bean id="testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-       <bean id="testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
-       <bean id="testRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
-               <property name="testDefinition" ref="testDef" />\r
-               <property name="testResult" ref="testResult"/>\r
-       </bean> \r
-\r
-       <flow:spec id="advanced.spec">\r
-               <description>spec description</description>\r
-               <flow:primitive name="param1" isParameter="true"\r
-                       type="integer" />\r
-               <flow:primitive name="param2" isParameter="true"\r
-                       type="integer" />                       \r
-       </flow:spec>\r
-\r
-\r
-       <flow:flow id="advanced.flowTemplate" abstract="true" spec="advanced.spec"\r
-               path="/path">\r
-               <description>flow description</description>\r
-               <bean parent="task.echo">\r
-                       <property name="message" value="Advanced: param1=@{param1}, param2=@{param2}" />\r
-                       <flow:variable/>\r
-               </bean> \r
-               <flow:flow>\r
-                       <bean parent="task.echo" p:message="Flow in Flow - param1=@{param1}, param2=@{param2} [Not variable]" />\r
-               </flow:flow>\r
\r
-               <bean parent="testRunTemplate">\r
-                       <property name="testData">\r
-                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                       <flow:variable/>\r
-                                       <property name="expected" value="@{param1}" />\r
-                                       <property name="reached" value="@{param2}" />\r
-                               </bean>\r
-                       </property>                                     \r
-               </bean>\r
\r
-       </flow:flow>\r
-\r
-       <flow:flow id="advanced.flowTemplate2" abstract="true" spec="advanced.spec"\r
-               path="/path">\r
-               <bean parent="task.echo" p:message="Advanced2: param1=@{param1}, param2=@{param2}">\r
-                       <flow:variable/>\r
-               </bean>\r
-               <flow:flow parent="advanced.flowTemplate">\r
-                       <flow:arg name="param1" value="@{param1}"/>\r
-                       <flow:arg name="param2">\r
-                               <!-- flow:param in flow:arg -->\r
-                               <flow:param name="param2" />\r
-                       </flow:arg>\r
-               </flow:flow>\r
-       </flow:flow>\r
-\r
-       \r
-       <flow:flow id="flow1" parent="advanced.flowTemplate">\r
-               <flow:arg name="param1" value="1" />\r
-               <flow:arg name="param2" value="1" />\r
-       </flow:flow>\r
-       \r
-       <flow:flow id="flow2">\r
-               <flow:flow parent="advanced.flowTemplate">\r
-                       <flow:arg name="param1" value="2" />\r
-                       <flow:arg name="param2" value="2" />\r
-               </flow:flow>\r
-       </flow:flow>\r
-\r
-       <flow:flow id="flow3" parent="advanced.flowTemplate2">\r
-               <flow:arg name="param1" value="3" />\r
-               <flow:arg name="param2" value="3" />\r
-       </flow:flow>\r
-       \r
-       <flow:flow id="flow4" parent="advanced.flowTemplate">\r
-               <description>Would fail if param 2 is not changed at execution</description>\r
-               <flow:arg name="param1" value="4" />\r
-               <flow:arg name="param2" value="3" />\r
-       </flow:flow>    \r
-\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-001.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-001.xml
deleted file mode 100644 (file)
index aeef3a3..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <bean id="canonic-ns.001" parent="canonic-ns.flowTemplate">\r
-               <description>Canonic 001</description>\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="parameterAtInstantiation" value="1" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-</beans>\r
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-002.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-002.xml
deleted file mode 100644 (file)
index 6668e67..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans:beans xmlns="http://www.argeo.org/schema/slc-flow"\r
-       xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:p="http://www.springframework.org/schema/p"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <flow id="canonic-ns.002" parent="canonic-ns.flowTemplate">\r
-               <arg name="parameterAtInstantiation" value="2" />\r
-               <arg name="displayWithoutControl" value="102" />\r
-               <arg name="displayWithControl" value="202" />\r
-               <arg name="hide" value="202" />\r
-               <arg name="refWithoutValue">\r
-                       <beans:bean id="testDataOk" p:expected="tata" p:reached="tata"\r
-                               class="org.argeo.slc.runtime.test.BasicTestData" />\r
-               </arg>\r
-       </flow>\r
-</beans:beans>\r
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns.xml
deleted file mode 100644 (file)
index 67bf012..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans:beans xmlns="http://www.argeo.org/schema/slc-flow"\r
-       xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <beans:import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
-       <beans:import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
-\r
-       <beans:import resource="canonic-ns-001.xml" />\r
-       <beans:import resource="canonic-ns-002.xml" />\r
-       <beans:import resource="tests.xml" />\r
-\r
-       <!--\r
-               Specifications definition is greatly simplified by the flow namespace\r
-       -->\r
-       <spec id="canonic-ns.spec">\r
-               <primitive name="parameterAtInstantiation" isParameter="true"\r
-                       type="integer" />\r
-               <primitive name="displayWithoutControl" value="100"\r
-                       isParameter="true" type="integer" isFrozen="true" />\r
-               <primitive name="displayWithControl" value="200"\r
-                       isParameter="true" type="integer" />\r
-               <primitive name="hide" value="300" isParameter="true" type="integer"\r
-                       isHidden="true" />\r
-               <ref name="refWithValue" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                       isParameter="true" ref="testDataNok" />\r
-               <ref name="refWithoutValue" targetClass="org.argeo.slc.runtime.test.BasicTestData" />\r
-               <ref name="refWithoutValueFrozen" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                       isParameter="true" isFrozen="true">\r
-                       <value>\r
-                               <beans:bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                       <aop:scoped-proxy />\r
-                                       <beans:property name="expected" value="tata" />\r
-                                       <beans:property name="reached" value="tata" />\r
-                               </beans:bean>\r
-                       </value>\r
-               </ref>\r
-       </spec>\r
-\r
-       <flow id="canonic-ns.flowTemplate" abstract="true" spec="canonic-ns.spec"\r
-               path="/path">\r
-               <beans:bean parent="task.echo"\r
-                       p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
-                       scope="execution">\r
-                       <aop:scoped-proxy />\r
-               </beans:bean>\r
-               <beans:ref bean="testRun" />\r
-       </flow>\r
-\r
-       <beans:bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
-               <aop:scoped-proxy />\r
-               <beans:property name="expected" value="tata" />\r
-               <beans:property name="reached" value="tata" />\r
-       </beans:bean>\r
-\r
-       <beans:bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
-               <aop:scoped-proxy />\r
-               <beans:property name="expected" value="tata" />\r
-               <beans:property name="reached" value="toto" />\r
-       </beans:bean>\r
-</beans:beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/containers.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/containers.xml
deleted file mode 100644 (file)
index 518e5f7..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
-       <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
-\r
-       <bean id="testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-       <bean id="testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
-       <bean id="testRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
-               <property name="testDefinition" ref="testDef" />\r
-               <property name="testResult" ref="testResult"/>\r
-       </bean> \r
-\r
-       <flow:spec id="test.list.spec">\r
-               <flow:ref name="list1" targetClass="java.util.List">\r
-                       <flow:value>\r
-                               <!-- a list element can be used directly as default value-->\r
-                               <list>\r
-                                       <value>val1</value>\r
-                               </list>\r
-                       </flow:value>\r
-               </flow:ref>\r
-               <flow:ref name="list2" targetClass="java.util.List" />\r
-               <!-- following parameters are not used in flow -->\r
-               <flow:ref name="dummyMap" targetClass="java.util.Map">\r
-                       <flow:value>\r
-                               <map></map>\r
-                       </flow:value>\r
-               </flow:ref>\r
-               <flow:ref name="dummySet" targetClass="java.util.Set">\r
-                       <flow:value>\r
-                               <set></set>\r
-                       </flow:value>\r
-               </flow:ref>\r
-               <flow:ref name="dummyProperties" targetClass="java.util.Properties">\r
-                       <flow:value>\r
-                               <props></props>\r
-                       </flow:value>\r
-               </flow:ref>\r
-               \r
-       </flow:spec>\r
-\r
-\r
-       <flow:flow id="test.list.flowTemplate" abstract="true" spec="test.list.spec"\r
-               path="/path">\r
-               <bean parent="task.echo">\r
-                       <property name="message" value="list1=@{list1}, list2=@{list2}" />\r
-                       <flow:variable/>\r
-               </bean> \r
-\r
-               <bean parent="testRunTemplate">\r
-                       <property name="testData">\r
-                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                       <property name="expected">\r
-                                               <flow:param name="list1"/>\r
-                                       </property>\r
-                                       <property name="reached">\r
-                                               <flow:param name="list2"/>\r
-                                       </property>\r
-                               </bean>\r
-                       </property>                                     \r
-               </bean>\r
\r
-       </flow:flow>\r
-\r
-       <flow:flow id="test.list.flow1" parent="test.list.flowTemplate">\r
-               <flow:arg name="list1">\r
-                       <list>\r
-                               <value>val1</value>\r
-                               <value>val2</value>                     \r
-                       </list>\r
-               </flow:arg>\r
-               <flow:arg name="list2">\r
-                       <list>\r
-                               <value>val1</value>\r
-                               <value>val2</value>                     \r
-                       </list>\r
-               </flow:arg>\r
-               \r
-               <!-- not used in flow (just to test that the syntax is accepted): -->\r
-               <flow:arg name="dummyMap">\r
-                       <map></map>\r
-               </flow:arg>\r
-               <flow:arg name="dummySet">\r
-                       <set></set>\r
-               </flow:arg>\r
-               <flow:arg name="dummyProperties">\r
-                       <props></props>\r
-               </flow:arg>             \r
-               \r
-       </flow:flow>\r
-       \r
-       <flow:flow id="test.list.flow2" parent="test.list.flowTemplate">\r
-               <description>use default value for parameter "list1"</description>\r
-               <flow:arg name="list2">\r
-                       <list>\r
-                               <value>val1</value>\r
-                       </list>\r
-               </flow:arg>\r
-       </flow:flow>\r
-\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/tests.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/tests.xml
deleted file mode 100644 (file)
index 5015725..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
-       xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <bean id="testRun" class="org.argeo.slc.runtime.test.SimpleTestRun">\r
-               <property name="testDefinition">\r
-                       <bean class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-               </property>\r
-               <property name="testData">\r
-                       <flow:param name="refWithValue" />\r
-               </property>\r
-               <!--            <property name="testData">-->\r
-               <!--                    <bean parent="parameterRef">-->\r
-               <!--                            <constructor-arg value="refWithValue" />-->\r
-               <!--                    </bean>-->\r
-               <!--            </property>-->\r
-               <property name="testResult">\r
-                       <bean parent="slcDefault.test.basicSimpleTestResult" scope="execution">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="displayWithControl" value="@{displayWithControl}" />\r
-                                       </map>\r
-                               </property>\r
-                               <aop:scoped-proxy />\r
-                       </bean>\r
-               </property>\r
-       </bean>\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/AbstractInternalSpringTestCase.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/AbstractInternalSpringTestCase.java
deleted file mode 100644 (file)
index 507bb41..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.argeo.slc.core.test.context;
-
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.BeanFactoryUtils;
-import org.springframework.beans.factory.ListableBeanFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/** Helper for tests using a Spring application context. */
-public abstract class AbstractInternalSpringTestCase extends TestCase {
-       protected final Log log = LogFactory.getLog(getClass());
-       private ConfigurableApplicationContext context;
-
-       /**
-        * Gets (and create if necessary) the application context to use. Default
-        * implementation uses a class path xml application context and calls
-        * {@link #getApplicationContextLocation()}.
-        */
-       protected ConfigurableApplicationContext getContext() {
-               if (context == null) {
-                       context = new ClassPathXmlApplicationContext(
-                                       getApplicationContextLocation());
-               }
-               return context;
-       }
-
-       /** Returns a bean from the underlying context */
-       @SuppressWarnings(value = { "unchecked" })
-       protected <T> T getBean(String beanId) {
-               return (T) getContext().getBean(beanId);
-       }
-
-       protected <T> T getBean(Class<? extends T> clss) {
-               T bean = loadSingleFromContext(getContext(), clss);
-               if (bean == null) {
-                       throw new SlcException("Cannot retrieve a unique bean of type "
-                                       + clss);
-               } else {
-                       return bean;
-               }
-       }
-
-       /**
-        * Th location of the application to load. The default implementation
-        * returns <i>applicationContext.xml</i> found in the same package as the
-        * test.
-        */
-       protected String getApplicationContextLocation() {
-               return inPackage("applicationContext.xml");
-       }
-
-       /**
-        * Prefixes the package of the class after converting the '.' to '/' in
-        * order to have a resource path.
-        */
-       protected String inPackage(String suffix) {
-               String prefix = getClass().getPackage().getName().replace('.', '/');
-               return prefix + '/' + suffix;
-       }
-
-       @SuppressWarnings(value = { "unchecked" })
-       protected <T> T loadSingleFromContext(ListableBeanFactory context,
-                       Class<T> clss) {
-               Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
-                               context, clss, false, false);
-               if (beans.size() == 1) {
-                       return beans.values().iterator().next();
-               } else if (beans.size() > 1) {
-                       if (log.isDebugEnabled()) {
-                               log
-                                               .debug(("Found more that on bean for type " + clss
-                                                               + ": " + beans.keySet()));
-                       }
-                       return null;
-               } else {
-                       return null;
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/ContextTest.java b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/ContextTest.java
deleted file mode 100644 (file)
index 64a4369..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.argeo.slc.core.test.context;
-
-import java.util.List;
-
-import org.argeo.slc.runtime.test.ContextUtils;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.argeo.slc.test.TestResultPart;
-import org.argeo.slc.test.TestStatus;
-import org.argeo.slc.test.context.ContextAware;
-
-public class ContextTest extends AbstractInternalSpringTestCase {
-
-       public void testComplexContext() {
-               SimpleTestResult testResult = new SimpleTestResult();
-               ContextUtils.compareReachedExpected(
-                               (ContextAware) getBean("context.c1"), testResult);
-               ContextUtils.compareReachedExpected(
-                               (ContextAware) getBean("context.c2"), testResult);
-               ContextUtils.compareReachedExpected(
-                               (ContextAware) getBean("context.c3"), testResult);
-
-               List<TestResultPart> parts = testResult.getParts();
-               assertEquals(6, parts.size());
-               assertEquals(TestStatus.PASSED, parts.get(0).getStatus());
-               assertEquals(TestStatus.PASSED, parts.get(1).getStatus());
-               assertEquals(TestStatus.PASSED, parts.get(2).getStatus());
-               assertEquals(TestStatus.FAILED, parts.get(3).getStatus());
-               assertEquals(TestStatus.PASSED, parts.get(4).getStatus());
-               assertEquals(TestStatus.PASSED, parts.get(5).getStatus());
-       }
-}
diff --git a/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/applicationContext.xml b/cms/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/applicationContext.xml
deleted file mode 100644 (file)
index 4949c4e..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <bean id="parentContext.pc1" parent="parentContext.template">\r
-               <property name="values">\r
-                       <map>\r
-                               <entry key="rootvar" value="text" />\r
-                       </map>\r
-               </property>\r
-               <property name="expectedValues">\r
-                       <map>\r
-                               <entry key="reference" value="20" />\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="context.c1" parent="context.template">\r
-               <property name="parentContext" ref="parentContext.pc1" />\r
-               <property name="values">\r
-                       <map>\r
-                               <entry key="reference" value="20" />\r
-                               <entry key="any" value="999" />\r
-                               <entry key="skipped" value="999" />\r
-                       </map>\r
-               </property>\r
-               <property name="expectedValues">\r
-                       <map>\r
-                               <entry key="reference" value="21" />\r
-                               <entry key="any" value="*" />\r
-                               <entry key="skipped" value="!" />\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="context.c2" parent="context.template">\r
-               <property name="parentContext" ref="parentContext.pc1" />\r
-               <property name="values">\r
-                       <map>\r
-                               <entry key="var" value="37" />\r
-                               <entry key="bad" value="56" />\r
-                       </map>\r
-               </property>\r
-               <property name="expectedValues">\r
-                       <map>\r
-                               <entry key="var" value="37" />\r
-                               <entry key="bad" value="57" />\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="parentContext.pc2" parent="parentContext.template">\r
-               <property name="parentContext" ref="parentContext.pc1" />\r
-               <property name="expectedValues">\r
-                       <map>\r
-                               <entry key="reference" value="40" />\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="context.c3" parent="context.template">\r
-               <property name="parentContext" ref="parentContext.pc2" />\r
-               <property name="values">\r
-                       <map>\r
-                               <entry key="reference" value="41" />\r
-                               <entry key="rootvar" value="textX" />\r
-                       </map>\r
-               </property>\r
-               <property name="expectedValues">\r
-                       <map>\r
-                               <entry key="reference" value="40" />\r
-                               <entry key="rootvar" value="text" />\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-\r
-       <bean id="parentContext.template"\r
-               class="org.argeo.slc.core.test.context.SimpleParentContextAware"\r
-               abstract="true">\r
-       </bean>\r
-\r
-       <bean id="context.template"\r
-               class="org.argeo.slc.core.test.context.SimpleContextAware"\r
-               abstract="true">\r
-       </bean>\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/pom.xml b/cms/org.argeo.slc.spring/pom.xml
deleted file mode 100644 (file)
index bb4ab6e..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.spring</artifactId>
-       <name>SLC Spring Runtime</name>
-       <dependencies>
-               <!-- Commons -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.enterprise</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.api</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.cms</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.jcr</artifactId>
-                       <version>${version.argeo-commons}</version>
-               </dependency>
-
-               <!-- Commons -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.osgi.boot</artifactId>
-                       <version>${version.argeo-commons}</version>
-                       <scope>provided</scope>
-               </dependency>
-
-               <!-- SLC -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.api</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.jcr</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.repo</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Spring -->
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.beans</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.core</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.context</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.expression</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.aop</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.gemini</groupId>
-                       <artifactId>org.eclipse.gemini.blueprint.core</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.gemini</groupId>
-                       <artifactId>org.eclipse.gemini.blueprint.io</artifactId>
-               </dependency>
-
-               <!-- Ant -->
-               <dependency>
-                       <groupId>org.argeo.tp.apache.ant</groupId>
-                       <artifactId>org.apache.ant</artifactId>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/ant/AntFlowGenerator.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/ant/AntFlowGenerator.java
deleted file mode 100644 (file)
index 1a6f692..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.argeo.slc.ant;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.argeo.slc.core.execution.AbstractExecutionFlowGenerator;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.core.io.Resource;
-
-public class AntFlowGenerator extends AbstractExecutionFlowGenerator {
-       private List<Resource> antFiles = new ArrayList<Resource>();
-
-       protected Map<String, BeanDefinition> createExecutionFlowDefinitions(
-                       ConfigurableListableBeanFactory beanFactory) {
-               Map<String, BeanDefinition> definitions = new HashMap<String, BeanDefinition>();
-
-               for (Resource antFile : antFiles) {
-                       AntRun antRun = new AntRun();
-                       antRun.setBuildFile(antFile);
-
-                       List<Runnable> executables = new ArrayList<Runnable>();
-                       executables.add(antRun);
-                       definitions.put("ant." + antFile.getFilename(),
-                                       createDefaultFlowDefinition(executables));
-               }
-               return definitions;
-       }
-
-       public void setAntFiles(List<Resource> antFiles) {
-               this.antFiles = antFiles;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/ant/AntRun.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/ant/AntRun.java
deleted file mode 100644 (file)
index 238e225..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-package org.argeo.slc.ant;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
-import org.apache.tools.ant.helper.ProjectHelper2;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-public class AntRun implements Runnable {
-       private final static Log log = LogFactory.getLog(AntRun.class);
-
-       private Resource buildFile;
-       private File baseDir;
-
-       private List<String> targets = new ArrayList<String>();
-       private Map<Object, Object> properties = new HashMap<Object, Object>();
-
-       public void run() {
-               Project project = new Project();
-
-               try {
-                       String path = buildFile.getURL().getPath();
-                       project.setUserProperty("ant.file", path);
-                       project.setBaseDir(extractBaseDir(path));
-
-                       project.init();
-                       ProjectHelper projectHelper = new ProjectHelper2();
-                       project.addReference(ProjectHelper.PROJECTHELPER_REFERENCE,
-                                       projectHelper);
-                       projectHelper.parse(project, buildFile.getURL());
-               } catch (Exception e) {
-                       throw new SlcException("Could not parse " + buildFile, e);
-               }
-
-               if (properties != null) {
-                       for (Map.Entry<Object, Object> entry : properties.entrySet()) {
-                               project.setUserProperty(entry.getKey().toString(), entry
-                                               .getValue().toString());
-                       }
-               }
-
-               project.fireBuildStarted();
-               Throwable exception = null;
-               try {
-                       project.addBuildListener(new LoggingListener());
-                       if (targets.size() == 0) {
-                               project.executeTarget(project.getDefaultTarget());
-                       } else {
-                               project.executeTargets(new Vector<String>(targets));
-                       }
-               } catch (Throwable e) {
-                       exception = e;
-                       throw new SlcException("Could not run Ant script " + buildFile, e);
-               } finally {
-                       project.fireBuildFinished(exception);
-               }
-       }
-
-       private File extractBaseDir(String path) {
-               if(this.baseDir!=null)
-                       return this.baseDir;
-               
-               String baseDir = null;
-               if (path.length() > 1) {
-                       int indx = path.lastIndexOf('/', path.length() - 1);
-                       if (indx == -1 || indx == 0) {
-                               baseDir = "/";
-                       } else {
-                               baseDir = path.substring(0, indx) + "/";
-                       }
-               } else {
-                       baseDir = "/";
-               }
-               File file = new File(baseDir);
-               if (file.exists()) {
-                       return file;
-               } else {
-                       return new File(System.getProperty("user.dir"));
-               }
-       }
-
-       public void setBuildFile(Resource buildFile) {
-               this.buildFile = buildFile;
-       }
-
-       public void setTargets(List<String> targets) {
-               this.targets = targets;
-       }
-
-       public void setProperties(Map<Object, Object> properties) {
-               this.properties = properties;
-       }
-
-       public void setBaseDir(File baseDir) {
-               this.baseDir = baseDir;
-       }
-
-       protected static class LoggingListener implements BuildListener {
-
-               public void buildFinished(BuildEvent event) {
-                       if (log.isDebugEnabled())
-                               log.debug("Ant build finished: " + event);
-               }
-
-               public void buildStarted(BuildEvent event) {
-                       if (log.isDebugEnabled())
-                               log.debug("Ant build started: " + event);
-               }
-
-               public void messageLogged(BuildEvent event) {
-                       if (event.getPriority() == Project.MSG_DEBUG) {
-                               if (log.isTraceEnabled())
-                                       log.trace(event.getMessage());
-                       } else if (event.getPriority() == Project.MSG_VERBOSE) {
-                               if (log.isDebugEnabled())
-                                       log.debug(event.getMessage());
-                       } else if (event.getPriority() == Project.MSG_INFO) {
-                               log.info(event.getMessage());
-
-                       } else if (event.getPriority() == Project.MSG_WARN) {
-                               log.warn(event.getMessage());
-
-                       } else if (event.getPriority() == Project.MSG_ERR) {
-                               log.error(event.getMessage());
-                       } else {
-                               log.error(event.getMessage());
-                       }
-               }
-
-               public void targetFinished(BuildEvent event) {
-                       if (log.isTraceEnabled())
-                               log.debug("Target finished: " + event.getTarget());
-               }
-
-               public void targetStarted(BuildEvent event) {
-                       if (log.isTraceEnabled())
-                               log.debug("Target started: " + event.getTarget());
-               }
-
-               public void taskFinished(BuildEvent event) {
-               }
-
-               public void taskStarted(BuildEvent event) {
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentUploader.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentUploader.java
deleted file mode 100644 (file)
index fcd2657..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.argeo.slc.core.attachment;
-
-import org.argeo.slc.attachment.Attachment;
-import org.springframework.core.io.Resource;
-
-public interface AttachmentUploader {
-       public void upload(Attachment attachment, Resource resource);
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/FileAttachmentsStorage.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/FileAttachmentsStorage.java
deleted file mode 100644 (file)
index b5c9e3c..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-package org.argeo.slc.core.attachment;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.attachment.Attachment;
-import org.argeo.slc.attachment.AttachmentsStorage;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-public class FileAttachmentsStorage implements AttachmentsStorage,
-               AttachmentUploader, InitializingBean {
-       private final static Log log = LogFactory
-                       .getLog(FileAttachmentsStorage.class);
-
-       private File attachmentsDirectory;
-
-       private String attachmentsTocFileName = "attachmentsToc.csv";
-
-       private DateFormat dateFormatDay = new SimpleDateFormat("yyyy-MM-dd");
-       private DateFormat dateFormatTime = new SimpleDateFormat("HH:mm:ss");
-
-       public void afterPropertiesSet() {
-               if (attachmentsDirectory == null) {
-
-                       String osgiInstanceArea = System.getProperty("osgi.instance.area");
-                       if (osgiInstanceArea != null) {
-                               if (osgiInstanceArea.startsWith("file:"))
-                                       osgiInstanceArea = osgiInstanceArea.substring("file:"
-                                                       .length());
-                               attachmentsDirectory = new File(osgiInstanceArea
-                                               + File.separator + "slcAttachments");
-                       }
-
-                       if (attachmentsDirectory == null) {
-                               String tempDir = System.getProperty("java.io.tmpdir");
-                               attachmentsDirectory = new File(tempDir + File.separator
-                                               + "slcAttachments");
-                       }
-               }
-               if (!attachmentsDirectory.exists())
-                       attachmentsDirectory.mkdirs();
-               if (log.isDebugEnabled())
-                       log.debug("File attachment storage initialized in directory "
-                                       + attachmentsDirectory);
-       }
-
-       public void retrieveAttachment(Attachment attachment,
-                       OutputStream outputStream) {
-               File file = getFile(attachment);
-               InputStream in = null;
-               try {
-                       byte[] buffer = new byte[1024 * 1024];
-                       in = new FileInputStream(file);
-                       int read = -1;
-                       while ((read = in.read(buffer)) >= 0) {
-                               outputStream.write(buffer, 0, read);
-                       }
-                       if (log.isTraceEnabled())
-                               log.trace("Read " + attachment + " from " + file);
-               } catch (IOException e) {
-                       throw new SlcException("Cannot write attachment " + attachment
-                                       + " to " + file, e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-               }
-       }
-
-       public void storeAttachment(Attachment attachment, InputStream inputStream) {
-               File file = getFile(attachment);
-               FileOutputStream out = null;
-               try {
-                       byte[] buffer = new byte[1024 * 1024];
-                       out = new FileOutputStream(file);
-                       int read = -1;
-                       while ((read = inputStream.read(buffer)) >= 0) {
-                               out.write(buffer, 0, read);
-                       }
-                       if (log.isTraceEnabled())
-                               log.trace("Wrote " + attachment + " to " + file);
-                       updateAttachmentToc(attachment, file);
-               } catch (IOException e) {
-                       throw new SlcException("Cannot write attachment " + attachment
-                                       + " to " + file, e);
-               } finally {
-                       IOUtils.closeQuietly(out);
-               }
-
-       }
-
-       public void upload(Attachment attachment, Resource resource) {
-               try {
-                       storeAttachment(attachment, resource.getInputStream());
-               } catch (IOException e) {
-                       throw new SlcException("Cannot upload attachment " + attachment, e);
-               }
-       }
-
-       /** For monitoring purposes only */
-       protected void updateAttachmentToc(Attachment attachment, File file) {
-               Date date = new Date(file.lastModified());
-               FileWriter writer = null;
-               try {
-                       writer = new FileWriter(attachmentsDirectory + File.separator
-                                       + attachmentsTocFileName, true);
-                       writer.append(dateFormatDay.format(date));
-                       writer.append(',');
-                       writer.append(dateFormatTime.format(date));
-                       writer.append(',');
-                       writer.append(attachment.getUuid());
-                       writer.append(',');
-                       writer.append(attachment.getName());
-                       writer.append(',');
-                       writer.append(attachment.getContentType());
-                       writer.append(',');
-                       writer.append(Long.toString(file.length()));
-                       writer.append(',');
-                       writer.append(file.getCanonicalPath());
-                       writer.append('\n');
-               } catch (IOException e) {
-                       log.warn("Could not update attachments TOC for " + attachment
-                                       + " and file " + file, e);
-               } finally {
-                       IOUtils.closeQuietly(writer);
-               }
-
-       }
-
-       protected File getFile(Attachment attachment) {
-               File file = new File(attachmentsDirectory + File.separator
-                               + attachment.getUuid());
-               return file;
-       }
-
-       public void setAttachmentsDirectory(File attachmentsDirectory) {
-               this.attachmentsDirectory = attachmentsDirectory;
-       }
-
-       public void setAttachmentsTocFileName(String attachmentsTocFileName) {
-               this.attachmentsTocFileName = attachmentsTocFileName;
-       }
-
-       public void setDateFormatDay(DateFormat dateFormatDay) {
-               this.dateFormatDay = dateFormatDay;
-       }
-
-       public void setDateFormatTime(DateFormat dateFormatTime) {
-               this.dateFormatTime = dateFormatTime;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/SimpleAttachment.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/SimpleAttachment.java
deleted file mode 100644 (file)
index 5319d59..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.argeo.slc.core.attachment;
-
-import java.io.Serializable;
-import java.util.UUID;
-
-import org.argeo.slc.attachment.Attachment;
-
-public class SimpleAttachment implements Attachment, Serializable {
-       private static final long serialVersionUID = 6615155908800610606L;
-       private String uuid = UUID.randomUUID().toString();
-       private String name;
-       private String contentType = "";
-
-       public SimpleAttachment() {
-       }
-
-       public SimpleAttachment(String uuid, String name, String contentType) {
-               super();
-               this.uuid = uuid;
-               this.name = name;
-               this.contentType = contentType;
-       }
-
-       public String getUuid() {
-               return uuid;
-       }
-
-       public void setUuid(String uuid) {
-               this.uuid = uuid;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public String getContentType() {
-               return contentType;
-       }
-
-       public void setContentType(String contentType) {
-               this.contentType = contentType;
-       }
-
-       public String toString() {
-               return "Attachment #" + uuid + "(" + name + ", " + contentType + ")";
-       }
-
-       public boolean equals(Object obj) {
-               if (obj instanceof Attachment) {
-                       Attachment attachment = (Attachment) obj;
-                       if (uuid != null && attachment.getUuid() != null)
-                               return uuid.equals(attachment.getUuid());
-
-                       if (name != null && attachment.getName() != null)
-                               return name.equals(attachment.getName());
-
-                       return hashCode() == attachment.hashCode();
-               }
-               return false;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/ResourceDistribution.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/ResourceDistribution.java
deleted file mode 100644 (file)
index e449331..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.argeo.slc.core.build;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.StreamReadable;
-import org.argeo.slc.build.Distribution;
-import org.springframework.core.io.Resource;
-
-/** A software distribution archive accessible via a {@link Resource}. */
-public class ResourceDistribution implements Distribution, StreamReadable {
-       private Resource resource;
-
-       public ResourceDistribution() {
-       }
-
-       public ResourceDistribution(Resource location) {
-               this.resource = location;
-       }
-
-       public String getDistributionId() {
-               return resource.toString();
-       }
-
-       public Resource getResource() {
-               return resource;
-       }
-
-       public void setResource(Resource resource) {
-               this.resource = resource;
-       }
-
-       public InputStream getInputStream() {
-               try {
-                       return resource.getInputStream();
-               } catch (IOException e) {
-                       throw new SlcException("Cannot get input stream", e);
-               }
-       }
-
-       @Override
-       public String toString() {
-               return resource.toString();
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionDistributionId.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionDistributionId.java
deleted file mode 100644 (file)
index 932ecc7..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.argeo.slc.core.build;
-
-import java.util.StringTokenizer;
-
-/**
- * <p>
- * An implementation of the distribution id using the standard
- * Major.Minor.Release notation. And additional arbitrary string can also be
- * added.
- * </p>
- * 
- * <p>
- * <b>Examples:</b><br>
- * 0.2.6<br>
- * 2.4.12.RC1
- * </p>
- */
-public class VersionDistributionId {
-
-       private Integer major;
-       private Integer minor;
-       private Integer release;
-       private String additional;
-
-       /** Parse the provided string in order to set the various components. */
-       public void setVersionString(String str) {
-               StringTokenizer st = new StringTokenizer(str, ".");
-               if (st.hasMoreTokens())
-                       major = Integer.parseInt(st.nextToken());
-               if (st.hasMoreTokens())
-                       minor = Integer.parseInt(st.nextToken());
-               if (st.hasMoreTokens())
-                       release = Integer.parseInt(st.nextToken());
-               if (st.hasMoreTokens())
-                       additional = st.nextToken();
-       }
-
-       public Integer getMajor() {
-               return major;
-       }
-
-       public void setMajor(Integer major) {
-               this.major = major;
-       }
-
-       public Integer getMinor() {
-               return minor;
-       }
-
-       public void setMinor(Integer minor) {
-               this.minor = minor;
-       }
-
-       public Integer getRelease() {
-               return release;
-       }
-
-       public void setRelease(Integer release) {
-               this.release = release;
-       }
-
-       public String getAdditional() {
-               return additional;
-       }
-
-       public void setAdditional(String additional) {
-               this.additional = additional;
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               // TODO Auto-generated method stub
-               return super.equals(obj);
-       }
-
-       @Override
-       public String toString() {
-               return major + "." + minor + "." + release
-                               + (additional != null ? "." + additional : "");
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionedResourceDistribution.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionedResourceDistribution.java
deleted file mode 100644 (file)
index 414a12b..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.argeo.slc.core.build;
-
-import org.argeo.slc.NameVersion;
-import org.springframework.core.io.Resource;
-
-/**
- * The distribution of a software package (jar, zip, RPM, etc.) which is
- * versioned. The archive itself is accessible via a {@link Resource}.
- */
-public class VersionedResourceDistribution extends ResourceDistribution
-               implements NameVersion {
-       private String name;
-       private String version;
-
-       public VersionedResourceDistribution() {
-               super();
-       }
-
-       public VersionedResourceDistribution(NameVersion nameVersion,
-                       Resource resource) {
-               this(nameVersion.getName(), nameVersion.getVersion(), resource);
-       }
-
-       public VersionedResourceDistribution(String name, String version,
-                       Resource resource) {
-               super(resource);
-               this.name = name;
-               this.version = version;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       public void setVersion(String version) {
-               this.version = version;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/package.html b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/build/package.html
deleted file mode 100644 (file)
index 5da2052..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-SLC Build: building of software systems.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DefaultResourceSet.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DefaultResourceSet.java
deleted file mode 100644 (file)
index a5b8536..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-package org.argeo.slc.core.deploy;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.util.AntPathMatcher;
-import org.springframework.util.PathMatcher;
-
-public class DefaultResourceSet implements ResourceLoaderAware,
-               InitializingBean, ResourceSet {
-       private final static Log log = LogFactory.getLog(DefaultResourceSet.class);
-       public final static String DEFAULT_EXCLUDES = "**/.svn/**";
-
-       private String base;
-       private String include;
-       private List<String> includes = new ArrayList<String>();
-       private String exclude;
-       private List<String> excludes = new ArrayList<String>();
-       private Boolean useDefaultExcludes = true;
-       private ResourcePatternResolver resourcePatternResolver;
-       private PathMatcher excludePathMatcher = new AntPathMatcher();
-
-       private ResourceLoader resourceLoader;
-
-       /** List the resources, identified by their relative path. */
-       public Map<String, Resource> listResources() {
-               try {
-                       Map<String, Resource> res = new TreeMap<String, Resource>();
-                       if (base == null)
-                               return res;
-                       String baseResUrl = getResourceLoaderToUse().getResource(base)
-                                       .getURL().toString();
-                       for (String includePattern : includes)
-                               processInclude(res, includePattern, baseResUrl);
-                       return res;
-               } catch (IOException e) {
-                       throw new SlcException("Cannot list resource from " + base, e);
-               }
-       }
-
-       protected void processInclude(Map<String, Resource> res, String include,
-                       String baseResUrl) throws IOException {
-               String pattern = base + "/" + include;
-               if (log.isTraceEnabled())
-                       log.trace("Look for resources with pattern '" + pattern
-                                       + "' in base url " + baseResUrl);
-               Resource[] resources = resourcePatternResolver.getResources(pattern);
-               resources: for (Resource resource : resources) {
-                       String url = resource.getURL().toString();
-                       String relPath = url.substring(baseResUrl.length());
-
-                       // skip dir
-                       if (relPath.charAt(relPath.length() - 1) == '/') {
-                               if (log.isTraceEnabled())
-                                       log.trace("Skip directory " + relPath + "=" + resource);
-                               continue resources;
-                       }
-
-                       // make sure there is not starting '/'
-                       if (relPath.charAt(0) == '/')
-                               relPath = relPath.substring(1);
-
-                       // skip excludes
-                       for (String exclude : excludes)
-                               if (excludePathMatcher.match(exclude, relPath)) {
-                                       if (log.isTraceEnabled())
-                                               log.trace("Exclude " + relPath + "=" + resource);
-                                       continue resources;
-                               }
-
-                       // check if already exists
-                       if (res.containsKey(relPath))
-                               log.warn(relPath + " already matched by " + res.get(relPath)
-                                               + ", " + resource + " will override it.");
-
-                       // store the marched resource
-                       res.put(relPath, resource);
-                       if (log.isTraceEnabled())
-                               log.trace(relPath + "=" + resource);
-               }
-
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               if (resourcePatternResolver == null)
-                       resourcePatternResolver = new PathMatchingResourcePatternResolver(
-                                       getResourceLoaderToUse());
-               if (include != null)
-                       addCommaSeparatedToList(include, includes);
-               if (exclude != null)
-                       addCommaSeparatedToList(exclude, excludes);
-
-               if (includes.size() == 0)
-                       includes.add("**");
-
-               if (useDefaultExcludes)
-                       addCommaSeparatedToList(DEFAULT_EXCLUDES, excludes);
-       }
-
-       private void addCommaSeparatedToList(String str, List<String> lst) {
-               StringTokenizer st = new StringTokenizer(str, ",");
-               while (st.hasMoreTokens()) {
-                       String token = st.nextToken();
-                       if (!lst.contains(token))
-                               lst.add(token);
-               }
-       }
-
-       public void setResourceLoader(ResourceLoader resourceLoader) {
-               this.resourceLoader = resourceLoader;
-       }
-
-       /**
-        * Can be overridden in order to provide the proper resource loader used to
-        * resolve resources.
-        */
-       public ResourceLoader getResourceLoaderToUse() {
-               return resourceLoader;
-       }
-
-       public void setBase(String base) {
-               this.base = base;
-       }
-
-       public void setInclude(String include) {
-               this.include = include;
-       }
-
-       public void setIncludes(List<String> includes) {
-               this.includes = includes;
-       }
-
-       public void setExclude(String exclude) {
-               this.exclude = exclude;
-       }
-
-       public void setExcludes(List<String> excludes) {
-               this.excludes = excludes;
-       }
-
-       public void setUseDefaultExcludes(Boolean useDefaultExcludes) {
-               this.useDefaultExcludes = useDefaultExcludes;
-       }
-
-       public void setExcludePathMatcher(PathMatcher excludePathMatcher) {
-               this.excludePathMatcher = excludePathMatcher;
-       }
-
-       public void setResourcePatternResolver(
-                       ResourcePatternResolver resourcePatternResolver) {
-               this.resourcePatternResolver = resourcePatternResolver;
-       }
-
-       public ResourcePatternResolver getResourcePatternResolver() {
-               return resourcePatternResolver;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DigestCheck.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DigestCheck.java
deleted file mode 100644 (file)
index e7908eb..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.argeo.slc.core.deploy;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-import org.springframework.util.DigestUtils;
-
-/** Add Spring capabilities to {@link DigestUtils} */
-public class DigestCheck extends DigestUtils {
-       public static String digest(String algorithm, Resource resource) {
-               try {
-                       File file = resource.getFile();
-                       return org.argeo.util.DigestUtils.digest(algorithm, file);
-               } catch (IOException e) {
-                       try {
-                               return org.argeo.util.DigestUtils.digest(algorithm,
-                                               resource.getInputStream());
-                       } catch (IOException e1) {
-                               throw new SlcException("Cannot digest " + resource
-                                               + " with algorithm " + algorithm, e);
-                       }
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/LocalFilesDeployment.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/LocalFilesDeployment.java
deleted file mode 100644 (file)
index d339b94..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.argeo.slc.core.deploy;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-public class LocalFilesDeployment implements Runnable {
-       private String targetBase = "";
-       private ResourceSet resourceSet;
-
-       public LocalFilesDeployment() {
-       }
-
-       public LocalFilesDeployment(ResourceSet resourceSet) {
-               this.resourceSet = resourceSet;
-       }
-
-       public void run() {
-               Map<String, Resource> resources = resourceSet.listResources();
-               for (String relPath : resources.keySet()) {
-                       File targetFile = new File(targetBase + File.separator + relPath);
-                       File parentDir = targetFile.getParentFile();
-                       if (!parentDir.exists())
-                               parentDir.mkdirs();
-
-                       Resource resource = resources.get(relPath);
-
-                       InputStream in = null;
-                       OutputStream out = null;
-                       try {
-                               in = resource.getInputStream();
-                               out = FileUtils.openOutputStream(targetFile);
-                               IOUtils.copy(in, out);
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot extract " + resource + " to "
-                                               + targetFile, e);
-                       } finally {
-                               IOUtils.closeQuietly(in);
-                               IOUtils.closeQuietly(out);
-                       }
-               }
-       }
-
-       public void setTargetBase(String targetBase) {
-               this.targetBase = targetBase;
-       }
-
-       public void setResourceSet(ResourceSet resourceSet) {
-               this.resourceSet = resourceSet;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/MultiResourceSet.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/MultiResourceSet.java
deleted file mode 100644 (file)
index 2086712..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.argeo.slc.core.deploy;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.springframework.core.io.Resource;
-
-public class MultiResourceSet implements ResourceSet {
-       private List<ResourceSet> resourceSets = new ArrayList<ResourceSet>();
-
-       public Map<String, Resource> listResources() {
-               Map<String, Resource> res = new HashMap<String, Resource>();
-               for (ResourceSet resourceSet : resourceSets) {
-                       res.putAll(resourceSet.listResources());
-               }
-               return res;
-       }
-
-       /** Last listed override previous for the same relative paths. */
-       public void setResourceSets(List<ResourceSet> resourceSets) {
-               this.resourceSets = resourceSets;
-       }
-
-       public List<ResourceSet> getResourceSets() {
-               return resourceSets;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/ResourceSet.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/ResourceSet.java
deleted file mode 100644 (file)
index 6d670e0..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.argeo.slc.core.deploy;
-
-import java.util.Map;
-
-import org.springframework.core.io.Resource;
-
-public interface ResourceSet {
-       /**
-        * List the resources, identified by their relative path. Relative paths
-        * must NOT start with a '/'.
-        */
-       public Map<String, Resource> listResources();
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/SimpleExecutables.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/SimpleExecutables.java
deleted file mode 100644 (file)
index 6c93368..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.argeo.slc.core.deploy;
-
-import java.io.File;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.InstalledExecutables;
-import org.argeo.slc.deploy.TargetData;
-
-public class SimpleExecutables implements InstalledExecutables {
-       private final static Log log = LogFactory.getLog(SimpleExecutables.class);
-
-       private String baseDir;
-       private Map<String, String> paths = new TreeMap<String, String>();
-
-       private Distribution distribution;
-
-       public String getExecutablePath(String key) {
-               String path = paths.get(key);
-               if (path == null) {
-                       if (log.isDebugEnabled())
-                               log.debug("No executable path found for key " + key
-                                               + ", using the key as executable name.");
-                       path = key;
-               }
-
-               if (baseDir != null)
-                       path = baseDir + File.separator + path;
-               return path;
-       }
-
-       public String getDeployedSystemId() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public DeploymentData getDeploymentData() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public Distribution getDistribution() {
-               return distribution;
-       }
-
-       public TargetData getTargetData() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public String getBaseDir() {
-               return baseDir;
-       }
-
-       public void setBaseDir(String baseDir) {
-               this.baseDir = baseDir;
-       }
-
-       public Map<String, String> getPaths() {
-               return paths;
-       }
-
-       public void setPaths(Map<String, String> paths) {
-               this.paths = paths;
-       }
-
-       public void setDistribution(Distribution distribution) {
-               this.distribution = distribution;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/VersionedDirSync.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/VersionedDirSync.java
deleted file mode 100644 (file)
index 40f6735..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.argeo.slc.core.deploy;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.deploy.VersioningDriver;
-
-/**
- * Synchronizes an URL to a local directory, taking into account versioning
- * information if possible.
- */
-public class VersionedDirSync implements Runnable {
-       private final static Log log = LogFactory.getLog(VersionedDirSync.class);
-
-       private VersioningDriver versioningDriver;
-       private File dir;
-       private String url;
-       private Boolean clean = false;
-
-       private Boolean changed = null;
-
-       public void run() {
-               changed = null;
-               if (clean) {
-                       try {
-                               log.info("Clean " + dir);
-                               FileUtils.deleteDirectory(dir);
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot delete checkout directory "
-                                               + dir, e);
-                       }
-                       dir.mkdirs();
-               }
-               log.info("Checkout " + url + " to " + dir);
-               changed = versioningDriver.checkout(url, dir, true);
-               if (log.isDebugEnabled())
-                       log.debug("Synchronized " + url + " to " + dir);
-       }
-
-       public void setVersioningDriver(VersioningDriver versioningDriver) {
-               this.versioningDriver = versioningDriver;
-       }
-
-       public void setDir(File dir) {
-               this.dir = dir;
-       }
-
-       public void setUrl(String url) {
-               this.url = url;
-       }
-
-       /** Delete before checkout */
-       public void setClean(Boolean clean) {
-               this.clean = clean;
-       }
-
-       /** Whether last call has changed the directory */
-       public Boolean getChanged() {
-               if (changed == null)
-                       throw new SlcException("Sync has not run");
-               return changed;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/package.html b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/package.html
deleted file mode 100644 (file)
index f3a4c5b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-SLC Deploy: deployment of software systems.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractExecutionFlowGenerator.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractExecutionFlowGenerator.java
deleted file mode 100644 (file)
index 1986115..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.GenericBeanDefinition;
-import org.springframework.core.Ordered;
-import org.springframework.core.PriorityOrdered;
-
-public abstract class AbstractExecutionFlowGenerator implements
-               BeanFactoryPostProcessor, PriorityOrdered {
-       private final Log log = LogFactory.getLog(getClass());
-
-       protected abstract Map<String, BeanDefinition> createExecutionFlowDefinitions(
-                       ConfigurableListableBeanFactory beanFactory);
-
-       public void postProcessBeanFactory(
-                       ConfigurableListableBeanFactory beanFactory) throws BeansException {
-               if (!(beanFactory instanceof BeanDefinitionRegistry)) {
-                       throw new SlcException("Can only work on "
-                                       + BeanDefinitionRegistry.class);
-               }
-
-               Map<String, BeanDefinition> definitions = createExecutionFlowDefinitions(beanFactory);
-
-               for (String beanName : definitions.keySet()) {
-                       if (log.isTraceEnabled())
-                               log.debug("Registering execution flow " + beanName);
-                       ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(
-                                       beanName, definitions.get(beanName));
-               }
-       }
-
-       protected GenericBeanDefinition createDefaultFlowDefinition(
-                       List<Runnable> executables) {
-               GenericBeanDefinition bd = new GenericBeanDefinition();
-               bd.setBeanClass(DefaultExecutionFlow.class);
-
-               MutablePropertyValues mpv = new MutablePropertyValues();
-               mpv.addPropertyValue("executables", executables);
-
-               bd.setPropertyValues(mpv);
-               return bd;
-       }
-
-       public int getOrder() {
-               return Ordered.HIGHEST_PRECEDENCE;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java
deleted file mode 100644 (file)
index 366b8d4..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import org.argeo.slc.execution.ExecutionModule;
-
-@Deprecated
-public abstract class AbstractSpringExecutionModule implements ExecutionModule
-                {
-/*
-       protected ApplicationContext applicationContext;
-
-       protected ExecutionContext executionContext;
-
-       protected ExecutionFlowDescriptorConverter descriptorConverter = new DefaultDescriptorConverter();
-
-       public ExecutionModuleDescriptor getDescriptor() {
-               ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
-               md.setName(getName());
-               md.setVersion(getVersion());
-
-               Map<String, ExecutionFlow> executionFlows = listFlows();
-               for (String name : executionFlows.keySet()) {
-                       ExecutionFlow executionFlow = executionFlows.get(name);
-
-                       Assert.notNull(executionFlow.getName());
-                       Assert.state(name.equals(executionFlow.getName()));
-
-                       ExecutionSpec executionSpec = executionFlow.getExecutionSpec();
-                       Assert.notNull(executionSpec);
-                       Assert.notNull(executionSpec.getName());
-
-                       Map<String, Object> values = new TreeMap<String, Object>();
-                       for (String key : executionSpec.getAttributes().keySet()) {
-                               ExecutionSpecAttribute attribute = executionSpec
-                                               .getAttributes().get(key);
-
-                               if (executionFlow.isSetAsParameter(key)) {
-                                       Object value = executionFlow.getParameter(key);
-                                       if (attribute instanceof PrimitiveSpecAttribute) {
-                                               PrimitiveValue primitiveValue = new PrimitiveValue();
-                                               primitiveValue
-                                                               .setType(((PrimitiveSpecAttribute) attribute)
-                                                                               .getType());
-                                               primitiveValue.setValue(value);
-                                               values.put(key, primitiveValue);
-                                       } else if (attribute instanceof RefSpecAttribute) {
-                                               RefValue refValue = new RefValue();
-                                               if (value instanceof ScopedObject) {
-                                                       refValue.setLabel("RUNTIME "
-                                                                       + value.getClass().getName());
-                                               } else {
-                                                       refValue.setLabel("STATIC "
-                                                                       + value.getClass().getName());
-                                               }
-                                               values.put(key, refValue);
-                                       } else if (attribute instanceof ResourceSpecAttribute) {
-                                               PrimitiveValue primitiveValue = new PrimitiveValue();
-                                               primitiveValue
-                                                               .setType(((ResourceSpecAttribute) attribute)
-                                                                               .getType());
-                                               primitiveValue.setValue(value);
-                                               values.put(key, primitiveValue);
-                                       } else {
-                                               throw new SlcException("Unkown spec attribute type "
-                                                               + attribute.getClass());
-                                       }
-                               }
-
-                       }
-
-                       ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name,
-                                       values, executionSpec);
-                       if (executionFlow.getPath() != null)
-                               efd.setPath(executionFlow.getPath());
-
-                       // Add execution spec if necessary
-                       if (!md.getExecutionSpecs().contains(executionSpec))
-                               md.getExecutionSpecs().add(executionSpec);
-
-                       // Add execution flow
-                       md.getExecutionFlows().add(efd);
-               }
-
-               return md;
-       }
-
-       protected Map<String, ExecutionFlow> listFlows() {
-               GenericBeanFactoryAccessor accessor = new GenericBeanFactoryAccessor(
-                               applicationContext);
-               Map<String, ExecutionFlow> executionFlows = accessor
-                               .getBeansOfType(ExecutionFlow.class);
-               return executionFlows;
-       }
-
-       public void execute(ExecutionFlowDescriptor executionFlowDescriptor) {
-               if (descriptorConverter != null)
-                       executionContext.addVariables(descriptorConverter
-                                       .convertValues(executionFlowDescriptor));
-               ExecutionFlow flow = (ExecutionFlow) applicationContext.getBean(
-                               executionFlowDescriptor.getName(), ExecutionFlow.class);
-               flow.run();
-       }
-
-       public void setApplicationContext(ApplicationContext applicationContext)
-                       throws BeansException {
-               this.applicationContext = applicationContext;
-       }
-
-       public void setExecutionContext(ExecutionContext executionContext) {
-               this.executionContext = executionContext;
-       }
-
-       public void setDescriptorConverter(
-                       ExecutionFlowDescriptorConverter descriptorConverter) {
-               this.descriptorConverter = descriptorConverter;
-       }*/
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgent.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgent.java
deleted file mode 100644 (file)
index c878e24..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.argeo.slc.core.execution;
-
-/** Implements the base methods of an SLC agent. */
-@Deprecated
-public class DefaultAgent extends org.argeo.slc.runtime.DefaultAgent {
-
-       public DefaultAgent() {
-               super();
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgentCli.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgentCli.java
deleted file mode 100644 (file)
index 8e0ccd1..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.argeo.slc.core.execution;
-
-/**
- * Authenticates thread and executes synchronously a command line execution.
- * Reference implementation of args to URIs algorithm.
- */
-@Deprecated
-public class DefaultAgentCli extends org.argeo.slc.runtime.DefaultAgentCli {
-
-       public DefaultAgentCli() {
-               super();
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlow.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlow.java
deleted file mode 100644 (file)
index f3b4eb1..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.util.Map;
-
-import org.argeo.slc.execution.ExecutionSpec;
-import org.springframework.beans.factory.BeanNameAware;
-import org.springframework.beans.factory.InitializingBean;
-
-/** Default implementation of an execution flow. */
-@Deprecated
-public class DefaultExecutionFlow extends org.argeo.slc.runtime.DefaultExecutionFlow
-               implements InitializingBean, BeanNameAware {
-       public DefaultExecutionFlow() {
-               super();
-       }
-
-       public DefaultExecutionFlow(ExecutionSpec executionSpec, Map<String, Object> parameters) {
-               super(executionSpec, parameters);
-       }
-
-       public DefaultExecutionFlow(ExecutionSpec executionSpec) {
-               super(executionSpec);
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               init();
-       }
-
-       public void setBeanName(String name) {
-               setName(name);
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java
deleted file mode 100644 (file)
index 0bdeb53..0000000
+++ /dev/null
@@ -1,350 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
-import org.argeo.slc.execution.ExecutionModuleDescriptor;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.FlowConfigurationException;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValue;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveUtils;
-import org.argeo.slc.primitive.PrimitiveValue;
-import org.springframework.aop.scope.ScopedObject;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.util.StringUtils;
-
-/**
- * Performs conversion in both direction between data exchanged with the agent
- * and the data in the application context.
- */
-public class DefaultExecutionFlowDescriptorConverter implements
-               ExecutionFlowDescriptorConverter, ApplicationContextAware {
-       public final static String REF_VALUE_TYPE_BEAN_NAME = "beanName";
-
-       /** Workaround for https://www.spartadn.com/bugzilla/show_bug.cgi?id=206 */
-       private final static String REF_VALUE_INTERNAL = "[internal]";
-
-       private final static Log log = LogFactory
-                       .getLog(DefaultExecutionFlowDescriptorConverter.class);
-
-       private ApplicationContext applicationContext;
-
-       @SuppressWarnings("unused")
-       public Map<String, Object> convertValues(
-                       ExecutionFlowDescriptor executionFlowDescriptor) {
-               Map<String, Object> values = executionFlowDescriptor.getValues();
-               Map<String, Object> convertedValues = new HashMap<String, Object>();
-               ExecutionSpec executionSpec = executionFlowDescriptor
-                               .getExecutionSpec();
-
-               if (executionSpec == null && log.isTraceEnabled())
-                       log.warn("Execution spec is null for " + executionFlowDescriptor);
-
-               if (values != null && executionSpec != null) {
-                       values: for (String key : values.keySet()) {
-                               ExecutionSpecAttribute attribute = executionSpec
-                                               .getAttributes().get(key);
-
-                               if (attribute == null)
-                                       throw new FlowConfigurationException(
-                                                       "No spec attribute defined for '" + key + "'");
-
-                               if (attribute.getIsConstant())
-                                       continue values;
-
-                               Object value = values.get(key);
-                               if (value instanceof PrimitiveValue) {
-                                       PrimitiveValue primitiveValue = (PrimitiveValue) value;
-                                       // TODO: check class <=> type
-                                       convertedValues.put(key, primitiveValue.getValue());
-                               } else if (value instanceof RefValue) {
-                                       RefValue refValue = (RefValue) value;
-                                       String type = refValue.getType();
-                                       if (REF_VALUE_TYPE_BEAN_NAME.equals(type)) {
-                                               // FIXME: UI should send all information about spec
-                                               // - targetClass
-                                               // - name
-                                               // String executionSpecName = executionSpec.getName();
-                                               // ExecutionSpec localSpec = (ExecutionSpec)
-                                               // applicationContext
-                                               // .getBean(executionSpecName);
-                                               // RefSpecAttribute localAttr = (RefSpecAttribute)
-                                               // localSpec
-                                               // .getAttributes().get(key);
-                                               // Class<?> targetClass = localAttr.getTargetClass();
-                                               //
-                                               // String primitiveType = PrimitiveUtils
-                                               // .classAsType(targetClass);
-                                               String primitiveType = null;
-                                               if (primitiveType != null) {
-                                                       // not active
-                                                       String ref = refValue.getRef();
-                                                       Object obj = PrimitiveUtils.convert(primitiveType,
-                                                                       ref);
-                                                       convertedValues.put(key, obj);
-                                               } else {
-                                                       String ref = refValue.getRef();
-                                                       if (ref != null && !ref.equals(REF_VALUE_INTERNAL)) {
-                                                               Object obj = null;
-                                                               if (applicationContext.containsBean(ref)) {
-                                                                       obj = applicationContext.getBean(ref);
-                                                               } else {
-                                                                       // FIXME: hack in order to pass primitive
-                                                                       obj = ref;
-                                                               }
-                                                               convertedValues.put(key, obj);
-                                                       } else {
-                                                               log.warn("Cannot interpret " + refValue);
-                                                       }
-                                               }
-                                       } else if (PrimitiveUtils.typeAsClass(type) != null) {
-                                               String ref = refValue.getRef();
-                                               Object obj = PrimitiveUtils.convert(type, ref);
-                                               convertedValues.put(key, obj);
-                                       } else {
-                                               throw new FlowConfigurationException(
-                                                               "Ref value type not supported: "
-                                                                               + refValue.getType());
-                                       }
-                               } else {
-                                       // default is to take the value as is
-                                       convertedValues.put(key, value);
-                               }
-                       }
-               }
-               return convertedValues;
-       }
-
-       public void addFlowsToDescriptor(ExecutionModuleDescriptor md,
-                       Map<String, ExecutionFlow> executionFlows) {
-               SortedSet<ExecutionFlowDescriptor> set = new TreeSet<ExecutionFlowDescriptor>(
-                               new ExecutionFlowDescriptorComparator());
-               for (String name : executionFlows.keySet()) {
-                       ExecutionFlow executionFlow = executionFlows.get(name);
-
-                       ExecutionFlowDescriptor efd = getExecutionFlowDescriptor(executionFlow);
-                       ExecutionSpec executionSpec = efd.getExecutionSpec();
-
-                       // Add execution spec if necessary
-                       if (!md.getExecutionSpecs().contains(executionSpec))
-                               md.getExecutionSpecs().add(executionSpec);
-
-                       // Add execution flow
-                       set.add(efd);
-                       // md.getExecutionFlows().add(efd);
-               }
-               md.getExecutionFlows().addAll(set);
-       }
-
-       public ExecutionFlowDescriptor getExecutionFlowDescriptor(
-                       ExecutionFlow executionFlow) {
-               if (executionFlow.getName() == null)
-                       throw new FlowConfigurationException("Flow name is null: "
-                                       + executionFlow);
-               String name = executionFlow.getName();
-
-               ExecutionSpec executionSpec = executionFlow.getExecutionSpec();
-               if (executionSpec == null)
-                       throw new FlowConfigurationException("Execution spec is null: "
-                                       + executionFlow);
-               if (executionSpec.getName() == null)
-                       throw new FlowConfigurationException(
-                                       "Execution spec name is null: " + executionSpec);
-
-               Map<String, Object> values = new TreeMap<String, Object>();
-               for (String key : executionSpec.getAttributes().keySet()) {
-                       ExecutionSpecAttribute attribute = executionSpec.getAttributes()
-                                       .get(key);
-
-                       if (attribute instanceof PrimitiveSpecAttribute) {
-                               if (executionFlow.isSetAsParameter(key)) {
-                                       Object value = executionFlow.getParameter(key);
-                                       PrimitiveValue primitiveValue = new PrimitiveValue();
-                                       primitiveValue.setType(((PrimitiveSpecAttribute) attribute)
-                                                       .getType());
-                                       primitiveValue.setValue(value);
-                                       values.put(key, primitiveValue);
-                               } else {
-                                       // no need to add a primitive value if it is not set,
-                                       // all necessary information is in the spec
-                               }
-                       } else if (attribute instanceof RefSpecAttribute) {
-                               if (attribute.getIsConstant()) {
-                                       values.put(key, new RefValue(REF_VALUE_INTERNAL));
-                               } else
-                                       values.put(
-                                                       key,
-                                                       buildRefValue((RefSpecAttribute) attribute,
-                                                                       executionFlow, key));
-                       } else {
-                               throw new FlowConfigurationException(
-                                               "Unkown spec attribute type " + attribute.getClass());
-                       }
-
-               }
-
-               ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name, null,
-                               values, executionSpec);
-               // Takes description from spring
-               BeanFactory bf = getBeanFactory();
-               if (bf != null) {
-                       BeanDefinition bd = getBeanFactory().getBeanDefinition(name);
-                       efd.setDescription(bd.getDescription());
-               }
-               return efd;
-       }
-
-       protected RefValue buildRefValue(RefSpecAttribute rsa,
-                       ExecutionFlow executionFlow, String key) {
-               RefValue refValue = new RefValue();
-               // FIXME: UI should be able to deal with other types
-               refValue.setType(REF_VALUE_TYPE_BEAN_NAME);
-               Class<?> targetClass = rsa.getTargetClass();
-               String primitiveType = PrimitiveUtils.classAsType(targetClass);
-               if (primitiveType != null) {
-                       if (executionFlow.isSetAsParameter(key)) {
-                               Object value = executionFlow.getParameter(key);
-                               refValue.setRef(value.toString());
-                       }
-                       refValue.setType(primitiveType);
-                       return refValue;
-               } else {
-
-                       if (executionFlow.isSetAsParameter(key)) {
-                               String ref = null;
-                               Object value = executionFlow.getParameter(key);
-                               if (applicationContext == null) {
-                                       log.warn("No application context declared, cannot scan ref value.");
-                                       ref = value.toString();
-                               } else {
-
-                                       // look for a ref to the value
-                                       Map<String, ?> beans = getBeanFactory()
-                                                       .getBeansOfType(targetClass, false, false);
-                                       // TODO: also check scoped beans
-                                       beans: for (String beanName : beans.keySet()) {
-                                               Object obj = beans.get(beanName);
-                                               if (value instanceof ScopedObject) {
-                                                       // don't call methods of the target of the scope
-                                                       if (obj instanceof ScopedObject)
-                                                               if (value == obj) {
-                                                                       ref = beanName;
-                                                                       break beans;
-                                                               }
-                                               } else {
-                                                       if (obj.equals(value)) {
-                                                               ref = beanName;
-                                                               break beans;
-                                                       }
-                                               }
-                                       }
-                               }
-                               if (ref == null) {
-                                       if (log.isTraceEnabled())
-                                               log.trace("Cannot define reference for ref spec attribute "
-                                                               + key
-                                                               + " in "
-                                                               + executionFlow
-                                                               + " ("
-                                                               + rsa
-                                                               + ")."
-                                                               + " If it is an inner bean consider put it frozen.");
-                                       ref = REF_VALUE_INTERNAL;
-                               } else {
-                                       if (log.isTraceEnabled())
-                                               log.trace(ref
-                                                               + " is the reference for ref spec attribute "
-                                                               + key + " in " + executionFlow + " (" + rsa
-                                                               + ")");
-                               }
-                               refValue.setRef(ref);
-                       }
-                       return refValue;
-               }
-       }
-
-       /** @return can be null */
-       private ConfigurableListableBeanFactory getBeanFactory() {
-               if (applicationContext == null)
-                       return null;
-               return ((ConfigurableApplicationContext) applicationContext)
-                               .getBeanFactory();
-       }
-
-       /** Must be use within the execution application context */
-       public void setApplicationContext(ApplicationContext applicationContext)
-                       throws BeansException {
-               this.applicationContext = applicationContext;
-       }
-
-       private static class ExecutionFlowDescriptorComparator implements
-                       Comparator<ExecutionFlowDescriptor> {
-               @SuppressWarnings("deprecation")
-               public int compare(ExecutionFlowDescriptor o1,
-                               ExecutionFlowDescriptor o2) {
-                       // TODO: write unit tests for this
-
-                       String name1 = o1.getName();
-                       String name2 = o2.getName();
-
-                       String path1 = o1.getPath();
-                       String path2 = o2.getPath();
-
-                       // Check whether name include path
-                       int lastIndex1 = name1.lastIndexOf('/');
-                       // log.debug(name1+", "+lastIndex1);
-                       if (!StringUtils.hasText(path1) && lastIndex1 >= 0) {
-                               path1 = name1.substring(0, lastIndex1);
-                               name1 = name1.substring(lastIndex1 + 1);
-                       }
-
-                       int lastIndex2 = name2.lastIndexOf('/');
-                       if (!StringUtils.hasText(path2) && lastIndex2 >= 0) {
-                               path2 = name2.substring(0, lastIndex2);
-                               name2 = name2.substring(lastIndex2 + 1);
-                       }
-
-                       // Perform the actual comparison
-                       if (StringUtils.hasText(path1) && StringUtils.hasText(path2)) {
-                               if (path1.equals(path2))
-                                       return name1.compareTo(name2);
-                               else if (path1.startsWith(path2))
-                                       return -1;
-                               else if (path2.startsWith(path1))
-                                       return 1;
-                               else
-                                       return path1.compareTo(path2);
-                       } else if (!StringUtils.hasText(path1)
-                                       && StringUtils.hasText(path2)) {
-                               return 1;
-                       } else if (StringUtils.hasText(path1)
-                                       && !StringUtils.hasText(path2)) {
-                               return -1;
-                       } else if (!StringUtils.hasText(path1)
-                                       && !StringUtils.hasText(path2)) {
-                               return name1.compareTo(name2);
-                       } else {
-                               return 0;
-                       }
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java
deleted file mode 100644 (file)
index e603f71..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValueChoice;
-import org.springframework.beans.factory.BeanNameAware;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ConfigurableApplicationContext;
-
-/** Spring based implementation of execution specifications. */
-@Deprecated
-public class DefaultExecutionSpec extends org.argeo.slc.runtime.DefaultExecutionSpec
-               implements BeanNameAware, ApplicationContextAware, InitializingBean {
-       private static final long serialVersionUID = 5159882223926926539L;
-       private final static Log log = LogFactory.getLog(DefaultExecutionSpec.class);
-       private transient ApplicationContext applicationContext;
-
-       public DefaultExecutionSpec() {
-               super();
-       }
-
-       public void setBeanName(String name) {
-               setName(name);
-       }
-
-       private ConfigurableListableBeanFactory getBeanFactory() {
-               return ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
-       }
-
-       public void setApplicationContext(ApplicationContext applicationContext) {
-               this.applicationContext = applicationContext;
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               if (getDescription() == null) {
-                       try {
-                               setDescription(getBeanFactory().getBeanDefinition(getName()).getDescription());
-                       } catch (NoSuchBeanDefinitionException e) {
-                               // silent
-                       }
-               }
-
-               for (String key : getAttributes().keySet()) {
-                       ExecutionSpecAttribute attr = getAttributes().get(key);
-                       if (attr instanceof RefSpecAttribute) {
-                               RefSpecAttribute rsa = (RefSpecAttribute) attr;
-                               if (rsa.getChoices() == null) {
-                                       List<RefValueChoice> choices = buildRefValueChoices(rsa);
-                                       rsa.setChoices(choices);
-                               }
-                               if (log.isTraceEnabled())
-                                       log.debug("Spec attr " + key + " has " + rsa.getChoices().size() + " choices");
-                       }
-               }
-       }
-
-       /**
-        * Generates a list of ref value choices based on the bean available in the
-        * application context.
-        */
-       protected List<RefValueChoice> buildRefValueChoices(RefSpecAttribute rsa) {
-               List<RefValueChoice> choices = new ArrayList<RefValueChoice>();
-               if (applicationContext == null) {
-                       log.warn("No application context declared," + " cannot scan ref value choices.");
-                       return choices;
-               }
-
-               beanNames: for (String beanName : getBeanFactory().getBeanNamesForType(rsa.getTargetClass(), true, false)) {
-
-                       // Since Spring 3, systemProperties is implicitly defined but has no
-                       // bean definition
-                       if (beanName.equals("systemProperties"))
-                               continue beanNames;
-
-                       BeanDefinition bd = getBeanFactory().getBeanDefinition(beanName);
-                       RefValueChoice choice = new RefValueChoice();
-                       choice.setName(beanName);
-                       choice.setDescription(bd.getDescription());
-                       if (log.isTraceEnabled())
-                               log.debug("Found choice " + beanName + " for " + rsa);
-
-                       choices.add(choice);
-
-               }
-               return choices;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionAspect.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionAspect.java
deleted file mode 100644 (file)
index 2fb2348..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionStack;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-
-@Aspect
-/** Aspect intercepting calls on execution flows and contexts. */
-public class ExecutionAspect {
-       private final static Log log = LogFactory.getLog(ExecutionAspect.class);
-
-       private ExecutionStack executionStack;
-       private ExecutionContext executionContext;
-
-       @Around("flowExecution()")
-       public void aroundFlow(ProceedingJoinPoint pjp) throws Throwable {
-               // IMPORTANT: Make sure that the execution context is called before the
-               // execution stack
-               executionContext.getUuid();
-
-               ExecutionFlow executionFlow = (ExecutionFlow) pjp.getTarget();
-               executionStack.enterFlow(executionFlow);
-               executionContext.setVariable(ExecutionContext.VAR_FLOW_ID,
-                               executionStack.getCurrentStackLevelUuid());
-               executionContext.setVariable(ExecutionContext.VAR_FLOW_NAME,
-                               executionFlow.getName());
-
-               logStackEvent("=> ", executionFlow);
-               try {
-                       // Actually execute the flow
-                       pjp.proceed();
-               } finally {
-                       logStackEvent("<= ", executionFlow);
-                       executionStack.leaveFlow(executionFlow);
-               }
-       }
-
-       @Around("getVariable()")
-       public Object aroundGetVariable(ProceedingJoinPoint pjp) throws Throwable {
-               Object obj = pjp.proceed();
-               // if the variable was not found, look in the stack starting at the
-               // upper flows
-               if (obj == null) {
-                       String key = pjp.getArgs()[0].toString();
-                       obj = executionStack.findLocalVariable(key);
-               }
-               return obj;
-       }
-
-       @Pointcut("execution(void org.argeo.slc.execution.ExecutionFlow.run())")
-       public void flowExecution() {
-       }
-
-       @Pointcut("execution(* org.argeo.slc.execution.ExecutionContext.getVariable(..))")
-       public void getVariable() {
-       }
-
-       public void setExecutionStack(ExecutionStack executionStack) {
-               this.executionStack = executionStack;
-       }
-
-       public void setExecutionContext(ExecutionContext executionContext) {
-               this.executionContext = executionContext;
-       }
-
-       protected void logStackEvent(String symbol, ExecutionFlow executionFlow) {
-               Integer stackSize = executionStack.getStackSize();
-               if (log.isTraceEnabled())
-                       log.debug(depthSpaces(stackSize) + symbol + executionFlow + " #"
-                                       + executionStack.getCurrentStackLevelUuid() + ", depth="
-                                       + stackSize);
-               if (log.isDebugEnabled())
-                       log.debug(depthSpaces(stackSize) + symbol + executionFlow);
-       }
-
-       protected void logRunnableExecution(ExecutionFlow executionFlow,
-                       Runnable runnable) {
-               Integer stackSize = executionStack.getStackSize();
-               if (log.isDebugEnabled())
-                       log.debug(depthSpaces(stackSize + 1)
-                                       + runnable.getClass().getSimpleName() + " in "
-                                       + executionFlow);
-       }
-
-       private String depthSpaces(int depth) {
-               StringBuffer buf = new StringBuffer(depth * 2);
-               for (int i = 0; i < depth; i++)
-                       buf.append("  ");
-               return buf.toString();
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java
deleted file mode 100644 (file)
index 7510504..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.beans.PropertyDescriptor;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.InstantiationManager;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.PropertyValue;
-import org.springframework.beans.PropertyValues;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
-import org.springframework.beans.factory.config.TypedStringValue;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.ManagedMap;
-import org.springframework.beans.factory.support.ManagedSet;
-import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
-
-/**
- * Spring post processor which ensures that execution parameters are properly
- * set. It is used at two levels: first during instantiation for instantiation
- * parameters which allow to implement templates, then at runtime in order to
- * interpret @{} placeholders when object of scope execution are instantiated.
- */
-public class ExecutionParameterPostProcessor extends
-               InstantiationAwareBeanPostProcessorAdapter {
-
-       private final static Log log = LogFactory
-                       .getLog(ExecutionParameterPostProcessor.class);
-
-       private ExecutionContext executionContext;
-       private InstantiationManager instantiationManager;
-
-       private String placeholderPrefix = "@{";
-       private String placeholderSuffix = "}";
-       private String nullValue;
-
-       @Override
-       public PropertyValues postProcessPropertyValues(PropertyValues pvs,
-                       PropertyDescriptor[] pds, Object bean, String beanName)
-                       throws BeansException {
-
-               // TODO: resolve at execution only if scope is execution
-               // TODO: deal with placeholders in RuntimeBeanReference and
-               // RuntimeBeanNameReference
-
-               MutablePropertyValues newPvs = new MutablePropertyValues();
-
-               boolean changesOccured = false;
-
-               for (PropertyValue pv : pvs.getPropertyValues()) {
-                       Object convertedValue = resolveValue(beanName, bean, pv.getValue());
-                       newPvs.addPropertyValue(new PropertyValue(pv, convertedValue));
-                       if (convertedValue != pv.getValue()) {
-                               changesOccured = true;
-                       }
-               }
-
-               return changesOccured ? newPvs : pvs;
-       }
-
-       @Override
-       public boolean postProcessAfterInstantiation(Object bean, String beanName)
-                       throws BeansException {
-               if (bean instanceof ExecutionFlow)
-                       instantiationManager.flowInitializationStarted(
-                                       (ExecutionFlow) bean, beanName);
-               return true;
-       }
-
-       @Override
-       public Object postProcessAfterInitialization(Object bean, String beanName)
-                       throws BeansException {
-               if (bean instanceof ExecutionFlow)
-                       instantiationManager.flowInitializationFinished(
-                                       (ExecutionFlow) bean, beanName);
-               return bean;
-       }
-
-       protected String resolvePlaceholder(Object bean, String placeholder) {
-               if (instantiationManager.isInFlowInitialization())
-                       return instantiationManager.getInitializingFlowParameter(
-                                       placeholder).toString();
-
-               else {// execution
-                               // next call fail if no execution context available
-                       Object obj = executionContext.getVariable(placeholder);
-                       if (obj != null) {
-                               return obj.toString();
-                       }
-               }
-
-               return null;
-       }
-
-       public Object resolveValue(String beanName, Object bean, Object value) {
-               if (value instanceof TypedStringValue) {
-                       TypedStringValue tsv = (TypedStringValue) value;
-                       String originalValue = tsv.getValue();
-
-                       String convertedValue = resolveString(beanName, bean, originalValue);
-                       if (convertedValue == null)
-                               return null;
-                       return convertedValue.equals(originalValue) ? value
-                                       : new TypedStringValue(convertedValue);
-               } else if (value instanceof String) {
-                       String originalValue = value.toString();
-                       String convertedValue = resolveString(beanName, bean, originalValue);
-                       if (convertedValue == null)
-                               return null;
-                       return convertedValue.equals(originalValue) ? value
-                                       : convertedValue;
-               } else if (value instanceof ManagedMap) {
-                       Map<?, ?> mapVal = (Map<?, ?>) value;
-
-                       Map<Object, Object> newContent = new ManagedMap<Object, Object>();
-                       boolean entriesModified = false;
-                       for (Iterator<?> it = mapVal.entrySet().iterator(); it.hasNext();) {
-                               Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
-                               Object key = entry.getKey();
-                               int keyHash = (key != null ? key.hashCode() : 0);
-                               Object newKey = resolveValue(beanName, bean, key);
-                               int newKeyHash = (newKey != null ? newKey.hashCode() : 0);
-                               Object val = entry.getValue();
-                               Object newVal = resolveValue(beanName, bean, val);
-                               newContent.put(newKey, newVal);
-                               entriesModified = entriesModified
-                                               || (newVal != val || newKey != key || newKeyHash != keyHash);
-                       }
-
-                       return entriesModified ? newContent : value;
-               } else if (value instanceof ManagedList) {
-                       List<?> listVal = (List<?>) value;
-                       List<Object> newContent = new ManagedList<Object>();
-                       boolean valueModified = false;
-
-                       for (int i = 0; i < listVal.size(); i++) {
-                               Object elem = listVal.get(i);
-                               Object newVal = resolveValue(beanName, bean, elem);
-                               newContent.add(newVal);
-                               if (!ObjectUtils.nullSafeEquals(newVal, elem)) {
-                                       valueModified = true;
-                               }
-                       }
-                       return valueModified ? newContent : value;
-               } else if (value instanceof ManagedSet) {
-                       Set<?> setVal = (Set<?>) value;
-                       Set<Object> newContent = new ManagedSet<Object>();
-                       boolean entriesModified = false;
-                       for (Iterator<?> it = setVal.iterator(); it.hasNext();) {
-                               Object elem = it.next();
-                               int elemHash = (elem != null ? elem.hashCode() : 0);
-                               Object newVal = resolveValue(beanName, bean, elem);
-                               int newValHash = (newVal != null ? newVal.hashCode() : 0);
-                               newContent.add(newVal);
-                               entriesModified = entriesModified
-                                               || (newVal != elem || newValHash != elemHash);
-                       }
-                       return entriesModified ? newContent : value;
-               } else {
-                       // log.debug(beanName + ": " + value.getClass() + " : " + value);
-                       return value;
-               }
-
-       }
-
-       private String resolveString(String beanName, Object bean, String strVal) {
-               // in case <null/> is passed
-               if (strVal == null)
-                       return null;
-
-               String value = parseStringValue(bean, strVal, new HashSet<String>());
-
-               if (value == null)
-                       throw new SlcException("Could not resolve placeholder '" + strVal
-                                       + "' in bean '" + beanName + "'");
-
-               return (value.equals(nullValue) ? null : value);
-       }
-
-       public void setPlaceholderPrefix(String placeholderPrefix) {
-               this.placeholderPrefix = placeholderPrefix;
-       }
-
-       public void setPlaceholderSuffix(String placeholderSuffix) {
-               this.placeholderSuffix = placeholderSuffix;
-       }
-
-       public void setNullValue(String nullValue) {
-               this.nullValue = nullValue;
-       }
-
-       public void setInstantiationManager(
-                       InstantiationManager instantiationManager) {
-               this.instantiationManager = instantiationManager;
-       }
-
-       public void setExecutionContext(ExecutionContext executionContext) {
-               this.executionContext = executionContext;
-       }
-
-       //
-       // Following methods hacked from the internals of
-       // PropertyPlaceholderConfigurer
-       //
-
-       protected String parseStringValue(Object bean, String strVal,
-                       Set<String> visitedPlaceholders)
-                       throws BeanDefinitionStoreException {
-
-               // in case <null/> is passed
-               if (strVal == null)
-                       return null;
-
-               StringBuffer buf = new StringBuffer(strVal);
-
-               int startIndex = strVal.indexOf(placeholderPrefix);
-               while (startIndex != -1) {
-                       int endIndex = findPlaceholderEndIndex(buf, startIndex);
-                       if (endIndex != -1) {
-                               String placeholder = buf.substring(startIndex
-                                               + placeholderPrefix.length(), endIndex);
-                               if (!visitedPlaceholders.add(placeholder)) {
-                                       throw new BeanDefinitionStoreException(
-                                                       "Circular placeholder reference '" + placeholder
-                                                                       + "' in property definitions");
-                               }
-                               // Recursive invocation, parsing placeholders contained in
-                               // the placeholder key.
-                               placeholder = parseStringValue(bean, placeholder,
-                                               visitedPlaceholders);
-                               // Now obtain the value for the fully resolved key...
-                               String propVal = resolvePlaceholder(bean, placeholder);
-                               if (propVal != null) {
-                                       // Recursive invocation, parsing placeholders contained
-                                       // in the
-                                       // previously resolved placeholder value.
-                                       propVal = parseStringValue(bean, propVal,
-                                                       visitedPlaceholders);
-                                       buf.replace(startIndex,
-                                                       endIndex + placeholderSuffix.length(), propVal);
-                                       if (log.isTraceEnabled()) {
-                                               log.trace("Resolved placeholder '" + placeholder + "'");
-                                       }
-                                       startIndex = buf.indexOf(placeholderPrefix, startIndex
-                                                       + propVal.length());
-                               } else {
-                                       throw new BeanDefinitionStoreException(
-                                                       "Could not resolve placeholder '" + placeholder
-                                                                       + "'");
-                               }
-                               visitedPlaceholders.remove(placeholder);
-                       } else {
-                               startIndex = -1;
-                       }
-               }
-
-               return buf.toString();
-       }
-
-       private int findPlaceholderEndIndex(CharSequence buf, int startIndex) {
-               int index = startIndex + placeholderPrefix.length();
-               int withinNestedPlaceholder = 0;
-               while (index < buf.length()) {
-                       if (StringUtils.substringMatch(buf, index, placeholderSuffix)) {
-                               if (withinNestedPlaceholder > 0) {
-                                       withinNestedPlaceholder--;
-                                       index = index + placeholderSuffix.length();
-                               } else {
-                                       return index;
-                               }
-                       } else if (StringUtils
-                                       .substringMatch(buf, index, placeholderPrefix)) {
-                               withinNestedPlaceholder++;
-                               index = index + placeholderPrefix.length();
-                       } else {
-                               index++;
-                       }
-               }
-               return -1;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResources.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResources.java
deleted file mode 100644 (file)
index 772330a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-
-import org.springframework.core.io.Resource;
-
-/** Provides write access to resources during execution */
-public interface ExecutionResources {
-       /** The base directory where this execution can write */
-       public File getWritableBaseDir();
-
-       /** Allocates a local file in the writable area and return it as a resource. */
-       public Resource getWritableResource(String relativePath);
-
-       /**
-        * Allocates a local file in the writable area and return it as a fully
-        * qualified OS path.
-        */
-       public String getWritableOsPath(String relativePath);
-
-       /**
-        * Allocates a local file in the writable area and return it as a
-        * {@link File}.
-        */
-       public File getWritableOsFile(String relativePath);
-
-       /**
-        * Returns the resource as a file path. If the resource is not writable it
-        * is copied as a file in the writable area and the path to this local file
-        * is returned.
-        */
-       public String getAsOsPath(Resource resource, Boolean overwrite);
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResourcesFactoryBean.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResourcesFactoryBean.java
deleted file mode 100644 (file)
index b217c3b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.core.io.Resource;
-import org.springframework.util.Assert;
-
-/** Workaround when execution placedholders needs to be passed. */
-public class ExecutionResourcesFactoryBean implements FactoryBean<Resource> {
-       private ExecutionResources executionResources;
-       private String relativePath;
-
-       public Resource getObject() throws Exception {
-               Assert.notNull(executionResources, "executionResources is null");
-               Assert.notNull(relativePath, "relativePath is null");
-               return executionResources.getWritableResource(relativePath);
-       }
-
-       public Class<? extends Object> getObjectType() {
-               return Resource.class;
-       }
-
-       public boolean isSingleton() {
-               return true;
-       }
-
-       public void setExecutionResources(ExecutionResources executionResources) {
-               this.executionResources = executionResources;
-       }
-
-       public void setRelativePath(String relativePath) {
-               this.relativePath = relativePath;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionScope.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionScope.java
deleted file mode 100644 (file)
index 19296ab..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionStack;
-import org.argeo.slc.runtime.ExecutionThread;
-import org.springframework.beans.factory.ObjectFactory;
-import org.springframework.beans.factory.config.Scope;
-
-/**
- * When Spring beans are instantiated with this scope, the same instance is
- * reused across an execution.
- */
-public class ExecutionScope implements Scope {
-       private final static Log log = LogFactory.getLog(ExecutionScope.class);
-
-       private final ThreadLocal<ExecutionStack> executionStack = new ThreadLocal<ExecutionStack>();
-       public final ThreadLocal<String> executionStackBeanName = new ThreadLocal<String>();
-
-       private final ThreadLocal<ExecutionContext> executionContext = new ThreadLocal<ExecutionContext>();
-       private final ThreadLocal<String> executionContextBeanName = new ThreadLocal<String>();
-
-       public Object get(String name, ObjectFactory<?> objectFactory) {
-               if (log.isTraceEnabled())
-                       log.debug("Get execution scoped bean " + name);
-
-               // shortcuts
-               if (executionStackBeanName.get() != null
-                               && name.equals(executionStackBeanName.get())) {
-                       return executionStack.get();
-               }
-
-               if (executionContextBeanName.get() != null
-                               && name.equals(executionContextBeanName.get())) {
-                       return executionContext.get();
-               }
-
-               // execution context must be defined first
-               if (executionContext.get() == null) {
-                       Object obj = objectFactory.getObject();
-                       if (obj instanceof ExecutionContext) {
-                               return dealWithSpecialScopedObject(name, executionContext,
-                                               executionContextBeanName, (ExecutionContext) obj);
-                       } else {
-                               // TODO: use execution context wrapper
-                               throw new SlcException("No execution context has been defined.");
-                       }
-               }
-
-               // for other scoped objects, an executions stack must be available
-               if (executionStack.get() == null) {
-                       Object obj = objectFactory.getObject();
-                       if (obj instanceof ExecutionStack) {
-                               return dealWithSpecialScopedObject(name, executionStack,
-                                               executionStackBeanName, (ExecutionStack) obj);
-                       } else {
-                               throw new SlcException("No execution stack has been defined.");
-                       }
-               }
-
-               // see if the execution stack already knows the object
-               Object obj = executionStack.get().findScopedObject(name);
-               if (obj == null) {
-                       obj = objectFactory.getObject();
-                       if (obj instanceof ExecutionContext)
-                               throw new SlcException(
-                                               "Only one execution context can be defined per thread");
-                       if (obj instanceof ExecutionStack)
-                               throw new SlcException(
-                                               "Only one execution stack can be defined per thread");
-
-                       checkForbiddenClasses(obj);
-
-                       executionStack.get().addScopedObject(name, obj);
-               }
-               return obj;
-
-       }
-
-       protected <T> T dealWithSpecialScopedObject(String name,
-                       ThreadLocal<T> threadLocal,
-                       ThreadLocal<String> threadLocalBeanName, T newObj) {
-
-               T obj = threadLocal.get();
-               if (obj == null) {
-                       obj = newObj;
-                       threadLocal.set(obj);
-                       threadLocalBeanName.set(name);
-                       if (log.isTraceEnabled()) {
-                               log.debug(obj.getClass() + " instantiated. (beanName=" + name
-                                               + ")");
-                       }
-                       return obj;
-               } else {
-                       throw new SlcException("Only one scoped " + obj.getClass()
-                                       + " can be defined per thread");
-               }
-
-       }
-
-       protected void checkForbiddenClasses(Object obj) {
-               Class<?> clss = obj.getClass();
-               if (ExecutionFlow.class.isAssignableFrom(clss)
-                               || ExecutionSpec.class.isAssignableFrom(clss)) {
-                       throw new UnsupportedException("Execution scoped object", clss);
-               }
-       }
-
-       public String getConversationId() {
-               // TODO: is it the most relevant?
-               return executionContext.get().getUuid();
-       }
-
-       public void registerDestructionCallback(String name, Runnable callback) {
-               if (Thread.currentThread() instanceof ExecutionThread) {
-                       ExecutionThread executionThread = (ExecutionThread) Thread
-                                       .currentThread();
-                       executionThread.registerDestructionCallback(name, callback);
-               }
-       }
-
-       public Object remove(String name) {
-               if (log.isDebugEnabled())
-                       log.debug("Remove object " + name);
-               throw new UnsupportedOperationException();
-       }
-
-       public Object resolveContextualObject(String key) {
-               return executionContext.get().getVariable(key);
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/FileExecutionResources.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/FileExecutionResources.java
deleted file mode 100644 (file)
index 41fb694..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionContext;
-import org.springframework.core.io.FileSystemResource;
-import org.springframework.core.io.Resource;
-import org.springframework.util.Assert;
-
-/** Implements write access to resources based on standard Java {@link File} */
-public class FileExecutionResources implements ExecutionResources {
-       private final static Log log = LogFactory
-                       .getLog(FileExecutionResources.class);
-       protected final static String DEFAULT_EXECUTION_RESOURCES_DIRNAME = "executionResources";
-       public final static String DEFAULT_EXECUTION_RESOURCES_TMP_PATH = System
-                       .getProperty("java.io.tmpdir")
-                       + File.separator
-                       + System.getProperty("user.name")
-                       + File.separator
-                       + "slc"
-                       + File.separator + DEFAULT_EXECUTION_RESOURCES_DIRNAME;
-
-       private File baseDir;
-       private ExecutionContext executionContext;
-       private String prefixDatePattern = "yyMMdd_HHmmss_SSS";
-       private SimpleDateFormat sdf = null;
-
-       private Boolean withExecutionSubdirectory = true;
-
-       public FileExecutionResources() {
-               // Default base directory
-               String osgiInstanceArea = System.getProperty("osgi.instance.area");
-               String osgiInstanceAreaDefault = System
-                               .getProperty("osgi.instance.area.default");
-
-               if (osgiInstanceArea != null) {
-                       // within OSGi with -data specified
-                       osgiInstanceArea = removeFilePrefix(osgiInstanceArea);
-                       baseDir = new File(osgiInstanceArea + File.separator
-                                       + DEFAULT_EXECUTION_RESOURCES_DIRNAME);
-               } else if (osgiInstanceAreaDefault != null) {
-                       // within OSGi without -data specified
-                       osgiInstanceAreaDefault = removeFilePrefix(osgiInstanceAreaDefault);
-                       baseDir = new File(osgiInstanceAreaDefault + File.separator
-                                       + DEFAULT_EXECUTION_RESOURCES_DIRNAME);
-               } else {// outside OSGi
-                       baseDir = new File(DEFAULT_EXECUTION_RESOURCES_TMP_PATH);
-               }
-       }
-
-       protected SimpleDateFormat sdf() {
-               // Lazy init in case prefix has been externally set
-               if (sdf == null)
-                       sdf = new SimpleDateFormat(prefixDatePattern);
-               return sdf;
-       }
-
-       public Resource getWritableResource(String relativePath) {
-               File file = getFile(relativePath);
-               File parentDir = file.getParentFile();
-
-               if (!parentDir.exists()) {
-                       // Creates if necessary
-                       if (log.isTraceEnabled())
-                               log.trace("Creating parent directory " + parentDir);
-                       parentDir.mkdirs();
-               }
-               Resource resource = new FileSystemResource(file);
-
-               if (log.isTraceEnabled())
-                       log.trace("Returns writable resource " + resource);
-               return resource;
-       }
-
-       public String getWritableOsPath(String relativePath) {
-               try {
-                       return getFile(relativePath).getCanonicalPath();
-               } catch (IOException e) {
-                       throw new SlcException("Cannot find canonical path", e);
-               }
-       }
-
-       public File getWritableOsFile(String relativePath) {
-               return getFile(relativePath);
-       }
-
-       public String getAsOsPath(Resource resource, Boolean overwrite) {
-               File file = fileFromResource(resource);
-               if (file != null)
-                       try {
-                               if (log.isTraceEnabled())
-                                       log.debug("Directly interpret " + resource + " as OS file "
-                                                       + file);
-                               return file.getCanonicalPath();
-                       } catch (IOException e1) {
-                               // silent
-                       }
-
-               if (log.isTraceEnabled())
-                       log.trace("Resource " + resource
-                                       + " is not available on the file system. Retrieving it...");
-
-               InputStream in = null;
-               OutputStream out = null;
-               try {
-                       String path = resource.getURL().getPath();
-                       file = getFile(path);
-                       if (file.exists() && !overwrite)
-                               return file.getCanonicalPath();
-
-                       file.getParentFile().mkdirs();
-                       in = resource.getInputStream();
-                       out = new FileOutputStream(file);
-                       IOUtils.copy(in, out);
-                       if (log.isDebugEnabled())
-                               log.debug("Retrieved " + resource + " to OS file " + file);
-                       return file.getCanonicalPath();
-               } catch (IOException e) {
-                       throw new SlcException("Could not make resource " + resource
-                                       + " an OS file.", e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-                       IOUtils.closeQuietly(out);
-               }
-       }
-
-       /**
-        * Extract the underlying file from the resource.
-        * 
-        * @return the file or null if no files support this resource.
-        */
-       protected File fileFromResource(Resource resource) {
-               try {
-                       return resource.getFile();
-               } catch (IOException e) {
-                       return null;
-               }
-
-       }
-
-       protected File getFile(String relativePath) {
-               File writableBaseDir = getWritableBaseDir();
-               return new File(writableBaseDir.getPath() + File.separator
-                               + relativePath.replace('/', File.separatorChar));
-       }
-
-       public File getWritableBaseDir() {
-               if (withExecutionSubdirectory) {
-                       Date executionContextCreationDate = (Date) executionContext
-                                       .getVariable(ExecutionContext.VAR_EXECUTION_CONTEXT_CREATION_DATE);
-                       Assert.notNull(executionContext, "execution context is null");
-                       String path = baseDir.getPath() + File.separator
-                                       + sdf().format(executionContextCreationDate);
-                       // TODO write execution id somewhere? like in a txt file
-                       return new File(path);
-               } else {
-                       return baseDir;
-               }
-       }
-
-       protected String removeFilePrefix(String url) {
-               if (url.startsWith("file:"))
-                       return url.substring("file:".length());
-               else if (url.startsWith("reference:file:"))
-                       return url.substring("reference:file:".length());
-               else
-                       return url;
-       }
-
-       public void setBaseDir(File baseDir) {
-               this.baseDir = baseDir;
-       }
-
-       public void setExecutionContext(ExecutionContext executionContext) {
-               this.executionContext = executionContext;
-       }
-
-       public void setPrefixDatePattern(String prefixDatePattern) {
-               this.prefixDatePattern = prefixDatePattern;
-       }
-
-       public File getBaseDir() {
-               return baseDir;
-       }
-
-       public ExecutionContext getExecutionContext() {
-               return executionContext;
-       }
-
-       public String getPrefixDatePattern() {
-               return prefixDatePattern;
-       }
-
-       /** Default is true. */
-       public void setWithExecutionSubdirectory(Boolean withExecutionSubdirectory) {
-               this.withExecutionSubdirectory = withExecutionSubdirectory;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/MapExecutionContext.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/MapExecutionContext.java
deleted file mode 100644 (file)
index 5a96405..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionStack;
-import org.springframework.beans.BeanWrapper;
-import org.springframework.beans.BeanWrapperImpl;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-public class MapExecutionContext implements ExecutionContext,
-               ApplicationContextAware {
-       private final Map<String, Object> variables = Collections
-                       .synchronizedMap(new HashMap<String, Object>());
-
-       private final String uuid;
-
-       private ApplicationContext applicationContext;
-       private ExecutionStack executionStack;
-
-       public MapExecutionContext() {
-               uuid = UUID.randomUUID().toString();
-               variables.put(VAR_EXECUTION_CONTEXT_ID, uuid);
-               variables.put(VAR_EXECUTION_CONTEXT_CREATION_DATE, new Date());
-       }
-
-       public void setVariable(String key, Object value) {
-               // check if we do not refer to a bean
-               int lastInd = key.lastIndexOf('.');
-               if (applicationContext != null && lastInd > 0) {
-                       String beanName = key.substring(0, lastInd);
-                       String propertyName = key.substring(lastInd + 1);
-                       if (applicationContext.containsBean(beanName)) {
-                               BeanWrapper beanWrapper = new BeanWrapperImpl(
-                                               applicationContext.getBean(beanName));
-                               if (!beanWrapper.isWritableProperty(propertyName))
-                                       throw new SlcException("No writable property "
-                                                       + propertyName + " in bean " + beanName);
-                               beanWrapper.setPropertyValue(propertyName, value);
-                       }
-               }
-
-               variables.put(key, value);
-       }
-
-       public Object getVariable(String key) {
-               // check if we do not refer to a bean
-               int lastInd = key.lastIndexOf('.');
-               if (applicationContext != null && lastInd > 0) {
-                       String beanName = key.substring(0, lastInd);
-                       String propertyName = key.substring(lastInd + 1);
-                       if (applicationContext.containsBean(beanName)) {
-                               BeanWrapper beanWrapper = new BeanWrapperImpl(
-                                               applicationContext.getBean(beanName));
-                               if (!beanWrapper.isReadableProperty(propertyName))
-                                       throw new SlcException("No readable property "
-                                                       + propertyName + " in bean " + beanName);
-                               Object obj = beanWrapper.getPropertyValue(propertyName);
-                               return obj;
-                       }
-               }
-
-               Object value = variables.get(key);
-               // try system property in last resort
-               if (value == null)
-                       value = System.getProperty(key);
-
-               // if the variable was not found, look in the stack starting at the
-               // upper flows
-               if (value == null) {
-                       value = executionStack.findLocalVariable(key);
-               }
-               return value;
-       }
-
-       public String getUuid() {
-               return uuid;
-       }
-
-       @Override
-       public void beforeFlow(ExecutionFlow executionFlow) {
-               // getUuid();
-               executionStack.enterFlow(executionFlow);
-               setVariable(ExecutionContext.VAR_FLOW_ID,
-                               executionStack.getCurrentStackLevelUuid());
-               setVariable(ExecutionContext.VAR_FLOW_NAME, executionFlow.getName());
-       }
-
-       @Override
-       public void afterFlow(ExecutionFlow executionFlow) {
-               executionStack.leaveFlow(executionFlow);
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               if (obj instanceof ExecutionContext)
-                       return uuid.equals(((ExecutionContext) obj).getUuid());
-               return false;
-       }
-
-       @Override
-       public String toString() {
-               return getClass().getSimpleName() + "#" + uuid;
-       }
-
-       public void setApplicationContext(ApplicationContext applicationContext)
-                       throws BeansException {
-               this.applicationContext = applicationContext;
-       }
-
-       public void setExecutionStack(ExecutionStack executionStack) {
-               this.executionStack = executionStack;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/OsFileFactoryBean.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/OsFileFactoryBean.java
deleted file mode 100644 (file)
index 7cd6e20..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.core.io.Resource;
-import org.springframework.util.Assert;
-
-/** Retrieve an OS File from the given resource. */
-public class OsFileFactoryBean implements FactoryBean<String> {
-       private ExecutionResources executionResources;
-       private Resource resource;
-       private Boolean overwrite = false;
-
-       /** Return an existing file on the file system. */
-       public String getObject() throws Exception {
-               Assert.notNull(executionResources, "executionResources is null");
-               Assert.notNull(resource, "resource is null");
-               return executionResources.getAsOsPath(resource, overwrite);
-       }
-
-       /** Return {@link Object} because CGLIB is unable to proxy {@link File}. */
-       public Class<? extends Object> getObjectType() {
-               return CharSequence.class;
-       }
-
-       public boolean isSingleton() {
-               return false;
-       }
-
-       /** The execution resources object. */
-       public void setExecutionResources(ExecutionResources executionResources) {
-               this.executionResources = executionResources;
-       }
-
-       /** The resource to access. */
-       public void setResource(Resource resource) {
-               this.resource = resource;
-       }
-
-       /**
-        * Whether to overwrite the resource if it already exists. Default is
-        * <code>false</code>.
-        */
-       public void setOverwrite(Boolean overwrite) {
-               this.overwrite = overwrite;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ParameterRef.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ParameterRef.java
deleted file mode 100644 (file)
index 093f781..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.runtime.InstantiationManager;
-import org.springframework.beans.factory.FactoryBean;
-
-public class ParameterRef implements FactoryBean<Object> {
-       private final static Log log = LogFactory.getLog(ParameterRef.class);
-
-       private InstantiationManager instantiationManager;
-       private String name;
-
-       /** Cached object. */
-       private Object object;
-
-       public ParameterRef() {
-       }
-
-       public ParameterRef(String name) {
-               this.name = name;
-       }
-
-       public Object getObject() throws Exception {
-               if (log.isTraceEnabled())
-                       log.debug("Parameter ref called for " + name);
-
-               if (object == null)
-                       object = instantiationManager.getInitializingFlowParameter(name);
-               return object;
-       }
-
-       public Class<?> getObjectType() {
-               if (object == null)
-                       return instantiationManager.getInitializingFlowParameterClass(name);
-               else
-                       return object.getClass();
-       }
-
-       public boolean isSingleton() {
-               return true;
-       }
-
-       public void setInstantiationManager(
-                       InstantiationManager instantiationManager) {
-               this.instantiationManager = instantiationManager;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/SedFilteredResource.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/SedFilteredResource.java
deleted file mode 100644 (file)
index 728f95c..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.ByteArrayResource;
-import org.springframework.core.io.Resource;
-
-/** Experimental and suboptimal */
-public class SedFilteredResource implements FactoryBean<Resource>,
-               InitializingBean {
-       private Resource source;
-
-       private List<String> filters = new ArrayList<String>();
-       private Map<Pattern, String> patterns = new HashMap<Pattern, String>();
-
-       private String charset = "UTF-8";
-       private Charset cs;
-       private CharsetDecoder decoder;
-
-       // private CharsetEncoder encoder;
-
-       public Resource getObject() throws Exception {
-               if (filters.size() == 0)
-                       return source;
-
-               // int capacity = 100 * 1024;// 100 KB
-               ByteBuffer bb;
-               if (source instanceof ByteArrayResource) {
-                       bb = ByteBuffer.wrap(((ByteArrayResource) source).getByteArray());
-               } else {
-                       FileInputStream fis = null;
-                       try {
-                               File file = source.getFile();
-                               fis = new FileInputStream(file);
-                               FileChannel fc = fis.getChannel();
-
-                               // Get the file's size and then map it into memory
-                               int sz = (int) fc.size();
-                               bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);
-                       } catch (IOException e) {
-                               // ReadableByteChannel channel = Channels.newChannel(source
-                               // .getInputStream());
-                               // bb = ByteBuffer.allocateDirect(capacity);
-                               // int read = 0;
-                               // do {
-                               // read = channel.read(bb);
-                               // } while (read > 0);
-                               // FIXME : use nio to parse the stream as it goes
-                               bb = ByteBuffer.wrap(IOUtils.toByteArray(source
-                                               .getInputStream()));
-                       } finally {
-                               IOUtils.closeQuietly(fis);
-                       }
-               }
-               CharBuffer cb = decoder.decode(bb);
-               for (Pattern pattern : patterns.keySet()) {
-                       Matcher matcher = pattern.matcher(cb);
-                       String output = matcher.replaceAll(patterns.get(pattern));
-                       cb = CharBuffer.wrap(output);
-               }
-               // ByteBuffer bbout = encoder.encode(cb);
-               // ByteArrayOutputStream out = new ByteArrayOutputStream(capacity);
-               // WritableByteChannel wchannel = Channels.newChannel(out);
-               // wchannel.write(bbout);
-               ByteArrayResource res = new ByteArrayResource(cb.toString().getBytes());
-               return res;
-       }
-
-       public Class<?> getObjectType() {
-               return Resource.class;
-       }
-
-       public boolean isSingleton() {
-               return true;
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               cs = Charset.forName(charset);
-               decoder = cs.newDecoder();
-               // encoder = cs.newEncoder();
-
-               for (String sedStr : filters) {
-                       sedStr = sedStr.trim();
-                       if (sedStr.length() < 4)
-                               throw new SlcException(sedStr + " not properly formatted.");
-                       if (sedStr.charAt(0) != 's')
-                               throw new SlcException(sedStr + " not properly formatted.");
-                       Character sep = sedStr.charAt(1);
-                       List<String> tokens = new ArrayList<String>(4);
-                       StringTokenizer st = new StringTokenizer(sedStr, sep.toString());
-                       while (st.hasMoreTokens())
-                               tokens.add(st.nextToken());
-                       if (tokens.size() != 3 && tokens.size() != 4)
-                               throw new SlcException(sedStr + " not properly formatted.");
-                       patterns.put(Pattern.compile(tokens.get(1)), tokens.get(2));
-               }
-       }
-
-       public void setSource(Resource source) {
-               this.source = source;
-       }
-
-       public void setFilters(List<String> filters) {
-               this.filters = filters;
-       }
-
-       public void setCharset(String charset) {
-               this.charset = charset;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/defaults.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/defaults.xml
deleted file mode 100644 (file)
index d84ba10..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-            http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:aop="http://www.springframework.org/schema/aop"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
-       <bean id="slcDefault.executionResources" parent="slcTemplate.fileResources"
-               scope="execution" lazy-init="true">
-               <aop:scoped-proxy proxy-target-class="false" />
-               <property name="executionContext" ref="executionContext" />
-       </bean>
-
-       <bean id="slcDefault.writableResource" parent="slcTemplate.writableResource"
-               abstract="true">
-               <property name="executionResources" ref="slcDefault.executionResources" />
-       </bean>
-
-       <bean id="slcDefault.osFile" parent="slcTemplate.osFile" abstract="true">
-               <property name="executionResources" ref="slcDefault.executionResources" />
-       </bean>
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ConsoleContextDescriber.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ConsoleContextDescriber.java
deleted file mode 100644 (file)
index 1e8f8f9..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.argeo.slc.core.execution.doc;
-
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.PropertyValue;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-
-public class ConsoleContextDescriber implements ContextDescriber {
-       public void describeContext(BeanDefinitionRegistry registry) {
-               String[] beanNames = registry.getBeanDefinitionNames();
-               for (String beanName : beanNames) {
-                       log("\n## BEAN: " + beanName);
-                       describeBean(registry.getBeanDefinition(beanName));
-               }
-       }
-
-       public void describeBean(BeanDefinition beanDefinition) {
-               log("BeanDefinition class: "+beanDefinition.getClass());
-               log("# ATTRIBUTES");
-               for(String attr:beanDefinition.attributeNames()){
-                       log(attr+"="+beanDefinition.getAttribute(attr));
-               }
-               log("# PROPERTIES");
-               MutablePropertyValues pValues = beanDefinition.getPropertyValues();
-               for (PropertyValue pv : pValues.getPropertyValues()) {
-                       log(pv.getName() + "= (" + pv.getValue().getClass() + ") "
-                                       + pv.getValue());
-               }
-       }
-
-       protected void log(Object obj){
-               System.out.println(obj);
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ContextDescriber.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ContextDescriber.java
deleted file mode 100644 (file)
index 7dd9afe..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.argeo.slc.core.execution.doc;
-
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-
-public interface ContextDescriber {
-       public void describeContext(BeanDefinitionRegistry registry);
-       public void describeBean(BeanDefinition bd);
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/CompositeRunnableFactory.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/CompositeRunnableFactory.java
deleted file mode 100644 (file)
index 4fc5dc0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.argeo.slc.core.execution.generator;
-
-import java.util.Map;
-
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-
-/**
- * Composite <code>RunnableFactory</code>, redirecting the Runnable 
- * creation to on of the configured <code>RunnableFactory</code> depending
- * on an entry of the data of the <code>RunnableDataNode</code>.
- */
-public class CompositeRunnableFactory implements RunnableFactory {
-
-       /**
-        * Key used to access factory ID in the data of the <code>RunnableDataNode</code>
-        */
-       private String factoryKey;
-
-       /**
-        * Maps a factory ID to an ExecutionFlowFactory
-        */
-       private Map<String, RunnableFactory> factories;
-
-       public void createAndRegisterRunnable(RunnableDataNode node,
-                       BeanDefinitionRegistry beanDefinitionRegistry) {
-               findFactory(node).createAndRegisterRunnable(node, beanDefinitionRegistry);
-       }       
-       
-       /**
-        * Finds the <code>RunnableFactory</code> to use for a <code>RunnableDataNode</code>
-        * @param node
-        * @return the <code>RunnableFactory</code> to use for the <code>RunnableDataNode</code>
-        */
-       private RunnableFactory findFactory(RunnableDataNode node) {
-               // get the factory ID from the data of the RunnableDescriptor
-               Map<String, Object> data = node.getData();
-               if (!data.containsKey(factoryKey)) {
-                       throw new SlcException("No data value for key '" + factoryKey + "'");
-               }
-               String factoryId = data.get(factoryKey).toString();
-               
-               // see if we have a factory for the factory ID
-               if ((factories != null) && factories.containsKey(factoryId)) {
-                       return factories.get(factoryId);
-               }
-               // if not, look for a bean of name equals to the factory ID
-               else {
-                       throw new SlcException("Not implemented");
-               }               
-       }
-       
-       public void setFactoryKey(String factoryKey) {
-               this.factoryKey = factoryKey;
-       }
-
-       public void setFactories(Map<String, RunnableFactory> factories) {
-               this.factories = factories;
-       }
-
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/DefaultRunnableDataNode.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/DefaultRunnableDataNode.java
deleted file mode 100644 (file)
index cd0eaef..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.argeo.slc.core.execution.generator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Default implementation of <code>RunnableDataNode</code>
- *
- */
-public class DefaultRunnableDataNode implements RunnableDataNode {
-
-       private List<RunnableDataNode> children = new ArrayList<RunnableDataNode>();
-       
-       private RunnableDataNode parent;
-       
-       /**
-        * Data of the RunnableDataNode. Does not contain
-        * parent data.
-        */
-       private Map<String, Object> properData = new HashMap<String, Object>();
-       
-       private String path;
-       
-       private String beanName;
-
-       public boolean isLeaf() {
-               return children.size() == 0;
-       }
-       
-       public List<RunnableDataNode> getChildren() {
-               return children;
-       }
-
-       public void addChild(RunnableDataNode child) {
-               child.setParent(this);
-               children.add(child);
-       }
-       
-       public Map<String, Object> getData() {
-               Map<String, Object> data = new HashMap<String, Object>();
-               if(parent != null) {
-                       Map<String, Object> parentData = parent.getData();
-                       if(parentData != null) {
-                               data.putAll(parentData);
-                       }
-               }
-               // entries defined in parentData can be overridden
-               // in properData
-               if(properData != null) {
-                       data.putAll(properData);
-               }
-               return data;
-       }
-
-       public Map<String, Object> getProperData() {
-               return properData;
-       }
-
-       public void setProperData(Map<String, Object> properData) {
-               this.properData = properData;
-       }
-
-       public String getPath() {
-               return path;
-       }
-
-       public void setPath(String path) {
-               this.path = path;
-       }
-
-       public String getBeanName() {
-               return beanName;
-       }
-
-       public void setBeanName(String beanName) {
-               this.beanName = beanName;
-       }
-
-       public void setParent(RunnableDataNode parent) {
-               this.parent = parent;
-       }
-
-       public RunnableDataNode getParent() {
-               return parent;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGenerator.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGenerator.java
deleted file mode 100644 (file)
index 0e06f4e..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-package org.argeo.slc.core.execution.generator;
-
-import java.util.HashMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.aop.scope.ScopedProxyUtils;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.GenericBeanDefinition;
-import org.springframework.core.Ordered;
-
-/**
- * Generates <code>ExecutionFlows</code> and <code>Runnables</code> as
- * beans in the Spring Application Context.
- * Called by the Application Context as a <code>BeanFactoryPostProcessor</code>.
- * Two kinds of beans are generated:
- * <code>RunnableCallFlow</code>, calling a list of <code>Runnables</code> from the
- * Application Context after configuring the <code>ExecutionContext</code>, 
- * and outputs of a <code>RunnableFactory</code>.
- */
-public class ExecutionFlowGenerator implements BeanFactoryPostProcessor,
-               Ordered {
-       
-       private final Log log = LogFactory.getLog(getClass());
-
-       /**
-        * Source providing a list of <code>RunnableCallFlowDescriptor</code> 
-        * used to create <code>RunnableCallFlow</code> and a list of 
-        * <code>RunnableDataNode</code> used to create any kind of flow via a factory
-        */
-       protected ExecutionFlowGeneratorSource source;
-       
-       /**
-        * Factory used to create Runnables in the Application context from
-        * the <code>RunnableDataNode</code> provided from the source.
-        */
-       protected RunnableFactory runnableFactory;
-       
-       /**
-        * Bean name of the <code>ExecutionContext</code>.
-        * Used to provide the created <code>RunnableCallFlow</code> beans 
-        * with a <code>RuntimeBeanReference</code> to
-        * the <code>ExecutionContext</code>
-        */
-       private String executionContextBeanName = "executionContext";
-       
-       /**
-        * Bean name of the context values Map.
-        * A bean of class HashMap is created with this name, and a 
-        * <code>RuntimeBeanReference</code> is provided to the created
-        * <code>RunnableCallFlow</code> beans.
-        */
-       private String contextValuesBeanName = "executionFlowGenerator.contextValues";
-       
-       /**
-        * Prefix added to the bean names defined in each 
-        * <code>RunnableCallFlowDescriptor</code>
-        */
-       private String flowBeanNamesPrefix = "";
-       
-       private int order = Ordered.HIGHEST_PRECEDENCE;
-               
-       public void postProcessBeanFactory(
-                       ConfigurableListableBeanFactory beanFactory) throws BeansException {
-
-               // assert that the beanFactory is a BeanDefinitionRegistry
-               if (!(beanFactory instanceof BeanDefinitionRegistry)) {
-                       throw new SlcException("Can only work on "
-                                       + BeanDefinitionRegistry.class);
-               } 
-               
-               // add bean for the Context Values Map
-               createAndRegisterContextValuesBean((BeanDefinitionRegistry) beanFactory);
-               
-               // add beans for each RunnableDataNode
-               for(RunnableDataNode node : source.getRunnableDataNodes()) {
-                       runnableFactory.createAndRegisterRunnable(node, (BeanDefinitionRegistry) beanFactory);
-               }
-               
-               // add beans for each RunnableCallFlowDescriptor of the source to the application context
-               for (RunnableCallFlowDescriptor descriptor : source
-                               .getRunnableCallFlowDescriptors()) {
-                       createAndRegisterFlowFor(descriptor, (BeanDefinitionRegistry) beanFactory);
-               }
-       }
-
-       /**
-        * Creates a <code>RunnableCallFlow</code> bean
-        * for a <code>RunnableCallFlowDescriptor</code> and registers 
-        * it in the <code>BeanDefinitionRegistry</code>
-        * @param flowDescriptor
-        * @param registry
-        */
-       private void createAndRegisterFlowFor(RunnableCallFlowDescriptor flowDescriptor, BeanDefinitionRegistry registry) {
-               // create the flow bean
-               GenericBeanDefinition flowBean = new GenericBeanDefinition();
-               flowBean.setBeanClass(RunnableCallFlow.class);
-               
-               String beanName = flowBeanNamesPrefix + flowDescriptor.getBeanName();
-               
-               MutablePropertyValues mpv = new MutablePropertyValues();                
-               mpv.addPropertyValue("runnableCalls", flowDescriptor.getRunnableCalls());
-               mpv.addPropertyValue("sharedContextValuesMap", new RuntimeBeanReference(contextValuesBeanName));
-               
-               mpv.addPropertyValue("name", beanName);
-               mpv.addPropertyValue("path", flowDescriptor.getPath());
-
-               mpv.addPropertyValue("executionContext", new RuntimeBeanReference(executionContextBeanName));
-               
-               flowBean.setPropertyValues(mpv);
-               
-               // register it
-               if(log.isDebugEnabled()) {
-                       log.debug("Registering bean definition for RunnableCallFlow " + beanName);
-               }
-               registry.registerBeanDefinition(beanName, flowBean);
-       }
-       
-       /**
-        * Creates the Context Values bean and register it in the
-        * <code>BeanDefinitionRegistry</code>
-        * @param registry
-        */
-       private void createAndRegisterContextValuesBean(BeanDefinitionRegistry registry) {
-               GenericBeanDefinition contextValuesBean = new GenericBeanDefinition();
-               contextValuesBean.setBeanClass(HashMap.class);
-               
-               BeanDefinitionHolder bdh = ScopedProxyUtils.createScopedProxy(new BeanDefinitionHolder(contextValuesBean, contextValuesBeanName), registry, true);                                                                                                                      
-               registry.registerBeanDefinition(contextValuesBeanName, bdh.getBeanDefinition());                
-       }
-       
-       public int getOrder() {
-               return order;
-       }
-
-       public void setOrder(int order) {
-               this.order = order;
-       }
-
-       public void setSource(ExecutionFlowGeneratorSource source) {
-               this.source = source;
-       }
-
-       public void setRunnableFactory(RunnableFactory runnableFactory) {
-               this.runnableFactory = runnableFactory;
-       }
-
-       public void setExecutionContextBeanName(String executionContextBeanName) {
-               this.executionContextBeanName = executionContextBeanName;
-       }
-
-       public void setContextValuesBeanName(String contextValuesBeanName) {
-               this.contextValuesBeanName = contextValuesBeanName;
-       }
-
-       public void setFlowBeanNamesPrefix(String flowBeanNamesPrefix) {
-               this.flowBeanNamesPrefix = flowBeanNamesPrefix;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGeneratorSource.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGeneratorSource.java
deleted file mode 100644 (file)
index de29e29..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.argeo.slc.core.execution.generator;
-
-import java.util.List;
-
-/**
- * Provides 2 types of information required by an <code>ExecutionFlowGenerator</code>: 
- * a list of <code>RunnableCallFlowDescriptor</code> used to create <code>RunnableCallFlow</code>
- * and a list of <code>RunnableDataNode</code> used to create any kind of flow via a factory.
- */
-public interface ExecutionFlowGeneratorSource {
-       
-       /**
-        * @return a list of <code>RunnableCallFlowDescriptor</code> used 
-        * by a <code>ExecutionFlowGenerator</code> to create <code>RunnableCallFlow</code>
-        */
-       public List<RunnableCallFlowDescriptor> getRunnableCallFlowDescriptors();
-       
-       /**
-        * @return a list of <code>RunnableDataNode</code> used 
-        * by a <code>ExecutionFlowGenerator</code> to create any kind of flow via a factory
-        */
-       public List<RunnableDataNode> getRunnableDataNodes();
-       
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCall.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCall.java
deleted file mode 100644 (file)
index d774072..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.argeo.slc.core.execution.generator;
-
-import java.util.Map;
-
-/**
- * Storage class for information required to call a flow 
- * of the Spring execution context: 
- * bean name of the flow,
- * variables to add to the Execution Context before the call 
- * and variables (context values) to add to a Map 
- * potentially referenced by the called flow 
- */
-public class RunnableCall {
-       
-       /**
-        * Bean name of the flow to call
-        */
-       private String beanName;
-       
-       /**
-        * Variables to add to the execution context before the call
-        */
-       private Map<String, Object> executionVariables;
-       
-       /**
-        * Variables to add to the Map potentially referenced by
-        * the called flow
-        */
-       private Map<String, Object> contextValues;
-
-       public String getBeanName() {
-               return beanName;
-       }
-
-       public void setBeanName(String beanName) {
-               this.beanName = beanName;
-       }
-
-       public Map<String, Object> getExecutionVariables() {
-               return executionVariables;
-       }
-
-       public void setExecutionVariables(Map<String, Object> executionVariables) {
-               this.executionVariables = executionVariables;
-       }
-
-       public Map<String, Object> getContextValues() {
-               return contextValues;
-       }
-
-       public void setContextValues(Map<String, Object> contextValues) {
-               this.contextValues = contextValues;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlow.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlow.java
deleted file mode 100644 (file)
index 04043ac..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-package org.argeo.slc.core.execution.generator;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Execution Flow calling a list of <code>Runnable</code> (identified by their
- * bean name in the Spring Application Context) after configuring the Execution
- * context and a Map potentially shared by the called <code>Runnable</code>
- * 
- */
-public class RunnableCallFlow implements ExecutionFlow, ApplicationContextAware {
-
-       private final static Log log = LogFactory.getLog(RunnableCallFlow.class);
-
-       /**
-        * Key in the execution context for the index of the call (e.g. 0 for the
-        * first runnable called, ...)
-        */
-       public final static String VAR_CALL_INDEX = "slcVar.runnableCallFlow.callIndex";
-
-       /**
-        * Name of the flow. Also bean name
-        */
-       private String name;
-
-       /**
-        * Path of the flow
-        */
-       private String path;
-
-       /**
-        * Whether an exception in a <code>Runnable</code> shall stop the execution
-        * of the flow
-        */
-       private Boolean failOnError = true;
-
-       /**
-        * List of <code>Runnable</code> to call, with bean name, execution
-        * variables and context values
-        */
-       private List<RunnableCall> runnableCalls;
-
-       /**
-        * Map potentially referenced by called flows. Updated with the context
-        * values of a Runnable before calling it.
-        */
-       private Map<String, Object> sharedContextValuesMap;
-
-       /**
-        * ExecutionSpec of the flow. Does not contain any attribute.
-        */
-       private ExecutionSpec executionSpec = new DefaultExecutionSpec();
-
-       /**
-        * Reference to the ExecutionContext
-        */
-       private ExecutionContext executionContext;
-
-       /**
-        * Reference to the Spring <code>ApplicationContext</code>. Set via
-        * <code>setApplicationContext</code>, the class implementing
-        * <code>ApplicationContextAware</code>
-        */
-       private ApplicationContext applicationContext;
-
-       /**
-        * Runs a <code>Runnable</code> after configuring the Execution Context and
-        * <code>sharedContextValuesMap</code>
-        * 
-        * @param runnable
-        *            the <code>Runnable</code> to call
-        * @param executionVariables
-        *            the variables to add to the <code>ExecutionContext</code>
-        * @param contextValues
-        *            the variables to add to <code>sharedContextValuesMap</code>
-        * @param callIndex
-        *            index of the call (0 for the first called
-        *            <code>Runnable</code>) set as variable of the
-        *            <code>ExecutionContext</code>
-        */
-       private void run(Runnable runnable, Map<String, Object> executionVariables,
-                       Map<String, Object> contextValues, int callIndex) {
-               // add all variables to the Execution Context
-               for (Map.Entry<String, Object> entry : executionVariables.entrySet()) {
-                       executionContext.setVariable(entry.getKey(), entry.getValue());
-               }
-
-               // add call Index Variable
-               executionContext.setVariable(VAR_CALL_INDEX, callIndex);
-
-               // clear sharedContextValues and add all values of contextValues
-               if (sharedContextValuesMap != null) {
-                       sharedContextValuesMap.clear();
-                       sharedContextValuesMap.putAll(contextValues);
-               }
-
-               // then run the runnable
-               doExecuteRunnable(runnable);
-       }
-
-       public void doExecuteRunnable(Runnable runnable) {
-               runnable.run();
-       }
-
-       /**
-        * Executes the flow. For each <code>RunnableCall</code>, the corresponding
-        * flow is retrieved from the Spring Application Context, the
-        * <code>ExecutionContext</code> and <code>sharedContextValuesMap</code> are
-        * configured and the <code>Runnable</code> is called.
-        */
-       public void run() {
-               if (applicationContext == null) {
-                       throw new SlcException("No ApplicationContext defined");
-               }
-
-               try {
-                       for (int callIndex = 0; callIndex < runnableCalls.size(); ++callIndex) {
-                               RunnableCall runnableCall = runnableCalls.get(callIndex);
-                               Object bean = applicationContext.getBean(
-                                               runnableCall.getBeanName(), Runnable.class);
-                               if (log.isDebugEnabled())
-                                       log.debug("Running flow '" + runnableCall.getBeanName()
-                                                       + "'");
-                               run((Runnable) bean, runnableCall.getExecutionVariables(),
-                                               runnableCall.getContextValues(), callIndex);
-                       }
-               } catch (RuntimeException e) {
-                       if (failOnError)
-                               throw e;
-                       else {
-                               log.error("Execution flow failed,"
-                                               + " but process did not fail"
-                                               + " because failOnError property"
-                                               + " is set to false: " + e);
-                               if (log.isTraceEnabled())
-                                       e.printStackTrace();
-                       }
-               }
-       }
-
-       public Iterator<Runnable> runnables() {
-               List<Runnable> runnables = new ArrayList<Runnable>();
-               for (int callIndex = 0; callIndex < runnableCalls.size(); ++callIndex) {
-                       RunnableCall runnableCall = runnableCalls.get(callIndex);
-                       Object bean = applicationContext.getBean(
-                                       runnableCall.getBeanName(), Runnable.class);
-                       runnables.add((Runnable) bean);
-               }
-               return runnables.iterator();
-       }
-
-       public Runnable getRunnable() {
-               if (runnableCalls.size() == 1)
-                       return runnables().next();
-               else
-                       throw new SlcException("There are " + runnableCalls.size()
-                                       + " runnables in flow " + getName());
-       }
-
-       @Override
-       public String toString() {
-               return new StringBuffer("RunnableCallFlow ").append(name).toString();
-       }
-
-       public ExecutionSpec getExecutionSpec() {
-               return executionSpec;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public Object getParameter(String key) {
-               throw new SlcException("RunnableCallFlow have no parameters");
-       }
-
-       public String getPath() {
-               return path;
-       }
-
-       public Boolean isSetAsParameter(String key) {
-               // The ExecutionSpec having no attribute,
-               // always return false
-               return false;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public void setPath(String path) {
-               this.path = path;
-       }
-
-       public void setExecutionContext(ExecutionContext executionContext) {
-               this.executionContext = executionContext;
-       }
-
-       public void setRunnableCalls(List<RunnableCall> runnableCalls) {
-               this.runnableCalls = runnableCalls;
-       }
-
-       public void setApplicationContext(ApplicationContext applicationContext) {
-               this.applicationContext = applicationContext;
-       }
-
-       public void setSharedContextValuesMap(Map<String, Object> contextValues) {
-               this.sharedContextValuesMap = contextValues;
-       }
-
-       public void setFailOnError(Boolean failOnError) {
-               this.failOnError = failOnError;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlowDescriptor.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlowDescriptor.java
deleted file mode 100644 (file)
index 738b75f..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.argeo.slc.core.execution.generator;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Storage Class for information required to
- * instantiate a <code>RunnableCallFlow</code>:
- * bean name of the flow, 
- * path of the flow 
- * and list of <code>RunnableCall</code>. 
- *
- */
-public class RunnableCallFlowDescriptor {
-       
-       /**
-        * Bean name of the flow to instantiate
-        */
-       private String beanName;
-       
-       /**
-        * Path of the flow to instantiate
-        */
-       private String path;
-       
-       /**
-        * List of <code>RunnableCall</code> 
-        */
-       private List<RunnableCall> runnableCalls = new ArrayList<RunnableCall>();
-
-       public String getBeanName() {
-               return beanName;
-       }
-
-       public void setBeanName(String beanName) {
-               this.beanName = beanName;
-       }
-
-       public String getPath() {
-               return path;
-       }
-
-       public void setPath(String path) {
-               this.path = path;
-       }
-
-       public List<RunnableCall> getRunnableCalls() {
-               return runnableCalls;
-       }
-
-       public void setRunnableCalls(List<RunnableCall> runnableCalls) {
-               this.runnableCalls = runnableCalls;
-       }
-       
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableDataNode.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableDataNode.java
deleted file mode 100644 (file)
index e526b5e..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.argeo.slc.core.execution.generator;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Stores information relative to a Runnable.
- * Allows to structure the information as a tree, each node
- * storing data as a Map.
- */
-public interface RunnableDataNode {
-
-       /**
-        * @return a Map containing the data associated with this node.
-        * Data associated with parent nodes are expected
-        * to be contained in the returned Map
-        */
-       public Map<String, Object> getData();   
-
-       /**
-        * @return the name of the bean to create.
-        * Can be null if no bean shall be created for the 
-        * <code>RunnableDataNode</code> (e.g. is is a sub-node)
-        */
-       public String getBeanName();
-       
-       /**
-        * @return the path of the flow bean to create.
-        * Can be null if the bean to created is not an
-        * <code>ExecutionFlow</code> or if no bean shall be created for the 
-        * <code>RunnableDataNode</code> (e.g. is is a sub-node)
-        */
-       public String getPath();
-               
-       /**
-        * @return whether the <code>RunnableDataNode</code> has
-        * children or not.
-        * Expected to be equivalent to <code>getChildren().empty()</code>
-        */
-       public boolean isLeaf();
-
-       /**
-        * @return the list of <code>RunnableDataNode</code> children.
-        * Can be empty. Shall not be null.
-        */
-       public List<RunnableDataNode> getChildren();
-       
-       /**
-        * @return the <code>RunnableDataNode</code> parent.
-        * Can be null if no parent is defined (top node).
-        */
-       public RunnableDataNode getParent();
-       
-       /**
-        * Sets the <code>RunnableDataNode</code> parent
-        * @param parent
-        */
-       public void setParent(RunnableDataNode parent); 
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableFactory.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableFactory.java
deleted file mode 100644 (file)
index c81008a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.argeo.slc.core.execution.generator;
-
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-
-/**
- * Interprets a <code>RunnableDataNode</code> by creating corresponding
- * beans and registering them in a <code>BeanDefinitionRegistry</code>
- *
- */
-public interface RunnableFactory {
-
-       public void createAndRegisterRunnable(RunnableDataNode node,
-                       BeanDefinitionRegistry beanDefinitionRegistry);
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/runtime.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/runtime.xml
deleted file mode 100644 (file)
index 303d55c..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License, 
-       Version 2.0 (the "License"); you may not use this file except in compliance 
-       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
-       Unless required by applicable law or agreed to in writing, software distributed 
-       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
-       OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
-       the specific language governing permissions and limitations under the License. -->
-<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under 
-       the Apache License, Version 2.0 (the "License"); you may not use this file 
-       except in compliance with the License. You may obtain a copy of the License 
-       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
-       law or agreed to in writing, software distributed under the License is distributed 
-       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
-       express or implied. See the License for the specific language governing permissions 
-       and limitations under the License. -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:aop="http://www.springframework.org/schema/aop"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
-       <description>Bare minimal runtime configuration. In general you will
-               want to use simple.xml instead.
-       </description>
-
-       <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
-               <property name="scopes">
-                       <map>
-                               <entry key="execution">
-                                       <bean class="org.argeo.slc.core.execution.ExecutionScope" />
-                               </entry>
-                       </map>
-               </property>
-       </bean>
-
-
-       <bean id="executionStack" class="org.argeo.slc.runtime.DefaultExecutionStack"
-               scope="execution">
-               <aop:scoped-proxy proxy-target-class="false" />
-       </bean>
-
-       <bean id="instantiationManager" class="org.argeo.slc.runtime.InstantiationManager" />
-
-       <bean class="org.argeo.slc.core.execution.ExecutionParameterPostProcessor">
-               <property name="executionContext" ref="executionContext" />
-               <property name="instantiationManager" ref="instantiationManager" />
-       </bean>
-
-       <!-- <bean class="org.argeo.slc.core.execution.ExecutionAspect"> -->
-       <!-- <property name="executionStack" ref="executionStack" /> -->
-       <!-- <property name="executionContext" ref="executionContext" /> -->
-       <!-- </bean> -->
-
-       <aop:aspectj-autoproxy />
-
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/simple.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/simple.xml
deleted file mode 100644 (file)
index ff243ba..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License, 
-       Version 2.0 (the "License"); you may not use this file except in compliance 
-       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
-       Unless required by applicable law or agreed to in writing, software distributed 
-       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
-       OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
-       the specific language governing permissions and limitations under the License. -->
-<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under 
-       the Apache License, Version 2.0 (the "License"); you may not use this file 
-       except in compliance with the License. You may obtain a copy of the License 
-       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
-       law or agreed to in writing, software distributed under the License is distributed 
-       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
-       express or implied. See the License for the specific language governing permissions 
-       and limitations under the License. -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:aop="http://www.springframework.org/schema/aop"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
-       <description>Default Capabilities</description>
-
-       <import resource="runtime.xml" />
-
-       <bean id="executionContext" class="org.argeo.slc.core.execution.MapExecutionContext"
-               scope="execution">
-               <aop:scoped-proxy proxy-target-class="false" />
-               <property name="executionStack" ref="executionStack" />
-       </bean>
-
-       <bean id="executionFlowDescriptorConverter"
-               class="org.argeo.slc.core.execution.DefaultExecutionFlowDescriptorConverter"></bean>
-
-       <bean
-               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
-               <property name="ignoreUnresolvablePlaceholders" value="true" />
-       </bean>
-
-       <bean id="parameterRef" class="org.argeo.slc.core.execution.ParameterRef"
-               abstract="true">
-               <property name="instantiationManager" ref="instantiationManager" />
-       </bean>
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/specs.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/specs.xml
deleted file mode 100644 (file)
index b1251d3..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-            http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
-       <bean id="specAttr.primitive" class="org.argeo.slc.primitive.PrimitiveSpecAttribute"
-               abstract="true" />
-       <bean id="specAttr.resource" class="org.argeo.slc.core.execution.ResourceSpecAttribute"
-               abstract="true" />
-       <bean id="specAttr.ref" class="org.argeo.slc.execution.RefSpecAttribute"
-               abstract="true" />
-
-       <bean id="slcTemplate.simpleFlow" class="org.argeo.slc.core.execution.DefaultExecutionFlow"
-               abstract="true" />
-       <bean id="slcTemplate.simpleSpec" class="org.argeo.slc.core.execution.DefaultExecutionSpec"
-               abstract="true" />
-
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/spring.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/spring.xml
deleted file mode 100644 (file)
index de1c06b..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-            http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under 
-       the Apache License, Version 2.0 (the "License"); you may not use this file 
-       except in compliance with the License. You may obtain a copy of the License 
-       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
-       law or agreed to in writing, software distributed under the License is distributed 
-       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
-       express or implied. See the License for the specific language governing permissions 
-       and limitations under the License. -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:aop="http://www.springframework.org/schema/aop"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
-       <description>
-               Simple runtime enriched with defaults and templates used
-               to simplify XML files. These templates have been deprecated by the
-               custom XML namespace and will be removed in SLC 2.x. Use the XML
-               namespace instead.
-       </description>
-
-       <import resource="simple.xml" />
-
-       <import resource="specs.xml" />
-       <import resource="templates.xml" />
-       <import resource="defaults.xml" />
-       <import resource="utils.xml" />
-       <import resource="tasks/core.xml" />
-
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/CloseTestResult.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/CloseTestResult.java
deleted file mode 100644 (file)
index 76460d6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import org.argeo.slc.test.TestResult;
-
-public class CloseTestResult implements Runnable {
-       private TestResult testResult;
-
-       public void run() {
-               testResult.close();
-       }
-
-       public void setTestResult(TestResult testResult) {
-               this.testResult = testResult;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/Echo.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/Echo.java
deleted file mode 100644 (file)
index 8714024..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-public class Echo implements Runnable {
-       private final static Log defaultLog = LogFactory.getLog(Echo.class);
-       private Resource writeTo = null;
-
-       private Log log;
-       private Object message;
-
-       public void run() {
-               log().info(message);
-
-               if (writeTo != null) {
-                       try {
-                               File file = writeTo.getFile();
-                               if (log().isDebugEnabled())
-                                       log().debug("Write to " + file);
-                               if (message != null)
-                                       FileUtils.writeStringToFile(file, message.toString());
-                       } catch (IOException e) {
-                               throw new SlcException("Could not write to " + writeTo, e);
-                       }
-               }
-       }
-
-       private Log log() {
-               return log != null ? log : defaultLog;
-       }
-
-       public void setMessage(Object message) {
-               this.message = message;
-       }
-
-       public void setWriteTo(Resource writeTo) {
-               this.writeTo = writeTo;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/If.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/If.java
deleted file mode 100644 (file)
index f8a79d8..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import org.argeo.slc.SlcException;
-
-/** Conditional execution */
-public class If implements Runnable {
-       private Boolean is;
-       private Boolean not;
-       private Runnable then;
-       private Runnable els;
-
-       public void run() {
-               if (is == null && not == null)
-                       throw new SlcException("No condition set");
-               if (is != null && not != null)
-                       throw new SlcException("Both is and not cannot be set");
-
-               boolean bool = (is != null ? is : !not);
-               if (bool) {
-                       if (then != null)
-                               then.run();
-               } else {
-                       if (els != null)
-                               els.run();
-               }
-
-       }
-
-       public void setIs(Boolean bool) {
-               this.is = bool;
-       }
-
-       public void setThen(Runnable then) {
-               this.then = then;
-       }
-
-       public void setEls(Runnable els) {
-               this.els = els;
-       }
-
-       public Boolean getNot() {
-               return not;
-       }
-
-       public void setNot(Boolean not) {
-               this.not = not;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/JvmProcess.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/JvmProcess.java
deleted file mode 100644 (file)
index 157c150..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-/** A Java Virtual Machine process. */
-public class JvmProcess extends SystemCall implements InitializingBean {
-       private Properties systemProperties = new Properties();
-       private List<Resource> classpath = new ArrayList<Resource>();
-       private List<Resource> pBootClasspath = new ArrayList<Resource>();
-       private Resource jvm = null;
-       private String mainClass;
-       private String mainJar;
-       private List<String> jvmArgs = new ArrayList<String>();
-       private List<String> args = new ArrayList<String>();
-
-       private String systemPropertiesFileProperty = null;
-       private String systemPropertiesFileDir = null;
-       private String systemPropertiesFileName = null;
-
-       public void afterPropertiesSet() throws Exception {
-               List<Object> command = new ArrayList<Object>();
-               if (jvm != null)
-                       command.add(asFile(jvm).getPath());
-               else
-                       command.add("java");
-
-               if (pBootClasspath.size() > 0) {
-                       StringBuffer buf = new StringBuffer("-Xbootclasspath/p:");
-                       Boolean first = true;
-                       for (Resource res : pBootClasspath) {
-                               if (first)
-                                       first = false;
-                               else
-                                       buf.append(File.pathSeparatorChar);
-
-                               buf.append(asFile(res));
-                       }
-                       command.add(buf.toString());
-               }
-
-               for (String jvmArg : jvmArgs) {
-                       command.add(jvmArg);
-               }
-
-               if (classpath.size() > 0) {
-                       command.add("-cp");
-                       StringBuffer buf = new StringBuffer("");
-                       for (Resource res : classpath) {
-                               if (buf.length() != 0)
-                                       buf.append(File.pathSeparatorChar);
-                               buf.append(asFile(res));
-                       }
-                       command.add(buf.toString());
-               }
-
-               if (systemPropertiesFileProperty == null) {
-                       // pass system properties as argument
-                       for (Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
-                               command.add("-D" + entry.getKey() + "=" + entry.getValue());
-                       }
-               } else {
-                       // write system properties in a file to work around OS limitations
-                       // with command line (e.g. Win XP)
-                       String dir = systemPropertiesFileDir;
-                       if (dir == null)
-                               dir = getExecDirToUse();
-                       String fileName = systemPropertiesFileName;
-                       if (fileName == null)
-                               fileName = systemPropertiesFileProperty + ".properties";
-
-                       // Write file
-                       FileOutputStream fos = null;
-                       File file = new File(dir + File.separator + fileName);
-                       try {
-
-                               if (!file.getParentFile().exists())
-                                       file.getParentFile().mkdirs();
-                               fos = new FileOutputStream(file);
-                               systemProperties.store(fos, "Automatically generated by "
-                                               + getClass());
-                               command.add("-D" + systemPropertiesFileProperty + "="
-                                               + file.getCanonicalPath());
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot write to system properties to "
-                                               + file, e);
-                       } finally {
-                               IOUtils.closeQuietly(fos);
-                       }
-               }
-
-               // Program
-               if (mainClass != null) {
-                       command.add(mainClass);
-               } else if (mainJar != null) {
-                       command.add("-jar");
-                       command.add(mainJar);
-               } else {
-                       throw new SlcException("No main class or jar defined");
-               }
-
-               for (String arg : args) {
-                       command.add(arg);
-               }
-
-               setCommand(command);
-       }
-
-       protected File asFile(Resource res) {
-               try {
-                       return res.getFile();
-               } catch (FileNotFoundException e) {
-                       return copyToTempFile(res);
-               } catch (IOException e) {
-                       throw new SlcException("Cannot convert resource to file", e);
-               }
-
-       }
-
-       protected File copyToTempFile(Resource res) {
-               File tempFile;
-               FileOutputStream fos;
-               try {
-                       tempFile = File.createTempFile("slcJvmProcess-", res.getFilename());
-                       tempFile.deleteOnExit();
-                       fos = new FileOutputStream(tempFile);
-                       IOUtils.copy(res.getInputStream(), fos);
-               } catch (IOException e) {
-                       throw new SlcException("Cannot copy " + res + " to temp file.", e);
-               }
-               IOUtils.closeQuietly(fos);
-               return tempFile;
-       }
-
-       /** Append the argument (for chaining) */
-       @Override
-       public SystemCall arg(String arg) {
-               args.add(arg);
-               return this;
-       }
-
-       /** Append the argument (for chaining) */
-       @Override
-       public SystemCall arg(String arg, String value) {
-               args.add(arg);
-               args.add(value);
-               return this;
-       }
-
-       public Properties getSystemProperties() {
-               return systemProperties;
-       }
-
-       public void setSystemProperties(Properties systemProperties) {
-               this.systemProperties = systemProperties;
-       }
-
-       public List<Resource> getClasspath() {
-               return classpath;
-       }
-
-       public void setClasspath(List<Resource> classpath) {
-               this.classpath = classpath;
-       }
-
-       public List<Resource> getPBootClasspath() {
-               return pBootClasspath;
-       }
-
-       public void setPBootClasspath(List<Resource> bootClasspath) {
-               pBootClasspath = bootClasspath;
-       }
-
-       public Resource getJvm() {
-               return jvm;
-       }
-
-       public void setJvm(Resource jvm) {
-               this.jvm = jvm;
-       }
-
-       public String getMainClass() {
-               return mainClass;
-       }
-
-       public void setMainClass(String mainClass) {
-               this.mainClass = mainClass;
-       }
-
-       public String getMainJar() {
-               return mainJar;
-       }
-
-       public void setMainJar(String mainJar) {
-               this.mainJar = mainJar;
-       }
-
-       public List<String> getJvmArgs() {
-               return jvmArgs;
-       }
-
-       public void setJvmArgs(List<String> jvmArgs) {
-               this.jvmArgs = jvmArgs;
-       }
-
-       public List<String> getArgs() {
-               return args;
-       }
-
-       public void setArgs(List<String> args) {
-               this.args = args;
-       }
-
-       public void setSystemPropertiesFileProperty(
-                       String systemPropertiesFilePropertyName) {
-               this.systemPropertiesFileProperty = systemPropertiesFilePropertyName;
-       }
-
-       public void setSystemPropertiesFileDir(String systemPropertiesFileDir) {
-               this.systemPropertiesFileDir = systemPropertiesFileDir;
-       }
-
-       public void setSystemPropertiesFileName(String systemPropertiesFileName) {
-               this.systemPropertiesFileName = systemPropertiesFileName;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MergedLists.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MergedLists.java
deleted file mode 100644 (file)
index bb25c88..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.beans.factory.FactoryBean;
-
-/** Merge the provided lists in one single list, in the order provided. */
-public class MergedLists implements FactoryBean<List<Object>> {
-       private List<List<Object>> lists = new ArrayList<List<Object>>();
-
-       public void setLists(List<List<Object>> lists) {
-               this.lists = lists;
-       }
-
-       public List<Object> getObject() throws Exception {
-               List<Object> merged = new ArrayList<Object>();
-               for (List<Object> lst : lists) {
-                       merged.addAll(lst);
-               }
-               return merged;
-       }
-
-       public Class<?> getObjectType() {
-               return List.class;
-       }
-
-       public boolean isSingleton() {
-               return false;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MethodCall.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MethodCall.java
deleted file mode 100644 (file)
index 88aeb47..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.util.Assert;
-import org.springframework.util.ReflectionUtils;
-
-public class MethodCall implements Runnable {
-       private Object target;
-       private String method;
-       private List<Object> args = new ArrayList<Object>();
-
-       public void run() {
-               Assert.notNull(target, "target");
-               Assert.notNull(method, "method");
-               Method methodRef = ReflectionUtils
-                               .findMethod(target.getClass(), method);
-               if (args.size() == 0)
-                       ReflectionUtils.invokeMethod(methodRef, target);
-               else
-                       ReflectionUtils.invokeMethod(methodRef, methodRef, args.toArray());
-       }
-
-       public void setTarget(Object target) {
-               this.target = target;
-       }
-
-       public void setMethod(String method) {
-               this.method = method;
-       }
-
-       public void setArgs(List<Object> args) {
-               this.args = args;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/OverrideContextAware.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/OverrideContextAware.java
deleted file mode 100644 (file)
index 6162ecb..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.test.context.SimpleContextAware;
-import org.argeo.slc.test.context.ContextAware;
-
-/**
- * Overrides Values and Expected values of a target 
- * <code>SimpleContextAware</code> with the corresponding
- * values and expected values of a source <code>ContextAware</code>
- *
- */
-public class OverrideContextAware implements Runnable {
-
-       private ContextAware source;
-
-       private SimpleContextAware target;
-       
-       /**
-        * Whether an exception shall be thrown if a value
-        * or expected value of the source is not defined
-        * in the target
-        */
-       private Boolean failIfUndefinedInSource = true;
-       
-       public void run() {
-               // override values
-               if(source.getValues() != null)
-                       for(String key : source.getValues().keySet()) {
-                               if(failIfUndefinedInSource && !target.getValues().containsKey(key)) {
-                                       throw new SlcException("No entry in target values for key '" + key + "'");
-                               }
-                               target.getValues().put(key, source.getValues().get(key));
-                       }
-               
-               // override expected values
-               if(source.getExpectedValues() != null)
-                       for(String key : source.getExpectedValues().keySet()) {
-                               if(failIfUndefinedInSource && !target.getExpectedValues().containsKey(key)) {
-                                       throw new SlcException("No entry in target expected values for key '" + key + "'");
-                               }
-                               target.getExpectedValues().put(key, source.getExpectedValues().get(key));
-                       }               
-       }       
-       
-       public void setSource(ContextAware source) {
-               this.source = source;
-       }
-
-       public void setTarget(SimpleContextAware target) {
-               this.target = target;
-       }
-
-       public void setFailIfUndefinedInSource(Boolean failIfUndefinedInSource) {
-               this.failIfUndefinedInSource = failIfUndefinedInSource;
-       }       
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCall.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCall.java
deleted file mode 100644 (file)
index 633f8f9..0000000
+++ /dev/null
@@ -1,767 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.security.auth.callback.CallbackHandler;
-
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.ExecuteException;
-import org.apache.commons.exec.ExecuteResultHandler;
-import org.apache.commons.exec.ExecuteStreamHandler;
-import org.apache.commons.exec.ExecuteWatchdog;
-import org.apache.commons.exec.Executor;
-import org.apache.commons.exec.LogOutputStream;
-import org.apache.commons.exec.PumpStreamHandler;
-import org.apache.commons.exec.ShutdownHookProcessDestroyer;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.core.execution.ExecutionResources;
-import org.argeo.slc.runtime.test.SimpleResultPart;
-import org.argeo.slc.test.TestResult;
-import org.argeo.slc.test.TestStatus;
-import org.springframework.core.io.Resource;
-
-/** Execute an OS specific system call. */
-public class SystemCall implements Runnable {
-       public final static String LOG_STDOUT = "System.out";
-
-       private final Log log = LogFactory.getLog(getClass());
-
-       private String execDir;
-
-       private String cmd = null;
-       private List<Object> command = null;
-
-       private Executor executor = new DefaultExecutor();
-       private Boolean synchronous = true;
-
-       private String stdErrLogLevel = "ERROR";
-       private String stdOutLogLevel = "INFO";
-
-       private Resource stdOutFile = null;
-       private Resource stdErrFile = null;
-
-       private Resource stdInFile = null;
-       /**
-        * If no {@link #stdInFile} provided, writing to this stream will write to
-        * the stdin of the process.
-        */
-       private OutputStream stdInSink = null;
-
-       private Boolean redirectStdOut = false;
-
-       private List<SystemCallOutputListener> outputListeners = Collections
-                       .synchronizedList(new ArrayList<SystemCallOutputListener>());
-
-       private Map<String, List<Object>> osCommands = new HashMap<String, List<Object>>();
-       private Map<String, String> osCmds = new HashMap<String, String>();
-       private Map<String, String> environmentVariables = new HashMap<String, String>();
-
-       private Boolean logCommand = false;
-       private Boolean redirectStreams = true;
-       private Boolean exceptionOnFailed = true;
-       private Boolean mergeEnvironmentVariables = true;
-
-//     private Authentication authentication;
-
-       private String osConsole = null;
-       private String generateScript = null;
-
-       /** 24 hours */
-       private Long watchdogTimeout = 24 * 60 * 60 * 1000l;
-
-       private TestResult testResult;
-
-       private ExecutionResources executionResources;
-
-       /** Sudo the command, as root if empty or as user if not. */
-       private String sudo = null;
-       // TODO make it more secure and robust, test only once
-       private final String sudoPrompt = UUID.randomUUID().toString();
-       private String askPassProgram = "/usr/libexec/openssh/ssh-askpass";
-       @SuppressWarnings("unused")
-       private boolean firstLine = true;
-       @SuppressWarnings("unused")
-       private CallbackHandler callbackHandler;
-       /** Chroot to the this path (must not be empty) */
-       private String chroot = null;
-
-       // Current
-       /** Current watchdog, null if process is completed */
-       ExecuteWatchdog currentWatchdog = null;
-
-       /** Empty constructor */
-       public SystemCall() {
-
-       }
-
-       /**
-        * Constructor based on the provided command list.
-        * 
-        * @param command
-        *            the command list
-        */
-       public SystemCall(List<Object> command) {
-               this.command = command;
-       }
-
-       /**
-        * Constructor based on the provided command.
-        * 
-        * @param cmd
-        *            the command. If the provided string contains no space a
-        *            command list is initialized with the argument as first
-        *            component (useful for chained construction)
-        */
-       public SystemCall(String cmd) {
-               if (cmd.indexOf(' ') < 0) {
-                       command = new ArrayList<Object>();
-                       command.add(cmd);
-               } else {
-                       this.cmd = cmd;
-               }
-       }
-
-       /** Executes the system call. */
-       public void run() {
-//             authentication = SecurityContextHolder.getContext().getAuthentication();
-
-               // Manage streams
-               Writer stdOutWriter = null;
-               OutputStream stdOutputStream = null;
-               Writer stdErrWriter = null;
-               InputStream stdInStream = null;
-               if (stdOutFile != null)
-                       if (redirectStdOut)
-                               stdOutputStream = createOutputStream(stdOutFile);
-                       else
-                               stdOutWriter = createWriter(stdOutFile, true);
-
-               if (stdErrFile != null) {
-                       stdErrWriter = createWriter(stdErrFile, true);
-               } else {
-                       if (stdOutFile != null && !redirectStdOut)
-                               stdErrWriter = createWriter(stdOutFile, true);
-               }
-
-               try {
-                       if (stdInFile != null)
-                               stdInStream = stdInFile.getInputStream();
-                       else {
-                               stdInStream = new PipedInputStream();
-                               stdInSink = new PipedOutputStream(
-                                               (PipedInputStream) stdInStream);
-                       }
-               } catch (IOException e2) {
-                       throw new SlcException("Cannot open a stream for " + stdInFile, e2);
-               }
-
-               if (log.isTraceEnabled()) {
-                       log.debug("os.name=" + System.getProperty("os.name"));
-                       log.debug("os.arch=" + System.getProperty("os.arch"));
-                       log.debug("os.version=" + System.getProperty("os.version"));
-               }
-
-               // Execution directory
-               File dir = new File(getExecDirToUse());
-               // if (!dir.exists())
-               // dir.mkdirs();
-
-               // Watchdog to check for lost processes
-               Executor executorToUse;
-               if (executor != null)
-                       executorToUse = executor;
-               else
-                       executorToUse = new DefaultExecutor();
-               executorToUse.setWatchdog(createWatchdog());
-
-               if (redirectStreams) {
-                       // Redirect standard streams
-                       executorToUse.setStreamHandler(createExecuteStreamHandler(
-                                       stdOutWriter, stdOutputStream, stdErrWriter, stdInStream));
-               } else {
-                       // Dummy stream handler (otherwise pump is used)
-                       executorToUse.setStreamHandler(new DummyexecuteStreamHandler());
-               }
-
-               executorToUse.setProcessDestroyer(new ShutdownHookProcessDestroyer());
-               executorToUse.setWorkingDirectory(dir);
-
-               // Command line to use
-               final CommandLine commandLine = createCommandLine();
-               if (logCommand)
-                       log.info("Execute command:\n" + commandLine
-                                       + "\n in working directory: \n" + dir + "\n");
-
-               // Env variables
-               Map<String, String> environmentVariablesToUse = null;
-               environmentVariablesToUse = new HashMap<String, String>();
-               if (mergeEnvironmentVariables)
-                       environmentVariablesToUse.putAll(System.getenv());
-               if (environmentVariables.size() > 0)
-                       environmentVariablesToUse.putAll(environmentVariables);
-
-               // Execute
-               ExecuteResultHandler executeResultHandler = createExecuteResultHandler(commandLine);
-
-               //
-               // THE EXECUTION PROPER
-               //
-               try {
-                       if (synchronous)
-                               try {
-                                       int exitValue = executorToUse.execute(commandLine,
-                                                       environmentVariablesToUse);
-                                       executeResultHandler.onProcessComplete(exitValue);
-                               } catch (ExecuteException e1) {
-                                       if (e1.getExitValue() == Executor.INVALID_EXITVALUE) {
-                                               Thread.currentThread().interrupt();
-                                               return;
-                                       }
-                                       // Sleep 1s in order to make sure error logs are flushed
-                                       Thread.sleep(1000);
-                                       executeResultHandler.onProcessFailed(e1);
-                               }
-                       else
-                               executorToUse.execute(commandLine, environmentVariablesToUse,
-                                               executeResultHandler);
-               } catch (SlcException e) {
-                       throw e;
-               } catch (Exception e) {
-                       throw new SlcException("Could not execute command " + commandLine,
-                                       e);
-               } finally {
-                       IOUtils.closeQuietly(stdOutWriter);
-                       IOUtils.closeQuietly(stdErrWriter);
-                       IOUtils.closeQuietly(stdInStream);
-                       IOUtils.closeQuietly(stdInSink);
-               }
-
-       }
-
-       public synchronized String function() {
-               final StringBuffer buf = new StringBuffer("");
-               SystemCallOutputListener tempOutputListener = new SystemCallOutputListener() {
-                       private Long lineCount = 0l;
-
-                       public void newLine(SystemCall systemCall, String line,
-                                       Boolean isError) {
-                               if (!isError) {
-                                       if (lineCount != 0l)
-                                               buf.append('\n');
-                                       buf.append(line);
-                                       lineCount++;
-                               }
-                       }
-               };
-               addOutputListener(tempOutputListener);
-               run();
-               removeOutputListener(tempOutputListener);
-               return buf.toString();
-       }
-
-       public String asCommand() {
-               return createCommandLine().toString();
-       }
-
-       @Override
-       public String toString() {
-               return asCommand();
-       }
-
-       /**
-        * Build a command line based on the properties. Can be overridden by
-        * specific command wrappers.
-        */
-       protected CommandLine createCommandLine() {
-               // Check if an OS specific command overrides
-               String osName = System.getProperty("os.name");
-               List<Object> commandToUse = null;
-               if (osCommands.containsKey(osName))
-                       commandToUse = osCommands.get(osName);
-               else
-                       commandToUse = command;
-               String cmdToUse = null;
-               if (osCmds.containsKey(osName))
-                       cmdToUse = osCmds.get(osName);
-               else
-                       cmdToUse = cmd;
-
-               CommandLine commandLine = null;
-
-               // Which command definition to use
-               if (commandToUse == null && cmdToUse == null)
-                       throw new SlcException("Please specify a command.");
-               else if (commandToUse != null && cmdToUse != null)
-                       throw new SlcException(
-                                       "Specify the command either as a line or as a list.");
-               else if (cmdToUse != null) {
-                       if (chroot != null && !chroot.trim().equals(""))
-                               cmdToUse = "chroot \"" + chroot + "\" " + cmdToUse;
-                       if (sudo != null) {
-                               environmentVariables.put("SUDO_ASKPASS", askPassProgram);
-                               if (!sudo.trim().equals(""))
-                                       cmdToUse = "sudo -p " + sudoPrompt + " -u " + sudo + " "
-                                                       + cmdToUse;
-                               else
-                                       cmdToUse = "sudo -p " + sudoPrompt + " " + cmdToUse;
-                       }
-
-                       // GENERATE COMMAND LINE
-                       commandLine = CommandLine.parse(cmdToUse);
-               } else if (commandToUse != null) {
-                       if (commandToUse.size() == 0)
-                               throw new SlcException("Command line is empty.");
-
-                       if (chroot != null && sudo != null) {
-                               commandToUse.add(0, "chroot");
-                               commandToUse.add(1, chroot);
-                       }
-
-                       if (sudo != null) {
-                               environmentVariables.put("SUDO_ASKPASS", askPassProgram);
-                               commandToUse.add(0, "sudo");
-                               commandToUse.add(1, "-p");
-                               commandToUse.add(2, sudoPrompt);
-                               if (!sudo.trim().equals("")) {
-                                       commandToUse.add(3, "-u");
-                                       commandToUse.add(4, sudo);
-                               }
-                       }
-
-                       // GENERATE COMMAND LINE
-                       commandLine = new CommandLine(commandToUse.get(0).toString());
-
-                       for (int i = 1; i < commandToUse.size(); i++) {
-                               if (log.isTraceEnabled())
-                                       log.debug(commandToUse.get(i));
-                               commandLine.addArgument(commandToUse.get(i).toString());
-                       }
-               } else {
-                       // all cases covered previously
-                       throw new UnsupportedException();
-               }
-
-               if (generateScript != null) {
-                       File scriptFile = new File(getExecDirToUse() + File.separator
-                                       + generateScript);
-                       try {
-                               FileUtils.writeStringToFile(scriptFile,
-                                               (osConsole != null ? osConsole + " " : "")
-                                                               + commandLine.toString());
-                       } catch (IOException e) {
-                               throw new SlcException("Could not generate script "
-                                               + scriptFile, e);
-                       }
-                       commandLine = new CommandLine(scriptFile);
-               } else {
-                       if (osConsole != null)
-                               commandLine = CommandLine.parse(osConsole + " "
-                                               + commandLine.toString());
-               }
-
-               return commandLine;
-       }
-
-       /**
-        * Creates a {@link PumpStreamHandler} which redirects streams to the custom
-        * logging mechanism.
-        */
-       protected ExecuteStreamHandler createExecuteStreamHandler(
-                       final Writer stdOutWriter, final OutputStream stdOutputStream,
-                       final Writer stdErrWriter, final InputStream stdInStream) {
-
-               // Log writers
-               OutputStream stdout = stdOutputStream != null ? stdOutputStream
-                               : new LogOutputStream() {
-                                       protected void processLine(String line, int level) {
-                                               // if (firstLine) {
-                                               // if (sudo != null && callbackHandler != null
-                                               // && line.startsWith(sudoPrompt)) {
-                                               // try {
-                                               // PasswordCallback pc = new PasswordCallback(
-                                               // "sudo password", false);
-                                               // Callback[] cbs = { pc };
-                                               // callbackHandler.handle(cbs);
-                                               // char[] pwd = pc.getPassword();
-                                               // char[] arr = Arrays.copyOf(pwd,
-                                               // pwd.length + 1);
-                                               // arr[arr.length - 1] = '\n';
-                                               // IOUtils.write(arr, stdInSink);
-                                               // stdInSink.flush();
-                                               // } catch (Exception e) {
-                                               // throw new SlcException(
-                                               // "Cannot retrieve sudo password", e);
-                                               // }
-                                               // }
-                                               // firstLine = false;
-                                               // }
-
-                                               if (line != null && !line.trim().equals(""))
-                                                       logStdOut(line);
-
-                                               if (stdOutWriter != null)
-                                                       appendLineToFile(stdOutWriter, line);
-                                       }
-                               };
-
-               OutputStream stderr = new LogOutputStream() {
-                       protected void processLine(String line, int level) {
-                               if (line != null && !line.trim().equals(""))
-                                       logStdErr(line);
-                               if (stdErrWriter != null)
-                                       appendLineToFile(stdErrWriter, line);
-                       }
-               };
-
-               PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(stdout,
-                               stderr, stdInStream) {
-
-                       @Override
-                       public void stop() throws IOException {
-                               // prevents the method to block when joining stdin
-                               if (stdInSink != null)
-                                       IOUtils.closeQuietly(stdInSink);
-
-                               super.stop();
-                       }
-               };
-               return pumpStreamHandler;
-       }
-
-       /** Creates the default {@link ExecuteResultHandler}. */
-       protected ExecuteResultHandler createExecuteResultHandler(
-                       final CommandLine commandLine) {
-               return new ExecuteResultHandler() {
-
-                       public void onProcessComplete(int exitValue) {
-                               String msg = "System call '" + commandLine
-                                               + "' properly completed.";
-                               if (log.isTraceEnabled())
-                                       log.trace(msg);
-                               if (testResult != null) {
-                                       forwardPath(testResult);
-                                       testResult.addResultPart(new SimpleResultPart(
-                                                       TestStatus.PASSED, msg));
-                               }
-                               releaseWatchdog();
-                       }
-
-                       public void onProcessFailed(ExecuteException e) {
-
-                               String msg = "System call '" + commandLine + "' failed.";
-                               if (testResult != null) {
-                                       forwardPath(testResult);
-                                       testResult.addResultPart(new SimpleResultPart(
-                                                       TestStatus.ERROR, msg, e));
-                               } else {
-                                       if (exceptionOnFailed)
-                                               throw new SlcException(msg, e);
-                                       else
-                                               log.error(msg, e);
-                               }
-                               releaseWatchdog();
-                       }
-               };
-       }
-
-       @Deprecated
-       protected void forwardPath(TestResult testResult) {
-               // TODO: allocate a TreeSPath
-       }
-
-       /**
-        * Shortcut method getting the execDir to use
-        */
-       protected String getExecDirToUse() {
-               try {
-                       if (execDir != null) {
-                               return execDir;
-                       }
-                       return System.getProperty("user.dir");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot find exec dir", e);
-               }
-       }
-
-       protected void logStdOut(String line) {
-               for (SystemCallOutputListener outputListener : outputListeners)
-                       outputListener.newLine(this, line, false);
-               log(stdOutLogLevel, line);
-       }
-
-       protected void logStdErr(String line) {
-               for (SystemCallOutputListener outputListener : outputListeners)
-                       outputListener.newLine(this, line, true);
-               log(stdErrLogLevel, line);
-       }
-
-       /** Log from the underlying streams. */
-       protected void log(String logLevel, String line) {
-               // TODO optimize
-//             if (SecurityContextHolder.getContext().getAuthentication() == null) {
-//                     SecurityContextHolder.getContext()
-//                                     .setAuthentication(authentication);
-//             }
-
-               if ("ERROR".equals(logLevel))
-                       log.error(line);
-               else if ("WARN".equals(logLevel))
-                       log.warn(line);
-               else if ("INFO".equals(logLevel))
-                       log.info(line);
-               else if ("DEBUG".equals(logLevel))
-                       log.debug(line);
-               else if ("TRACE".equals(logLevel))
-                       log.trace(line);
-               else if (LOG_STDOUT.equals(logLevel))
-                       System.out.println(line);
-               else if ("System.err".equals(logLevel))
-                       System.err.println(line);
-               else
-                       throw new SlcException("Unknown log level " + logLevel);
-       }
-
-       /** Append line to a log file. */
-       protected void appendLineToFile(Writer writer, String line) {
-               try {
-                       writer.append(line).append('\n');
-               } catch (IOException e) {
-                       log.error("Cannot write to log file", e);
-               }
-       }
-
-       /** Creates the writer for the output/err files. */
-       protected Writer createWriter(Resource target, Boolean append) {
-               FileWriter writer = null;
-               try {
-
-                       final File file;
-                       if (executionResources != null)
-                               file = new File(executionResources.getAsOsPath(target, true));
-                       else
-                               file = target.getFile();
-                       writer = new FileWriter(file, append);
-               } catch (IOException e) {
-                       log.error("Cannot get file for " + target, e);
-                       IOUtils.closeQuietly(writer);
-               }
-               return writer;
-       }
-
-       /** Creates an outputstream for the output/err files. */
-       protected OutputStream createOutputStream(Resource target) {
-               FileOutputStream out = null;
-               try {
-
-                       final File file;
-                       if (executionResources != null)
-                               file = new File(executionResources.getAsOsPath(target, true));
-                       else
-                               file = target.getFile();
-                       out = new FileOutputStream(file, false);
-               } catch (IOException e) {
-                       log.error("Cannot get file for " + target, e);
-                       IOUtils.closeQuietly(out);
-               }
-               return out;
-       }
-
-       /** Append the argument (for chaining) */
-       public SystemCall arg(String arg) {
-               if (command == null)
-                       command = new ArrayList<Object>();
-               command.add(arg);
-               return this;
-       }
-
-       /** Append the argument (for chaining) */
-       public SystemCall arg(String arg, String value) {
-               if (command == null)
-                       command = new ArrayList<Object>();
-               command.add(arg);
-               command.add(value);
-               return this;
-       }
-
-       // CONTROL
-       public synchronized Boolean isRunning() {
-               return currentWatchdog != null;
-       }
-
-       private synchronized ExecuteWatchdog createWatchdog() {
-//             if (currentWatchdog != null)
-//                     throw new SlcException("A process is already being monitored");
-               currentWatchdog = new ExecuteWatchdog(watchdogTimeout);
-               return currentWatchdog;
-       }
-
-       private synchronized void releaseWatchdog() {
-               currentWatchdog = null;
-       }
-
-       public synchronized void kill() {
-               if (currentWatchdog != null)
-                       currentWatchdog.destroyProcess();
-       }
-
-       /** */
-       public void setCmd(String command) {
-               this.cmd = command;
-       }
-
-       public void setCommand(List<Object> command) {
-               this.command = command;
-       }
-
-       public void setExecDir(String execdir) {
-               this.execDir = execdir;
-       }
-
-       public void setStdErrLogLevel(String stdErrLogLevel) {
-               this.stdErrLogLevel = stdErrLogLevel;
-       }
-
-       public void setStdOutLogLevel(String stdOutLogLevel) {
-               this.stdOutLogLevel = stdOutLogLevel;
-       }
-
-       public void setSynchronous(Boolean synchronous) {
-               this.synchronous = synchronous;
-       }
-
-       public void setOsCommands(Map<String, List<Object>> osCommands) {
-               this.osCommands = osCommands;
-       }
-
-       public void setOsCmds(Map<String, String> osCmds) {
-               this.osCmds = osCmds;
-       }
-
-       public void setEnvironmentVariables(Map<String, String> environmentVariables) {
-               this.environmentVariables = environmentVariables;
-       }
-
-       public Map<String, String> getEnvironmentVariables() {
-               return environmentVariables;
-       }
-
-       public void setWatchdogTimeout(Long watchdogTimeout) {
-               this.watchdogTimeout = watchdogTimeout;
-       }
-
-       public void setStdOutFile(Resource stdOutFile) {
-               this.stdOutFile = stdOutFile;
-       }
-
-       public void setStdErrFile(Resource stdErrFile) {
-               this.stdErrFile = stdErrFile;
-       }
-
-       public void setStdInFile(Resource stdInFile) {
-               this.stdInFile = stdInFile;
-       }
-
-       public void setTestResult(TestResult testResult) {
-               this.testResult = testResult;
-       }
-
-       public void setLogCommand(Boolean logCommand) {
-               this.logCommand = logCommand;
-       }
-
-       public void setRedirectStreams(Boolean redirectStreams) {
-               this.redirectStreams = redirectStreams;
-       }
-
-       public void setExceptionOnFailed(Boolean exceptionOnFailed) {
-               this.exceptionOnFailed = exceptionOnFailed;
-       }
-
-       public void setMergeEnvironmentVariables(Boolean mergeEnvironmentVariables) {
-               this.mergeEnvironmentVariables = mergeEnvironmentVariables;
-       }
-
-       public void setOsConsole(String osConsole) {
-               this.osConsole = osConsole;
-       }
-
-       public void setGenerateScript(String generateScript) {
-               this.generateScript = generateScript;
-       }
-
-       public void setExecutionResources(ExecutionResources executionResources) {
-               this.executionResources = executionResources;
-       }
-
-       public void setRedirectStdOut(Boolean redirectStdOut) {
-               this.redirectStdOut = redirectStdOut;
-       }
-
-       public void addOutputListener(SystemCallOutputListener outputListener) {
-               outputListeners.add(outputListener);
-       }
-
-       public void removeOutputListener(SystemCallOutputListener outputListener) {
-               outputListeners.remove(outputListener);
-       }
-
-       public void setOutputListeners(
-                       List<SystemCallOutputListener> outputListeners) {
-               this.outputListeners = outputListeners;
-       }
-
-       public void setExecutor(Executor executor) {
-               this.executor = executor;
-       }
-
-       public void setSudo(String sudo) {
-               this.sudo = sudo;
-       }
-
-       public void setCallbackHandler(CallbackHandler callbackHandler) {
-               this.callbackHandler = callbackHandler;
-       }
-
-       public void setChroot(String chroot) {
-               this.chroot = chroot;
-       }
-
-       private class DummyexecuteStreamHandler implements ExecuteStreamHandler {
-
-               public void setProcessErrorStream(InputStream is) throws IOException {
-               }
-
-               public void setProcessInputStream(OutputStream os) throws IOException {
-               }
-
-               public void setProcessOutputStream(InputStream is) throws IOException {
-               }
-
-               public void start() throws IOException {
-               }
-
-               public void stop() {
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCallOutputListener.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCallOutputListener.java
deleted file mode 100644 (file)
index 7972cdc..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-public interface SystemCallOutputListener {
-       public void newLine(SystemCall systemCall, String line, Boolean isError);
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/UploadAttachments.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/UploadAttachments.java
deleted file mode 100644 (file)
index 83f2ee8..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.argeo.slc.core.execution.tasks;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.attachment.Attachment;
-import org.argeo.slc.attachment.AttachmentsEnabled;
-import org.argeo.slc.core.attachment.AttachmentUploader;
-import org.springframework.core.io.Resource;
-
-public class UploadAttachments implements Runnable {
-       private AttachmentUploader attachmentUploader;
-       private Attachment attachment = null;
-       private Resource resource = null;
-       private Map<Attachment, Resource> attachments = new HashMap<Attachment, Resource>();
-       private List<AttachmentsEnabled> attachTo = new ArrayList<AttachmentsEnabled>();
-       private Boolean newUuidPerExecution = true;
-
-       public void run() {
-               if (attachment != null) {
-                       if (resource == null)
-                               throw new SlcException("A resource must be specified.");
-                       uploadAndAdd(attachment, resource);
-               }
-
-               for (Attachment attachmentT : attachments.keySet()) {
-                       Resource resourceT = attachments.get(attachmentT);
-                       uploadAndAdd(attachmentT, resourceT);
-               }
-
-       }
-
-       protected void uploadAndAdd(Attachment attachment, Resource resource) {
-               if (newUuidPerExecution)
-                       attachment.setUuid(UUID.randomUUID().toString());
-               attachmentUploader.upload(attachment, resource);
-               for (AttachmentsEnabled attachmentsEnabled : attachTo) {
-                       attachmentsEnabled.addAttachment(attachment);
-               }
-       }
-
-       public void setAttachmentUploader(AttachmentUploader attachmentUploader) {
-               this.attachmentUploader = attachmentUploader;
-       }
-
-       public void setAttachments(Map<Attachment, Resource> attachments) {
-               this.attachments = attachments;
-       }
-
-       public void setAttachTo(List<AttachmentsEnabled> attachTo) {
-               this.attachTo = attachTo;
-       }
-
-       public void setAttachment(Attachment attachment) {
-               this.attachment = attachment;
-       }
-
-       public void setResource(Resource resource) {
-               this.resource = resource;
-       }
-
-       public void setNewUuidPerExecution(Boolean newUuidPerExecution) {
-               this.newUuidPerExecution = newUuidPerExecution;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/core.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/core.xml
deleted file mode 100644 (file)
index df35944..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-            http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
-       <bean id="task.echo" class="org.argeo.slc.core.execution.tasks.Echo"
-               abstract="true" />
-       <bean id="task.systemCall" class="org.argeo.slc.core.execution.tasks.SystemCall"
-               abstract="true" />
-       <bean id="task.closeTestResult" class="org.argeo.slc.core.execution.tasks.CloseTestResult"
-               abstract="true" />
-       <bean id="task.slcManager" class="org.argeo.slc.core.execution.tasks.SlcManager"
-               abstract="true" />
-       <bean id="task.overrideContextAware" class="org.argeo.slc.core.execution.tasks.OverrideContextAware"
-               abstract="true" />
-       <bean id="task.uploadAttachments" class="org.argeo.slc.core.execution.tasks.UploadAttachments"
-               abstract="true" />
-
-       <bean id="taskArg.attachment" class="org.argeo.slc.core.attachment.SimpleAttachment"
-               abstract="true" />
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/templates.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/templates.xml
deleted file mode 100644 (file)
index 28b742a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-            http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
-       <bean id="slcTemplate.fileResources" class="org.argeo.slc.core.execution.FileExecutionResources"
-               abstract="true" />
-
-       <bean id="slcTemplate.resourcesFactoryBean" parent="slcTemplate.writableResource"
-               abstract="true" />
-
-       <bean id="slcTemplate.writableResource"
-               class="org.argeo.slc.core.execution.ExecutionResourcesFactoryBean"
-               abstract="true" />
-
-       <bean id="slcTemplate.osFile" class="org.argeo.slc.core.execution.OsFileFactoryBean"
-               abstract="true" />
-
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/utils.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/utils.xml
deleted file mode 100644 (file)
index 527e701..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-            http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:aop="http://www.springframework.org/schema/aop"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
-       <bean id="mergedLists" class="org.argeo.slc.core.execution.tasks.MergedLists"
-               abstract="true">
-       </bean>
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/AsFlowDecorator.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/AsFlowDecorator.java
deleted file mode 100644 (file)
index b68d9c7..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.argeo.slc.core.execution.xml;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.DefaultExecutionFlow;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.springframework.beans.BeanMetadataElement;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/** Publishes a {@link Runnable} as an {@link ExecutionFlow} */
-public class AsFlowDecorator implements BeanDefinitionDecorator {
-       private Log log = LogFactory.getLog(AsFlowDecorator.class);
-
-       public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder bean,
-                       ParserContext ctx) {
-               String attrValue = ((Attr) node).getValue();
-               if (attrValue.charAt(attrValue.length() - 1) == '/')
-                       throw new SlcException(attrValue + " cannot end with a path");
-               final String flowBeanName = attrValue;
-
-               if (log.isTraceEnabled())
-                       log.trace("flowBeanName=" + flowBeanName);
-
-               if (ctx.getRegistry().containsBeanDefinition(flowBeanName))
-                       throw new SlcException("A bean named " + flowBeanName
-                                       + " is already defined.");
-               BeanDefinitionBuilder flow = BeanDefinitionBuilder
-                               .rootBeanDefinition(DefaultExecutionFlow.class);
-               ManagedList<BeanMetadataElement> executables = new ManagedList<BeanMetadataElement>(
-                               1);
-
-               String beanName = bean.getBeanName();
-               if (beanName == null)
-                       executables.add(bean.getBeanDefinition());
-               else
-                       executables.add(new RuntimeBeanReference(beanName));
-
-               // if (path != null)
-               // flow.addPropertyValue("path", path);
-               flow.addPropertyValue("executables", executables);
-
-               if (beanName != null)
-                       ctx.getRegistry().registerBeanDefinition(flowBeanName,
-                                       flow.getBeanDefinition());
-               return bean;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ExecutionScopeDecorator.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ExecutionScopeDecorator.java
deleted file mode 100644 (file)
index b756381..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.argeo.slc.core.execution.xml;
-
-import org.springframework.aop.scope.ScopedProxyUtils;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.parsing.BeanComponentDefinition;
-import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Inspired by org.springframework.aop.config.ScopedProxyBeanDefinitionDecorator
- */
-public class ExecutionScopeDecorator implements BeanDefinitionDecorator {      
-       private static final String PROXY_TARGET_CLASS = "proxy-target-class";  
-       
-       public BeanDefinitionHolder decorate(Node node,
-                       BeanDefinitionHolder definition, ParserContext parserContext) {
-               
-               definition.getBeanDefinition().setScope("execution");
-               
-               // Default: CGLib not used
-               boolean proxyTargetClass = false;
-               if (node instanceof Element) {
-                       Element ele = (Element) node;
-                       if (ele.hasAttribute(PROXY_TARGET_CLASS)) {
-                               proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS)).booleanValue();
-                       }
-               }
-               
-               // Register the original bean definition as it will be referenced by the scoped proxy and is relevant for tooling (validation, navigation).
-               String targetBeanName = ScopedProxyUtils.getTargetBeanName(definition.getBeanName());
-               parserContext.getReaderContext().fireComponentRegistered(new BeanComponentDefinition(definition.getBeanDefinition(), targetBeanName));
-               
-               return ScopedProxyUtils.createScopedProxy(definition, parserContext.getRegistry(), proxyTargetClass);           
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java
deleted file mode 100644 (file)
index 60e8699..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-package org.argeo.slc.core.execution.xml;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.DefaultExecutionFlow;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.ManagedMap;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/** Interprets the <flow:flow> tag */
-public class FlowBeanDefinitionParser extends
-               AbstractSingleBeanDefinitionParser {
-       private Log log = LogFactory.getLog(FlowBeanDefinitionParser.class);
-
-       /** Whether the user has already be warned on path attribute usage. */
-       private Boolean warnedAboutPathAttribute = false;
-
-       @Override
-       protected void doParse(Element element, ParserContext parserContext,
-                       BeanDefinitionBuilder builder) {
-               String path = element.getAttribute("path");
-               if (StringUtils.hasText(path)) {
-                       builder.addPropertyValue("path", path);
-
-                       // warns user only once
-                       if (!warnedAboutPathAttribute)
-                               log.warn("The path=\"\" attribute is deprecated"
-                                               + " and will be removed in a later release."
-                                               + " Use <flow:flow name=\"/my/path/flowName\">.");
-                       warnedAboutPathAttribute = true;
-               }
-
-               String spec = element.getAttribute("spec");
-               if (StringUtils.hasText(spec))
-                       builder.getBeanDefinition().getConstructorArgumentValues()
-                                       .addGenericArgumentValue(new RuntimeBeanReference(spec));
-
-               String abstrac = element.getAttribute("abstract");
-               if (StringUtils.hasText(abstrac))
-                       builder.setAbstract(Boolean.parseBoolean(abstrac));
-
-               String parent = element.getAttribute("parent");
-               if (StringUtils.hasText(parent))
-                       builder.setParentName(parent);
-
-               builder.getBeanDefinition().setDescription(
-                               DomUtils.getChildElementValueByTagName(element, "description"));
-
-               List<Element> argsElems = new ArrayList<Element>();
-               List<Element> execElems = new ArrayList<Element>();
-               List<Element> specElems = new ArrayList<Element>();
-               NodeList nodeList = element.getChildNodes();
-               for (int i = 0; i < nodeList.getLength(); i++) {
-                       Node node = nodeList.item(i);
-                       if (node instanceof Element) {
-                               if (DomUtils.nodeNameEquals(node, "arg"))
-                                       argsElems.add((Element) node);
-                               else if (DomUtils.nodeNameEquals(node, "spec"))
-                                       specElems.add((Element) node);
-                               else if (!DomUtils.nodeNameEquals(node, "description"))
-                                       execElems.add((Element) node);
-                       }
-               }
-
-               // Arguments
-               if (argsElems.size() != 0) {
-                       ManagedMap<String, Object> args = new ManagedMap<String, Object>(
-                                       argsElems.size());
-                       for (Element argElem : argsElems) {
-                               Object value = NamespaceUtils.parseValue(argElem,
-                                               parserContext, builder.getBeanDefinition(), null);
-                               if (value != null)
-                                       args.put(argElem.getAttribute("name"), value);
-                               else
-                                       throw new SlcException("No value defined.");
-                       }
-                       builder.getBeanDefinition().getConstructorArgumentValues()
-                                       .addGenericArgumentValue(args);
-               }
-
-               // Execution specs
-               if (StringUtils.hasText(spec) && specElems.size() != 0)
-                       throw new SlcException("A flow cannot have multiple specs");
-               if (specElems.size() == 1) {
-                       Object specObj = NamespaceUtils.parseBeanOrReference(
-                                       specElems.get(0), parserContext,
-                                       builder.getBeanDefinition());
-                       builder.getBeanDefinition().getConstructorArgumentValues()
-                                       .addGenericArgumentValue(specObj);
-               } else if (specElems.size() > 1)
-                       throw new SlcException("A flow cannot have multiple specs");
-
-               // Executables
-               if (execElems.size() != 0) {
-                       ManagedList<Object> executables = new ManagedList<Object>(
-                                       execElems.size());
-                       for (Element child : execElems) {
-                               // child validity check is performed in xsd
-                               executables.add(NamespaceUtils.parseBeanOrReference(child,
-                                               parserContext, builder.getBeanDefinition()));
-                       }
-                       if (executables.size() > 0)
-                               builder.addPropertyValue("executables", executables);
-               }
-       }
-
-       @SuppressWarnings("unchecked")
-       @Override
-       protected Class<? extends ExecutionFlow> getBeanClass(Element element) {
-               String clss = element.getAttribute("class");
-               if (StringUtils.hasText(clss))
-                       // TODO: check that it actually works
-                       try {
-                               return (Class<? extends ExecutionFlow>) getClass()
-                                               .getClassLoader().loadClass(clss);
-                       } catch (ClassNotFoundException e) {
-                               try {
-                                       return (Class<? extends ExecutionFlow>) Thread
-                                                       .currentThread().getContextClassLoader()
-                                                       .loadClass(clss);
-                               } catch (ClassNotFoundException e1) {
-                                       throw new SlcException("Cannot load class " + clss, e);
-                               }
-                       }
-               else
-                       return DefaultExecutionFlow.class;
-       }
-
-       // parse nested bean definition
-       // private Object parseBeanReference(Element element,
-       // ParserContext parserContext, BeanDefinitionBuilder builder) {
-       // return parserContext.getDelegate().parsePropertySubElement(element,
-       // builder.getBeanDefinition());
-       // }
-
-       @Override
-       protected String resolveId(Element element,
-                       AbstractBeanDefinition definition, ParserContext parserContext)
-                       throws BeanDefinitionStoreException {
-               String name = element.getAttribute("name");
-               if (StringUtils.hasText(name)) {
-                       return name;
-               } else {
-                       return super.resolveId(element, definition, parserContext);
-               }
-       }
-
-       protected boolean shouldGenerateIdAsFallback() {
-               return true;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowNamespaceHandler.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowNamespaceHandler.java
deleted file mode 100644 (file)
index a1d6912..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.argeo.slc.core.execution.xml;
-
-import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
-public class FlowNamespaceHandler extends NamespaceHandlerSupport {
-
-       public void init() {
-               registerBeanDefinitionParser("flow", new FlowBeanDefinitionParser());
-               registerBeanDefinitionParser("spec", new SpecBeanDefinitionParser());
-               registerBeanDefinitionDecoratorForAttribute("as-flow",
-                               new AsFlowDecorator());
-               registerBeanDefinitionParser("param", new ParamDecorator());
-                
-               // The objective was to replace
-               // - attribute scope="execution"
-               // - and element "aop:scoped-proxy" 
-               // by a single attribute, using an attribute decorator 
-               // this does not work correctly with other attribute decorators (e.g. 
-               // p namespace) since this decorator needs to be called after all
-               // properties have been set on target bean. 
-               // It works properly with element decorators (called after all attribute
-               // decorators
-               registerBeanDefinitionDecorator("variable", new ExecutionScopeDecorator());
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/NamespaceUtils.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/NamespaceUtils.java
deleted file mode 100644 (file)
index baa0152..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.argeo.slc.core.execution.xml;
-
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Utilities to simplify common tasks when interpreting a custom namespace and
- * converting it into bean definitions.
- */
-public class NamespaceUtils {
-       // private final static Log log = LogFactory.getLog(NamespaceUtils.class);
-
-       /**
-        * Returns the value defined either: directly by the the 'value' attribute,
-        * as reference by the 'ref' attribute or as a nested bean.
-        */
-       public static Object parseValue(Element element,
-                       ParserContext parserContext,
-                       BeanDefinition containingBeanDefintion, String valueTagName) {
-               Object value = null;
-               if (element.hasAttribute("value")) {
-                       value = element.getAttribute("value");
-               }
-
-               if (element.hasAttribute("ref")) {
-                       if (value != null)
-                               throw new SlcException("Multiple value definition for "
-                                               + element);
-                       value = new RuntimeBeanReference(element.getAttribute("ref"));
-               }
-
-               Element uniqueSubElem = null;
-               if (valueTagName != null) {
-                       Element valueElem = DomUtils.getChildElementByTagName(element,
-                                       valueTagName);
-                       if (valueElem != null) {
-                               uniqueSubElem = findUniqueSubElement(valueElem);
-                               if (uniqueSubElem == null)
-                                       throw new SlcException("No subelement found under "
-                                                       + valueElem);
-                       }
-               } else {// no intermediary tag
-                       uniqueSubElem = findUniqueSubElement(element);
-               }
-
-               if (uniqueSubElem != null) {
-                       if (value != null)
-                               throw new SlcException("Multiple value definition for "
-                                               + element);
-                       value = parseBeanOrReference(uniqueSubElem, parserContext,
-                                       containingBeanDefintion);
-               }
-               return value;
-       }
-
-       public static Element findUniqueSubElement(Element element) {
-               NodeList childNodes = element.getChildNodes();
-
-               Element uniqueSubElem = null;
-               for (int i = 0; i < childNodes.getLength(); i++) {
-                       Node node = childNodes.item(i);
-                       if (node != null && node instanceof Element) {
-                               if (uniqueSubElem == null)
-                                       uniqueSubElem = (Element) node;
-                               else
-                                       throw new SlcException(
-                                                       "There are more than one sub element under "
-                                                                       + element);
-                       }
-               }
-               return uniqueSubElem;
-       }
-
-       public static Object parseBeanOrReference(Element element,
-                       ParserContext parserContext, BeanDefinition beanDefinition) {
-               // return parserContext.getDelegate().parsePropertySubElement(element,
-               // beanDefinition);
-
-               BeanDefinitionParserDelegate deleg = parserContext.getDelegate();
-               // if ("bean".equals(element.getNodeName()))
-               // return deleg.parseBeanDefinitionElement(element, beanDefinition);
-               // else
-               return deleg.parsePropertySubElement(element, beanDefinition);
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ParamDecorator.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ParamDecorator.java
deleted file mode 100644 (file)
index ed7a223..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.argeo.slc.core.execution.xml;
-
-import org.argeo.slc.core.execution.ParameterRef;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-import org.w3c.dom.Element;
-
-public class ParamDecorator extends AbstractSingleBeanDefinitionParser {
-
-       // public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder
-       // bean,
-       // ParserContext ctx) {
-       // String paramName = ((Element) node).getAttribute("name");
-       // String propertyName = ((Element) node.getParentNode())
-       // .getAttribute("name");
-       // BeanDefinitionBuilder parameterRef = BeanDefinitionBuilder
-       // .genericBeanDefinition(ParameterRef.class);
-       // parameterRef.addPropertyReference("instantiationManager",
-       // "instantiationManager");
-       // parameterRef.addConstructorArgValue(paramName);
-       // bean.getBeanDefinition().getPropertyValues().addPropertyValue(
-       // propertyName, parameterRef.getBeanDefinition());
-       // return bean;
-       // }
-
-       @Override
-       protected void doParse(Element element, ParserContext parserContext,
-                       BeanDefinitionBuilder builder) {
-               String paramName = element.getAttribute("name");
-
-               String instantationManagerRef = element
-                               .getAttribute("instantiationManager");
-               if (!StringUtils.hasText(instantationManagerRef))
-                       instantationManagerRef = "instantiationManager";
-               builder.addPropertyReference("instantiationManager",
-                               instantationManagerRef);
-               builder.addConstructorArgValue(paramName);
-       }
-
-       @Override
-       protected Class<ParameterRef> getBeanClass(Element element) {
-               return ParameterRef.class;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java
deleted file mode 100644 (file)
index 937e8d0..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.argeo.slc.core.execution.xml;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValueChoice;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.ManagedMap;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-
-/** Interprets the <flow:spec> tag */
-public class SpecBeanDefinitionParser extends
-               AbstractSingleBeanDefinitionParser {
-       private Log log = LogFactory.getLog(SpecBeanDefinitionParser.class);
-
-       @Override
-       protected void doParse(Element element, ParserContext parserContext,
-                       BeanDefinitionBuilder builder) {
-               builder.getBeanDefinition().setDescription(
-                               DomUtils.getChildElementValueByTagName(element, "description"));
-
-               ManagedMap<String, BeanDefinition> attributes = new ManagedMap<String, BeanDefinition>();
-
-               // Primitives
-               for (Element child : (List<Element>) DomUtils
-                               .getChildElementsByTagName(element, "primitive")) {
-                       BeanDefinitionBuilder childBuilder = BeanDefinitionBuilder
-                                       .genericBeanDefinition(PrimitiveSpecAttribute.class);
-                       addCommonProperties(child, parserContext, childBuilder);
-
-                       String type = child.getAttribute("type");
-                       if (StringUtils.hasText(type))
-                               childBuilder.addPropertyValue("type", type);
-
-                       putInAttributes(attributes, child,
-                                       childBuilder.getBeanDefinition(), "primitive");
-               }
-
-               // Refs
-               for (Element refAttrElem : (List<Element>) DomUtils
-                               .getChildElementsByTagName(element, "ref")) {
-                       BeanDefinitionBuilder refAttrBuilder = BeanDefinitionBuilder
-                                       .genericBeanDefinition(RefSpecAttribute.class);
-                       addCommonProperties(refAttrElem, parserContext, refAttrBuilder);
-
-                       String targetClassName = refAttrElem.getAttribute("targetClass");
-                       if (StringUtils.hasText(targetClassName))
-                               refAttrBuilder.addPropertyValue("targetClass", targetClassName);
-
-                       // Choices
-                       Element choicesElem = DomUtils.getChildElementByTagName(
-                                       refAttrElem, "choices");
-                       if (choicesElem != null) {
-                               List<Element> choices = DomUtils.getChildElementsByTagName(
-                                               choicesElem, "choice");
-                               ManagedList<BeanDefinition> choiceBeans = new ManagedList<BeanDefinition>(
-                                               choices.size());
-                               for (Element choiceElem : choices) {
-                                       BeanDefinitionBuilder choiceBuilder = BeanDefinitionBuilder
-                                                       .genericBeanDefinition(RefValueChoice.class);
-                                       choiceBuilder.addPropertyValue("name",
-                                                       choiceElem.getAttribute("name"));
-                                       String desc = choiceElem.getAttribute("description");
-                                       if (StringUtils.hasText(desc))
-                                               choiceBuilder.addPropertyValue("description", desc);
-
-                                       choiceBeans.add(choiceBuilder.getBeanDefinition());
-                               }
-                               refAttrBuilder.addPropertyValue("choices", choiceBeans);
-                       }
-
-                       putInAttributes(attributes, refAttrElem,
-                                       refAttrBuilder.getBeanDefinition(), "ref");
-               }
-
-               builder.addPropertyValue("attributes", attributes);
-       }
-
-       protected void addCommonProperties(Element element,
-                       ParserContext parserContext, BeanDefinitionBuilder specAttr) {
-               addBooleanProperty("isImmutable", specAttr, element);
-               addBooleanProperty("isConstant", specAttr, element);
-               addBooleanProperty("isHidden", specAttr, element);
-               addBooleanProperty("isParameter", specAttr, element);
-               addBooleanProperty("isFrozen", specAttr, element);
-
-               Object value = NamespaceUtils.parseValue(element, parserContext,
-                               specAttr.getBeanDefinition(), "value");
-               if (value != null)
-                       specAttr.addPropertyValue("value", value);
-
-       }
-
-       protected void putInAttributes(
-                       ManagedMap<String, BeanDefinition> attributes, Element child,
-                       BeanDefinition beanDefinition, String nature) {
-               String name = child.getAttribute("name");
-               attributes.put(name, beanDefinition);
-               if (log.isTraceEnabled())
-                       log.debug("Added " + nature + " attribute " + name);
-
-       }
-
-       private void addBooleanProperty(String name,
-                       BeanDefinitionBuilder specAttr, Element element) {
-               String bool = element.getAttribute(name);
-               if (StringUtils.hasText(bool))
-                       specAttr.addPropertyValue(name, Boolean.parseBoolean(bool));
-
-       }
-
-       @Override
-       protected Class<DefaultExecutionSpec> getBeanClass(Element element) {
-               return DefaultExecutionSpec.class;
-       }
-
-       protected boolean shouldGenerateIdAsFallback() {
-               return false;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd
deleted file mode 100644 (file)
index 8b31a60..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-       xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns:beans="http://www.springframework.org/schema/beans"
-       targetNamespace="http://www.argeo.org/schema/slc-flow"
-       elementFormDefault="qualified" attributeFormDefault="unqualified">
-
-       <xsd:import namespace="http://www.springframework.org/schema/beans"
-               schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" />
-
-       <xsd:annotation>
-               <xsd:documentation><![CDATA[
-       SLC Flow Schema, version 0.12
-       Authors: Mathieu Baudier
-       
-       This simplifies the definition of SLC flows and their integration with 
-       regular Spring beans.
-               ]]></xsd:documentation>
-       </xsd:annotation>
-
-       <xsd:element name="flow">
-               <xsd:annotation>
-                       <xsd:documentation><![CDATA[
-       Adds an SLC execution flow, using the default implementation.
-                       ]]></xsd:documentation>
-               </xsd:annotation>
-               <xsd:complexType>
-                       <xsd:complexContent>
-                               <xsd:extension base="beans:identifiedType">
-                                       <xsd:sequence>
-                                               <xsd:element ref="beans:description" minOccurs="0" />
-                                               <xsd:sequence>
-                                                       <xsd:element name="arg" minOccurs="0" maxOccurs="unbounded"
-                                                               type="flow:argType">
-                                                               <xsd:annotation>
-                                                                       <xsd:documentation><![CDATA[
-       Parameter for an execution flow which will override at instantiation the 
-       value of the parameter already defined as default value or in a parent bean.
-                                                                       ]]></xsd:documentation>
-                                                               </xsd:annotation>
-                                                       </xsd:element>
-                                               </xsd:sequence>
-                                               <xsd:sequence>
-                                                       <xsd:choice minOccurs="0" maxOccurs="unbounded">
-                                                               <xsd:element ref="beans:bean" />
-                                                               <xsd:element ref="beans:ref" />
-                                                               <xsd:element ref="flow:flow" />
-                                                       </xsd:choice>
-                                                       <!--
-                                                               <xsd:any namespace="##other" processContents="strict"
-                                                               minOccurs="0" maxOccurs="unbounded" />
-                                                       -->
-                                               </xsd:sequence>
-                                       </xsd:sequence>
-                                       <xsd:attribute name="name" type="xsd:string">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       Name of the flow (alternative to ID).
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="class" type="xsd:string">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       Another implementation of execution flow.
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="path" type="xsd:string">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       The hierarchical path under which to register this flow.
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="spec" type="xsd:string">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       A reference to the related specification bean.
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="parent" type="xsd:string">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       The parent bean definition (in Spring sense).
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="abstract" type="xsd:boolean"
-                                               default="false">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       Whether this flow is abstract (in Spring sense).
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                               </xsd:extension>
-                       </xsd:complexContent>
-               </xsd:complexType>
-       </xsd:element>
-
-       <xsd:element name="spec">
-               <xsd:annotation>
-                       <xsd:documentation><![CDATA[
-       SLC flow specifications, defining the parameters and variables
-       which can be used in related flows, along with their default values and 
-       various constraints.
-                       ]]></xsd:documentation>
-               </xsd:annotation>
-               <xsd:complexType>
-                       <xsd:complexContent>
-                               <xsd:extension base="beans:identifiedType">
-                                       <xsd:sequence>
-                                               <xsd:element ref="beans:description" minOccurs="0" />
-                                               <xsd:choice minOccurs="0" maxOccurs="unbounded">
-                                                       <xsd:element name="primitive" type="flow:primitiveSpecAttributeType"
-                                                               minOccurs="0" maxOccurs="unbounded">
-                                                               <xsd:annotation>
-                                                                       <xsd:documentation><![CDATA[
-       A primitive specification attribute, that is, a plain standard value
-       and not a reference to an object.
-                                                                       ]]></xsd:documentation>
-                                                               </xsd:annotation>
-                                                       </xsd:element>
-                                                       <xsd:element name="ref" type="flow:refSpecAttributeType"
-                                                               minOccurs="0" maxOccurs="unbounded">
-                                                               <xsd:annotation>
-                                                                       <xsd:documentation><![CDATA[
-       A reference specification attribute, that is, a reference to another object.
-                                                                       ]]></xsd:documentation>
-                                                               </xsd:annotation>
-                                                       </xsd:element>
-                                               </xsd:choice>
-                                       </xsd:sequence>
-                               </xsd:extension>
-                       </xsd:complexContent>
-               </xsd:complexType>
-       </xsd:element>
-
-       <xsd:complexType name="specAttributeType">
-               <xsd:choice>
-                       <xsd:element name="value" minOccurs="0" maxOccurs="1">
-                               <xsd:annotation>
-                                       <xsd:documentation><![CDATA[
-       The default value of the attribute as an inner bean.
-                                       ]]></xsd:documentation>
-                               </xsd:annotation>
-                               <xsd:complexType>
-                                       <xsd:choice minOccurs="1" maxOccurs="1">
-                                               <xsd:element ref="beans:bean" />
-                                               <xsd:element ref="beans:ref" />
-                                               <xsd:element ref="beans:list" />
-                                               <xsd:element ref="beans:set" />
-                                               <xsd:element ref="beans:map" />
-                                               <xsd:element ref="beans:props" />
-                                       </xsd:choice>
-                               </xsd:complexType>
-                       </xsd:element>
-               </xsd:choice>
-               <xsd:attribute name="name" use="required" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The name of the attribute, under which in can then be referenced.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="value" use="optional" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The default value of the attribute.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="ref" use="optional" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The default value of the attribute as a reference to another bean.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="isParameter" use="optional" type="xsd:boolean"
-                       default="false">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Whether the attribute is a parameter, that is, it has to be set at 
-       instantiation but can be modified afterwards for objects of scope execution.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="isFrozen" use="optional" type="xsd:boolean"
-                       default="false">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Whether the attribute is frozen, that is, it cannot be modified at runtime.
-       A frozen attribute has to be a parameter.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="isHidden" use="optional" type="xsd:boolean"
-                       default="false">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Whether the attribute is hidden, that is, it should not be displayed in UIs.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-       </xsd:complexType>
-
-       <xsd:complexType name="primitiveSpecAttributeType">
-               <xsd:complexContent>
-                       <xsd:extension base="flow:specAttributeType">
-                               <xsd:attribute name="type" default="string">
-                                       <xsd:annotation>
-                                               <xsd:documentation><![CDATA[
-       The type of the primitive specification attribute.
-                                               ]]></xsd:documentation>
-                                       </xsd:annotation>
-                                       <xsd:simpleType>
-                                               <xsd:restriction base="xsd:string">
-                                                       <xsd:enumeration value="string" />
-                                                       <xsd:enumeration value="integer" />
-                                                       <xsd:enumeration value="long" />
-                                                       <xsd:enumeration value="float" />
-                                                       <xsd:enumeration value="double" />
-                                                       <xsd:enumeration value="boolean" />
-                                               </xsd:restriction>
-                                       </xsd:simpleType>
-                               </xsd:attribute>
-                       </xsd:extension>
-               </xsd:complexContent>
-       </xsd:complexType>
-
-       <xsd:complexType name="refSpecAttributeType">
-               <xsd:complexContent>
-                       <xsd:extension base="flow:specAttributeType">
-                               <xsd:choice>
-                                       <xsd:element name="choices" minOccurs="0" maxOccurs="1">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       Possible values to chose from, if ommitted, all the beans in the 
-       application context which implement the provided targetClass will 
-       be considered.
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                               <xsd:complexType>
-                                                       <xsd:choice>
-                                                               <xsd:element name="choice" minOccurs="0" maxOccurs="unbounded"
-                                                                       type="flow:refChoiceType">
-                                                                       <xsd:annotation>
-                                                                               <xsd:documentation><![CDATA[
-       A choice for a reference specification attribute.
-                                                                               ]]></xsd:documentation>
-                                                                       </xsd:annotation>
-                                                               </xsd:element>
-                                                       </xsd:choice>
-                                               </xsd:complexType>
-                                       </xsd:element>
-                               </xsd:choice>
-                               <xsd:attribute name="targetClass" use="required" type="xsd:string">
-                                       <xsd:annotation>
-                                               <xsd:documentation><![CDATA[
-       The class that has to be implemented by the underlying object.
-                                       ]]></xsd:documentation>
-                                       </xsd:annotation>
-                               </xsd:attribute>
-                       </xsd:extension>
-               </xsd:complexContent>
-       </xsd:complexType>
-
-       <xsd:complexType name="refChoiceType">
-               <xsd:attribute name="name" use="required" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The name of the related bean.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="description" use="optional" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       A human readable description of this choice.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-       </xsd:complexType>
-
-       <xsd:complexType name="argType">
-               <xsd:choice minOccurs="0" maxOccurs="1">
-                       <xsd:element ref="beans:bean" />
-                       <xsd:element ref="beans:ref" />
-                       <xsd:element ref="flow:param" />
-                       <xsd:element ref="beans:list" />
-                       <xsd:element ref="beans:set" />
-                       <xsd:element ref="beans:map" />
-                       <xsd:element ref="beans:props" />
-               </xsd:choice>
-               <xsd:attribute name="name" use="required" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The name of the related parameter.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="value" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The plain value of the related parameter.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="ref" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The value of the related parameter as a reference to a bean.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-       </xsd:complexType>
-
-       <xsd:attribute name="as-flow" type="xsd:string">
-               <xsd:annotation>
-                       <xsd:documentation><![CDATA[
-       If decorating an executable bean, it will generate an implicit SLC 
-       execution flow with the provided value as name.
-                       ]]></xsd:documentation>
-               </xsd:annotation>
-       </xsd:attribute>
-       <!--
-               <xsd:attribute name="var" type="xsd:boolean"> <xsd:annotation>
-               <xsd:documentation><![CDATA[ If true, the decorated bean is set to
-               scope execution and proxied. ]]></xsd:documentation> </xsd:annotation>
-               </xsd:attribute>
-       -->
-
-       <xsd:element name="variable">
-               <xsd:complexType>
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Marks a bean definition as being variable, i.e. a scoped proxy of scope execution 
-                       ]]></xsd:documentation>
-                       </xsd:annotation>
-                       <xsd:attribute name="proxy-target-class" type="xsd:boolean"
-                               default="true">
-                               <xsd:annotation>
-                                       <xsd:documentation><![CDATA[
-                                               Are class-based (CGLIB) proxies to be created?
-                                               This is the default;
-                                               in order to switch to standard Java
-                                               interface-based proxies, turn this flag to
-                                               "false".
-                                       ]]></xsd:documentation>
-                               </xsd:annotation>
-                       </xsd:attribute>
-               </xsd:complexType>
-       </xsd:element>
-
-       <xsd:element name="param">
-               <xsd:annotation>
-                       <xsd:documentation><![CDATA[
-       If within a property tag of a bean, it will set the value of this property
-        with a reference to a parameter.
-                       ]]></xsd:documentation>
-               </xsd:annotation>
-               <xsd:complexType>
-                       <xsd:attribute name="name" type="xsd:string" use="required">
-                               <xsd:annotation>
-                                       <xsd:documentation><![CDATA[
-       The name of the related parameter.
-                                       ]]></xsd:documentation>
-                               </xsd:annotation>
-                       </xsd:attribute>
-                       <xsd:attribute name="instantiationManager" type="xsd:string"
-                               use="optional" default="instantiationManager">
-                               <xsd:annotation>
-                                       <xsd:documentation><![CDATA[
-       A reference to the instantiation manager to use instead of the default one
-       (expert usage).
-                                       ]]></xsd:documentation>
-                               </xsd:annotation>
-                       </xsd:attribute>
-               </xsd:complexType>
-       </xsd:element>
-
-</xsd:schema>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd
deleted file mode 100644 (file)
index a70798f..0000000
+++ /dev/null
@@ -1,402 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-       xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns:beans="http://www.springframework.org/schema/beans"
-       targetNamespace="http://www.argeo.org/schema/slc-flow"
-       elementFormDefault="qualified" attributeFormDefault="unqualified">
-
-       <xsd:import namespace="http://www.springframework.org/schema/beans"
-               schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" />
-
-       <xsd:annotation>
-               <xsd:documentation><![CDATA[
-       SLC Flow Schema, version 1.2
-       Authors: Mathieu Baudier
-       
-       This simplifies the definition of SLC flows and their integration with 
-       regular Spring beans.
-               ]]></xsd:documentation>
-       </xsd:annotation>
-
-       <xsd:element name="flow">
-               <xsd:annotation>
-                       <xsd:documentation><![CDATA[
-       Adds an SLC execution flow, using the default implementation.
-                       ]]></xsd:documentation>
-               </xsd:annotation>
-               <xsd:complexType>
-                       <xsd:complexContent>
-                               <xsd:extension base="beans:identifiedType">
-                                       <xsd:sequence>
-                                               <xsd:element ref="beans:description" minOccurs="0" />
-                                               <xsd:sequence>
-                                                       <xsd:element name="arg" minOccurs="0" maxOccurs="unbounded"
-                                                               type="flow:argType">
-                                                               <xsd:annotation>
-                                                                       <xsd:documentation><![CDATA[
-       Parameter for an execution flow which will override at instantiation the 
-       value of the parameter already defined as default value or in a parent bean.
-                                                                       ]]></xsd:documentation>
-                                                               </xsd:annotation>
-                                                       </xsd:element>
-                                               </xsd:sequence>
-                                               <xsd:sequence>
-                                                       <xsd:choice minOccurs="0" maxOccurs="unbounded">
-                                                               <xsd:element ref="beans:bean" />
-                                                               <xsd:element ref="beans:ref" />
-                                                               <xsd:element ref="flow:flow" />
-                                                               <xsd:element ref="flow:spec" />
-                                                       </xsd:choice>
-                                                       <!-- <xsd:any namespace="##other" processContents="strict" minOccurs="0" 
-                                                               maxOccurs="unbounded" /> -->
-                                               </xsd:sequence>
-                                       </xsd:sequence>
-                                       <xsd:attribute name="name" type="xsd:string">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       Name of the flow (alternative to ID).
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="class" type="xsd:string">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       Another implementation of execution flow.
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="path" type="xsd:string">
-                                               <!-- DEPRECATED: not used anymore -->
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       The hierarchical path under which to register this flow.
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="spec" type="xsd:string">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       A reference to the related specification bean.
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="parent" type="xsd:string">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       The parent bean definition (in Spring sense).
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                                       <xsd:attribute name="abstract" type="xsd:boolean"
-                                               default="false">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       Whether this flow is abstract (in Spring sense).
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                       </xsd:attribute>
-                               </xsd:extension>
-                       </xsd:complexContent>
-               </xsd:complexType>
-       </xsd:element>
-
-       <xsd:element name="spec">
-               <xsd:annotation>
-                       <xsd:documentation><![CDATA[
-       SLC flow specifications, defining the parameters and variables
-       which can be used in related flows, along with their default values and 
-       various constraints.
-                       ]]></xsd:documentation>
-               </xsd:annotation>
-               <xsd:complexType>
-                       <xsd:complexContent>
-                               <xsd:extension base="beans:identifiedType">
-                                       <xsd:sequence>
-                                               <xsd:element ref="beans:description" minOccurs="0" />
-                                               <xsd:choice minOccurs="0" maxOccurs="unbounded">
-                                                       <xsd:element name="primitive" type="flow:primitiveSpecAttributeType"
-                                                               minOccurs="0" maxOccurs="unbounded">
-                                                               <xsd:annotation>
-                                                                       <xsd:documentation><![CDATA[
-       A primitive specification attribute, that is, a plain standard value
-       and not a reference to an object.
-                                                                       ]]></xsd:documentation>
-                                                               </xsd:annotation>
-                                                       </xsd:element>
-                                                       <xsd:element name="ref" type="flow:refSpecAttributeType"
-                                                               minOccurs="0" maxOccurs="unbounded">
-                                                               <xsd:annotation>
-                                                                       <xsd:documentation><![CDATA[
-       A reference specification attribute, that is, a reference to another object.
-                                                                       ]]></xsd:documentation>
-                                                               </xsd:annotation>
-                                                       </xsd:element>
-                                               </xsd:choice>
-                                       </xsd:sequence>
-                               </xsd:extension>
-                       </xsd:complexContent>
-               </xsd:complexType>
-       </xsd:element>
-
-       <xsd:complexType name="specAttributeType">
-               <xsd:choice>
-                       <xsd:element name="value" minOccurs="0" maxOccurs="1">
-                               <xsd:annotation>
-                                       <xsd:documentation><![CDATA[
-       The default value of the attribute as an inner bean.
-                                       ]]></xsd:documentation>
-                               </xsd:annotation>
-                               <xsd:complexType>
-                                       <xsd:choice minOccurs="1" maxOccurs="1">
-                                               <xsd:element ref="beans:bean" />
-                                               <xsd:element ref="beans:ref" />
-                                               <xsd:element ref="beans:list" />
-                                               <xsd:element ref="beans:set" />
-                                               <xsd:element ref="beans:map" />
-                                               <xsd:element ref="beans:props" />
-                                       </xsd:choice>
-                               </xsd:complexType>
-                       </xsd:element>
-               </xsd:choice>
-               <xsd:attribute name="name" use="required" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The name of the attribute, under which in can then be referenced.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="value" use="optional" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The default value of the attribute.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="ref" use="optional" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The default value of the attribute as a reference to another bean.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="isImmutable" use="optional" type="xsd:boolean"
-                       default="false">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Whether the attribute is a parameter, that is, it has to be set at 
-       instantiation but can be modified afterwards for objects of scope execution.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="isParameter" use="optional" type="xsd:boolean"
-                       default="false">
-                       <!-- DEPRECATED: old name of isImmutable -->
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Whether the attribute is a parameter, that is, it has to be set at 
-       instantiation but can be modified afterwards for objects of scope execution.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="isConstant" use="optional" type="xsd:boolean"
-                       default="false">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Whether the attribute is frozen, that is, it cannot be modified at runtime.
-       A frozen attribute has to be a parameter.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="isFrozen" use="optional" type="xsd:boolean"
-                       default="false">
-                       <!-- DEPRECATED: old name of isConstant -->
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Whether the attribute is frozen, that is, it cannot be modified at runtime.
-       A frozen attribute has to be a parameter.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="isHidden" use="optional" type="xsd:boolean"
-                       default="false">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Whether the attribute is hidden, that is, it should not be displayed in UIs.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-       </xsd:complexType>
-
-       <xsd:complexType name="primitiveSpecAttributeType">
-               <xsd:complexContent>
-                       <xsd:extension base="flow:specAttributeType">
-                               <xsd:attribute name="type" default="string">
-                                       <xsd:annotation>
-                                               <xsd:documentation><![CDATA[
-       The type of the primitive specification attribute.
-                                               ]]></xsd:documentation>
-                                       </xsd:annotation>
-                                       <xsd:simpleType>
-                                               <xsd:restriction base="xsd:string">
-                                                       <xsd:enumeration value="string" />
-                                                       <xsd:enumeration value="password" />
-                                                       <xsd:enumeration value="integer" />
-                                                       <xsd:enumeration value="long" />
-                                                       <xsd:enumeration value="float" />
-                                                       <xsd:enumeration value="double" />
-                                                       <xsd:enumeration value="boolean" />
-                                               </xsd:restriction>
-                                       </xsd:simpleType>
-                               </xsd:attribute>
-                       </xsd:extension>
-               </xsd:complexContent>
-       </xsd:complexType>
-
-       <xsd:complexType name="refSpecAttributeType">
-               <xsd:complexContent>
-                       <xsd:extension base="flow:specAttributeType">
-                               <xsd:choice>
-                                       <xsd:element name="choices" minOccurs="0" maxOccurs="1">
-                                               <xsd:annotation>
-                                                       <xsd:documentation><![CDATA[
-       Possible values to chose from, if ommitted, all the beans in the 
-       application context which implement the provided targetClass will 
-       be considered.
-                                                       ]]></xsd:documentation>
-                                               </xsd:annotation>
-                                               <xsd:complexType>
-                                                       <xsd:choice>
-                                                               <xsd:element name="choice" minOccurs="0" maxOccurs="unbounded"
-                                                                       type="flow:refChoiceType">
-                                                                       <xsd:annotation>
-                                                                               <xsd:documentation><![CDATA[
-       A choice for a reference specification attribute.
-                                                                               ]]></xsd:documentation>
-                                                                       </xsd:annotation>
-                                                               </xsd:element>
-                                                       </xsd:choice>
-                                               </xsd:complexType>
-                                       </xsd:element>
-                               </xsd:choice>
-                               <xsd:attribute name="targetClass" use="required" type="xsd:string">
-                                       <xsd:annotation>
-                                               <xsd:documentation><![CDATA[
-       The class that has to be implemented by the underlying object.
-                                       ]]></xsd:documentation>
-                                       </xsd:annotation>
-                               </xsd:attribute>
-                       </xsd:extension>
-               </xsd:complexContent>
-       </xsd:complexType>
-
-       <xsd:complexType name="refChoiceType">
-               <xsd:attribute name="name" use="required" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The name of the related bean.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="description" use="optional" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       A human readable description of this choice.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-       </xsd:complexType>
-
-       <xsd:complexType name="argType">
-               <xsd:choice minOccurs="0" maxOccurs="1">
-                       <xsd:element ref="beans:bean" />
-                       <xsd:element ref="beans:ref" />
-                       <xsd:element ref="flow:param" />
-                       <xsd:element ref="beans:list" />
-                       <xsd:element ref="beans:set" />
-                       <xsd:element ref="beans:map" />
-                       <xsd:element ref="beans:props" />
-               </xsd:choice>
-               <xsd:attribute name="name" use="required" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The name of the related parameter.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="value" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The plain value of the related parameter.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-               <xsd:attribute name="ref" type="xsd:string">
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       The value of the related parameter as a reference to a bean.
-                               ]]></xsd:documentation>
-                       </xsd:annotation>
-               </xsd:attribute>
-       </xsd:complexType>
-
-       <xsd:attribute name="as-flow" type="xsd:string">
-               <xsd:annotation>
-                       <xsd:documentation><![CDATA[
-       If decorating an executable bean, it will generate an implicit SLC 
-       execution flow with the provided value as name.
-                       ]]></xsd:documentation>
-               </xsd:annotation>
-       </xsd:attribute>
-       <!-- <xsd:attribute name="var" type="xsd:boolean"> <xsd:annotation> <xsd:documentation><![CDATA[ 
-               If true, the decorated bean is set to scope execution and proxied. ]]></xsd:documentation> 
-               </xsd:annotation> </xsd:attribute> -->
-
-       <xsd:element name="variable">
-               <xsd:complexType>
-                       <xsd:annotation>
-                               <xsd:documentation><![CDATA[
-       Marks a bean definition as being variable, i.e. a scoped proxy of scope execution 
-                       ]]></xsd:documentation>
-                       </xsd:annotation>
-                       <xsd:attribute name="proxy-target-class" type="xsd:boolean"
-                               default="true">
-                               <xsd:annotation>
-                                       <xsd:documentation><![CDATA[
-                                               Are class-based (CGLIB) proxies to be created?
-                                               This is the default;
-                                               in order to switch to standard Java
-                                               interface-based proxies, turn this flag to
-                                               "false".
-                                       ]]></xsd:documentation>
-                               </xsd:annotation>
-                       </xsd:attribute>
-               </xsd:complexType>
-       </xsd:element>
-
-       <xsd:element name="param">
-               <xsd:annotation>
-                       <xsd:documentation><![CDATA[
-       If within a property tag of a bean, it will set the value of this property
-        with a reference to a parameter.
-                       ]]></xsd:documentation>
-               </xsd:annotation>
-               <xsd:complexType>
-                       <xsd:attribute name="name" type="xsd:string" use="required">
-                               <xsd:annotation>
-                                       <xsd:documentation><![CDATA[
-       The name of the related parameter.
-                                       ]]></xsd:documentation>
-                               </xsd:annotation>
-                       </xsd:attribute>
-                       <xsd:attribute name="instantiationManager" type="xsd:string"
-                               use="optional" default="instantiationManager">
-                               <xsd:annotation>
-                                       <xsd:documentation><![CDATA[
-       A reference to the instantiation manager to use instead of the default one
-       (expert usage).
-                                       ]]></xsd:documentation>
-                               </xsd:annotation>
-                       </xsd:attribute>
-               </xsd:complexType>
-       </xsd:element>
-
-</xsd:schema>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/DefaultContextTestData.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/DefaultContextTestData.java
deleted file mode 100644 (file)
index 2701cd2..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.argeo.slc.core.test.context;
-
-import org.argeo.slc.runtime.test.TestDataUtils;
-import org.argeo.slc.test.TestData;
-import org.argeo.slc.test.TestDataProvider;
-
-public class DefaultContextTestData extends SimpleContextAware implements
-               TestData, TestDataProvider {
-
-       public <T extends TestData> T getTestData(Class<T> clss, String key) {
-               return TestDataUtils.getItSelf(clss, this);
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleContextAware.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleContextAware.java
deleted file mode 100644 (file)
index b2d8191..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.argeo.slc.core.test.context;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.runtime.test.ContextUtils;
-import org.argeo.slc.test.context.ContextAware;
-import org.argeo.slc.test.context.ParentContextAware;
-import org.springframework.beans.factory.InitializingBean;
-
-public class SimpleContextAware implements ContextAware, InitializingBean {
-       private ParentContextAware parentContext;
-
-       private Map<String, Object> values = new TreeMap<String, Object>();
-       private Map<String, Object> expectedValues = new TreeMap<String, Object>();
-
-       private String contextSkipFlag = DEFAULT_SKIP_FLAG;
-       private String contextAnyFlag = DEFAULT_ANY_FLAG;
-
-       public Map<String, Object> getValues() {
-               return values;
-       }
-
-       public void setValues(Map<String, Object> values) {
-               this.values = values;
-       }
-
-       public Map<String, Object> getExpectedValues() {
-               return expectedValues;
-       }
-
-       public void setExpectedValues(Map<String, Object> expectedValues) {
-               this.expectedValues = expectedValues;
-       }
-
-       /** Used to add this context as a child by setting a property. */
-       public void setParentContext(ParentContextAware parentContextAware) {
-               if (parentContext != null)
-                       throw new SlcException("Parent context already set");
-               this.parentContext = parentContextAware;
-               this.parentContext.addChildContext(this);
-       }
-
-       protected ParentContextAware getParentContext() {
-               return parentContext;
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               if (parentContext != null) {
-                       ContextUtils.synchronize(parentContext);
-               }
-       }
-
-       public String getContextSkipFlag() {
-               return contextSkipFlag;
-       }
-
-       public void setContextSkipFlag(String contextSkipFlag) {
-               this.contextSkipFlag = contextSkipFlag;
-       }
-
-       public String getContextAnyFlag() {
-               return contextAnyFlag;
-       }
-
-       public void setContextAnyFlag(String contextAnyFlag) {
-               this.contextAnyFlag = contextAnyFlag;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleParentContextAware.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleParentContextAware.java
deleted file mode 100644 (file)
index 3c2e7b9..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.argeo.slc.core.test.context;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Vector;
-
-import org.argeo.slc.runtime.test.ContextUtils;
-import org.argeo.slc.test.context.ContextAware;
-import org.argeo.slc.test.context.ParentContextAware;
-import org.springframework.beans.factory.InitializingBean;
-
-public class SimpleParentContextAware extends SimpleContextAware implements
-               ParentContextAware, InitializingBean {
-       private List<ContextAware> children = new Vector<ContextAware>();
-
-       public Collection<ContextAware> getChildContexts() {
-               return children;
-       }
-
-       public void addChildContext(ContextAware contextAware) {
-               children.add(contextAware);
-       }
-
-       @Override
-       public void afterPropertiesSet() throws Exception {
-               if (getParentContext() != null) {
-                       // If has a parent, sync it.
-                       super.afterPropertiesSet();
-               } else {
-                       if (children.size() > 0) {
-                               // No need to synchronize if no children
-                               ContextUtils.synchronize(this);
-                       }
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/package.html b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/package.html
deleted file mode 100644 (file)
index cd08d63..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-Context variables to be passed between parts of tests.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/package.html b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/package.html
deleted file mode 100644 (file)
index c70d2d1..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-SLC Test: test of software systems.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/spring.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/test/spring.xml
deleted file mode 100644 (file)
index 28fba40..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Copyright (C) 2007-2012 Argeo GmbH
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-            http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
-    default-lazy-init="true">
-
-    <bean name="slcDefault.test.testRun"
-        class="org.argeo.slc.runtime.test.SimpleTestRun"
-        scope="prototype">
-    </bean>
-
-    <bean name="slcDefault.test.uuid" class="java.util.UUID"
-        factory-method="randomUUID" scope="prototype">
-    </bean>
-
-    <bean id="slcDefault.test.basicSimpleTestResult"
-        class="org.argeo.slc.runtime.test.SimpleTestResult"
-        abstract="true">
-        <property name="uuid">
-            <bean factory-bean="slcDefault.test.uuid"
-                factory-method="toString">
-            </bean>
-        </property>
-    </bean>
-
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundleRegister.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundleRegister.java
deleted file mode 100644 (file)
index b04395c..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.argeo.slc.osgi;
-
-/** <b>Experimental</b> A structured set of OSGi bundles. */
-public interface BundleRegister {
-       /**
-        * @param pkg
-        *            the Java package
-        * @param version
-        *            the version, can be only major.minor or null
-        * @return the bundle providing this package or null if none was found
-        */
-       public String bundleProvidingPackage(String pkg, String version);
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundlesManager.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundlesManager.java
deleted file mode 100644 (file)
index 6563d39..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-package org.argeo.slc.osgi;
-
-import java.util.Collection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextEvent;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextListener;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleContextClosedEvent;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleContextFailedEvent;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleContextRefreshedEvent;
-import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
-import org.eclipse.gemini.blueprint.util.OsgiFilterUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.util.Assert;
-
-/** Wraps low-level access to a {@link BundleContext} */
-@SuppressWarnings("deprecation")
-public class BundlesManager implements BundleContextAware, FrameworkListener,
-               InitializingBean, DisposableBean,
-               OsgiBundleApplicationContextListener<OsgiBundleApplicationContextEvent> {
-       private final static Log log = LogFactory.getLog(BundlesManager.class);
-
-       private BundleContext bundleContext;
-
-       private Long defaultTimeout = 60 * 1000l;
-       private Long pollingPeriod = 200l;
-
-       // Refresh sync objects
-       private final Object refreshedPackageSem = new Object();
-       private Boolean packagesRefreshed = false;
-
-       public BundlesManager() {
-       }
-
-       public BundlesManager(BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-       }
-
-       /**
-        * Stop the module, update it, refresh it and restart it. All synchronously.
-        */
-       public void upgradeSynchronous(OsgiBundle osgiBundle) {
-               try {
-                       Bundle bundle = findRelatedBundle(osgiBundle);
-
-                       long begin = System.currentTimeMillis();
-
-                       long bStop = begin;
-                       stopSynchronous(bundle);
-
-                       long bUpdate = System.currentTimeMillis();
-                       updateSynchronous(bundle);
-
-                       // Refresh in case there are fragments
-                       long bRefresh = System.currentTimeMillis();
-                       refreshSynchronous(bundle);
-
-                       long bStart = System.currentTimeMillis();
-                       startSynchronous(bundle);
-
-                       long aStart = System.currentTimeMillis();
-                       if (log.isTraceEnabled()) {
-                               log.debug("OSGi upgrade performed in " + (aStart - begin)
-                                               + "ms for bundle " + osgiBundle);
-                               log.debug(" stop \t: " + (bUpdate - bStop) + "ms");
-                               log.debug(" update\t: " + (bRefresh - bUpdate) + "ms");
-                               log.debug(" refresh\t: " + (bStart - bRefresh) + "ms");
-                               log.debug(" start\t: " + (aStart - bStart) + "ms");
-                               log.debug(" TOTAL\t: " + (aStart - begin) + "ms");
-                       }
-
-                       long bAppContext = System.currentTimeMillis();
-                       String filter = "(Bundle-SymbolicName=" + bundle.getSymbolicName()
-                                       + ")";
-                       // Wait for application context to be ready
-                       // TODO: use service tracker
-                       Collection<ServiceReference<ApplicationContext>> srs = getServiceRefSynchronous(
-                                       ApplicationContext.class, filter);
-                       ServiceReference<ApplicationContext> sr = srs.iterator().next();
-                       long aAppContext = System.currentTimeMillis();
-                       long end = aAppContext;
-
-                       if (log.isTraceEnabled()) {
-                               log.debug("Application context refresh performed in "
-                                               + (aAppContext - bAppContext) + "ms for bundle "
-                                               + osgiBundle);
-                       }
-
-                       if (log.isDebugEnabled())
-                               log.debug("Bundle '" + bundle.getSymbolicName()
-                                               + "' upgraded and ready " + " (upgrade performed in "
-                                               + (end - begin) + "ms).");
-
-                       if (log.isTraceEnabled()) {
-                               ApplicationContext applicationContext = (ApplicationContext) bundleContext
-                                               .getService(sr);
-                               int beanDefCount = applicationContext.getBeanDefinitionCount();
-                               log.debug(" " + beanDefCount + " beans in app context of "
-                                               + bundle.getSymbolicName()
-                                               + ", average init time per bean=" + (end - begin)
-                                               / beanDefCount + "ms");
-                       }
-
-                       bundleContext.ungetService(sr);
-
-               } catch (Exception e) {
-                       throw new SlcException("Cannot update bundle " + osgiBundle, e);
-               }
-       }
-
-       /** Updates bundle synchronously. */
-       protected void updateSynchronous(Bundle bundle) throws BundleException {
-               bundle.update();
-               boolean waiting = true;
-
-               long begin = System.currentTimeMillis();
-               do {
-                       int state = bundle.getState();
-                       if (state == Bundle.INSTALLED || state == Bundle.ACTIVE
-                                       || state == Bundle.RESOLVED)
-                               waiting = false;
-
-                       sleepWhenPolling();
-                       checkTimeout(begin, "Update of bundle " + bundle.getSymbolicName()
-                                       + " timed out. Bundle state = " + bundle.getState());
-               } while (waiting);
-
-               if (log.isTraceEnabled())
-                       log.debug("Bundle " + bundle.getSymbolicName() + " updated.");
-       }
-
-       /** Starts bundle synchronously. Does nothing if already started. */
-       protected void startSynchronous(Bundle bundle) throws BundleException {
-               int originalState = bundle.getState();
-               if (originalState == Bundle.ACTIVE)
-                       return;
-
-               bundle.start();
-               boolean waiting = true;
-
-               long begin = System.currentTimeMillis();
-               do {
-                       if (bundle.getState() == Bundle.ACTIVE)
-                               waiting = false;
-
-                       sleepWhenPolling();
-                       checkTimeout(begin, "Start of bundle " + bundle.getSymbolicName()
-                                       + " timed out. Bundle state = " + bundle.getState());
-               } while (waiting);
-
-               if (log.isTraceEnabled())
-                       log.debug("Bundle " + bundle.getSymbolicName() + " started.");
-       }
-
-       /** Stops bundle synchronously. Does nothing if already started. */
-       protected void stopSynchronous(Bundle bundle) throws BundleException {
-               int originalState = bundle.getState();
-               if (originalState != Bundle.ACTIVE)
-                       return;
-
-               bundle.stop();
-               boolean waiting = true;
-
-               long begin = System.currentTimeMillis();
-               do {
-                       if (bundle.getState() != Bundle.ACTIVE
-                                       && bundle.getState() != Bundle.STOPPING)
-                               waiting = false;
-
-                       sleepWhenPolling();
-                       checkTimeout(begin, "Stop of bundle " + bundle.getSymbolicName()
-                                       + " timed out. Bundle state = " + bundle.getState());
-               } while (waiting);
-
-               if (log.isTraceEnabled())
-                       log.debug("Bundle " + bundle.getSymbolicName() + " stopped.");
-       }
-
-       /** Refresh bundle synchronously. Does nothing if already started. */
-       protected void refreshSynchronous(Bundle bundle) throws BundleException {
-               ServiceReference<PackageAdmin> packageAdminRef = bundleContext
-                               .getServiceReference(PackageAdmin.class);
-               PackageAdmin packageAdmin = (PackageAdmin) bundleContext
-                               .getService(packageAdminRef);
-               Bundle[] bundles = { bundle };
-
-               long begin = System.currentTimeMillis();
-               synchronized (refreshedPackageSem) {
-                       packagesRefreshed = false;
-                       packageAdmin.refreshPackages(bundles);
-                       try {
-                               refreshedPackageSem.wait(defaultTimeout);
-                       } catch (InterruptedException e) {
-                               // silent
-                       }
-                       if (!packagesRefreshed) {
-                               long now = System.currentTimeMillis();
-                               throw new SlcException("Packages not refreshed after "
-                                               + (now - begin) + "ms");
-                       } else {
-                               packagesRefreshed = false;
-                       }
-               }
-
-               if (log.isTraceEnabled())
-                       log.debug("Bundle " + bundle.getSymbolicName() + " refreshed.");
-       }
-
-       public void frameworkEvent(FrameworkEvent event) {
-               if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
-                       synchronized (refreshedPackageSem) {
-                               packagesRefreshed = true;
-                               refreshedPackageSem.notifyAll();
-                       }
-               }
-       }
-
-       public <S> Collection<ServiceReference<S>> getServiceRefSynchronous(
-                       Class<S> clss, String filter) throws InvalidSyntaxException {
-               if (log.isTraceEnabled())
-                       log.debug("Filter: '" + filter + "'");
-               Collection<ServiceReference<S>> sfs = null;
-               boolean waiting = true;
-               long begin = System.currentTimeMillis();
-               do {
-                       sfs = bundleContext.getServiceReferences(clss, filter);
-
-                       if (sfs != null)
-                               waiting = false;
-
-                       sleepWhenPolling();
-                       checkTimeout(begin, "Search of services " + clss + " with filter "
-                                       + filter + " timed out.");
-               } while (waiting);
-
-               return sfs;
-       }
-
-       protected void checkTimeout(long begin, String msg) {
-               long now = System.currentTimeMillis();
-               if (now - begin > defaultTimeout)
-                       throw new SlcException(msg + " (timeout after " + (now - begin)
-                                       + "ms)");
-
-       }
-
-       protected void sleepWhenPolling() {
-               try {
-                       Thread.sleep(pollingPeriod);
-               } catch (InterruptedException e) {
-                       throw new SlcException("Polling interrupted");
-               }
-       }
-
-       /** Creates and open a new service tracker. */
-       public <S> ServiceTracker<S, S> newTracker(Class<S> clss) {
-               ServiceTracker<S, S> st = new ServiceTracker<S, S>(bundleContext, clss,
-                               null);
-               st.open();
-               return st;
-       }
-
-       public <T> T getSingleService(Class<T> clss, String filter,
-                       Boolean synchronous) {
-               if (filter != null)
-                       Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
-               Collection<ServiceReference<T>> sfs;
-               try {
-                       if (synchronous)
-                               sfs = getServiceRefSynchronous(clss, filter);
-                       else
-                               sfs = bundleContext.getServiceReferences(clss, filter);
-               } catch (InvalidSyntaxException e) {
-                       throw new SlcException("Cannot retrieve service reference for "
-                                       + filter, e);
-               }
-
-               if (sfs == null || sfs.size() == 0)
-                       return null;
-               else if (sfs.size() > 1)
-                       throw new SlcException("More than one execution flow found for "
-                                       + filter);
-               return (T) bundleContext.getService(sfs.iterator().next());
-       }
-
-       public <T> T getSingleServiceStrict(Class<T> clss, String filter,
-                       Boolean synchronous) {
-               T service = getSingleService(clss, filter, synchronous);
-               if (service == null)
-                       throw new SlcException("No execution flow found for " + filter);
-               else
-                       return service;
-       }
-
-       public OsgiBundle findRelatedBundle(String moduleName, String moduleVersion) {
-               OsgiBundle osgiBundle = new OsgiBundle(moduleName, moduleVersion);
-               if (osgiBundle.getVersion() == null) {
-                       Bundle bundle = findRelatedBundle(osgiBundle);
-                       osgiBundle = new OsgiBundle(bundle);
-               }
-               return osgiBundle;
-       }
-
-       /**
-        * @param osgiBundle
-        *            cannot be null
-        * @return the related bundle or null if not found
-        * @throws SlcException
-        *             if osgiBundle argument is null
-        */
-       public Bundle findRelatedBundle(OsgiBundle osgiBundle) {
-               if (osgiBundle == null)
-                       throw new SlcException("OSGi bundle cannot be null");
-
-               Bundle bundle = null;
-               if (osgiBundle.getInternalBundleId() != null) {
-                       bundle = bundleContext.getBundle(osgiBundle.getInternalBundleId());
-                       Assert.isTrue(
-                                       osgiBundle.getName().equals(bundle.getSymbolicName()),
-                                       "symbolic name consistent");
-                       if (osgiBundle.getVersion() != null)
-                               Assert.isTrue(
-                                               osgiBundle.getVersion().equals(
-                                                               bundle.getHeaders().get(
-                                                                               Constants.BUNDLE_VERSION)),
-                                               "version consistent");
-               } else if (osgiBundle.getVersion() == null
-                               || osgiBundle.getVersion().equals("0.0.0")) {
-                       bundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
-                                       osgiBundle.getName());
-               } else {// scan all bundles
-                       bundles: for (Bundle b : bundleContext.getBundles()) {
-                               if (b.getSymbolicName() == null) {
-                                       log.warn("Bundle " + b + " has no symbolic name defined.");
-                                       continue bundles;
-                               }
-
-                               if (b.getSymbolicName().equals(osgiBundle.getName())) {
-                                       if (osgiBundle.getVersion() == null) {
-                                               bundle = b;
-                                               break bundles;
-                                       }
-
-                                       if (b.getHeaders().get(Constants.BUNDLE_VERSION)
-                                                       .equals(osgiBundle.getVersion())) {
-                                               bundle = b;
-                                               osgiBundle.setInternalBundleId(b.getBundleId());
-                                               break bundles;
-                                       }
-                               }
-                       }
-               }
-               return bundle;
-       }
-
-       /** Find a single bundle based on a symbolic name pattern. */
-       public OsgiBundle findFromPattern(String pattern) {
-               OsgiBundle osgiBundle = null;
-               for (Bundle b : bundleContext.getBundles()) {
-                       if (b.getSymbolicName().contains(pattern)) {
-                               osgiBundle = new OsgiBundle(b);
-                               break;
-                       }
-               }
-               return osgiBundle;
-       }
-
-       public OsgiBundle getBundle(Long bundleId) {
-               Bundle bundle = bundleContext.getBundle(bundleId);
-               return new OsgiBundle(bundle);
-       }
-
-       public void setBundleContext(BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               bundleContext.addFrameworkListener(this);
-       }
-
-       public void destroy() throws Exception {
-               bundleContext.removeFrameworkListener(this);
-       }
-
-       public void setDefaultTimeout(Long defaultTimeout) {
-               this.defaultTimeout = defaultTimeout;
-       }
-
-       /**
-        * Use with caution since it may interfer with some cached information
-        * within this object
-        */
-       public BundleContext getBundleContext() {
-               return bundleContext;
-       }
-
-       public void setPollingPeriod(Long pollingPeriod) {
-               this.pollingPeriod = pollingPeriod;
-       }
-
-       public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {
-               if (event instanceof OsgiBundleContextRefreshedEvent) {
-                       log.debug("App context refreshed: " + event);
-               } else if (event instanceof OsgiBundleContextFailedEvent) {
-                       log.debug("App context failed: " + event);
-               }
-               if (event instanceof OsgiBundleContextClosedEvent) {
-                       log.debug("App context closed: " + event);
-               }
-
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/FileSystemBundleRegister.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/FileSystemBundleRegister.java
deleted file mode 100644 (file)
index 605c797..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.argeo.slc.osgi;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.Constants;
-
-/** <b>Experimental</b> */
-public class FileSystemBundleRegister implements BundleRegister {
-       private final static Log log = LogFactory
-                       .getLog(FileSystemBundleRegister.class);
-       private Properties packagesBundles = null;
-
-       public String bundleProvidingPackage(String pkg, String version) {
-               if (packagesBundles == null)
-                       return null;
-               return packagesBundles.getProperty(pkg);
-       }
-
-       protected void scan(File baseDirectory) {
-               long begin = System.currentTimeMillis();
-               int bundleCount = 0;
-               int packageCount = 0;
-
-               packagesBundles = new Properties();
-
-               File[] files = baseDirectory.listFiles();
-               for (File file : files) {
-                       if (file.isDirectory()) {
-
-                       } else {
-                               JarFile jarFile = null;
-                               try {
-                                       jarFile = new JarFile(file);
-                                       Manifest manifest = jarFile.getManifest();
-                                       String symbolicName = manifest.getMainAttributes()
-                                                       .getValue(Constants.BUNDLE_SYMBOLICNAME);
-                                       String exportPackage = manifest.getMainAttributes()
-                                                       .getValue(Constants.EXPORT_PACKAGE);
-
-                                       // List exported packages
-                                       Set<String> exportedPackages = exportPackageToPackageNames(exportPackage);
-
-                                       for (String exportedPackage : exportedPackages) {
-                                               packagesBundles.put(exportedPackage, symbolicName);
-                                               packageCount++;
-                                               if (log.isTraceEnabled())
-                                                       log.trace("Register " + exportedPackage + "="
-                                                                       + symbolicName);
-                                       }
-                                       bundleCount++;
-                               } catch (Exception e) {
-                                       log.warn("Cannot scan " + file, e);
-                                       if (log.isTraceEnabled())
-                                               e.printStackTrace();
-                               } finally {
-                                       IOUtils.closeQuietly(jarFile);
-                               }
-                       }
-               }
-               if (log.isDebugEnabled())
-                       log.debug("Scanned " + bundleCount + " bundles with "
-                                       + packageCount + " packages in "
-                                       + (System.currentTimeMillis() - begin) + " ms");
-       }
-
-       protected Set<String> exportPackageToPackageNames(String exportPackage) {
-               Set<String> exportedPackages = new HashSet<String>();
-               if (exportPackage == null)
-                       return exportedPackages;
-               char[] arr = exportPackage.toCharArray();
-
-               StringBuffer currentPkg = new StringBuffer("");
-               boolean skip = false;
-               boolean inQuote = false;
-               for (char c : arr) {
-                       if (c == ' ' || c == '\n') {
-                               // ignore
-                       } else if (c == ';') {
-                               if (!skip)
-                                       skip = true;
-                       } else if (c == ',') {
-                               if (skip && !inQuote) {
-                                       skip = false;
-                                       // add new package
-                                       exportedPackages.add(currentPkg.toString());
-                                       currentPkg = new StringBuffer("");
-                               }
-                       } else if (c == '\"') {
-                               inQuote = inQuote ? false : true;
-                       } else {
-                               if (!skip)
-                                       currentPkg.append(c);
-                       }
-               }
-
-               return exportedPackages;
-       }
-
-       public static void main(String[] args) {
-               FileSystemBundleRegister fsbr = new FileSystemBundleRegister();
-               fsbr.scan(new File(
-                               "/home/mbaudier/dev/src/slc/dist/org.argeo.slc.sdk/target/lib"));
-
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/MultipleServiceExporterPostProcessor.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/MultipleServiceExporterPostProcessor.java
deleted file mode 100644 (file)
index 01509c2..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-package org.argeo.slc.osgi;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.event.ContextRefreshedEvent;
-import org.springframework.core.Ordered;
-
-/** Publishes beans of the application context as OSGi services. */
-@SuppressWarnings(value = { "unchecked", "rawtypes" })
-public class MultipleServiceExporterPostProcessor implements
-               ApplicationListener, Ordered {
-       private final static Log log = LogFactory
-                       .getLog(MultipleServiceExporterPostProcessor.class);
-
-       private List<Class> interfaces = new ArrayList<Class>();
-
-       private int order = Ordered.LOWEST_PRECEDENCE;
-
-       private BundleContext bundleContext = null;
-
-       // private Class osgiServiceFactoryClass = OsgiServiceFactoryBean.class;
-       // private Boolean useServiceProviderContextClassLoader = false;
-
-       public void onApplicationEvent(ApplicationEvent event) {
-               Map<String, Object> beans = new HashMap<String, Object>();
-               if (event instanceof ContextRefreshedEvent) {
-                       if (bundleContext != null) {
-                               for (Class clss : interfaces) {
-                                       ApplicationContext ac = ((ContextRefreshedEvent) event)
-                                                       .getApplicationContext();
-                                       beans.putAll(ac.getBeansOfType(clss, false, false));
-                               }
-
-                               int count = 0;
-                               for (String beanName : beans.keySet()) {
-                                       Object bean = beans.get(beanName);
-                                       List<String> classes = new ArrayList<String>();
-                                       for (Class clss : interfaces) {
-                                               if (clss.isAssignableFrom(bean.getClass())) {
-                                                       classes.add(clss.getName());
-                                               }
-                                       }
-                                       Properties props = new Properties();
-                                       Bundle bundle = bundleContext.getBundle();
-                                       props.put(Constants.BUNDLE_SYMBOLICNAME,
-                                                       bundle.getSymbolicName());
-                                       props.put(Constants.BUNDLE_VERSION, bundle.getVersion());
-                                       // retrocompatibility with pre-1.0:
-                                       props.put("org.eclipse.gemini.blueprint.bean.name", beanName);
-                                       bundleContext.registerService(
-                                                       classes.toArray(new String[classes.size()]), bean,
-                                                       new Hashtable(props));
-                                       count++;
-                               }
-                               if (log.isTraceEnabled())
-                                       log.trace("Published " + count + " " + interfaces
-                                                       + " as OSGi services from bundle "
-                                                       + bundleContext.getBundle().getSymbolicName() + " "
-                                                       + bundleContext.getBundle().getVersion());
-                               // note: the services will be automatically unregistered when
-                               // the bundle will be stopped
-                       }
-               }
-       }
-
-       // public void postProcessBeanFactory(
-       // ConfigurableListableBeanFactory beanFactory) throws BeansException {
-       // if (!(beanFactory instanceof BeanDefinitionRegistry)) {
-       // throw new SlcException("Can only work on "
-       // + BeanDefinitionRegistry.class);
-       // }
-       //
-       // long begin = System.currentTimeMillis();
-       //
-       // // Merge all beans implementing these interfaces
-       // Set<String> beanNames = new HashSet<String>();
-       // for (Class clss : interfaces) {
-       // String[] strs = beanFactory.getBeanNamesForType(clss, true, false);
-       // beanNames.addAll(Arrays.asList(strs));
-       // }
-       //
-       // // Register service factory beans for them
-       // for (String beanName : beanNames) {
-       // MutablePropertyValues mpv = new MutablePropertyValues();
-       // mpv.addPropertyValue("interfaces", interfaces.toArray());
-       // mpv.addPropertyValue("targetBeanName", beanName);
-       // if (useServiceProviderContextClassLoader)
-       // mpv.addPropertyValue("contextClassLoader",
-       // ExportContextClassLoader.SERVICE_PROVIDER);
-       // RootBeanDefinition bd = new RootBeanDefinition(
-       // osgiServiceFactoryClass, mpv);
-       //
-       // String exporterBeanName = "osgiService." + beanName;
-       // if (log.isTraceEnabled())
-       // log.debug("Registering OSGi service exporter "
-       // + exporterBeanName);
-       // ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(
-       // exporterBeanName, bd);
-       // }
-       //
-       // long end = System.currentTimeMillis();
-       // if (log.isTraceEnabled())
-       // log.debug("Multiple services exported in " + (end - begin)
-       // + " ms in bundle.");
-       //
-       // }
-
-       public void setInterfaces(List<Class> interfaces) {
-               this.interfaces = interfaces;
-       }
-
-       // public void setOsgiServiceFactoryClass(Class osgiServiceFactoryClass) {
-       // this.osgiServiceFactoryClass = osgiServiceFactoryClass;
-       // }
-
-       public int getOrder() {
-               return order;
-       }
-
-       public void setOrder(int order) {
-               this.order = order;
-       }
-
-       // public void setUseServiceProviderContextClassLoader(
-       // Boolean useServiceProviderContextClassLoader) {
-       // this.useServiceProviderContextClassLoader =
-       // useServiceProviderContextClassLoader;
-       // }
-
-       public void setBundleContext(BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiBundle.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiBundle.java
deleted file mode 100644 (file)
index 01275da..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.argeo.slc.osgi;
-
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.core.build.ResourceDistribution;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.Module;
-import org.argeo.slc.deploy.ModuleDescriptor;
-import org.argeo.slc.deploy.TargetData;
-import org.argeo.slc.execution.RealizedFlow;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.springframework.core.io.Resource;
-
-/** A deployed OSGi bundle. */
-public class OsgiBundle extends DefaultNameVersion implements Module {
-       private ResourceDistribution distribution;
-
-       private Long internalBundleId;
-
-       private String title;
-       private String description;
-
-       public OsgiBundle() {
-
-       }
-
-       public OsgiBundle(String name, String version) {
-               super(name, version);
-       }
-
-       public OsgiBundle(NameVersion nameVersion) {
-               super(nameVersion);
-       }
-
-       public OsgiBundle(Bundle bundle) {
-               super(bundle.getSymbolicName(), getVersionSafe(bundle));
-               internalBundleId = bundle.getBundleId();
-       }
-
-       /**
-        * Initialize from a {@link RealizedFlow}.
-        * 
-        * @deprecated introduce an unnecessary dependency. TODO: create a separate
-        *             helper.
-        */
-       public OsgiBundle(RealizedFlow realizedFlow) {
-               super(realizedFlow.getModuleName(), realizedFlow.getModuleVersion());
-       }
-
-       /** Utility to avoid NPE. */
-       private static String getVersionSafe(Bundle bundle) {
-               Object versionObj = bundle.getHeaders().get(Constants.BUNDLE_VERSION);
-               if (versionObj != null)
-                       return versionObj.toString();
-               else
-                       return null;
-       }
-
-       /** Unique deployed system id. TODO: use internal bundle id when available? */
-       public String getDeployedSystemId() {
-               return getName() + ":" + getVersion();
-       }
-
-       /**
-        * OSGi bundle are self-contained and do not require additional deployment
-        * data.
-        * 
-        * @return always null
-        */
-       public DeploymentData getDeploymentData() {
-               return null;
-       }
-
-       /** The related distribution. */
-       public Distribution getDistribution() {
-               return distribution;
-       }
-
-       /**
-        * The related distribution, a jar file with OSGi metadata referenced by a
-        * {@link Resource}.
-        */
-       public ResourceDistribution getResourceDistribution() {
-               return distribution;
-       }
-
-       /** TODO: reference the {@link OsgiRuntime} as target data? */
-       public TargetData getTargetData() {
-               throw new UnsupportedOperationException();
-       }
-
-       public void setResourceDistribution(ResourceDistribution distribution) {
-               this.distribution = distribution;
-       }
-
-       /**
-        * Bundle ID used by the OSGi runtime. To be used for optimization when
-        * looking in the bundle context. Can therefore be null.
-        */
-       public Long getInternalBundleId() {
-               return internalBundleId;
-       }
-
-       /** Only package access for the time being. e.g. from {@link BundlesManager} */
-       void setInternalBundleId(Long internalBundleId) {
-               this.internalBundleId = internalBundleId;
-       }
-
-       /** Value of the <code>Bundle-Name</code> directive. */
-       public String getTitle() {
-               return title;
-       }
-
-       public void setTitle(String label) {
-               this.title = label;
-       }
-
-       /** Value of the <code>Bundle-Description</code> directive. */
-       public String getDescription() {
-               return description;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-
-       public ModuleDescriptor getModuleDescriptor() {
-               ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
-               moduleDescriptor.setName(getName());
-               moduleDescriptor.setVersion(getVersion());
-               moduleDescriptor.setDescription(description);
-               moduleDescriptor.setTitle(title);
-               return moduleDescriptor;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModule.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModule.java
deleted file mode 100644 (file)
index ca3f5fa..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.argeo.slc.osgi;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.core.execution.AbstractSpringExecutionModule;
-import org.argeo.slc.execution.ExecutionContext;
-
-@Deprecated
-public class OsgiExecutionModule extends AbstractSpringExecutionModule {
-       private final static Log log = LogFactory.getLog(OsgiExecutionModule.class);
-
-       public OsgiExecutionModule() {
-               log.error("######## ERROR - DEPRECATED APPROACH USED ########");
-               log.error(OsgiExecutionModule.class.getName() + " is deprecated. ");
-               log
-                               .error("It will be removed in the next release. Remove its bean definition.");
-               log
-                               .error("And replace: <service interface=\"org.argeo.slc.execution.ExecutionModule\" ref=\"executionModule\" />");
-               log
-                               .error("by: <beans:import resource=\"classpath:org/argeo/slc/osgi/execution/spring.xml\" /> ");
-               log.error("in osgi.xml.\n\n");
-       }
-
-       public void setExecutionContext(ExecutionContext executionContext) {
-               // do nothing, just for compatibility
-       }
-
-       /*
-        * private BundleContext bundleContext;
-        * 
-        * @Override public void execute(ExecutionFlowDescriptor
-        * executionFlowDescriptor) { if (descriptorConverter != null)
-        * executionContext.addVariables(descriptorConverter
-        * .convertValues(executionFlowDescriptor));
-        * 
-        * ExecutionFlow flow = findExecutionFlow(getName(), getVersion(),
-        * executionFlowDescriptor.getName()); flow.run(); }
-        * 
-        * @Override protected Map<String, ExecutionFlow> listFlows() { String
-        * filter = "(org.argeo.slc.execution.module.name=" + getName() + ")";
-        * ServiceReference[] sfs; try { sfs =
-        * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
-        * filter); } catch (InvalidSyntaxException e) { throw new SlcException(
-        * "Cannot retrieve service reference for flow " + filter, e); }
-        * 
-        * Map<String, ExecutionFlow> flows = new HashMap<String, ExecutionFlow>();
-        * for (ServiceReference sf : sfs) { ExecutionFlow flow = (ExecutionFlow)
-        * bundleContext.getService(sf); flows.put(flow.getName(), flow); } return
-        * flows; }
-        * 
-        * public String getName() { return
-        * bundleContext.getBundle().getSymbolicName(); }
-        * 
-        * public String getVersion() { return
-        * bundleContext.getBundle().getHeaders().get("Bundle-Version") .toString();
-        * }
-        * 
-        * public void setBundleContext(BundleContext bundleContext) {
-        * this.bundleContext = bundleContext; }
-        * 
-        * protected ExecutionFlow findExecutionFlow(String moduleName, String
-        * moduleVersion, String flowName) { String filter =
-        * "(&(org.argeo.slc.execution.module.name=" + moduleName +
-        * ")(org.argeo.slc.execution.flow.name=" + flowName + "))";
-        * log.debug("OSGi filter: " + filter);
-        * 
-        * Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
-        * ServiceReference[] sfs; try { sfs =
-        * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
-        * filter); } catch (InvalidSyntaxException e) { throw new
-        * SlcException("Cannot retrieve service reference for " + filter, e); }
-        * 
-        * if (sfs == null || sfs.length == 0) throw new
-        * SlcException("No execution flow found for " + filter); else if
-        * (sfs.length > 1) throw new
-        * SlcException("More than one execution flow found for " + filter); return
-        * (ExecutionFlow) bundleContext.getService(sfs[0]); }
-        */
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModulesManager.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModulesManager.java
deleted file mode 100644 (file)
index 63eb6f9..0000000
+++ /dev/null
@@ -1,686 +0,0 @@
-package org.argeo.slc.osgi;
-
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.DefaultExecutionFlowDescriptorConverter;
-import org.argeo.slc.deploy.Module;
-import org.argeo.slc.deploy.ModuleDescriptor;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
-import org.argeo.slc.execution.ExecutionModuleDescriptor;
-import org.argeo.slc.execution.ExecutionModulesListener;
-import org.argeo.slc.execution.RealizedFlow;
-import org.argeo.slc.runtime.AbstractExecutionModulesManager;
-import org.eclipse.gemini.blueprint.service.importer.OsgiServiceLifecycleListener;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.Constants;
-import org.osgi.framework.launch.Framework;
-import org.springframework.context.ApplicationContext;
-
-/** Execution modules manager implementation based on an OSGi runtime. */
-public class OsgiExecutionModulesManager extends
-               AbstractExecutionModulesManager implements
-               OsgiServiceLifecycleListener, BundleListener {
-
-       private final static Log log = LogFactory
-                       .getLog(OsgiExecutionModulesManager.class);
-
-       private BundlesManager bundlesManager;
-       private Map<OsgiBundle, ExecutionContext> executionContexts = new HashMap<OsgiBundle, ExecutionContext>();
-       private Map<OsgiBundle, ExecutionFlowDescriptorConverter> executionFlowDescriptorConverters = new HashMap<OsgiBundle, ExecutionFlowDescriptorConverter>();
-       private Map<OsgiBundle, Set<ExecutionFlow>> executionFlows = new HashMap<OsgiBundle, Set<ExecutionFlow>>();
-       private ExecutionFlowDescriptorConverter defaultDescriptorConverter = new DefaultExecutionFlowDescriptorConverter();
-
-       private List<ExecutionModulesListener> executionModulesListeners = new ArrayList<ExecutionModulesListener>();
-
-       private Boolean registerFlowsToJmx = false;
-
-       public void init() throws Exception {
-               bundlesManager.getBundleContext().addBundleListener(this);
-
-               final String module = System.getProperty(UNIQUE_LAUNCH_MODULE_PROPERTY);
-               final String flow = System.getProperty(UNIQUE_LAUNCH_FLOW_PROPERTY);
-               if (module != null) {
-                       // launch a flow and stops
-                       new Thread("Unique Flow") {
-                               @Override
-                               public void run() {
-                                       executeFlowAndExit(module, null, flow);
-                               }
-                       }.start();
-               }
-       }
-
-       public void destroy() {
-               bundlesManager.getBundleContext().removeBundleListener(this);
-       }
-
-       /** Executes a single flow and <b>stops the JVM</b> */
-       protected void executeFlowAndExit(final String module,
-                       final String version, final String flow) {
-               if (log.isDebugEnabled())
-                       log.debug("Launch unique flow " + flow + " from module " + module);
-               try {
-                       OsgiBundle osgiBundle = bundlesManager.findFromPattern(module);
-                       if (osgiBundle == null)
-                               throw new SlcException("No OSGi bundle found for " + module);
-                       // Bundle moduleBundle =
-                       // bundlesManager.findRelatedBundle(osgiBundle);
-                       start(osgiBundle);
-
-                       RealizedFlow lastLaunch = findRealizedFlow(module, flow);
-                       if (lastLaunch == null)
-                               throw new SlcException("Cannot find launch for " + module + " "
-                                               + flow);
-                       execute(lastLaunch);
-               } catch (Exception e) {
-                       log.error(
-                                       "Error in unique flow " + flow + " from module " + module,
-                                       e);
-               } finally {
-                       if (log.isDebugEnabled())
-                               log.debug("Shutdown OSGi runtime...");
-                       Framework framework = (Framework) bundlesManager.getBundleContext()
-                                       .getBundle(0);
-                       try {
-                               // shutdown framework
-                               framework.stop();
-                               // wait 1 min for shutdown
-                               framework.waitForStop(60 * 1000);
-                               // close VM
-                               System.exit(0);
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                               System.exit(1);
-                       }
-               }
-       }
-
-       // public void startExectionModule(String moduleName, String moduleVersion)
-       // {
-       // try {
-       // ServiceReference[] sr = bundlesManager.getServiceRefSynchronous(
-       // ApplicationContext.class.getName(),
-       // "org.springframework.context.service.name=" + moduleName);
-       // // bundlesManager.startSynchronous(moduleBundle);
-       // if (sr == null || sr.length == 0)
-       // throw new SlcException(
-       // "Cannot find execution module application context "
-       // + moduleName);
-       // } catch (InvalidSyntaxException e) {
-       // throw new SlcException("Cannot start exeuction module "
-       // + moduleName, e);
-       // }
-       // }
-
-       public synchronized ExecutionModuleDescriptor getExecutionModuleDescriptor(
-                       String moduleName, String version) {
-               ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
-               OsgiBundle osgiBundle = null;
-               DefaultNameVersion nameVersion = new DefaultNameVersion(moduleName,
-                               version);
-               bundles: for (Iterator<OsgiBundle> iterator = executionContexts
-                               .keySet().iterator(); iterator.hasNext();) {
-                       OsgiBundle ob = iterator.next();
-                       if (nameVersion.getVersion() != null) {
-                               if (ob.equals(nameVersion)) {
-                                       osgiBundle = ob;
-                                       break bundles;
-                               }
-                       } else {
-                               if (ob.getName().equals(nameVersion.getName())) {
-                                       osgiBundle = ob;
-                                       break bundles;
-                               }
-                       }
-               }
-               if (osgiBundle == null)
-                       throw new SlcException("No execution module registered for "
-                                       + nameVersion);
-               md.setName(osgiBundle.getName());
-               md.setVersion(osgiBundle.getVersion());
-               md.setTitle(osgiBundle.getTitle());
-               md.setDescription(osgiBundle.getDescription());
-
-               ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = getExecutionFlowDescriptorConverter(
-                               moduleName, version);
-               if (executionFlowDescriptorConverter == null)
-                       throw new SlcException("No flow converter found.");
-               executionFlowDescriptorConverter.addFlowsToDescriptor(md,
-                               listFlows(moduleName, version));
-               return md;
-       }
-
-       public synchronized List<ExecutionModuleDescriptor> listExecutionModules() {
-               List<ExecutionModuleDescriptor> descriptors = new ArrayList<ExecutionModuleDescriptor>();
-
-               for (Iterator<OsgiBundle> iterator = executionContexts.keySet()
-                               .iterator(); iterator.hasNext();) {
-                       OsgiBundle osgiBundle = iterator.next();
-                       ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
-                       setMetadataFromBundle(md,
-                                       bundlesManager.findRelatedBundle(osgiBundle));
-                       descriptors.add(md);
-               }
-               return descriptors;
-       }
-
-       protected synchronized Map<String, ExecutionFlow> listFlows(
-                       String moduleName, String moduleVersion) {
-
-               Map<String, ExecutionFlow> flows = new HashMap<String, ExecutionFlow>();
-               OsgiBundle key = bundlesManager.findRelatedBundle(moduleName,
-                               moduleVersion);
-               if (!executionFlows.containsKey(key))
-                       return flows;
-               Set<ExecutionFlow> flowsT = executionFlows.get(key);
-               for (ExecutionFlow flow : flowsT)
-                       flows.put(flow.getName(), flow);
-               return flows;
-       }
-
-       protected ExecutionFlow findExecutionFlow(String moduleName,
-                       String moduleVersion, String flowName) {
-               String filter = moduleVersion == null || moduleVersion.equals("0.0.0") ? "(&(Bundle-SymbolicName="
-                               + moduleName
-                               + ")(org.eclipse.gemini.blueprint.bean.name="
-                               + flowName + "))"
-                               : "(&(Bundle-SymbolicName=" + moduleName + ")(Bundle-Version="
-                                               + moduleVersion
-                                               + ")(org.eclipse.gemini.blueprint.bean.name="
-                                               + flowName + "))";
-               return bundlesManager.getSingleServiceStrict(ExecutionFlow.class,
-                               filter, true);
-       }
-
-       protected ExecutionContext findExecutionContext(String moduleName,
-                       String moduleVersion) {
-               String filter = moduleFilter(moduleName, moduleVersion);
-               return bundlesManager.getSingleServiceStrict(ExecutionContext.class,
-                               filter, true);
-       }
-
-       protected ExecutionFlowDescriptorConverter findExecutionFlowDescriptorConverter(
-                       String moduleName, String moduleVersion) {
-               String filter = moduleFilter(moduleName, moduleVersion);
-               return bundlesManager.getSingleService(
-                               ExecutionFlowDescriptorConverter.class, filter, false);
-       }
-
-       /** Only based on symbolic name if version is null or "0.0.0" */
-       protected String moduleFilter(String moduleName, String moduleVersion) {
-               return moduleVersion == null || moduleVersion.equals("0.0.0") ? "(Bundle-SymbolicName="
-                               + moduleName + ")"
-                               : "(&(Bundle-SymbolicName=" + moduleName + ")(Bundle-Version="
-                                               + moduleVersion + "))";
-
-       }
-
-       /**
-        * Builds a minimal realized flow, based on the provided information
-        * (typically from the command line).
-        * 
-        * @param module
-        *            a bundle id, or a pattern contained in a bundle symbolic name
-        * @param module
-        *            the execution flow name
-        * @return a minimal realized flow, to be used in an execution
-        */
-       public RealizedFlow findRealizedFlow(String module, String executionName) {
-               // First check whether we have a bundleId
-               Long bundleId = null;
-               try {
-                       bundleId = Long.parseLong(module);
-               } catch (NumberFormatException e) {
-                       // silent
-               }
-
-               // Look for bundle names containing pattern
-               OsgiBundle bundle = null;
-               if (bundleId != null) {
-                       bundle = bundlesManager.getBundle(bundleId);
-               } else {
-                       bundle = bundlesManager.findFromPattern(module);
-               }
-
-               if (bundle != null) {
-                       RealizedFlow launch = new RealizedFlow();
-                       launch.setModuleName(bundle.getName());
-                       launch.setModuleVersion(bundle.getVersion());
-                       ExecutionFlowDescriptor descriptor = new ExecutionFlowDescriptor();
-                       descriptor.setName(executionName);
-                       launch.setFlowDescriptor(descriptor);
-                       return launch;
-               } else {
-                       log.warn("Could not find any execution module matching these requirements.");
-                       return null;
-               }
-       }
-
-       public void upgrade(NameVersion nameVersion) {
-               OsgiBundle osgiBundle = new OsgiBundle(nameVersion);
-               bundlesManager.upgradeSynchronous(osgiBundle);
-       }
-
-       protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
-                       String moduleName, String moduleVersion) {
-               return findExecutionFlowDescriptorConverter(moduleName, moduleVersion);
-               // OsgiBundle osgiBundle = new OsgiBundle(moduleName, moduleVersion);
-               // return getExecutionFlowDescriptorConverter(osgiBundle);
-       }
-
-       protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
-                       OsgiBundle osgiBundle) {
-               if (executionFlowDescriptorConverters.containsKey(osgiBundle))
-                       return executionFlowDescriptorConverters.get(osgiBundle);
-               else
-                       return defaultDescriptorConverter;
-       }
-
-       public ModuleDescriptor getModuleDescriptor(String moduleName,
-                       String version) {
-               return getExecutionModuleDescriptor(moduleName, version);
-       }
-
-       public List<ModuleDescriptor> listModules() {
-               Bundle[] bundles = bundlesManager.getBundleContext().getBundles();
-               List<ModuleDescriptor> lst = new ArrayList<ModuleDescriptor>();
-               for (Bundle bundle : bundles) {
-                       ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
-                       setMetadataFromBundle(moduleDescriptor, bundle);
-                       lst.add(moduleDescriptor);
-               }
-               return lst;
-       }
-
-       public void start(NameVersion nameVersion) {
-               try {
-                       Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
-                                       nameVersion));
-                       if (bundle == null)
-                               throw new SlcException("Could not find bundle for "
-                                               + nameVersion);
-
-                       bundlesManager.startSynchronous(bundle);
-                       if (isSpringInstrumented(bundle)) {
-                               // Wait for Spring application context to be ready
-                               String filter = "(Bundle-SymbolicName="
-                                               + bundle.getSymbolicName() + ")";
-                               try {
-                                       bundlesManager.getServiceRefSynchronous(
-                                                       ApplicationContext.class, filter);
-                               } catch (Exception e) {
-                                       // stop if application context not found
-                                       bundle.stop();
-                                       throw e;
-                               }
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot start " + nameVersion, e);
-               }
-       }
-
-       /** Do it calmly in order to avoid NPE */
-       private Boolean isSpringInstrumented(Bundle bundle) {
-               Dictionary<?, ?> headers = bundle.getHeaders();
-               if (headers != null && headers.get("Spring-Context") != null)
-                       return true;
-               Enumeration<?> springEntryPaths = bundle
-                               .getEntryPaths("/META-INF/spring");
-               if (springEntryPaths != null && springEntryPaths.hasMoreElements())
-                       return true;
-               return false;
-       }
-
-       public void stop(NameVersion nameVersion) {
-               try {
-                       Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
-                                       nameVersion));
-                       bundlesManager.stopSynchronous(bundle);
-               } catch (BundleException e) {
-                       throw new SlcException("Cannot stop " + nameVersion, e);
-               }
-       }
-
-       protected void setMetadataFromBundle(ModuleDescriptor md, Bundle bundle) {
-               Bundle bdl = bundle;
-               if (bdl == null) {
-                       if (md.getName() == null || md.getVersion() == null)
-                               throw new SlcException("Name and version not available.");
-
-                       Bundle[] bundles = bundlesManager.getBundleContext().getBundles();
-                       for (Bundle b : bundles) {
-                               if (b.getSymbolicName().equals(md.getName())
-                                               && md.getVersion().equals(
-                                                               getHeaderSafe(b, Constants.BUNDLE_VERSION))) {
-                                       bdl = b;
-                                       break;
-                               }
-                       }
-
-               }
-
-               if (bdl == null)
-                       throw new SlcException("Cannot find bundle.");
-
-               md.setName(bdl.getSymbolicName());
-               md.setVersion(getHeaderSafe(bdl, Constants.BUNDLE_VERSION));
-               md.setTitle(getHeaderSafe(bdl, Constants.BUNDLE_NAME));
-               md.setDescription(getHeaderSafe(bdl, Constants.BUNDLE_DESCRIPTION));
-
-               // copy manifets header to meta data
-               Dictionary<?, ?> headers = bundle.getHeaders();
-               Enumeration<?> keys = headers.keys();
-               while (keys.hasMoreElements()) {
-                       Object key = keys.nextElement();
-                       Object value = headers.get(key);
-                       if (value != null)
-                               md.getMetadata().put(key.toString(), value.toString());
-               }
-
-               // check if started
-               if (bundle.getState() == Bundle.ACTIVE
-                               || bundle.getState() == Bundle.STARTING)
-                       md.setStarted(true);
-               else
-                       md.setStarted(false);
-       }
-
-       private String getHeaderSafe(Bundle bundle, Object key) {
-               Object obj = bundle.getHeaders().get(key);
-               if (obj == null)
-                       return null;
-               else
-                       return obj.toString();
-       }
-
-       /*
-        * REGISTRATION
-        */
-
-       /** Registers an execution context. */
-       public synchronized void register(ExecutionContext executionContext,
-                       Map<String, String> properties) {
-               OsgiBundle osgiBundle = asOsgiBundle(properties);
-               Bundle bundle = bundlesManager.findRelatedBundle(osgiBundle);
-               osgiBundle.setTitle(getHeaderSafe(bundle, Constants.BUNDLE_NAME));
-               osgiBundle.setDescription(getHeaderSafe(bundle,
-                               Constants.BUNDLE_DESCRIPTION));
-               executionContexts.put(osgiBundle, executionContext);
-               if (log.isTraceEnabled())
-                       log.trace("Registered execution context from " + osgiBundle);
-               // Notify
-               ModuleDescriptor md = osgiBundle.getModuleDescriptor();
-               md.setStarted(true);
-               for (ExecutionModulesListener listener : executionModulesListeners)
-                       listener.executionModuleAdded(md);
-       }
-
-       /** Unregisters an execution context. */
-       public synchronized void unregister(ExecutionContext executionContext,
-                       Map<String, String> properties) {
-               // FIXME why are properties null?
-               if (properties == null)
-                       return;
-               OsgiBundle osgiBundle = asOsgiBundle(properties);
-               if (executionContexts.containsKey(osgiBundle)) {
-                       executionContexts.remove(osgiBundle);
-                       if (log.isTraceEnabled())
-                               log.trace("Removed execution context from " + osgiBundle);
-                       // Notify
-                       ModuleDescriptor md = osgiBundle.getModuleDescriptor();
-                       md.setStarted(false);
-                       for (ExecutionModulesListener listener : executionModulesListeners)
-                               listener.executionModuleRemoved(md);
-               }
-       }
-
-       /** Registers an execution flow. */
-       public synchronized void register(ExecutionFlow executionFlow,
-                       Map<String, String> properties) {
-               OsgiBundle osgiBundle = asOsgiBundle(properties);
-               if (!executionFlows.containsKey(osgiBundle)) {
-                       executionFlows.put(osgiBundle, new HashSet<ExecutionFlow>());
-               }
-               executionFlows.get(osgiBundle).add(executionFlow);
-               if (log.isTraceEnabled())
-                       log.trace("Registered " + executionFlow + " from " + osgiBundle);
-
-               // notifications
-               if (registerFlowsToJmx)
-                       registerMBean(osgiBundle, executionFlow);
-               ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
-               for (ExecutionModulesListener listener : executionModulesListeners)
-                       listener.executionFlowAdded(osgiBundle.getModuleDescriptor(),
-                                       efdc.getExecutionFlowDescriptor(executionFlow));
-       }
-
-       /** Unregisters an execution flow. */
-       public synchronized void unregister(ExecutionFlow executionFlow,
-                       Map<String, String> properties) {
-               // FIXME why are properties null?
-               if (properties == null)
-                       return;
-               OsgiBundle osgiBundle = asOsgiBundle(properties);
-               if (executionFlows.containsKey(osgiBundle)) {
-                       Set<ExecutionFlow> flows = executionFlows.get(osgiBundle);
-                       flows.remove(executionFlow);
-                       if (log.isTraceEnabled())
-                               log.trace("Removed " + executionFlow + " from " + osgiBundle);
-                       if (flows.size() == 0) {
-                               executionFlows.remove(osgiBundle);
-                               if (log.isTraceEnabled())
-                                       log.trace("Removed flows set from " + osgiBundle);
-                       }
-
-                       // notifications
-                       if (registerFlowsToJmx)
-                               unregisterMBean(osgiBundle, executionFlow);
-                       ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
-                       for (ExecutionModulesListener listener : executionModulesListeners)
-                               listener.executionFlowRemoved(osgiBundle.getModuleDescriptor(),
-                                               efdc.getExecutionFlowDescriptor(executionFlow));
-               }
-       }
-
-       /** Registers an execution module listener. */
-       public synchronized void register(
-                       ExecutionModulesListener executionModulesListener,
-                       Map<String, String> properties) {
-               // sync with current state
-               for (OsgiBundle osgiBundle : executionContexts.keySet()) {
-                       executionModulesListener.executionModuleAdded(osgiBundle
-                                       .getModuleDescriptor());
-               }
-               for (OsgiBundle osgiBundle : executionFlows.keySet()) {
-                       ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
-                       for (ExecutionFlow executionFlow : executionFlows.get(osgiBundle))
-                               executionModulesListener.executionFlowAdded(
-                                               osgiBundle.getModuleDescriptor(),
-                                               efdc.getExecutionFlowDescriptor(executionFlow));
-               }
-               executionModulesListeners.add(executionModulesListener);
-       }
-
-       /** Unregisters an execution module listener. */
-       public synchronized void unregister(
-                       ExecutionModulesListener executionModulesListener,
-                       Map<String, String> properties) {
-               executionModulesListeners.remove(executionModulesListener);
-       }
-
-       /*
-        * INTERFACE IMPLEMENTATIONS
-        */
-
-       public void bundleChanged(BundleEvent evt) {
-               Bundle bundle = evt.getBundle();
-               if (bundle.getHeaders().get(
-                               ExecutionModuleDescriptor.SLC_EXECUTION_MODULE) != null) {
-                       OsgiBundle osgiBundle = new OsgiBundle(bundle);
-                       if (evt.getType() == BundleEvent.INSTALLED)
-                               for (ExecutionModulesListener listener : executionModulesListeners)
-                                       listener.executionModuleAdded(osgiBundle
-                                                       .getModuleDescriptor());
-                       else if (evt.getType() == BundleEvent.UNINSTALLED)
-                               for (ExecutionModulesListener listener : executionModulesListeners)
-                                       listener.executionModuleRemoved(osgiBundle
-                                                       .getModuleDescriptor());
-               }
-
-       }
-
-       @SuppressWarnings({ "rawtypes" })
-       public synchronized void bind(Object service, Map properties)
-                       throws Exception {
-               if (service instanceof ExecutionFlowDescriptorConverter) {
-                       ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = (ExecutionFlowDescriptorConverter) service;
-                       OsgiBundle osgiBundle = asOsgiBundle(properties);
-                       executionFlowDescriptorConverters.put(osgiBundle,
-                                       executionFlowDescriptorConverter);
-                       if (log.isTraceEnabled())
-                               log.debug("Registered execution flow descriptor converter from "
-                                               + osgiBundle);
-               } else {
-                       // ignore
-               }
-       }
-
-       @SuppressWarnings("rawtypes")
-       public synchronized void unbind(Object service, Map properties)
-                       throws Exception {
-               if (service instanceof ExecutionFlowDescriptorConverter) {
-                       OsgiBundle osgiBundle = asOsgiBundle(properties);
-                       if (executionFlowDescriptorConverters.containsKey(osgiBundle)) {
-                               executionFlowDescriptorConverters.remove(osgiBundle);
-                               if (log.isTraceEnabled())
-                                       log.debug("Removed execution flow descriptor converter from "
-                                                       + osgiBundle);
-                       }
-               } else {
-                       // ignore
-               }
-       }
-
-       /*
-        * JMX
-        */
-       protected MBeanServer getMBeanServer() {
-               return ManagementFactory.getPlatformMBeanServer();
-       }
-
-       public void registerMBean(Module module, ExecutionFlow executionFlow) {
-               try {
-                       StandardMBean mbean = new StandardMBean(executionFlow,
-                                       ExecutionFlow.class);
-                       getMBeanServer().registerMBean(mbean,
-                                       flowMBeanName(module, executionFlow));
-               } catch (Exception e) {
-                       String msg = "Cannot register execution flow " + executionFlow
-                                       + " as mbean";
-                       throw new SlcException(msg, e);
-               }
-       }
-
-       public void unregisterMBean(Module module, ExecutionFlow executionFlow) {
-               try {
-                       getMBeanServer().unregisterMBean(
-                                       flowMBeanName(module, executionFlow));
-               } catch (Exception e) {
-                       String msg = "Cannot unregister execution flow " + executionFlow
-                                       + " as mbean";
-                       throw new SlcException(msg, e);
-               }
-       }
-
-       protected ObjectName flowMBeanName(Module module,
-                       ExecutionFlow executionFlow) {
-               String executionModulesPrefix = "SLCExecutionModules";
-               // String path = executionFlow.getPath();
-               String name = executionFlow.getName();
-               // if (path == null && name.indexOf('/') >= 0) {
-               // path = name.substring(0, name.lastIndexOf('/'));
-               // name = name.substring(name.lastIndexOf('/'));
-               // }
-
-               StringBuffer buf = new StringBuffer(executionModulesPrefix + ":"
-                               + "module=" + module.getName() + " [" + module.getVersion()
-                               + "],");
-
-               // if (path != null && !path.equals("")) {
-               // int depth = 0;
-               // for (String token : path.split("/")) {
-               // if (!token.equals("")) {
-               // buf.append("path").append(depth).append('=');
-               // // in order to have directories first
-               // buf.append('/');
-               // buf.append(token).append(',');
-               // depth++;
-               // }
-               // }
-               // }
-               buf.append("name=").append(name);
-               try {
-                       return new ObjectName(buf.toString());
-               } catch (Exception e) {
-                       throw new SlcException("Cannot generate object name based on "
-                                       + buf, e);
-               }
-       }
-
-       /*
-        * UTILITIES
-        */
-       @SuppressWarnings("rawtypes")
-       private OsgiBundle asOsgiBundle(Map properties) {
-               String bundleSymbolicName = checkAndGet(Constants.BUNDLE_SYMBOLICNAME,
-                               properties);
-               String bundleVersion = checkAndGet(Constants.BUNDLE_VERSION, properties);
-               return new OsgiBundle(bundleSymbolicName, bundleVersion);
-       }
-
-       @SuppressWarnings("rawtypes")
-       private String checkAndGet(Object key, Map properties) {
-               if (!properties.containsKey(key) || properties.get(key) == null)
-                       throw new SlcException(key + " not set in " + properties);
-               else
-                       return properties.get(key).toString();
-       }
-
-       public void setBundlesManager(BundlesManager bundlesManager) {
-               this.bundlesManager = bundlesManager;
-       }
-
-       public void setDefaultDescriptorConverter(
-                       ExecutionFlowDescriptorConverter defaultDescriptorConverter) {
-               this.defaultDescriptorConverter = defaultDescriptorConverter;
-       }
-
-       public void setRegisterFlowsToJmx(Boolean registerFlowsToJmx) {
-               this.registerFlowsToJmx = registerFlowsToJmx;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionResources.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionResources.java
deleted file mode 100644 (file)
index 3668b91..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.argeo.slc.osgi;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.FileExecutionResources;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.eclipse.gemini.blueprint.io.OsgiBundleResource;
-import org.osgi.framework.BundleContext;
-import org.springframework.core.io.Resource;
-
-/** Write access to resources in an OSGi context */
-public class OsgiExecutionResources extends FileExecutionResources implements
-               BundleContextAware {
-       private final static Log log = LogFactory
-                       .getLog(OsgiExecutionResources.class);
-
-       private BundleContext bundleContext;
-
-       @Override
-       protected File fileFromResource(Resource resource) {
-               File file = super.fileFromResource(resource);
-               if (file != null)
-                       return file;
-
-               if (!(resource instanceof OsgiBundleResource))
-                       return null;
-
-               OsgiBundleResource osgiBundleResource = (OsgiBundleResource) resource;
-               try {
-                       return osgiBundleResource.getFile();
-               } catch (IOException e) {
-                       if (log.isTraceEnabled())
-                               log.trace("Resource " + resource
-                                               + " is not available on the file system: " + e);
-               }
-
-               // TODO: ability to access resources in other bundles
-               String location = bundleContext.getBundle().getLocation();
-               String base = null;
-               if (location.startsWith("reference:file:"))
-                       base = location.substring("reference:file:".length());
-               else if (location.startsWith("initial@reference:file:")) {
-                       // TODO: Equinox specific?
-                       String relPath = location.substring("initial@reference:file:"
-                                       .length());
-                       // if (relPath.startsWith("../"))// relative to the framework jar
-                       // relPath = relPath.substring("../".length());
-                       // String framework =
-                       // System.getProperty("osgi.framework").substring(
-                       // "file:".length());
-                       // log.debug(framework);
-                       String installArea = System.getProperty("osgi.install.area")
-                                       .substring("file:".length());
-                       // log.debug(installArea);
-                       base = installArea + '/' + relPath;
-                       // int sepIndex = framework.lastIndexOf(File.separatorChar);
-                       // framework = framework.substring(0, sepIndex);
-                       // base = framework + '/' + relPath;
-               } else {
-                       return null;
-               }
-
-               String path = base + '/' + osgiBundleResource.getPathWithinContext();
-               try {
-                       file = new File(path).getCanonicalFile();
-               } catch (IOException e) {
-                       throw new SlcException("Cannot determine canonical path for "
-                                       + path, e);
-               }
-
-               if (!file.exists())
-                       throw new SlcException(file
-                                       + " was retrieved in bundle located at '" + location
-                                       + "' for resource " + resource + " but it does not exist");
-
-               if (log.isTraceEnabled())
-                       log.debug("OSGi local resource: " + file + " from " + resource);
-               return file;
-       }
-
-       public void setBundleContext(BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiRuntime.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiRuntime.java
deleted file mode 100644 (file)
index 089baa6..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.argeo.slc.osgi;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.StreamReadable;
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.core.build.VersionedResourceDistribution;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.DynamicRuntime;
-import org.argeo.slc.deploy.TargetData;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-
-public class OsgiRuntime implements BundleContextAware, ResourceLoaderAware,
-               DynamicRuntime<OsgiBundle> {
-       private String uuid = UUID.randomUUID().toString();
-       private BundleContext bundleContext;
-       private ResourceLoader resourceLoader;
-
-       public List<OsgiBundle> listModules() {
-               List<OsgiBundle> modules = new ArrayList<OsgiBundle>();
-               Bundle[] bundles = bundleContext.getBundles();
-               for (Bundle bundle : bundles) {
-                       OsgiBundle osgiBundle = new OsgiBundle(bundle);
-                       modules.add(osgiBundle);
-                       String location = bundle.getLocation();
-                       if (location != null) {
-                               Resource resource = resourceLoader.getResource(location);
-                               osgiBundle
-                                               .setResourceDistribution(new VersionedResourceDistribution(
-                                                               osgiBundle.getName(), osgiBundle.getVersion(),
-                                                               resource));
-                       }
-               }
-               return modules;
-       }
-
-       public OsgiBundle installModule(Distribution distribution) {
-               if (!(distribution instanceof StreamReadable))
-                       throw new UnsupportedException("distribution", distribution);
-
-               StreamReadable sr = (StreamReadable) distribution;
-               Bundle bundle;
-               try {
-                       bundle = bundleContext.installBundle(sr.toString(), sr
-                                       .getInputStream());
-               } catch (BundleException e) {
-                       throw new SlcException(
-                                       "Cannot install OSGi bundle " + distribution, e);
-               }
-               return new OsgiBundle(bundle);
-       }
-
-       public void updateModule(NameVersion nameVersion) {
-               Bundle bundle = findBundle(nameVersion);
-               try {
-                       bundle.update();
-               } catch (BundleException e) {
-                       throw new SlcException("Cannot update " + bundle, e);
-               }
-       }
-
-       public void uninstallModule(NameVersion nameVersion) {
-               Bundle bundle = findBundle(nameVersion);
-               try {
-                       bundle.uninstall();
-               } catch (BundleException e) {
-                       throw new SlcException("Cannot uninstall " + bundle, e);
-               }
-       }
-
-       public void startModule(NameVersion nameVersion) {
-               Bundle bundle = findBundle(nameVersion);
-               try {
-                       bundle.start();
-                       // TODO: use bundle manager
-               } catch (BundleException e) {
-                       throw new SlcException("Cannot uninstall " + bundle, e);
-               }
-       }
-
-       protected Bundle findBundle(NameVersion nameVersion) {
-               Bundle[] bundles = bundleContext.getBundles();
-               for (Bundle bundle : bundles) {
-                       OsgiBundle osgiBundle = new OsgiBundle(bundle);
-                       if (osgiBundle.equals(nameVersion)) {
-                               return bundle;
-                       }
-               }
-               throw new SlcException("Could not find bundle " + nameVersion);
-       }
-
-       public void shutdown() {
-               // FIXME use framework
-               throw new UnsupportedException();
-       }
-
-       public String getDeployedSystemId() {
-               return uuid;
-       }
-
-       public DeploymentData getDeploymentData() {
-               throw new UnsupportedException();
-       }
-
-       public Distribution getDistribution() {
-               throw new UnsupportedException();
-       }
-
-       public TargetData getTargetData() {
-               throw new UnsupportedException();
-       }
-
-       public void setBundleContext(BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-       }
-
-       public void setResourceLoader(ResourceLoader resourceLoader) {
-               this.resourceLoader = resourceLoader;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/AbstractOsgiModularDistribution.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/AbstractOsgiModularDistribution.java
deleted file mode 100644 (file)
index 61380c0..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.argeo.slc.osgi.build;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.build.ModularDistribution;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.springframework.beans.factory.InitializingBean;
-
-public abstract class AbstractOsgiModularDistribution implements
-               ModularDistribution, BundleContextAware, InitializingBean {
-       private final static Log log = LogFactory
-                       .getLog(AbstractOsgiModularDistribution.class);
-
-       private BundleContext bundleContext;
-       private EclipseUpdateSite eclipseUpdateSite;
-
-       /** Initialized by the object itself. */
-       private SortedMap<NameVersion, Distribution> distributions = new TreeMap<NameVersion, Distribution>();
-
-       protected abstract void fillDistributions(
-                       SortedMap<NameVersion, Distribution> distributions)
-                       throws Exception;
-
-       public Distribution getModuleDistribution(String moduleName,
-                       String moduleVersion) {
-               return distributions.get(new DefaultNameVersion(moduleName,
-                               moduleVersion));
-       }
-
-       public String getDistributionId() {
-               return bundleContext.getBundle().getSymbolicName()
-                               + "-"
-                               + bundleContext.getBundle().getHeaders()
-                                               .get(Constants.BUNDLE_VERSION);
-       }
-
-       public Set<NameVersion> listModulesNameVersions() {
-               return distributions.keySet();
-       }
-
-       public Iterator<NameVersion> nameVersions() {
-               return distributions.keySet().iterator();
-       }
-
-       public void setBundleContext(BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               fillDistributions(distributions);
-               if (log.isDebugEnabled())
-                       log.debug("Distribution " + getName() + ":" + getVersion()
-                                       + " loaded (" + distributions.size() + " modules)");
-       }
-
-       protected String findVersion(String name) {
-               Set<String> versions = new HashSet<String>();
-               for (NameVersion key : distributions.keySet()) {
-                       if (key.getName().equals(name))
-                               versions.add(key.getVersion());
-               }
-
-               if (versions.size() == 0)
-                       throw new SlcException("Cannot find version for name " + name);
-               else if (versions.size() > 1)
-                       throw new SlcException("Found more than one version for name "
-                                       + name + ": " + versions);
-               else
-                       return versions.iterator().next();
-
-       }
-
-       public Object getModulesDescriptor(String descriptorType) {
-               if (descriptorType.equals("eclipse"))
-                       return writeEclipseUpdateSite();
-               else
-                       throw new UnsupportedException("descriptorType", descriptorType);
-       }
-
-       protected Set<NameVersion> writePlainUrlList() {
-               return distributions.keySet();
-       }
-
-       protected String writeEclipseUpdateSite() {
-               if (eclipseUpdateSite == null)
-                       throw new SlcException("No eclipse update site declared.");
-
-               StringBuffer buf = new StringBuffer("");
-               buf.append("<site>");
-
-               List<EclipseUpdateSiteCategory> usedCategories = new ArrayList<EclipseUpdateSiteCategory>();
-               for (EclipseUpdateSiteFeature feature : eclipseUpdateSite.getFeatures()) {
-
-                       String featureId = feature.getName();
-                       String featureVersion = findVersion(featureId);
-                       buf.append("<feature");
-                       buf.append(" url=\"features/").append(featureId).append('_')
-                                       .append(featureVersion).append(".jar\"");
-                       buf.append(" id=\"").append(featureId).append("\"");
-                       buf.append(" version=\"").append(featureVersion).append("\"");
-                       buf.append(">\n");
-
-                       for (EclipseUpdateSiteCategory category : feature.getCategories()) {
-                               usedCategories.add(category);
-                               buf.append("  <category name=\"").append(category.getName())
-                                               .append("\"/>\n");
-                       }
-                       buf.append("</feature>\n\n");
-               }
-
-               for (EclipseUpdateSiteCategory category : usedCategories) {
-                       buf.append("<category-def");
-                       buf.append(" name=\"").append(category.getName()).append("\"");
-                       buf.append(" label=\"").append(category.getLabel()).append("\"");
-                       buf.append(">\n");
-                       buf.append("  <description>").append(category.getDescription())
-                                       .append("</description>\n");
-                       buf.append("</category-def>\n\n");
-               }
-
-               buf.append("</site>");
-               return buf.toString();
-       }
-
-       public String getName() {
-               return bundleContext.getBundle().getSymbolicName();
-       }
-
-       public String getVersion() {
-               return bundleContext.getBundle().getHeaders()
-                               .get(Constants.BUNDLE_VERSION).toString();
-       }
-
-       @Override
-       public String toString() {
-               return new DefaultNameVersion(this).toString();
-       }
-
-       public void setEclipseUpdateSite(EclipseUpdateSite eclipseUpdateSite) {
-               this.eclipseUpdateSite = eclipseUpdateSite;
-       }
-
-       public BundleContext getBundleContext() {
-               return bundleContext;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/BundleModularDistribution.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/BundleModularDistribution.java
deleted file mode 100644 (file)
index ec7d2f6..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.argeo.slc.osgi.build;
-
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.SortedMap;
-import java.util.StringTokenizer;
-import java.util.jar.JarInputStream;
-import java.util.jar.Manifest;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.core.build.VersionedResourceDistribution;
-import org.osgi.framework.Constants;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.io.ResourceLoader;
-
-public class BundleModularDistribution extends AbstractOsgiModularDistribution
-               implements ResourceLoaderAware {
-       private ResourceLoader resourceLoader;
-
-       private String libDirectory = "/lib";
-
-       protected void fillDistributions(
-                       SortedMap<NameVersion, Distribution> distributions)
-                       throws Exception {
-               Enumeration<URL> urls = (Enumeration<URL>) getBundleContext()
-                               .getBundle().findEntries(libDirectory, "*.jar", false);
-               while (urls.hasMoreElements()) {
-                       URL url = urls.nextElement();
-                       JarInputStream in = null;
-                       try {
-                               in = new JarInputStream(url.openStream());
-                               Manifest mf = in.getManifest();
-                               String name = mf.getMainAttributes().getValue(
-                                               Constants.BUNDLE_SYMBOLICNAME);
-                               // Skip additional specs such as
-                               // ; singleton:=true
-                               if (name.indexOf(';') > -1) {
-                                       name = new StringTokenizer(name, " ;").nextToken();
-                               }
-
-                               String version = mf.getMainAttributes().getValue(
-                                               Constants.BUNDLE_VERSION);
-                               DefaultNameVersion nameVersion = new DefaultNameVersion(name,
-                                               version);
-                               distributions.put(nameVersion,
-                                               new VersionedResourceDistribution(name, version,
-                                                               resourceLoader.getResource(url.toString())));
-                       } finally {
-                               IOUtils.closeQuietly(in);
-                       }
-               }
-       }
-
-       public void setLibDirectory(String libDirectory) {
-               this.libDirectory = libDirectory;
-       }
-
-       public void setResourceLoader(ResourceLoader resourceLoader) {
-               this.resourceLoader = resourceLoader;
-       }
-
-       /*
-        * @SuppressWarnings(value = { "unchecked" }) protected URL
-        * findModule(String moduleName, String version) { Enumeration<URL> urls =
-        * (Enumeration<URL>) bundleContext.getBundle() .findEntries(libDirectory,
-        * moduleName + "*", false);
-        * 
-        * if (!urls.hasMoreElements()) throw new SlcException("Cannot find module "
-        * + moduleName);
-        * 
-        * URL url = urls.nextElement();
-        * 
-        * // TODO: check version as well if (urls.hasMoreElements()) throw new
-        * SlcException("More than one module with name " + moduleName); return url;
-        * }
-        */
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSite.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSite.java
deleted file mode 100644 (file)
index b8debf5..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.argeo.slc.osgi.build;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class EclipseUpdateSite {
-       private List<EclipseUpdateSiteFeature> features = new ArrayList<EclipseUpdateSiteFeature>();
-
-       public List<EclipseUpdateSiteFeature> getFeatures() {
-               return features;
-       }
-
-       public void setFeatures(List<EclipseUpdateSiteFeature> features) {
-               this.features = features;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteCategory.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteCategory.java
deleted file mode 100644 (file)
index 510a555..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.argeo.slc.osgi.build;
-
-public class EclipseUpdateSiteCategory {
-       private String name;
-       private String label;
-       private String description;
-
-       public String getLabel() {
-               return label;
-       }
-
-       public void setLabel(String label) {
-               this.label = label;
-       }
-
-       public String getDescription() {
-               return description;
-       }
-
-       public void setDescription(String description) {
-               this.description = description;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteFeature.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteFeature.java
deleted file mode 100644 (file)
index 42ded0b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.argeo.slc.osgi.build;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class EclipseUpdateSiteFeature {
-       private String name;
-       private List<EclipseUpdateSiteCategory> categories = new ArrayList<EclipseUpdateSiteCategory>();
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public List<EclipseUpdateSiteCategory> getCategories() {
-               return categories;
-       }
-
-       public void setCategories(List<EclipseUpdateSiteCategory> categories) {
-               this.categories = categories;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java
deleted file mode 100644 (file)
index acc4bab..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.argeo.slc.osgi.build;
-
-import java.net.URL;
-import java.util.SortedMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.core.build.VersionedResourceDistribution;
-import org.argeo.slc.osgi.OsgiBundle;
-import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
-import org.osgi.framework.Bundle;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-
-public class OsgiRuntimeModularDistribution extends
-               AbstractOsgiModularDistribution implements ResourceLoaderAware {
-       private final static Log log = LogFactory
-                       .getLog(OsgiRuntimeModularDistribution.class);
-
-       private ResourceLoader resourceLoader;
-
-       protected void fillDistributions(
-                       SortedMap<NameVersion, Distribution> distributions)
-                       throws Exception {
-
-               String frameworkUrl = System.getProperty("osgi.framework");
-               String frameworkBaseUrl = null;
-               if (frameworkUrl != null)
-                       frameworkBaseUrl = frameworkUrl.substring(0, frameworkUrl
-                                       .lastIndexOf('/'));
-               bundles: for (Bundle bundle : getBundleContext().getBundles()) {
-                       OsgiBundle osgiBundle = new OsgiBundle(bundle);
-
-                       String originalLocation = bundle.getLocation();
-
-                       if (OsgiBundleUtils.isSystemBundle(bundle)) {
-                               continue bundles;
-                       }
-
-                       String location = originalLocation;
-                       if (originalLocation.startsWith("reference:file:"))
-                               location = originalLocation.substring("reference:".length());
-
-                       if (frameworkBaseUrl != null
-                                       && originalLocation.startsWith("initial@reference:file:")) {
-                               location = frameworkBaseUrl
-                                               + '/'
-                                               + originalLocation.substring("initial@reference:file:"
-                                                               .length());
-                       }
-
-                       try {
-                               URL url = new URL(location);
-                               Resource res = resourceLoader.getResource(url.toString());
-                               distributions.put(osgiBundle,
-                                               new VersionedResourceDistribution(osgiBundle, res));
-
-                               if (log.isTraceEnabled())
-                                       log.debug("Added url " + url + " from original location "
-                                                       + originalLocation);
-                       } catch (Exception e) {
-                               log.warn("Cannot interpret location " + location
-                                               + " of bundle " + bundle + ": " + e);
-                       }
-               }
-       }
-
-       public void setResourceLoader(ResourceLoader resourceLoader) {
-               this.resourceLoader = resourceLoader;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/deploy/OsgiResourceSet.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/deploy/OsgiResourceSet.java
deleted file mode 100644 (file)
index bea3949..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.argeo.slc.osgi.deploy;
-
-import org.argeo.slc.core.deploy.DefaultResourceSet;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.eclipse.gemini.blueprint.io.OsgiBundleResourceLoader;
-import org.eclipse.gemini.blueprint.io.OsgiBundleResourcePatternResolver;
-import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.springframework.core.io.ResourceLoader;
-
-/**
- * Retrieves ressources from an OSGi bundle either the active one or another one
- * referenced by its symbolic name.
- */
-public class OsgiResourceSet extends DefaultResourceSet implements
-               BundleContextAware {
-       private BundleContext bundleContext;
-       private Bundle bundle = null;
-       private String bundleSymbolicName = null;
-
-       private OsgiBundleResourceLoader osgiBundleResourceLoader = null;
-
-       @Override
-       public void afterPropertiesSet() throws Exception {
-               osgiBundleResourceLoader = new OsgiBundleResourceLoader(getBundle());
-               if (getResourcePatternResolver() == null)
-                       setResourcePatternResolver(new OsgiBundleResourcePatternResolver(
-                                       osgiBundleResourceLoader));
-               super.afterPropertiesSet();
-       }
-
-       public Bundle getBundle() {
-               if (bundle != null)
-                       return bundle;
-               else if (bundleSymbolicName != null)// do not cache
-                       return OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
-                                       bundleSymbolicName);
-               else
-                       // containing bundle
-                       return bundleContext.getBundle();
-       }
-
-       public void setBundleContext(BundleContext bundleContext) {
-               this.bundleContext = bundleContext;
-       }
-
-       @Override
-       public ResourceLoader getResourceLoaderToUse() {
-               return osgiBundleResourceLoader;
-       }
-
-       public void setBundle(Bundle bundle) {
-               this.bundle = bundle;
-       }
-
-       public void setBundleSymbolicName(String bundleSymbolicName) {
-               this.bundleSymbolicName = bundleSymbolicName;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/execution.xml b/cms/org.argeo.slc.spring/src/org/argeo/slc/osgi/execution.xml
deleted file mode 100644 (file)
index cc0aac0..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License, 
-       Version 2.0 (the "License"); you may not use this file except in compliance 
-       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
-       Unless required by applicable law or agreed to in writing, software distributed 
-       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
-       OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
-       the specific language governing permissions and limitations under the License. -->
-<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under 
-       the Apache License, Version 2.0 (the "License"); you may not use this file 
-       except in compliance with the License. You may obtain a copy of the License 
-       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
-       law or agreed to in writing, software distributed under the License is distributed 
-       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
-       express or implied. See the License for the specific language governing permissions 
-       and limitations under the License. -->
-
-<beans xmlns:osgi="http://www.springframework.org/schema/osgi"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd
-       http://www.springframework.org/schema/beans   
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
-       <osgi:service interface="org.argeo.slc.execution.ExecutionContext"
-               ref="executionContext" />
-       <osgi:service
-               interface="org.argeo.slc.execution.ExecutionFlowDescriptorConverter"
-               ref="executionFlowDescriptorConverter" />
-
-       <osgi:reference id="callbackHandler"
-               interface="javax.security.auth.callback.CallbackHandler" cardinality="0..1" />
-
-       <bean class="org.argeo.slc.osgi.MultipleServiceExporterPostProcessor">
-               <property name="interfaces">
-                       <list>
-                               <value><![CDATA[org.argeo.slc.execution.ExecutionFlow]]></value>
-                       </list>
-               </property>
-               <property name="bundleContext" ref="bundleContext" />
-       </bean>
-
-       <bean id="osgiExecutionResources" class="org.argeo.slc.osgi.OsgiExecutionResources">
-               <property name="executionContext" ref="executionContext" />
-       </bean>
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/AbstractSystemExecution.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/AbstractSystemExecution.java
deleted file mode 100644 (file)
index 2c12838..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.argeo.slc.spring;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.slc.SlcException;
-
-/** Provides base method for executing code with system authorization. */
-abstract class AbstractSystemExecution {
-       private final static Log log = LogFactory.getLog(AbstractSystemExecution.class);
-       private final Subject subject = new Subject();
-
-       /** Authenticate the calling thread */
-       protected void authenticateAsSystem() {
-               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
-               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-               try {
-                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
-                       lc.login();
-               } catch (LoginException e) {
-                       throw new SlcException("Cannot login as system", e);
-               } finally {
-                       Thread.currentThread().setContextClassLoader(origClassLoader);
-               }
-               if (log.isTraceEnabled())
-                       log.trace("System authenticated");
-       }
-
-       protected void deauthenticateAsSystem() {
-               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
-               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-               try {
-                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
-                       lc.logout();
-               } catch (LoginException e) {
-                       throw new SlcException("Cannot logout as system", e);
-               } finally {
-                       Thread.currentThread().setContextClassLoader(origClassLoader);
-               }
-       }
-
-       protected Subject getSubject() {
-               return subject;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/AuthenticatedApplicationContextInitialization.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/AuthenticatedApplicationContextInitialization.java
deleted file mode 100644 (file)
index 40d562b..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.argeo.slc.spring;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-
-import org.eclipse.gemini.blueprint.context.DependencyInitializationAwareBeanPostProcessor;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.support.AbstractBeanFactory;
-import org.springframework.beans.factory.support.SecurityContextProvider;
-import org.springframework.beans.factory.support.SimpleSecurityContextProvider;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Executes with a system authentication the instantiation and initialization
- * methods of the application context where it has been defined.
- */
-public class AuthenticatedApplicationContextInitialization extends
-               AbstractSystemExecution implements
-               DependencyInitializationAwareBeanPostProcessor, ApplicationContextAware {
-       /** If non empty, restricts to these beans */
-       private List<String> beanNames = new ArrayList<String>();
-
-       public Object postProcessBeforeInitialization(Object bean, String beanName)
-                       throws BeansException {
-               if (beanNames.size() == 0 || beanNames.contains(beanName))
-                       authenticateAsSystem();
-               return bean;
-       }
-
-       public Object postProcessAfterInitialization(Object bean, String beanName)
-                       throws BeansException {
-               if (beanNames.size() == 0 || beanNames.contains(beanName))
-                       deauthenticateAsSystem();
-               return bean;
-       }
-
-       public void setBeanNames(List<String> beanNames) {
-               this.beanNames = beanNames;
-       }
-
-       @Override
-       public void setApplicationContext(ApplicationContext applicationContext)
-                       throws BeansException {
-               if (applicationContext.getAutowireCapableBeanFactory() instanceof AbstractBeanFactory) {
-                       final AbstractBeanFactory beanFactory = ((AbstractBeanFactory) applicationContext
-                                       .getAutowireCapableBeanFactory());
-                       // retrieve subject's access control context
-                       // and set it as the bean factory security context
-                       Subject.doAs(getSubject(), new PrivilegedAction<Void>() {
-                               @Override
-                               public Void run() {
-                                       SecurityContextProvider scp = new SimpleSecurityContextProvider(
-                                                       AccessController.getContext());
-                                       beanFactory.setSecurityContextProvider(scp);
-                                       return null;
-                               }
-                       });
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AbstractSystemExecution.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AbstractSystemExecution.java
deleted file mode 100644 (file)
index eb1d731..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.argeo.slc.spring.auth;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.slc.SlcException;
-
-/** Provides base method for executing code with system authorization. */
-abstract class AbstractSystemExecution {
-       private final static Log log = LogFactory.getLog(AbstractSystemExecution.class);
-       private final Subject subject = new Subject();
-
-       /** Authenticate the calling thread */
-       protected void authenticateAsSystem() {
-               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
-               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-               try {
-                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
-                       lc.login();
-               } catch (LoginException e) {
-                       throw new SlcException("Cannot login as system", e);
-               } finally {
-                       Thread.currentThread().setContextClassLoader(origClassLoader);
-               }
-               if (log.isTraceEnabled())
-                       log.trace("System authenticated");
-       }
-
-       protected void deauthenticateAsSystem() {
-               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
-               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-               try {
-                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
-                       lc.logout();
-               } catch (LoginException e) {
-                       throw new SlcException("Cannot logout as system", e);
-               } finally {
-                       Thread.currentThread().setContextClassLoader(origClassLoader);
-               }
-       }
-
-       protected Subject getSubject() {
-               return subject;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AuthenticatedApplicationContextInitialization.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AuthenticatedApplicationContextInitialization.java
deleted file mode 100644 (file)
index 79f7822..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.argeo.slc.spring.auth;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-
-import org.eclipse.gemini.blueprint.context.DependencyInitializationAwareBeanPostProcessor;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.support.AbstractBeanFactory;
-import org.springframework.beans.factory.support.SecurityContextProvider;
-import org.springframework.beans.factory.support.SimpleSecurityContextProvider;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Executes with a system authentication the instantiation and initialization
- * methods of the application context where it has been defined.
- */
-public class AuthenticatedApplicationContextInitialization extends
-               AbstractSystemExecution implements
-               DependencyInitializationAwareBeanPostProcessor, ApplicationContextAware {
-       /** If non empty, restricts to these beans */
-       private List<String> beanNames = new ArrayList<String>();
-
-       public Object postProcessBeforeInitialization(Object bean, String beanName)
-                       throws BeansException {
-               if (beanNames.size() == 0 || beanNames.contains(beanName))
-                       authenticateAsSystem();
-               return bean;
-       }
-
-       public Object postProcessAfterInitialization(Object bean, String beanName)
-                       throws BeansException {
-               if (beanNames.size() == 0 || beanNames.contains(beanName))
-                       deauthenticateAsSystem();
-               return bean;
-       }
-
-       public void setBeanNames(List<String> beanNames) {
-               this.beanNames = beanNames;
-       }
-
-       @Override
-       public void setApplicationContext(ApplicationContext applicationContext)
-                       throws BeansException {
-               if (applicationContext.getAutowireCapableBeanFactory() instanceof AbstractBeanFactory) {
-                       final AbstractBeanFactory beanFactory = ((AbstractBeanFactory) applicationContext
-                                       .getAutowireCapableBeanFactory());
-                       // retrieve subject's access control context
-                       // and set it as the bean factory security context
-                       Subject.doAs(getSubject(), new PrivilegedAction<Void>() {
-                               @Override
-                               public Void run() {
-                                       SecurityContextProvider scp = new SimpleSecurityContextProvider(
-                                                       AccessController.getContext());
-                                       beanFactory.setSecurityContextProvider(scp);
-                                       return null;
-                               }
-                       });
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/SimpleRoleRegistration.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/SimpleRoleRegistration.java
deleted file mode 100644 (file)
index 44b7b79..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.argeo.slc.spring.auth;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-import javax.transaction.UserTransaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.UserAdmin;
-
-/**
- * Register one or many roles via a user admin service. Does nothing if the role
- * is already registered.
- */
-public class SimpleRoleRegistration implements Runnable {
-       private final static Log log = LogFactory
-                       .getLog(SimpleRoleRegistration.class);
-
-       private String role;
-       private List<String> roles = new ArrayList<String>();
-       private UserAdmin userAdmin;
-       private UserTransaction userTransaction;
-
-       @Override
-       public void run() {
-               try {
-                       userTransaction.begin();
-                       if (role != null && !roleExists(role))
-                               newRole(toDn(role));
-
-                       for (String r : roles)
-                               if (!roleExists(r))
-                                       newRole(toDn(r));
-                       userTransaction.commit();
-               } catch (Exception e) {
-                       try {
-                               userTransaction.rollback();
-                       } catch (Exception e1) {
-                               log.error("Cannot rollback", e1);
-                       }
-                       throw new SlcException("Cannot add roles", e);
-               }
-       }
-
-       private boolean roleExists(String role) {
-               return userAdmin.getRole(toDn(role).toString()) != null;
-       }
-
-       protected void newRole(LdapName r) {
-               userAdmin.createRole(r.toString(), Role.GROUP);
-               log.info("Added role " + r + " required by application.");
-       }
-
-       public void register(UserAdmin userAdminService, Map<?, ?> properties) {
-               this.userAdmin = userAdminService;
-               run();
-       }
-
-       protected LdapName toDn(String name) {
-               try {
-                       return new LdapName("cn=" + name + ",ou=roles,ou=node");
-               } catch (InvalidNameException e) {
-                       throw new SlcException("Badly formatted role name " + name, e);
-               }
-       }
-
-       public void setRole(String role) {
-               this.role = role;
-       }
-
-       public void setRoles(List<String> roles) {
-               this.roles = roles;
-       }
-
-       public void setUserAdmin(UserAdmin userAdminService) {
-               this.userAdmin = userAdminService;
-       }
-
-       public void setUserTransaction(UserTransaction userTransaction) {
-               this.userTransaction = userTransaction;
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/BndWrapper.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/BndWrapper.java
deleted file mode 100644 (file)
index 8b52c9a..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.argeo.slc.spring.repo.osgi;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.BeanNameAware;
-
-public class BndWrapper extends org.argeo.slc.repo.osgi.BndWrapper implements BeanNameAware {
-       private final static Log log = LogFactory.getLog(BndWrapper.class);
-
-       @Override
-       public void setBeanName(String name) {
-               if (getName() == null) {
-                       setName(name);
-               } else {
-                       if (!name.contains("#"))
-                               log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/MavenWrapper.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/MavenWrapper.java
deleted file mode 100644 (file)
index f351a5b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.argeo.slc.spring.repo.osgi;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.BeanNameAware;
-
-public class MavenWrapper extends org.argeo.slc.repo.osgi.MavenWrapper implements BeanNameAware {
-       private final static Log log = LogFactory.getLog(MavenWrapper.class);
-
-       @Override
-       public void setBeanName(String name) {
-               if (getName() == null) {
-                       setName(name);
-               } else {
-                       if (!name.contains("#"))
-                               log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/UriWrapper.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/UriWrapper.java
deleted file mode 100644 (file)
index 1b5edd1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.argeo.slc.spring.repo.osgi;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.BeanNameAware;
-
-public class UriWrapper extends org.argeo.slc.repo.osgi.UriWrapper implements BeanNameAware {
-       private final static Log log = LogFactory.getLog(UriWrapper.class);
-
-       @Override
-       public void setBeanName(String name) {
-               if (getName() == null) {
-                       setName(name);
-               } else {
-                       if (!name.contains("#"))
-                               log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractExecutionFlowTestcase.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractExecutionFlowTestcase.java
deleted file mode 100644 (file)
index f95296a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.spring.unit;
-
-import org.argeo.slc.execution.ExecutionFlow;
-
-public abstract class AbstractExecutionFlowTestcase extends AbstractSpringTestCase {
-       @SuppressWarnings(value = { "unchecked" })
-       protected <T extends ExecutionFlow> T executeFlow(String flowName) {
-               ExecutionFlow flow = getBean(flowName);
-               flow.run();
-               return (T) flow;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractOsgiRuntimeTestCase.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractOsgiRuntimeTestCase.java
deleted file mode 100644 (file)
index 734a5ec..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-package org.argeo.slc.spring.unit;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.osgi.boot.OsgiBoot;
-import org.argeo.slc.SlcException;
-import org.eclipse.core.runtime.adaptor.EclipseStarter;
-import org.eclipse.gemini.blueprint.util.OsgiStringUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.springframework.context.ApplicationContext;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("restriction")
-public abstract class AbstractOsgiRuntimeTestCase extends TestCase {
-       private final static Log log = LogFactory
-                       .getLog(AbstractOsgiRuntimeTestCase.class);
-
-       protected OsgiBoot osgiBoot = null;
-
-       protected void installBundles() throws Exception {
-
-       }
-
-       public void setUp() throws Exception {
-               // To avoid xerces from the classpath being detected as the provider
-               System
-                               .setProperty("javax.xml.parsers.DocumentBuilderFactory",
-                                               "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
-               System.setProperty("javax.xml.parsers.SAXParserFactory",
-                               "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
-
-               BundleContext bundleContext = startRuntime();
-               osgiBoot = new OsgiBoot(bundleContext);
-               log.info("OSGi runtime started.");
-
-               installBundles();
-
-               List<String> bundlesToStart = getBundlesToStart();
-               osgiBoot.startBundles(bundlesToStart);
-               waitAllBundlesOk(bundlesToStart);
-               if (log.isTraceEnabled())
-                       listInstalledBundles();
-       }
-
-       public void tearDown() throws Exception {
-               osgiBoot = null;
-               stopRuntime();
-               log.info("OSGi runtime stopped.");
-       }
-
-       protected BundleContext startRuntime() throws Exception {
-               String[] args = { "-console", "-clean" };
-               BundleContext bundleContext = EclipseStarter.startup(args, null);
-               return bundleContext;
-       }
-
-       protected void stopRuntime() throws Exception {
-               EclipseStarter.shutdown();
-       }
-
-       protected List<String> getBundlesToStart() {
-               return new ArrayList<String>();
-       }
-
-       protected void listInstalledBundles() {
-               BundleContext bundleContext = osgiBoot.getBundleContext();
-               Bundle[] bundles = bundleContext.getBundles();
-               for (int i = 0; i < bundles.length; i++) {
-                       System.out.println(OsgiStringUtils.nullSafeSymbolicName(bundles[i])
-                                       + " [" + OsgiStringUtils.bundleStateAsString(bundles[i])
-                                       + "] " + bundles[i].getLocation());
-               }
-
-       }
-
-       protected Map<Bundle, ApplicationContext> getOsgiApplicationContexts()
-                       throws Exception {
-               Map<Bundle, ApplicationContext> map = new HashMap<Bundle, ApplicationContext>();
-               BundleContext bundleContext = osgiBoot.getBundleContext();
-               ServiceReference[] srs = bundleContext.getServiceReferences(
-                               ApplicationContext.class.getName(), null);
-               for (ServiceReference sr : srs) {
-                       ApplicationContext context = (ApplicationContext) bundleContext
-                                       .getService(sr);
-                       map.put(sr.getBundle(), context);
-               }
-               return map;
-       }
-
-       /** Wait for all bundles to be either RESOLVED or ACTIVE. */
-       protected void waitAllBundlesOk(List<String> bundlesToStart) {
-               BundleContext bundleContext = osgiBoot.getBundleContext();
-               long begin = System.currentTimeMillis();
-               long duration = 0;
-               boolean allBundlesOk = true;
-               StringBuffer badBundles = null;
-               while (duration < getResolvedTimeout()) {
-                       badBundles = new StringBuffer();
-                       for (Bundle bundle : bundleContext.getBundles()) {
-                               if (bundle.getSymbolicName() != null
-                                               && bundle.getSymbolicName().startsWith(
-                                                               "org.eclipse.jdt")) {
-                                       // don't check Eclipse SDK bundles
-                                       continue;
-                               }
-
-                               if (bundle.getState() == Bundle.INSTALLED) {
-                                       allBundlesOk = false;
-                                       badBundles
-                                                       .append(OsgiStringUtils
-                                                                       .nullSafeSymbolicName(bundle)
-                                                                       + " ["
-                                                                       + OsgiStringUtils
-                                                                                       .bundleStateAsString(bundle) + "]");
-                               }
-
-                               if (bundlesToStart.contains(bundle.getSymbolicName())
-                                               && bundle.getState() != Bundle.ACTIVE) {
-                                       allBundlesOk = false;
-                                       badBundles.append(OsgiStringUtils
-                                                       .nullSafeSymbolicName(bundle)
-                                                       + " ["
-                                                       + OsgiStringUtils.bundleStateAsString(bundle)
-                                                       + "]\n");
-                               }
-                       }
-
-                       if (allBundlesOk)
-                               break;// while
-
-                       sleep(1000);
-
-                       duration = System.currentTimeMillis() - begin;
-               }
-
-               if (!allBundlesOk) {
-                       listInstalledBundles();
-                       throw new SlcException(
-                                       "Some bundles are not at the proper status:\n" + badBundles);
-               }
-       }
-
-       /**
-        * Make sure that the application context of the started bundles starting
-        * with this prefix are properly initialized
-        */
-       protected void assertStartedBundlesApplicationContext(
-                       String bundleSymbolicNamesPrefix) {
-               List<String> bundlesToStart = getBundlesToStart();
-               for (String bundleSName : bundlesToStart) {
-                       if (bundleSName.startsWith(bundleSymbolicNamesPrefix))
-                               assertBundleApplicationContext(bundleSName);
-               }
-       }
-
-       /**
-        * Make sure that the application context of this bundle is properly
-        * initialized
-        */
-       protected void assertBundleApplicationContext(String bundleSymbolicName) {
-               String filter = "(Bundle-SymbolicName=" + bundleSymbolicName + ")";
-               // Wait for application context to be ready
-               try {
-                       ServiceReference[] srs = getServiceRefSynchronous(
-                                       ApplicationContext.class.getName(), filter);
-                       if (srs == null)
-                               throw new SlcException("No application context for "
-                                               + bundleSymbolicName);
-               } catch (InvalidSyntaxException e) {
-                       throw new SlcException(
-                                       "Unexpected exception when looking for application context for bundle "
-                                                       + bundleSymbolicName, e);
-               }
-               log.info("Application context of bundle " + bundleSymbolicName
-                               + " is initalized.");
-       }
-
-       protected ServiceReference[] getServiceRefSynchronous(String clss,
-                       String filter) throws InvalidSyntaxException {
-               // FIXME: factorize
-               if (log.isTraceEnabled())
-                       log.debug("Filter: '" + filter + "'");
-               ServiceReference[] sfs = null;
-               boolean waiting = true;
-               long begin = System.currentTimeMillis();
-               do {
-                       sfs = getBundleContext().getServiceReferences(clss, filter);
-
-                       if (sfs != null)
-                               waiting = false;
-
-                       sleep(100);
-                       if (System.currentTimeMillis() - begin > getDefaultTimeout())
-                               throw new SlcException("Search of services " + clss
-                                               + " with filter " + filter + " timed out.");
-               } while (waiting);
-
-               return sfs;
-       }
-
-       protected BundleContext getBundleContext() {
-               return osgiBoot.getBundleContext();
-       }
-
-       /** Default is 30s */
-       protected long getResolvedTimeout() {
-               return 30 * 1000l;
-       }
-
-       /** Default is 10s */
-       protected long getDefaultTimeout() {
-               return 10 * 1000l;
-       }
-
-       final protected void sleep(long duration) {
-               try {
-                       Thread.sleep(1000);
-               } catch (InterruptedException e) {
-                       // silent
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractSpringTestCase.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractSpringTestCase.java
deleted file mode 100644 (file)
index ec532eb..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.argeo.slc.spring.unit;
-
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.BeanFactoryUtils;
-import org.springframework.beans.factory.ListableBeanFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import junit.framework.TestCase;
-
-/** Helper for tests using a Spring application co,text. */
-public abstract class AbstractSpringTestCase extends TestCase {
-       protected final Log log = LogFactory.getLog(getClass());
-       private ConfigurableApplicationContext context;
-
-       /**
-        * Gets (and create if necessary) the application context to use. Default
-        * implementation uses a class path xml application context and calls
-        * {@link #getApplicationContextLocation()}.
-        */
-       protected ConfigurableApplicationContext getContext() {
-               if (context == null) {
-                       context = new ClassPathXmlApplicationContext(
-                                       getApplicationContextLocation());
-                       if (getIsStartContext())
-                               context.start();
-               }
-               return context;
-       }
-
-       @Override
-       protected void tearDown() throws Exception {
-               if (context != null && context.isActive())
-                       context.close();
-               super.tearDown();
-       }
-
-       /** Whether the context should be started after being created. */
-       protected Boolean getIsStartContext() {
-               return false;
-       }
-
-       /** Returns a bean from the underlying context */
-       @SuppressWarnings(value = { "unchecked" })
-       protected <T> T getBean(String beanId) {
-               return (T) getContext().getBean(beanId);
-       }
-
-       protected <T> T getBean(Class<? extends T> clss) {
-               T bean = loadSingleFromContext(getContext(), clss);
-               if (bean == null) {
-                       throw new SlcException("Cannot retrieve a unique bean of type "
-                                       + clss);
-               } else {
-                       return bean;
-               }
-       }
-
-       /**
-        * Th location of the application to load. The default implementation
-        * returns <i>applicationContext.xml</i> found in the same package as the
-        * test.
-        */
-       protected String getApplicationContextLocation() {
-               return inPackage("applicationContext.xml");
-       }
-
-       /**
-        * Prefixes the package of the class after converting the '.' to '/' in
-        * order to have a resource path.
-        */
-       protected String inPackage(String suffix) {
-               String prefix = getClass().getPackage().getName().replace('.', '/');
-               return prefix + '/' + suffix;
-       }
-
-       @SuppressWarnings(value = { "unchecked" })
-       protected <T> T loadSingleFromContext(ListableBeanFactory context,
-                       Class<T> clss) {
-               Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
-                               context, clss, false, false);
-               if (beans.size() == 1) {
-                       return beans.values().iterator().next();
-               } else if (beans.size() > 1) {
-                       if (log.isDebugEnabled()) {
-                               log
-                                               .debug(("Found more that on bean for type " + clss
-                                                               + ": " + beans.keySet()));
-                       }
-                       return null;
-               } else {
-                       return null;
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/ExecutionFlowDescriptorTestUtils.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/ExecutionFlowDescriptorTestUtils.java
deleted file mode 100644 (file)
index 5e504f6..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.argeo.slc.spring.unit;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValue;
-import org.argeo.slc.execution.RefValueChoice;
-import org.argeo.slc.primitive.PrimitiveAccessor;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveValue;
-import org.argeo.slc.runtime.test.BasicTestData;
-
-public class ExecutionFlowDescriptorTestUtils {
-       public static ExecutionFlowDescriptor createSimpleExecutionFlowDescriptor() {
-               ExecutionFlowDescriptor flowDescriptor = new ExecutionFlowDescriptor();
-               flowDescriptor.setName("simpleFlow");
-               flowDescriptor.setDescription("my description");
-
-               Map<String, Object> values = new HashMap<String, Object>();
-               values.put("primitiveInteger", new PrimitiveValue(
-                               PrimitiveAccessor.TYPE_INTEGER, 100));
-
-               RefValue refValue = new RefValue("002");
-               values.put("ref1", refValue);
-               flowDescriptor.setValues(values);
-
-               flowDescriptor.setExecutionSpec(createRelatedSimpleSpec());
-               return flowDescriptor;
-       }
-
-       protected static DefaultExecutionSpec createRelatedSimpleSpec() {
-               DefaultExecutionSpec spec = new DefaultExecutionSpec();
-               spec.setBeanName("simpleSpec");
-               Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
-
-               PrimitiveSpecAttribute primitiveInteger = new PrimitiveSpecAttribute();
-               primitiveInteger.setType(PrimitiveAccessor.TYPE_INTEGER);
-               primitiveInteger.setValue(50);
-               attributes.put("primitiveInteger", primitiveInteger);
-
-               RefSpecAttribute ref1 = new RefSpecAttribute();
-               ref1.setTargetClass(BasicTestData.class);
-               ref1.setChoices(new ArrayList<RefValueChoice>());
-               ref1.getChoices().add(new RefValueChoice("001", "desc"));
-               ref1.getChoices().add(new RefValueChoice("002", null));
-               ref1.getChoices().add(new RefValueChoice("003", null));
-               attributes.put("ref1", ref1);
-
-               spec.setAttributes(attributes);
-
-               return spec;
-       }
-}
diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/UnitUtils.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/UnitUtils.java
deleted file mode 100644 (file)
index 1e69adf..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.argeo.slc.spring.unit;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-public abstract class UnitUtils {
-       public static void assertDateSec(Date expected, Date reached) {
-               if (expected == null) {
-                       assertNull(reached);
-                       return;
-               } else {
-                       assertNotNull(reached);
-               }
-
-               Calendar expectedCal = new GregorianCalendar();
-               expectedCal.setTime(expected);
-               Calendar reachedCal = new GregorianCalendar();
-               reachedCal.setTime(reached);
-               assertEquals(expectedCal.get(Calendar.YEAR), reachedCal
-                               .get(Calendar.YEAR));
-               assertEquals(expectedCal.get(Calendar.MONTH), reachedCal
-                               .get(Calendar.MONTH));
-               assertEquals(expectedCal.get(Calendar.DATE), reachedCal
-                               .get(Calendar.DATE));
-               assertEquals(expectedCal.get(Calendar.HOUR_OF_DAY), reachedCal
-                               .get(Calendar.HOUR_OF_DAY));
-               assertEquals(expectedCal.get(Calendar.MINUTE), reachedCal
-                               .get(Calendar.MINUTE));
-               assertEquals(expectedCal.get(Calendar.SECOND), reachedCal
-                               .get(Calendar.SECOND));
-       }
-
-       private UnitUtils() {
-
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/.classpath b/cms/org.argeo.slc.support/.classpath
deleted file mode 100644 (file)
index 70b08e8..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" output="target/classes" path="src"/>
-       <classpathentry kind="src" path="ext/test"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/cms/org.argeo.slc.support/.gitignore b/cms/org.argeo.slc.support/.gitignore
deleted file mode 100644 (file)
index 09e3bc9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/bin/
-/target/
diff --git a/cms/org.argeo.slc.support/.project b/cms/org.argeo.slc.support/.project
deleted file mode 100644 (file)
index 174f70d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.support</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.jdt.core.javanature</nature>
-               <nature>org.eclipse.pde.PluginNature</nature>
-       </natures>
-</projectDescription>
diff --git a/cms/org.argeo.slc.support/META-INF/.gitignore b/cms/org.argeo.slc.support/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/cms/org.argeo.slc.support/bnd.bnd b/cms/org.argeo.slc.support/bnd.bnd
deleted file mode 100644 (file)
index fc72621..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-Import-Package: org.apache.commons.logging,\
-org.dbunit.*;resolution:="optional",\
-junit.framework;resolution:="optional",\
-javax.mail.*;resolution:="optional",\
-org.apache.commons.vfs.*,\
-javax.swing.plaf.metal,\
-org.osgi.*;version=0.0.0,\
-*
\ No newline at end of file
diff --git a/cms/org.argeo.slc.support/ext/test/log4j.properties b/cms/org.argeo.slc.support/ext/test/log4j.properties
deleted file mode 100644 (file)
index 0133bab..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# Set root logger level to DEBUG and its only appender to A1.\r
-log4j.rootLogger=WARN, console\r
-\r
-## Levels\r
-# Slc\r
-log4j.logger.org.argeo=DEBUG\r
-\r
-# Castor\r
-log4j.logger.org.exolab.castor=WARN\r
-\r
-# Spring\r
-log4j.logger.org.springframework=WARN\r
-\r
-\r
-## Appenders\r
-# A1 is set to be a ConsoleAppender.\r
-log4j.appender.console=org.apache.log4j.ConsoleAppender\r
-\r
-# A1 uses PatternLayout.\r
-log4j.appender.console.layout=org.apache.log4j.PatternLayout\r
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n\r
-\r
diff --git a/cms/org.argeo.slc.support/ext/test/org/argeo/slc/diff/LineTokenizerTest.java b/cms/org.argeo.slc.support/ext/test/org/argeo/slc/diff/LineTokenizerTest.java
deleted file mode 100644 (file)
index 58ed61a..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.argeo.slc.diff;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class LineTokenizerTest extends TestCase {
-       public void testSimple() throws Exception {
-               testAndAssert("a,b,c", new String[] { "a", "b", "c" });
-               testAndAssert("hello,bonjour,hallo,priviet", new String[] { "hello",
-                               "bonjour", "hallo", "priviet" });
-       }
-
-       public void testTricky() throws Exception {
-               testAndAssert("alone", new String[] { "alone" });
-               testAndAssert("", new String[] { "" });
-
-               testAndAssert(",hello,bonjour,hallo,priviet", new String[] { "",
-                               "hello", "bonjour", "hallo", "priviet" });
-               testAndAssert("hello,bonjour,,hallo,priviet", new String[] { "hello",
-                               "bonjour", "", "hallo", "priviet" });
-               testAndAssert("hello,bonjour,hallo,priviet,", new String[] { "hello",
-                               "bonjour", "hallo", "priviet", "" });
-               testAndAssert(",hello,,bonjour,hallo,,,,priviet,", new String[] { "",
-                               "hello", "", "bonjour", "hallo", "", "", "", "priviet", "" });
-
-               testAndAssert(",,,", new String[] { "", "", "", "" });
-       }
-
-       public void testComplex() throws Exception {
-               testAndAssert("a#b#c", '#', "", new String[] { "a", "b", "c" });
-               testAndAssert("hello!bonjour!hallo!priviet", '!', "", new String[] {
-                               "hello", "bonjour", "hallo", "priviet" });
-
-               testAndAssert("hello,,bonjour,,hallo,priviet", ',', "<EMPTY>",
-                               new String[] { "hello", "<EMPTY>", "bonjour", "<EMPTY>",
-                                               "hallo", "priviet" });
-       }
-
-       private void testAndAssert(String str, String[] expected) {
-               testAndAssert(str, ',', "", expected);
-       }
-
-       private void testAndAssert(String str, Character sep, String noValueStr,
-                       String[] expected) {
-               List<String> res = LineTokenizer.tokenize(str, sep, noValueStr);
-               assertEquals("Size", expected.length, res.size());
-               for (int i = 0; i < res.size(); i++) {
-                       String token = res.get(i);
-                       assertEquals("Value@" + i, expected[i], token);
-               }
-       }
-}
diff --git a/cms/org.argeo.slc.support/pom.xml b/cms/org.argeo.slc.support/pom.xml
deleted file mode 100644 (file)
index f0b19fb..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc-cms</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.support</artifactId>
-       <name>SLC Third Party Support</name>
-       <dependencies>
-               <!-- SLC Runtime -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.runtime</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.spring</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DataInterpreter.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DataInterpreter.java
deleted file mode 100644 (file)
index 0f2705d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.argeo.slc.diff;
-
-/**
- * Converts data into a format better adapted for comparison. It is typically
- * used to convert <code>String</code> into typed format such as
- * <code>BigDecimal</code>
- */
-public interface DataInterpreter {
-       /**
-        * Converts data
-        * 
-        * @param key
-        *            any object used to differentiate the type of data (e.g.
-        *            column, path)
-        * @param value
-        *            the data to convert
-        * @return the converted object
-        */
-       public Object convert(Object key, Object value);
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/Diff.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/Diff.java
deleted file mode 100644 (file)
index 6bb5f6d..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.argeo.slc.diff;
-
-import org.springframework.core.io.Resource;
-
-/** A comparator providing structured information about the differences found. */
-public interface Diff {
-       /** Performs the comparison. */
-       public void compare(Resource expected, Resource reached,
-                       DiffResult diffResult);
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssue.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssue.java
deleted file mode 100644 (file)
index b390d68..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.argeo.slc.diff;
-
-/** The root class for issues which happened during a diff. */
-public abstract class DiffIssue implements Comparable<DiffIssue> {
-       /** The position of this issue. */
-       // Was final and is not anymore in order to persist in hibernate
-       protected DiffPosition position;
-
-       // hibernate
-       private long id;
-
-       /** Constructor */
-       public DiffIssue(DiffPosition position) {
-               super();
-               this.position = position;
-       }
-
-       public int compareTo(DiffIssue o) {
-               return position.compareTo(o.position);
-       }
-
-       /** The position of this issue within the test file */
-       public DiffPosition getPosition() {
-               return position;
-       }
-
-       // Hibernate
-       @SuppressWarnings("unused")
-       private void setId(long id) {
-               this.id = id;
-       }
-
-       @SuppressWarnings("unused")
-       private long getId() {
-               return id;
-       }
-
-       @SuppressWarnings("unused")
-       private void setPosition(DiffPosition position) {
-               this.position = position;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssueKey.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssueKey.java
deleted file mode 100644 (file)
index c9dde85..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.argeo.slc.diff;
-
-/** Intermediate class that can hold the key to be displayed. */
-public abstract class DiffIssueKey extends DiffIssue {
-       /** The position of this issue. */
-       protected DiffKey key;
-
-       /** Constructor without key */
-       public DiffIssueKey(DiffPosition position) {
-               super(position);
-       }
-
-       /** Constructor with key */
-       public DiffIssueKey(DiffPosition position, DiffKey key) {
-               super(position);
-               this.key = key;
-       }
-
-       public Object getKey() {
-               return key;
-       }
-
-       @Override
-       public String toString() {
-               if (key != null) {
-                       return key.toString();
-               } else {
-                       return "";
-               }
-       }
-
-       // Hibernate
-       @SuppressWarnings("unused")
-       private void setKey(DiffKey key) {
-               this.key = key;
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffKey.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffKey.java
deleted file mode 100644 (file)
index 89a3496..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.argeo.slc.diff;
-
-/**
- * Object able to uniquely identify an atomic diff part. Used to identify
- * missings and left-overs.
- */
-public interface DiffKey {
-       public String toString();
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissing.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissing.java
deleted file mode 100644 (file)
index adea313..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.argeo.slc.diff;
-
-/**
- * A value missing in one of the file. If its position is related to expected,
- * this means it is a left over in the reached, if its position is related to
- * the reached it means that it is missing from the reached. If the value is
- * null it means that the entire line is missing.
- */
-public class DiffMissing extends DiffIssueKey {
-
-       public DiffMissing(DiffPosition position, DiffKey key) {
-               super(position);
-               super.key = key;
-       }
-
-       @Override
-       public String toString() {
-               if (position.relatedFile == RelatedFile.EXPECTED) {
-                       return position + ": left over " + super.toString();
-               } else if (position.relatedFile == RelatedFile.REACHED) {
-                       return position + ": missing " + super.toString();
-               }
-               return super.toString();
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissingXml.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissingXml.java
deleted file mode 100644 (file)
index c182237..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.argeo.slc.diff;
-
-/**
- * <code>DiffMissing</code> using the XPath of the position as
- * <code>DiffKey</code>
- */
-public class DiffMissingXml extends DiffMissing {
-
-       public DiffMissingXml(XPathDiffPosition position) {
-               super(position, new DiffKeyXml(position.getXPath()));
-       }
-
-       /** Implementation of <code>DiffKey</code> based on an XPath string. */
-       protected static class DiffKeyXml implements DiffKey {
-               private final String xPath;
-
-               public DiffKeyXml(String xPath) {
-                       this.xPath = xPath;
-               }
-
-               public String getXPath() {
-                       return xPath;
-               }
-
-               @Override
-               public String toString() {
-                       return xPath;
-               }
-
-               @Override
-               public boolean equals(Object obj) {
-                       if (!(obj instanceof DiffKeyXml))
-                               return false;
-                       return xPath.equals(((DiffKeyXml) obj).xPath);
-               }
-
-               @Override
-               public int hashCode() {
-                       return xPath.hashCode();
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffNotMatched.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffNotMatched.java
deleted file mode 100644 (file)
index eba911f..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.argeo.slc.diff;
-
-import org.argeo.slc.SlcException;
-
-/** Diff issue where reached and expected values are different. */
-public class DiffNotMatched extends DiffIssueKey {
-
-       // To enable hibernate persistance, these object cannot be final
-       // private final Object expected;
-       // private final Object reached;
-
-       private Object expected;
-       private Object reached;
-
-       public DiffNotMatched(DiffPosition position, Object expected, Object reached) {
-               super(position);
-               this.expected = expected;
-               this.reached = reached;
-       }
-
-       public DiffNotMatched(DiffPosition position, Object expected,
-                       Object reached, DiffKey key) {
-               super(position, key);
-               this.expected = expected;
-               this.reached = reached;
-       }
-
-       public Object getExpected() {
-               return expected;
-       }
-
-       public Object getReached() {
-               return reached;
-       }
-
-       @Override
-       public String toString() {
-               String result = position + ": not matched " + expected + " <> "
-                               + reached;
-               if (super.key != null) {
-                       result = result + " - Key: " + super.toString();
-               }
-
-               return result;
-       }
-
-       @SuppressWarnings("unused")
-       private String getExpectedStr() {
-               if (expected instanceof String)
-                       return (String) expected;
-               else
-                       throw new SlcException(
-                                       "Object 'expected' is of wrong type. Must be a String");
-       }
-
-       @SuppressWarnings("unused")
-       private String getReachedStr() {
-               if (reached instanceof String)
-                       return (String) reached;
-               else
-                       throw new SlcException(
-                                       "Object 'reached' is of wrong type. Must be a String");
-       }
-
-       @SuppressWarnings("unused")
-       private void setReachedStr(String reachedStr) {
-               this.reached = reachedStr;
-       }
-
-       @SuppressWarnings("unused")
-       private void setExpectedStr(String expectedStr) {
-               this.expected = expectedStr;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffPosition.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffPosition.java
deleted file mode 100644 (file)
index 9f38d88..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.argeo.slc.diff;
-
-/** The position of a diff issue within the test resource. */
-public abstract class DiffPosition implements Comparable<DiffPosition> {
-       protected RelatedFile relatedFile;
-
-       public DiffPosition(RelatedFile relatedFile) {
-               super();
-               this.relatedFile = relatedFile;
-       }
-
-       // For Hibernate
-       DiffPosition() {
-       }
-
-       public RelatedFile getRelatedFile() {
-               return relatedFile;
-       }
-
-       // Added to enable the new data model for persisting TabularDiffTestResult
-       @SuppressWarnings("unused")
-       private Boolean getIsReached() {
-               return relatedFile.equals(RelatedFile.REACHED);
-       }
-
-       @SuppressWarnings("unused")
-       private void setIsReached(Boolean isReached) {
-               this.relatedFile = (isReached ? RelatedFile.REACHED
-                               : RelatedFile.EXPECTED);
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffResult.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/DiffResult.java
deleted file mode 100644 (file)
index 8c0f9e2..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.argeo.slc.diff;
-
-/**
- * The result of a diff, to be subclassed in order to provide richer information
- */
-public interface DiffResult {
-       /** Adds a diff issue */
-       public void addDiffIssue(DiffIssue diffIssue);
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/KeyColumnsDiff.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/KeyColumnsDiff.java
deleted file mode 100644 (file)
index 7647321..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.diff;
-
-import java.util.List;
-
-/**
- * Diff which is based on comparison of multiple-key atomic elements (typically
- * columns in a tabular content)
- */
-public interface KeyColumnsDiff extends Diff {
-       /** $The list of key columns. */
-       List<String> getKeyColumns();
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/LineTokenizer.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/LineTokenizer.java
deleted file mode 100644 (file)
index fed4c37..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.argeo.slc.diff;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Parses a string as a vector of strings according to a separator, dealing
- * properly with missing values. This is intended to be used instead of the
- * standard StringTokenizer, which does not deal well with empty values.
- * Contrary to the StringTokenizer the provided String is parsed in the
- * constructor and the values stored as a property. This should therefore not be
- * used to parse long strings. No reference to the argument passed in
- * constructor is kept.
- */
-public class LineTokenizer {
-       private final List<String> tokens;
-
-       /** Complete constructor. */
-       public LineTokenizer(String stringToParse, Character separator,
-                       String noValueString) {
-               this.tokens = parse(stringToParse, separator, noValueString);
-       }
-
-       /**
-        * Parse the string as a vector of strings. Can be overridden in order to
-        * provide another implementation.
-        */
-       protected List<String> parse(final String stringToParse,
-                       final char separator, final String noValueString) {
-               // Init
-               final int NULL = -1;
-               List<String> res = new ArrayList<String>();
-               final char[] array = stringToParse.toCharArray();
-               int lastSeparatorIndex = NULL;
-
-               // Loop on chars
-               for (int currIndex = 0; currIndex < array.length; currIndex++) {
-                       char c = array[currIndex];
-                       if (c == separator) {
-                               if (currIndex == 0) {
-                                       // first char is a separator
-                                       res.add(new String(noValueString));
-                                       lastSeparatorIndex = 0;
-                               } else if (lastSeparatorIndex == NULL) {
-                                       // first separator found
-                                       res.add(new String(array, 0, currIndex));
-                                       lastSeparatorIndex = currIndex;
-                               } else if (lastSeparatorIndex != NULL
-                                               && (lastSeparatorIndex == (currIndex - 1))) {
-                                       // consecutive separators
-                                       res.add(new String(noValueString));
-                                       lastSeparatorIndex = currIndex;
-                               } else {
-                                       // simple case
-                                       res.add(new String(array, lastSeparatorIndex + 1, currIndex
-                                                       - lastSeparatorIndex - 1));
-                                       lastSeparatorIndex = currIndex;
-                               }
-                       }
-               }
-
-               // Finalize
-               if (lastSeparatorIndex == NULL) {
-                       // no separator found
-                       res.add(new String(stringToParse));
-               } else if (lastSeparatorIndex == (array.length - 1)) {
-                       // last char is a separator
-                       res.add(new String(noValueString));
-               } else {
-                       // last token
-                       res.add(new String(array, lastSeparatorIndex + 1, array.length
-                                       - lastSeparatorIndex - 1));
-               }
-               return res;
-       }
-
-       /** The tokens. */
-       public List<String> getTokens() {
-               return tokens;
-       }
-
-       /** Parse */
-       public static List<String> tokenize(String stringToParse,
-                       Character separator, String noValueString) {
-               LineTokenizer lt = new LineTokenizer(stringToParse, separator,
-                               noValueString);
-               return lt.getTokens();
-       }
-
-       /** Parse, using the empty string as no value string. */
-       public static List<String> tokenize(String stringToParse,
-                       Character separator) {
-               return tokenize(stringToParse, separator, "");
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/RelatedFile.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/RelatedFile.java
deleted file mode 100644 (file)
index 09b1033..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.argeo.slc.diff;
-
-/** Enumeration of the types of resource tested. */
-public enum RelatedFile {
-       /** The expected resource */
-       EXPECTED,
-       /** The reached resource */
-       REACHED
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/TableDiffPosition.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/TableDiffPosition.java
deleted file mode 100644 (file)
index a683843..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.argeo.slc.diff;
-
-import org.argeo.slc.UnsupportedException;
-
-/**
- * A diff position within a table structure such a CSV file or an SQL result
- * set.
- */
-public class TableDiffPosition extends DiffPosition {
-       private Integer line;
-       /** Can be null */
-       private Integer column;
-       /** Can be null */
-       private String columnName;
-
-       public TableDiffPosition(RelatedFile relatedFile, Integer line,
-                       Integer column, String columnName) {
-               super(relatedFile);
-               this.line = line;
-               this.column = column;
-               this.columnName = columnName;
-       }
-
-       @SuppressWarnings("unused")
-       private TableDiffPosition() {
-       }
-
-       public Integer getLine() {
-               return line;
-       }
-
-       public Integer getColumn() {
-               return column;
-       }
-
-       public String getColumnName() {
-               return columnName;
-       }
-
-       public int compareTo(DiffPosition dp) {
-               if (!(dp instanceof TableDiffPosition))
-                       throw new UnsupportedException("position", dp);
-
-               TableDiffPosition o = (TableDiffPosition) dp;
-               if (relatedFile.equals(o.relatedFile)) {
-                       if (line == o.line) {
-                               return column.compareTo(o.column);
-                       } else {
-                               return line.compareTo(o.line);
-                       }
-               } else {
-                       return relatedFile.compareTo(o.relatedFile);
-               }
-       }
-
-       @Override
-       public String toString() {
-               StringBuffer buf = new StringBuffer("");
-               buf.append(relatedFile).append('[').append(line);
-               if (column != null) {
-                       buf.append(',').append(column);
-                       if (columnName != null) {
-                               buf.append('-').append(columnName);
-                       }
-               }
-               buf.append(']');
-               return buf.toString();
-       }
-
-       // Hibernate
-       @SuppressWarnings("unused")
-       private void setLine(Integer line) {
-               this.line = line;
-       }
-
-       @SuppressWarnings("unused")
-       private void setColumn(Integer column) {
-               this.column = column;
-       }
-
-       @SuppressWarnings("unused")
-       private void setColumnName(String columnName) {
-               this.columnName = columnName;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/Tolerance.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/Tolerance.java
deleted file mode 100644 (file)
index 6bddd1d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.argeo.slc.diff;
-
-/** Compares objects, eventually using tolerance mechanisms. */
-public interface Tolerance {
-       /**
-        * Compares objects
-        * 
-        * @param key
-        *            any object used to differentiate the type of data (e.g.
-        *            column, path)
-        * @param expected
-        *            the expected value
-        * @param reached
-        *            the reached value
-        * @return the converted object
-        */
-       public Boolean compare(Object key, Object expected, Object reached);
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/ToleranceDiff.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/ToleranceDiff.java
deleted file mode 100644 (file)
index 8260889..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.argeo.slc.diff;
-
-import java.util.Map;
-
-/** A diff which can manage tolerances. */
-public interface ToleranceDiff extends Diff {
-
-       /** Get tolerances, key is the column name. */
-       public Map<String, String> getTolerances();
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/XPathDiffPosition.java b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/XPathDiffPosition.java
deleted file mode 100644 (file)
index b119421..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.argeo.slc.diff;
-
-import org.argeo.slc.UnsupportedException;
-
-/** A diff position within an Xml file. <b>NOT YET IMPLEMENTED</b>. */
-public class XPathDiffPosition extends DiffPosition {
-
-       private String xPath;
-
-       public XPathDiffPosition(RelatedFile relatedFile, String path) {
-               super(relatedFile);
-               xPath = path;
-       }
-
-       public int compareTo(DiffPosition dp) {
-               if (!(dp instanceof XPathDiffPosition))
-                       throw new UnsupportedException("position", dp);
-
-               XPathDiffPosition o = (XPathDiffPosition) dp;
-               if (relatedFile.equals(o.relatedFile)) {
-                       return xPath.compareTo(o.xPath);
-               } else {
-                       return relatedFile.compareTo(o.relatedFile);
-               }
-       }
-
-       public String getXPath() {
-               return xPath;
-       }
-
-       @Override
-       public String toString() {
-               return xPath;
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/diff/package.html b/cms/org.argeo.slc.support/src/org/argeo/slc/diff/package.html
deleted file mode 100644 (file)
index a58e685..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>\r
-<head></head>\r
-<body>\r
-Abstraction of diff comparison with structured results.\r
-</body>\r
-</html>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/AbstractJschTask.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/AbstractJschTask.java
deleted file mode 100644 (file)
index 59c0acf..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.PrivilegedAction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Logger;
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.UserAuthGSSAPIWithMIC;
-
-public abstract class AbstractJschTask implements Runnable {
-       private final Log log = LogFactory.getLog(getClass());
-
-       private SshTarget sshTarget;
-
-       protected Session openSession() {
-               if (sshTarget.getSession() != null) {
-                       Session session = sshTarget.getSession();
-                       if (session.isConnected()) {
-                               if (log.isTraceEnabled())
-                                       log.debug("Using cached session to " + getSshTarget() + " via SSH");
-                               return session;
-                       }
-               }
-
-               try {
-                       JSch jsch = new JSch();
-                       if (sshTarget.getUsePrivateKey() && sshTarget.getLocalPrivateKey().exists())
-                               jsch.addIdentity(sshTarget.getLocalPrivateKey().getAbsolutePath());
-                       Session session = jsch.getSession(getSshTarget().getUser(), getSshTarget().getHost(),
-                                       getSshTarget().getPort());
-
-                       session.setUserInfo(getSshTarget().getUserInfo());
-                       session.setConfig("userauth.gssapi-with-mic", UserAuthGSSAPIWithMIC.class.getName());
-                       session.setServerAliveInterval(1000);
-                       session.connect();
-                       if (log.isTraceEnabled())
-                               log.trace("Connected to " + getSshTarget() + " via SSH");
-                       if (sshTarget.getSession() != null) {
-                               if (log.isTraceEnabled())
-                                       log.trace("The cached session to " + getSshTarget() + " was disconnected and was reset.");
-                               sshTarget.setSession(session);
-                       }
-                       return session;
-               } catch (JSchException e) {
-                       if (sshTarget.getUserInfo() instanceof SimpleUserInfo)
-                               ((SimpleUserInfo) sshTarget.getUserInfo()).reset();
-                       throw new SlcException("Could not open session to " + getSshTarget(), e);
-               }
-       }
-
-       public void run() {
-               Session session = openSession();
-               try {
-                       run(session);
-               } finally {
-                       if (sshTarget != null && sshTarget.getSession() == null) {
-                               session.disconnect();
-                               if (log.isTraceEnabled())
-                                       log.trace("Disconnected from " + getSshTarget() + " via SSH");
-                       }
-               }
-       }
-
-       abstract void run(Session session);
-
-       protected int checkAck(InputStream in) throws IOException {
-               int b = in.read();
-               // b may be 0 for success,
-               // 1 for error,
-               // 2 for fatal error,
-               // -1
-               if (b == 0)
-                       return b;
-               else if (b == -1)
-                       return b;// throw new SlcException("SSH ack returned -1");
-               else if (b == 1 || b == 2) {
-                       StringBuffer sb = new StringBuffer();
-                       int c;
-                       do {
-                               c = in.read();
-                               sb.append((char) c);
-                       } while (c != '\n');
-                       if (b == 1) { // error
-                               throw new SlcException("SSH ack error: " + sb.toString());
-                       }
-                       if (b == 2) { // fatal error
-                               throw new SlcException("SSH fatal error: " + sb.toString());
-                       }
-               }
-               return b;
-       }
-
-       public SshTarget getSshTarget() {
-               if (sshTarget == null)
-                       throw new SlcException("No SSH target defined.");
-               return sshTarget;
-       }
-
-       public void setSshTarget(SshTarget sshTarget) {
-               this.sshTarget = sshTarget;
-       }
-
-       PrivilegedAction<Void> asPrivilegedAction() {
-               return new PrivilegedAction<Void>() {
-                       public Void run() {
-                               AbstractJschTask.this.run();
-                               return null;
-                       }
-               };
-       }
-
-       static {
-               JSch.setLogger(new JschLogger());
-       }
-
-       private static class JschLogger implements Logger {
-               private final Log log = LogFactory.getLog(JschLogger.class);
-
-               // TODO better support levels
-               @Override
-               public boolean isEnabled(int level) {
-                       if (log.isTraceEnabled())
-                               return true;
-                       return false;
-               }
-
-               @Override
-               public void log(int level, String message) {
-                       log.trace(message);
-               }
-
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/CallbackHandlerUserInfo.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/CallbackHandlerUserInfo.java
deleted file mode 100644 (file)
index c069a81..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.argeo.slc.jsch;
-
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.PasswordCallback;
-
-import org.argeo.slc.SlcException;
-
-/** Retrieve a password or a passphrase using a standard callback handler. */
-public final class CallbackHandlerUserInfo extends SimpleUserInfo {
-       private CallbackHandler callbackHandler;
-
-       private Boolean alwaysPrompt = false;
-
-       public boolean promptPassphrase(String message) {
-               if (passphrase != null)
-                       return true;
-
-               if (!alwaysPrompt && passphraseSafe != null)
-                       return true;
-
-               reset();
-               PasswordCallback passwordCb = new PasswordCallback("SSH Passphrase",
-                               false);
-               Callback[] dialogCbs = new Callback[] { passwordCb };
-               try {
-                       callbackHandler.handle(dialogCbs);
-                       passphraseSafe = passwordCb.getPassword();
-                       return passphraseSafe != null;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot ask for a password", e);
-               }
-       }
-
-       public boolean promptPassword(String message) {
-               if (password != null)
-                       return true;
-
-               if (!alwaysPrompt && passwordSafe != null)
-                       return true;
-
-               reset();
-               PasswordCallback passwordCb = new PasswordCallback("SSH Password",
-                               false);
-               Callback[] dialogCbs = new Callback[] { passwordCb };
-               try {
-                       callbackHandler.handle(dialogCbs);
-                       passwordSafe = passwordCb.getPassword();
-                       return passwordSafe != null;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot ask for a password", e);
-               }
-       }
-
-       public void setAlwaysPrompt(Boolean alwaysPrompt) {
-               this.alwaysPrompt = alwaysPrompt;
-       }
-
-       public void setCallbackHandler(CallbackHandler defaultCallbackHandler) {
-               this.callbackHandler = defaultCallbackHandler;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/GetMachineId.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/GetMachineId.java
deleted file mode 100644 (file)
index fc7e88b..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-
-class GetMachineId {
-
-       public static void main(String[] args) {
-               URL url = GetMachineId.class.getResource("jaas.cfg");
-               System.setProperty("java.security.auth.login.config", url.toExternalForm());
-
-               String hostname = args[0];
-               try {
-                       LoginContext lc = new LoginContext("SINGLE_USER");
-                       lc.login();
-
-                       SshTarget sshTarget = new SshTarget();
-                       sshTarget.setHost(hostname);
-                       RemoteExec remoteExec = new RemoteExec();
-                       remoteExec.setCommand("cat /etc/machine-id");
-                       remoteExec.setSshTarget(sshTarget);
-                       List<String> lines = new ArrayList<>();
-                       remoteExec.setStdOutLines(lines);
-
-                       Subject.doAs(lc.getSubject(), remoteExec.asPrivilegedAction());
-
-                       String machineId = lines.get(0);
-                       System.out.println(hostname + ": " + machineId);
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschContextSession.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschContextSession.java
deleted file mode 100644 (file)
index 8855beb..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.argeo.slc.jsch;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-
-import com.jcraft.jsch.Session;
-
-/** Caches a JSCH session in the the ssh target. */
-public class JschContextSession extends AbstractJschTask implements
-               InitializingBean, DisposableBean {
-       private final static Log log = LogFactory.getLog(JschContextSession.class);
-       private Boolean autoconnect = false;
-
-       @Override
-       void run(Session session) {
-               // clear();
-               getSshTarget().setSession(session);
-               if (log.isDebugEnabled())
-                       log.debug("Cached SSH context session to " + getSshTarget());
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               // if (log.isDebugEnabled())
-               // log.debug(getClass() + ".afterPropertiesSet(), " + beanName + ", "
-               // + this);
-               if (autoconnect)
-                       try {
-                               run();
-                       } catch (Exception e) {
-                               log.error("Could not automatically open session", e);
-                       }
-       }
-
-       public void destroy() throws Exception {
-               clear();
-       }
-
-       public void clear() {
-               SshTarget sshTarget = getSshTarget();
-               synchronized (sshTarget) {
-                       if (sshTarget.getSession() != null) {
-                               sshTarget.getSession().disconnect();
-                               sshTarget.setSession(null);
-                               if (log.isDebugEnabled())
-                                       log.debug("Cleared cached SSH context session to "
-                                                       + getSshTarget());
-                       }
-               }
-       }
-
-       public void setAutoconnect(Boolean autoconnect) {
-               this.autoconnect = autoconnect;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschExecutor.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschExecutor.java
deleted file mode 100644 (file)
index b9d5f55..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.ExecuteException;
-import org.apache.commons.exec.ExecuteResultHandler;
-import org.apache.commons.exec.ExecuteStreamHandler;
-import org.apache.commons.exec.ExecuteWatchdog;
-import org.apache.commons.exec.Executor;
-import org.apache.commons.exec.ProcessDestroyer;
-
-/** A Commons Exec executor executing remotely via SSH */
-public class JschExecutor implements Executor {
-       private File workingDirectory;
-       private ExecuteStreamHandler streamHandler;
-
-       private SshTarget sshTarget;
-
-       public void setExitValue(int value) {
-               // TODO Auto-generated method stub
-
-       }
-
-       public void setExitValues(int[] values) {
-               // TODO Auto-generated method stub
-
-       }
-
-       public boolean isFailure(int exitValue) {
-               return Executor.INVALID_EXITVALUE == exitValue;
-       }
-
-       public ExecuteStreamHandler getStreamHandler() {
-               return streamHandler;
-       }
-
-       public void setStreamHandler(ExecuteStreamHandler streamHandler) {
-               this.streamHandler = streamHandler;
-       }
-
-       public ExecuteWatchdog getWatchdog() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public void setWatchdog(ExecuteWatchdog watchDog) {
-               // TODO Auto-generated method stub
-
-       }
-
-       public ProcessDestroyer getProcessDestroyer() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public void setProcessDestroyer(ProcessDestroyer processDestroyer) {
-               // TODO Auto-generated method stub
-
-       }
-
-       public File getWorkingDirectory() {
-               return workingDirectory;
-       }
-
-       public void setWorkingDirectory(File workingDirectory) {
-               this.workingDirectory = workingDirectory;
-       }
-
-       public int execute(CommandLine command) throws ExecuteException,
-                       IOException {
-               return execute(command, (Map) null);
-       }
-
-       public int execute(CommandLine command, Map environment)
-                       throws ExecuteException, IOException {
-               String cmd = command.toString();
-               if(workingDirectory!=null)
-                       cmd = "cd "+workingDirectory.getPath()+" && "+cmd;
-               RemoteExec remoteExec = new RemoteExec();
-               remoteExec.setSshTarget(sshTarget);
-               remoteExec.setStreamHandler(streamHandler);
-               remoteExec.setCommand(cmd);
-               if (environment != null)
-                       remoteExec.setEnv(environment);
-               remoteExec.run();
-               return remoteExec.getLastExitStatus() != null ? remoteExec
-                               .getLastExitStatus() : Executor.INVALID_EXITVALUE;
-       }
-
-       public void execute(CommandLine command, ExecuteResultHandler handler)
-                       throws ExecuteException, IOException {
-               // TODO Auto-generated method stub
-
-       }
-
-       public void execute(CommandLine command, Map environment,
-                       ExecuteResultHandler handler) throws ExecuteException, IOException {
-
-       }
-
-       public SshTarget getSshTarget() {
-               return sshTarget;
-       }
-
-       public void setSshTarget(SshTarget sshTarget) {
-               this.sshTarget = sshTarget;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschMultiTasks.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/JschMultiTasks.java
deleted file mode 100644 (file)
index 3dcba87..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.jcraft.jsch.Session;
-
-public class JschMultiTasks extends AbstractJschTask {
-       private List<AbstractJschTask> tasks = new ArrayList<AbstractJschTask>();
-
-       @Override
-       protected void run(Session session) {
-               for (AbstractJschTask task : tasks) {
-                       task.setSshTarget(getSshTarget());
-                       task.run(session);
-               }
-       }
-
-       public void setTasks(List<AbstractJschTask> tasks) {
-               this.tasks = tasks;
-       }
-
-       public List<AbstractJschTask> getTasks() {
-               return tasks;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/RemoteExec.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/RemoteExec.java
deleted file mode 100644 (file)
index 886dc92..0000000
+++ /dev/null
@@ -1,486 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.commons.exec.ExecuteStreamHandler;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.ExecutionResources;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.core.io.Resource;
-import org.springframework.util.StringUtils;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.ChannelShell;
-import com.jcraft.jsch.Session;
-
-public class RemoteExec extends AbstractJschTask {
-       private final static Log log = LogFactory.getLog(RemoteExec.class);
-
-       private Boolean failOnBadExitStatus = true;
-
-       private List<String> commands = new ArrayList<String>();
-       private String command;
-       private SystemCall systemCall;
-       private List<SystemCall> systemCalls = new ArrayList<SystemCall>();
-       private Resource script;
-       private Boolean xForwarding = false;
-       private Boolean agentForwarding = false;
-       private Boolean forceShell = false;
-       private Map<String, String> env = new HashMap<String, String>();
-       private Resource stdIn = null;
-       private Resource stdOut = null;
-       private ExecutionResources executionResources;
-
-       private String user;
-
-       private ExecuteStreamHandler streamHandler = null;
-
-       private Integer lastExitStatus = null;
-       /**
-        * If set, stdout is written to it as a list of lines. Cleared before each
-        * run.
-        */
-       private List<String> stdOutLines = null;
-       private Boolean logEvenIfStdOutLines = false;
-       private Boolean quiet = false;
-
-       public RemoteExec() {
-       }
-
-       public RemoteExec(SshTarget sshTarget, String cmd) {
-               setSshTarget(sshTarget);
-               setCommand(cmd);
-       }
-
-       public void run(Session session) {
-               List<String> commandsToUse = new ArrayList<String>(commands);
-               String commandToUse = command;
-               // convert system calls
-               if (systemCall != null) {
-                       if (command != null)
-                               throw new SlcException("Cannot specify command AND systemCall");
-                       commandToUse = convertSystemCall(systemCall);
-               }
-
-               if (systemCalls.size() != 0) {
-                       if (commandsToUse.size() != 0)
-                               throw new SlcException(
-                                               "Cannot specify commands AND systemCalls");
-                       for (SystemCall systemCall : systemCalls)
-                               commandsToUse.add(convertSystemCall(systemCall));
-               }
-
-               if (script != null) {
-                       // TODO: simply pass the script as a string command
-                       if (commandsToUse.size() != 0)
-                               throw new SlcException("Cannot specify commands and script");
-                       BufferedReader reader = null;
-                       try {
-                               reader = new BufferedReader(new InputStreamReader(
-                                               script.getInputStream()));
-                               String line = null;
-                               while ((line = reader.readLine()) != null) {
-                                       if (!StringUtils.hasText(line))
-                                               continue;
-                                       commandsToUse.add(line);
-                               }
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot read script " + script, e);
-                       } finally {
-                               IOUtils.closeQuietly(reader);
-                       }
-               }
-
-               if (forceShell) {
-                       // for the time being do not interpret both \n and ;
-                       // priority to \n
-                       // until we know how to parse ; within ""
-                       if (commandToUse.indexOf('\n') >= 0) {
-                               StringTokenizer st = new StringTokenizer(commandToUse, "\n");
-                               while (st.hasMoreTokens()) {
-                                       String cmd = st.nextToken();
-                                       commandsToUse.add(cmd);
-                               }
-                       } else if (commandToUse.indexOf(';') >= 0) {
-                               StringTokenizer st = new StringTokenizer(commandToUse, ";");
-                               while (st.hasMoreTokens()) {
-                                       String cmd = st.nextToken();
-                                       commandsToUse.add(cmd);
-                               }
-                       } else {
-                               commandsToUse.add(commandToUse);
-                       }
-                       commandToUse = null;
-               }
-
-               // run as user
-               if (user != null) {
-                       if (commandsToUse.size() > 0) {
-                               commandsToUse.add(0, "su - " + user);
-                               commandsToUse.add("exit");
-                       } else {
-                               if (command.indexOf('\"') >= 0)
-                                       throw new SlcException(
-                                                       "Don't know how to su a command with \", use shell instead.");
-                               commandToUse = "su - " + user + " -c \"" + command + "\"";
-                       }
-               }
-
-               // execute command(s)
-               if (commandToUse != null) {
-                       if (commandsToUse.size() != 0)
-                               throw new SlcException(
-                                               "Specify either a single command or a list of commands.");
-                       remoteExec(session, commandToUse);
-               } else {
-                       if (commandsToUse.size() == 0)
-                               throw new SlcException(
-                                               "Neither a single command or a list of commands has been specified.");
-
-                       remoteExec(session, commandsToUse, script != null ? "script "
-                                       + script.getFilename() : commandsToUse.size() + " commands");
-               }
-       }
-
-       protected String convertSystemCall(SystemCall systemCall) {
-               // TODO: prepend environment variables
-               // TODO: deal with exec dir
-               return systemCall.asCommand();
-       }
-
-       protected void remoteExec(Session session, final List<String> commands,
-                       String description) {
-               try {
-                       final ChannelShell channel = (ChannelShell) session
-                                       .openChannel("shell");
-                       channel.setInputStream(null);
-                       channel.setXForwarding(xForwarding);
-                       channel.setAgentForwarding(agentForwarding);
-                       channel.setEnv(new Hashtable<String, String>(env));
-
-                       /*
-                        * // Choose the pty-type "vt102".
-                        * ((ChannelShell)channel).setPtyType("vt102");
-                        */
-                       // Writer thread
-                       final BufferedWriter writer = new BufferedWriter(
-                                       new OutputStreamWriter(channel.getOutputStream()));
-
-                       if (log.isDebugEnabled())
-                               log.debug("Run " + description + " on " + getSshTarget()
-                                               + "...");
-                       channel.connect();
-
-                       // write commands to shell
-                       Thread writerThread = new Thread("Shell writer " + getSshTarget()) {
-                               @Override
-                               public void run() {
-                                       try {
-                                               for (String line : commands) {
-                                                       if (!StringUtils.hasText(line))
-                                                               continue;
-                                                       writer.write(line);
-                                                       writer.newLine();
-                                               }
-                                               writer.append("exit");
-                                               writer.newLine();
-                                               writer.flush();
-                                               // channel.disconnect();
-                                       } catch (IOException e) {
-                                               throw new SlcException("Cannot write to shell on "
-                                                               + getSshTarget(), e);
-                                       } finally {
-                                               IOUtils.closeQuietly(writer);
-                                       }
-                               }
-                       };
-                       writerThread.start();
-
-                       readStdOut(channel);
-                       checkExitStatus(channel);
-                       channel.disconnect();
-
-               } catch (Exception e) {
-                       throw new SlcException("Cannot use SSH shell on " + getSshTarget(),
-                                       e);
-               }
-
-       }
-
-       protected void remoteExec(Session session, String command) {
-               try {
-                       final ChannelExec channel = (ChannelExec) session
-                                       .openChannel("exec");
-                       channel.setCommand(command);
-
-                       channel.setInputStream(null);
-                       channel.setXForwarding(xForwarding);
-                       channel.setAgentForwarding(agentForwarding);
-                       channel.setEnv(new Hashtable<String, String>(env));
-                       channel.setErrStream(null);
-
-                       // Standard Error
-                       readStdErr(channel);
-
-                       if (log.isTraceEnabled())
-                               log.trace("Run '" + command + "' on " + getSshTarget() + "...");
-                       channel.connect();
-
-                       readStdIn(channel);
-                       readStdOut(channel);
-
-                       if (streamHandler != null) {
-                               streamHandler.start();
-                               while (!channel.isClosed()) {
-                                       try {
-                                               Thread.sleep(100);
-                                       } catch (Exception e) {
-                                               break;
-                                       }
-                               }
-                       }
-
-                       checkExitStatus(channel);
-                       channel.disconnect();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot execute remotely '" + command
-                                       + "' on " + getSshTarget(), e);
-               }
-       }
-
-       protected void readStdOut(Channel channel) {
-               try {
-                       if (stdOut != null) {
-                               OutputStream localStdOut = createOutputStream(stdOut);
-                               try {
-                                       IOUtils.copy(channel.getInputStream(), localStdOut);
-                               } finally {
-                                       IOUtils.closeQuietly(localStdOut);
-                               }
-                       } else if (streamHandler != null) {
-                               if (channel.getInputStream() != null)
-                                       streamHandler.setProcessOutputStream(channel
-                                                       .getInputStream());
-                       } else {
-                               BufferedReader stdOut = null;
-                               try {
-                                       InputStream in = channel.getInputStream();
-                                       stdOut = new BufferedReader(new InputStreamReader(in));
-                                       String line = null;
-                                       while ((line = stdOut.readLine()) != null) {
-                                               if (!line.trim().equals("")) {
-
-                                                       if (stdOutLines != null) {
-                                                               stdOutLines.add(line);
-                                                               if (logEvenIfStdOutLines && !quiet)
-                                                                       log.info(line);
-                                                       } else {
-                                                               if (!quiet)
-                                                                       log.info(line);
-                                                       }
-                                               }
-                                       }
-                               } finally {
-                                       IOUtils.closeQuietly(stdOut);
-                               }
-                       }
-               } catch (IOException e) {
-                       throw new SlcException("Cannot redirect stdout from "
-                                       + getSshTarget(), e);
-               }
-       }
-
-       protected void readStdErr(final ChannelExec channel) {
-               if (streamHandler != null) {
-                       try {
-                               streamHandler.setProcessOutputStream(channel.getErrStream());
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot read stderr from "
-                                               + getSshTarget(), e);
-                       }
-               } else {
-                       new Thread("stderr " + getSshTarget()) {
-                               public void run() {
-                                       BufferedReader stdErr = null;
-                                       try {
-                                               InputStream in = channel.getErrStream();
-                                               stdErr = new BufferedReader(new InputStreamReader(in));
-                                               String line = null;
-                                               while ((line = stdErr.readLine()) != null) {
-                                                       if (!line.trim().equals(""))
-                                                               log.error(line);
-                                               }
-                                       } catch (IOException e) {
-                                               if (log.isDebugEnabled())
-                                                       log.error("Cannot read stderr from "
-                                                                       + getSshTarget(), e);
-                                       } finally {
-                                               IOUtils.closeQuietly(stdErr);
-                                       }
-                               }
-                       }.start();
-               }
-       }
-
-       protected void readStdIn(final ChannelExec channel) {
-               if (stdIn != null) {
-                       Thread stdInThread = new Thread("Stdin " + getSshTarget()) {
-                               @Override
-                               public void run() {
-                                       OutputStream out = null;
-                                       try {
-                                               out = channel.getOutputStream();
-                                               IOUtils.copy(stdIn.getInputStream(), out);
-                                       } catch (IOException e) {
-                                               throw new SlcException("Cannot write stdin on "
-                                                               + getSshTarget(), e);
-                                       } finally {
-                                               IOUtils.closeQuietly(out);
-                                       }
-                               }
-                       };
-                       stdInThread.start();
-               } else if (streamHandler != null) {
-                       try {
-                               streamHandler.setProcessInputStream(channel.getOutputStream());
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot write stdin on "
-                                               + getSshTarget(), e);
-                       }
-               }
-       }
-
-       protected void checkExitStatus(Channel channel) {
-               if (channel.isClosed()) {
-                       lastExitStatus = channel.getExitStatus();
-                       if (lastExitStatus == 0) {
-                               if (log.isTraceEnabled())
-                                       log.trace("Remote execution exit status: " + lastExitStatus);
-                       } else {
-                               String msg = "Remote execution failed with " + " exit status: "
-                                               + lastExitStatus;
-                               if (failOnBadExitStatus)
-                                       throw new SlcException(msg);
-                               else
-                                       log.error(msg);
-                       }
-               }
-
-       }
-
-       protected OutputStream createOutputStream(Resource target) {
-               FileOutputStream out = null;
-               try {
-
-                       final File file;
-                       if (executionResources != null)
-                               file = new File(executionResources.getAsOsPath(target, true));
-                       else
-                               file = target.getFile();
-                       out = new FileOutputStream(file, false);
-               } catch (IOException e) {
-                       log.error("Cannot get file for " + target, e);
-                       IOUtils.closeQuietly(out);
-               }
-               return out;
-       }
-
-       public Integer getLastExitStatus() {
-               return lastExitStatus;
-       }
-
-       public void setStreamHandler(ExecuteStreamHandler executeStreamHandler) {
-               this.streamHandler = executeStreamHandler;
-       }
-
-       public void setCommand(String command) {
-               this.command = command;
-       }
-
-       public void setCommands(List<String> commands) {
-               this.commands = commands;
-       }
-
-       public void setFailOnBadExitStatus(Boolean failOnBadExitStatus) {
-               this.failOnBadExitStatus = failOnBadExitStatus;
-       }
-
-       public void setSystemCall(SystemCall systemCall) {
-               this.systemCall = systemCall;
-       }
-
-       public void setSystemCalls(List<SystemCall> systemCalls) {
-               this.systemCalls = systemCalls;
-       }
-
-       public void setScript(Resource script) {
-               this.script = script;
-       }
-
-       public void setxForwarding(Boolean xForwarding) {
-               this.xForwarding = xForwarding;
-       }
-
-       public void setAgentForwarding(Boolean agentForwarding) {
-               this.agentForwarding = agentForwarding;
-       }
-
-       public void setEnv(Map<String, String> env) {
-               this.env = env;
-       }
-
-       public void setForceShell(Boolean forceShell) {
-               this.forceShell = forceShell;
-       }
-
-       public List<String> getCommands() {
-               return commands;
-       }
-
-       public void setStdOutLines(List<String> stdOutLines) {
-               this.stdOutLines = stdOutLines;
-       }
-
-       public void setLogEvenIfStdOutLines(Boolean logEvenIfStdOutLines) {
-               this.logEvenIfStdOutLines = logEvenIfStdOutLines;
-       }
-
-       public void setQuiet(Boolean quiet) {
-               this.quiet = quiet;
-       }
-
-       public void setStdIn(Resource stdIn) {
-               this.stdIn = stdIn;
-       }
-
-       public void setStdOut(Resource stdOut) {
-               this.stdOut = stdOut;
-       }
-
-       public void setExecutionResources(ExecutionResources executionResources) {
-               this.executionResources = executionResources;
-       }
-
-       public void setUser(String user) {
-               this.user = user;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpFrom.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpFrom.java
deleted file mode 100644 (file)
index ced80ee..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.Session;
-
-public class ScpFrom extends AbstractJschTask {
-       private final static Log log = LogFactory.getLog(ScpFrom.class);
-
-       private Resource localResource;
-       private String remotePath;
-       private Boolean mkdir = false;
-
-       public void run(Session session) {
-               if (localResource != null) {
-                       File lFile;
-                       try {
-                               lFile = localResource.getFile();
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot interpret resource "
-                                               + localResource + " as file.", e);
-                       }
-                       downloadFile(session, lFile, remotePath);
-               }
-       }
-
-       protected void downloadFile(Session session, File localFile,
-                       String remoteFile) {
-               OutputStream out = null;
-               OutputStream channelOut;
-               InputStream channelIn;
-               try {
-                       // exec 'scp -f rfile' remotely
-                       String command = "scp -f " + remoteFile;
-                       Channel channel = session.openChannel("exec");
-                       ((ChannelExec) channel).setCommand(command);
-
-                       // get I/O streams for remote scp
-                       channelOut = channel.getOutputStream();
-                       channelIn = channel.getInputStream();
-
-                       channel.connect();
-
-                       byte[] buf = new byte[1024];
-
-                       // send '\0'
-                       buf[0] = 0;
-                       channelOut.write(buf, 0, 1);
-                       channelOut.flush();
-
-                       while (true) {
-                               int c = checkAck(channelIn);
-                               if (c != 'C') {
-                                       break;
-                               }
-
-                               // read '0644 '
-                               channelIn.read(buf, 0, 5);
-
-                               long filesize = 0L;
-                               while (true) {
-                                       if (channelIn.read(buf, 0, 1) < 0) {
-                                               // error
-                                               break;
-                                       }
-                                       if (buf[0] == ' ')
-                                               break;
-                                       filesize = filesize * 10L + (long) (buf[0] - '0');
-                               }
-
-                               String remoteFileName = null;
-                               for (int i = 0;; i++) {
-                                       channelIn.read(buf, i, 1);
-                                       if (buf[i] == (byte) 0x0a) {
-                                               remoteFileName = new String(buf, 0, i);
-                                               break;
-                                       }
-                               }
-
-                               // System.out.println("filesize="+filesize+", file="+file);
-
-                               // send '\0'
-                               buf[0] = 0;
-                               channelOut.write(buf, 0, 1);
-                               channelOut.flush();
-
-                               // Create a s adirectory if it doesn't exists
-                               if (!localFile.exists() && mkdir)
-                                       localFile.mkdirs();
-
-                               // read a content of lfile
-                               String localPath = localFile.isDirectory() ? localFile
-                                               .getPath()
-                                               + File.separator + remoteFileName : localFile.getPath();
-
-                               out = new FileOutputStream(localPath);
-                               int foo;
-                               while (true) {
-                                       if (buf.length < filesize)
-                                               foo = buf.length;
-                                       else
-                                               foo = (int) filesize;
-                                       foo = channelIn.read(buf, 0, foo);
-                                       if (foo < 0) {
-                                               // error
-                                               break;
-                                       }
-                                       out.write(buf, 0, foo);
-                                       filesize -= foo;
-                                       if (filesize == 0L)
-                                               break;
-                               }
-
-                               checkAck(channelIn);
-
-                               // send '\0'
-                               buf[0] = 0;
-                               channelOut.write(buf, 0, 1);
-                               channelOut.flush();
-
-                               if (log.isDebugEnabled())
-                                       log.debug("Finished downloading " + remoteFile + " on "
-                                                       + getSshTarget() + " to " + localPath);
-                       }
-
-                       channel.disconnect();
-                       // session.disconnect();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot download " + remoteFile + " to "
-                                       + localFile, e);
-               } finally {
-                       IOUtils.closeQuietly(out);
-               }
-       }
-
-       public void setLocalResource(Resource localFile) {
-               this.localResource = localFile;
-       }
-
-       public void setRemotePath(String remoteFile) {
-               this.remotePath = remoteFile;
-       }
-
-       public void setMkdir(Boolean mkdir) {
-               this.mkdir = mkdir;
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpTo.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpTo.java
deleted file mode 100644 (file)
index 5da5f79..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.ByteArrayResource;
-import org.springframework.core.io.Resource;
-import org.springframework.util.AntPathMatcher;
-import org.springframework.util.PathMatcher;
-import org.springframework.util.StringUtils;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.Session;
-
-public class ScpTo extends AbstractJschTask {
-       private final static Log log = LogFactory.getLog(ScpTo.class);
-
-       private Resource localResource;
-       private String remotePath;
-
-       private String dir;
-       private String remoteDir;
-       private List<String> includes = new ArrayList<String>();
-
-       private List<String> excludes = new ArrayList<String>();
-
-       private PathMatcher pathMatcher;
-
-       public void run(Session session) {
-               if (StringUtils.hasText(dir)) {
-                       if (!StringUtils.hasText(remoteDir))
-                               throw new SlcException("Remote dir has to be specified.");
-
-                       String dirOs = dir.replace('/', File.separatorChar);
-                       if (dirOs.charAt(dir.length() - 1) != File.separatorChar) {
-                               dirOs = dirOs + File.separator;
-                       }
-
-                       if (pathMatcher == null)
-                               pathMatcher = new AntPathMatcher();
-
-                       log.info("Start multiple scp based on " + dirOs);
-                       scanDir(session, dirOs, "", includes, excludes);
-               }
-
-               if (localResource != null) {
-                       uploadResource(session, localResource);
-               }
-       }
-
-       protected void scanDir(Session session, String dir, String currentRelPath,
-                       List<String> includes, List<String> excludes) {
-               File[] files = new File(dir).listFiles();
-               for (File file : files) {
-                       if (!file.isDirectory()) {
-                               String relPath = currentRelPath.concat(file.getName());
-                               if (match(relPath, includes, excludes, false)) {
-                                       uploadFile(session, file, remoteDir + '/' + relPath);
-                               }
-                       } else {
-                               String relPath = currentRelPath.concat(file.getName()).concat(
-                                               "/");
-                               if (match(relPath, includes, excludes, true)) {
-                                       String nextDir = dir.concat(file.getName()).concat(
-                                                       File.separator);
-                                       scanDir(session, nextDir, relPath, includes, excludes);
-                               }
-                       }
-               }
-       }
-
-       protected Boolean match(String path, List<String> includes,
-                       List<String> excludes, boolean matchStart) {
-               for (String patternIn : includes) {
-                       boolean matchIn = matchStart ? pathMatcher.matchStart(patternIn,
-                                       path) : pathMatcher.match(patternIn, path);
-                       if (matchIn) {
-                               // Could be included, check excludes
-                               boolean excluded = false;
-                               ex: for (String patternEx : excludes) {
-                                       boolean matchEx = matchStart ? pathMatcher.matchStart(
-                                                       patternEx, path) : pathMatcher.match(patternEx,
-                                                       path);
-
-                                       if (matchEx) {
-                                               excluded = true;
-                                               break ex;
-                                       }
-                               }
-                               if (!excluded)
-                                       return true;
-                       }
-               }
-               return false;
-       }
-
-       protected void uploadFile(Session session, File file, String remoteFile) {
-               try {
-                       upload(session, new FileInputStream(file), file.length(), file
-                                       .getPath(), file.toString(), remoteFile);
-               } catch (FileNotFoundException e) {
-                       throw new SlcException("Cannot upload " + file, e);
-               }
-       }
-
-       protected void uploadResource(Session session, Resource resource) {
-               String targetPath = remotePath != null ? remotePath : remoteDir + '/'
-                               + resource.getFilename();
-               try {
-                       File lFile = resource.getFile();
-                       uploadFile(session, lFile, targetPath);
-               } catch (IOException e) {
-                       // no underlying file found
-                       // load the resource in memory before transferring it
-                       InputStream in = null;
-                       try {
-                               byte[] arr;
-                               String path;
-                               if (resource instanceof ByteArrayResource) {
-                                       arr = ((ByteArrayResource) resource).getByteArray();
-                                       path = "bytearray";
-                               } else {
-                                       in = resource.getInputStream();
-                                       ByteArrayOutputStream out = new ByteArrayOutputStream();
-                                       IOUtils.copy(in, out);
-                                       arr = out.toByteArray();
-                                       path = resource.getURL().getPath();
-                                       if (path.startsWith("/"))
-                                               path = path.substring(1);
-                               }
-                               ByteArrayInputStream content = new ByteArrayInputStream(arr);
-                               upload(session, content, arr.length, path, resource.toString(),
-                                               targetPath);
-                               arr = null;
-                       } catch (IOException e1) {
-                               throw new SlcException("Can not interpret resource "
-                                               + localResource, e1);
-                       } finally {
-                               IOUtils.closeQuietly(in);
-                               // no need to close byte arrays streams
-                       }
-               }
-       }
-
-       protected void upload(Session session, InputStream in, long size,
-                       String path, String sourceDesc, String remoteFile) {
-               OutputStream channelOut;
-               InputStream channelIn;
-               try {
-
-                       // exec 'scp -t rfile' remotely
-                       String command = "scp -p -t " + remoteFile;
-                       Channel channel = session.openChannel("exec");
-                       ((ChannelExec) channel).setCommand(command);
-
-                       // get I/O streams for remote scp
-                       channelOut = channel.getOutputStream();
-                       channelIn = channel.getInputStream();
-
-                       channel.connect();
-                       checkAck(channelIn);
-
-                       // send "C0644 filesize filename", where filename should not include
-                       // '/'
-                       long filesize = size;
-                       command = "C0644 " + filesize + " ";
-                       int index = path.lastIndexOf('/');
-                       if (index > 0) {
-                               command += path.substring(index + 1);
-                       } else {
-                               command += path;
-                       }
-                       command += "\n";
-
-                       channelOut.write(command.getBytes());
-                       channelOut.flush();
-                       checkAck(channelIn);
-
-                       if (log.isTraceEnabled())
-                               log.debug("Start copy of " + sourceDesc + " to " + remoteFile
-                                               + " on " + getSshTarget() + "...");
-
-                       final long oneMB = 1024l;// in KB
-                       final long tenMB = 10 * oneMB;// in KB
-
-                       // send a content of lfile
-                       byte[] buf = new byte[1024];
-                       long cycleCount = 0;
-                       long nbrOfBytes = 0;
-                       while (true) {
-                               int len = in.read(buf, 0, buf.length);
-                               if (len <= 0)
-                                       break;
-                               channelOut.write(buf, 0, len); // out.flush();
-                               nbrOfBytes = nbrOfBytes + len;
-                               if (((cycleCount % oneMB) == 0) && cycleCount != 0)// each 1 MB
-                                       System.out.print('#');
-                               if (((cycleCount % (tenMB)) == 0) && cycleCount != 0)// each 10
-                                       // MB
-                                       System.out.print(" - " + cycleCount / tenMB + "0 MB\n");
-                               cycleCount++;
-                       }
-                       // send '\0'
-                       buf[0] = 0;
-                       channelOut.write(buf, 0, 1);
-                       channelOut.flush();
-                       checkAck(channelIn);
-
-                       if (log.isDebugEnabled())
-                               log.debug("Transferred to " + remoteFile + " ("
-                                               + sizeDesc(nbrOfBytes) + ") on " + getSshTarget()
-                                               + " from " + sourceDesc);
-
-                       IOUtils.closeQuietly(channelOut);
-
-                       channel.disconnect();
-               } catch (Exception e) {
-                       throw new SlcException("Cannot copy " + path + " to " + remoteFile,
-                                       e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-               }
-       }
-
-       protected String sizeDesc(Long nbrOfBytes) {
-               if (nbrOfBytes < 1024)
-                       return nbrOfBytes + " B";
-               else if (nbrOfBytes < 1024 * 1024)
-                       return (nbrOfBytes / 1024) + " KB";
-               else
-                       return nbrOfBytes / (1024 * 1024) + " MB";
-       }
-
-       public void setLocalResource(Resource localFile) {
-               this.localResource = localFile;
-       }
-
-       public void setRemotePath(String remoteFile) {
-               this.remotePath = remoteFile;
-       }
-
-       public void setDir(String dir) {
-               this.dir = dir;
-       }
-
-       public void setRemoteDir(String remoteDir) {
-               this.remoteDir = remoteDir;
-       }
-
-       public void setIncludes(List<String> includes) {
-               this.includes = includes;
-       }
-
-       public void setExcludes(List<String> excludes) {
-               this.excludes = excludes;
-       }
-
-       public void setPathMatcher(PathMatcher pathMatcher) {
-               this.pathMatcher = pathMatcher;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SimpleUserInfo.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SimpleUserInfo.java
deleted file mode 100644 (file)
index fd84224..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.util.Arrays;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-
-import com.jcraft.jsch.UserInfo;
-
-/** Basic implementation of user info. */
-public class SimpleUserInfo implements UserInfo {
-       private Boolean permissive = true;
-       private Boolean verbose = false;
-
-       private final static Log log = LogFactory.getLog(SimpleUserInfo.class);
-
-       protected String password;
-       protected char[] passwordSafe;
-       protected String passphrase;
-       protected char[] passphraseSafe;
-
-       public void reset() {
-               if (passwordSafe != null)
-                       Arrays.fill(passwordSafe, (char) 0);
-               passwordSafe = null;
-               if (passphraseSafe != null)
-                       Arrays.fill(passphraseSafe, (char) 0);
-               passphraseSafe = null;
-       }
-
-       public void setPassword(String password) {
-               this.password = password;
-       }
-
-       public void setPassphrase(String passphrase) {
-               this.passphrase = passphrase;
-       }
-
-       public String getPassphrase() {
-               if (passphraseSafe != null)
-                       return new String(passphraseSafe);
-               return passphrase;
-       }
-
-       public String getPassword() {
-               if (passwordSafe != null)
-                       return new String(passwordSafe);
-               return password;
-       }
-
-       public boolean promptPassphrase(String message) {
-               if (permissive)
-                       return true;
-               else {
-                       log.info(message);
-                       passwordSafe = readPassword(System.in);
-                       return passwordSafe != null;
-               }
-       }
-
-       public boolean promptPassword(String message) {
-               if (permissive)
-                       return true;
-               else {
-                       log.info(message);
-                       passwordSafe = readPassword(System.in);
-                       return passwordSafe != null;
-               }
-       }
-
-       public boolean promptYesNo(String message) {
-               String msg = message + " (y/n): ";
-               if (permissive) {
-                       if (verbose)
-                               log.info(msg + "y");
-                       return true;
-               } else {
-                       log.info(msg);
-                       char c;
-                       try {
-                               c = (char) System.in.read();
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot read stdin", e);
-                       }
-                       if (c == 'y')
-                               return true;
-                       else
-                               return false;
-               }
-       }
-
-       public void showMessage(String message) {
-               log.info(message);
-       }
-
-       public void setPermissive(Boolean permissive) {
-               this.permissive = permissive;
-       }
-
-       public void setVerbose(Boolean verbose) {
-               this.verbose = verbose;
-       }
-
-       protected char[] readPassword(InputStream in) {
-
-               try {
-                       char[] lineBuffer;
-                       char[] buf;
-                       // int i;
-
-                       buf = lineBuffer = new char[128];
-
-                       int room = buf.length;
-                       int offset = 0;
-                       int c;
-
-                       loop: while (true) {
-                               switch (c = in.read()) {
-                               case -1:
-                               case '\n':
-                                       break loop;
-
-                               case '\r':
-                                       int c2 = in.read();
-                                       if ((c2 != '\n') && (c2 != -1)) {
-                                               if (!(in instanceof PushbackInputStream)) {
-                                                       in = new PushbackInputStream(in);
-                                               }
-                                               ((PushbackInputStream) in).unread(c2);
-                                       } else
-                                               break loop;
-
-                               default:
-                                       if (--room < 0) {
-                                               buf = new char[offset + 128];
-                                               room = buf.length - offset - 1;
-                                               System.arraycopy(lineBuffer, 0, buf, 0, offset);
-                                               Arrays.fill(lineBuffer, ' ');
-                                               lineBuffer = buf;
-                                       }
-                                       buf[offset++] = (char) c;
-                                       break;
-                               }
-                       }
-
-                       if (offset == 0) {
-                               return null;
-                       }
-
-                       char[] ret = new char[offset];
-                       System.arraycopy(buf, 0, ret, 0, offset);
-                       Arrays.fill(buf, ' ');
-
-                       return ret;
-               } catch (IOException e) {
-                       throw new SlcException("Cannot read password.", e);
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SshFilesDeployment.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SshFilesDeployment.java
deleted file mode 100644 (file)
index 53670e1..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.deploy.DigestCheck;
-import org.argeo.slc.core.deploy.ResourceSet;
-import org.springframework.core.io.Resource;
-
-import com.jcraft.jsch.Session;
-
-public class SshFilesDeployment extends AbstractJschTask implements Runnable {
-       private final static Log log = LogFactory.getLog(SshFilesDeployment.class);
-       private String targetBase = "";
-       private ResourceSet resourceSet;
-       /**
-        * Activate with algorithm as per
-        * http://java.sun.com/j2se/1.5.0/docs/guide/security/CryptoSpec.html#AppA
-        */
-       private String checksum = "MD5";
-       private int remoteChecksumsPerCall = 20;
-
-       public SshFilesDeployment() {
-       }
-
-       public SshFilesDeployment(SshTarget sshTarget, ResourceSet resourceSet) {
-               setSshTarget(sshTarget);
-               this.resourceSet = resourceSet;
-       }
-
-       @Override
-       void run(Session session) {
-               JschMultiTasks multiTasks = new JschMultiTasks();
-
-               Map<String, Resource> resources = resourceSet.listResources();
-
-               // Analyze set
-               List<String> subDirs = new ArrayList<String>();
-               Map<String, String> targetPaths = new HashMap<String, String>();
-               for (String relPath : resources.keySet()) {
-                       String parentDir;
-                       int lastIndexSubDir = relPath.lastIndexOf('/');
-                       if (lastIndexSubDir > 0)
-                               parentDir = targetBase + '/'
-                                               + relPath.substring(0, lastIndexSubDir);
-                       else
-                               parentDir = targetBase;
-
-                       boolean skipDir = false;
-                       registerDirs: for (String registeredDir : new ArrayList<String>(
-                                       subDirs)) {
-                               if (parentDir.equals(registeredDir)) {
-                                       if (log.isTraceEnabled())
-                                               log.trace("Already registered, skip " + parentDir);
-                                       skipDir = true;
-                                       break registerDirs;
-                               }
-
-                               if (parentDir.startsWith(registeredDir))
-                                       if (subDirs.contains(registeredDir)) {
-                                               subDirs.remove(registeredDir);
-                                               if (log.isTraceEnabled())
-                                                       log.trace("Remove parent " + registeredDir + " of "
-                                                                       + parentDir);
-                                               continue registerDirs;
-                                       }
-
-                               if (registeredDir.startsWith(parentDir)) {
-                                       skipDir = true;
-                                       if (log.isTraceEnabled())
-                                               log.trace("Skip " + parentDir
-                                                               + " because child already registered.");
-                                       break registerDirs;
-                               }
-                       }
-
-                       if (!subDirs.contains(parentDir) && !skipDir) {
-                               subDirs.add(parentDir);
-                       }
-
-                       targetPaths.put(relPath, targetBase + "/" + relPath);
-               }
-
-               // checksum
-               List<String> targetPathsEqualsToLocal = new ArrayList<String>();
-               if (checksum != null) {
-                       Map<String, String> remoteChecksums = new HashMap<String, String>();
-                       List<String> csLines = new ArrayList<String>();
-                       String csExecutable;
-                       if ("MD5".equals(checksum))
-                               csExecutable = "/usr/bin/md5sum";
-                       else if ("SHA".equals(checksum))
-                               csExecutable = "/usr/bin/sha1sum";
-                       else if ("SHA-256".equals(checksum))
-                               csExecutable = "/usr/bin/sha256sum";
-                       else if ("SHA-512".equals(checksum))
-                               csExecutable = "/usr/bin/sha512sum";
-                       else
-                               throw new SlcException(
-                                               "Don't know how to remotely execute checksum "
-                                                               + checksum);
-
-                       StringBuffer csCmd = new StringBuffer(csExecutable);
-                       int numberOfPaths = targetPaths.size();
-                       int count = 0;
-                       for (String targetPath : targetPaths.values()) {
-                               csCmd.append(" ").append(targetPath);
-                               count++;
-
-                               if ((count % remoteChecksumsPerCall == 0)
-                                               || count == numberOfPaths) {
-                                       RemoteExec remoteCs = new RemoteExec();
-                                       remoteCs.setSshTarget(getSshTarget());
-                                       remoteCs.setCommand(csCmd.toString());
-                                       remoteCs.setStdOutLines(csLines);
-                                       remoteCs.setFailOnBadExitStatus(false);
-                                       remoteCs.run(session);
-                                       csCmd = new StringBuffer(csExecutable);
-                               }
-
-                       }
-
-                       remoteChecksums: for (String csLine : csLines) {
-                               StringTokenizer st = new StringTokenizer(csLine, ": ");
-                               String cs = st.nextToken();
-                               if (cs.equals(csExecutable)) {
-                                       // remote does not exist
-                                       continue remoteChecksums;
-                               } else {
-                                       String targetPath = st.nextToken();
-                                       if (log.isTraceEnabled())
-                                               log.trace("REMOTE: " + targetPath + "=" + cs);
-                                       remoteChecksums.put(targetPath, cs);
-                               }
-                       }
-
-                       // Local checksums
-                       for (String relPath : resources.keySet()) {
-                               Resource resource = resources.get(relPath);
-                               String targetPath = targetPaths.get(relPath);
-                               if (remoteChecksums.containsKey(targetPath)) {
-                                       String cs = DigestCheck.digest(checksum, resource);
-                                       if (log.isTraceEnabled())
-                                               log.trace("LOCAL : " + targetPath + "=" + cs);
-                                       if (remoteChecksums.get(targetPath).equals(cs))
-                                               targetPathsEqualsToLocal.add(targetPath);
-                               }
-                       }
-               }
-
-               // Prepare multitask
-
-               // Create dirs
-               StringBuffer mkdirCmd = new StringBuffer("mkdir -p");
-               RemoteExec remoteExec = new RemoteExec();
-               for (String dir : subDirs) {
-                       // remoteExec.getCommands().add("mkdir -p " + dir);
-                       mkdirCmd.append(' ');
-                       if (dir.indexOf(' ') >= 0)
-                               mkdirCmd.append('\"').append(dir).append('\"');
-                       else
-                               mkdirCmd.append(dir);
-               }
-               remoteExec.setCommand(mkdirCmd.toString());
-               multiTasks.getTasks().add(remoteExec);
-
-               // Perform copies
-               int copied = 0;
-               int skipped = 0;
-               copy: for (String relPath : resources.keySet()) {
-                       String targetPath = targetPaths.get(relPath);
-                       if (targetPathsEqualsToLocal.contains(targetPath)) {
-                               if (log.isTraceEnabled())
-                                       log.trace("Skip copy of " + relPath
-                                                       + " since it is equal to remote " + targetPath);
-                               skipped++;
-                               continue copy;
-                       }
-                       // Copy resource
-                       Resource resource = resources.get(relPath);
-                       ScpTo scpTo = new ScpTo();
-                       scpTo.setLocalResource(resource);
-                       scpTo.setRemotePath(targetPath);
-                       multiTasks.getTasks().add(scpTo);
-                       copied++;
-                       // TODO: set permissions
-               }
-
-               multiTasks.setSshTarget(getSshTarget());
-               multiTasks.run(session);
-
-               if (checksum != null && log.isDebugEnabled())
-                       log.debug("Copied " + copied + " files, skipped " + skipped
-                                       + " with same checksum.");
-       }
-
-       public void setTargetBase(String targetBase) {
-               this.targetBase = targetBase;
-       }
-
-       public void setResourceSet(ResourceSet resourceSet) {
-               this.resourceSet = resourceSet;
-       }
-
-       public void setChecksum(String checksum) {
-               this.checksum = checksum;
-       }
-
-       /** Number of remote checksums per remote call */
-       public void setRemoteChecksumsPerCall(int remoteChecksumsPerCall) {
-               this.remoteChecksumsPerCall = remoteChecksumsPerCall;
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SshShell.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SshShell.java
deleted file mode 100644 (file)
index 2ec2b72..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-import org.springframework.util.StringUtils;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.Session;
-
-public class SshShell extends AbstractJschTask {
-       private final static Log log = LogFactory.getLog(SshShell.class);
-       private Resource input;
-
-       @Override
-       void run(Session session) {
-               try {
-                       final Channel channel = session.openChannel("shell");
-
-                       // Enable agent-forwarding.
-                       // ((ChannelShell)channel).setAgentForwarding(true);
-
-                       // channel.setInputStream(System.in);
-                       // channel.setInputStream(input.getInputStream());
-                       /*
-                        * // a hack for MS-DOS prompt on Windows.
-                        * channel.setInputStream(new FilterInputStream(System.in){ public
-                        * int read(byte[] b, int off, int len)throws IOException{ return
-                        * in.read(b, off, (len>1024?1024:len)); } });
-                        */
-
-                       // channel.setOutputStream(System.out);
-
-                       /*
-                        * // Choose the pty-type "vt102".
-                        * ((ChannelShell)channel).setPtyType("vt102");
-                        */
-
-                       /*
-                        * // Set environment variable "LANG" as "ja_JP.eucJP".
-                        * ((ChannelShell)channel).setEnv("LANG", "ja_JP.eucJP");
-                        */
-
-                       // Writer thread
-                       final BufferedWriter writer = new BufferedWriter(
-                                       new OutputStreamWriter(channel.getOutputStream()));
-
-                       // channel.connect();
-                       channel.connect(3 * 1000);
-
-                       // while (!channel.isConnected())
-                       // try {
-                       // Thread.sleep(500);
-                       // } catch (InterruptedException e1) {
-                       // // silent
-                       // }
-
-                       Thread writerThread = new Thread("Shell writer " + getSshTarget()) {
-
-                               @Override
-                               public void run() {
-
-                                       if (log.isDebugEnabled())
-                                               log.debug("Start writing to shell");
-
-                                       BufferedReader reader = null;
-                                       try {
-                                               reader = new BufferedReader(new InputStreamReader(input
-                                                               .getInputStream()));
-                                               String line = null;
-                                               while ((line = reader.readLine()) != null) {
-                                                       if (!StringUtils.hasText(line))
-                                                               continue;
-                                                       writer.write(line);
-                                                       writer.newLine();
-                                               }
-                                               writer.append("exit");
-                                               writer.newLine();
-                                               writer.flush();
-                                               // channel.disconnect();
-                                       } catch (IOException e) {
-                                               throw new SlcException("Cannot write to shell on "
-                                                               + getSshTarget(), e);
-                                       } finally {
-                                               IOUtils.closeQuietly(reader);
-                                       }
-                               }
-                       };
-                       writerThread.start();
-
-                       BufferedReader execIn = null;
-                       try {
-                               execIn = new BufferedReader(new InputStreamReader(channel
-                                               .getInputStream()));
-                               String line = null;
-                               while ((line = execIn.readLine()) != null) {
-                                       if (!line.trim().equals(""))
-                                               log.info(line);
-                               }
-                       } catch (Exception e) {
-                               throw new SlcException("Cannot read from shell on "
-                                               + getSshTarget(), e);
-                       } finally {
-                               IOUtils.closeQuietly(execIn);
-                       }
-
-               } catch (Exception e) {
-                       throw new SlcException("Cannot use SSH shell on " + getSshTarget(),
-                                       e);
-               }
-       }
-
-       public void setInput(Resource input) {
-               this.input = input;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SshTarget.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SshTarget.java
deleted file mode 100644 (file)
index f328f8f..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.io.File;
-
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.UserInfo;
-
-public class SshTarget {
-       private String host;
-       private Integer port = 22;
-       private String user;
-       private UserInfo userInfo = new SimpleUserInfo();
-
-       private Boolean usePrivateKey = true;
-       private File localPrivateKey = new File(System.getProperty("user.home")
-                       + File.separator + ".ssh" + File.separator + "id_rsa");
-
-       /** cached session */
-       private transient Session session;
-
-       public String getHost() {
-               return host;
-       }
-
-       public void setHost(String host) {
-               this.host = host;
-       }
-
-       public Integer getPort() {
-               return port;
-       }
-
-       public void setPort(Integer port) {
-               this.port = port;
-       }
-
-       public String getUser() {
-               return user;
-       }
-
-       public void setUser(String user) {
-               this.user = user;
-       }
-
-       public UserInfo getUserInfo() {
-               return userInfo;
-       }
-
-       public void setUserInfo(UserInfo userInfo) {
-               this.userInfo = userInfo;
-       }
-
-       public void setLocalPrivateKey(File localPrivateKey) {
-               this.localPrivateKey = localPrivateKey;
-       }
-
-       public File getLocalPrivateKey() {
-               return localPrivateKey;
-       }
-
-       public Boolean getUsePrivateKey() {
-               return usePrivateKey;
-       }
-
-       public void setUsePrivateKey(Boolean usePrivateKey) {
-               this.usePrivateKey = usePrivateKey;
-       }
-
-       public String toString() {
-               return getUser() + "@" + getHost() + ":" + getPort();
-       }
-
-       public synchronized Session getSession() {
-               return session;
-       }
-
-       public synchronized void setSession(Session session) {
-               this.session = session;
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SwingUserInfo.java b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/SwingUserInfo.java
deleted file mode 100644 (file)
index 14eb16b..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.argeo.slc.jsch;
-
-import java.awt.Container;
-import java.awt.GridLayout;
-import java.awt.Panel;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Arrays;
-
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JPasswordField;
-
-/** Retrieves a password or a passphrase using standard Swing */
-public class SwingUserInfo extends SimpleUserInfo {
-
-       private Boolean alwaysPrompt = false;
-
-       public boolean promptPassphrase(String message) {
-               if (passphrase != null)
-                       return true;
-
-               if (!alwaysPrompt && passphraseSafe != null)
-                       return true;
-
-               PasswordDialog dialog = new PasswordDialog(message) {
-                       private static final long serialVersionUID = 3266299327166418364L;
-
-                       @Override
-                       protected void useCredentials(char[] password) {
-                               passphraseSafe = new char[password.length];
-                               System.arraycopy(password, 0, passphraseSafe, 0,
-                                               password.length);
-                               // passphraseSafe = Arrays.copyOf(password, password.length);
-                       }
-               };
-               dialog.setVisible(true);
-               return dialog.getWasProvided();
-       }
-
-       public boolean promptPassword(String message) {
-               if (password != null)
-                       return true;
-
-               if (!alwaysPrompt && passwordSafe != null)
-                       return true;
-
-               PasswordDialog dialog = new PasswordDialog(message) {
-                       private static final long serialVersionUID = 3266299327166418364L;
-
-                       @Override
-                       protected void useCredentials(char[] password) {
-                               // passwordSafe = Arrays.copyOf(password, password.length);
-                               passwordSafe = new char[password.length];
-                               System.arraycopy(password, 0, passwordSafe, 0, password.length);
-                       }
-               };
-               dialog.setVisible(true);
-               return dialog.getWasProvided();
-       }
-
-       public void setAlwaysPrompt(Boolean alwaysPrompt) {
-               this.alwaysPrompt = alwaysPrompt;
-       }
-
-       protected static class PasswordDialog extends JDialog implements
-                       ActionListener {
-               private static final long serialVersionUID = 3399155607980846207L;
-
-               private static final String OK = "ok";
-
-               private JPasswordField password = new JPasswordField("", 10);
-
-               private JButton okButton;
-               private JButton cancelButton;
-
-               private Boolean wasProvided = false;
-
-               public PasswordDialog(String title) {
-                       setTitle(title);
-                       setModal(true);
-                       setLocationRelativeTo(null);
-                       setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-
-                       JPanel p1 = new JPanel(new GridLayout(1, 2, 3, 3));
-                       p1.add(new JLabel("Password"));
-                       password.setActionCommand(OK);
-                       password.addActionListener(this);
-                       p1.add(password);
-                       add("Center", p1);
-
-                       Panel p2 = new Panel();
-                       okButton = addButton(p2, "OK");
-                       okButton.setActionCommand(OK);
-                       cancelButton = addButton(p2, "Cancel");
-                       add("South", p2);
-                       setSize(240, 120);
-
-                       pack();
-               }
-
-               /** To be overridden */
-               protected void useCredentials(char[] password) {
-                       // does nothing
-               }
-
-               private JButton addButton(Container c, String name) {
-                       JButton button = new JButton(name);
-                       button.addActionListener(this);
-                       c.add(button);
-                       return button;
-               }
-
-               public final void actionPerformed(ActionEvent evt) {
-                       Object source = evt.getSource();
-                       if (source == okButton || evt.getActionCommand().equals(OK)) {
-                               char[] p = password.getPassword();
-                               useCredentials(p);
-                               wasProvided = true;
-                               Arrays.fill(p, '0');
-                               cleanUp();
-                       } else if (source == cancelButton)
-                               cleanUp();
-               }
-
-               private void cleanUp() {
-                       password.setText("");
-                       dispose();
-               }
-
-               public Boolean getWasProvided() {
-                       return wasProvided;
-               }
-
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/jaas.cfg b/cms/org.argeo.slc.support/src/org/argeo/slc/jsch/jaas.cfg
deleted file mode 100644 (file)
index 21176b9..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-SINGLE_USER {
-    com.sun.security.auth.module.Krb5LoginModule optional
-     principal="${user.name}"
-     useTicketCache=true;
-};
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/jcr/JcrRepositoryBackup.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/jcr/JcrRepositoryBackup.java
deleted file mode 100644 (file)
index 977bf87..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-package org.argeo.slc.lib.jcr;
-
-import java.util.UUID;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.vfs2.FileObject;
-import org.apache.commons.vfs2.FileSelectInfo;
-import org.apache.commons.vfs2.FileSelector;
-import org.apache.commons.vfs2.FileSystemException;
-import org.apache.commons.vfs2.FileSystemManager;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.api.NodeUtils;
-import org.argeo.slc.SlcException;
-
-/** Backups a JCR repository */
-public class JcrRepositoryBackup implements Runnable {
-       private final static Log log = LogFactory.getLog(JcrRepositoryBackup.class);
-
-       private String sourceRepo;
-       private String sourceDatastore;
-       private String targetFile;
-
-       private String sourceWksp;
-
-       private String sourceUsername;
-       private char[] sourcePassword;
-
-       private RepositoryFactory repositoryFactory;
-       private FileSystemManager fileSystemManager;
-
-       public void run() {
-               Session sourceDefaultSession = null;
-               try {
-                       long begin = System.currentTimeMillis();
-
-                       FileObject archiveRoot = fileSystemManager.resolveFile(targetFile);
-                       archiveRoot.createFolder();
-
-                       String datastoreFolderName = "datastore";
-                       if (hasDatastore())
-                               backupDataStore(archiveRoot.resolveFile(datastoreFolderName));
-
-                       Repository sourceRepository = NodeUtils.getRepositoryByUri(
-                                       repositoryFactory, sourceRepo);
-                       Credentials sourceCredentials = null;
-                       if (sourceUsername != null)
-                               sourceCredentials = new SimpleCredentials(sourceUsername,
-                                               sourcePassword);
-
-                       sourceDefaultSession = sourceRepository.login(sourceCredentials);
-                       for (String sourceWorkspaceName : sourceDefaultSession
-                                       .getWorkspace().getAccessibleWorkspaceNames()) {
-                               if (Thread.interrupted()) {
-                                       log.error("Workspace backup interrupted");
-                                       Thread.currentThread().interrupt();
-                                       return;
-                               }
-
-                               if (sourceWksp != null && !sourceWksp.trim().equals("")
-                                               && !sourceWorkspaceName.equals(sourceWksp))
-                                       continue;
-                               Session sourceSession = null;
-                               JarOutputStream out = null;
-                               FileObject workspaceBackup = null;
-                               try {
-                                       Manifest manifest = new Manifest();
-                                       manifest.getMainAttributes().put(
-                                                       Attributes.Name.MANIFEST_VERSION, "1.0");
-                                       manifest.getMainAttributes().putValue("Backup-UUID",
-                                                       UUID.randomUUID().toString());
-                                       manifest.getMainAttributes().putValue("Backup-Timestamp",
-                                                       Long.toString(System.currentTimeMillis()));
-                                       manifest.getMainAttributes().putValue(
-                                                       "Backup-JCR-Workspace", sourceWorkspaceName);
-                                       workspaceBackup = fileSystemManager.resolveFile(targetFile
-                                                       + "/" + sourceWorkspaceName + ".jar");
-
-                                       out = new JarOutputStream(workspaceBackup.getContent()
-                                                       .getOutputStream(), manifest);
-                                       sourceSession = sourceRepository.login(sourceCredentials,
-                                                       sourceWorkspaceName);
-                                       backupWorkspace(sourceSession, out);
-                               } finally {
-                                       JcrUtils.logoutQuietly(sourceSession);
-                                       IOUtils.closeQuietly(out);
-                                       if (workspaceBackup != null)
-                                               workspaceBackup.close();
-                               }
-                       }
-
-                       // in case some binaries have been added during the backup
-                       if (hasDatastore())
-                               backupDataStore(archiveRoot.resolveFile(datastoreFolderName));
-
-                       long duration = (System.currentTimeMillis() - begin) / 1000;// s
-                       log.info("Backed-up " + sourceRepo + " in " + (duration / 60)
-                                       + "min " + (duration % 60) + "s");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot backup " + sourceRepo, e);
-               } finally {
-                       JcrUtils.logoutQuietly(sourceDefaultSession);
-               }
-       }
-
-       protected Boolean hasDatastore() {
-               return sourceDatastore != null && !sourceDatastore.trim().equals("");
-       }
-
-       protected void backupWorkspace(Session sourceSession, JarOutputStream out) {
-               try {
-                       if (log.isTraceEnabled())
-                               log.trace("Backup " + sourceSession.getWorkspace().getName()
-                                               + "...");
-                       Boolean skipBinaries = hasDatastore();
-                       for (NodeIterator it = sourceSession.getRootNode().getNodes(); it
-                                       .hasNext();) {
-                               if (Thread.interrupted()) {
-                                       log.error("Node backup interrupted");
-                                       Thread.currentThread().interrupt();
-                                       return;
-                               }
-                               Node node = it.nextNode();
-                               JarEntry entry = new JarEntry(node.getPath());
-                               out.putNextEntry(entry);
-                               sourceSession.exportSystemView(node.getPath(), out,
-                                               skipBinaries, false);
-                               out.flush();
-                               out.closeEntry();
-                       }
-                       if (log.isDebugEnabled())
-                               log.debug("Backed up " + sourceSession.getWorkspace().getName());
-               } catch (Exception e) {
-                       throw new SlcException("Cannot backup "
-                                       + sourceSession.getWorkspace().getName(), e);
-               }
-       }
-
-       protected void backupDataStore(final FileObject targetDatastore) {
-               try {
-                       targetDatastore.createFolder();
-                       final FileObject sourceDataStore = fileSystemManager
-                                       .resolveFile(sourceDatastore);
-                       if (log.isDebugEnabled())
-                               log.debug("Backup " + sourceDatastore);
-                       targetDatastore.copyFrom(sourceDataStore, new FileSelector() {
-                               public boolean traverseDescendents(FileSelectInfo fileInfo)
-                                               throws Exception {
-                                       return true;
-                               }
-
-                               public boolean includeFile(FileSelectInfo fileInfo)
-                                               throws Exception {
-                                       String relativeName = fileInfo
-                                                       .getFile()
-                                                       .getName()
-                                                       .getPath()
-                                                       .substring(
-                                                                       sourceDataStore.getName().getPath()
-                                                                                       .length());
-                                       FileObject target = targetDatastore
-                                                       .resolveFile(relativeName);
-                                       if (target.exists()) {
-                                               return false;
-                                       } else {
-                                               return true;
-                                       }
-                               }
-                       });
-                       if (log.isDebugEnabled())
-                               log.debug("Backed-up " + sourceDatastore);
-               } catch (FileSystemException e) {
-                       throw new SlcException("Cannot backup datastore", e);
-               }
-       }
-
-       public void setSourceRepo(String sourceRepo) {
-               this.sourceRepo = sourceRepo;
-       }
-
-       public void setSourceWksp(String sourceWksp) {
-               this.sourceWksp = sourceWksp;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setSourceUsername(String sourceUsername) {
-               this.sourceUsername = sourceUsername;
-       }
-
-       public void setSourcePassword(char[] sourcePassword) {
-               this.sourcePassword = sourcePassword;
-       }
-
-       public void setFileSystemManager(FileSystemManager fileSystemManager) {
-               this.fileSystemManager = fileSystemManager;
-       }
-
-       public void setTargetFile(String targetFile) {
-               this.targetFile = targetFile;
-       }
-
-       public void setSourceDatastore(String sourceDatastore) {
-               this.sourceDatastore = sourceDatastore;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRedhatDeploymentData.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRedhatDeploymentData.java
deleted file mode 100644 (file)
index e93b99b..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.argeo.slc.lib.linux;
-
-import org.argeo.slc.core.deploy.MultiResourceSet;
-import org.argeo.slc.core.deploy.ResourceSet;
-
-public class DefaultRedhatDeploymentData implements RedhatDeploymentData {
-       private ResourceSet configurationFiles;
-       private String runlevelsScript;
-       private String permissionsScript;
-
-       private RedhatDeploymentData parent;
-
-       public ResourceSet getConfigurationFiles() {
-               if (parent != null && parent.getConfigurationFiles() != null) {
-                       MultiResourceSet mrs = new MultiResourceSet();
-                       mrs.getResourceSets().add(parent.getConfigurationFiles());
-                       mrs.getResourceSets().add(configurationFiles);
-                       return mrs;
-               } else {
-                       return configurationFiles;
-               }
-       }
-
-       public String getRunlevelsScript() {
-               if (parent != null && parent.getRunlevelsScript() != null)
-                       return parent.getRunlevelsScript() + "\n" + runlevelsScript;
-               else
-                       return runlevelsScript;
-       }
-
-       public String getPermissionsScript() {
-               if (parent != null && parent.getPermissionsScript() != null)
-                       return parent.getPermissionsScript() + "\n" + permissionsScript;
-               else
-                       return permissionsScript;
-       }
-
-       public void setRunlevelsScript(String runlevelsScript) {
-               this.runlevelsScript = runlevelsScript;
-       }
-
-       public void setConfigurationFiles(ResourceSet configurationFiles) {
-               this.configurationFiles = configurationFiles;
-       }
-
-       public void setPermissionsScript(String permissionsScript) {
-               this.permissionsScript = permissionsScript;
-       }
-
-       public void setParent(RedhatDeploymentData parentDeploymentData) {
-               this.parent = parentDeploymentData;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRpmDistribution.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRpmDistribution.java
deleted file mode 100644 (file)
index 5722bc1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.argeo.slc.lib.linux;
-
-import java.util.List;
-
-public class DefaultRpmDistribution implements RpmDistribution {
-       private List<String> additionalPackages;
-
-       public String getDistributionId() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public List<String> getAdditionalPackages() {
-               return additionalPackages;
-       }
-
-       public void setAdditionalPackages(List<String> additionalPackages) {
-               this.additionalPackages = additionalPackages;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DeployLxcContainer.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DeployLxcContainer.java
deleted file mode 100644 (file)
index 3325dc0..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.argeo.slc.lib.linux;
-
-import java.io.File;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-
-/** Deploy and initialize an LXC container. */
-public class DeployLxcContainer implements Runnable {
-
-       private String chroot;
-
-       private Resource hostScript = new ClassPathResource(
-                       "/org/argeo/slc/lib/linux/lxc-init-host.sh", getClass()
-                                       .getClassLoader());
-       private Resource guestScript = new ClassPathResource(
-                       "/org/argeo/slc/lib/linux/lxc-init-guest.sh", getClass()
-                                       .getClassLoader());;
-
-       // private CallbackHandler callbackHandler;
-
-       private Integer ram = 1024;
-       private Integer vcpu = 2;
-
-       @Override
-       public void run() {
-               if (chroot == null || chroot.trim().equals(""))
-                       throw new SlcException("A chroot directory must be defined");
-
-               File chrootDir = new File(chroot);
-               chrootDir.mkdirs();
-
-               ScriptCall hostCall = new ScriptCall(hostScript);
-               hostCall.setLogCommand(true);
-               hostCall.arg(chroot);
-               // hostCall.getEnvironmentVariables().put("CHROOT", chroot);
-               // hostCall.setSudo("");
-               // hostCall.setCallbackHandler(callbackHandler);
-               hostCall.run();
-
-               ScriptCall guestCall = new ScriptCall(guestScript);
-               guestCall.setLogCommand(true);
-               // guestCall.setSudo("");
-               // guestCall.setCallbackHandler(callbackHandler);
-               guestCall.setChroot(chroot);
-               guestCall.run();
-
-               SystemCall virtInstall = new SystemCall(
-                               "virt-install --connect lxc:/// --name " + chrootDir.getName()
-                                               + " --ram " + ram + " --vcpu " + vcpu
-                                               + " --filesystem " + chrootDir.getAbsolutePath()
-                                               + ",/ --noautoconsole");
-               virtInstall.setLogCommand(true);
-               // virtInstall.setSudo("");
-               virtInstall.run();
-       }
-
-       public void setChroot(String chroot) {
-               this.chroot = chroot;
-       }
-
-       public void setHostScript(Resource hostScript) {
-               this.hostScript = hostScript;
-       }
-
-       public void setGuestScript(Resource guestScript) {
-               this.guestScript = guestScript;
-       }
-
-       // public void setCallbackHandler(CallbackHandler callbackHandler) {
-       // this.callbackHandler = callbackHandler;
-       // }
-
-       public void setRam(Integer ram) {
-               this.ram = ram;
-       }
-
-       public void setVcpu(Integer vcpu) {
-               this.vcpu = vcpu;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatDeploymentData.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatDeploymentData.java
deleted file mode 100644 (file)
index 39592b7..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.lib.linux;
-
-import org.argeo.slc.core.deploy.ResourceSet;
-import org.argeo.slc.deploy.DeploymentData;
-
-public interface RedhatDeploymentData extends DeploymentData {
-       public ResourceSet getConfigurationFiles();
-
-       public String getRunlevelsScript();
-
-       public String getPermissionsScript();
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatHostManager.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatHostManager.java
deleted file mode 100644 (file)
index 8b1c5e5..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.argeo.slc.lib.linux;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.deploy.LocalFilesDeployment;
-import org.argeo.slc.core.deploy.ResourceSet;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.argeo.slc.jsch.RemoteExec;
-import org.argeo.slc.jsch.SshFilesDeployment;
-import org.argeo.slc.jsch.SshTarget;
-
-public class RedhatHostManager {
-
-       private SimpleLinuxHost host;
-
-       // SSH
-       private Boolean useSsh = true;
-       private SshTarget sshTarget = null;
-
-       public void installPackages() {
-               StringBuffer cmd = new StringBuffer("yum --nogpgcheck -y install");
-               for (String pkg : ((RpmDistribution) host.getDistribution())
-                               .getAdditionalPackages()) {
-                       cmd.append(' ').append(pkg);
-               }
-               executeCommand(cmd.toString());
-
-               RedhatDeploymentData rdd = (RedhatDeploymentData) host
-                               .getDeploymentData();
-               executeCommand(rdd.getRunlevelsScript());
-       }
-
-       public void deployConfig() {
-               RedhatDeploymentData rdd = (RedhatDeploymentData) host
-                               .getDeploymentData();
-               deploy(rdd.getConfigurationFiles());
-               executeCommand(rdd.getPermissionsScript());
-       }
-
-       // GENERIC?
-       protected void deploy(ResourceSet resourceSet) {
-               if (useSsh)
-                       new SshFilesDeployment(getSshTarget(), resourceSet).run();
-               else
-                       new LocalFilesDeployment(resourceSet).run();
-
-       }
-
-       protected void executeCommand(String command) {
-               if (command == null)
-                       return;
-
-               if (useSsh) {
-                       RemoteExec rExec = new RemoteExec(getSshTarget(), command);
-                       rExec.setFailOnBadExitStatus(false);
-                       rExec.run();
-               } else
-                       new SystemCall(command).run();
-       }
-
-       protected SshTarget getSshTarget() {
-               if (sshTarget == null)
-                       throw new SlcException("No SSH target defined");
-               return sshTarget;
-       }
-
-       public void setHost(SimpleLinuxHost host) {
-               this.host = host;
-       }
-
-       public void setUseSsh(Boolean useSsh) {
-               this.useSsh = useSsh;
-       }
-
-       public void setSshTarget(SshTarget sshTarget) {
-               this.sshTarget = sshTarget;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RpmDistribution.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RpmDistribution.java
deleted file mode 100644 (file)
index 66e7969..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.lib.linux;
-
-import java.util.List;
-
-import org.argeo.slc.build.Distribution;
-
-public interface RpmDistribution extends Distribution {
-       public List<String> getAdditionalPackages();
-
-       public void setAdditionalPackages(List<String> additionalPackages);
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/ScriptCall.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/ScriptCall.java
deleted file mode 100644 (file)
index 755fa0c..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.argeo.slc.lib.linux;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-/** Call to the interpreter of a script language. */
-public class ScriptCall extends SystemCall implements InitializingBean {
-       private Resource script;
-       private List<Object> scriptArgs = new ArrayList<Object>();
-
-       private Boolean localScriptCopy = false;
-
-       /** For use in Spring. */
-       public ScriptCall() {
-               super();
-       }
-
-       /** For use in code ({@link #init()} is called). */
-       public ScriptCall(Resource script) {
-               this.script = script;
-               init();
-       }
-
-       public void init() {
-               initInterpreter();
-               for (Object obj : scriptArgs) {
-                       arg(obj.toString());
-               }
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               init();
-       }
-
-       protected void initInterpreter() {
-               String ext = FilenameUtils.getExtension(script.getFilename());
-
-               if (localScriptCopy) {
-                       File scriptFile = copyScript();
-                       if ("sh".equals(ext))
-                               arg("/bin/sh").arg(scriptFile.getAbsolutePath());
-                       else if ("pl".equals(ext))
-                               arg("/usr/bin/perl").arg(scriptFile.getAbsolutePath());
-                       else if ("py".equals(ext))
-                               arg("/usr/bin/python").arg(scriptFile.getAbsolutePath());
-                       else
-                               throw new SlcException(
-                                               "Cannot initialize script intepreter for " + script);
-               } else {
-                       setStdInFile(script);
-                       if ("sh".equals(ext))
-                               arg("/bin/sh").arg("-s");
-                       else if ("pl".equals(ext))
-                               arg("/usr/bin/perl").arg("/dev/stdin");
-                       else if ("py".equals(ext))
-                               arg("/usr/bin/python").arg("-");
-                       else
-                               throw new SlcException(
-                                               "Cannot initialize script intepreter for " + script);
-               }
-       }
-
-       private File copyScript() {
-               InputStream in = null;
-               OutputStream out = null;
-               try {
-                       File scriptFile = File.createTempFile("script", ".sh");
-                       scriptFile.deleteOnExit();
-                       in = script.getInputStream();
-                       out = new FileOutputStream(scriptFile);
-                       IOUtils.copy(in, out);
-                       return scriptFile;
-               } catch (Exception e) {
-                       throw new SlcException("Cannot copy " + script, e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-                       IOUtils.closeQuietly(out);
-               }
-       }
-
-       public void setScript(Resource script) {
-               this.script = script;
-       }
-
-       public void setScriptArgs(List<Object> scriptArgs) {
-               this.scriptArgs = scriptArgs;
-       }
-
-       public void setLocalScriptCopy(Boolean localScriptCopy) {
-               this.localScriptCopy = localScriptCopy;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/SimpleLinuxHost.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/SimpleLinuxHost.java
deleted file mode 100644 (file)
index d51497a..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.argeo.slc.lib.linux;
-
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class SimpleLinuxHost implements DeployedSystem {
-       private DeploymentData deploymentData;
-       private Distribution distribution;
-       private TargetData targetData;
-
-       public String getDeployedSystemId() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public DeploymentData getDeploymentData() {
-               return deploymentData;
-       }
-
-       public void setDeploymentData(DeploymentData deploymentData) {
-               this.deploymentData = deploymentData;
-       }
-
-       public Distribution getDistribution() {
-               return distribution;
-       }
-
-       public void setDistribution(Distribution distribution) {
-               this.distribution = distribution;
-       }
-
-       public TargetData getTargetData() {
-               return targetData;
-       }
-
-       public void setTargetData(TargetData targetData) {
-               this.targetData = targetData;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-guest.sh b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-guest.sh
deleted file mode 100644 (file)
index 11ecc4e..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-echo demo | passwd root --stdin
-
-#Fix root login on console
-echo "pts/0" >>/etc/securetty
-sed -i s/"session    required     pam_selinux.so close"/"#session    required     pam_selinux.so close"/g /etc/pam.d/login
-sed -i s/"session    required     pam_selinux.so open"/"#session    required     pam_selinux.so open"/g /etc/pam.d/login
-sed -i s/"session    required     pam_loginuid.so"/"#session    required     pam_loginuid.so"/g /etc/pam.d/login
-
-#Configuring basic networking
-cat > /etc/sysconfig/network << EOF
-NETWORKING=yes
-HOSTNAME=demo
-EOF
-cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
-DEVICE=eth0
-BOOTPROTO=dhcp
-ONBOOT=yes
-EOF
-
-#Enabling sshd
-chkconfig sshd on
-
-# Fixing root login for sshd
-sed -i s/"session    required     pam_selinux.so close"/"#session    required     pam_selinux.so close"/g /etc/pam.d/sshd
-sed -i s/"session    required     pam_loginuid.so"/"#session    required     pam_loginuid.so"/g /etc/pam.d/sshd
-sed -i s/"session    required     pam_selinux.so open env_params"/"#session    required     pam_selinux.so open env_params"/g /etc/pam.d/sshd
-
-# Leaving the chroot'ed filesystem
-exit
\ No newline at end of file
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-host.sh b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-host.sh
deleted file mode 100644 (file)
index 9e0d75d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-CHROOT=$1
-echo Init LXC container $CHROOT
-
-mkdir $CHROOT/etc/yum.repos.d/ -p  
-cat /etc/yum.repos.d/CentOS-Base.repo |sed s/'$releasever'/6/g > $CHROOT/etc/yum.repos.d/CentOS-Base.repo
-yum groupinstall core --installroot=$CHROOT --nogpgcheck -y
-yum install plymouth libselinux-python --installroot=$CHROOT --nogpgcheck -y
\ No newline at end of file
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/redhat.xml b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/redhat.xml
deleted file mode 100644 (file)
index 8379b8a..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
-    Copyright (C) 2007-2012 Argeo GmbH\r
-\r
-    Licensed under the Apache License, Version 2.0 (the "License");\r
-    you may not use this file except in compliance with the License.\r
-    You may obtain a copy of the License at\r
-\r
-            http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-    Unless required by applicable law or agreed to in writing, software\r
-    distributed under the License is distributed on an "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-    See the License for the specific language governing permissions and\r
-    limitations under the License.\r
-\r
--->\r
-<!-- Copyright (C) 2007-2012 Mathieu Baudier Licensed under the Apache License, \r
-       Version 2.0 (the "License"); you may not use this file except in compliance \r
-       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 \r
-       Unless required by applicable law or agreed to in writing, software distributed \r
-       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES \r
-       OR CONDITIONS OF ANY KIND, either express or implied. See the License for \r
-       the specific language governing permissions and limitations under the License. -->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-1.2.xsd">\r
-\r
-       <bean id="hostManager" class="org.argeo.slc.lib.linux.RedhatHostManager">\r
-               <property name="sshTarget" ref="sshTarget" />\r
-               <property name="host" ref="host" />\r
-       </bean>\r
-\r
-       <!-- Execution Flows -->\r
-       <bean flow:as-flow="deployConfig" class="org.argeo.slc.core.execution.tasks.MethodCall"\r
-               p:target-ref="hostManager" p:method="deployConfig" />\r
-\r
-       <bean flow:as-flow="system/reboot" p:command="shutdown -r now"\r
-               p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec" />\r
-\r
-       <bean flow:as-flow="system/shutdown" p:command="shutdown -h now"\r
-               p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec" />\r
-\r
-       <bean flow:as-flow="system/packages/install" class="org.argeo.slc.core.execution.tasks.MethodCall"\r
-               p:target-ref="hostManager" p:method="installPackages" />\r
-\r
-       <bean flow:as-flow="system/packages/update" p:sshTarget-ref="sshTarget"\r
-               class="org.argeo.slc.jsch.RemoteExec">\r
-               <property name="systemCall">\r
-                       <bean class="org.argeo.slc.core.execution.tasks.SystemCall">\r
-                               <property name="cmd" value="yum -y update" />\r
-                       </bean>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean flow:as-flow="system/security/firewall" p:script="osgibundle:/scripts/firewall.sh"\r
-               p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec" />\r
-\r
-       <flow:flow name="system/security/authconfig">\r
-               <flow:spec>\r
-                       <flow:primitive name="ldapserver" />\r
-                       <flow:primitive name="ldapbasedn" />\r
-               </flow:spec>\r
-               <bean p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec">\r
-                       <flow:variable />\r
-                       <property name="systemCall">\r
-                               <bean class="org.argeo.slc.core.execution.tasks.SystemCall">\r
-                                       <property name="command">\r
-                                               <list>\r
-                                                       <value>authconfig</value>\r
-                                                       <value>--enableldap</value>\r
-                                                       <value>--enableldapauth</value>\r
-                                                       <value>--enablecache</value>\r
-                                                       <value>--enablemkhomedir</value>\r
-                                                       <value>--ldapserver=@{ldapserver}</value>\r
-                                                       <value>--ldapbasedn=@{ldapbasedn}</value>\r
-                                                       <value>--passalgo=sha256</value>\r
-                                                       <value>--updateall</value>\r
-                                               </list>\r
-                                       </property>\r
-                               </bean>\r
-                       </property>\r
-               </bean>\r
-       </flow:flow>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/BuildInMock.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/BuildInMock.java
deleted file mode 100644 (file)
index 44c4e0c..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.exec.Executor;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-
-/** Rebuild an SRPM in mock. (Historical) Replaces the build-mock.sh script. */
-public class BuildInMock implements Runnable {
-       private final static Log log = LogFactory.getLog(BuildInMock.class);
-
-       /** Mock flavour provided by the EPEL repository */
-       public final static String EPEL = "EPEL";
-       /** Mock flavour provided by CentOS until v5 */
-       public final static String CENTOS = "CENTOS";
-
-       public final static String NOARCH = "noarch";
-
-       private String mockVar = "/var/lib/mock";
-
-       private String mockFlavour = EPEL;
-       private String mockConfig = null;
-
-       private String repository;
-       private String release = null;
-       private String level = null;
-       private String arch = NOARCH;
-
-       private String rpmPackage = null;
-
-       private Boolean mkdirs = true;
-
-       private RpmBuildEnvironment buildEnvironment;
-       private Executor executor;
-
-       private String debuginfoDirName = "debuginfo";
-
-       public void run() {
-               // TODO check if caller is in mock group
-
-               String cfgId = repository + "-" + release + "-" + arch;
-               String cfg = mockConfig != null ? mockConfig : "slc/" + cfgId;
-
-               // prepare mock call
-               SystemCall mock = new SystemCall();
-               if (arch != null)
-                       mock.arg("setarch").arg(arch);
-               mock.arg("mock");
-               if (mockFlavour.equals(EPEL))
-                       mock.arg("-v");
-               else if (mockFlavour.equals(CENTOS))
-                       mock.arg("--debug");
-               if (arch != null)
-                       mock.arg("--arch=" + arch);
-               mock.arg("-r").arg(cfg);
-
-               mock.arg("--scm-enable");
-               mock.arg("--scm-option").arg("package=" + rpmPackage);
-
-               mock.setLogCommand(true);
-
-               // mock command execution
-               mock.setExecutor(executor);
-               mock.run();
-
-               // File repoDir = new File(buildEnvironment.getStagingBase() + "/"
-               // + repository + "/" + level + "/" + release);
-               File repoDir = new File(buildEnvironment.getStagingBase() + "/"
-                               + repository + "-" + release + "-staging");
-               File srpmDir = new File(repoDir, "SRPMS");
-               if (mkdirs)
-                       srpmDir.mkdirs();
-               File archDir = null;
-               File debuginfoDir = null;
-               if (!arch.equals(NOARCH)) {
-                       archDir = new File(repoDir, arch);
-                       debuginfoDir = new File(archDir, debuginfoDirName);
-                       debuginfoDir.mkdirs();
-               }
-
-               // copy RPMs
-               Set<File> reposToRecreate = new HashSet<File>();
-               File resultDir = new File(mockVar + "/" + cfgId + "/result");
-               rpms: for (File file : resultDir.listFiles()) {
-                       if (file.isDirectory())
-                               continue rpms;
-
-                       File[] targetDirs;
-                       if (file.getName().contains(".src.rpm"))
-                               targetDirs = new File[] { srpmDir };
-                       else if (file.getName().contains("-debuginfo-"))
-                               targetDirs = new File[] { debuginfoDir };
-                       else if (!arch.equals(NOARCH)
-                                       && file.getName().contains("." + arch + ".rpm"))
-                               targetDirs = new File[] { archDir };
-                       else if (file.getName().contains(".noarch.rpm")) {
-                               List<File> dirs = new ArrayList<File>();
-                               for (String arch : buildEnvironment.getArchs())
-                                       dirs.add(new File(repoDir, arch));
-                               targetDirs = dirs.toArray(new File[dirs.size()]);
-                       } else if (file.getName().contains(".rpm"))
-                               throw new SlcException("Don't know where to copy " + file);
-                       else {
-                               if (log.isTraceEnabled())
-                                       log.trace("Skip " + file);
-                               continue rpms;
-                       }
-
-                       reposToRecreate.addAll(Arrays.asList(targetDirs));
-                       copyToDirs(file, targetDirs);
-               }
-
-               // recreate changed repos
-               for (File repoToRecreate : reposToRecreate) {
-                       SystemCall createrepo = new SystemCall();
-                       createrepo.arg("createrepo");
-                       // sqllite db
-                       createrepo.arg("-d");
-                       // debuginfo
-                       if (!repoToRecreate.getName().equals(debuginfoDirName))
-                               createrepo.arg("-x").arg(debuginfoDirName + "/*");
-                       // quiet
-                       createrepo.arg("-q");
-                       createrepo.arg(repoToRecreate.getAbsolutePath());
-
-                       createrepo.setExecutor(executor);
-                       createrepo.run();
-                       log.info("Updated repo " + repoToRecreate);
-               }
-       }
-
-       protected void copyToDirs(File file, File[] dirs) {
-               for (File dir : dirs) {
-                       try {
-                               FileUtils.copyFileToDirectory(file, dir);
-                               if (log.isDebugEnabled())
-                                       log.debug(file + " => " + dir);
-                       } catch (IOException e) {
-                               throw new SlcException("Cannot copy " + file + " to " + dir, e);
-                       }
-               }
-       }
-
-       public void setMockFlavour(String mockFlavour) {
-               this.mockFlavour = mockFlavour;
-       }
-
-       public void setMockConfig(String mockConfig) {
-               this.mockConfig = mockConfig;
-       }
-
-       public void setRepository(String repo) {
-               this.repository = repo;
-       }
-
-       public void setRelease(String release) {
-               this.release = release;
-       }
-
-       public void setLevel(String level) {
-               this.level = level;
-       }
-
-       public void setArch(String arch) {
-               this.arch = arch;
-       }
-
-       public void setRpmPackage(String rpmPackage) {
-               this.rpmPackage = rpmPackage;
-       }
-
-       public void setMockVar(String mockVar) {
-               this.mockVar = mockVar;
-       }
-
-       public void setMkdirs(Boolean mkdirs) {
-               this.mkdirs = mkdirs;
-       }
-
-       public void setBuildEnvironment(RpmBuildEnvironment buildEnvironment) {
-               this.buildEnvironment = buildEnvironment;
-       }
-
-       public void setExecutor(Executor executor) {
-               this.executor = executor;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/CreateSrpm.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/CreateSrpm.java
deleted file mode 100644 (file)
index 04680df..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.exec.Executor;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.UrlResource;
-
-/** Generates an SRPM from a spec file */
-public class CreateSrpm implements Runnable {
-       private final static Log log = LogFactory.getLog(CreateSrpm.class);
-
-       private File topdir;
-
-       /** Directory where to cache downloaded distributions. */
-       private File distributionCache;
-
-       private Resource specFile;
-
-       private RpmBuildEnvironment rpmBuildEnvironment;
-
-       private Boolean overwriteSources = false;
-
-       private File srpmFile;
-
-       private Executor executor;
-
-       public void run() {
-               File sourcesDir = new File(topdir, "SOURCES");
-               sourcesDir.mkdirs();
-               File specsDir = new File(topdir, "SPECS");
-               File srpmsDir = new File(topdir, "SRPMS");
-
-               try {
-                       // Parse spec file and copy required resources
-                       RpmSpecFile spec = new RpmSpecFile(specFile);
-                       copyToSources(spec, sourcesDir);
-
-                       // Copy spec file
-                       File targetFile = new File(specsDir, specFile.getFilename())
-                                       .getCanonicalFile();
-                       copyResourceToFile(specFile, targetFile);
-
-                       // Generate rpmbuild config files
-                       rpmBuildEnvironment.writeRpmbuildConfigFiles(topdir);
-
-                       // Build SRPM
-                       srpmsDir.mkdirs();
-                       SystemCall packageSrpm = new SystemCall();
-                       packageSrpm.arg("rpmbuild");
-                       packageSrpm.arg("-bs").arg("--nodeps");
-                       packageSrpm.arg("--rcfile=rpmrc");
-                       packageSrpm.arg("--macros=" + RpmBuildEnvironment.defaultMacroFiles
-                                       + ":rpmmacros");
-                       // buildSrpm.arg("-D", "_topdir " + topdir.getCanonicalPath() + "");
-                       packageSrpm.arg("SPECS/" + specFile.getFilename());
-                       packageSrpm.setExecDir(topdir.getCanonicalPath());
-                       packageSrpm.setLogCommand(true);
-
-                       // Execute
-                       packageSrpm.setExecutor(executor);
-                       String answer = packageSrpm.function();
-
-                       // Extract generated SRPM path
-                       // TODO: make it safer
-                       String srpmPath = answer.split(":")[1].trim();
-                       srpmFile = new File(srpmPath);
-               } catch (IOException e) {
-                       throw new SlcException("Cannot generate SRPM from " + specFile, e);
-               }
-
-       }
-
-       protected void copyToSources(RpmSpecFile spec, File sourcesDir) {
-               try {
-                       List<Resource> toCopyToSources = new ArrayList<Resource>();
-                       List<Resource> toDownload = new ArrayList<Resource>();
-                       for (String file : spec.getSources().values()) {
-                               try {
-                                       Resource res;
-                                       try {
-                                               res = specFile.createRelative("../SOURCES/" + file);
-                                               if (!res.exists())
-                                                       res = new UrlResource(file);
-
-                                       } catch (Exception e) {
-                                               res = new UrlResource(file);
-                                               toDownload.add(res);
-                                       }
-                                       toCopyToSources.add(res);
-                               } catch (Exception e) {
-                                       log.error("Cannot interpret " + file, e);
-                               }
-                       }
-                       for (String file : spec.getPatches().values()) {
-                               try {
-                                       Resource res;
-                                       try {
-                                               res = specFile.createRelative("../SOURCES/" + file);
-                                               if (!res.exists()) {
-                                                       res = new UrlResource(file);
-                                               }
-                                       } catch (Exception e) {
-                                               res = new UrlResource(file);
-                                               toDownload.add(res);
-                                       }
-                                       toCopyToSources.add(res);
-                               } catch (Exception e) {
-                                       log.error("Cannot interpret " + file, e);
-                               }
-                       }
-
-                       // FIXME: we may have missed some files here
-                       for (Resource res : toCopyToSources) {
-                               File targetDir;
-                               if (distributionCache != null && toDownload.contains(res)) {
-                                       if (!distributionCache.exists())
-                                               distributionCache.mkdirs();
-                                       targetDir = distributionCache;
-                                       if (log.isDebugEnabled())
-                                               log.debug("Cache " + res + " in " + targetDir);
-                               } else
-                                       targetDir = sourcesDir;
-                               File targetFile = new File(targetDir, res.getFilename())
-                                               .getCanonicalFile();
-                               if (!targetFile.exists() || overwriteSources)
-                                       copyResourceToFile(res, targetFile);
-                               if (!targetDir.equals(sourcesDir)) {
-                                       File fileInSourcesDir = new File(sourcesDir,
-                                                       targetFile.getName());
-                                       if (!fileInSourcesDir.exists()
-                                                       || !(fileInSourcesDir.length() == targetFile
-                                                                       .length()))
-                                               FileUtils.copyFile(targetFile, fileInSourcesDir);
-                               }
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot copy to " + sourcesDir, e);
-               }
-       }
-
-       private static void copyResourceToFile(Resource res, File targetFile) {
-               try {
-                       if (targetFile.equals(res.getFile())) {
-                               if (log.isDebugEnabled())
-                                       log.debug("Target identical to source, skipping... "
-                                                       + targetFile + " <=> " + res);
-                               return;
-                       }
-               } catch (IOException e1) {
-                       // silent
-               }
-
-               OutputStream out = null;
-               InputStream in = null;
-               try {
-                       out = FileUtils.openOutputStream(targetFile);
-                       in = res.getInputStream();
-                       IOUtils.copy(in, out);
-                       if (log.isDebugEnabled())
-                               log.debug("Copied " + targetFile + " from " + res);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot copy " + res + " to " + targetFile,
-                                       e);
-               } finally {
-                       IOUtils.closeQuietly(in);
-                       IOUtils.closeQuietly(out);
-               }
-
-       }
-
-       public void setSpecFile(Resource specFile) {
-               this.specFile = specFile;
-       }
-
-       public void setTopdir(File topdir) {
-               this.topdir = topdir;
-       }
-
-       public void setOverwriteSources(Boolean overwriteSources) {
-               this.overwriteSources = overwriteSources;
-       }
-
-       public File getSrpmFile() {
-               return srpmFile;
-       }
-
-       public void setRpmBuildEnvironment(RpmBuildEnvironment rpmBuildEnvironment) {
-               this.rpmBuildEnvironment = rpmBuildEnvironment;
-       }
-
-       public void setDistributionCache(File distributionCache) {
-               this.distributionCache = distributionCache;
-       }
-
-       public void setExecutor(Executor executor) {
-               this.executor = executor;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/ImportSrpm.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/ImportSrpm.java
deleted file mode 100644 (file)
index e005608..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.File;
-
-import org.argeo.slc.core.execution.tasks.SystemCall;
-
-/** Install an SRPM into a working copy */
-public class ImportSrpm implements Runnable {
-       private File baseDir;
-       private File srpmFile;
-       private RpmBuildEnvironment rpmBuildEnvironment;
-
-       public void run() {
-               SystemCall rpmQuery = new SystemCall(
-                               "rpm --queryformat '%{NAME}\n' -qp " + srpmFile);
-               String packageName = rpmQuery.function();
-
-               File topdir = new File(baseDir, packageName);
-
-               // prepare SVN
-               // TODO: do it with SVNKit
-               topdir.mkdirs();
-               new SystemCall("svn add " + topdir).run();
-               new SystemCall("svn propset svn:ignore rpm*\nBUILD\nSRPMS\nRPMS " + topdir).run();
-               File sourcesDir = new File(topdir, "SOURCES");
-               sourcesDir.mkdirs();
-               new SystemCall("svn add " + sourcesDir).run();
-               new SystemCall("svn propset svn:ignore *gz\n*bz2\n*.zip\n*.jar " + sourcesDir).run();
-               File specsDir = new File(topdir, "SPECS");
-               specsDir.mkdirs();
-               new SystemCall("svn add " + specsDir).run();
-
-               // Write rpm config files
-               File rpmmacroFile = new File(topdir, "rpmmacros");
-               File rpmrcFile = new File(topdir, "rpmrc");
-               rpmBuildEnvironment.writeRpmbuildConfigFiles(topdir, rpmmacroFile,
-                               rpmrcFile);
-
-               // Install SRPM
-               SystemCall installSrpm = new SystemCall();
-               installSrpm.arg("rpm");
-               installSrpm.arg("-Uvh");
-               installSrpm.arg("--rcfile=" + rpmrcFile.getAbsolutePath());
-               installSrpm.arg(srpmFile.getAbsolutePath());
-               installSrpm.setExecDir(topdir.getAbsolutePath());
-               installSrpm.setLogCommand(true);
-               installSrpm.run();
-       }
-
-       public void setBaseDir(File basedir) {
-               this.baseDir = basedir;
-       }
-
-       public void setSrpmFile(File srpmFile) {
-               this.srpmFile = srpmFile;
-       }
-
-       public void setRpmBuildEnvironment(RpmBuildEnvironment rpmBuildEnvironment) {
-               this.rpmBuildEnvironment = rpmBuildEnvironment;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmBuildEnvironment.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmBuildEnvironment.java
deleted file mode 100644 (file)
index 17a1f27..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.io.FileUtils;
-import org.argeo.slc.SlcException;
-
-/**
- * Defines a build environment. This information is typically used by other
- * components performing the various actions related to RPM build.
- */
-public class RpmBuildEnvironment {
-       static String defaultMacroFiles = "/usr/lib/rpm/macros:/usr/lib/rpm/ia32e-linux/macros:/usr/lib/rpm/redhat/macros:/etc/rpm/macros.*:/etc/rpm/macros:/etc/rpm/ia32e-linux/macros:~/.rpmmacros";
-
-       private Map<String, String> rpmmacros = new HashMap<String, String>();
-
-       private List<String> archs = new ArrayList<String>();
-
-       private String stagingBase = "/mnt/slc/repos/rpm";
-
-       /** Write (topdir)/rpmmacros and (topdir)/rpmrc */
-       public void writeRpmbuildConfigFiles(File topdir) {
-               writeRpmbuildConfigFiles(topdir, new File(topdir, "rpmmacros"),
-                               new File(topdir, "rpmrc"));
-       }
-
-       public void writeRpmbuildConfigFiles(File topdir, File rpmmacroFile,
-                       File rpmrcFile) {
-               try {
-                       List<String> macroLines = new ArrayList<String>();
-                       macroLines.add("%_topdir " + topdir.getCanonicalPath());
-                       for (String macroKey : rpmmacros.keySet()) {
-                               macroLines.add(macroKey + " " + rpmmacros.get(macroKey));
-                       }
-                       FileUtils.writeLines(rpmmacroFile, macroLines);
-
-                       List<String> rpmrcLines = new ArrayList<String>();
-                       rpmrcLines.add("include: /usr/lib/rpm/rpmrc");
-                       rpmrcLines.add("macrofiles: " + defaultMacroFiles + ":"
-                                       + rpmmacroFile.getCanonicalPath());
-                       FileUtils.writeLines(rpmrcFile, rpmrcLines);
-               } catch (IOException e) {
-                       throw new SlcException("Cannot write rpmbuild config files", e);
-               }
-
-       }
-
-       public Map<String, String> getRpmmacros() {
-               return rpmmacros;
-       }
-
-       public void setRpmmacros(Map<String, String> rpmmacros) {
-               this.rpmmacros = rpmmacros;
-       }
-
-       public String getDefaultMacroFiles() {
-               return defaultMacroFiles;
-       }
-
-       public void setDefaultMacroFiles(String defaultMacroFiles) {
-               this.defaultMacroFiles = defaultMacroFiles;
-       }
-
-       public void setArchs(List<String> archs) {
-               this.archs = archs;
-       }
-
-       public List<String> getArchs() {
-               return archs;
-       }
-
-       public String getStagingBase() {
-               return stagingBase;
-       }
-
-       public void setStagingBase(String stagingBase) {
-               this.stagingBase = stagingBase;
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmSpecFile.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmSpecFile.java
deleted file mode 100644 (file)
index 899603a..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.io.IOUtils;
-import org.springframework.core.io.Resource;
-
-public class RpmSpecFile {
-       private Resource specFile;
-
-       private String name;
-       private String version;
-       private String release;
-       private Map<String, String> sources = new HashMap<String, String>();
-       private Map<String, String> patches = new HashMap<String, String>();
-
-       public RpmSpecFile(Resource specFile) {
-               this.specFile = specFile;
-               parseSpecFile();
-       }
-
-       public void init() {
-               parseSpecFile();
-       }
-
-       @SuppressWarnings("unchecked")
-       protected void parseSpecFile() {
-               try {
-                       List<String> lines = (List<String>) IOUtils.readLines(specFile
-                                       .getInputStream());
-
-                       lines: for (String line : lines) {
-                               int indexSemiColon = line.indexOf(':');
-                               if (indexSemiColon <= 0)
-                                       continue lines;
-                               String directive = line.substring(0, indexSemiColon).trim();
-                               String value = line.substring(indexSemiColon + 1).trim();
-                               if ("name".equals(directive.toLowerCase()))
-                                       name = value;
-                               else if ("version".equals(directive.toLowerCase()))
-                                       version = value;
-                               else if ("release".equals(directive.toLowerCase()))
-                                       release = value;
-                               else if (directive.toLowerCase().startsWith("source"))
-                                       sources.put(directive, interpret(value));
-                               else if (directive.toLowerCase().startsWith("patch"))
-                                       patches.put(directive, interpret(value));
-                       }
-
-               } catch (IOException e) {
-                       throw new RuntimeException("Cannot parse spec file " + specFile, e);
-               }
-       }
-
-       protected String interpret(String value) {
-               StringBuffer buf = new StringBuffer(value.length());
-               StringBuffer currKey = null;
-               boolean mayBeKey = false;
-               chars: for (char c : value.toCharArray()) {
-                       if (c == '%')
-                               mayBeKey = true;
-                       else if (c == '{') {
-                               if (mayBeKey)
-                                       currKey = new StringBuffer();
-                       } else if (c == '}') {
-                               if (currKey == null)
-                                       continue chars;
-                               String key = currKey.toString();
-                               if ("name".equals(key.toLowerCase()))
-                                       buf.append(name);
-                               else if ("version".equals(key.toLowerCase()))
-                                       buf.append(version);
-                               else
-                                       buf.append("%{").append(key).append('}');
-                               currKey = null;
-                       } else {
-                               if (currKey != null)
-                                       currKey.append(c);
-                               else
-                                       buf.append(c);
-                       }
-               }
-               return buf.toString();
-       }
-
-       public Resource getSpecFile() {
-               return specFile;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       public String getRelease() {
-               return release;
-       }
-
-       public Map<String, String> getSources() {
-               return sources;
-       }
-
-       public Map<String, String> getPatches() {
-               return patches;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxMachine.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxMachine.java
deleted file mode 100644 (file)
index 2b561b6..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.argeo.slc.lib.vbox;
-
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-import org.springframework.beans.factory.BeanNameAware;
-import org.springframework.beans.factory.InitializingBean;
-
-public class VBoxMachine implements DeployedSystem, BeanNameAware,
-               InitializingBean {
-       private String deployedSystemId = null;
-       private String name;
-       private String beanName;
-
-       public String getDeployedSystemId() {
-               return deployedSystemId;
-       }
-
-       public DeploymentData getDeploymentData() {
-               throw new UnsupportedException();
-       }
-
-       public Distribution getDistribution() {
-               throw new UnsupportedException();
-       }
-
-       public TargetData getTargetData() {
-               throw new UnsupportedException();
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public void setDeployedSystemId(String deployedSystemId) {
-               this.deployedSystemId = deployedSystemId;
-       }
-
-       public void setBeanName(String beanName) {
-               this.beanName = name;
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               if (name == null)
-                       name = beanName;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxManager.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxManager.java
deleted file mode 100644 (file)
index 9992d77..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-package org.argeo.slc.lib.vbox;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.core.io.Resource;
-
-public class VBoxManager {
-       private final static Log log = LogFactory.getLog(VBoxManager.class);
-
-       private VBoxMachine vm;
-       private String executable = "VBoxManage";
-
-       private List<VBoxNat> nats = new ArrayList<VBoxNat>();
-
-       public void importOvf(Resource ovfDefinition) {
-               try {
-                       List<Object> cmd = new ArrayList<Object>();
-                       cmd.add(executable);
-                       cmd.add("import");
-                       cmd.add(ovfDefinition.getFile().getCanonicalPath());
-                       cmd.add("--vsys 0 --vmname <name>");
-                       cmd.add("0");
-                       cmd.add("--vmname");
-                       cmd.add(vm.getName());
-                       new SystemCall(cmd).run();
-               } catch (IOException e) {
-                       throw new SlcException("Cannot import OVF appliance "
-                                       + ovfDefinition, e);
-               }
-       }
-
-       public void startVm() {
-               startVm("gui");
-       }
-
-       public void startVmHeadless() {
-               startVm("vrdp");
-       }
-
-       public void startVm(String type) {
-               List<Object> cmd = new ArrayList<Object>();
-               cmd.add(executable);
-               cmd.add("startvm");
-               cmd.add(vm.getName());
-               cmd.add("--type");
-               cmd.add(type);
-               new SystemCall(cmd).run();
-       }
-
-       public void applyNats() {
-               StringBuffer script = new StringBuffer("");
-               for (VBoxNat vBoxNat : nats) {
-                       for (String id : vBoxNat.getMappings().keySet()) {
-                               VBoxPortMapping mapping = vBoxNat.getMappings().get(id);
-
-                               // Try to delete rule first
-                               try {
-                                       StringBuffer delCmd = new StringBuffer(
-                                                       "VBoxManage modifyvm");
-                                       delCmd.append(" \"").append(vm.getName()).append("\"");
-                                       delCmd.append(" --natpf").append(vBoxNat.getDevice())
-                                                       .append(" ");
-                                       delCmd.append(" delete ");
-                                       delCmd.append("\"").append(id).append("\"");
-                                       new SystemCall(delCmd.toString()).run();
-                                       script.append(delCmd).append("\n");
-                               } catch (Exception e) {
-                                       // silent
-                               }
-
-                               StringBuffer cmd = new StringBuffer("VBoxManage modifyvm");
-                               cmd.append(" \"").append(vm.getName()).append("\"");
-                               cmd.append(" --natpf").append(vBoxNat.getDevice()).append(" ");
-                               cmd.append("\"");
-                               cmd.append(id).append(",");
-                               cmd.append(mapping.getProtocol()).append(",");
-                               cmd.append(",");
-                               cmd.append(mapping.getHostPort()).append(",");
-                               cmd.append(vBoxNat.getGuestIp()).append(",");
-                               cmd.append(mapping.getGuestPort());
-                               cmd.append("\"");
-
-                               new SystemCall(cmd.toString()).run();
-                               script.append(cmd).append("\n");
-
-                               // Older VirtualBox
-                               // new SystemCall(createNatCommand(id, vBoxNat.getDevice(),
-                               // "Protocol", mapping.getProtocol(), script)).run();
-                               // script.append('\n');
-                               // new SystemCall(createNatCommand(id, vBoxNat.getDevice(),
-                               // "GuestPort", mapping.getGuest(), script)).run();
-                               // script.append('\n');
-                               // new SystemCall(createNatCommand(id, vBoxNat.getDevice(),
-                               // "HostPort", mapping.getHost(), script)).run();
-                               // script.append('\n');
-                               // script.append('\n');
-                       }
-                       script.append('\n');
-               }
-
-               if (log.isDebugEnabled())
-                       log.debug("Port setting script:\n" + script);
-       }
-
-       protected List<Object> createNatCommand(String id, String device,
-                       String cfgKey, String value, StringBuffer script) {
-               List<Object> cmd = new ArrayList<Object>();
-               cmd.add(executable);
-               cmd.add("setextradata");
-               cmd.add(vm.getName());
-               cmd.add("VBoxInternal/Devices/" + device + "/0/LUN#0/Config/" + id
-                               + "/" + cfgKey);
-               cmd.add(value);
-
-               for (Object arg : cmd) {
-                       script.append(arg).append(' ');
-               }
-
-               return cmd;
-       }
-
-       public String getExecutable() {
-               return executable;
-       }
-
-       public void setExecutable(String executable) {
-               this.executable = executable;
-       }
-
-       public List<VBoxNat> getNats() {
-               return nats;
-       }
-
-       public void setNats(List<VBoxNat> boxNats) {
-               nats = boxNats;
-       }
-
-       public void setVm(VBoxMachine vm) {
-               this.vm = vm;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxNat.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxNat.java
deleted file mode 100644 (file)
index 2661009..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.argeo.slc.lib.vbox;
-
-import java.util.Map;
-
-/** The NAT mapping table */
-public class VBoxNat {
-       private String device = "1";
-       private String guestIp = "";
-       private Map<String, VBoxPortMapping> mappings;
-
-       public String getDevice() {
-               return device;
-       }
-
-       public void setDevice(String device) {
-               this.device = device;
-       }
-
-       public Map<String, VBoxPortMapping> getMappings() {
-               return mappings;
-       }
-
-       public void setMappings(Map<String, VBoxPortMapping> mappings) {
-               this.mappings = mappings;
-       }
-
-       public String getGuestIp() {
-               return guestIp;
-       }
-
-       public void setGuestIp(String guestIp) {
-               this.guestIp = guestIp;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxPortMapping.java b/cms/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxPortMapping.java
deleted file mode 100644 (file)
index 64ec866..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.argeo.slc.lib.vbox;
-
-/** The mapping of one port. */
-public class VBoxPortMapping {
-       private String protocol = "TCP";
-       private String guestPort;
-       private String hostPort;
-
-       public String getProtocol() {
-               return protocol;
-       }
-
-       public void setProtocol(String type) {
-               this.protocol = type;
-       }
-
-       public String getGuestPort() {
-               return guestPort;
-       }
-
-       public void setGuestPort(String guestPort) {
-               this.guestPort = guestPort;
-       }
-
-       public String getHostPort() {
-               return hostPort;
-       }
-
-       public void setHostPort(String hostPort) {
-               this.hostPort = hostPort;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/log4j/SlcExecutionAppender.java b/cms/org.argeo.slc.support/src/org/argeo/slc/log4j/SlcExecutionAppender.java
deleted file mode 100644 (file)
index 2a9ea5f..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.argeo.slc.log4j;
-
-import java.util.Date;
-import java.util.concurrent.BlockingQueue;
-
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-import org.argeo.slc.execution.ExecutionStep;
-import org.argeo.slc.runtime.ExecutionThread;
-import org.argeo.slc.runtime.ProcessThreadGroup;
-
-/** Not meant to be used directly in standard log4j config */
-public class SlcExecutionAppender extends AppenderSkeleton {
-
-       private Boolean disabled = false;
-
-       private String level = null;
-
-       private Level log4jLevel = null;
-
-       /** Marker to prevent stack overflow */
-       private ThreadLocal<Boolean> dispatching = new ThreadLocal<Boolean>() {
-
-               @Override
-               protected Boolean initialValue() {
-                       return false;
-               }
-       };
-
-       // private Layout layout = null;
-       // private String pattern = "%m - %c%n";
-       private Boolean onlyExecutionThread = false;
-
-       public void init() {
-               // if (layout != null)
-               // setLayout(layout);
-               // else
-               // setLayout(new PatternLayout(pattern));
-               Logger.getRootLogger().addAppender(this);
-       }
-
-       @Override
-       protected void append(LoggingEvent event) {
-               if (disabled)
-                       return;
-
-               if (dispatching.get())
-                       return;
-
-               if (level != null && !level.trim().equals("")) {
-                       if (log4jLevel == null || !log4jLevel.toString().equals(level))
-                               try {
-                                       log4jLevel = Level.toLevel(level);
-                               } catch (Exception e) {
-                                       System.err.println("Log4j level could not be set for level '" + level + "', resetting it to null.");
-                                       e.printStackTrace();
-                                       level = null;
-                               }
-
-                       if (log4jLevel != null && !event.getLevel().isGreaterOrEqual(log4jLevel)) {
-                               return;
-                       }
-               }
-
-               // Check whether we are within an executing process
-               Thread currentThread = Thread.currentThread();
-               if (currentThread.getThreadGroup() instanceof ProcessThreadGroup) {
-                       if (onlyExecutionThread && !(currentThread instanceof ExecutionThread))
-                               return;
-
-                       final String type;
-                       if (event.getLevel().equals(Level.ERROR) || event.getLevel().equals(Level.FATAL))
-                               type = ExecutionStep.ERROR;
-                       else if (event.getLevel().equals(Level.WARN))
-                               type = ExecutionStep.WARNING;
-                       else if (event.getLevel().equals(Level.INFO))
-                               type = ExecutionStep.INFO;
-                       else if (event.getLevel().equals(Level.DEBUG))
-                               type = ExecutionStep.DEBUG;
-                       else if (event.getLevel().equals(Level.TRACE))
-                               type = ExecutionStep.TRACE;
-                       else
-                               type = ExecutionStep.INFO;
-
-                       ExecutionStep step = new ExecutionStep(event.getLoggerName(), new Date(event.getTimeStamp()), type,
-                                       event.getMessage().toString());
-
-                       try {
-                               dispatching.set(true);
-                               BlockingQueue<ExecutionStep> steps = ((ProcessThreadGroup) currentThread.getThreadGroup()).getSteps();
-                               if (steps.remainingCapacity() == 0) {
-                                       stdOut("WARNING: execution steps queue is full, skipping step: " + step);
-                                       // FIXME understand why it block indefinitely: the queue
-                                       // should be emptied by the logging thread
-                               } else {
-                                       steps.add(step);
-                               }
-                       } finally {
-                               dispatching.set(false);
-                       }
-               }
-       }
-
-       public void destroy() throws Exception {
-               Logger.getRootLogger().removeAppender(this);
-       }
-
-       public void close() {
-       }
-
-       public boolean requiresLayout() {
-               return false;
-       }
-
-       // public void setLayout(Layout layout) {
-       // this.layout = layout;
-       // }
-
-       /** For development purpose, since using regular logging is not easy here */
-       static void stdOut(Object obj) {
-               System.out.println(obj);
-       }
-
-       // public void setPattern(String pattern) {
-       // this.pattern = pattern;
-       // }
-
-       public void setOnlyExecutionThread(Boolean onlyExecutionThread) {
-               this.onlyExecutionThread = onlyExecutionThread;
-       }
-
-       public void setDisabled(Boolean disabled) {
-               this.disabled = disabled;
-       }
-
-       public void setLevel(String level) {
-               this.level = level;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/mail/SendMail.java b/cms/org.argeo.slc.support/src/org/argeo/slc/mail/SendMail.java
deleted file mode 100644 (file)
index db4ab45..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.argeo.slc.mail;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.mail.Message;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-
-/** Sends a mail via JavaMail, local mail command or Google Mail. */
-public class SendMail implements Runnable {
-       // See:
-       // http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailUsage
-       // http://java.sun.com/products/javamail/FAQ.html#gmail
-
-       private final static Log log = LogFactory.getLog(SendMail.class);
-
-       private String host;
-       private String from;
-       private String to;
-       private String subject;
-       private String text;
-       private String username;
-       private String password;
-       private Map<String, String> javaMailProperties = new HashMap<String, String>();
-
-       public void run() {
-               if ("local".equals(host))
-                       sendWithMailCommand();
-               else if ("smtp.gmail.com".equals(host))
-                       sendWithGMail();
-               else
-                       sendWithJavaMail();
-       }
-
-       protected void sendWithMailCommand() {
-               SystemCall mail = new SystemCall("mail");
-               mail.arg("-s", subject).arg(to);
-               mail.run();
-               if (log.isDebugEnabled())
-                       log.debug("Sent mail to " + to + " with OS mail command");
-       }
-
-       protected void sendWithJavaMail() {
-               try {
-                       // Get system properties
-                       Properties props = System.getProperties();
-
-                       // Setup mail server
-                       props.put("mail.smtp.host", host);
-
-                       for (String key : javaMailProperties.keySet())
-                               props.put(key, javaMailProperties.get(key));
-
-                       // Get session
-                       Session session = Session.getDefaultInstance(props, null);
-
-                       // Define message
-                       MimeMessage message = new MimeMessage(session);
-                       buildJavaMailMessage(message);
-
-                       // Send message
-                       Transport.send(message);
-                       if (log.isDebugEnabled())
-                               log.debug("Sent mail to " + to + " with JavaMail");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot send message.", e);
-               }
-       }
-
-       protected void sendWithGMail() {
-               try {
-                       Properties props = new Properties();
-                       props.put("mail.smtps.auth", "true");
-                       props.put("mail.smtps.host", host);
-                       Session session = Session.getDefaultInstance(props, null);
-                       MimeMessage message = new MimeMessage(session);
-                       buildJavaMailMessage(message);
-                       Transport t = session.getTransport("smtps");
-                       try {
-                               t.connect(host, username, password);
-                               t.sendMessage(message, message.getAllRecipients());
-                       } finally {
-                               t.close();
-                       }
-                       if (log.isDebugEnabled())
-                               log.debug("Sent mail to " + to + " with Google Mail");
-               } catch (Exception e) {
-                       throw new SlcException("Cannot send message.", e);
-               }
-       }
-
-       protected void buildJavaMailMessage(Message message) throws Exception {
-               message.setFrom(new InternetAddress(from));
-               message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
-               message.setSubject(subject);
-               message.setText(text);
-       }
-
-       public void setHost(String host) {
-               this.host = host;
-       }
-
-       public void setFrom(String from) {
-               this.from = from;
-       }
-
-       public void setTo(String to) {
-               this.to = to;
-       }
-
-       public void setSubject(String subject) {
-               this.subject = subject;
-       }
-
-       public void setText(String text) {
-               this.text = text;
-       }
-
-       public void setJavaMailProperties(Map<String, String> javaMailProperties) {
-               this.javaMailProperties = javaMailProperties;
-       }
-
-       public void setUsername(String username) {
-               this.username = username;
-       }
-
-       public void setPassword(String password) {
-               this.password = password;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationDeployment.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationDeployment.java
deleted file mode 100644 (file)
index 804f280..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import java.io.File;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployEnvironment;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.Deployment;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdApplicationDeployment implements Deployment {
-       private static final Log log = LogFactory
-                       .getLog(HttpdApplicationDeployment.class);
-
-       private HttpdApplicationTargetData targetData;
-       private DeploymentData deploymentData;
-       private SimpleHttpdApplication deployedSystem;
-       private Distribution distribution;
-
-       private DeployEnvironment deployEnvironment;
-
-       public void run() {
-               try {
-                       deployEnvironment.unpackTo(distribution, targetData
-                                       .getTargetRootLocation(), null);
-
-                       // FIXME: make it generic
-                       String deployDataPath = targetData.getTargetRootLocation()
-                                       .getCanonicalPath();
-
-                       deployEnvironment.unpackTo(deploymentData,
-                                       new File(deployDataPath), null);
-                       deployedSystem = new SimpleHttpdApplication();
-                       deployedSystem.setTargetData(targetData);
-
-                       log.info("Deployed " + distribution + " to " + targetData);
-               } catch (Exception e) {
-                       throw new SlcException("Cannot deploy " + distribution + " to "
-                                       + targetData, e);
-               }
-
-       }
-
-       public void setTargetData(TargetData targetData) {
-               this.targetData = (HttpdApplicationTargetData) targetData;
-       }
-
-       public void setDeploymentData(DeploymentData deploymentData) {
-               this.deploymentData = deploymentData;
-       }
-
-       public DeployedSystem getDeployedSystem() {
-               return deployedSystem;
-       }
-
-       public void setDistribution(Distribution distribution) {
-               this.distribution = distribution;
-       }
-
-       public void setDeployEnvironment(DeployEnvironment deployEnvironment) {
-               this.deployEnvironment = deployEnvironment;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationTargetData.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationTargetData.java
deleted file mode 100644 (file)
index 7b052ec..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdApplicationTargetData implements TargetData {
-       private HttpdServer webServer;
-       private String relativePath;
-       private String targetRootPath;
-
-       public HttpdServer getWebServer() {
-               return webServer;
-       }
-
-       public void setWebServer(HttpdServer webServer) {
-               this.webServer = webServer;
-       }
-
-       public String getRelativePath() {
-               return relativePath;
-       }
-
-       /**
-        * If targetRootLocation not set, used to build the targetRootLocation,
-        * relative to the webserver base.
-        */
-       public void setRelativePath(String relativePath) {
-               this.relativePath = relativePath;
-       }
-
-       public String getTargetRootPath() {
-               return targetRootPath;
-       }
-
-       public void setTargetRootPath(String targetRootPath) {
-               this.targetRootPath = targetRootPath;
-       }
-
-       public URL getTargetBaseUrl() {
-               try {
-                       URL wsUrl = getWebServer().getBaseUrl();
-                       // TODO: use URI
-                       return new URL(wsUrl, wsUrl.getFile() + '/' + relativePath);
-               } catch (MalformedURLException e) {
-                       throw new SlcException("Cannot get base url for " + relativePath, e);
-               }
-       }
-
-       public File getTargetRootLocation() {
-               if (targetRootPath != null && !targetRootPath.equals("")) {
-                       return new File(targetRootPath);
-               } else {
-                       HttpdServerTargetData targetData = (HttpdServerTargetData) getWebServer()
-                                       .getTargetData();
-                       String path = targetData.getServerRoot() + File.separator
-                                       + getRelativePath();
-                       return new File(path);
-               }
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServer.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServer.java
deleted file mode 100644 (file)
index 5fa4e9b..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdServer implements WebServer {
-       private HttpdServerTargetData targetData;
-       private HttpdServerDeploymentData deploymentData;
-
-       public URL getBaseUrl() {
-               try {
-                       return new URL("http://localhost:" + targetData.getPort());
-               } catch (IOException e) {
-                       throw new SlcException("Cannot get url for Httpd server "
-                                       + getDeployedSystemId(), e);
-               }
-       }
-
-       public String getDeployedSystemId() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public Distribution getDistribution() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public DeploymentData getDeploymentData() {
-               return deploymentData;
-       }
-
-       public TargetData getTargetData() {
-               return targetData;
-       }
-
-       public void setTargetData(TargetData targetData) {
-               this.targetData = (HttpdServerTargetData)targetData;
-       }
-
-       public void setDeploymentData(DeploymentData deploymentData) {
-               this.deploymentData = (HttpdServerDeploymentData)deploymentData;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeployment.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeployment.java
deleted file mode 100644 (file)
index 785510f..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.Deployment;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdServerDeployment implements Deployment {
-//     private HttpdServerTargetData targetData;
-
-       public void run() {
-               // TODO Auto-generated method stub
-
-       }
-
-       public DeployedSystem getDeployedSystem() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public void setDeploymentData(DeploymentData deploymentData) {
-               // TODO Auto-generated method stub
-
-       }
-
-       public void setDistribution(Distribution distribution) {
-       }
-
-       public void setTargetData(TargetData targetData) {
-//             this.targetData = (HttpdServerTargetData) targetData;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeploymentData.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeploymentData.java
deleted file mode 100644 (file)
index 668ee39..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import org.argeo.slc.deploy.DeploymentData;
-
-public class HttpdServerDeploymentData implements DeploymentData {
-       private String configFile;
-
-       public String getConfigFile() {
-               return configFile;
-       }
-
-       public void setConfigFile(String configFile) {
-               this.configFile = configFile;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerManager.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerManager.java
deleted file mode 100644 (file)
index 20b7859..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.deploy.DeployedSystemManager;
-
-public class HttpdServerManager implements DeployedSystemManager<HttpdServer> {
-       private final static Log log = LogFactory.getLog(HttpdServerManager.class);
-
-       private HttpdServer httpdServer;
-
-       public void start() {
-               runProcessAsync(createCommandLine("start"));
-               log.info("Started httpd server with root "
-                               + getHttpdServerTargetData().getServerRoot());
-       }
-
-       public void stop() {
-               runProcessAsync(createCommandLine("stop"));
-               log.info("Stopped httpd server with root "
-                               + getHttpdServerTargetData().getServerRoot());
-       }
-
-       protected String[] createCommandLine(String action) {
-               String httpdPath = getHttpdServerTargetData().getExecutables()
-                               .getExecutablePath("httpd");
-               String[] cmd = { httpdPath, "-d",
-                               getHttpdServerTargetData().getServerRoot(), "-f",
-                               getHttpdServerDeploymentData().getConfigFile(), "-k", action };
-               if (log.isDebugEnabled())
-                       log.debug("Command line: " + Arrays.asList(cmd));
-               return cmd;
-       }
-
-       protected static void runProcessAsync(String... command) {
-               ProcessBuilder procBuilder = new ProcessBuilder(command);
-               procBuilder.redirectErrorStream(true);
-               try {
-                       Process proc = procBuilder.start();
-                       final InputStream in = proc.getInputStream();
-                       Thread logThread = new Thread() {
-
-                               @Override
-                               public void run() {
-                                       BufferedReader reader = new BufferedReader(
-                                                       new InputStreamReader(in));
-                                       String line = null;
-                                       try {
-                                               while ((line = reader.readLine()) != null)
-                                                       log.info(line);
-                                       } catch (IOException e) {
-                                               log.error("Failed to read stdout", e);
-                                       }
-                               }
-                       };
-
-                       logThread.start();
-               } catch (IOException e) {
-                       throw new SlcException("Could not run command", e);
-               }
-       }
-
-       public void setDeployedSystem(HttpdServer httpdServer) {
-               this.httpdServer = httpdServer;
-       }
-
-       protected HttpdServerDeploymentData getHttpdServerDeploymentData() {
-               return (HttpdServerDeploymentData) httpdServer.getDeploymentData();
-       }
-
-       protected HttpdServerTargetData getHttpdServerTargetData() {
-               return (HttpdServerTargetData) httpdServer.getTargetData();
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerTargetData.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerTargetData.java
deleted file mode 100644 (file)
index e4f28ca..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import org.argeo.slc.deploy.InstalledExecutables;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdServerTargetData implements TargetData {
-       private String serverRoot;
-       private Integer port;
-       private InstalledExecutables executables;
-
-       public String getServerRoot() {
-               return serverRoot;
-       }
-
-       public void setServerRoot(String serverRoot) {
-               this.serverRoot = serverRoot;
-       }
-
-       public Integer getPort() {
-               return port;
-       }
-
-       public void setPort(Integer port) {
-               this.port = port;
-       }
-
-       public InstalledExecutables getExecutables() {
-               return executables;
-       }
-
-       public void setExecutables(InstalledExecutables executables) {
-               this.executables = executables;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/SimpleHttpdApplication.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/SimpleHttpdApplication.java
deleted file mode 100644 (file)
index b5157f6..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import java.io.File;
-import java.net.URL;
-
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeploymentData;
-
-public class SimpleHttpdApplication implements WebApplication {
-       private HttpdApplicationTargetData targetData;
-       private Distribution distribution;
-
-       public void setDistribution(Distribution distribution) {
-               this.distribution = distribution;
-       }
-
-       public URL getBaseUrl() {
-               return targetData.getTargetBaseUrl();
-       }
-
-       public File getRootLocation() {
-               return targetData.getTargetRootLocation();
-       }
-
-       public String getDeployedSystemId() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       public HttpdApplicationTargetData getTargetData() {
-               return targetData;
-       }
-
-       public void setTargetData(HttpdApplicationTargetData targetData) {
-               this.targetData = targetData;
-       }
-
-       public Distribution getDistribution() {
-               return distribution;
-       }
-
-       public DeploymentData getDeploymentData() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebApplication.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebApplication.java
deleted file mode 100644 (file)
index 1d82754..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import java.io.File;
-import java.net.URL;
-
-import org.argeo.slc.deploy.DeployedSystem;
-
-public interface WebApplication extends DeployedSystem {
-       public URL getBaseUrl();
-
-       public File getRootLocation();
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebServer.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebServer.java
deleted file mode 100644 (file)
index afce096..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.argeo.slc.support.deploy;
-
-import java.net.URL;
-
-import org.argeo.slc.deploy.DeployedSystem;
-
-public interface WebServer extends DeployedSystem {
-       public URL getBaseUrl();
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/DbModel.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/DbModel.java
deleted file mode 100644 (file)
index 6140d7b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.support.deploy.db;
-
-import java.sql.Connection;
-
-public interface DbModel {
-       public void createSchema(Connection connection);
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/JdbcAware.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/JdbcAware.java
deleted file mode 100644 (file)
index 0d4de5e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.argeo.slc.support.deploy.db;
-
-import javax.sql.DataSource;
-
-public interface JdbcAware {
-       public DataSource getDataSource();
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/SimpleJdbcDatabase.java b/cms/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/SimpleJdbcDatabase.java
deleted file mode 100644 (file)
index 4f15209..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.argeo.slc.support.deploy.db;
-
-import javax.sql.DataSource;
-
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class SimpleJdbcDatabase implements DeployedSystem, JdbcAware {
-       private DataSource dataSource;
-
-       public String getDeployedSystemId() {
-               return dataSource.toString();
-       }
-
-       public DataSource getDataSource() {
-               return dataSource;
-       }
-
-       public void setDataSource(DataSource dataSource) {
-               this.dataSource = dataSource;
-       }
-
-       @Override
-       public Distribution getDistribution() {
-               throw new UnsupportedOperationException();
-       }
-
-       @Override
-       public DeploymentData getDeploymentData() {
-               throw new UnsupportedOperationException();
-       }
-
-       @Override
-       public TargetData getTargetData() {
-               throw new UnsupportedOperationException();
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResource.java b/cms/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResource.java
deleted file mode 100644 (file)
index 7c0c7e9..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.argeo.slc.vfs;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.apache.commons.io.IOExceptionWithCause;
-import org.apache.commons.vfs2.FileObject;
-import org.apache.commons.vfs2.FileSystemException;
-import org.apache.commons.vfs2.NameScope;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-public class VfsResource implements Resource {
-       private FileObject fileObject;
-
-       public VfsResource(FileObject fileObject) {
-               this.fileObject = fileObject;
-       }
-
-       public Resource createRelative(String relativePath) throws IOException {
-               return new VfsResource(fileObject.resolveFile(relativePath,
-                               NameScope.DESCENDENT_OR_SELF));
-       }
-
-       public boolean exists() {
-               try {
-                       return fileObject.exists();
-               } catch (FileSystemException e) {
-                       throw new SlcException("Cannot find out whether " + fileObject
-                                       + " exists", e);
-               }
-       }
-
-       public String getDescription() {
-               return "VFS resource " + fileObject;
-       }
-
-       public File getFile() throws IOException {
-               throw new IOException("Cannot access " + getDescription()
-                               + " as a local file");
-               // TODO: access local files
-               // if(fileObject instanceof LocalFile){
-               // ((LocalFile)fileObject).
-               // }
-               // return null;
-       }
-
-       public String getFilename() {
-               return fileObject.getName().getBaseName();
-       }
-
-       public URI getURI() throws IOException {
-               try {
-                       return new URI(fileObject.getName().getURI());
-               } catch (URISyntaxException e) {
-                       throw new IOExceptionWithCause(e);
-               }
-       }
-
-       public URL getURL() throws IOException {
-               return fileObject.getURL();
-       }
-
-       public boolean isOpen() {
-               return fileObject.isContentOpen();
-       }
-
-       public boolean isReadable() {
-               try {
-                       return fileObject.isReadable();
-               } catch (FileSystemException e) {
-                       throw new SlcException("Cannot find out whether " + fileObject
-                                       + " is readable", e);
-               }
-       }
-
-       public long lastModified() throws IOException {
-               return fileObject.getContent().getLastModifiedTime();
-       }
-
-       public InputStream getInputStream() throws IOException {
-               return fileObject.getContent().getInputStream();
-       }
-
-       public FileObject getFileObject() {
-               return fileObject;
-       }
-
-       public long contentLength(){
-               return -1;
-       }
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceFactory.java b/cms/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceFactory.java
deleted file mode 100644 (file)
index ac92adf..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.argeo.slc.vfs;
-
-import org.apache.commons.vfs2.CacheStrategy;
-import org.apache.commons.vfs2.FileSystemManager;
-import org.apache.commons.vfs2.impl.StandardFileSystemManager;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-public class VfsResourceFactory implements FactoryBean, InitializingBean {
-       private String url;
-       private FileSystemManager fileSystemManager;
-
-       public Object getObject() throws Exception {
-               return new VfsResource(fileSystemManager.resolveFile(url));
-       }
-
-       public Class<?> getObjectType() {
-               return Resource.class;
-       }
-
-       public boolean isSingleton() {
-               return false;
-       }
-
-       public void afterPropertiesSet() throws Exception {
-               if (fileSystemManager == null) {
-                       fileSystemManager = new StandardFileSystemManager();
-                       ((StandardFileSystemManager) fileSystemManager)
-                                       .setCacheStrategy(CacheStrategy.ON_RESOLVE);
-                       ((StandardFileSystemManager) fileSystemManager).init();
-               }
-
-       }
-
-}
diff --git a/cms/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceSet.java b/cms/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceSet.java
deleted file mode 100644 (file)
index a56b431..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.argeo.slc.vfs;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.vfs2.FileObject;
-import org.apache.commons.vfs2.FileSystemException;
-import org.apache.commons.vfs2.FileSystemManager;
-import org.apache.commons.vfs2.VFS;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.deploy.ResourceSet;
-import org.springframework.core.io.Resource;
-
-public class VfsResourceSet implements ResourceSet {
-       private String base;
-
-       public Map<String, Resource> listResources() {
-               try {
-                       FileSystemManager fileSystemManager = VFS.getManager();
-                       FileObject fileObject = fileSystemManager.resolveFile(base);
-                       Map<String, Resource> map = new HashMap<String, Resource>();
-                       addToMap(map, "", fileObject);
-
-                       // TODO: add filters
-                       return map;
-               } catch (FileSystemException e) {
-                       throw new SlcException("Cannot list VFS resources from " + base, e);
-               }
-       }
-
-       /** recursive */
-       protected void addToMap(Map<String, Resource> map, String parentPath,
-                       FileObject fileObject) {
-               try {
-                       String newParentPath = parentPath
-                                       + fileObject.getName().getBaseName() + '/';
-                       if (fileObject.getType().hasChildren()) {
-                               for (FileObject child : fileObject.getChildren()) {
-                                       addToMap(map, newParentPath, child);
-                               }
-                       } else {
-                               map.put(parentPath + fileObject.getName().getBaseName(),
-                                               new VfsResource(fileObject));
-                       }
-               } catch (FileSystemException e) {
-                       throw new SlcException("Cannot add children from " + parentPath, e);
-               }
-       }
-
-       public void setBase(String base) {
-               this.base = base;
-       }
-
-}
index 333ab67924885fe6644403568007edefd96184ef..4d0b53387862d71b9f2668dd65b05b7f392c0d7e 100644 (file)
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
-               <groupId>org.argeo.maven</groupId>
-               <artifactId>argeo-osgi-parent</artifactId>
-               <version>2.1.4-SNAPSHOT</version>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>2.3-SNAPSHOT</version>
        </parent>
-       <groupId>org.argeo.slc</groupId>
        <artifactId>argeo-slc-cms</artifactId>
        <packaging>pom</packaging>
        <name>Argeo SLC CMS</name>
        <version>2.3-SNAPSHOT</version>
-       <properties>
-               <version.argeo-tp>2.1.27</version.argeo-tp>
-               <version.argeo-tp-extras>2.1.13</version.argeo-tp-extras>
-               <version.argeo-commons>2.3-SNAPSHOT</version.argeo-commons>
-
-               <version.slc>2.3.1-SNAPSHOT</version.slc>
-               <developmentCycle.startDate>2015-02-12</developmentCycle.startDate>
-               <developmentCycle.slc>2.1</developmentCycle.slc>
-               <version.argeo-commons-legacy>2.1.86</version.argeo-commons-legacy>
-
-               <argeo.rpm.stagingRepository>/srv/rpmfactory/unstable/argeo-osgi-2/argeo</argeo.rpm.stagingRepository>
-       </properties>
        <modules>
                <!-- Argeo CMS extensions -->
                <module>org.argeo.cms.integration</module>
                <module>org.argeo.ext.equinox.jetty</module>
 
-               <!-- SLC framework -->
-               <module>org.argeo.slc.api</module>
-               <module>org.argeo.slc.runtime</module>
-               <module>org.argeo.slc.jcr</module>
-
-               <!--  SLC Repo -->
-               <module>org.argeo.slc.repo</module>
-               <module>org.argeo.slc.factory</module>
-
-               <!-- Legacy Runtime -->
-               <module>org.argeo.slc.spring</module>
-               <module>org.argeo.slc.support</module>
-               <module>org.argeo.slc.launcher</module>
-
-               <!-- Legacy Modules -->
-               <module>org.argeo.slc.agent</module>
-               <module>org.argeo.slc.agent.jcr</module>
-               <module>org.argeo.slc.server.repo</module>
-
-               <!-- Legacy UI -->
-               <module>org.argeo.slc.client.ui</module>
-               <module>org.argeo.slc.client.ui.dist</module>
-               <module>org.argeo.slc.client.rap</module>
        </modules>
-       <url>http://projects.argeo.org/slc/</url>
-       <scm>
-               <connection>scm:git:http://git.argeo.org/lgpl/argeo-slc.git</connection>
-               <url>http://git.argeo.org/?p=lgpl/argeo-slc.git;a=summary</url>
-               <developerConnection>scm:git:https://code.argeo.org/git/lgpl/argeo-slc.git</developerConnection>
-               <tag>HEAD</tag>
-       </scm>
-       <organization>
-               <name>Argeo GmbH</name>
-       </organization>
-       <inceptionYear>2007</inceptionYear>
-       <licenses>
-               <license>
-                       <name>LGPL-3.0-or-later</name>
-                       <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url>
-                       <distribution>repo</distribution>
-               </license>
-       </licenses>
-       <dependencies>
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>argeo-tp</artifactId>
-                       <version>${version.argeo-tp}</version>
-                       <scope>provided</scope>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>org.argeo.tp.apache</groupId>
-                                       <artifactId>org.apache.xerces</artifactId>
-                               </exclusion>
-                               <!-- Avoid slf4j implementations lurking in the classpath. -->
-                               <exclusion>
-                                       <groupId>org.argeo.tp.sdk</groupId>
-                                       <artifactId>biz.aQute.bndlib</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>org.argeo.tp.misc</groupId>
-                                       <artifactId>slf4j.osgi</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-       </dependencies>
-       <dependencyManagement>
-               <dependencies>
-                       <dependency>
-                               <groupId>org.argeo.tp</groupId>
-                               <artifactId>argeo-tp</artifactId>
-                               <version>${version.argeo-tp}</version>
-                               <type>pom</type>
-                               <scope>import</scope>
-                       </dependency>
-                       <dependency>
-                               <groupId>org.argeo.tp</groupId>
-                               <artifactId>argeo-tp-rap-e4</artifactId>
-                               <version>${version.argeo-tp}</version>
-                               <type>pom</type>
-                               <scope>import</scope>
-                       </dependency>
-                       <dependency>
-                               <groupId>org.argeo.tp.extras</groupId>
-                               <artifactId>argeo-tp-extras</artifactId>
-                               <version>${version.argeo-tp-extras}</version>
-                               <type>pom</type>
-                               <scope>import</scope>
-                       </dependency>
-               </dependencies>
-       </dependencyManagement>
-       <repositories>
-               <repository>
-                       <id>argeo</id>
-                       <url>http://forge.argeo.org/data/java/argeo-2.1/</url>
-                       <releases>
-                               <enabled>true</enabled>
-                               <updatePolicy>daily</updatePolicy>
-                               <checksumPolicy>warn</checksumPolicy>
-                       </releases>
-                       <snapshots>
-                               <enabled>false</enabled>
-                       </snapshots>
-               </repository>
-               <repository>
-                       <id>argeo-extras</id>
-                       <url>http://forge.argeo.org/data/java/argeo-extras-2.1/</url>
-                       <releases>
-                               <enabled>true</enabled>
-                               <updatePolicy>daily</updatePolicy>
-                               <checksumPolicy>warn</checksumPolicy>
-                       </releases>
-                       <snapshots>
-                               <enabled>false</enabled>
-                       </snapshots>
-               </repository>
-               <repository>
-                       <id>argeo-unstable</id>
-                       <url>http://forge.argeo.org/data/java/argeo-2.3/</url>
-                       <releases>
-                               <enabled>true</enabled>
-                               <updatePolicy>never</updatePolicy>
-                               <checksumPolicy>warn</checksumPolicy>
-                       </releases>
-                       <snapshots>
-                               <enabled>false</enabled>
-                       </snapshots>
-               </repository>
-               <!-- Disable Maven default repository -->
-               <repository>
-                       <id>central</id>
-                       <url>http://repo1.maven.org/maven2</url>
-                       <releases>
-                               <enabled>false</enabled>
-                       </releases>
-                       <snapshots>
-                               <enabled>false</enabled>
-                       </snapshots>
-               </repository>
-       </repositories>
-       <reporting>
-               <plugins>
-                       <plugin>
-                               <artifactId>maven-project-info-reports-plugin</artifactId>
-                               <version>2.9</version>
-                               <reportSets>
-                                       <reportSet>
-                                               <reports>
-                                                       <report>index</report>
-                                                       <report>summary</report>
-                                                       <report>license</report>
-                                                       <report>scm</report>
-                                               </reports>
-                                       </reportSet>
-                               </reportSets>
-                       </plugin>
-                       <plugin>
-                               <artifactId>maven-javadoc-plugin</artifactId>
-                               <version>3.0.0</version>
-                               <configuration>
-                                       <failOnError>false</failOnError>
-                                       <additionalJOption>-Xdoclint:none</additionalJOption>
-                                       <excludePackageNames>*.internal.*,org.eclipse.*</excludePackageNames>
-                                       <encoding>UTF-8</encoding>
-                                       <detectLinks>true</detectLinks>
-                                       <links>
-                                               <link>http://docs.oracle.com/javase/8/docs/api</link>
-                                               <link>https://osgi.org/javadoc/r5/core</link>
-                                               <link>https://osgi.org/javadoc/r5/enterprise</link>
-                                               <link>https://docs.adobe.com/docs/en/spec/javax.jcr/javadocs/jcr-2.0</link>
-                                               <link>http://help.eclipse.org/oxygen/topic/org.eclipse.platform.doc.isv/reference/api</link>
-                                               <link>http://docs.spring.io/spring/docs/3.2.x/javadoc-api</link>
-                                       </links>
-                               </configuration>
-                               <reportSets>
-                                       <reportSet>
-                                               <id>aggregate-javadoc</id>
-                                               <inherited>false</inherited>
-                                               <reports>
-                                                       <report>aggregate</report>
-                                               </reports>
-                                       </reportSet>
-                                       <reportSet>
-                                               <id>javadoc</id>
-                                               <reports />
-                                       </reportSet>
-                               </reportSets>
-                       </plugin>
-                       <plugin>
-                               <artifactId>maven-jxr-plugin</artifactId>
-                               <version>2.5</version>
-                               <reportSets>
-                                       <reportSet>
-                                               <id>aggregate-jxr</id>
-                                               <inherited>false</inherited>
-                                               <reports>
-                                                       <report>aggregate</report>
-                                               </reports>
-                                       </reportSet>
-                                       <reportSet>
-                                               <id>jxr</id>
-                                               <reports />
-                                       </reportSet>
-                               </reportSets>
-                       </plugin>
-               </plugins>
-       </reporting>
-       <distributionManagement>
-               <site>
-                       <id>staging</id>
-                       <url>file:///srv/docfactory/argeo-2.3/site/argeo-slc/</url>
-               </site>
-       </distributionManagement>
-       <profiles>
-               <profile>
-                       <id>localrepo</id>
-                       <repositories>
-                               <repository>
-                                       <id>argeo-extras</id>
-                                       <url>http://localhost:7080/data/java/argeo-extras-2.3</url>
-                                       <releases>
-                                               <enabled>true</enabled>
-                                               <updatePolicy>daily</updatePolicy>
-                                               <checksumPolicy>warn</checksumPolicy>
-                                       </releases>
-                               </repository>
-                       </repositories>
-               </profile>
-       </profiles>
 </project>
diff --git a/demo/modules/.gitignore b/demo/modules/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/demo/modules/cnf/maven.bnd b/demo/modules/cnf/maven.bnd
deleted file mode 100644 (file)
index a3fca92..0000000
+++ /dev/null
@@ -1 +0,0 @@
--include: ../../../cnf/maven.bnd
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.ant/.gitignore b/demo/modules/org.argeo.slc.demo.ant/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/demo/modules/org.argeo.slc.demo.ant/.project b/demo/modules/org.argeo.slc.demo.ant/.project
deleted file mode 100644 (file)
index 5a20f60..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.demo.ant</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <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>
-       </natures>
-</projectDescription>
diff --git a/demo/modules/org.argeo.slc.demo.ant/.settings/org.eclipse.pde.core.prefs b/demo/modules/org.argeo.slc.demo.ant/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644 (file)
index fd871b4..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#Wed Jan 06 20:27:20 CET 2010
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
diff --git a/demo/modules/org.argeo.slc.demo.ant/META-INF/.gitignore b/demo/modules/org.argeo.slc.demo.ant/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/demo/modules/org.argeo.slc.demo.ant/META-INF/spring/ant.xml b/demo/modules/org.argeo.slc.demo.ant/META-INF/spring/ant.xml
deleted file mode 100644 (file)
index 3cff3b4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <bean id="main" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean class="org.argeo.slc.ant.AntRun">\r
-                                       <property name="buildFile" value="osgibundle:/ant/hello/build.xml" />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.ant/META-INF/spring/flowGenerator.xml b/demo/modules/org.argeo.slc.demo.ant/META-INF/spring/flowGenerator.xml
deleted file mode 100644 (file)
index d25caf9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <bean class="org.argeo.slc.ant.AntFlowGenerator">\r
-               <property name="antFiles">\r
-                       <list>\r
-                               <value>osgibundle:/ant/hello/build.xml\r
-                               </value>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.ant/META-INF/spring/imports.xml b/demo/modules/org.argeo.slc.demo.ant/META-INF/spring/imports.xml
deleted file mode 100644 (file)
index 3428e8b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
-       <import resource="classpath:org/argeo/slc/core/execution/simple.xml" />
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.ant/META-INF/spring/osgi.xml b/demo/modules/org.argeo.slc.demo.ant/META-INF/spring/osgi.xml
deleted file mode 100644 (file)
index f505229..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
-</beans:beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.ant/ant/hello/build.xml b/demo/modules/org.argeo.slc.demo.ant/ant/hello/build.xml
deleted file mode 100644 (file)
index 78dffa3..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<project default="hello">
-       <target name="hello">
-               <echo message="Hello World!" />
-       </target>
-</project>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.ant/bnd.bnd b/demo/modules/org.argeo.slc.demo.ant/bnd.bnd
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/demo/modules/org.argeo.slc.demo.ant/build.properties b/demo/modules/org.argeo.slc.demo.ant/build.properties
deleted file mode 100644 (file)
index 5f22cdd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-bin.includes = META-INF/
diff --git a/demo/modules/org.argeo.slc.demo.ant/pom.xml b/demo/modules/org.argeo.slc.demo.ant/pom.xml
deleted file mode 100644 (file)
index 359c983..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc.demo</groupId>
-               <artifactId>modules</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.demo.ant</artifactId>
-       <name>SLC Demo Ant</name>
-</project>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/.classpath b/demo/modules/org.argeo.slc.demo.basic/.classpath
deleted file mode 100644 (file)
index acad1c2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/demo/modules/org.argeo.slc.demo.basic/.gitignore b/demo/modules/org.argeo.slc.demo.basic/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/demo/modules/org.argeo.slc.demo.basic/.project b/demo/modules/org.argeo.slc.demo.basic/.project
deleted file mode 100644 (file)
index 1792645..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.demo.basic</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/demo/modules/org.argeo.slc.demo.basic/.settings/org.eclipse.pde.core.prefs b/demo/modules/org.argeo.slc.demo.basic/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644 (file)
index e2c3c3e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#Fri Mar 13 13:44:23 CET 2009
-eclipse.preferences.version=1
-pluginProject.equinox=false
-pluginProject.extensions=false
-resolve.requirebundle=false
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/.gitignore b/demo/modules/org.argeo.slc.demo.basic/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/basic-001.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/basic-001.xml
deleted file mode 100644 (file)
index cc121f2..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <bean id="basic.001" parent="basic.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="testData1" value-ref="basic.001.testData" />\r
-                               <entry key="testData2">\r
-                                       <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
-                                               <aop:scoped-proxy />\r
-                                               <property name="expected" value="tata101" />\r
-                                               <property name="reached" value="tata@{testedComponentId}" />\r
-                                       </bean>\r
-                               </entry>\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-\r
-       <bean id="basic.001.testData" class="org.argeo.slc.runtime.test.BasicTestData"\r
-               scope="execution">\r
-               <aop:scoped-proxy />\r
-               <property name="expected" value="tata100" />\r
-               <property name="reached" value="tata@{testedComponentId}" />\r
-       </bean>\r
-\r
-       <bean id="basic.001.testData2" class="org.argeo.slc.core.test.context.DefaultContextTestData">\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/basic-002.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/basic-002.xml
deleted file mode 100644 (file)
index 4baf291..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-\r
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <bean id="basic.002" parent="basic.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="testData1">\r
-                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                               <property name="expected" value="toto" />\r
-                                               <property name="reached" value="toto" />\r
-                                       </bean>\r
-                               </entry>\r
-                               <entry key="testData2">\r
-                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                               <property name="expected" value="tata" />\r
-                                               <property name="reached" value="toto" />\r
-                                       </bean>\r
-                               </entry>\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/basic.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/basic.xml
deleted file mode 100644 (file)
index a2e34c1..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <bean id="basic.spec" parent="slcTemplate.simpleSpec">\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="testedComponentId">\r
-                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
-                                               p:type="integer" />\r
-                               </entry>\r
-                               <entry key="testData1">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:isParameter="true" p:isFrozen="true" />\r
-                               </entry>\r
-                               <entry key="testData2">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:isParameter="true" p:isFrozen="true" />\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="basic.flowTemplate" parent="slcTemplate.simpleFlow"\r
-               abstract="true">\r
-               <constructor-arg ref="basic.spec" />\r
-               <property name="path" value="/test/basic" />\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo" scope="execution">\r
-                                       <property name="message" value="From basic @{testedComponentId}" />\r
-                                       <aop:scoped-proxy />\r
-                               </bean>\r
-                               <bean parent="basic.testRun">\r
-                                       <property name="testDefinition" ref="basic.testDef" />\r
-                                       <property name="testData">\r
-                                               <bean parent="parameterRef">\r
-                                                       <constructor-arg value="testData1" />\r
-                                               </bean>\r
-                                       </property>\r
-                               </bean>\r
-                               <bean parent="basic.testRun">\r
-                                       <property name="testDefinition" ref="basic.testDef" />\r
-                                       <property name="testData" ref="ref1" />\r
-                               </bean>\r
-\r
-                               <bean class="org.argeo.slc.jcr.JcrMetadataWriter">\r
-                                       <property name="metadata">\r
-                                               <map>\r
-                                                       <entry key="metadata1" value="value1" />\r
-                                                       <entry key="slc:metadata2" value="value2" />\r
-                                               </map>\r
-                                       </property>\r
-                                       <property name="baseNode">\r
-                                               <bean factory-bean="basic.testResult" factory-method="getNode" />\r
-                                       </property>\r
-                                       <flow:variable />\r
-                               </bean>\r
-\r
-                               <!-- Attachments -->\r
-                               <bean parent="task.echo">\r
-                                       <property name="message" value="DATA" />\r
-                                       <property name="writeTo" ref="basic.writeTo" />\r
-                               </bean>\r
-\r
-                               <bean parent="task.uploadAttachments">\r
-                                       <property name="attachmentUploader" ref="attachmentUploader" />\r
-                                       <property name="attachment">\r
-                                               <bean parent="taskArg.attachment">\r
-                                                       <property name="name" value="myAttachment.txt" />\r
-                                               </bean>\r
-                                       </property>\r
-                                       <property name="resource" ref="basic.writeTo" />\r
-                                       <property name="attachTo">\r
-                                               <list>\r
-                                                       <ref bean="basic.testResult" />\r
-                                               </list>\r
-                                       </property>\r
-                               </bean>\r
-\r
-                               <bean parent="task.closeTestResult" scope="execution">\r
-                                       <property name="testResult" ref="basic.testResult" />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="ref1" parent="parameterRef" scope="prototype">\r
-               <constructor-arg value="testData2" />\r
-       </bean>\r
-\r
-       <bean id="basic.testData" class="org.argeo.slc.runtime.test.BasicTestData">\r
-               <aop:scoped-proxy />\r
-               <property name="expected" value="tata" />\r
-               <property name="reached" value="tata" />\r
-       </bean>\r
-\r
-       <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition"\r
-               scope="prototype" />\r
-\r
-       <bean id="basic.testResult" class="org.argeo.slc.jcr.JcrTestResult"\r
-               init-method="init" destroy-method="destroy">\r
-               <flow:variable />\r
-               <property name="resultType" value="slc:diffResult" />\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="testCase" value="@{slcVar.flow.name}" />\r
-                       </map>\r
-               </property>\r
-               <property name="repository" ref="repository" />\r
-       </bean>\r
-\r
-       <!-- <bean id="basic.testResult" parent="slcDefault.test.basicTreeTestResult" -->\r
-       <!-- scope="execution"> -->\r
-       <!-- <property name="listeners" ref="resultListeners" /> -->\r
-       <!-- <property name="attributes"> -->\r
-       <!-- <map> -->\r
-       <!-- <entry key="testedComponentId" value="@{testedComponentId}" /> -->\r
-       <!-- </map> -->\r
-       <!-- </property> -->\r
-       <!-- <aop:scoped-proxy /> -->\r
-       <!-- </bean> -->\r
-\r
-       <bean id="basic.testRun" class="org.argeo.slc.runtime.test.SimpleTestRun"\r
-               abstract="true">\r
-               <property name="testResult" ref="basic.testResult" />\r
-       </bean>\r
-\r
-       <bean id="basic.writeTo" factory-bean="basic.resourcesManager"\r
-               factory-method="getWritableResource" scope="execution">\r
-               <constructor-arg value="subdir/writeTo" />\r
-               <aop:scoped-proxy />\r
-       </bean>\r
-\r
-       <bean id="basic.resourcesManager" parent="slcTemplate.fileResources">\r
-               <property name="executionContext" ref="executionContext" />\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-001.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-001.xml
deleted file mode 100644 (file)
index 181e3e7..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <bean id="canonic.001" parent="canonic.flowTemplate">\r
-               <description>Canonic 001</description>\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="parameterAtInstantiation" value="1" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-</beans>\r
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-002.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-002.xml
deleted file mode 100644 (file)
index 5916c08..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <bean id="canonic.002" parent="canonic.flowTemplate">\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="parameterAtInstantiation" value="2" />\r
-                               <entry key="displayWithoutControl" value="102" />\r
-                               <entry key="displayWithControl" value="202" />\r
-                               <entry key="hide" value="202" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-</beans>\r
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-001.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-001.xml
deleted file mode 100644 (file)
index 5b1dbf6..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <bean id="canonic-ns.001" parent="canonic-ns.flowTemplate">\r
-               <description>Canonic 001</description>\r
-               <constructor-arg>\r
-                       <map>\r
-                               <entry key="parameterAtInstantiation" value="1" />\r
-                       </map>\r
-               </constructor-arg>\r
-       </bean>\r
-</beans>\r
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-002.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-002.xml
deleted file mode 100644 (file)
index 991f67f..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <flow:flow id="canonic-ns.002" parent="canonic-ns.flowTemplate">\r
-               <flow:arg name="parameterAtInstantiation" value="2" />\r
-               <flow:arg name="displayWithoutControl" value="102" />\r
-               <flow:arg name="displayWithControl" value="202" />\r
-               <flow:arg name="hide" value="202" />\r
-       </flow:flow>\r
-</beans>\r
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns.xml
deleted file mode 100644 (file)
index 8fe234b..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <flow:spec id="canonic-ns.spec">\r
-               <flow:primitive name="parameterAtInstantiation"\r
-                       isParameter="true" type="integer" />\r
-               <flow:primitive name="displayWithoutControl" value="100"\r
-                       isParameter="true" type="integer" isFrozen="true" />\r
-               <flow:primitive name="displayWithControl" value="200"\r
-                       isParameter="true" type="integer" />\r
-               <flow:primitive name="hide" value="300" isParameter="true"\r
-                       type="integer" isHidden="true" />\r
-               <flow:ref name="refWithValue" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                       isParameter="true" ref="testDataNok" />\r
-               <flow:ref name="refWithoutValue" targetClass="org.argeo.slc.runtime.test.BasicTestData" />\r
-               <flow:ref name="refWithoutValueFrozen" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                       isParameter="true" isFrozen="true">\r
-                       <flow:value>\r
-                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                       <aop:scoped-proxy />\r
-                                       <property name="expected" value="tata" />\r
-                                       <property name="reached" value="tata" />\r
-                               </bean>\r
-                       </flow:value>\r
-               </flow:ref>\r
-       </flow:spec>\r
-\r
-       <flow:flow id="canonic-ns.flowTemplate" abstract="true"\r
-               spec="canonic-ns.spec">\r
-               <bean parent="task.echo"\r
-                       p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
-                       scope="execution">\r
-                       <aop:scoped-proxy />\r
-               </bean>\r
-       </flow:flow>\r
-\r
-       <bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
-               <aop:scoped-proxy />\r
-               <property name="expected" value="tata" />\r
-               <property name="reached" value="tata" />\r
-       </bean>\r
-\r
-       <bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
-               <aop:scoped-proxy />\r
-               <property name="expected" value="tata" />\r
-               <property name="reached" value="toto" />\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/canonic.xml
deleted file mode 100644 (file)
index f45b1ae..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <bean id="canonic.spec" parent="slcTemplate.simpleSpec">\r
-               <description>Covers various combinations of specs</description>\r
-               <property name="attributes">\r
-                       <map>\r
-                               <entry key="parameterAtInstantiation">\r
-                                       <bean parent="specAttr.primitive" p:isParameter="true" p:type="integer" />\r
-                               </entry>\r
-                               <entry key="displayWithoutControl">\r
-                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="false"\r
-                                               p:isFrozen="true" p:type="integer" />\r
-                               </entry>\r
-                               <entry key="displayWithControl">\r
-                                       <bean parent="specAttr.primitive" p:value="200" p:isParameter="false"\r
-                                               p:isFrozen="false" p:type="integer" />\r
-                               </entry>\r
-                               <entry key="hide">\r
-                                       <bean parent="specAttr.primitive" p:value="300" p:isParameter="true"\r
-                                               p:isFrozen="false" p:isHidden="true" p:type="integer" />\r
-                               </entry>\r
-                               <entry key="refWithValue">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:value-ref="testDataNok" p:isParameter="true" p:isFrozen="false" />\r
-                               </entry>\r
-                               <entry key="refWithoutValue">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:isParameter="false" p:isFrozen="false" />\r
-                               </entry>\r
-                               <entry key="refWithoutValueFrozen">\r
-                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
-                                               p:isParameter="true" p:isFrozen="true">\r
-                                               <property name="value">\r
-                                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
-                                                               <aop:scoped-proxy />\r
-                                                               <property name="expected" value="tata" />\r
-                                                               <property name="reached" value="tata" />\r
-                                                       </bean>\r
-                                               </property>\r
-                                       </bean>\r
-                               </entry>\r
-                       </map>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="canonic.flowTemplate" parent="slcTemplate.simpleFlow"\r
-               abstract="true">\r
-               <constructor-arg ref="canonic.spec" />\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo"\r
-                                       p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
-                                       scope="execution">\r
-                                       <aop:scoped-proxy />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
-               <aop:scoped-proxy />\r
-               <property name="expected" value="tata" />\r
-               <property name="reached" value="tata" />\r
-       </bean>\r
-\r
-       <bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
-               <aop:scoped-proxy />\r
-               <property name="expected" value="tata" />\r
-               <property name="reached" value="toto" />\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/imports.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/imports.xml
deleted file mode 100644 (file)
index dc44a31..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
-       <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />
-
-       <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />
-
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/main.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/main.xml
deleted file mode 100644 (file)
index a2ee7a2..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
-       <bean id="main" parent="slcTemplate.simpleFlow">\r
-               <description>The Main Flow</description>\r
-               <constructor-arg>\r
-                       <bean parent="slcTemplate.simpleSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="testKey">\r
-                                                       <bean parent="specAttr.primitive" p:value="660" />\r
-                                               </entry>\r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-               <property name="executables">\r
-                       <list>\r
-                               <ref local="echo1" />\r
-                               <ref bean="basic.001" />\r
-                               <ref bean="basic.001" />\r
-                               <ref bean="basic.002" />\r
-                               <ref bean="canonic.001" />\r
-                               <ref bean="canonic.002" />\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="noArg" parent="slcTemplate.simpleFlow">\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean parent="task.echo">\r
-                                       <property name="message" value="No arg!" />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean id="echo1" parent="task.echo" scope="execution">\r
-               <property name="message" value="From main! @{testKey}" />\r
-               <aop:scoped-proxy />\r
-       </bean>\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/namespace.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/namespace.xml
deleted file mode 100644 (file)
index 610f5ee..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <!-- Flow definition is simplified thanks to the 'flow:flow' element -->\r
-       <flow:flow name="/namespace/flow" >\r
-               <bean p:message="TEST in flow" class="org.argeo.slc.core.execution.tasks.Echo" />\r
-               <ref bean="referencedRunnable" />\r
-       </flow:flow>\r
-\r
-       <bean id="referencedRunnable" p:message="TEST in referenced Runnable"\r
-               class="org.argeo.slc.core.execution.tasks.Echo" />\r
-\r
-       <!--\r
-               Standalone beans implementing Runnable can be exposed as flows via the\r
-               'flow:as-flow' attribute\r
-       -->\r
-       <bean id="standaloneRunnable" flow:as-flow="implicitFlow"\r
-               p:message="TEST in implicit flow" class="org.argeo.slc.core.execution.tasks.Echo" />\r
-\r
-       <!-- Specs definition is also simplified -->\r
-       <flow:spec id="namespaceSpec">\r
-               <flow:primitive name="primitive" value="100"\r
-                       isParameter="true" type="integer" />\r
-       </flow:spec>\r
-\r
-       <flow:flow name="/namespace/flowSpec" spec="namespaceSpec">\r
-               <bean p:message="TEST in flow @{primitive}" class="org.argeo.slc.core.execution.tasks.Echo"\r
-                       scope="execution">\r
-                       <aop:scoped-proxy />\r
-               </bean>\r
-               <ref bean="referencedRunnable" />\r
-       </flow:flow>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/osgi.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/osgi.xml
deleted file mode 100644 (file)
index 099ecd5..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
-\r
-       <reference id="attachmentUploader"\r
-               interface="org.argeo.slc.core.attachment.AttachmentUploader"\r
-               cardinality="0..1" />\r
-\r
-       <!-- REFERENCES -->\r
-       <reference id="repository" interface="javax.jcr.Repository"\r
-               filter="(cn=slc)" />\r
-</beans:beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/systemCall.xml b/demo/modules/org.argeo.slc.demo.basic/META-INF/spring/systemCall.xml
deleted file mode 100644 (file)
index 5b88539..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
-       <!-- Basic echo, should work on all OSs -->\r
-       <flow:flow name="os/systemCall">\r
-               <bean p:cmd="echo Hello World!" class="org.argeo.slc.core.execution.tasks.SystemCall" />\r
-       </flow:flow>\r
-\r
-       <!-- Must disable requiretty in sudoers file -->\r
-       <flow:flow name="os/sudo">\r
-               <bean p:cmd="sudo id" class="org.argeo.slc.core.execution.tasks.SystemCall">\r
-                       <property name="environmentVariables">\r
-                               <map>\r
-                                       <entry key="SUDO_ASKPASS" value="/usr/libexec/openssh/gnome-ssh-askpass" />\r
-                               </map>\r
-                       </property>\r
-               </bean>\r
-       </flow:flow>\r
-\r
-       <!-- SSH -->\r
-       <flow:flow name="os/ssh">\r
-               <bean p:cmd="ls /etc" class="org.argeo.slc.core.execution.tasks.SystemCall">\r
-                       <property name="executor" ref="sshExecutor" />\r
-               </bean>\r
-       </flow:flow>\r
-\r
-       <bean name="sshExecutor" class="org.argeo.slc.jsch.JschExecutor">\r
-               <property name="sshTarget">\r
-                       <bean p:host="localhost" p:port="22" p:user="${user.name}"\r
-                               p:localPrivateKey="${user.home}/.ssh/id_rsa" class="org.argeo.slc.jsch.SshTarget">\r
-                               <property name="userInfo">\r
-                                       <bean class="org.argeo.slc.jsch.SwingUserInfo" />\r
-                               </property>\r
-                       </bean>\r
-               </property>\r
-       </bean>\r
-\r
-\r
-\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.basic/bnd.bnd b/demo/modules/org.argeo.slc.demo.basic/bnd.bnd
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/demo/modules/org.argeo.slc.demo.basic/build.properties b/demo/modules/org.argeo.slc.demo.basic/build.properties
deleted file mode 100644 (file)
index d7751b8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-bin.includes = .settings/,\
-               .project,\
-               META-INF/,\
-               conf/,\
-               pom.xml,\
-               .svn/
diff --git a/demo/modules/org.argeo.slc.demo.basic/pom.xml b/demo/modules/org.argeo.slc.demo.basic/pom.xml
deleted file mode 100644 (file)
index 05109b9..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc.demo</groupId>
-               <artifactId>modules</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.demo.basic</artifactId>
-       <name>SLC Demo Basic</name>
-<!--   <build> -->
-<!--           <plugins> -->
-<!--                   <plugin> -->
-<!--                           <groupId>org.apache.felix</groupId> -->
-<!--                           <artifactId>maven-bundle-plugin</artifactId> -->
-<!--                           <configuration> -->
-<!--                                   <instructions> -->
-<!--                                           <SLC-ExecutionModule>default</SLC-ExecutionModule> -->
-<!--                                           <Import-Package> -->
-<!--                                                   *, -->
-<!--                                                   org.argeo.slc.core.structure.tree, -->
-
-<!--                                                   net.sf.cglib.core, -->
-<!--                                                   net.sf.cglib.proxy, -->
-<!--                                                   net.sf.cglib.reflect, -->
-<!--                                                   org.aopalliance.aop, -->
-<!--                                                   org.argeo.slc.core.execution, -->
-<!--                                                   org.argeo.slc.core.execution.tasks, -->
-<!--                                                   org.argeo.slc.execution, -->
-<!--                                                   org.argeo.slc.osgi, -->
-<!--                                                   org.springframework.aop, -->
-<!--                                                   org.springframework.aop.framework, -->
-<!--                                                   org.springframework.aop.scope, -->
-<!--                                                   org.springframework.beans.factory.config, -->
-<!--                                                   org.springframework.core.io,                                                                                             -->
-<!--                                           </Import-Package> -->
-<!--                                   </instructions> -->
-<!--                           </configuration> -->
-<!--                   </plugin> -->
-<!--           </plugins> -->
-<!--   </build> -->
-</project>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.minimal/.gitignore b/demo/modules/org.argeo.slc.demo.minimal/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/demo/modules/org.argeo.slc.demo.minimal/.project b/demo/modules/org.argeo.slc.demo.minimal/.project
deleted file mode 100644 (file)
index ba8b1b5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.slc.demo.minimal</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <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>
-       </natures>
-</projectDescription>
diff --git a/demo/modules/org.argeo.slc.demo.minimal/.settings/org.eclipse.pde.core.prefs b/demo/modules/org.argeo.slc.demo.minimal/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644 (file)
index 5886cbf..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#Wed Jan 06 20:27:49 CET 2010
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
diff --git a/demo/modules/org.argeo.slc.demo.minimal/META-INF/.gitignore b/demo/modules/org.argeo.slc.demo.minimal/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/common.xml b/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/common.xml
deleted file mode 100644 (file)
index a753d4e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:aop="http://www.springframework.org/schema/aop"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
-       <import resource="classpath:org/argeo/slc/core/execution/simple.xml" />
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld-raw.xml b/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld-raw.xml
deleted file mode 100644 (file)
index 6f61494..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xmlns:aop="http://www.springframework.org/schema/aop"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"\r
-       >\r
-\r
-       <!-- Hello world without namespace (for reference, do not use) -->\r
-       <bean name="HelloWorld/Raw" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
-               <description>Print Hello World!</description>\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean p:message="Hello World!" class="org.argeo.slc.core.execution.tasks.Echo" />\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-       <bean name="HelloWorld/RawWithVar" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
-               <description>Print Hello World! with variable</description>\r
-               <constructor-arg>\r
-                       <bean class="org.argeo.slc.core.execution.DefaultExecutionSpec">\r
-                               <property name="attributes">\r
-                                       <map>\r
-                                               <entry key="testKey">\r
-                                                       <bean p:value="777"\r
-                                                               class="org.argeo.slc.primitive.PrimitiveSpecAttribute" />\r
-                                               </entry>\r
-                                       </map>\r
-                               </property>\r
-                       </bean>\r
-               </constructor-arg>\r
-               <property name="executables">\r
-                       <list>\r
-                               <bean p:message="Hello World! @{testKey}" class="org.argeo.slc.core.execution.tasks.Echo"\r
-                                       scope="execution">\r
-                                       <aop:scoped-proxy proxy-target-class="false" />\r
-                               </bean>\r
-                       </list>\r
-               </property>\r
-       </bean>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml b/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml
deleted file mode 100644 (file)
index 0d249dc..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns="http://www.springframework.org/schema/beans"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-       xsi:schemaLocation="\r
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
-       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-1.2.xsd">\r
-\r
-       <!-- Hello world -->\r
-       <flow:flow name="hello">\r
-               <description>Print Hello World!</description>\r
-               <bean p:message="Hello World!" class="org.argeo.slc.core.execution.tasks.Echo" />\r
-       </flow:flow>\r
-\r
-\r
-       <flow:flow name="HelloWorld/WithVar">\r
-               <description>Print Hello World! with variable</description>\r
-               <flow:spec>\r
-                       <flow:primitive name="testKey" value="777" />\r
-               </flow:spec>\r
-               <bean p:message="Hello World! @{testKey}" class="org.argeo.slc.core.execution.tasks.Echo">\r
-                       <flow:variable proxy-target-class="false" />\r
-               </bean>\r
-       </flow:flow>\r
-\r
-</beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/osgi.xml b/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/osgi.xml
deleted file mode 100644 (file)
index f505229..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
-</beans:beans>
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.minimal/bnd.bnd b/demo/modules/org.argeo.slc.demo.minimal/bnd.bnd
deleted file mode 100644 (file)
index 758b56d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#Import-Package: org.argeo.slc.runtime,\
-#*
\ No newline at end of file
diff --git a/demo/modules/org.argeo.slc.demo.minimal/build.properties b/demo/modules/org.argeo.slc.demo.minimal/build.properties
deleted file mode 100644 (file)
index 5f22cdd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-bin.includes = META-INF/
diff --git a/demo/modules/org.argeo.slc.demo.minimal/pom.xml b/demo/modules/org.argeo.slc.demo.minimal/pom.xml
deleted file mode 100644 (file)
index dc74700..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc.demo</groupId>
-               <artifactId>modules</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.demo.minimal</artifactId>
-       <name>SLC Demo Minimal</name>
-</project>
\ No newline at end of file
diff --git a/demo/modules/pom.xml b/demo/modules/pom.xml
deleted file mode 100644 (file)
index 105634e..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>demo</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <groupId>org.argeo.slc.demo</groupId>
-       <artifactId>modules</artifactId>
-       <packaging>pom</packaging>
-       <name>SLC Demo Modules</name>
-       <modules>
-               <module>org.argeo.slc.demo.ant</module>
-               <module>org.argeo.slc.demo.basic</module>
-               <module>org.argeo.slc.demo.minimal</module>
-       </modules>
-       <properties>
-               <additionalImports.slc-lib>
-                       com.jcraft.jsch;resolution:=optional,
-                       org.apache.commons.exec;resolution:=optional,
-               </additionalImports.slc-lib>
-       </properties>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.felix</groupId>
-                               <artifactId>maven-bundle-plugin</artifactId>
-                               <configuration>
-                                       <instructions>
-                                               <SLC-ExecutionModule>default</SLC-ExecutionModule>
-                                               <!-- Minimal imports + some optional convenience imports -->
-                                               <Import-Package>
-                                                       org.springframework.cglib.proxy,
-                                                       org.springframework.cglib.core,
-                                                       org.springframework.cglib.reflect,
-                                                       org.aopalliance.aop,
-                                                       org.argeo.slc.primitive,
-                                                       org.argeo.slc.attachment,
-                                                       org.argeo.slc.runtime,
-                                                       org.argeo.slc.runtime.test,
-                                                       org.argeo.slc.core.execution,
-                                                       org.argeo.slc.core.execution.tasks,
-                                                       org.argeo.slc.core.test,
-                                                       org.argeo.slc.execution,
-                                                       org.argeo.slc.osgi,
-                                                       org.argeo.slc.test,
-                                                       org.springframework.aop,
-                                                       org.springframework.aop.framework,
-                                                       org.springframework.aop.scope,
-                                                       org.springframework.beans.factory.config,
-                                                       org.springframework.core.io,
-                                                       ${additionalImports.slc-lib},
-                                                       *
-                                               </Import-Package>
-                                       </instructions>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
-       <dependencies>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.dep.minimal</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-                       <type>pom</type>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.dep.backend</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-                       <type>pom</type>
-                       <optional>true</optional>
-               </dependency>
-       </dependencies>
-</project>
diff --git a/demo/pom.xml b/demo/pom.xml
deleted file mode 100644 (file)
index 67cb368..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>demo</artifactId>
-       <packaging>pom</packaging>
-       <name>SLC Demo</name>
-       <modules>
-               <module>modules</module>
-       </modules>
-</project>
diff --git a/dep/org.argeo.slc.dep.backend/.gitignore b/dep/org.argeo.slc.dep.backend/.gitignore
deleted file mode 100644 (file)
index 583e927..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/target/
-/org.argeo.slc.dep.backend-maven.target
diff --git a/dep/org.argeo.slc.dep.backend/META-INF/.gitignore b/dep/org.argeo.slc.dep.backend/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/dep/org.argeo.slc.dep.backend/bnd.bnd b/dep/org.argeo.slc.dep.backend/bnd.bnd
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/dep/org.argeo.slc.dep.backend/p2.inf b/dep/org.argeo.slc.dep.backend/p2.inf
deleted file mode 100644 (file)
index 0423aa5..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-properties.1.name=org.eclipse.equinox.p2.type.category
-properties.1.value=true
\ No newline at end of file
diff --git a/dep/org.argeo.slc.dep.backend/pom.xml b/dep/org.argeo.slc.dep.backend/pom.xml
deleted file mode 100644 (file)
index 92b4ee4..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>dep</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.dep.backend</artifactId>
-       <name>SLC Backend</name>
-       <properties>
-               <argeo.rpm.stagingRepository>/srv/rpmfactory/legacy/argeo-osgi-2/argeo</argeo.rpm.stagingRepository>
-       </properties>
-       <dependencies>
-               <!-- SLC Minimal -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.dep.spring</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-                       <type>pom</type>
-               </dependency>
-
-               <!-- SLC Libs -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.slc</groupId> -->
-               <!-- <artifactId>org.argeo.slc.lib.repo</artifactId> -->
-               <!-- <version>1.1.14-SNAPSHOT</version> -->
-               <!-- </dependency> -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.slc</groupId> -->
-               <!-- <artifactId>org.argeo.slc.lib.jcr</artifactId> -->
-               <!-- <version>1.1.14-SNAPSHOT</version> -->
-               <!-- </dependency> -->
-
-               <!-- Extensions -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.support</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.server.repo</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.slc</groupId> -->
-               <!-- <artifactId>org.argeo.slc.server.repo.webapp</artifactId> -->
-               <!-- <version>2.1.1-SNAPSHOT</version> -->
-               <!-- </dependency> -->
-
-               <!-- UI -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.client.ui</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.client.ui.dist</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.client.rap</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-
-               <!-- OSGi Boot for platform generation only, as it could be used by regular 
-                       Java applications to launch an OSGi runtime. -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.osgi.boot</artifactId>
-                       <version>${version.argeo-commons}</version>
-                       <scope>test</scope>
-               </dependency>
-
-               <!-- Legacy Argeo Commons platform (Eclipse 3) -->
-               <dependency>
-                       <groupId>org.argeo.slc.legacy.commons</groupId>
-                       <artifactId>org.argeo.dep.cms.platform</artifactId>
-                       <version>${version.argeo-commons-legacy}</version>
-                       <type>pom</type>
-               </dependency>
-
-               <dependency>
-                       <groupId>org.argeo.tp.misc</groupId>
-                       <artifactId>com.googlecode.javaewah.JavaEWAH</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.misc</groupId>
-                       <artifactId>org.eclipse.jgit</artifactId>
-               </dependency>
-       </dependencies>
-       <profiles>
-               <profile>
-                       <id>rpmbuild</id>
-                       <build>
-                               <plugins>
-                                       <plugin>
-                                               <artifactId>maven-assembly-plugin</artifactId>
-                                               <executions>
-                                                       <execution>
-                                                               <id>prepare-source</id>
-                                                               <phase>package</phase>
-                                                               <goals>
-                                                                       <goal>single</goal>
-                                                               </goals>
-                                                               <configuration>
-                                                                       <descriptorRefs>
-                                                                               <descriptorRef>a2-source</descriptorRef>
-                                                                       </descriptorRefs>
-                                                               </configuration>
-                                                       </execution>
-                                               </executions>
-                                       </plugin>
-                                       <plugin>
-                                               <groupId>org.codehaus.mojo</groupId>
-                                               <artifactId>rpm-maven-plugin</artifactId>
-                                               <executions>
-                                                       <execution>
-                                                               <id>rpm-argeo</id>
-                                                               <phase>package</phase>
-                                                               <goals>
-                                                                       <goal>rpm</goal>
-                                                               </goals>
-                                                               <configuration>
-                                                                       <name>slc-platform</name>
-                                                                       <mappings>
-                                                                               <mapping>
-                                                                                       <directory>/usr/share/osgi</directory>
-                                                                                       <username>root</username>
-                                                                                       <groupname>root</groupname>
-                                                                                       <filemode>644</filemode>
-                                                                                       <directoryIncluded>true</directoryIncluded>
-                                                                                       <sources>
-                                                                                               <source>
-                                                                                                       <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
-                                                                                                       <includes>
-                                                                                                               <include>**/*.jar</include>
-                                                                                                       </includes>
-                                                                                               </source>
-                                                                                       </sources>
-                                                                               </mapping>
-                                                                       </mappings>
-                                                                       <requires>
-                                                                               <require>argeo-cms-platform</require>
-                                                                               <require>slc-spring</require>
-                                                                       </requires>
-                                                               </configuration>
-                                                       </execution>
-                                               </executions>
-                                       </plugin>
-                               </plugins>
-                       </build>
-               </profile>
-       </profiles>
-</project>
\ No newline at end of file
index 8a48e995cb5b47bd868c230b02f2d09abe32d4bf..dda7e333dfaab86e60ee920df083e74058c96744 100644 (file)
                <dependency>
                        <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.slc.api</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
+                       <version>2.3-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.slc.runtime</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
+                       <version>2.3-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.slc.jcr</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
+                       <version>2.3-SNAPSHOT</version>
                </dependency>
 
                <!-- SLC Repo -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.slc.repo</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
+                       <version>2.3-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.slc.factory</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
+                       <version>2.3-SNAPSHOT</version>
                </dependency>
 
                <!-- CMS extensions -->
                <dependency>
                        <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.cms.integration</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
+                       <version>2.3-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.argeo.slc</groupId>
                        <artifactId>org.argeo.ext.equinox.jetty</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
+                       <version>2.3-SNAPSHOT</version>
                </dependency>
 
                <!-- CLI Agent -->
diff --git a/dep/org.argeo.slc.dep.spring.e4.rap/.gitignore b/dep/org.argeo.slc.dep.spring.e4.rap/.gitignore
deleted file mode 100644 (file)
index 5931da6..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/target/
-*.target
diff --git a/dep/org.argeo.slc.dep.spring.e4.rap/META-INF/.gitignore b/dep/org.argeo.slc.dep.spring.e4.rap/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/dep/org.argeo.slc.dep.spring.e4.rap/bnd.bnd b/dep/org.argeo.slc.dep.spring.e4.rap/bnd.bnd
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/dep/org.argeo.slc.dep.spring.e4.rap/pom.xml b/dep/org.argeo.slc.dep.spring.e4.rap/pom.xml
deleted file mode 100644 (file)
index 91848b1..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>dep</artifactId>
-               <version>2.1.18-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.dep.spring.e4.rap</artifactId>
-       <name>SLC Spring E4 RAP</name>
-       <dependencies>
-               <!-- Parent dependencies -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.dep.cms.sdk</artifactId>
-                       <version>${version.argeo-commons}</version>
-                       <type>pom</type>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.dep.spring</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-                       <type>pom</type>
-               </dependency>
-
-
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.e4</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-
-               <!-- OSGi Boot for platform generation only, as it could be used by regular 
-                       Java applications to launch an OSGi runtime. -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.osgi.boot</artifactId>
-                       <version>${version.argeo-commons}</version>
-                       <scope>test</scope>
-               </dependency>
-
-               <!-- ALM Third Parties -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.tp.apache.ant</groupId> -->
-               <!-- <artifactId>org.apache.ant</artifactId> -->
-               <!-- </dependency> -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.tp.apache.ant</groupId> -->
-               <!-- <artifactId>org.apache.ant.launch</artifactId> -->
-               <!-- </dependency> -->
-
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.tp.sdk</groupId> -->
-               <!-- <artifactId>biz.aQute.bndlib</artifactId> -->
-               <!-- </dependency> -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.tp.sdk</groupId> -->
-               <!-- <artifactId>org.junit</artifactId> -->
-               <!-- </dependency> -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.tp.sdk</groupId> -->
-               <!-- <artifactId>org.redline-rpm</artifactId> -->
-               <!-- </dependency> -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.tp.misc</groupId> -->
-               <!-- <artifactId>com.googlecode.javaewah.JavaEWAH</artifactId> -->
-               <!-- </dependency> -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.tp.misc</groupId> -->
-               <!-- <artifactId>org.eclipse.jgit</artifactId> -->
-               <!-- </dependency> -->
-       </dependencies>
-       <profiles>
-               <profile>
-                       <id>rpmbuild</id>
-                       <build>
-                               <plugins>
-                                       <plugin>
-                                               <artifactId>maven-assembly-plugin</artifactId>
-                                               <executions>
-                                                       <execution>
-                                                               <id>prepare-source</id>
-                                                               <phase>package</phase>
-                                                               <goals>
-                                                                       <goal>single</goal>
-                                                               </goals>
-                                                               <configuration>
-                                                                       <descriptorRefs>
-                                                                               <descriptorRef>a2-source</descriptorRef>
-                                                                       </descriptorRefs>
-                                                               </configuration>
-                                                       </execution>
-                                               </executions>
-                                       </plugin>
-                                       <plugin>
-                                               <groupId>org.codehaus.mojo</groupId>
-                                               <artifactId>rpm-maven-plugin</artifactId>
-                                               <executions>
-                                                       <execution>
-                                                               <id>rpm-argeo</id>
-                                                               <phase>package</phase>
-                                                               <goals>
-                                                                       <goal>rpm</goal>
-                                                               </goals>
-                                                               <configuration>
-                                                                       <name>slc-e4-rap</name>
-                                                                       <mappings>
-                                                                               <mapping>
-                                                                                       <directory>/usr/share/osgi</directory>
-                                                                                       <username>root</username>
-                                                                                       <groupname>root</groupname>
-                                                                                       <filemode>644</filemode>
-                                                                                       <directoryIncluded>true</directoryIncluded>
-                                                                                       <sources>
-                                                                                               <source>
-                                                                                                       <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
-                                                                                                       <includes>
-                                                                                                               <include>**/*.jar</include>
-                                                                                                       </includes>
-                                                                                               </source>
-                                                                                       </sources>
-                                                                               </mapping>
-                                                                       </mappings>
-                                                                       <requires>
-                                                                               <require>argeo-cms-e4-rap</require>
-                                                                               <require>argeo-cms-sdk-tp</require>
-                                                                               <require>slc-agent</require>
-                                                                       </requires>
-                                                               </configuration>
-                                                       </execution>
-                                               </executions>
-                                       </plugin>
-                               </plugins>
-                       </build>
-               </profile>
-       </profiles>
-</project>
\ No newline at end of file
diff --git a/dep/org.argeo.slc.dep.spring/.gitignore b/dep/org.argeo.slc.dep.spring/.gitignore
deleted file mode 100644 (file)
index 76df179..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/target/
-/*.target
diff --git a/dep/org.argeo.slc.dep.spring/META-INF/.gitignore b/dep/org.argeo.slc.dep.spring/META-INF/.gitignore
deleted file mode 100644 (file)
index 4854a41..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/MANIFEST.MF
diff --git a/dep/org.argeo.slc.dep.spring/bnd.bnd b/dep/org.argeo.slc.dep.spring/bnd.bnd
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/dep/org.argeo.slc.dep.spring/pom.xml b/dep/org.argeo.slc.dep.spring/pom.xml
deleted file mode 100644 (file)
index 11e61df..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>dep</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.slc.dep.spring</artifactId>
-       <name>SLC Agent based on Spring</name>
-       <properties>
-               <argeo.rpm.stagingRepository>/srv/rpmfactory/legacy/argeo-osgi-2/argeo</argeo.rpm.stagingRepository>
-       </properties>
-       <dependencies>
-               <!-- Parent dependencies -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.dep.minimal</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-                       <type>pom</type>
-               </dependency>
-
-               <!-- Spring-based Agent -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.spring</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.support</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.agent</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.agent.jcr</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Transitional fake Java 8 APIs, required by old version of Spring, 
-                       in the process of being removed -->
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.legacy.fake.java8</artifactId>
-                       <version>2.1.18-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Not strictly Spring dependencies but used by the old approach -->
-               <dependency>
-                       <groupId>org.argeo.tp.apache.ant</groupId>
-                       <artifactId>org.apache.ant</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.apache.ant</groupId>
-                       <artifactId>org.apache.ant.launch</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.javax</groupId>
-                       <artifactId>javax.mail</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.misc</groupId>
-                       <artifactId>com.jcraft.jsch</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.apache.commons</groupId>
-                       <artifactId>org.apache.commons.vfs</artifactId>
-               </dependency>
-
-               <!-- Base Spring dependency -->
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.beans</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.core</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.javax</groupId>
-                       <artifactId>javax.el</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.gemini</groupId>
-                       <artifactId>org.eclipse.gemini.blueprint.core</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.gemini</groupId>
-                       <artifactId>org.eclipse.gemini.blueprint.extender</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.gemini</groupId>
-                       <artifactId>org.eclipse.gemini.blueprint.io</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.misc</groupId>
-                       <artifactId>org.aspectj.weaver</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.misc</groupId>
-                       <artifactId>org.aopalliance</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.aop</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.context</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.expression</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.instrument</artifactId>
-               </dependency>
-
-               <!-- Spring -->
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.aspects</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.context.support</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.jdbc</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.tx</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.web</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.tp.spring</groupId>
-                       <artifactId>org.springframework.web.servlet</artifactId>
-               </dependency>
-
-               <!-- CLI Agent -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.slc</groupId> -->
-               <!-- <artifactId>org.argeo.slc.launcher</artifactId> -->
-               <!-- <version>1.1.12-SNAPSHOT</version> -->
-               <!-- </dependency> -->
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.slc</groupId> -->
-               <!-- <artifactId>org.argeo.slc.agent.cli</artifactId> -->
-               <!-- <version>2.1.1-SNAPSHOT</version> -->
-               <!-- </dependency> -->
-       </dependencies>
-       <profiles>
-               <profile>
-                       <id>rpmbuild</id>
-                       <build>
-                               <plugins>
-                                       <plugin>
-                                               <artifactId>maven-assembly-plugin</artifactId>
-                                               <executions>
-                                                       <execution>
-                                                               <id>prepare-source</id>
-                                                               <phase>package</phase>
-                                                               <goals>
-                                                                       <goal>single</goal>
-                                                               </goals>
-                                                               <configuration>
-                                                                       <descriptorRefs>
-                                                                               <descriptorRef>a2-source</descriptorRef>
-                                                                       </descriptorRefs>
-                                                               </configuration>
-                                                       </execution>
-                                               </executions>
-                                       </plugin>
-                                       <plugin>
-                                               <groupId>org.codehaus.mojo</groupId>
-                                               <artifactId>rpm-maven-plugin</artifactId>
-                                               <executions>
-                                                       <execution>
-                                                               <id>rpm-argeo</id>
-                                                               <phase>package</phase>
-                                                               <goals>
-                                                                       <goal>rpm</goal>
-                                                               </goals>
-                                                               <configuration>
-                                                                       <name>slc-spring</name>
-                                                                       <mappings>
-                                                                               <mapping>
-                                                                                       <directory>/usr/share/osgi</directory>
-                                                                                       <username>root</username>
-                                                                                       <groupname>root</groupname>
-                                                                                       <filemode>644</filemode>
-                                                                                       <directoryIncluded>true</directoryIncluded>
-                                                                                       <sources>
-                                                                                               <source>
-                                                                                                       <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
-                                                                                                       <includes>
-                                                                                                               <include>**/*.jar</include>
-                                                                                                       </includes>
-                                                                                               </source>
-                                                                                       </sources>
-                                                                               </mapping>
-                                                                       </mappings>
-                                                                       <requires>
-                                                                               <require>argeo-cms-node</require>
-                                                                               <require>argeo-slc</require>
-                                                                               <require>argeo-slc-tp</require>
-                                                                               <require>slc-spring-tp</require>
-                                                                       </requires>
-                                                               </configuration>
-                                                       </execution>
-                                               </executions>
-                                       </plugin>
-                               </plugins>
-                       </build>
-               </profile>
-               <profile>
-                       <id>rpmbuild-tp</id>
-                       <build>
-                               <plugins>
-                                       <plugin>
-                                               <artifactId>maven-assembly-plugin</artifactId>
-                                               <executions>
-                                                       <execution>
-                                                               <id>prepare-source-tp</id>
-                                                               <phase>package</phase>
-                                                               <goals>
-                                                                       <goal>single</goal>
-                                                               </goals>
-                                                               <configuration>
-                                                                       <descriptorRefs>
-                                                                               <descriptorRef>a2-source-tp</descriptorRef>
-                                                                       </descriptorRefs>
-                                                               </configuration>
-                                                       </execution>
-                                               </executions>
-                                       </plugin>
-                                       <plugin>
-                                               <groupId>org.codehaus.mojo</groupId>
-                                               <artifactId>rpm-maven-plugin</artifactId>
-                                               <executions>
-                                                       <execution>
-                                                               <id>rpm-tp</id>
-                                                               <phase>package</phase>
-                                                               <goals>
-                                                                       <goal>rpm</goal>
-                                                               </goals>
-                                                               <configuration>
-                                                                       <name>slc-spring-tp</name>
-                                                                       <projversion>${version.argeo-tp}</projversion>
-                                                                       <release>${maven.build.timestamp}</release>
-                                                                       <mappings>
-                                                                               <mapping>
-                                                                                       <directory>/usr/share/osgi</directory>
-                                                                                       <username>root</username>
-                                                                                       <groupname>root</groupname>
-                                                                                       <filemode>644</filemode>
-                                                                                       <directoryIncluded>false</directoryIncluded>
-                                                                                       <sources>
-                                                                                               <source>
-                                                                                                       <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source-tp</location>
-                                                                                                       <includes>
-                                                                                                               <include>**/*.jar</include>
-                                                                                                       </includes>
-                                                                                               </source>
-                                                                                       </sources>
-                                                                               </mapping>
-                                                                       </mappings>
-                                                               </configuration>
-                                                       </execution>
-                                               </executions>
-                                       </plugin>
-                               </plugins>
-                       </build>
-               </profile>
-       </profiles>
-</project>
\ No newline at end of file
index e73a4ae416f94fd6acebbe71bc7032590d85a518..33c2e9d068e632685e11e14d3bad77a088abaafd 100644 (file)
@@ -12,9 +12,6 @@
        <modules>
                <module>org.argeo.slc.dep.minimal</module>
                <module>org.argeo.slc.dep.e4.rap</module>
-               <!--  Legacy -->
-               <module>org.argeo.slc.dep.spring</module>
-               <module>org.argeo.slc.dep.backend</module>
        </modules>
        <build>
                <plugins>
index 1b80743401a995a4f3dad6afbe8533d4219b0385..7a1611908de244034aa2394b0337227a3126f38d 100644 (file)
        <name>SLC Distribution</name>
        <modules>
                <module>slc</module>
-<!--           <module>slc-maven</module> -->
        </modules>
-       <!-- <profiles> -->
-       <!-- <profile> -->
-       <!-- <id>rpmbuild</id> -->
-       <!-- <build> -->
-       <!-- <plugins> -->
-       <!-- <plugin> -->
-       <!-- <artifactId>maven-antrun-plugin</artifactId> -->
-       <!-- <executions> -->
-       <!-- <execution> -->
-       <!-- <phase>install</phase> -->
-       <!-- <goals> -->
-       <!-- <goal>run</goal> -->
-       <!-- </goals> -->
-       <!-- <configuration> -->
-       <!-- <target> -->
-       <!-- <copy todir="${rpm.stagingRepository}" verbose="true" failonerror="false"> -->
-       <!-- <fileset dir="${project.build.directory}/rpm" includes="*/RPMS/**/*.rpm" /> -->
-       <!-- <flattenmapper /> -->
-       <!-- </copy> -->
-       <!-- </target> -->
-       <!-- </configuration> -->
-       <!-- </execution> -->
-       <!-- </executions> -->
-       <!-- </plugin> -->
-       <!-- </plugins> -->
-       <!-- </build> -->
-       <!-- </profile> -->
-       <!-- </profiles> -->
 </project>
\ No newline at end of file
diff --git a/dist/slc-maven/.gitignore b/dist/slc-maven/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/dist/slc-maven/pom.xml b/dist/slc-maven/pom.xml
deleted file mode 100644 (file)
index 522d61c..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>dist</artifactId>
-               <version>2.1.10-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>slc-maven</artifactId>
-       <packaging>pom</packaging>
-       <name>SLC Distribution Maven</name>
-       <dependencies>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.support.maven</artifactId>
-                       <version>2.1.10-SNAPSHOT</version>
-               </dependency>
-               <!-- <dependency> -->
-               <!-- <groupId>org.argeo.slc</groupId> -->
-               <!-- <artifactId>org.argeo.slc.lib.build</artifactId> -->
-               <!-- <version>2.1.10-SNAPSHOT</version> -->
-               <!-- </dependency> -->
-       </dependencies>
-       <profiles>
-               <profile>
-                       <id>rpmbuild</id>
-                       <build>
-                               <plugins>
-                                       <plugin>
-                                               <groupId>org.codehaus.mojo</groupId>
-                                               <artifactId>rpm-maven-plugin</artifactId>
-                                               <executions>
-                                                       <execution>
-                                                               <id>rpm-slc-maven</id>
-                                                               <phase>package</phase>
-                                                               <goals>
-                                                                       <goal>rpm</goal>
-                                                               </goals>
-                                                               <configuration>
-                                                                       <name>slc-maven</name>
-                                                                       <version>${version.maven}</version>
-                                                                       <copyright>2011 Argeo</copyright>
-                                                                       <mappings>
-                                                                               <mapping>
-                                                                                       <directory>/usr/share/osgi</directory>
-                                                                                       <username>root</username>
-                                                                                       <groupname>root</groupname>
-                                                                                       <filemode>644</filemode>
-                                                                                       <directoryIncluded>false</directoryIncluded>
-                                                                                       <dependency>
-                                                                                               <includes>
-                                                                                                       <include>org.argeo.slc:org.argeo.slc.support.maven</include>
-                                                                                                       <!-- <include>org.argeo.slc:org.argeo.slc.lib.build</include> -->
-                                                                                               </includes>
-                                                                                       </dependency>
-                                                                               </mapping>
-                                                                       </mappings>
-                                                                       <requires>
-                                                                               <require>slc-platform</require>
-                                                                       </requires>
-                                                               </configuration>
-                                                       </execution>
-                                               </executions>
-                                       </plugin>
-                               </plugins>
-                       </build>
-               </profile>
-       </profiles>
-</project>
\ No newline at end of file
diff --git a/legacy/dep/cnf/maven.bnd b/legacy/dep/cnf/maven.bnd
new file mode 100644 (file)
index 0000000..4bd5c0c
--- /dev/null
@@ -0,0 +1 @@
+-include: ../../cnf/maven.bnd
\ No newline at end of file
diff --git a/legacy/dep/org.argeo.slc.dep.backend/.gitignore b/legacy/dep/org.argeo.slc.dep.backend/.gitignore
new file mode 100644 (file)
index 0000000..583e927
--- /dev/null
@@ -0,0 +1,2 @@
+/target/
+/org.argeo.slc.dep.backend-maven.target
diff --git a/legacy/dep/org.argeo.slc.dep.backend/META-INF/.gitignore b/legacy/dep/org.argeo.slc.dep.backend/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/dep/org.argeo.slc.dep.backend/bnd.bnd b/legacy/dep/org.argeo.slc.dep.backend/bnd.bnd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/legacy/dep/org.argeo.slc.dep.backend/p2.inf b/legacy/dep/org.argeo.slc.dep.backend/p2.inf
new file mode 100644 (file)
index 0000000..0423aa5
--- /dev/null
@@ -0,0 +1,2 @@
+properties.1.name=org.eclipse.equinox.p2.type.category
+properties.1.value=true
\ No newline at end of file
diff --git a/legacy/dep/org.argeo.slc.dep.backend/pom.xml b/legacy/dep/org.argeo.slc.dep.backend/pom.xml
new file mode 100644 (file)
index 0000000..92b4ee4
--- /dev/null
@@ -0,0 +1,159 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>dep</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.dep.backend</artifactId>
+       <name>SLC Backend</name>
+       <properties>
+               <argeo.rpm.stagingRepository>/srv/rpmfactory/legacy/argeo-osgi-2/argeo</argeo.rpm.stagingRepository>
+       </properties>
+       <dependencies>
+               <!-- SLC Minimal -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.dep.spring</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+                       <type>pom</type>
+               </dependency>
+
+               <!-- SLC Libs -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.lib.repo</artifactId> -->
+               <!-- <version>1.1.14-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.lib.jcr</artifactId> -->
+               <!-- <version>1.1.14-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+
+               <!-- Extensions -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.support</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.server.repo</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.server.repo.webapp</artifactId> -->
+               <!-- <version>2.1.1-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+
+               <!-- UI -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.client.ui</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.client.ui.dist</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.client.rap</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+
+               <!-- OSGi Boot for platform generation only, as it could be used by regular 
+                       Java applications to launch an OSGi runtime. -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.osgi.boot</artifactId>
+                       <version>${version.argeo-commons}</version>
+                       <scope>test</scope>
+               </dependency>
+
+               <!-- Legacy Argeo Commons platform (Eclipse 3) -->
+               <dependency>
+                       <groupId>org.argeo.slc.legacy.commons</groupId>
+                       <artifactId>org.argeo.dep.cms.platform</artifactId>
+                       <version>${version.argeo-commons-legacy}</version>
+                       <type>pom</type>
+               </dependency>
+
+               <dependency>
+                       <groupId>org.argeo.tp.misc</groupId>
+                       <artifactId>com.googlecode.javaewah.JavaEWAH</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.misc</groupId>
+                       <artifactId>org.eclipse.jgit</artifactId>
+               </dependency>
+       </dependencies>
+       <profiles>
+               <profile>
+                       <id>rpmbuild</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <artifactId>maven-assembly-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>prepare-source</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>single</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <descriptorRefs>
+                                                                               <descriptorRef>a2-source</descriptorRef>
+                                                                       </descriptorRefs>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                                       <plugin>
+                                               <groupId>org.codehaus.mojo</groupId>
+                                               <artifactId>rpm-maven-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>rpm-argeo</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>rpm</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <name>slc-platform</name>
+                                                                       <mappings>
+                                                                               <mapping>
+                                                                                       <directory>/usr/share/osgi</directory>
+                                                                                       <username>root</username>
+                                                                                       <groupname>root</groupname>
+                                                                                       <filemode>644</filemode>
+                                                                                       <directoryIncluded>true</directoryIncluded>
+                                                                                       <sources>
+                                                                                               <source>
+                                                                                                       <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
+                                                                                                       <includes>
+                                                                                                               <include>**/*.jar</include>
+                                                                                                       </includes>
+                                                                                               </source>
+                                                                                       </sources>
+                                                                               </mapping>
+                                                                       </mappings>
+                                                                       <requires>
+                                                                               <require>argeo-cms-platform</require>
+                                                                               <require>slc-spring</require>
+                                                                       </requires>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+</project>
\ No newline at end of file
diff --git a/legacy/dep/org.argeo.slc.dep.spring/.gitignore b/legacy/dep/org.argeo.slc.dep.spring/.gitignore
new file mode 100644 (file)
index 0000000..76df179
--- /dev/null
@@ -0,0 +1,2 @@
+/target/
+/*.target
diff --git a/legacy/dep/org.argeo.slc.dep.spring/META-INF/.gitignore b/legacy/dep/org.argeo.slc.dep.spring/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/dep/org.argeo.slc.dep.spring/bnd.bnd b/legacy/dep/org.argeo.slc.dep.spring/bnd.bnd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/legacy/dep/org.argeo.slc.dep.spring/pom.xml b/legacy/dep/org.argeo.slc.dep.spring/pom.xml
new file mode 100644 (file)
index 0000000..11e61df
--- /dev/null
@@ -0,0 +1,287 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>dep</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.dep.spring</artifactId>
+       <name>SLC Agent based on Spring</name>
+       <properties>
+               <argeo.rpm.stagingRepository>/srv/rpmfactory/legacy/argeo-osgi-2/argeo</argeo.rpm.stagingRepository>
+       </properties>
+       <dependencies>
+               <!-- Parent dependencies -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.dep.minimal</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+                       <type>pom</type>
+               </dependency>
+
+               <!-- Spring-based Agent -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.spring</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.support</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.agent</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.agent.jcr</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Transitional fake Java 8 APIs, required by old version of Spring, 
+                       in the process of being removed -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.legacy.fake.java8</artifactId>
+                       <version>2.1.18-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Not strictly Spring dependencies but used by the old approach -->
+               <dependency>
+                       <groupId>org.argeo.tp.apache.ant</groupId>
+                       <artifactId>org.apache.ant</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.apache.ant</groupId>
+                       <artifactId>org.apache.ant.launch</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.javax</groupId>
+                       <artifactId>javax.mail</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.misc</groupId>
+                       <artifactId>com.jcraft.jsch</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.apache.commons</groupId>
+                       <artifactId>org.apache.commons.vfs</artifactId>
+               </dependency>
+
+               <!-- Base Spring dependency -->
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.beans</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.javax</groupId>
+                       <artifactId>javax.el</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.gemini</groupId>
+                       <artifactId>org.eclipse.gemini.blueprint.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.gemini</groupId>
+                       <artifactId>org.eclipse.gemini.blueprint.extender</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.gemini</groupId>
+                       <artifactId>org.eclipse.gemini.blueprint.io</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.misc</groupId>
+                       <artifactId>org.aspectj.weaver</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.misc</groupId>
+                       <artifactId>org.aopalliance</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.aop</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.context</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.expression</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.instrument</artifactId>
+               </dependency>
+
+               <!-- Spring -->
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.aspects</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.context.support</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.jdbc</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.tx</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.web</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.web.servlet</artifactId>
+               </dependency>
+
+               <!-- CLI Agent -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.launcher</artifactId> -->
+               <!-- <version>1.1.12-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.agent.cli</artifactId> -->
+               <!-- <version>2.1.1-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+       </dependencies>
+       <profiles>
+               <profile>
+                       <id>rpmbuild</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <artifactId>maven-assembly-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>prepare-source</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>single</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <descriptorRefs>
+                                                                               <descriptorRef>a2-source</descriptorRef>
+                                                                       </descriptorRefs>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                                       <plugin>
+                                               <groupId>org.codehaus.mojo</groupId>
+                                               <artifactId>rpm-maven-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>rpm-argeo</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>rpm</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <name>slc-spring</name>
+                                                                       <mappings>
+                                                                               <mapping>
+                                                                                       <directory>/usr/share/osgi</directory>
+                                                                                       <username>root</username>
+                                                                                       <groupname>root</groupname>
+                                                                                       <filemode>644</filemode>
+                                                                                       <directoryIncluded>true</directoryIncluded>
+                                                                                       <sources>
+                                                                                               <source>
+                                                                                                       <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
+                                                                                                       <includes>
+                                                                                                               <include>**/*.jar</include>
+                                                                                                       </includes>
+                                                                                               </source>
+                                                                                       </sources>
+                                                                               </mapping>
+                                                                       </mappings>
+                                                                       <requires>
+                                                                               <require>argeo-cms-node</require>
+                                                                               <require>argeo-slc</require>
+                                                                               <require>argeo-slc-tp</require>
+                                                                               <require>slc-spring-tp</require>
+                                                                       </requires>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+               <profile>
+                       <id>rpmbuild-tp</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <artifactId>maven-assembly-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>prepare-source-tp</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>single</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <descriptorRefs>
+                                                                               <descriptorRef>a2-source-tp</descriptorRef>
+                                                                       </descriptorRefs>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                                       <plugin>
+                                               <groupId>org.codehaus.mojo</groupId>
+                                               <artifactId>rpm-maven-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>rpm-tp</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>rpm</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <name>slc-spring-tp</name>
+                                                                       <projversion>${version.argeo-tp}</projversion>
+                                                                       <release>${maven.build.timestamp}</release>
+                                                                       <mappings>
+                                                                               <mapping>
+                                                                                       <directory>/usr/share/osgi</directory>
+                                                                                       <username>root</username>
+                                                                                       <groupname>root</groupname>
+                                                                                       <filemode>644</filemode>
+                                                                                       <directoryIncluded>false</directoryIncluded>
+                                                                                       <sources>
+                                                                                               <source>
+                                                                                                       <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source-tp</location>
+                                                                                                       <includes>
+                                                                                                               <include>**/*.jar</include>
+                                                                                                       </includes>
+                                                                                               </source>
+                                                                                       </sources>
+                                                                               </mapping>
+                                                                       </mappings>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+</project>
\ No newline at end of file
diff --git a/legacy/dep/pom.xml b/legacy/dep/pom.xml
new file mode 100644 (file)
index 0000000..852a91f
--- /dev/null
@@ -0,0 +1,98 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>legacy-dep</artifactId>
+       <name>SLC LEgacy Dependencies</name>
+       <packaging>pom</packaging>
+       <modules>
+               <module>org.argeo.slc.dep.spring</module>
+               <module>org.argeo.slc.dep.backend</module>
+       </modules>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <configuration>
+                                       <instructions>
+                                               <SLC-ModularDistribution>default</SLC-ModularDistribution>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.argeo.maven.plugins</groupId>
+                               <artifactId>argeo-osgi-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <id>generate-descriptors</id>
+                                               <goals>
+                                                       <goal>descriptors</goal>
+                                               </goals>
+                                               <phase>generate-resources</phase>
+                                       </execution>
+                               </executions>
+                       </plugin>
+                       <plugin>
+                               <artifactId>maven-assembly-plugin</artifactId>
+                               <configuration>
+                                       <attach>false</attach>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>org.argeo.tp.equinox</groupId>
+                       <artifactId>org.eclipse.osgi</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.sdk</groupId>
+                       <artifactId>org.junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.sdk</groupId>
+                       <artifactId>org.hamcrest</artifactId>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+       <profiles>
+               <profile>
+                       <id>check-osgi</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <groupId>org.argeo.maven.plugins</groupId>
+                                               <artifactId>argeo-osgi-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>check-osgi</id>
+                                                               <phase>test</phase>
+                                                               <goals>
+                                                                       <goal>equinox</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <onlyCheck>true</onlyCheck>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+                       <dependencies>
+                               <dependency>
+                                       <groupId>org.argeo.commons</groupId>
+                                       <artifactId>org.argeo.osgi.boot</artifactId>
+                                       <version>${version.argeo-commons}</version>
+                                       <scope>test</scope>
+                               </dependency>
+                       </dependencies>
+               </profile>
+       </profiles>
+</project>
\ No newline at end of file
diff --git a/legacy/lib/.gitignore b/legacy/lib/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/lib/pom.xml b/legacy/lib/pom.xml
new file mode 100644 (file)
index 0000000..9e04232
--- /dev/null
@@ -0,0 +1,61 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>lib</artifactId>
+       <packaging>pom</packaging>
+       <name>SLC Standard Libs</name>
+       <description>SLC execution modules for generic tasks, to be used as parent pom</description>
+       <properties>
+               <additionalImports.slc-lib>
+                       com.jcraft.jsch;resolution:=optional,
+                       org.apache.commons.exec;resolution:=optional,
+               </additionalImports.slc-lib>
+       </properties>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <configuration>
+                                       <instructions>
+                                               <SLC-ExecutionModule>default</SLC-ExecutionModule>
+                                               <!-- Minimal imports + some optional convenience imports -->
+                                               <Import-Package>
+                                                       org.argeo.security.jackrabbit;resolution:="optional",
+                                                       org.springframework.cglib.proxy;resolution:="optional",
+                                                       org.springframework.cglib.core;resolution:="optional",
+                                                       org.springframework.cglib.reflect;resolution:="optional",
+                                                       org.aopalliance.aop;resolution:="optional",
+                                                       org.argeo.slc.runtime,
+                                                       org.argeo.slc.core.execution;resolution:="optional",
+                                                       org.argeo.slc.core.execution.tasks;resolution:="optional",
+                                                       org.argeo.slc.execution,
+                                                       org.argeo.slc.osgi;resolution:="optional",
+                                                       org.argeo.slc.test,
+                                                       org.springframework.aop;resolution:="optional",
+                                                       org.springframework.aop.framework;resolution:="optional",
+                                                       org.springframework.aop.scope;resolution:="optional",
+                                                       org.springframework.beans.factory.config;resolution:="optional",
+                                                       org.springframework.core.io;resolution:="optional",
+                                                       ${additionalImports.slc-lib},
+                                                       *
+                                               </Import-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.dep.minimal</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+                       <type>pom</type>
+               </dependency>
+       </dependencies>
+</project>
diff --git a/legacy/org.argeo.slc.agent.jcr/.gitignore b/legacy/org.argeo.slc.agent.jcr/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/org.argeo.slc.agent.jcr/.project b/legacy/org.argeo.slc.agent.jcr/.project
new file mode 100644 (file)
index 0000000..5aa7b5c
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.agent.jcr</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <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>
+       </natures>
+</projectDescription>
diff --git a/legacy/org.argeo.slc.agent.jcr/META-INF/.gitignore b/legacy/org.argeo.slc.agent.jcr/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml b/legacy/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml
new file mode 100644 (file)
index 0000000..848879f
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xmlns:util="http://www.springframework.org/schema/util"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/util\r
+       http://www.springframework.org/schema/util/spring-util-2.5.xsd">\r
+\r
+       <!-- REFERENCES -->\r
+       <reference id="repository" interface="javax.jcr.Repository"\r
+               filter="(cn=slc)" />\r
+\r
+<!--   <reference id="authenticationManager" -->\r
+<!--           interface="org.springframework.security.authentication.AuthenticationManager" /> -->\r
+\r
+       <reference id="modulesManager"\r
+               interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
+\r
+       <!-- SERVICES -->\r
+<!--   <service ref="attachmentUploader" interface="org.argeo.slc.core.attachment.AttachmentUploader" /> -->\r
+\r
+       <service interface="org.argeo.slc.execution.ExecutionModulesListener"\r
+               ref="executionModulesListener" />\r
+\r
+       <service ref="agent" interface="org.argeo.slc.execution.SlcAgent" />\r
+       <service ref="agentCli" interface="org.argeo.slc.execution.SlcAgentCli" />\r
+\r
+       <service ref="fileSystemManager" interface="org.apache.commons.vfs2.FileSystemManager" />\r
+</beans:beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.agent.jcr/META-INF/spring/jcr.xml b/legacy/org.argeo.slc.agent.jcr/META-INF/spring/jcr.xml
new file mode 100644 (file)
index 0000000..b15866d
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <bean id="agent" class="org.argeo.slc.jcr.execution.JcrAgent"\r
+               init-method="init" destroy-method="destroy">\r
+               <property name="defaultModulePrefix" value="org.argeo.slc.lib" />\r
+               <property name="repository" ref="repository" />\r
+               <property name="modulesManager" ref="modulesManager" />\r
+       </bean>\r
+\r
+       <bean id="agentCli" class="org.argeo.slc.core.execution.DefaultAgentCli">\r
+               <property name="agent" ref="agent" />\r
+<!--           <property name="authenticationManager" ref="authenticationManager" /> -->\r
+       </bean>\r
+\r
+       <bean id="executionModulesListener" class="org.argeo.slc.jcr.execution.JcrExecutionModulesListener"\r
+               init-method="init" destroy-method="destroy">\r
+               <property name="agent" ref="agent" />\r
+               <property name="repository" ref="repository" />\r
+               <property name="modulesManager" ref="modulesManager" />\r
+       </bean>\r
+\r
+       <!-- Thread-bound session is used when multiple threads with various authentication \r
+               will call the component -->\r
+<!--   <bean id="session" class="org.argeo.security.jcr.SecureThreadBoundSession"> -->\r
+<!--           <property name="repository" ref="repository" /> -->\r
+<!--   </bean> -->\r
+\r
+<!--   <bean id="attachmentUploader" class="org.argeo.slc.jcr.execution.JcrAttachmentUploader"> -->\r
+<!--   </bean> -->\r
+\r
+\r
+       <bean\r
+               class="org.argeo.slc.spring.AuthenticatedApplicationContextInitialization">\r
+       </bean>\r
+\r
+\r
+       <bean name="fileSystemManager" class="org.apache.commons.vfs2.impl.StandardFileSystemManager"\r
+               init-method="init" destroy-method="close" />\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.agent.jcr/bnd.bnd b/legacy/org.argeo.slc.agent.jcr/bnd.bnd
new file mode 100644 (file)
index 0000000..00566cc
--- /dev/null
@@ -0,0 +1,21 @@
+Import-Package: org.argeo.slc.jcr,\
+org.argeo.security.jackrabbit,\
+org.apache.commons.vfs2.provider.bzip2,\
+org.apache.commons.vfs2.provider.compressed,\
+org.apache.commons.vfs2.provider.ftp,\
+org.apache.commons.vfs2.provider.ftps,\
+org.apache.commons.vfs2.provider.gzip,\
+org.apache.commons.vfs2.provider.http,\
+org.apache.commons.vfs2.provider.https,\
+org.apache.commons.vfs2.provider.jar,\
+org.apache.commons.vfs2.provider.local,\
+org.apache.commons.vfs2.provider.ram,\
+org.apache.commons.vfs2.provider.res,\
+org.apache.commons.vfs2.provider.sftp,\
+org.apache.commons.vfs2.provider.tar,\
+org.apache.commons.vfs2.provider.url,\
+org.apache.commons.vfs2.provider.temp,\
+org.apache.commons.vfs2.provider.webdav,\
+org.apache.commons.vfs2.provider.zip,\
+org.osgi.*;version=0.0.0,\
+*
diff --git a/legacy/org.argeo.slc.agent.jcr/build.properties b/legacy/org.argeo.slc.agent.jcr/build.properties
new file mode 100644 (file)
index 0000000..7594fab
--- /dev/null
@@ -0,0 +1,2 @@
+bin.includes = META-INF/,\
+               .
diff --git a/legacy/org.argeo.slc.agent.jcr/pom.xml b/legacy/org.argeo.slc.agent.jcr/pom.xml
new file mode 100644 (file)
index 0000000..437754a
--- /dev/null
@@ -0,0 +1,11 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.agent.jcr</artifactId>
+       <name>SLC Agent JCR</name>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.agent/.gitignore b/legacy/org.argeo.slc.agent/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/org.argeo.slc.agent/.project b/legacy/org.argeo.slc.agent/.project
new file mode 100644 (file)
index 0000000..f167854
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.agent</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <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>
+       </natures>
+</projectDescription>
diff --git a/legacy/org.argeo.slc.agent/META-INF/.gitignore b/legacy/org.argeo.slc.agent/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.agent/META-INF/spring/agent.xml b/legacy/org.argeo.slc.agent/META-INF/spring/agent.xml
new file mode 100644 (file)
index 0000000..1f8ca96
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <bean\r
+               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">\r
+               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />\r
+               <property name="locations">\r
+                       <value>osgibundle:agent.properties</value>\r
+               </property>\r
+       </bean>\r
+\r
+       <!-- Manager -->\r
+       <bean id="modulesManager" class="org.argeo.slc.osgi.OsgiExecutionModulesManager"\r
+               init-method="init" destroy-method="destroy">\r
+               <property name="bundlesManager" ref="bundlesManager" />\r
+       </bean>\r
+\r
+       <bean id="bundlesManager" class="org.argeo.slc.osgi.BundlesManager">\r
+               <property name="defaultTimeout" value="${slc.agent.osgi.defaultTimeout}" />\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.agent/META-INF/spring/osgi.xml b/legacy/org.argeo.slc.agent/META-INF/spring/osgi.xml
new file mode 100644 (file)
index 0000000..79d933c
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xmlns:util="http://www.springframework.org/schema/util"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <!-- REFERENCES -->\r
+       <!-- No <set> so that the equals methods are not called -->\r
+       <list id="executionContexts" interface="org.argeo.slc.execution.ExecutionContext"\r
+               cardinality="0..N">\r
+               <listener ref="modulesManager" bind-method="register"\r
+                       unbind-method="unregister" />\r
+       </list>\r
+\r
+       <list id="executionFlows" interface="org.argeo.slc.execution.ExecutionFlow"\r
+               cardinality="0..N">\r
+               <listener ref="modulesManager" bind-method="register"\r
+                       unbind-method="unregister" />\r
+       </list>\r
+\r
+       <list id="executionModulesListeners" interface="org.argeo.slc.execution.ExecutionModulesListener"\r
+               cardinality="0..N">\r
+               <listener ref="modulesManager" bind-method="register"\r
+                       unbind-method="unregister" />\r
+       </list>\r
+\r
+       <list id="executionFlowDescriptorConverters"\r
+               interface="org.argeo.slc.execution.ExecutionFlowDescriptorConverter"\r
+               cardinality="0..N">\r
+               <listener ref="modulesManager" />\r
+       </list>\r
+       <reference id="userTransaction" interface="javax.transaction.UserTransaction" />\r
+       <reference id="userAdmin" interface="org.osgi.service.useradmin.UserAdmin" />\r
+\r
+       <!-- SERVICES -->\r
+       <service ref="modulesManager" interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
+\r
+       <!-- LABEL -->\r
+<!--   <beans:bean class="org.argeo.cms.spring.osgi.OsgiModuleLabel"> -->\r
+<!--           <beans:property name="bundleContext" ref="bundleContext" /> -->\r
+<!--   </beans:bean> -->\r
+\r
+       <!-- ROLES -->\r
+<!--   <reference id="userAdminService" interface="org.argeo.security.UserAdminService" /> -->\r
+\r
+       <beans:bean class="org.argeo.maintenance.SimpleRoleRegistration"\r
+               init-method="run">\r
+               <beans:property name="role" value="org.argeo.slc.user" />\r
+               <beans:property name="userAdmin" ref="userAdmin" />\r
+               <beans:property name="userTransaction" ref="userTransaction" />\r
+<!--           <beans:property name="userAdminService" ref="userAdminService" /> -->\r
+       </beans:bean>\r
+</beans:beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.agent/agent.properties b/legacy/org.argeo.slc.agent/agent.properties
new file mode 100644 (file)
index 0000000..4767d7c
--- /dev/null
@@ -0,0 +1 @@
+slc.agent.osgi.defaultTimeout=60000
diff --git a/legacy/org.argeo.slc.agent/bnd.bnd b/legacy/org.argeo.slc.agent/bnd.bnd
new file mode 100644 (file)
index 0000000..7f2410c
--- /dev/null
@@ -0,0 +1,2 @@
+Import-Package: org.osgi.*;version=0.0.0,\
+*
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.agent/build.properties b/legacy/org.argeo.slc.agent/build.properties
new file mode 100644 (file)
index 0000000..7594fab
--- /dev/null
@@ -0,0 +1,2 @@
+bin.includes = META-INF/,\
+               .
diff --git a/legacy/org.argeo.slc.agent/pom.xml b/legacy/org.argeo.slc.agent/pom.xml
new file mode 100644 (file)
index 0000000..fbf41ce
--- /dev/null
@@ -0,0 +1,11 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.agent</artifactId>
+       <name>SLC Agent</name>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.rap/.classpath b/legacy/org.argeo.slc.client.rap/.classpath
new file mode 100644 (file)
index 0000000..06bea94
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
+       <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/legacy/org.argeo.slc.client.rap/.gitignore b/legacy/org.argeo.slc.client.rap/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/org.argeo.slc.client.rap/.project b/legacy/org.argeo.slc.client.rap/.project
new file mode 100644 (file)
index 0000000..9b82af4
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.argeo.slc.client.rap</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/legacy/org.argeo.slc.client.rap/.settings/org.eclipse.jdt.core.prefs b/legacy/org.argeo.slc.client.rap/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..8b45224
--- /dev/null
@@ -0,0 +1,8 @@
+#Thu Apr 14 17:49:18 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/legacy/org.argeo.slc.client.rap/META-INF/.gitignore b/legacy/org.argeo.slc.client.rap/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.client.rap/META-INF/spring/commands.xml b/legacy/org.argeo.slc.client.rap/META-INF/spring/commands.xml
new file mode 100644 (file)
index 0000000..f19c551
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+       <!-- RAP Specific open JCR file service -->
+       <!-- <bean id="openJcrFileService" class="org.argeo.slc.client.rap.OpenJcrFileService" -->
+       <!-- scope="prototype" init-method="init" destroy-method="destroy"> -->
+       <!-- <property name="repoService" ref="repoService" /> -->
+       <!-- <property name="repositoryFactory" ref="repositoryFactory" /> -->
+       <!-- <property name="keyring" ref="keyring" /> -->
+       <!-- <property name="nodeRepository" ref="nodeRepository" /> -->
+       <!-- </bean> -->
+
+       <bean id="org.argeo.slc.client.rap.openJcrFile" class="org.argeo.slc.client.ui.specific.OpenJcrFile"
+               scope="prototype">
+               <property name="repoService" ref="repoService" />
+       </bean>
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.rap/META-INF/spring/jcr.xml b/legacy/org.argeo.slc.client.rap/META-INF/spring/jcr.xml
new file mode 100644 (file)
index 0000000..4a35de6
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
+
+       <bean id="repoService" class="org.argeo.slc.repo.core.RepoServiceImpl">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+</beans>
diff --git a/legacy/org.argeo.slc.client.rap/META-INF/spring/osgi.xml b/legacy/org.argeo.slc.client.rap/META-INF/spring/osgi.xml
new file mode 100644 (file)
index 0000000..6c76546
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans\r
+       xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xmlns:osgi="http://www.springframework.org/schema/osgi"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
+       osgi:default-timeout="30000">\r
+\r
+       <beans:description>SLC UI RAP</beans:description>\r
+\r
+       <reference id="nodeRepository"\r
+       interface="javax.jcr.Repository" />\r
+       <reference id="repositoryFactory"\r
+               interface="javax.jcr.RepositoryFactory" />\r
+       <reference id="keyring"\r
+               interface="org.argeo.api.security.CryptoKeyring" />\r
+</beans:beans>\r
diff --git a/legacy/org.argeo.slc.client.rap/bnd.bnd b/legacy/org.argeo.slc.client.rap/bnd.bnd
new file mode 100644 (file)
index 0000000..7b46665
--- /dev/null
@@ -0,0 +1,16 @@
+Bundle-SymbolicName: org.argeo.slc.client.rap;singleton=true
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.argeo.slc.client.rap.SlcRapPlugin
+Require-Bundle: org.eclipse.ui;resolution:=optional,\
+org.eclipse.core.runtime,\
+org.eclipse.rap.ui;resolution:=optional,\
+org.eclipse.rap.ui.workbench;resolution:=optional
+
+Import-Package: javax.jcr.nodetype,\
+javax.servlet,\
+javax.servlet.http,\
+org.argeo.eclipse.spring,\
+org.argeo.slc.repo.core,\
+org.argeo.cms.ui.util,\
+*
+                                                       
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.rap/build.properties b/legacy/org.argeo.slc.client.rap/build.properties
new file mode 100644 (file)
index 0000000..5dd830c
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/main/java/\r
+output.. = target/classes/\r
+bin.includes = plugin.xml,\\r
+               META-INF/,\\r
+               .\r
diff --git a/legacy/org.argeo.slc.client.rap/icons/slc_execution_perspective.gif b/legacy/org.argeo.slc.client.rap/icons/slc_execution_perspective.gif
new file mode 100644 (file)
index 0000000..b8ca14a
Binary files /dev/null and b/legacy/org.argeo.slc.client.rap/icons/slc_execution_perspective.gif differ
diff --git a/legacy/org.argeo.slc.client.rap/plugin.xml b/legacy/org.argeo.slc.client.rap/plugin.xml
new file mode 100644 (file)
index 0000000..b0639cc
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<?eclipse version="3.6"?>\r
+<plugin>\r
+       <extension\r
+               point="org.eclipse.rap.ui.entrypoint">\r
+               <entrypoint\r
+                       id="org.argeo.slc.client.rap.slcSecureRap"\r
+                       class="org.argeo.slc.client.rap.SlcSecureRap"\r
+                       path="/slc">\r
+               </entrypoint>\r
+       </extension>\r
+   \r
+       <!-- COMMANDS  --> \r
+       <extension\r
+        point="org.eclipse.ui.commands">\r
+               <command\r
+                       id="org.argeo.slc.client.rap.openJcrFile"\r
+                       defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"\r
+                       name="Open Workspace Editor">\r
+                       <commandParameter\r
+                               id="param.repoNodePath"\r
+                               name="Repo node path">\r
+                       </commandParameter>\r
+                       <commandParameter\r
+                               id="param.repoUri"\r
+                               name="Repo URI">\r
+                       </commandParameter>\r
+                       <commandParameter\r
+                               id="param.workspaceName"\r
+                               name="Workspace name">\r
+                       </commandParameter>\r
+                       <commandParameter\r
+                               id="param.filePath"\r
+                               name="File Path">\r
+                       </commandParameter>\r
+       </command>\r
+       </extension>\r
+</plugin>\r
diff --git a/legacy/org.argeo.slc.client.rap/pom.xml b/legacy/org.argeo.slc.client.rap/pom.xml
new file mode 100644 (file)
index 0000000..c1decab
--- /dev/null
@@ -0,0 +1,37 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.client.rap</artifactId>
+       <name>SLC Client RAP</name>
+       <packaging>jar</packaging>
+       <dependencies>
+               <!-- SLC -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.repo</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Argeo common distribution for Secured UI -->
+               <dependency>
+                       <groupId>org.argeo.slc.legacy.commons</groupId>
+                       <artifactId>org.argeo.cms.ui.workbench.rap</artifactId>
+                       <version>${version.argeo-commons-legacy}</version>
+               </dependency>
+
+               <!-- RAP workbench -->
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>argeo-tp-rap-e3</artifactId>
+                       <version>${version.argeo-tp}</version>
+                       <type>pom</type>
+                       <scope>provided</scope>
+               </dependency>
+
+       </dependencies>
+</project>
diff --git a/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/OpenJcrFileService.java b/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/OpenJcrFileService.java
new file mode 100644 (file)
index 0000000..1a1f1dc
--- /dev/null
@@ -0,0 +1,98 @@
+package org.argeo.slc.client.rap;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+//import org.eclipse.rap.rwt.service.IServiceHandler;
+
+/**
+ * Basic Default service handler that retrieves a file from a NT_FILE JCR node
+ * and launch the download.
+ */
+public class OpenJcrFileService {//implements IServiceHandler {
+
+       /* DEPENDENCY INJECTION */
+       final private Node fileNode;
+
+       public OpenJcrFileService(Node fileNode) {
+               this.fileNode = fileNode;
+       }
+
+       public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+               // Get the file content
+               byte[] download = getFileAsByteArray();
+
+               // Send the file in the response
+               //HttpServletResponse response = RWT.getResponse();
+               response.setContentType("application/octet-stream");
+               response.setContentLength(download.length);
+               String contentDisposition = null;
+               try {
+                       contentDisposition = "attachment; filename=\""
+                                       + JcrUtils.lastPathElement(fileNode.getPath()) + "\"";
+               } catch (RepositoryException e) {
+                       throw new SlcException("Error while getting file Path " + fileNode,
+                                       e);
+               }
+               response.setHeader("Content-Disposition", contentDisposition);
+
+               try {
+                       response.getOutputStream().write(download);
+               } catch (IOException ioe) {
+                       throw new SlcException("Error while writing the file " + fileNode
+                                       + " to the servlet response", ioe);
+               }
+       }
+
+       protected byte[] getFileAsByteArray() {
+
+               Session businessSession = null;
+               try {
+                       boolean isValid = true;
+                       Node child = null;
+                       if (!fileNode.isNodeType(NodeType.NT_FILE))
+                               isValid = false;
+                       else {
+                               child = fileNode.getNode(Property.JCR_CONTENT);
+                               if (!(child.isNodeType(NodeType.NT_RESOURCE) || child
+                                               .hasProperty(Property.JCR_DATA)))
+                                       isValid = false;
+                       }
+
+                       if (!isValid)
+                               return null;
+
+                       byte[] ba = null;
+                       InputStream fis = null;
+                       try {
+                               fis = (InputStream) child.getProperty(Property.JCR_DATA)
+                                               .getBinary().getStream();
+                               ba = IOUtils.toByteArray(fis);
+                       } catch (Exception e) {
+                               throw new SlcException("Stream error while opening file "
+                                               + fileNode, e);
+                       } finally {
+                               IOUtils.closeQuietly(fis);
+                       }
+                       return ba;
+
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unexpected error while "
+                                       + "opening file node " + fileNode, e);
+               } finally {
+                       JcrUtils.logoutQuietly(businessSession);
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcRapPlugin.java b/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcRapPlugin.java
new file mode 100644 (file)
index 0000000..e23ea74
--- /dev/null
@@ -0,0 +1,71 @@
+package org.argeo.slc.client.rap;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ * 
+ * Enable life-cycle management of RAP specific services
+ */
+public class SlcRapPlugin extends AbstractUIPlugin {
+
+       // The plug-in ID
+       public static final String PLUGIN_ID = "org.argeo.slc.client.rap"; //$NON-NLS-1$
+
+       // The shared instance
+       private static SlcRapPlugin plugin;
+
+       /**
+        * The constructor
+        */
+       public SlcRapPlugin() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+        * )
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+        * )
+        */
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       /**
+        * Returns the shared instance
+        * 
+        * @return the shared instance
+        */
+       public static SlcRapPlugin getDefault() {
+               return plugin;
+       }
+
+       /**
+        * Returns an image descriptor for the image file at the given plug-in
+        * relative path
+        * 
+        * @param path
+        *            the path
+        * @return the image descriptor
+        */
+       public static ImageDescriptor getImageDescriptor(String path) {
+               return imageDescriptorFromPlugin(PLUGIN_ID, path);
+       }
+
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcSecureRap.java b/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcSecureRap.java
new file mode 100644 (file)
index 0000000..ddd7753
--- /dev/null
@@ -0,0 +1,81 @@
+package org.argeo.slc.client.rap;
+
+import org.argeo.cms.ui.workbench.rap.RapWindowAdvisor;
+import org.argeo.cms.ui.workbench.rap.RapWorkbenchAdvisor;
+import org.argeo.cms.ui.workbench.rap.RapWorkbenchLogin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+/**
+ * This class controls all aspects of the application's execution and is
+ * contributed through the plugin.xml.
+ */
+public class SlcSecureRap extends RapWorkbenchLogin {
+
+       @Override
+       protected RapWorkbenchAdvisor createRapWorkbenchAdvisor(
+                       final String username) {
+               return new RapWorkbenchAdvisor(username) {
+                       @Override
+                       public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
+                                       IWorkbenchWindowConfigurer configurer) {
+                               return new SlcRapWorkbenchWindowAdvisor(configurer, username);
+                       }
+
+               };
+       }
+
+       /** Workaround for resize issue */
+       class SlcRapWorkbenchWindowAdvisor extends RapWindowAdvisor {
+
+               public SlcRapWorkbenchWindowAdvisor(
+                               IWorkbenchWindowConfigurer configurer, String username) {
+                       super(configurer, username);
+               }
+
+               public void preWindowOpen() {
+                       IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
+                       configurer.setShowCoolBar(true);
+                       configurer.setShowMenuBar(false);
+                       configurer.setShowStatusLine(false);
+                       configurer.setShowPerspectiveBar(true);
+                       configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
+                       // Full screen, see
+                       // http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02697.html
+                       configurer.setShellStyle(SWT.NO_TRIM);
+                       Rectangle bounds = Display.getCurrent().getBounds();
+                       configurer.setInitialSize(new Point(bounds.width, bounds.height));
+               }
+
+               @Override
+               public void postWindowCreate() {
+                       Shell shell = getWindowConfigurer().getWindow().getShell();
+                       shell.setMaximized(true);
+               }
+
+               @Override
+               public void postWindowOpen() {
+                       String defaultPerspective = getWindowConfigurer()
+                                       .getWorkbenchConfigurer().getWorkbench()
+                                       .getPerspectiveRegistry().getDefaultPerspective();
+                       if (defaultPerspective == null) {
+                               IWorkbenchWindow window = getWindowConfigurer().getWindow();
+                               if (window == null)
+                                       return;
+
+                               IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
+                                               .create(window);
+                               openPerspectiveDialogAction.run();
+                       }
+               }
+
+       }
+}
diff --git a/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFile.java b/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFile.java
new file mode 100644 (file)
index 0000000..8876a15
--- /dev/null
@@ -0,0 +1,102 @@
+package org.argeo.slc.client.ui.specific;
+
+import java.net.URL;
+import java.util.UUID;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.rap.OpenJcrFileService;
+import org.argeo.slc.repo.RepoService;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.rap.rwt.RWT;
+//import org.eclipse.rap.rwt.service.IServiceHandler;
+//import org.eclipse.rap.rwt.service.IServiceManager;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Rap specific command handler to open a file retrieved from a distant JCR
+ * Repository. It creates and register a service instantiated with the
+ * corresponding JCR node, forwards the request, and un register the service on
+ * dispose
+ * 
+ * This command and the corresponding service are specific for RAP version [1.3,
+ * 2)
+ */
+public class OpenJcrFile extends AbstractHandler {
+
+       // Use (new OpenJcrFileCmdId()).getCmdId() instead.
+       // public final String ID = SlcRapPlugin.PLUGIN_ID + ".openJcrFile";
+       
+       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
+       public final static String PARAM_REPO_URI = "param.repoUri";
+       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
+       public final static String PARAM_FILE_PATH = "param.filePath";
+
+       private RepoService repoService;
+       private String currentServiceId;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
+               String repoUri = event.getParameter(PARAM_REPO_URI);
+               String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
+               String filePath = event.getParameter(PARAM_FILE_PATH);
+
+               // TODO sanity check
+               if (filePath == null || "".equals(filePath.trim()))
+                       return null;
+               Session businessSession = null;
+               try {
+                       businessSession = repoService.getRemoteSession(repoNodePath,
+                                       repoUri, wkspName);
+                       Node result = businessSession.getNode(filePath);
+
+                       // Create a temporary service. No better solution has been found
+                       // yet.
+                       currentServiceId = UUID.randomUUID().toString();
+                       OpenJcrFileService ojfs = new OpenJcrFileService(result);
+                       // FIXME replace it
+//                     IServiceManager manager = RWT.getServiceManager();
+//                     manager.registerServiceHandler(currentServiceId, ojfs);
+                       String urlStr = createFullDownloadUrl(currentServiceId);
+                       URL url = new URL(urlStr);
+                       PlatformUI.getWorkbench().getBrowserSupport()
+                                       .createBrowser("DownloadDialog").openURL(url);
+               } catch (Exception e) {
+                       throw new SlcException("Unable to open Jcr File for path "
+                                       + filePath, e);
+               }
+
+               return null;
+       }
+
+       @Override
+       public void dispose() {
+//             IServiceManager manager = RWT.getServiceManager();
+//             manager.unregisterServiceHandler(currentServiceId);
+               super.dispose();
+       }
+
+       private String createFullDownloadUrl(String serviceId) {
+               StringBuilder url = new StringBuilder();
+               url.append(RWT.getRequest().getRequestURL());
+
+               StringBuilder params = new StringBuilder();
+               params.append("?");
+               // FIXME commented out so that it builds
+               //params.append(IServiceHandler.REQUEST_PARAM).append("=");
+               params.append(serviceId);
+               String encodedURL = RWT.getResponse().encodeURL(params.toString());
+               url.append(encodedURL);
+               return url.toString();
+       }
+
+       /* Dependency Injection */
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java b/legacy/org.argeo.slc.client.rap/src/org/argeo/slc/client/ui/specific/OpenJcrFileCmdId.java
new file mode 100644 (file)
index 0000000..a4e0d83
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.slc.client.ui.specific;
+
+import org.argeo.slc.client.rap.SlcRapPlugin;
+
+/**
+ * Workaround a single sourcing problem:
+ * 
+ * final static variable are imported at compilation time (we build against RCP)
+ * and we still must have a different ID (the prefix must be the PLUGIN ID) for
+ * RAP and RCP in order to be able to inject beans in the corresponding commands 
+ */
+public class OpenJcrFileCmdId {
+
+       public String getCmdId() {
+               return SlcRapPlugin.PLUGIN_ID + ".openJcrFile";
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/.classpath b/legacy/org.argeo.slc.client.ui.dist/.classpath
new file mode 100644 (file)
index 0000000..120e381
--- /dev/null
@@ -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/JavaSE-1.7"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/legacy/org.argeo.slc.client.ui.dist/.gitignore b/legacy/org.argeo.slc.client.ui.dist/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/org.argeo.slc.client.ui.dist/.project b/legacy/org.argeo.slc.client.ui.dist/.project
new file mode 100644 (file)
index 0000000..30b71ed
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.client.ui.dist</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/legacy/org.argeo.slc.client.ui.dist/.settings/org.eclipse.jdt.core.prefs b/legacy/org.argeo.slc.client.ui.dist/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..7c5d419
--- /dev/null
@@ -0,0 +1,8 @@
+#Wed Dec 08 08:27:02 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/legacy/org.argeo.slc.client.ui.dist/.settings/org.eclipse.pde.core.prefs b/legacy/org.argeo.slc.client.ui.dist/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..0e2e537
--- /dev/null
@@ -0,0 +1,4 @@
+#Wed Dec 08 08:27:02 CET 2010
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/legacy/org.argeo.slc.client.ui.dist/META-INF/.gitignore b/legacy/org.argeo.slc.client.ui.dist/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml b/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml
new file mode 100644 (file)
index 0000000..a9eb9af
--- /dev/null
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+       <!-- DISTRIBUTIONS MANAGEMENT -->
+       <bean id="normalizeDistribution"
+               class="org.argeo.slc.client.ui.dist.commands.NormalizeDistribution">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="openModuleEditor" class="org.argeo.slc.client.ui.dist.commands.OpenModuleEditor"
+               scope="prototype">
+               <property name="repoService" ref="repoService" />
+       </bean>
+
+       <!-- REPOSITORY MANAGEMENT -->
+       <bean id="registerRepository"
+               class="org.argeo.slc.client.ui.dist.commands.RegisterRepository">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="unregisterRemoteRepo"
+               class="org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo"
+               scope="prototype">
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="displayRepoInformation"
+               class="org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation"
+               scope="prototype">
+               <property name="repoService" ref="repoService" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+
+       <!-- WORKSPACE MANAGEMENT -->
+       <bean id="openWorkspaceEditor"
+               class="org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor"
+               scope="prototype">
+               <property name="localRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="fetch" class="org.argeo.slc.client.ui.dist.commands.Fetch"
+               scope="prototype">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="manageWorkspaceAuth"
+               class="org.argeo.slc.client.ui.dist.commands.ManageWorkspaceAuth"
+               scope="prototype">
+               <property name="repository" ref="javaRepository" />
+       </bean>
+
+       <bean id="publishWorkspace" class="org.argeo.slc.client.ui.dist.commands.PublishWorkspace">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="normalizeWorkspace"
+               class="org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="openGenerateBinariesWizard"
+               class="org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard">
+               <property name="repoService" ref="repoService" />
+       </bean>
+
+       <!-- WORKSPACE CRUD -->
+       <bean id="createWorkspace" class="org.argeo.slc.client.ui.dist.commands.CreateWorkspace">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="copyWorkspace" class="org.argeo.slc.client.ui.dist.commands.CopyWorkspace">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="copyLocalJavaWorkspace"
+               class="org.argeo.slc.client.ui.dist.commands.CopyLocalJavaWorkspace">
+               <property name="javaRepoManager">
+                       <bean factory-bean="slcRepoManager" factory-method="getJavaRepoManager" />
+               </property>
+               <property name="javaRepository" ref="javaRepository" />
+       </bean>
+
+       <bean id="createLocalJavaWorkspace"
+               class="org.argeo.slc.client.ui.dist.commands.CreateLocalJavaWorkspace">
+               <property name="javaRepoManager">
+                       <bean factory-bean="slcRepoManager" factory-method="getJavaRepoManager" />
+               </property>
+       </bean>
+
+       <bean id="mergeWorkspaces" class="org.argeo.slc.client.ui.dist.commands.MergeWorkspaces">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="deleteWorkspace" class="org.argeo.slc.client.ui.dist.commands.DeleteWorkspace">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <!-- ADVANCED -->
+       <bean id="runInOsgi" class="org.argeo.slc.client.ui.dist.commands.RunInOsgi"
+               scope="prototype">
+               <property name="repository" ref="javaRepository" />
+       </bean>
+
+       <!-- LEGACY -->
+       <!-- <bean id="org.argeo.slc.client.ui.dist.openGenericJcrQueryEditor" class="org.argeo.eclipse.ui.jcr.commands.OpenGenericJcrQueryEditor" 
+               scope="prototype"> <property name="editorId" value="org.argeo.slc.client.ui.dist.genericJcrQueryEditor" 
+               /> </bean> -->
+       <bean id="refreshDistributionsView"
+               class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionsView"
+               scope="prototype">
+       </bean>
+
+       <bean id="org.argeo.slc.client.ui.dist.deleteArtifacts" class="org.argeo.slc.client.ui.dist.commands.DeleteArtifacts"
+               scope="prototype">
+       </bean>
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/editors.xml b/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/editors.xml
new file mode 100644 (file)
index 0000000..23632d5
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
+
+       <bean id="distWorkspaceEditor"
+               class="org.argeo.slc.client.ui.dist.editors.DistWorkspaceEditor"
+               scope="prototype">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="localRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="artifactVersionEditor"
+               class="org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor"
+               scope="prototype">
+               <property name="repoService" ref="repoService" />
+       </bean>
+
+       <bean id="modularDistVersionEditor"
+               class="org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor"
+               scope="prototype">
+               <property name="repoService" ref="repoService" />
+       </bean>
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/jcr.xml b/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/jcr.xml
new file mode 100644 (file)
index 0000000..6b21f8e
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
+
+       <bean id="repoService" class="org.argeo.slc.repo.core.RepoServiceImpl">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <!-- For the record <property name="session"> <bean factory-bean="repository" 
+               factory-method="login" /> </property> -->
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml b/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml
new file mode 100644 (file)
index 0000000..324c66f
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xmlns:osgi="http://www.springframework.org/schema/osgi"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
+       osgi:default-timeout="30000">\r
+\r
+       <reference id="javaRepository" interface="javax.jcr.Repository"\r
+               filter="(cn=java)" />\r
+\r
+       <reference id="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
+       <reference id="keyring" interface="org.argeo.api.security.CryptoKeyring" />\r
+\r
+       <reference id="nodeRepository" interface="javax.jcr.Repository"\r
+               filter="(cn=ego)" />\r
+\r
+       <reference id="slcRepoManager" interface="org.argeo.slc.repo.SlcRepoManager" />\r
+</beans:beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml b/legacy/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml
new file mode 100644 (file)
index 0000000..73eeaef
--- /dev/null
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd 
+        http://www.springframework.org/schema/util 
+        http://www.springframework.org/schema/util/spring-util-2.5.xsd">
+
+       <!-- Views -->
+<!--   <bean id="artifactsBrowser" class="org.argeo.slc.client.ui.dist.views.ArtifactsBrowser" -->
+<!--           scope="prototype"> -->
+<!--           <property name="jcrSession" ref="slcSession" /> -->
+<!--   </bean> -->
+<!--   <bean id="queryArtifactsForm" class="org.argeo.slc.client.ui.dist.views.QueryArtifactsForm" -->
+<!--           scope="prototype"> -->
+<!--           <property name="session" ref="slcSession" /> -->
+<!--           <property name="columnProperties"> -->
+<!--                   <list> -->
+<!--                           <value>slc:artifactVersion.jcr:uuid</value> -->
+<!--                           <value>slc:artifactVersion.slc:groupId</value> -->
+<!--                           <value>slc:artifactVersion.slc:artifactId</value> -->
+<!--                           <value>slc:artifactVersion.slc:artifactVersion</value> -->
+<!--                   </list> -->
+<!--           </property> -->
+<!--   </bean> -->
+<!--   <bean id="queryBundlesForm" class="org.argeo.slc.client.ui.dist.views.QueryBundlesForm" -->
+<!--           scope="prototype"> -->
+<!--           <property name="session" ref="slcSession" /> -->
+<!--           <property name="columnProperties"> -->
+<!--                   <list> -->
+<!--                           <value>slc:artifactVersion.jcr:uuid</value> -->
+<!--                           <value>slc:bundleArtifact.slc:symbolic-name</value> -->
+<!--                           <value>slc:artifactVersion.slc:groupId</value> -->
+<!--                           <value>slc:bundleArtifact.slc:bundle-version</value> -->
+<!--                           <value>slc:bundleArtifact.slc:Fragment-Host</value> -->
+<!--                   </list> -->
+<!--           </property> -->
+<!--   </bean> -->
+
+<!--   <bean id="queryArtifactsText" class="org.argeo.slc.client.ui.dist.views.QueryArtifactsText" -->
+<!--           scope="prototype"> -->
+<!--           <property name="session" ref="slcSession" /> -->
+<!--   </bean> -->
+
+       <bean id="distributionsView" class="org.argeo.slc.client.ui.dist.views.DistributionsView"
+               scope="prototype">
+               <!-- <property name="repositoryFactory" ref="repositoryFactory" /> -->
+               <!-- <property name="keyring" ref="keyring" /> -->
+               <property name="nodeRepository" ref="nodeRepository" />
+               <property name="treeContentProvider" ref="distTreeContentProvider" />
+       </bean>
+
+       <!-- Corresponding content provider -->
+       <bean id="distTreeContentProvider"
+               class="org.argeo.slc.client.ui.dist.controllers.DistTreeContentProvider"
+               scope="prototype">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+       </bean>
+
+       <!-- ANONYMOUS DISTRIBUTION VIEW -->
+       <bean id="anonymousDistributionsView"
+               class="org.argeo.slc.client.ui.dist.views.AnonymousDistributionsView"
+               scope="prototype">
+               <property name="treeContentProvider" ref="anonymousDistTreeContentProvider" />
+       </bean>
+
+       <!-- Corresponding content provider -->
+       <bean id="anonymousDistTreeContentProvider"
+               class="org.argeo.slc.client.ui.dist.controllers.AnonymousDistTreeContentProvider"
+               scope="prototype">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+       </bean>
+
+       <!-- <bean id="distributionPerspective" class="org.argeo.slc.client.ui.dist.DistributionPerspective" 
+               scope="prototype"> <property name="repositoryFactory" ref="repositoryFactory" 
+               /> <property name="nodeRepository" ref="nodeRepository" /> </bean> -->
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/bnd.bnd b/legacy/org.argeo.slc.client.ui.dist/bnd.bnd
new file mode 100644 (file)
index 0000000..c2eeb87
--- /dev/null
@@ -0,0 +1,15 @@
+Bundle-SymbolicName: org.argeo.slc.client.ui.dist;singleton=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.ui;resolution:=optional,\
+org.eclipse.core.runtime,\
+org.eclipse.rap.ui;resolution:=optional,\
+org.eclipse.rap.ui.workbench;resolution:=optional
+
+Bundle-Activator: org.argeo.slc.client.ui.dist.DistPlugin
+Import-Package: org.argeo.eclipse.spring,\
+javax.jcr.nodetype,\
+javax.jcr.security,\
+aQute.lib.*;resolution:=optional,\
+org.osgi.*;version=0.0.0,\
+*
+                                                       
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/build.properties b/legacy/org.argeo.slc.client.ui.dist/build.properties
new file mode 100644 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/addItem.gif b/legacy/org.argeo.slc.client.ui.dist/icons/addItem.gif
new file mode 100644 (file)
index 0000000..a5ac28d
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/addItem.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/addRepo.gif b/legacy/org.argeo.slc.client.ui.dist/icons/addRepo.gif
new file mode 100644 (file)
index 0000000..b4832fc
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/addRepo.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/artifactBase.gif b/legacy/org.argeo.slc.client.ui.dist/icons/artifactBase.gif
new file mode 100644 (file)
index 0000000..fca9c53
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/artifactBase.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/artifactVersionBase.gif b/legacy/org.argeo.slc.client.ui.dist/icons/artifactVersionBase.gif
new file mode 100644 (file)
index 0000000..c026f01
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/artifactVersionBase.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/changeRights.gif b/legacy/org.argeo.slc.client.ui.dist/icons/changeRights.gif
new file mode 100644 (file)
index 0000000..a6b251f
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/changeRights.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/checked.gif b/legacy/org.argeo.slc.client.ui.dist/icons/checked.gif
new file mode 100644 (file)
index 0000000..00da14e
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/checked.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/clear.gif b/legacy/org.argeo.slc.client.ui.dist/icons/clear.gif
new file mode 100644 (file)
index 0000000..cbb71be
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/clear.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/distGrp.gif b/legacy/org.argeo.slc.client.ui.dist/icons/distGrp.gif
new file mode 100644 (file)
index 0000000..0470e15
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/distGrp.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/distGrpReadOnly.gif b/legacy/org.argeo.slc.client.ui.dist/icons/distGrpReadOnly.gif
new file mode 100644 (file)
index 0000000..ae98299
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/distGrpReadOnly.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/distribution_perspective.gif b/legacy/org.argeo.slc.client.ui.dist/icons/distribution_perspective.gif
new file mode 100644 (file)
index 0000000..955d5e8
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/distribution_perspective.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/fetchRepo.png b/legacy/org.argeo.slc.client.ui.dist/icons/fetchRepo.png
new file mode 100644 (file)
index 0000000..195659f
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/fetchRepo.png differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/file.gif b/legacy/org.argeo.slc.client.ui.dist/icons/file.gif
new file mode 100644 (file)
index 0000000..ef30288
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/file.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/help.gif b/legacy/org.argeo.slc.client.ui.dist/icons/help.gif
new file mode 100644 (file)
index 0000000..ca1b1e7
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/help.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/homeRepo.gif b/legacy/org.argeo.slc.client.ui.dist/icons/homeRepo.gif
new file mode 100644 (file)
index 0000000..4472e8c
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/homeRepo.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/modularDistributionVersion.gif b/legacy/org.argeo.slc.client.ui.dist/icons/modularDistributionVersion.gif
new file mode 100644 (file)
index 0000000..22f78af
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/modularDistributionVersion.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/more.gif b/legacy/org.argeo.slc.client.ui.dist/icons/more.gif
new file mode 100644 (file)
index 0000000..57ad089
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/more.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/more.png b/legacy/org.argeo.slc.client.ui.dist/icons/more.png
new file mode 100644 (file)
index 0000000..1252a14
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/more.png differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/normalize.gif b/legacy/org.argeo.slc.client.ui.dist/icons/normalize.gif
new file mode 100644 (file)
index 0000000..b8ca14a
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/normalize.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/package.gif b/legacy/org.argeo.slc.client.ui.dist/icons/package.gif
new file mode 100644 (file)
index 0000000..131c28d
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/package.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/packageBrowser.gif b/legacy/org.argeo.slc.client.ui.dist/icons/packageBrowser.gif
new file mode 100644 (file)
index 0000000..983932f
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/packageBrowser.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/packages.gif b/legacy/org.argeo.slc.client.ui.dist/icons/packages.gif
new file mode 100644 (file)
index 0000000..22f78af
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/packages.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/publish.gif b/legacy/org.argeo.slc.client.ui.dist/icons/publish.gif
new file mode 100644 (file)
index 0000000..ec6cca4
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/publish.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/pview.gif b/legacy/org.argeo.slc.client.ui.dist/icons/pview.gif
new file mode 100644 (file)
index 0000000..4aa54a6
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/pview.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/refresh.png b/legacy/org.argeo.slc.client.ui.dist/icons/refresh.png
new file mode 100644 (file)
index 0000000..a3884fb
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/refresh.png differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/removeItem.gif b/legacy/org.argeo.slc.client.ui.dist/icons/removeItem.gif
new file mode 100644 (file)
index 0000000..2b88506
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/removeItem.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/removeMark.gif b/legacy/org.argeo.slc.client.ui.dist/icons/removeMark.gif
new file mode 100644 (file)
index 0000000..d766177
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/removeMark.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/repo.gif b/legacy/org.argeo.slc.client.ui.dist/icons/repo.gif
new file mode 100644 (file)
index 0000000..c13bea1
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/repo.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/repoReadOnly.gif b/legacy/org.argeo.slc.client.ui.dist/icons/repoReadOnly.gif
new file mode 100644 (file)
index 0000000..a076324
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/repoReadOnly.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif b/legacy/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif
new file mode 100644 (file)
index 0000000..2df4b45
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/runInOsgi.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/search.gif b/legacy/org.argeo.slc.client.ui.dist/icons/search.gif
new file mode 100644 (file)
index 0000000..d540a01
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/search.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/searchForm.gif b/legacy/org.argeo.slc.client.ui.dist/icons/searchForm.gif
new file mode 100644 (file)
index 0000000..cbbb3af
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/searchForm.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/search_decl_obj.gif b/legacy/org.argeo.slc.client.ui.dist/icons/search_decl_obj.gif
new file mode 100644 (file)
index 0000000..f31a02a
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/search_decl_obj.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/showSize.gif b/legacy/org.argeo.slc.client.ui.dist/icons/showSize.gif
new file mode 100644 (file)
index 0000000..2df4b45
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/showSize.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/sinfocenter_obj.gif b/legacy/org.argeo.slc.client.ui.dist/icons/sinfocenter_obj.gif
new file mode 100644 (file)
index 0000000..b867103
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/sinfocenter_obj.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/unchecked.gif b/legacy/org.argeo.slc.client.ui.dist/icons/unchecked.gif
new file mode 100644 (file)
index 0000000..7aa131a
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/unchecked.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/icons/wkspGroup.gif b/legacy/org.argeo.slc.client.ui.dist/icons/wkspGroup.gif
new file mode 100644 (file)
index 0000000..79b22b7
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui.dist/icons/wkspGroup.gif differ
diff --git a/legacy/org.argeo.slc.client.ui.dist/plugin.xml b/legacy/org.argeo.slc.client.ui.dist/plugin.xml
new file mode 100644 (file)
index 0000000..4d42d75
--- /dev/null
@@ -0,0 +1,492 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+       <!-- PERSPECTIVES --> 
+       <extension
+               point="org.eclipse.ui.perspectives">
+               <perspective
+            name="SLC Factory"
+            class="org.argeo.slc.client.ui.dist.DistributionPerspective"
+            id="org.argeo.slc.client.ui.dist.distributionPerspective"
+            icon="icons/distribution_perspective.gif">
+               </perspective>
+               <perspective
+            name="SLC Distribution"
+            class="org.argeo.slc.client.ui.dist.AnonymousDistributionPerspective"
+            id="org.argeo.slc.client.ui.dist.anonymousDistributionPerspective"
+            icon="icons/repo.gif">
+               </perspective>
+   </extension>
+   <!-- VIEWS -->
+   <extension
+               point="org.eclipse.ui.views">
+               <view
+            class="org.argeo.eclipse.spring.SpringExtensionFactory"
+            id="org.argeo.slc.client.ui.dist.distributionsView"
+            icon="icons/search.gif"
+            name="Distributions">
+               </view>
+               <view
+            class="org.argeo.eclipse.spring.SpringExtensionFactory"
+            id="org.argeo.slc.client.ui.dist.anonymousDistributionsView"
+            icon="icons/search.gif"
+            name="Public Repository">
+               </view>
+               <view
+            class="org.argeo.slc.client.ui.dist.views.HelpView"
+            id="org.argeo.slc.client.ui.dist.helpView"
+            icon="icons/help.gif"
+            name="About">
+               </view>
+               <!--
+               <view
+            class="org.argeo.eclipse.spring.SpringExtensionFactory"
+            id="org.argeo.slc.client.ui.dist.artifactsBrowser"
+            icon="icons/packageBrowser.gif"
+            name="Artifacts browser">
+               </view>
+               <view
+            class="org.argeo.eclipse.spring.SpringExtensionFactory"
+            id="org.argeo.slc.client.ui.dist.queryArtifactsForm"
+            icon="icons/searchForm.gif"
+            name="Artifacts Form">
+               </view>
+               <view
+            class="org.argeo.eclipse.spring.SpringExtensionFactory"
+            id="org.argeo.slc.client.ui.dist.queryBundlesForm"
+            icon="icons/searchForm.gif"
+                       name="Bundles Form">
+               </view>
+               <view
+            class="org.argeo.eclipse.spring.SpringExtensionFactory"
+            id="org.argeo.slc.client.ui.dist.queryArtifactsText"
+            icon="icons/search.gif"
+            name="Query builder">
+               </view>
+               -->
+               <view
+                name="Progress View"
+                icon="icons/pview.gif"
+                category="org.eclipse.ui"
+                class="org.eclipse.ui.ExtensionFactory:progressView"
+                id="org.eclipse.ui.views.ProgressView">
+               </view>
+       </extension>
+       <!-- EDITORS -->
+       <extension
+               point="org.eclipse.ui.editors">
+               <!-- <editor
+                       class="org.argeo.slc.client.ui.dist.editors.GenericBundleEditor"
+                       id="org.argeo.slc.client.ui.dist.genericBundleEditor"
+                       name="Bundle editor"
+                       icon="icons/artifactVersionBase.gif"
+                       default="false">
+               </editor> -->
+               <editor
+                       class="org.argeo.eclipse.spring.SpringExtensionFactory"
+                       id="org.argeo.slc.client.ui.dist.artifactVersionEditor"
+                       name="Artifact Version Editor"
+                       icon="icons/artifactVersionBase.gif"
+                       default="false">
+               </editor>
+               <editor
+                       class="org.argeo.eclipse.spring.SpringExtensionFactory"
+                       id="org.argeo.slc.client.ui.dist.modularDistVersionEditor"
+                       name="Modular Distribution Version Editor"
+                       icon="icons/modularDistributionVersion.gif"
+                       default="false">
+               </editor>
+               <editor
+                       class="org.argeo.eclipse.spring.SpringExtensionFactory"
+                       id="org.argeo.slc.client.ui.dist.distWorkspaceEditor"
+                       name="Distribution workspace editor"
+                       icon="icons/distribution_perspective.gif"
+                       default="false">
+               </editor>
+       </extension>
+
+    <!-- COMMANDS  --> 
+       <extension
+         point="org.eclipse.ui.commands">
+               
+               <!-- Distribution Managemnt -->
+               <command
+            id="org.argeo.slc.client.ui.dist.normalizeDistribution"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Normalize Distribution">
+                       <commandParameter
+                               id="workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+                       <commandParameter
+                               id="targetRepoPath"
+                               name="Target repo node path">
+                       </commandParameter>
+       </command>
+       
+       <command
+            id="org.argeo.slc.client.ui.dist.openModuleEditor"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Open Workspace Editor">
+                       <commandParameter
+                               id="param.repoNodePath"
+                               name="Repo node path">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.repoUri"
+                               name="Repo URI">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.modulePath"
+                               name="Module path name">
+                       </commandParameter>
+       </command>
+       
+       <!-- Repository Management --> 
+       <command
+            id="org.argeo.slc.client.ui.dist.registerRepository"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Add Repository">
+       </command>
+       <command
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            id="org.argeo.slc.client.ui.dist.unregisterRemoteRepo"
+            name="Unregister remote repository">
+            <commandParameter
+                       id="org.argeo.slc.client.ui.dist.repoNodePath"
+                       name="Remote Repo path">
+                       </commandParameter>
+       </command>
+               <command
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            id="org.argeo.slc.client.ui.dist.displayRepoInformation"
+            name="Display repository information">
+       </command>
+       
+       <!-- Workspace Management -->
+               <command
+            id="org.argeo.slc.client.ui.dist.openWorkspaceEditor"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Open Workspace Editor">
+                       <commandParameter
+                               id="param.repoNodePath"
+                               name="Repo node path">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.repoUri"
+                               name="Repo URI">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+       </command>
+       <command
+            id="org.argeo.slc.client.ui.dist.fetch"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Fetch repository">
+            <commandParameter
+                       id="targetRepoPath"
+                       name="Target repo uri">
+                       </commandParameter>
+       </command>
+       
+       <!-- <command
+            defaultHandler="org.argeo.slc.client.ui.dist.commands.MarkAsRelevantCategory"
+            id="org.argeo.slc.client.ui.dist.markAsRelevantCategory"
+            name="Mark as relevant category">
+       </command> --> 
+       
+       <command
+            id="org.argeo.slc.client.ui.dist.openGenerateBinariesWizard"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Generate Binaries...">
+            <commandParameter
+                               id="param.repoNodePath"
+                               name="Repo node path">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.modulePath"
+                               name="Module path name">
+                       </commandParameter>
+       </command>
+       
+       <command
+            id="org.argeo.slc.client.ui.dist.normalizeWorkspace"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Normalize Workspace">
+                       <commandParameter
+                               id="workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+                       <commandParameter
+                               id="targetRepoPath"
+                               name="Target repo node path">
+                       </commandParameter>
+       </command>
+       <command
+            id="org.argeo.slc.client.ui.dist.manageWorkspaceAuth"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Manage workspace authorizations">
+            <commandParameter
+                       id="org.argeo.slc.client.ui.dist.workspaceName"
+                       name="Workspace Name">
+                       </commandParameter>
+       </command>
+
+       <command
+            id="org.argeo.slc.client.ui.dist.publishWorkspace"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Publish selected workspace">
+                       <commandParameter
+                               id="workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+                       <commandParameter
+                               id="targetRepoPath"
+                               name="Target repo node path">
+                       </commandParameter>
+       </command>
+       
+               <command
+            id="org.argeo.slc.client.ui.dist.mergeWorkspaces"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Copy chosen Workspace">
+            <commandParameter
+                       id="srcWkspName"
+                       name="Source Workspace Name">
+                       </commandParameter>
+          <commandParameter
+                       id="srcRepoPath"
+                       name="Source Repo Node path ">
+                       </commandParameter>
+           <commandParameter
+                       id="targetWkspName"
+                       name="Target Workspace Name">
+                       </commandParameter>
+            <commandParameter
+                       id="targetRepoPath"
+                       name="Target repo node path">
+                       </commandParameter>
+       </command>
+       
+       <!-- Workspaces CRUD --> 
+               <!-- Generic new and copy workspace -->
+               <command
+            id="org.argeo.slc.client.ui.dist.createWorkspace"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Create Workspace">
+            <commandParameter
+                       id="workspacePrefix"
+                       name="Workspace prefix">
+                       </commandParameter>
+            <commandParameter
+                       id="targetRepoPath"
+                       name="Target repo node path">
+                       </commandParameter>
+       </command>
+       <command
+            id="org.argeo.slc.client.ui.dist.copyWorkspace"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Copy chosen Workspace">
+            <commandParameter
+                       id="srcWkspName"
+                       name="Source Workspace Name">
+                       </commandParameter>
+            <commandParameter
+                       id="targetRepoPath"
+                       name="Target repo node path">
+                       </commandParameter>
+       </command>
+       <!-- Specific for local java workspaces --> 
+       <command
+            id="org.argeo.slc.client.ui.dist.createLocalJavaWorkspace"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Create Local Java Workspace">
+            <commandParameter
+                       id="workspacePrefix"
+                       name="Workspace prefix">
+                       </commandParameter>
+       </command>
+               <command
+            id="org.argeo.slc.client.ui.dist.copyLocalJavaWorkspace"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Copy chosen local Java Workspace">
+            <commandParameter
+                       id="srcWkspName"
+                       name="Source Workspace Name">
+                       </commandParameter>
+       </command>
+               
+               <!-- Not terminated delete command - does not really work -->
+       <command
+                       id="org.argeo.slc.client.ui.dist.deleteWorkspace"
+                       defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+                       name="Delete chosen Workspace">
+                       <commandParameter
+                               id="workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+                       <commandParameter
+                               id="targetRepoPath"
+                               name="Target repo node path">
+                       </commandParameter>
+       </command>
+       
+               <!-- Advanced commands --> 
+               <command
+            id="org.argeo.slc.client.ui.dist.doNothing"
+            defaultHandler="org.argeo.slc.client.ui.dist.commands.DoNothing"
+            name="Advanced">
+       </command>
+               <command
+            id="org.argeo.slc.client.ui.dist.runInOsgi"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Run in OSGi">
+            <commandParameter
+                       id="workspaceName"
+                       name="Workspace Name">
+                       </commandParameter>
+            <commandParameter
+                  id="modulePath"
+                  name="Module Path"
+                  optional="true">
+            </commandParameter>
+       </command>
+       <command
+            id="org.argeo.slc.client.ui.dist.refreshDistributionsView"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Refresh Distributions View">
+       </command>
+               
+               <!-- Legacy -->
+               <command
+            defaultHandler="org.argeo.slc.client.ui.dist.commands.RefreshArtifactBrowser"
+            id="org.argeo.slc.client.ui.dist.refreshArtifactBrowser"
+            name="Refresh Artifact Browser">
+       </command>
+               
+       <command
+            defaultHandler="org.argeo.slc.client.ui.dist.commands.ShowSizeColumn"
+            id="org.argeo.slc.client.ui.dist.showSizeColumn"
+            name="Show size column">
+            <state 
+                               id="org.argeo.slc.client.ui.dist.showSizeColumn.toggleState">
+                               <class class="org.eclipse.jface.commands.ToggleState"> 
+                                       <parameter
+                                               name="default"
+                                       value="true" />
+                               </class>
+                       </state>
+       </command>
+       <command
+            id="org.argeo.slc.client.ui.dist.deleteArtifacts"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Remove selected artifacts">
+       </command>
+    </extension>
+    
+       <!-- MENU CONTRIBUTIONS --> 
+       <extension
+         id="menu:org.eclipse.ui.main.menu"
+         point="org.eclipse.ui.menus">
+               <!-- Distributions view tool bar --> 
+               <menuContribution
+               locationURI="toolbar:org.argeo.slc.client.ui.dist.distributionsView">
+            <command
+               commandId="org.argeo.slc.client.ui.dist.registerRepository"
+                icon="icons/addRepo.gif"
+                label="Register repository"
+                tooltip="Register a remote repository">
+            </command>
+             <command
+                commandId="org.argeo.slc.client.ui.dist.doNothing"
+                 id="org.argeo.slc.client.ui.dist.advancedMenu"
+                 icon="icons/more.gif"
+                 tooltip="Access to advanced commands"
+                 style="pulldown">
+           </command>
+        </menuContribution>
+               <menuContribution locationURI="menu:org.argeo.slc.client.ui.dist.advancedMenu">
+               <command
+                               commandId="org.argeo.slc.client.ui.dist.refreshDistributionsView"
+                               icon="icons/refresh.png"
+                               label="Refresh"
+                               tooltip="Force the full refresh of the distribution tree (close all open connections)">
+                       </command>
+            <!-- <command
+               commandId="org.argeo.slc.client.ui.dist.runInOSGi"
+                icon="icons/showSize.gif"
+                label="Run in OSGi"
+                tooltip="Run in a spearate OSGi runtime">
+            </command>
+            -->
+               </menuContribution>
+               <!-- Anonymous distribution view toolbar -->             
+        <menuContribution
+               locationURI="toolbar:org.argeo.slc.client.ui.dist.anonymousDistributionsView">
+            <command
+               commandId="org.argeo.slc.client.ui.dist.refreshDistributionsView"
+                icon="icons/refresh.png"
+                label="Refresh"
+                tooltip="Force the full refresh of the distribution tree (close all open connections)">
+            </command>
+        </menuContribution>
+        <!-- Artifact Browser Tool bar --> 
+               <menuContribution
+               locationURI="toolbar:org.argeo.slc.client.ui.dist.artifactsBrowser">
+            <command
+               commandId="org.argeo.slc.client.ui.dist.showSizeColumn"
+                icon="icons/showSize.gif"
+                style="toggle" 
+                label="Show sizes"
+                tooltip="Warning: showing size column might reduce overall browser reactivity">
+            </command>
+                       <command
+               commandId="org.argeo.slc.client.ui.dist.refreshArtifactBrowser"
+                icon="icons/refresh.png"
+                       label="Refresh"
+                tooltip="Refresh the whole browser">
+            </command>
+        </menuContribution>
+        <!-- Queries --> 
+               <!-- <menuContribution
+                allPopups="false"
+                locationURI="menu:org.eclipse.ui.main.menu?after=edit">
+               <menu label="Queries"
+              mnemonic="Queries"
+              id="org.argeo.slc.client.ui.dist.queryMenu">
+                <command
+                      commandId="org.argeo.slc.client.ui.dist.openGenericJcrQueryEditor"
+                      disabledIcon="icons/saveDisabled.gif"
+                      icon="icons/results.gif"
+                      label="JCR Query"
+                      style="push"
+                      tooltip="Open JCR query editor">
+                </command>
+             </menu>
+          </menuContribution> -->
+       </extension>
+       <extension
+           point="org.eclipse.ui.activities">
+        <!-- TODO: find a way to exclude evrything -->
+        <activityPatternBinding
+              activityId="org.argeo.slc.client.ui.slcActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.slc.client.ui.dist/org.argeo.slc.client.ui.dist.distributionPerspective">
+        </activityPatternBinding>
+        <activityPatternBinding
+              activityId="org.argeo.security.ui.adminActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.slc.client.ui.dist/org.argeo.slc.client.ui.dist.distributionPerspective">
+        </activityPatternBinding>
+     </extension>
+</plugin>
diff --git a/legacy/org.argeo.slc.client.ui.dist/pom.xml b/legacy/org.argeo.slc.client.ui.dist/pom.xml
new file mode 100644 (file)
index 0000000..81c5c8d
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.client.ui.dist</artifactId>
+       <name>SLC Client UI Distribution</name>
+       <packaging>jar</packaging>
+       <dependencies>
+               <!-- Commons UI -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.eclipse.ui</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc.legacy.commons</groupId>
+                       <artifactId>org.argeo.cms.ui.workbench</artifactId>
+                       <version>${version.argeo-commons-legacy}</version>
+               </dependency>
+
+
+               <!-- SLC repo -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.api</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.repo</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.spring</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.server.repo</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Argeo Base dependencies -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.core</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+
+               <!-- RAP workbench -->
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>argeo-tp-rap-e3</artifactId>
+                       <version>${version.argeo-tp}</version>
+                       <type>pom</type>
+                       <scope>provided</scope>
+               </dependency>
+
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/AnonymousDistributionPerspective.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/AnonymousDistributionPerspective.java
new file mode 100644 (file)
index 0000000..e2418a8
--- /dev/null
@@ -0,0 +1,25 @@
+package org.argeo.slc.client.ui.dist;
+
+import org.argeo.slc.client.ui.dist.views.AnonymousDistributionsView;
+import org.argeo.slc.client.ui.dist.views.HelpView;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/** Simple default perspective that presents public repositories */
+public class AnonymousDistributionPerspective implements IPerspectiveFactory {
+
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".anonymousDistributionPerspective";
+
+       public void createInitialLayout(IPageLayout layout) {
+               String editorArea = layout.getEditorArea();
+               layout.setEditorAreaVisible(true);
+               layout.setFixed(false);
+
+               IFolderLayout main = layout.createFolder("main", IPageLayout.LEFT,
+                               0.3f, editorArea);
+               main.addView(AnonymousDistributionsView.ID);
+               main.addView(HelpView.ID);
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistConstants.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistConstants.java
new file mode 100644 (file)
index 0000000..10e5f6a
--- /dev/null
@@ -0,0 +1,33 @@
+package org.argeo.slc.client.ui.dist;
+
+import org.argeo.slc.SlcNames;
+import org.osgi.framework.Constants;
+
+/** Constants used across the application. */
+public interface DistConstants {
+
+       /*
+        * MISCEALLENEOUS
+        */
+       public final static String DATE_TIME_FORMAT = "MM/dd/yyyy, HH:mm";
+       public final static String DATE_FORMAT = "MM/dd/yyyy";
+       // this should be directly retrieved from JCR APIs once we have solved the
+       // problem of the translation of name space to shortcut, typically
+       // {http://www.jcp.org/jcr/1.0} to jcr:
+       public final static String JCR_IDENTIFIER = "jcr:uuid";
+       public final static String JCR_MIXIN_TYPES = "jcr:mixinTypes";
+
+       // FIXME: should be defined in SlcNames
+       public final static String SLC_BUNDLE_NAME = SlcNames.SLC_
+                       + Constants.BUNDLE_NAME;
+       public final static String SLC_BUNDLE_LICENCE = SlcNames.SLC_
+                       + "Bundle-License";
+       public final static String SLC_BUNDLE_VENDOR = SlcNames.SLC_
+                       + Constants.BUNDLE_VENDOR;
+
+       public final static String SLC_BUNDLE_DESCRIPTION = SlcNames.SLC_
+                       + Constants.BUNDLE_DESCRIPTION;
+
+       public final String DEFAULT_PUBLIC_REPOSITORY_URI = "vm:///java";
+
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistImages.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistImages.java
new file mode 100644 (file)
index 0000000..9f5cba1
--- /dev/null
@@ -0,0 +1,60 @@
+package org.argeo.slc.client.ui.dist;
+
+import org.eclipse.swt.graphics.Image;
+
+/** Shared icons. */
+public class DistImages {
+
+       public final static Image IMG_ARTIFACT_BASE = DistPlugin
+                       .getImageDescriptor("icons/artifactBase.gif").createImage();
+       public final static Image IMG_PACKAGE = DistPlugin.getImageDescriptor(
+                       "icons/package.gif").createImage();
+       public final static Image IMG_BUNDLE = DistPlugin.getImageDescriptor(
+                       "icons/packages.gif").createImage();
+       public final static Image IMG_ARTIFACT_VERSION_BASE = DistPlugin
+                       .getImageDescriptor("icons/artifactVersionBase.gif").createImage();
+       public final static Image IMG_FILE = DistPlugin.getImageDescriptor(
+                       "icons/file.gif").createImage();
+
+       /* WORKSPACES */
+       public final static Image IMG_WKSP = DistPlugin.getImageDescriptor(
+                       "icons/distribution_perspective.gif").createImage();
+
+       /* REPOSITORIES */
+       public final static Image IMG_REPO = DistPlugin.getImageDescriptor(
+                       "icons/repo.gif").createImage();
+       public final static Image IMG_HOME_REPO = DistPlugin.getImageDescriptor(
+                       "icons/homeRepo.gif").createImage();
+       public final static Image IMG_REPO_READONLY = DistPlugin
+                       .getImageDescriptor("icons/repoReadOnly.gif").createImage();
+       public final static Image IMG_ADD_REPO = DistPlugin.getImageDescriptor(
+                       "icons/addRepo.gif").createImage();
+       public final static Image IMG_REMOVE_REPO = DistPlugin.getImageDescriptor(
+                       "icons/artifactBase.gif").createImage();
+       public final static Image IMG_FETCH_REPO = DistPlugin.getImageDescriptor(
+                       "icons/fetchRepo.png").createImage();
+
+       /* DISTRIBUTIONS */
+       public final static Image IMG_WKSP_GROUP = DistPlugin.getImageDescriptor(
+                       "icons/wkspGroup.gif").createImage();
+       public final static Image IMG_DISTGRP = DistPlugin.getImageDescriptor(
+                       "icons/distGrp.gif").createImage();
+       public final static Image IMG_DISTGRP_READONLY = DistPlugin
+                       .getImageDescriptor("icons/distGrpReadOnly.gif").createImage();
+
+       public final static Image IMG_MODULAR_DIST_BASE = DistPlugin
+                       .getImageDescriptor("icons/packages.gif").createImage();
+       public final static Image IMG_MODULAR_DIST_VERSION = DistPlugin
+                       .getImageDescriptor("icons/packages.gif").createImage();
+
+       public final static Image IMG_GROUP_BASE = DistPlugin.getImageDescriptor(
+                       "icons/packages.gif").createImage();
+
+       /* Various */
+       public final static Image CHECKED = DistPlugin.getImageDescriptor(
+                       "icons/checked.gif").createImage();
+       public final static Image UNCHECKED = DistPlugin.getImageDescriptor(
+                       "icons/unchecked.gif").createImage();
+       public final static Image IMG_CLEAR = DistPlugin.getImageDescriptor(
+                       "icons/clear.gif").createImage();
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistPlugin.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistPlugin.java
new file mode 100644 (file)
index 0000000..b85fcba
--- /dev/null
@@ -0,0 +1,26 @@
+package org.argeo.slc.client.ui.dist;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/** Default activator for the distribution bundle */
+public class DistPlugin extends AbstractUIPlugin {
+       public final static String PLUGIN_ID = "org.argeo.slc.client.ui.dist";
+
+       private static DistPlugin plugin;
+
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       public static DistPlugin getDefault() {
+               return plugin;
+       }
+
+       public static ImageDescriptor getImageDescriptor(String path) {
+               return imageDescriptorFromPlugin(PLUGIN_ID, path);
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistributionPerspective.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/DistributionPerspective.java
new file mode 100644 (file)
index 0000000..cedc2eb
--- /dev/null
@@ -0,0 +1,26 @@
+package org.argeo.slc.client.ui.dist;
+
+import org.argeo.slc.client.ui.dist.views.DistributionsView;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/** Manage a set of software repositories */
+public class DistributionPerspective implements IPerspectiveFactory {
+
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".distributionPerspective";
+
+       public void createInitialLayout(IPageLayout layout) {
+               String editorArea = layout.getEditorArea();
+               layout.setEditorAreaVisible(true);
+               layout.setFixed(false);
+
+               IFolderLayout main = layout.createFolder("main", IPageLayout.LEFT,
+                               0.3f, editorArea);
+               main.addView(DistributionsView.ID);
+               IFolderLayout bottom = layout.createFolder("bottom",
+                               IPageLayout.BOTTOM, 0.75f, editorArea);
+               bottom.addView("org.eclipse.ui.views.ProgressView");
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/BndProcess.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/BndProcess.java
new file mode 100644 (file)
index 0000000..2573496
--- /dev/null
@@ -0,0 +1,48 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.jar.Manifest;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+import aQute.bnd.osgi.Builder;
+import aQute.bnd.osgi.Constants;
+import aQute.bnd.osgi.Jar;
+
+public class BndProcess extends AbstractHandler implements Constants {
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               try {
+                       Builder b = new Builder();
+                       b.setProperty(EXPORT_PACKAGE, "org.osgi.framework");
+                       b.setProperty(PRIVATE_PACKAGE, "*");
+                       b.addClasspath(new File(
+                                       "/home/mbaudier/.m2/repository/org/eclipse/osgi/org.eclipse.osgi/3.6.1/org.eclipse.osgi-3.6.1.jar"));
+
+                       Jar jar = b.build();
+                       Manifest m = jar.getManifest();
+                       jar.write(new File(b.getBsn() + ".jar"));
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+
+               return null;
+       }
+
+       public static void main(String[] args) {
+               try {
+                       new BndProcess().execute(null);
+               } catch (ExecutionException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyLocalJavaWorkspace.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyLocalJavaWorkspace.java
new file mode 100644 (file)
index 0000000..7d26f90
--- /dev/null
@@ -0,0 +1,165 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.security.Privilege;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.ui.workbench.util.PrivilegedJob;
+import org.argeo.eclipse.ui.EclipseJcrMonitor;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.repo.JavaRepoManager;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Create a copy of the chosen workspace in the local Java repository using a
+ * JavaRepoManager.
+ */
+public class CopyLocalJavaWorkspace extends AbstractHandler {
+       private static final Log log = LogFactory
+                       .getLog(CopyLocalJavaWorkspace.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".copyLocalJavaWorkspace";
+       public final static String DEFAULT_LABEL = "Copy Java Workspace...";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/addItem.gif");
+
+       public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
+
+       // DEPENDENCY INJECTION
+       private Repository javaRepository;
+       private JavaRepoManager javaRepoManager;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               String wkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
+
+               InputDialog inputDialog = new InputDialog(HandlerUtil
+                               .getActiveWorkbenchWindow(event).getShell(),
+                               "New copy of workspace " + wkspName,
+                               "Choose a name for the workspace to create", "", null);
+               int result = inputDialog.open();
+               if (result == Window.OK) {
+                       String newWorkspaceName = inputDialog.getValue();
+
+                       if (newWorkspaceName == null || newWorkspaceName.trim().equals("")
+                                       || newWorkspaceName.trim().equals(wkspName.trim())) {
+                               ErrorDialog
+                                               .openError(HandlerUtil.getActiveShell(event),
+                                                               "Non valid workspace name", newWorkspaceName
+                                                                               + " is not a valid workspace name.",
+                                                               new Status(IStatus.ERROR, "not valid", 0,
+                                                                               "Error", null));
+                               return null;
+                       }
+                       Job copyWkspJob = new CopyWkspJob(javaRepoManager, javaRepository,
+                                       wkspName, newWorkspaceName, HandlerUtil
+                                                       .getActiveWorkbenchWindow(event).getShell()
+                                                       .getDisplay());
+                       copyWkspJob.setUser(true);
+                       copyWkspJob.schedule();
+               }
+               return null;
+       }
+
+       private static class CopyWkspJob extends PrivilegedJob {
+
+               private JavaRepoManager javaRepoManager;
+               private Repository javaRepository;
+               private String srcWkspName;
+               private String targetWkspName;
+               private Display display;
+
+               public CopyWkspJob(JavaRepoManager javaRepoManager,
+                               Repository javaRepository, String srcWkspName,
+                               String targetWkspName, Display display) {
+                       super("Duplicate workspace");
+                       this.javaRepoManager = javaRepoManager;
+                       this.javaRepository = javaRepository;
+                       this.srcWkspName = srcWkspName;
+                       this.targetWkspName = targetWkspName;
+                       this.display = display;
+               }
+
+               @Override
+               protected IStatus doRun(IProgressMonitor progressMonitor) {
+                       long begin = System.currentTimeMillis();
+
+                       JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
+                       monitor.beginTask("Copy workspace", -1);
+                       monitor.subTask("Copying nodes");
+
+                       Session srcSession = null;
+                       Session targetSession = null;
+                       try {
+                               // Initialize source
+                               srcSession = javaRepository.login(srcWkspName);
+                               Node srcRootNode = srcSession.getRootNode();
+
+                               // Create the workspace -
+                               // FIXME will throw an error if workspace already exists
+                               javaRepoManager.createWorkspace(targetWkspName);
+                               targetSession = javaRepository.login(targetWkspName);
+                               Node newRootNode = targetSession.getRootNode();
+
+                               RepoUtils.copy(srcRootNode, newRootNode, monitor);
+                               targetSession.save();
+                               JcrUtils.addPrivilege(targetSession, "/",
+                                               SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
+                               monitor.worked(1);
+
+                               display.asyncExec(new Runnable() {
+                                       public void run() {
+                                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+                                       }
+                               });
+
+                       } catch (RepositoryException re) {
+                               throw new SlcException(
+                                               "Unexpected error while creating the new workspace.",
+                                               re);
+                       } finally {
+                               JcrUtils.logoutQuietly(srcSession);
+                               JcrUtils.logoutQuietly(targetSession);
+                       }
+
+                       monitor.done();
+                       long duration = (System.currentTimeMillis() - begin) / 1000;// in
+                                                                                                                                               // s
+                       if (log.isDebugEnabled())
+                               log.debug("Duplicated local java workspace " + srcWkspName
+                                               + " to workspace " + targetWkspName + " in "
+                                               + (duration / 60) + "min " + (duration % 60) + "s");
+                       return Status.OK_STATUS;
+               }
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setJavaRepository(Repository javaRepository) {
+               this.javaRepository = javaRepository;
+       }
+
+       public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
+               this.javaRepoManager = javaRepoManager;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyWorkspace.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CopyWorkspace.java
new file mode 100644 (file)
index 0000000..4abdfab
--- /dev/null
@@ -0,0 +1,183 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.security.Privilege;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.api.security.Keyring;
+import org.argeo.cms.ui.workbench.util.PrivilegedJob;
+import org.argeo.eclipse.ui.EclipseJcrMonitor;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Create a copy of the chosen workspace in a remote repository */
+public class CopyWorkspace extends AbstractHandler {
+       private static final Log log = LogFactory.getLog(CopyWorkspace.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".copyWorkspace";
+       public final static String DEFAULT_LABEL = "Duplicate...";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/addItem.gif");
+
+       public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+
+       // DEPENDENCY INJECTION
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       private Repository nodeRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
+               String wkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
+
+               InputDialog inputDialog = new InputDialog(HandlerUtil
+                               .getActiveWorkbenchWindow(event).getShell(),
+                               "New copy of workspace " + wkspName,
+                               "Choose a name for the workspace to create", "", null);
+               int result = inputDialog.open();
+               if (result == Window.OK) {
+                       String newWorkspaceName = inputDialog.getValue();
+
+                       if (newWorkspaceName == null || newWorkspaceName.trim().equals("")
+                                       || newWorkspaceName.trim().equals(wkspName.trim())) {
+                               ErrorDialog
+                                               .openError(HandlerUtil.getActiveShell(event),
+                                                               "Non valid workspace name", newWorkspaceName
+                                                                               + " is not a valid workspace name.",
+                                                               new Status(IStatus.ERROR, "not valid", 0,
+                                                                               "Error", null));
+                               return null;
+                       }
+                       Job copyWkspJob = new CopyWkspJob(repositoryFactory, keyring,
+                                       nodeRepository, targetRepoPath, wkspName, newWorkspaceName,
+                                       HandlerUtil.getActiveWorkbenchWindow(event).getShell()
+                                                       .getDisplay());
+                       copyWkspJob.setUser(true);
+                       copyWkspJob.schedule();
+               }
+               return null;
+       }
+
+       private static class CopyWkspJob extends PrivilegedJob {
+
+               private RepositoryFactory repositoryFactory;
+               private Keyring keyring;
+               private Repository localRepository;
+               private String targetRepoPath;
+               private String srcWkspName;
+               private String targetWkspName;
+               private Display display;
+
+               public CopyWkspJob(RepositoryFactory repositoryFactory,
+                               Keyring keyring, Repository localRepository,
+                               String targetRepoPath, String srcWkspName,
+                               String targetWkspName, Display display) {
+                       super("Duplicate workspace");
+                       this.repositoryFactory = repositoryFactory;
+                       this.keyring = keyring;
+                       this.localRepository = localRepository;
+                       this.targetRepoPath = targetRepoPath;
+                       this.srcWkspName = srcWkspName;
+                       this.targetWkspName = targetWkspName;
+                       this.display = display;
+               }
+
+               @Override
+               protected IStatus doRun(IProgressMonitor progressMonitor) {
+                       long begin = System.currentTimeMillis();
+
+                       JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
+                       monitor.beginTask("Copy workspace", -1);
+                       monitor.subTask("Copying nodes");
+
+                       Session nodeSession = null;
+                       Session srcSession = null;
+                       Session newSession = null;
+                       try {
+                               nodeSession = localRepository.login();
+                               Node repoNode = nodeSession.getNode(targetRepoPath);
+                               Repository repository = RepoUtils.getRepository(
+                                               repositoryFactory, keyring, repoNode);
+                               Credentials credentials = RepoUtils.getRepositoryCredentials(
+                                               keyring, repoNode);
+
+                               srcSession = repository.login(credentials, srcWkspName);
+
+                               // Create the workspace
+                               srcSession.getWorkspace().createWorkspace(targetWkspName);
+                               Node srcRootNode = srcSession.getRootNode();
+                               // log in the newly created workspace
+                               newSession = repository.login(credentials, targetWkspName);
+                               Node newRootNode = newSession.getRootNode();
+                               RepoUtils.copy(srcRootNode, newRootNode, monitor);
+                               newSession.save();
+                               JcrUtils.addPrivilege(newSession, "/", SlcConstants.ROLE_SLC,
+                                               Privilege.JCR_ALL);
+
+                               display.asyncExec(new Runnable() {
+                                       public void run() {
+                                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+                                       }
+                               });
+                               monitor.worked(1);
+
+                       } catch (RepositoryException re) {
+                               throw new SlcException(
+                                               "Unexpected error while creating the new workspace.",
+                                               re);
+                       } finally {
+                               JcrUtils.logoutQuietly(newSession);
+                               JcrUtils.logoutQuietly(srcSession);
+                               JcrUtils.logoutQuietly(nodeSession);
+                       }
+
+                       monitor.done();
+                       long duration = (System.currentTimeMillis() - begin) / 1000;// in
+                                                                                                                                               // s
+                       if (log.isDebugEnabled())
+                               log.debug("Created workspace " + targetWkspName + " in "
+                                               + (duration / 60) + "min " + (duration % 60) + "s");
+                       return Status.OK_STATUS;
+               }
+
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateLocalJavaWorkspace.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateLocalJavaWorkspace.java
new file mode 100644 (file)
index 0000000..dd15ecf
--- /dev/null
@@ -0,0 +1,83 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.repo.JavaRepoManager;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Create a new empty workspace in the default local java repository */
+public class CreateLocalJavaWorkspace extends AbstractHandler {
+       private static final Log log = LogFactory
+                       .getLog(CreateLocalJavaWorkspace.class);
+
+       // Exposes commands meta-info
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".createLocalJavaWorkspace";
+       public final static String DEFAULT_LABEL = "Create local Java workspace...";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/addItem.gif");
+
+       // Parameters
+       public final static String PARAM_WORKSPACE_PREFIX = "workspacePrefix";
+
+       /* DEPENDENCY INJECTION */
+       private JavaRepoManager javaRepoManager;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               String prefix = event.getParameter(PARAM_WORKSPACE_PREFIX);
+               // TODO : add an input validator
+               InputDialog inputDialog = new InputDialog(HandlerUtil
+                               .getActiveWorkbenchWindow(event).getShell(), "Workspace name?",
+                               "Choose a name for the workspace to create",
+                               prefix == null ? "" : prefix + "-", null);
+               int result = inputDialog.open();
+
+               String enteredName = inputDialog.getValue();
+               final String legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
+               char[] arr = enteredName.toUpperCase().toCharArray();
+               int count = 0;
+               for (int i = 0; i < arr.length; i++) {
+                       if (legalChars.indexOf(arr[i]) == -1)
+                               count = count + 7;
+                       else
+                               count++;
+               }
+
+               if (count > 60) {
+                       ErrorFeedback.show("Workspace name '" + enteredName
+                                       + "' is too long or contains"
+                                       + " too many special characters such as '.' or '-'.");
+                       return null;
+               }
+
+               String workspaceName = enteredName;
+               // Canceled by user
+               if (result == Dialog.CANCEL || workspaceName == null
+                               || "".equals(workspaceName.trim()))
+                       return null;
+
+               // FIXME will throw an exception if this workspace name is already used.
+               javaRepoManager.createWorkspace(workspaceName);
+
+               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+               if (log.isTraceEnabled())
+                       log.trace("WORKSPACE " + workspaceName + " CREATED");
+
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
+               this.javaRepoManager = javaRepoManager;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateWorkspace.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/CreateWorkspace.java
new file mode 100644 (file)
index 0000000..9934c86
--- /dev/null
@@ -0,0 +1,133 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.security.Privilege;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.api.security.Keyring;
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Create a new empty workspace in a remote repository */
+public class CreateWorkspace extends AbstractHandler {
+       private static final Log log = LogFactory.getLog(CreateWorkspace.class);
+
+       // Exposes commands meta-info
+       public final static String ID = DistPlugin.PLUGIN_ID + ".createWorkspace";
+       public final static String DEFAULT_LABEL = "Create workspace...";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/addItem.gif");
+
+       // Parameters
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+       public final static String PARAM_WORKSPACE_PREFIX = "workspacePrefix";
+
+       // DEPENDENCY INJECTION
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       private Repository nodeRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
+               String prefix = event.getParameter(PARAM_WORKSPACE_PREFIX);
+
+               Session nodeSession = null;
+               Session session = null;
+               try {
+                       nodeSession = nodeRepository.login();
+                       Node repoNode = nodeSession.getNode(targetRepoPath);
+                       Repository repository = RepoUtils.getRepository(repositoryFactory,
+                                       keyring, repoNode);
+                       Credentials credentials = RepoUtils.getRepositoryCredentials(
+                                       keyring, repoNode);
+
+                       // TODO : add an input validator
+                       InputDialog inputDialog = new InputDialog(HandlerUtil
+                                       .getActiveWorkbenchWindow(event).getShell(),
+                                       "Workspace name?",
+                                       "Choose a name for the workspace to create",
+                                       prefix == null ? "" : prefix + "-", null);
+                       int result = inputDialog.open();
+
+                       String enteredName = inputDialog.getValue();
+
+                       final String legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
+                       char[] arr = enteredName.toUpperCase().toCharArray();
+                       int count = 0;
+                       for (int i = 0; i < arr.length; i++) {
+                               if (legalChars.indexOf(arr[i]) == -1)
+                                       count = count + 7;
+                               else
+                                       count++;
+                       }
+
+                       if (log.isTraceEnabled())
+                               log.trace("Translated workspace name length: " + count
+                                               + " (name: " + enteredName + " )");
+
+                       if (count > 60) {
+                               ErrorFeedback.show("Workspace name '" + enteredName
+                                               + "' is too long or contains"
+                                               + " too many special characters such as '.' or '-'.");
+                               return null;
+                       }
+
+                       String workspaceName = enteredName;
+
+                       // Canceled by user
+                       if (result == Dialog.CANCEL || workspaceName == null
+                                       || "".equals(workspaceName.trim()))
+                               return null;
+
+                       session = repository.login(credentials);
+                       session.getWorkspace().createWorkspace(workspaceName);
+                       JcrUtils.logoutQuietly(session);
+                       // init new workspace
+                       session = repository.login(credentials, workspaceName);
+                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+                                       Privilege.JCR_ALL);
+                       CommandHelpers.callCommand(RefreshDistributionsView.ID);
+                       if (log.isTraceEnabled())
+                               log.trace("WORKSPACE " + workspaceName + " CREATED");
+
+               } catch (RepositoryException re) {
+                       ErrorFeedback.show(
+                                       "Unexpected error while creating the new workspace.", re);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+                       JcrUtils.logoutQuietly(nodeSession);
+               }
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteArtifacts.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteArtifacts.java
new file mode 100644 (file)
index 0000000..4caf2b5
--- /dev/null
@@ -0,0 +1,72 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import java.util.Iterator;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Delete chosen artifacts from the current workspace */
+public class DeleteArtifacts extends AbstractHandler {
+       // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".deleteArtifacts";
+       public final static String DEFAULT_LABEL = "Delete selected items";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/removeItem.gif");
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               try {
+                       IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
+
+                       if (activePart instanceof IEditorPart) {
+                               ISelection selector = ((IEditorPart) activePart)
+                                               .getEditorSite().getSelectionProvider().getSelection();
+                               if (selector != null
+                                               && selector instanceof IStructuredSelection) {
+                                       Iterator<?> it = ((IStructuredSelection) selector)
+                                                       .iterator();
+
+                                       String msg = "Your are about to definitively remove the "
+                                                       + ((IStructuredSelection) selector).size()
+                                                       + " selected artifacts.\n"
+                                                       + "Are you sure you want to proceed?";
+
+                                       boolean result = MessageDialog.openConfirm(DistPlugin
+                                                       .getDefault().getWorkbench().getDisplay()
+                                                       .getActiveShell(), "Confirm Deletion", msg);
+
+                                       if (result) {
+                                               while (it.hasNext()) {
+                                                       Node node = (Node) it.next();
+                                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                                               // we remove the artifactVersion, that is the
+                                                               // parent
+                                                               node.getParent().remove();
+                                                               node.getSession().save();
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       // CommandHelpers.callCommand(RefreshDistributionOverviewPage.ID);
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while deleting artifacts.", re);
+               }
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java
new file mode 100644 (file)
index 0000000..4707fc0
--- /dev/null
@@ -0,0 +1,121 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.api.security.Keyring;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * Delete chosen workspace in the current repository.
+ * 
+ * Due to current version of JackRabbit, it only cleans it for the time being,
+ * removing all nodes of type {@code NodeType.NT_FOLDER} and
+ * {@code NodeType.NT_UNSTRUCTURED}
+ */
+public class DeleteWorkspace extends AbstractHandler {
+       // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".deleteWorkspace";
+       public final static String DEFAULT_LABEL = "Clear";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/removeItem.gif");
+
+       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+
+       // DEPENDENCY INJECTION
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       private Repository nodeRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
+               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+
+               Session nodeSession = null;
+               Session session = null;
+               try {
+                       nodeSession = nodeRepository.login();
+                       Node repoNode = nodeSession.getNode(targetRepoPath);
+                       Repository repository = RepoUtils.getRepository(repositoryFactory,
+                                       keyring, repoNode);
+                       Credentials credentials = RepoUtils.getRepositoryCredentials(
+                                       keyring, repoNode);
+
+                       String msg = "Your are about to completely delete workspace ["
+                                       + workspaceName + "].\n Do you really want to proceed?";
+                       boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
+                                       .getWorkbench().getDisplay().getActiveShell(),
+                                       "Confirm workspace deletion", msg);
+
+                       if (result) {
+                               // msg =
+                               // "There is no possible turning back, are your REALLY sure you want to proceed ?";
+                               msg = "WARNING: \nCurrent Jackrabbit version used does "
+                                               + "not support workspace deletion.\n"
+                                               + "Thus, the workspace will only be cleaned so "
+                                               + "that you can launch fetch process again.\n\n"
+                                               + "Do you still want to proceed?";
+                               result = MessageDialog.openConfirm(DistPlugin.getDefault()
+                                               .getWorkbench().getDisplay().getActiveShell(),
+                                               "Confirm workspace deletion", msg);
+                       }
+
+                       if (result) {
+                               session = repository.login(credentials, workspaceName);
+                               // TODO use this with a newer version of Jackrabbit
+                               // Workspace wsp = session.getWorkspace();
+                               // wsp.deleteWorkspace(workspaceName);
+                               NodeIterator nit = session.getRootNode().getNodes();
+                               while (nit.hasNext()) {
+                                       Node node = nit.nextNode();
+                                       if (node.isNodeType(NodeType.NT_FOLDER)
+                                                       || node.isNodeType(NodeType.NT_UNSTRUCTURED)) {
+                                               // String path = node.getPath();
+                                               node.remove();
+                                               session.save();
+                                       }
+                               }
+                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while deleting workspace ["
+                                                       + workspaceName + "].", re);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+                       JcrUtils.logoutQuietly(nodeSession);
+               }
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java
new file mode 100644 (file)
index 0000000..38e4367
--- /dev/null
@@ -0,0 +1,145 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Repository;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.argeo.slc.repo.RepoService;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Open a dialog that displays various information on the current repository.
+ */
+public class DisplayRepoInformation extends AbstractHandler {
+       public final static String ID = DistPlugin.PLUGIN_ID + ".displayRepoInformation";
+       public final static String DEFAULT_LABEL = "Information";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/help.gif");
+
+       /* DEPENDENCY INJECTION */
+       private RepoService repoService;
+       private Repository nodeRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               IStructuredSelection iss = (IStructuredSelection) HandlerUtil
+                               .getActiveSite(event).getSelectionProvider().getSelection();
+               if (iss.getFirstElement() instanceof RepoElem) {
+                       RepoElem re = (RepoElem) iss.getFirstElement();
+
+                       Session defaultSession = null;
+                       try {
+                               defaultSession = repoService.getRemoteSession(re.getRepoNodePath(),
+                                               re.getUri(), null);
+
+                               InformationDialog inputDialog = new InformationDialog(
+                                               HandlerUtil.getActiveSite(event).getShell());
+                               inputDialog.create();
+                               // TODO add more information.
+                               inputDialog.loginTxt.setText(defaultSession.getUserID());
+                               inputDialog.nameTxt.setText(re.getLabel());
+                               inputDialog.uriTxt.setText(re.getUri());
+                               inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
+
+                               inputDialog.open();
+                               // } catch (RepositoryException e) {
+                               // throw new SlcException("Unexpected error while "
+                               // + "getting repository information.", e);
+                       } finally {
+                               JcrUtils.logoutQuietly(defaultSession);
+                       }
+               }
+               return null;
+       }
+
+       private class InformationDialog extends Dialog {
+               Text nameTxt;
+               Text uriTxt;
+               Text loginTxt;
+               Button readOnlyBtn;
+
+               @Override
+               protected void createButtonsForButtonBar(Composite parent) {
+                       // No Cancel button
+                       createButton(parent, IDialogConstants.OK_ID, "OK", true);
+               }
+
+               public InformationDialog(Shell parentShell) {
+                       super(parentShell);
+               }
+
+               protected Point getInitialSize() {
+                       return new Point(500, 250);
+               }
+
+               protected Control createDialogArea(Composite parent) {
+                       Composite dialogarea = (Composite) super.createDialogArea(parent);
+                       dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+                                       true));
+                       Composite composite = new Composite(dialogarea, SWT.NONE);
+                       GridLayout layout = new GridLayout(2, false);
+                       layout.horizontalSpacing = 15;
+                       composite.setLayout(layout);
+                       GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+                       composite.setLayoutData(gd);
+
+                       nameTxt = createLT(composite, "Name");
+                       uriTxt = createLT(composite, "URI");
+                       loginTxt = createLT(composite, "Logged as");
+                       readOnlyBtn = createLC(composite, "Read only");
+                       parent.pack();
+                       return composite;
+               }
+
+               /** Creates label and text. */
+               protected Text createLT(Composite parent, String label) {
+                       new Label(parent, SWT.RIGHT).setText(label);
+                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.NONE);
+                       text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       text.setEditable(false);
+                       return text;
+               }
+
+               /** Creates label and check. */
+               protected Button createLC(Composite parent, String label) {
+                       new Label(parent, SWT.RIGHT).setText(label);
+                       Button check = new Button(parent, SWT.CHECK);
+                       check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       check.setEnabled(false);
+                       return check;
+               }
+
+               protected void configureShell(Shell shell) {
+                       super.configureShell(shell);
+                       shell.setText("Repository information");
+               }
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
+       }
+
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DoNothing.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/DoNothing.java
new file mode 100644 (file)
index 0000000..2a9307a
--- /dev/null
@@ -0,0 +1,15 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/** Util command used to enable sub menus in various toolbars. Does nothing */
+public class DoNothing extends AbstractHandler {
+       public final static String ID = DistPlugin.PLUGIN_ID + ".doNothing";
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               return null;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/Fetch.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/Fetch.java
new file mode 100644 (file)
index 0000000..39a9274
--- /dev/null
@@ -0,0 +1,80 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.api.security.Keyring;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.client.ui.dist.wizards.FetchWizard;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Wrap a {@code RepoSync} as an Eclipse command. Open a wizard that enable
+ * definition of the fetch process parameters
+ */
+public class Fetch extends AbstractHandler {
+       // private final static Log log = LogFactory.getLog(Fetch.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".fetch";
+       public final static String DEFAULT_LABEL = "Fetch...";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/fetchRepo.png");
+
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+
+       // DEPENDENCY INJECTION
+       private Keyring keyring;
+       private RepositoryFactory repositoryFactory;
+       private Repository nodeRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               Session currSession = null;
+               try {
+                       // Target Repository
+                       String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
+                       currSession = nodeRepository.login();
+                       Node targetRepoNode = currSession.getNode(targetRepoPath);
+
+                       FetchWizard wizard = new FetchWizard(keyring, repositoryFactory,
+                                       nodeRepository);
+                       wizard.setTargetRepoNode(targetRepoNode);
+                       WizardDialog dialog = new WizardDialog(
+                                       HandlerUtil.getActiveShell(event), wizard);
+
+                       int result = dialog.open();
+                       if (result == Dialog.OK)
+                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+                       return null;
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unable te retrieve repo node from path", e);
+               } finally {
+                       JcrUtils.logoutQuietly(currSession);
+               }
+       }
+
+       // DEPENDENCY INJECTION
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+
+       public void setNodeRepository(Repository repository) {
+               this.nodeRepository = repository;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java
new file mode 100644 (file)
index 0000000..24e43cb
--- /dev/null
@@ -0,0 +1,56 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.wizards.ChangeRightsWizard;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Open a dialog to manage rights on the current workspace's root node */
+public class ManageWorkspaceAuth extends AbstractHandler {
+       // private static final Log log =
+       // LogFactory.getLog(ManageWorkspaceAuth.class);
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".manageWorkspaceAuth";
+       public final static String DEFAULT_LABEL = "Manage Rights";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/changeRights.gif");
+
+       public final static String PARAM_WORKSPACE_NAME = DistPlugin.PLUGIN_ID
+                       + ".workspaceName";
+
+       /* DEPENDENCY INJECTION */
+       private Repository repository;
+       private Session session;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+               try {
+                       session = repository.login(workspaceName);
+                       ChangeRightsWizard wizard = new ChangeRightsWizard(session);
+                       WizardDialog dialog = new WizardDialog(
+                                       HandlerUtil.getActiveShell(event), wizard);
+                       dialog.open();
+                       return null;
+               } catch (RepositoryException re) {
+                       throw new SlcException("Cannot log in the repository "
+                                       + repository + " in workspace " + workspaceName, re);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/MergeWorkspaces.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/MergeWorkspaces.java
new file mode 100644 (file)
index 0000000..70c3d7a
--- /dev/null
@@ -0,0 +1,157 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Credentials;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.api.security.Keyring;
+import org.argeo.eclipse.ui.EclipseJcrMonitor;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+/** Merge two workspaces */
+public class MergeWorkspaces extends AbstractHandler {
+       private final static Log log = LogFactory.getLog(MergeWorkspaces.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".mergeWorkspaces";
+       public final static String DEFAULT_LABEL = "Merge";
+
+       public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
+       public final static String PARAM_SOURCE_REPO_PATH = "srcRepoPath";
+       public final static String PARAM_TARGET_WORKSPACE_NAME = "targetWkspName";
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+
+       // DEPENDENCY INJECTION
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       private Repository nodeRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
+               String targetWkspName = event.getParameter(PARAM_TARGET_WORKSPACE_NAME);
+               String sourceRepoPath = event.getParameter(PARAM_SOURCE_REPO_PATH);
+               String sourceWkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
+
+               Session nodeSession = null;
+               try {
+                       nodeSession = nodeRepository.login();
+                       Node srcRepoNode = nodeSession.getNode(sourceRepoPath);
+                       Repository srcRepository = RepoUtils.getRepository(repositoryFactory, keyring, srcRepoNode);
+                       Credentials srcCredentials = RepoUtils.getRepositoryCredentials(keyring, srcRepoNode);
+
+                       Node targetRepoNode = nodeSession.getNode(targetRepoPath);
+                       Repository targetRepository = RepoUtils.getRepository(repositoryFactory, keyring, targetRepoNode);
+                       Credentials targetCredentials = RepoUtils.getRepositoryCredentials(keyring, targetRepoNode);
+
+                       // String msg = "Are you sure you want to merge distribution ["
+                       // + sourceWkspName + "] in distribution [" + targetWkspName
+                       // + "] ?";
+                       //
+                       // boolean result = MessageDialog.openConfirm(
+                       // HandlerUtil.getActiveShell(event), "Confirm Merge", msg);
+
+                       // if (result) {
+                       // Open sessions here since the background thread
+                       // won't necessarily be authenticated.
+                       // Job should close the sessions.
+                       Session sourceSession = srcRepository.login(srcCredentials, sourceWkspName);
+                       Session targetSession;
+                       try {
+                               targetSession = targetRepository.login(targetCredentials, targetWkspName);
+                       } catch (NoSuchWorkspaceException e) {
+                               Session defaultSession = targetRepository.login(targetCredentials);
+                               try {
+                                       defaultSession.getWorkspace().createWorkspace(targetWkspName);
+                               } catch (Exception e1) {
+                                       throw new SlcException("Cannot create new workspace " + targetWkspName, e);
+                               } finally {
+                                       JcrUtils.logoutQuietly(defaultSession);
+                               }
+                               targetSession = targetRepository.login(targetCredentials, targetWkspName);
+                       }
+
+                       Job workspaceMergeJob = new WorkspaceMergeJob(sourceSession, targetSession);
+                       workspaceMergeJob.setUser(true);
+                       workspaceMergeJob.schedule();
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unexpected error while merging workspaces.", re);
+               } finally {
+                       JcrUtils.logoutQuietly(nodeSession);
+               }
+               return null;
+       }
+
+       private static class WorkspaceMergeJob extends Job {
+               private Session sourceSession;
+               private Session targetSession;
+
+               public WorkspaceMergeJob(Session sourceSession, Session targetSession) {
+                       super("Workspace merge");
+                       this.sourceSession = sourceSession;
+                       this.targetSession = targetSession;
+               }
+
+               @Override
+               protected IStatus run(IProgressMonitor eclipseMonitor) {
+                       long begin = System.currentTimeMillis();
+                       try {
+                               Query countQuery = sourceSession.getWorkspace().getQueryManager()
+                                               .createQuery("select file from [nt:file] as file", Query.JCR_SQL2);
+                               QueryResult result = countQuery.execute();
+                               Long expectedCount = result.getNodes().getSize();
+                               if (log.isDebugEnabled())
+                                       log.debug("Will copy " + expectedCount + " files...");
+
+                               JcrMonitor monitor = new EclipseJcrMonitor(eclipseMonitor);
+                               eclipseMonitor.beginTask("Copy files", expectedCount.intValue());
+
+                               Long count = JcrUtils.copyFiles(sourceSession.getRootNode(), targetSession.getRootNode(), true, monitor,
+                                               true);
+
+                               monitor.done();
+                               long duration = (System.currentTimeMillis() - begin) / 1000;// in
+                                                                                                                                                       // s
+                               if (log.isDebugEnabled())
+                                       log.debug("Copied " + count + " files in " + (duration / 60) + "min " + (duration % 60) + "s");
+
+                               return Status.OK_STATUS;
+                       } catch (RepositoryException e) {
+                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID, "Cannot merge", e);
+                       } finally {
+                               JcrUtils.logoutQuietly(sourceSession);
+                               JcrUtils.logoutQuietly(targetSession);
+                       }
+               }
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeDistribution.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeDistribution.java
new file mode 100644 (file)
index 0000000..e35b9bc
--- /dev/null
@@ -0,0 +1,374 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Binary;
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+import javax.jcr.util.TraversingItemVisitor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.api.security.Keyring;
+import org.argeo.eclipse.ui.EclipseJcrMonitor;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.repo.ArtifactIndexer;
+import org.argeo.slc.repo.JarFileIndexer;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.slc.repo.maven.AetherUtils;
+import org.argeo.slc.repo.maven.MavenConventionsUtils;
+import org.argeo.slc.repo.osgi.NormalizeGroup;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Legacy - Make sure than Maven and OSGi metadata are consistent */
+public class NormalizeDistribution extends AbstractHandler implements SlcNames {
+       private final static Log log = LogFactory
+                       .getLog(NormalizeDistribution.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".normalizeDistribution";
+       public final static String DEFAULT_LABEL = "Legacy Normalization...";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/normalize.gif");
+
+       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+
+       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
+
+       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
+       private JarFileIndexer jarFileIndexer = new JarFileIndexer();
+
+       // DEPENDENCY INJECTION
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       private Repository nodeRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
+               String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
+
+               Session nodeSession = null;
+               NormalizeJob job;
+               try {
+
+                       NormalizationDialog dialog = new NormalizationDialog(
+                                       HandlerUtil.getActiveShell(event));
+                       if (dialog.open() != Dialog.OK)
+                               return null;
+
+                       nodeSession = nodeRepository.login();
+                       Node repoNode = nodeSession.getNode(targetRepoPath);
+                       Repository repository = RepoUtils.getRepository(repositoryFactory,
+                                       keyring, repoNode);
+                       Credentials credentials = RepoUtils.getRepositoryCredentials(
+                                       keyring, repoNode);
+
+                       String version = dialog.getVersion();
+                       Boolean overridePoms = dialog.getOverridePoms();
+
+                       job = new NormalizeJob(repository.login(credentials, wkspName),
+                                       version, overridePoms);
+                       job.setUser(true);
+                       job.schedule();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot normalize " + wkspName, e);
+               } finally {
+                       JcrUtils.logoutQuietly(nodeSession);
+               }
+               return null;
+       }
+
+       protected void packageSourcesAsPdeSource(Node sourcesNode) {
+               Binary origBinary = null;
+               Binary osgiBinary = null;
+               try {
+                       Session session = sourcesNode.getSession();
+                       Artifact sourcesArtifact = AetherUtils.convertPathToArtifact(
+                                       sourcesNode.getPath(), null);
+
+                       // read name version from manifest
+                       Artifact osgiArtifact = new DefaultArtifact(
+                                       sourcesArtifact.getGroupId(),
+                                       sourcesArtifact.getArtifactId(),
+                                       sourcesArtifact.getExtension(),
+                                       sourcesArtifact.getVersion());
+                       String osgiPath = MavenConventionsUtils.artifactPath(
+                                       artifactBasePath, osgiArtifact);
+                       osgiBinary = session.getNode(osgiPath).getNode(Node.JCR_CONTENT)
+                                       .getProperty(Property.JCR_DATA).getBinary();
+
+                       NameVersion nameVersion = RepoUtils.readNameVersion(osgiBinary
+                                       .getStream());
+
+                       // create PDe sources artifact
+                       Artifact pdeSourceArtifact = new DefaultArtifact(
+                                       sourcesArtifact.getGroupId(),
+                                       sourcesArtifact.getArtifactId() + ".source",
+                                       sourcesArtifact.getExtension(),
+                                       sourcesArtifact.getVersion());
+                       String targetSourceParentPath = MavenConventionsUtils
+                                       .artifactParentPath(artifactBasePath, pdeSourceArtifact);
+                       String targetSourceFileName = MavenConventionsUtils
+                                       .artifactFileName(pdeSourceArtifact);
+                       String targetSourceJarPath = targetSourceParentPath + '/'
+                                       + targetSourceFileName;
+
+                       Node targetSourceParentNode = JcrUtils.mkfolders(session,
+                                       targetSourceParentPath);
+                       origBinary = sourcesNode.getNode(Node.JCR_CONTENT)
+                                       .getProperty(Property.JCR_DATA).getBinary();
+                       byte[] targetJarBytes = RepoUtils.packageAsPdeSource(
+                                       origBinary.getStream(), nameVersion);
+                       JcrUtils.copyBytesAsFile(targetSourceParentNode,
+                                       targetSourceFileName, targetJarBytes);
+
+                       // reindex
+                       Node targetSourceJarNode = session.getNode(targetSourceJarPath);
+                       artifactIndexer.index(targetSourceJarNode);
+                       jarFileIndexer.index(targetSourceJarNode);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot add PDE sources for " + sourcesNode,
+                                       e);
+               } finally {
+                       JcrUtils.closeQuietly(origBinary);
+                       JcrUtils.closeQuietly(osgiBinary);
+               }
+
+       }
+
+       private class NormalizeJob extends Job {
+               private Session session;
+               private String version;
+               private Boolean overridePoms;
+
+               public NormalizeJob(Session session, String version,
+                               Boolean overridePoms) {
+                       super("Normalize Distribution");
+                       this.session = session;
+                       this.version = version;
+                       this.overridePoms = overridePoms;
+               }
+
+               @Override
+               protected IStatus run(IProgressMonitor progressMonitor) {
+
+                       try {
+                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
+                               // normalize artifacts
+                               Query countQuery = session
+                                               .getWorkspace()
+                                               .getQueryManager()
+                                               .createQuery("select file from [nt:file] as file",
+                                                               Query.JCR_SQL2);
+                               QueryResult result = countQuery.execute();
+                               Long expectedCount = result.getNodes().getSize();
+                               monitor.beginTask("Normalize artifacts of "
+                                               + session.getWorkspace().getName(),
+                                               expectedCount.intValue());
+                               NormalizingTraverser tiv = new NormalizingTraverser(monitor);
+                               session.getNode(artifactBasePath).accept(tiv);
+
+                               // normalize groups
+                               Query groupQuery = session
+                                               .getWorkspace()
+                                               .getQueryManager()
+                                               .createQuery(
+                                                               "select group from [" + SlcTypes.SLC_GROUP_BASE
+                                                                               + "] as group", Query.JCR_SQL2);
+                               NodeIterator groups = groupQuery.execute().getNodes();
+                               monitor.beginTask("Normalize groups of "
+                                               + session.getWorkspace().getName(),
+                                               (int) groups.getSize());
+                               while (groups.hasNext()) {
+                                       NormalizeGroup.processGroupNode(groups.nextNode(), version,
+                                                       overridePoms, monitor);
+                               }
+                       } catch (Exception e) {
+                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
+                                               "Cannot normalize distribution "
+                                                               + session.getWorkspace().getName(), e);
+                       } finally {
+                               JcrUtils.logoutQuietly(session);
+                       }
+                       return Status.OK_STATUS;
+               }
+
+       }
+
+       private class NormalizingTraverser extends TraversingItemVisitor {
+               JcrMonitor monitor;
+
+               public NormalizingTraverser(JcrMonitor monitor) {
+                       super();
+                       this.monitor = monitor;
+               }
+
+               @Override
+               protected void entering(Property property, int level)
+                               throws RepositoryException {
+               }
+
+               @Override
+               protected void entering(Node node, int level)
+                               throws RepositoryException {
+                       if (node.isNodeType(NodeType.NT_FILE)) {
+                               if (node.getName().endsWith("-sources.jar")) {
+                                       monitor.subTask(node.getName());
+                                       packageSourcesAsPdeSource(node);
+                                       node.getSession().save();
+                                       monitor.worked(1);
+                                       if (log.isDebugEnabled())
+                                               log.debug("Processed source artifact " + node.getPath());
+                               } else if (node.getName().endsWith(".jar")) {
+                                       if (jarFileIndexer.support(node.getPath()))
+                                               if (artifactIndexer.support(node.getPath())) {
+                                                       monitor.subTask(node.getName());
+                                                       artifactIndexer.index(node);
+                                                       jarFileIndexer.index(node);
+                                                       node.getSession().save();
+                                                       monitor.worked(1);
+                                                       if (log.isDebugEnabled())
+                                                               log.debug("Processed artifact "
+                                                                               + node.getPath());
+                                               }
+                               } else {
+                                       monitor.worked(1);
+                               }
+                       }
+               }
+
+               @Override
+               protected void leaving(Property property, int level)
+                               throws RepositoryException {
+               }
+
+               @Override
+               protected void leaving(Node node, int level) throws RepositoryException {
+               }
+
+       }
+
+       public class NormalizationDialog extends TitleAreaDialog {
+               private static final long serialVersionUID = -3103886455862638580L;
+
+               private Text versionT;
+               private String version;
+               private Button overridePomsC;
+               private Boolean overridePoms;
+
+               public NormalizationDialog(Shell parentShell) {
+                       super(parentShell);
+               }
+
+               protected Point getInitialSize() {
+                       return new Point(300, 250);
+               }
+
+               protected Control createDialogArea(Composite parent) {
+                       Composite dialogarea = (Composite) super.createDialogArea(parent);
+                       dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+                                       true));
+                       Composite composite = new Composite(dialogarea, SWT.NONE);
+                       composite.setLayout(new GridLayout(2, false));
+                       composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+                                       false));
+                       versionT = createLT(composite, "Version");
+                       overridePomsC = createLC(composite, "Override POMs");
+                       setMessage("Configure normalization", IMessageProvider.NONE);
+
+                       parent.pack();
+                       return composite;
+               }
+
+               @Override
+               protected void okPressed() {
+                       version = versionT.getText();
+                       overridePoms = overridePomsC.getSelection();
+                       super.okPressed();
+               }
+
+               /** Creates label and text. */
+               protected Text createLT(Composite parent, String label) {
+                       new Label(parent, SWT.NONE).setText(label);
+                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER
+                                       | SWT.NONE);
+                       text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       return text;
+               }
+
+               /** Creates label and check. */
+               protected Button createLC(Composite parent, String label) {
+                       new Label(parent, SWT.NONE).setText(label);
+                       Button check = new Button(parent, SWT.CHECK);
+                       check.setSelection(false);
+                       check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       return check;
+               }
+
+               protected void configureShell(Shell shell) {
+                       super.configureShell(shell);
+                       shell.setText("Normalize...");
+               }
+
+               public String getVersion() {
+                       return version;
+               }
+
+               public Boolean getOverridePoms() {
+                       return overridePoms;
+               }
+
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java
new file mode 100644 (file)
index 0000000..e5ed4d4
--- /dev/null
@@ -0,0 +1,217 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+import javax.jcr.util.TraversingItemVisitor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.api.security.Keyring;
+import org.argeo.eclipse.ui.EclipseJcrMonitor;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.repo.ArtifactIndexer;
+import org.argeo.slc.repo.JarFileIndexer;
+import org.argeo.slc.repo.ModularDistributionIndexer;
+import org.argeo.slc.repo.PdeSourcesIndexer;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * Force the indexing of a given workspace by making sure than Maven and OSGi
+ * metadata are consistent. This mechanism normally relies on JCR Listeners but
+ * must sometimes be triggered manually
+ */
+public class NormalizeWorkspace extends AbstractHandler implements SlcNames {
+       private final static Log log = LogFactory.getLog(NormalizeWorkspace.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".normalizeWorkspace";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin.getImageDescriptor("icons/normalize.gif");
+
+       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+
+       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
+
+       // DEPENDENCY INJECTION
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       private Repository repository;
+
+       // Relevant default node indexers
+       private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer();
+       // WARNING Order is important: must be called in the following order.
+       private ModularDistributionIndexer modularDistributionIndexer = new ModularDistributionIndexer();
+       private JarFileIndexer jarFileIndexer = new JarFileIndexer();
+       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
+               String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
+
+               Session currSession = null;
+               NormalizeJob job;
+               try {
+                       String msg = "Your are about to normalize workspace: " + wkspName
+                                       + ".\nThis will index OSGi bundles and Maven artifacts, "
+                                       + "it will also convert Maven sources to PDE Sources if needed.\n"
+                                       + "Note that no information will be overwritten: " + "all existing information are kept."
+                                       + "\n\n Do you really want to proceed ?";
+
+                       if (!MessageDialog.openConfirm(DistPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(),
+                                       "Confirm workspace normalization", msg))
+                               return null;
+
+                       currSession = repository.login();
+                       Node repoNode = currSession.getNode(targetRepoPath);
+                       Repository repository = RepoUtils.getRepository(repositoryFactory, keyring, repoNode);
+                       Credentials credentials = RepoUtils.getRepositoryCredentials(keyring, repoNode);
+
+                       job = new NormalizeJob(repository.login(credentials, wkspName));
+                       job.setUser(true);
+                       job.schedule();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot normalize " + wkspName, e);
+               } finally {
+                       JcrUtils.logoutQuietly(currSession);
+               }
+               return null;
+       }
+
+       private class NormalizeJob extends Job {
+               private Session session;
+
+               public NormalizeJob(Session session) {
+                       super("Normalize Distribution");
+                       this.session = session;
+               }
+
+               @Override
+               protected IStatus run(IProgressMonitor progressMonitor) {
+                       try {
+                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
+                               // Normalize artifacts
+                               Query countQuery = session.getWorkspace().getQueryManager()
+                                               .createQuery("select file from [nt:file] as file", Query.JCR_SQL2);
+                               QueryResult result = countQuery.execute();
+                               Long expectedCount = result.getNodes().getSize();
+                               monitor.beginTask("Normalize artifacts of " + session.getWorkspace().getName(),
+                                               expectedCount.intValue());
+                               NormalizingTraverser tiv = new NormalizingTraverser(monitor);
+                               Node artifactBaseNode = session.getNode(artifactBasePath);
+                               artifactBaseNode.accept(tiv);
+                       } catch (Exception e) {
+                               log.error("Error normalizing workspace " + session.getWorkspace().getName() + ": " + e.getMessage());
+                               if (log.isErrorEnabled())
+                                       e.printStackTrace();
+                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
+                                               "Cannot normalize distribution " + session.getWorkspace().getName(), e);
+                       } finally {
+                               JcrUtils.logoutQuietly(session);
+                       }
+                       return Status.OK_STATUS;
+               }
+       }
+
+       private class NormalizingTraverser extends TraversingItemVisitor {
+               JcrMonitor monitor;
+
+               public NormalizingTraverser(JcrMonitor monitor) {
+                       super();
+                       this.monitor = monitor;
+               }
+
+               @Override
+               protected void entering(Property property, int level) throws RepositoryException {
+               }
+
+               @Override
+               protected void entering(Node node, int level) throws RepositoryException {
+                       if (node.getPath().startsWith(RepoConstants.DIST_DOWNLOAD_BASEPATH))
+                               return;
+
+                       if (node.isNodeType(NodeType.NT_FILE)) {
+                               if (node.getName().endsWith("-sources.jar")) {
+                                       monitor.subTask(node.getName());
+                                       pdeSourceIndexer.index(node);
+                                       node.getSession().save();
+                                       monitor.worked(1);
+                                       if (log.isDebugEnabled())
+                                               log.debug("Processed source artifact " + node.getPath());
+                               } else if (node.getName().endsWith("-javadoc.jar")) {
+                                       if (log.isDebugEnabled())
+                                               log.debug("Skip indexing of Javadoc jar " + node.getPath());
+                               } else if (node.getName().endsWith(".jar")) {
+                                       if (jarFileIndexer.support(node.getPath()))
+                                               if (artifactIndexer.support(node.getPath())) {
+                                                       monitor.subTask(node.getName());
+                                                       modularDistributionIndexer.index(node);
+                                                       jarFileIndexer.index(node);
+                                                       artifactIndexer.index(node);
+                                                       if (node.getSession().hasPendingChanges()) {
+                                                               node.getSession().save();
+                                                               if (log.isDebugEnabled())
+                                                                       log.debug("Processed jar artifact " + node.getPath());
+                                                       }
+                                                       monitor.worked(1);
+                                               }
+                               } else if (node.getName().endsWith(".pom")) {
+                                       // Removed: we do not support binaries concept anymore.
+                                       // if (distBundleIndexer.support(node.getPath()))
+                                       // distBundleIndexer.index(node);
+                                       if (artifactIndexer.support(node.getPath()))
+                                               artifactIndexer.index(node);
+                                       if (node.getSession().hasPendingChanges()) {
+                                               node.getSession().save();
+                                               if (log.isDebugEnabled())
+                                                       log.debug("Processed pom artifact " + node.getPath());
+                                       }
+                                       monitor.worked(1);
+                               } else {
+                                       monitor.worked(1);
+                               }
+                       }
+               }
+
+               @Override
+               protected void leaving(Property property, int level) throws RepositoryException {
+               }
+
+               @Override
+               protected void leaving(Node node, int level) throws RepositoryException {
+               }
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.repository = nodeRepository;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenGenerateBinariesWizard.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenGenerateBinariesWizard.java
new file mode 100644 (file)
index 0000000..c1b6c12
--- /dev/null
@@ -0,0 +1,59 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.client.ui.dist.wizards.GenerateBinariesWizard;
+import org.argeo.slc.repo.RepoService;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Open a {@code GenerateBinariesWizard} wizard for the selected node */
+public class OpenGenerateBinariesWizard extends AbstractHandler {
+       // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".openGenerateBinariesWizard";
+       public final static String DEFAULT_LABEL = "Generate Aether Index";
+       public final static ImageDescriptor DEFAULT_ICON = null;
+
+       /* DEPENDENCY INJECTION */
+       private RepoService repoService;
+
+       // Absolute Coordinates of the current group node
+       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
+       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
+       public final static String PARAM_MODULE_PATH = "param.modulePath";
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
+                               .getActiveWorkbenchWindow().getActivePage().getActivePart();
+
+               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
+               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+               String modulePath = event.getParameter(PARAM_MODULE_PATH);
+
+               GenerateBinariesWizard wizard = new GenerateBinariesWizard(repoService,
+                               repoNodePath, workspaceName, modulePath);
+
+               WizardDialog dialog = new WizardDialog(
+                               HandlerUtil.getActiveShell(event), wizard);
+               int result = dialog.open();
+
+               if (result == Dialog.OK
+                               && (activePart instanceof RefreshDistributionsView))
+                       CommandHelpers.callCommand(RefreshDistributionsView.ID);
+
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenModuleEditor.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenModuleEditor.java
new file mode 100644 (file)
index 0000000..bf07e49
--- /dev/null
@@ -0,0 +1,83 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor;
+import org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor;
+import org.argeo.slc.client.ui.dist.editors.ModuleEditorInput;
+import org.argeo.slc.repo.RepoService;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Open the relevant editor for a given module node of a given repository
+ * workspace. For the time being, modules can be artifacts or
+ * modularDistributions
+ */
+public class OpenModuleEditor extends AbstractHandler {
+       public final static String ID = DistPlugin.PLUGIN_ID + ".openModuleEditor";
+       public final static String DEFAULT_LABEL = "Open relevant editor";
+
+       // use local node repo and repository factory to retrieve and log to
+       // relevant repository
+       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
+       // use URI and repository factory to retrieve and ANONYMOUSLY log in
+       // relevant repository
+       public final static String PARAM_REPO_URI = "param.repoUri";
+       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
+       public final static String PARAM_MODULE_PATH = "param.modulePath";
+
+       /* DEPENDENCY INJECTION */
+       private RepoService repoService;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
+               String repoUri = event.getParameter(PARAM_REPO_URI);
+               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+               String modulePath = event.getParameter(PARAM_MODULE_PATH);
+
+               Session businessSession = null;
+               try {
+                       businessSession = repoService.getRemoteSession(repoNodePath,
+                                       repoUri, workspaceName);
+
+                       Node module = businessSession.getNode(modulePath);
+                       ModuleEditorInput mei = new ModuleEditorInput(repoNodePath,
+                                       repoUri, workspaceName, modulePath);
+
+                       // Choose correct editor based on its mixin
+                       if (module.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION))
+                               HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
+                                               .openEditor(mei, ModularDistVersionEditor.ID);
+                       else
+                               HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
+                                               .openEditor(mei, ArtifactVersionEditor.ID);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unexpected error while "
+                                       + "getting repoNode info for repoNode at path "
+                                       + repoNodePath, e);
+               } catch (PartInitException e) {
+                       throw new SlcException("Unexpected error while "
+                                       + "opening editor for workspace " + workspaceName
+                                       + " with URI " + repoUri + " and repoNode at path "
+                                       + repoNodePath, e);
+               } finally {
+                       JcrUtils.logoutQuietly(businessSession);
+               }
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenWorkspaceEditor.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/OpenWorkspaceEditor.java
new file mode 100644 (file)
index 0000000..cf25b83
--- /dev/null
@@ -0,0 +1,82 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.cms.ArgeoNames;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.editors.DistWkspEditorInput;
+import org.argeo.slc.client.ui.dist.editors.DistWorkspaceEditor;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Open a distribution workspace editor for a given workspace in a repository
+ */
+public class OpenWorkspaceEditor extends AbstractHandler {
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".openWorkspaceEditor";
+       public final static String DEFAULT_LABEL = "Open editor";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/distribution_perspective.gif");
+
+       // Use local node repo and repository factory to retrieve and log to
+       // relevant repository
+       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
+       // Use URI and repository factory to retrieve and ANONYMOUSLY log in
+       // relevant repository
+       public final static String PARAM_REPO_URI = "param.repoUri";
+       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
+
+       /* DEPENDENCY INJECTION */
+       private Repository localRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
+               String repoUri = event.getParameter(PARAM_REPO_URI);
+               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+
+               Session defaultSession = null;
+               if (repoNodePath != null && repoUri == null) {
+                       try {
+                               defaultSession = localRepository.login();
+                               if (defaultSession.nodeExists(repoNodePath)) {
+                                       Node repoNode = defaultSession.getNode(repoNodePath);
+                                       repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
+                                                       .getString();
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Unexpected error while "
+                                               + "getting repoNode at path " + repoNodePath, e);
+                       } finally {
+                               JcrUtils.logoutQuietly(defaultSession);
+                       }
+               }
+
+               DistWkspEditorInput wei = new DistWkspEditorInput(repoNodePath,
+                               repoUri, workspaceName);
+               try {
+                       HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
+                                       .openEditor(wei, DistWorkspaceEditor.ID);
+               } catch (PartInitException e) {
+                       throw new SlcException("Unexpected error while "
+                                       + "opening editor for workspace " + workspaceName
+                                       + " with URI " + repoUri + " and repoNode at path "
+                                       + repoNodePath, e);
+               }
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setLocalRepository(Repository localRepository) {
+               this.localRepository = localRepository;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/PublishWorkspace.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/PublishWorkspace.java
new file mode 100644 (file)
index 0000000..9c868cd
--- /dev/null
@@ -0,0 +1,94 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.security.Privilege;
+
+import org.argeo.api.security.Keyring;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/** Publish the current workspace by giving READ_ONLY rights to anonymous */
+public class PublishWorkspace extends AbstractHandler {
+       // private static final Log log = LogFactory.getLog(PublishWorkspace.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".publishWorkspace";
+       public final static String DEFAULT_LABEL = "Make Public";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/publish.gif");
+
+       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+
+       // DEPENDENCY INJECTION
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       private Repository nodeRepository;
+
+       private String publicRole = SlcConstants.USER_ANONYMOUS;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
+               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+
+               Session nodeSession = null;
+               Session session = null;
+
+               try {
+                       nodeSession = nodeRepository.login();
+                       Node repoNode = nodeSession.getNode(targetRepoPath);
+                       Repository repository = RepoUtils.getRepository(repositoryFactory,
+                                       keyring, repoNode);
+                       Credentials credentials = RepoUtils.getRepositoryCredentials(
+                                       keyring, repoNode);
+
+                       String msg = "Are you sure you want to publish this distribution: "
+                                       + workspaceName + " ?";
+                       boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
+                                       .getWorkbench().getDisplay().getActiveShell(),
+                                       "Confirm publication", msg);
+
+                       if (result) {
+                               session = repository.login(credentials, workspaceName);
+                               JcrUtils.addPrivilege(session, "/", publicRole,
+                                               Privilege.JCR_READ);
+                               session.save();
+                               JcrUtils.logoutQuietly(session);
+                               // CommandHelpers.callCommand(RefreshDistributionsView.ID);
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while publishing workspace "
+                                                       + workspaceName, re);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+                       JcrUtils.logoutQuietly(nodeSession);
+               }
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshArtifactBrowser.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshArtifactBrowser.java
new file mode 100644 (file)
index 0000000..f9d9f18
--- /dev/null
@@ -0,0 +1,19 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import org.argeo.slc.client.ui.dist.views.ArtifactsBrowser;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Force the refresh of the artifact browser view */
+public class RefreshArtifactBrowser extends AbstractHandler {
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               ArtifactsBrowser view = (ArtifactsBrowser) HandlerUtil
+                               .getActiveWorkbenchWindow(event).getActivePage()
+                               .findView(ArtifactsBrowser.ID);
+               view.refresh(null);
+               return null;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshDistributionsView.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RefreshDistributionsView.java
new file mode 100644 (file)
index 0000000..e03ab48
--- /dev/null
@@ -0,0 +1,29 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.views.AnonymousDistributionsView;
+import org.argeo.slc.client.ui.dist.views.DistributionsView;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IWorkbenchPart;
+
+/** Force refresh of the Distributions View */
+public class RefreshDistributionsView extends AbstractHandler {
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".refreshDistributionsView";
+       public final static String DEFAULT_LABEL = "Refresh the distribution view";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/refresh.png");
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
+                               .getActiveWorkbenchWindow().getActivePage().getActivePart();
+               if (activePart instanceof DistributionsView)
+                       ((DistributionsView) activePart).refresh();
+               else if (activePart instanceof AnonymousDistributionsView)
+                       ((AnonymousDistributionsView) activePart).refresh();
+               return null;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RegisterRepository.java
new file mode 100644 (file)
index 0000000..f09fd17
--- /dev/null
@@ -0,0 +1,57 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryFactory;
+
+import org.argeo.api.security.Keyring;
+import org.argeo.cms.ArgeoNames;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.client.ui.dist.wizards.RegisterRepoWizard;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Register a remote repository by creating a node in the current local node. */
+public class RegisterRepository extends AbstractHandler implements ArgeoNames,
+               SlcNames {
+
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".registerRepository";
+       public final static String DEFAULT_LABEL = "Register a repository...";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/addRepo.gif");
+
+       /* DEPENDENCY INJECTION */
+       private RepositoryFactory repositoryFactory;
+       private Repository nodeRepository;
+       private Keyring keyring;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               RegisterRepoWizard wizard = new RegisterRepoWizard(keyring,
+                               repositoryFactory, nodeRepository);
+               WizardDialog dialog = new WizardDialog(
+                               HandlerUtil.getActiveShell(event), wizard);
+               int result = dialog.open();
+               if (result == Dialog.OK)
+                       CommandHelpers.callCommand(RefreshDistributionsView.ID);
+               return null;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RunInOsgi.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/RunInOsgi.java
new file mode 100644 (file)
index 0000000..fc336f6
--- /dev/null
@@ -0,0 +1,285 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.net.URL;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.core.execution.tasks.JvmProcess;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.slc.repo.maven.MavenConventionsUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/** <b>UNDER DEVELOPMENT</b>. Download and prepare an OSGi runtime */
+public class RunInOsgi extends AbstractHandler implements SlcNames {
+       private final static Log log = LogFactory.getLog(RunInOsgi.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".runInOsgi";
+       public final static String DEFAULT_LABEL = "Run in OSGi";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/runInOsgi.gif");
+
+       public final static String PARAM_WORKSPACE_NAME = "workspaceName";
+       public final static String PARAM_MODULE_PATH = "modulePath";
+
+       /* DEPENDENCY INJECTION */
+       private Repository repository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               String workspace = event.getParameter(PARAM_WORKSPACE_NAME);
+               String modulePath = event.getParameter(PARAM_MODULE_PATH);
+               String port = System.getProperty("argeo.server.port.http");
+               // String localMavenBase = System.getProperty("user.home")
+               // + "/.m2/repository";
+
+               InputStream jarStream = null;
+               OutputStream out = null;
+               Writer writer = null;
+               Session session = null;
+               try {
+                       // Bundle distPluginBundle = DistPlugin.getDefault().getBundle();
+                       // File baseDir = distPluginBundle.getBundleContext().getDataFile(
+                       // "runInOSGi");
+                       File baseDir = new File(System.getProperty("java.io.tmpdir")
+                                       + "/runInOSGi-" + System.getProperty("user.name"));
+                       if (baseDir.exists())
+                               FileUtils.deleteDirectory(baseDir);
+                       File libDir = new File(baseDir, "lib");
+                       libDir.mkdirs();
+                       File confDir = new File(baseDir, "configuration");
+                       confDir.mkdirs();
+                       File dataDir = new File(baseDir, "data");
+                       dataDir.mkdirs();
+
+                       session = repository.login(workspace);
+
+                       // NodeIterator bundles = listBundleArtifacts(session);
+                       // if (log.isDebugEnabled())
+                       // log.debug("## Copying to " + libDir);
+                       //
+                       // File equinoxJar = null;
+                       // List<File> files = new ArrayList<File>();
+                       // bundles: while (bundles.hasNext()) {
+                       // Node bundleNode = bundles.nextNode();
+                       // String symbolicName = JcrUtils.get(bundleNode,
+                       // SLC_SYMBOLIC_NAME);
+                       //
+                       // // skip sources
+                       // if (symbolicName.endsWith(".source"))
+                       // continue bundles;
+                       // // skip eclipse
+                       // if (symbolicName.startsWith("org.eclipse")
+                       // && !symbolicName.equals("org.eclipse.osgi"))
+                       // continue bundles;
+                       // if (symbolicName.equals("org.polymap.openlayers.rap.widget"))
+                       // continue bundles;
+                       //
+                       // File targetFile = new File(libDir, bundleNode.getName());
+                       // out = new FileOutputStream(targetFile);
+                       // jarStream = bundleNode.getNode(Node.JCR_CONTENT)
+                       // .getProperty(Property.JCR_DATA).getBinary().getStream();
+                       // IOUtils.copy(jarStream, out);
+                       // if (symbolicName.equals("org.eclipse.osgi"))
+                       // equinoxJar = targetFile;
+                       // else
+                       // files.add(targetFile);
+                       // if (log.isDebugEnabled())
+                       // log.debug("Copied " + targetFile.getName());
+                       //
+                       // IOUtils.closeQuietly(out);
+                       // IOUtils.closeQuietly(jarStream);
+                       // }
+                       //
+                       // StringBuffer osgiBundles = new StringBuffer("osgi.bundles=");
+                       // for (int i = 0; i < files.size(); i++) {
+                       // if (i != 0)
+                       // osgiBundles.append(',');
+                       // osgiBundles.append(files.get(i).getName());
+                       // }
+
+                       String equinoxJar = null;
+
+                       Node distModule = session.getNode(modulePath);
+                       NodeIterator coordinates = distModule.getNode(SLC_MODULES)
+                                       .getNodes();
+                       StringBuilder conf = new StringBuilder(1024 * 1024);
+                       conf.append("osgi.clean=true\n");
+                       conf.append("osgi.console=7777\n");
+                       // conf.append("osgi.console.enable.builtin=true\n");
+
+                       conf.append("osgi.bundles=");
+                       coords: while (coordinates.hasNext()) {
+                               Node coord = coordinates.nextNode();
+                               // String category =
+                               // coord.getProperty(SLC_CATEGORY).getString();
+                               String name = coord.getProperty(SLC_NAME).getString();
+                               String version = coord.getProperty(SLC_VERSION).getString();
+                               Artifact artifact = RepoUtils.asArtifact(coord);
+                               String path = MavenConventionsUtils.artifactPath("", artifact);
+                               String url = "http://localhost:" + port + "/data/public/java/"
+                                               + workspace + path;
+                               if (log.isDebugEnabled())
+                                       log.debug(url);
+                               File f = new File(libDir, name + "-" + version + ".jar");
+                               FileUtils.copyURLToFile(new URL(url), f);
+                               if (name.equals("org.eclipse.osgi")) {
+                                       // File f = new File(localMavenBase + path);
+                                       // if (!f.exists())
+                                       // FileUtils.copyURLToFile(new URL(url), f);
+                                       equinoxJar = f.getCanonicalPath();
+                                       continue coords;
+                               }
+                               conf.append(f.getName());
+                               if (coordinates.hasNext())
+                                       conf.append(",\\\n");
+                       }
+
+                       File confIni = new File(confDir, "config.ini");
+                       writer = new FileWriter(confIni);
+                       writer.write(conf.toString());
+                       IOUtils.closeQuietly(writer);
+
+                       // Map<String, String> configuration = new HashMap<String,
+                       // String>();
+                       // configuration.put("osgi.configuration.area",
+                       // confDir.getCanonicalPath());
+                       // configuration.put("osgi.instance.area",
+                       // dataDir.getCanonicalPath());
+                       // // Do clean
+                       // configuration.put("osgi.clean", "true");
+
+                       JvmProcess osgiRuntime = new JvmProcess();
+                       osgiRuntime.setExecDir(baseDir.getCanonicalPath());
+                       if (equinoxJar == null)
+                               throw new SlcException("Cannot find OSGi runtime.");
+                       osgiRuntime.setMainJar(equinoxJar);
+                       osgiRuntime.arg("-configuration", confDir.getCanonicalPath()).arg(
+                                       "-data", dataDir.getCanonicalPath());
+                       // .arg("-console", "7777").arg("-clean");
+                       osgiRuntime.setLogCommand(true);
+                       osgiRuntime.afterPropertiesSet();
+                       Job job = new RunInOsgiJob(osgiRuntime);
+                       job.schedule();
+                       // osgiRuntime.run();
+
+                       // Map<String, String> configuration = new HashMap<String,
+                       // String>();
+                       // configuration.put("osgi.configuration.area",
+                       // confDir.getCanonicalPath());
+                       // configuration.put("osgi.instance.area",
+                       // dataDir.getCanonicalPath());
+                       // // Do clean
+                       // configuration.put("osgi.clean", "true");
+                       // ServiceLoader<FrameworkFactory> ff = ServiceLoader
+                       // .load(FrameworkFactory.class);
+                       // FrameworkFactory frameworkFactory = ff.iterator().next();
+                       // Framework framework =
+                       // frameworkFactory.newFramework(configuration);
+                       // framework.start();
+                       // BundleContext testBundleContext = framework.getBundleContext();
+
+                       // for (int i = 0; i < files.size(); i++) {
+                       // testBundleContext.installBundle("file://"
+                       // + files.get(i).getCanonicalPath());
+                       // }
+                       //
+                       // Bundle[] testBundles = testBundleContext.getBundles();
+                       // for (Bundle bundle : testBundles) {
+                       // if (log.isDebugEnabled())
+                       // log.debug(bundle.getSymbolicName() + " "
+                       // + bundle.getVersion());
+                       // }
+
+               } catch (Exception e) {
+                       ErrorFeedback.show("Cannot run in OSGi", e);
+               } finally {
+                       IOUtils.closeQuietly(jarStream);
+                       IOUtils.closeQuietly(out);
+                       IOUtils.closeQuietly(writer);
+                       JcrUtils.logoutQuietly(session);
+               }
+
+               return null;
+       }
+
+       // private NodeIterator listBundleArtifacts(Session session)
+       // throws RepositoryException {
+
+       // QueryManager queryManager = session.getWorkspace().getQueryManager();
+       // QueryObjectModelFactory factory = queryManager.getQOMFactory();
+       //
+       // final String bundleArtifactsSelector = "bundleArtifacts";
+       // Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
+       // bundleArtifactsSelector);
+       //
+       // Ordering order = factory.ascending(factory.propertyValue(
+       // bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
+       // Ordering[] orderings = { order };
+       //
+       // QueryObjectModel query = factory.createQuery(source, null, orderings,
+       // null);
+       //
+       // QueryResult result = query.execute();
+       // return result.getNodes();
+       // }
+
+       private class RunInOsgiJob extends Job {
+               final JvmProcess osgiRuntime;
+
+               public RunInOsgiJob(JvmProcess osgiRuntime) {
+                       super("OSGi Test");
+                       this.osgiRuntime = osgiRuntime;
+               }
+
+               @Override
+               protected IStatus run(IProgressMonitor monitor) {
+                       osgiRuntime.setSynchronous(false);
+                       osgiRuntime.run();
+                       while (!monitor.isCanceled()) {
+                               try {
+                                       Thread.sleep(500);
+                               } catch (InterruptedException e) {
+                                       // silent
+                               }
+
+                               if (monitor.isCanceled()) {
+                                       osgiRuntime.kill();
+                                       return Status.CANCEL_STATUS;
+                               }
+                               if (!osgiRuntime.isRunning())
+                                       break;
+                       }
+                       return Status.OK_STATUS;
+               }
+
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ShowSizeColumn.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/ShowSizeColumn.java
new file mode 100644 (file)
index 0000000..3486dbf
--- /dev/null
@@ -0,0 +1,33 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.views.ArtifactsBrowser;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.State;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Change visible state of the ArtifactBrower size column */
+public class ShowSizeColumn extends AbstractHandler {
+       public final static String ID = DistPlugin.PLUGIN_ID + ".showSizeColumn";
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               ArtifactsBrowser view = (ArtifactsBrowser) HandlerUtil
+                               .getActiveWorkbenchWindow(event).getActivePage()
+                               .findView(ArtifactsBrowser.ID);
+
+               ICommandService service = (ICommandService) PlatformUI.getWorkbench()
+                               .getService(ICommandService.class);
+               Command command = service.getCommand(ID);
+               State state = command.getState(ID + ".toggleState");
+
+               boolean wasVisible = (Boolean) state.getValue();
+               view.setSizeVisible(!wasVisible);
+               state.setValue(!wasVisible);
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/UnregisterRemoteRepo.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/UnregisterRemoteRepo.java
new file mode 100644 (file)
index 0000000..8ff0e4a
--- /dev/null
@@ -0,0 +1,74 @@
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.api.NodeConstants;
+import org.argeo.cms.ArgeoTypes;
+import org.argeo.cms.ui.workbench.util.CommandUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * Un-register a remote repository by deleting the corresponding RepoNode from
+ * the node Repository. It does not affect the repository instance
+ */
+public class UnregisterRemoteRepo extends AbstractHandler {
+       // private static final Log log = LogFactory
+       // .getLog(UnregisterRemoteRepo.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".unregisterRemoteRepo";
+       public final static String DEFAULT_LABEL = "Unregister";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin.getImageDescriptor("icons/removeItem.gif");
+
+       public final static String PARAM_REPO_PATH = DistPlugin.PLUGIN_ID + ".repoNodePath";
+
+       // DEPENCY INJECTION
+       private Repository nodeRepository;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               Session session = null;
+               String repoPath = event.getParameter(PARAM_REPO_PATH);
+               if (repoPath == null)
+                       return null;
+
+               try {
+                       session = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
+                       Node rNode = session.getNode(repoPath);
+                       if (rNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
+
+                               String alias = rNode.getProperty(Property.JCR_TITLE).getString();
+                               String msg = "Your are about to unregister remote repository: " + alias + "\n"
+                                               + "Are you sure you want to proceed ?";
+
+                               boolean result = MessageDialog.openConfirm(
+                                               DistPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(), "Confirm Delete", msg);
+
+                               if (result) {
+                                       rNode.remove();
+                                       session.save();
+                               }
+                               CommandUtils.callCommand(RefreshDistributionsView.ID);
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unexpected error while unregistering remote repository.", e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+               return null;
+       }
+
+       // DEPENCY INJECTION
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/package.html b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/package.html
new file mode 100644 (file)
index 0000000..fa91751
--- /dev/null
@@ -0,0 +1,6 @@
+<html>
+<head></head>
+<body>
+Eclipse commands wrapping Runnable objects define in non-ui specific code.
+</body>
+</html>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/AnonymousDistTreeContentProvider.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/AnonymousDistTreeContentProvider.java
new file mode 100644 (file)
index 0000000..465faf4
--- /dev/null
@@ -0,0 +1,72 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import javax.jcr.RepositoryFactory;
+
+import org.argeo.eclipse.ui.TreeParent;
+import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Enable browsing in local public slc distribution repositories. For the time
+ * being, it supports only one repository at a time. Repository factory must be
+ * injected
+ */
+public class AnonymousDistTreeContentProvider implements ITreeContentProvider {
+       private static final long serialVersionUID = -4149180221319229128L;
+
+       // List<RepoElem> repositories = new ArrayList<RepoElem>();
+       private RepoElem publicRepo;
+
+       private RepositoryFactory repositoryFactory;
+
+       /**
+        * @param input
+        *            the URI to the public repository to browse
+        */
+       public Object[] getElements(Object input) {
+               String uri = (String) input;
+               publicRepo = new RepoElem(repositoryFactory, uri,
+                               "Argeo Public Repository");
+               // force connection and creation of the children UI object
+               publicRepo.login();
+               return publicRepo.getChildren();
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       }
+
+       // @Override
+       public Object[] getChildren(Object parentElement) {
+               if (parentElement instanceof TreeParent)
+                       return ((TreeParent) parentElement).getChildren();
+               else
+                       return null;
+       }
+
+       // @Override
+       public Object getParent(Object element) {
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).getParent();
+               return null;
+       }
+
+       // @Override
+       public boolean hasChildren(Object element) {
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).hasChildren();
+               else
+                       return false;
+       }
+
+       public void dispose() {
+               publicRepo.dispose();
+       }
+
+       /*
+        * DEPENDENCY INJECTION
+        */
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactLabelProvider.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactLabelProvider.java
new file mode 100644 (file)
index 0000000..197921e
--- /dev/null
@@ -0,0 +1,96 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.graphics.Image;
+
+/** Retrieve artifact information to be displayed in an artifact tree or table */
+public class ArtifactLabelProvider extends ColumnLabelProvider implements
+               DistConstants, SlcTypes {
+       private static final long serialVersionUID = 8672622174076959016L;
+
+       // To be able to change column order easily
+       public static final int COLUMN_TREE = 0;
+       public static final int COLUMN_DATE = 1;
+       public static final int COLUMN_SIZE = 2;
+
+       // Utils
+       protected static DateFormat timeFormatter = new SimpleDateFormat(
+                       DATE_TIME_FORMAT);
+
+       public void update(ViewerCell cell) {
+               int colIndex = cell.getColumnIndex();
+               Object element = cell.getElement();
+               cell.setText(getColumnText(element, colIndex));
+               if (element instanceof Node && colIndex == 0) {
+                       Node node = (Node) element;
+                       try {
+                               if (node.isNodeType(SLC_ARTIFACT_BASE))
+                                       cell.setImage(DistImages.IMG_ARTIFACT_BASE);
+                               else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE))
+                                       cell.setImage(DistImages.IMG_ARTIFACT_VERSION_BASE);
+                       } catch (RepositoryException e) {
+                               // Silent
+                       }
+               }
+       }
+
+       @Override
+       public Image getImage(Object element) {
+
+               if (element instanceof Node) {
+                       Node node = (Node) element;
+                       try {
+                               if (node.isNodeType(SLC_ARTIFACT_BASE)) {
+                                       return DistImages.IMG_ARTIFACT_BASE;
+                               } else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) {
+                                       return DistImages.IMG_ARTIFACT_VERSION_BASE;
+                               }
+                       } catch (RepositoryException e) {
+                               // Silent
+                       }
+               }
+               return null;
+       }
+
+       public String getColumnText(Object element, int columnIndex) {
+               try {
+                       if (element instanceof Node) {
+                               Node node = (Node) element;
+                               switch (columnIndex) {
+                               case COLUMN_TREE:
+                                       return node.getName();
+                               case COLUMN_SIZE:
+                                       long size = JcrUtils.getNodeApproxSize(node) / 1024;
+                                       if (size > 1024)
+                                               return size / 1024 + " MB";
+                                       else
+                                               return size + " KB";
+                               case COLUMN_DATE:
+                                       if (node.hasProperty(Property.JCR_LAST_MODIFIED))
+                                               return timeFormatter.format(node
+                                                               .getProperty(Property.JCR_LAST_MODIFIED)
+                                                               .getDate().getTime());
+                                       else
+                                               return null;
+                               }
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexepected error while getting property values", re);
+               }
+               return null;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactsTreeContentProvider.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactsTreeContentProvider.java
new file mode 100644 (file)
index 0000000..5559b44
--- /dev/null
@@ -0,0 +1,91 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+
+import org.argeo.eclipse.ui.jcr.util.JcrItemsComparator;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcTypes;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/** Enable specific browsing of an artifact tree */
+public class ArtifactsTreeContentProvider implements ITreeContentProvider,
+               SlcTypes {
+       private static final long serialVersionUID = -8097817288192073987L;
+
+       // Utils
+       private boolean sortChildren = true;
+       private JcrItemsComparator itemComparator = new JcrItemsComparator();
+
+       public Object[] getElements(Object parent) {
+               return getChildren(parent);
+       }
+
+       public Object getParent(Object child) {
+               return null;
+       }
+
+       public Object[] getChildren(Object parent) {
+               Object[] elements = null;
+               try {
+                       if (parent instanceof Node) {
+                               Node node = (Node) parent;
+                               NodeIterator ni = node.getNodes();
+                               List<Node> nodesList = new ArrayList<Node>();
+                               while (ni.hasNext()) {
+                                       nodesList.add(ni.nextNode());
+                               }
+                               if (sortChildren) {
+                                       Node[] arr = (Node[]) nodesList.toArray(new Node[nodesList
+                                                       .size()]);
+                                       Arrays.sort(arr, itemComparator);
+                                       return arr;
+                               } else
+                                       return nodesList.toArray();
+
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException(
+                                       "Unexpected exception while listing node properties", e);
+               }
+               return elements;
+       }
+
+       public boolean hasChildren(Object parent) {
+               try {
+                       if (parent instanceof Node) {
+                               Node curNode = (Node) parent;
+                               // We manually stop digging at this level
+                               if (curNode.isNodeType(SLC_ARTIFACT_VERSION_BASE))
+                                       return false;
+                               else if (curNode.hasNodes())
+                                       return true;
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException(
+                                       "Unexpected exception while checking if property is multiple",
+                                       e);
+               }
+               return false;
+       }
+
+       public void setSortChildren(boolean sortChildren) {
+               this.sortChildren = sortChildren;
+       }
+
+       public boolean getSortChildren() {
+               return sortChildren;
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       }
+
+       public void dispose() {
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistSessionFactory.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistSessionFactory.java
new file mode 100644 (file)
index 0000000..52c5374
--- /dev/null
@@ -0,0 +1,87 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import javax.jcr.Credentials;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.api.security.Keyring;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.RepoUtils;
+
+/**
+ * Provide shortcuts to retrieve sessions, repositories and workspaces that are
+ * persisted in the current user node using path only.
+ */
+public class DistSessionFactory {
+
+       /* DEPENDENCY INJECTION */
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       private Repository nodeRepository;
+
+       /**
+        * Returns a new session on the given workspace. This session *must* be
+        * disposed by the caller. If the workspace does not exist and
+        * createIfNeeded==true, tries to create it
+        * 
+        * */
+       public Session getSessionFromWorkspacePath(String path,
+                       boolean createIfNeeded) {
+               Session nodeSession = null;
+               try {
+                       nodeSession = nodeRepository.login();
+                       Node localWksp = nodeSession.getNode(path);
+                       Repository repository = RepoUtils.getRepository(repositoryFactory,
+                                       keyring, localWksp.getParent());
+                       Credentials credentials = RepoUtils.getRepositoryCredentials(
+                                       keyring, localWksp.getParent());
+
+                       String wkspName = JcrUtils.lastPathElement(path);
+                       Session session = null;
+                       try {
+                               session = repository.login(credentials, wkspName);
+                       } catch (NoSuchWorkspaceException e) {
+                               if (createIfNeeded) {
+                                       Session defaultSession = repository.login(credentials);
+                                       try {
+                                               defaultSession.getWorkspace().createWorkspace(wkspName);
+                                       } catch (Exception e1) {
+                                               throw new SlcException("Cannot create new workspace "
+                                                               + wkspName, e);
+                                       } finally {
+                                               JcrUtils.logoutQuietly(defaultSession);
+                                       }
+                                       session = repository.login(credentials, wkspName);
+                               } else
+                                       throw new SlcException("Workspace" + wkspName
+                                                       + "does not exists and should not be created", e);
+                       }
+                       return session;
+               } catch (RepositoryException e) {
+                       throw new SlcException("cannot create session" + " for workspace "
+                                       + path, e);
+               } finally {
+                       JcrUtils.logoutQuietly(nodeSession);
+               }
+       }
+
+       /*
+        * DEPENDENCY INJECTION
+        */
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+
+       public void setRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparator.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparator.java
new file mode 100644 (file)
index 0000000..c788ebc
--- /dev/null
@@ -0,0 +1,62 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import org.argeo.slc.client.ui.dist.model.DistParentElem;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
+import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
+import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
+import org.argeo.slc.client.ui.dist.utils.NameVersionComparator;
+import org.argeo.slc.client.ui.dist.utils.VersionComparator;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+/** Specific comparator to enhance Distribution tree browsers */
+public class DistTreeComparator extends ViewerComparator {
+       private static final long serialVersionUID = -7386716562202568704L;
+
+       private VersionComparator vc = new VersionComparator();
+       private NameVersionComparator nvc = new NameVersionComparator();
+
+       public int category(Object element) {
+               if (element instanceof RepoElem)
+                       if (((RepoElem) element).inHome())
+                               // Home repository always first
+                               return 2;
+                       else
+                               return 5;
+               else if (element instanceof WkspGroupElem)
+                       return 10;
+               else if (element instanceof WorkspaceElem)
+                       return 15;
+               else
+                       return 20;
+       }
+
+       public int compare(Viewer viewer, Object e1, Object e2) {
+               int cat1 = category(e1);
+               int cat2 = category(e2);
+
+               if (cat1 != cat2) {
+                       return cat1 - cat2;
+               }
+
+               String s1, s2;
+
+               if (e1 instanceof DistParentElem) {
+                       s1 = ((DistParentElem) e1).getName();
+                       s2 = ((DistParentElem) e2).getName();
+               } else {
+                       s1 = e1.toString();
+                       s2 = e2.toString();
+               }
+
+               if (e1 instanceof WorkspaceElem)
+                       // Reverse order for nameversions
+                       return nvc.compare(viewer, s2, s1);
+               else if (e1 instanceof ModularDistVersionElem)
+                       // Reverse order for versions
+                       return vc.compare(viewer, s2, s1);
+               else
+                       return s1.compareTo(s2);
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparer.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeComparer.java
new file mode 100644 (file)
index 0000000..5c6b9de
--- /dev/null
@@ -0,0 +1,28 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import org.argeo.eclipse.ui.TreeParent;
+import org.eclipse.jface.viewers.IElementComparer;
+
+/** Compares two elements of the Distribution tree */
+public class DistTreeComparer implements IElementComparer {
+
+       public int hashCode(Object element) {
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).hashCode();
+               else
+
+                       return element.getClass().toString().hashCode();
+       }
+
+       public boolean equals(Object elementA, Object elementB) {
+               if (!(elementA instanceof TreeParent)
+                               || !(elementB instanceof TreeParent)) {
+                       return elementA == null ? elementB == null : elementA
+                                       .equals(elementB);
+               } else {
+                       TreeParent tpA = ((TreeParent) elementA);
+                       TreeParent tpB = ((TreeParent) elementB);
+                       return tpA.compareTo(tpB) == 0;
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java
new file mode 100644 (file)
index 0000000..b7e25d1
--- /dev/null
@@ -0,0 +1,140 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.api.NodeConstants;
+import org.argeo.api.NodeUtils;
+import org.argeo.api.security.Keyring;
+import org.argeo.cms.ArgeoNames;
+import org.argeo.cms.ArgeoTypes;
+import org.argeo.eclipse.ui.TreeParent;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.argeo.slc.repo.RepoConstants;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Enables browsing in local and remote SLC software repositories. Keyring and
+ * repository factory must be injected
+ */
+public class DistTreeContentProvider implements ITreeContentProvider {
+       private static final long serialVersionUID = -7640840211717811421L;
+
+       /* DEPENDENCY INJECTION */
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+
+       // Context
+       private Session nodeSession;
+       List<RepoElem> repositories = new ArrayList<RepoElem>();
+
+       public Object[] getElements(Object input) {
+               Repository nodeRepository = (Repository) input;
+               try {
+                       if (nodeSession != null)
+                               dispose();
+                       nodeSession = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
+
+                       String reposPath = NodeUtils.getUserHome(nodeSession).getPath() + RepoConstants.REPOSITORIES_BASE_PATH;
+
+                       if (!nodeSession.itemExists(reposPath))
+                               initializeModel(nodeSession);
+
+                       NodeIterator repos = nodeSession.getNode(reposPath).getNodes();
+                       while (repos.hasNext()) {
+                               Node repoNode = repos.nextNode();
+                               if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
+                                       String label = repoNode.isNodeType(NodeType.MIX_TITLE)
+                                                       ? repoNode.getProperty(Property.JCR_TITLE).getString()
+                                                       : repoNode.getName();
+                                       repositories.add(new RepoElem(repositoryFactory, keyring, repoNode, label));
+                               }
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot get base elements", e);
+               }
+               return repositories.toArray();
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       }
+
+       // @Override
+       public Object[] getChildren(Object parentElement) {
+               if (parentElement instanceof TreeParent)
+                       return ((TreeParent) parentElement).getChildren();
+               else
+                       return null;
+       }
+
+       // @Override
+       public Object getParent(Object element) {
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).getParent();
+               return null;
+       }
+
+       // @Override
+       public boolean hasChildren(Object element) {
+               if (element instanceof TreeParent)
+                       return ((TreeParent) element).hasChildren();
+               else
+                       return false;
+       }
+
+       public void dispose() {
+               for (RepoElem repoElem : repositories)
+                       repoElem.dispose();
+               repositories = new ArrayList<RepoElem>();
+               JcrUtils.logoutQuietly(nodeSession);
+       }
+
+       private void initializeModel(Session nodeSession) {
+               try {
+                       Node homeNode = NodeUtils.getUserHome(nodeSession);
+                       if (homeNode == null) // anonymous
+                               throw new SlcException("User must be authenticated.");
+
+                       // make sure base directory is available
+                       Node repos = JcrUtils.mkdirs(homeNode, RepoConstants.REPOSITORIES_BASE_PATH, null);
+                       if (nodeSession.hasPendingChanges())
+                               nodeSession.save();
+
+                       // register default local java repository
+                       String alias = RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS;
+                       Repository javaRepository = NodeUtils.getRepositoryByAlias(repositoryFactory, alias);
+                       if (javaRepository != null) {
+                               if (!repos.hasNode(alias)) {
+                                       Node repoNode = repos.addNode(alias, ArgeoTypes.ARGEO_REMOTE_REPOSITORY);
+                                       repoNode.setProperty(ArgeoNames.ARGEO_URI, "vm:///" + alias);
+                                       repoNode.addMixin(NodeType.MIX_TITLE);
+                                       repoNode.setProperty(Property.JCR_TITLE, RepoConstants.DEFAULT_JAVA_REPOSITORY_LABEL);
+                                       nodeSession.save();
+                               }
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot initialize model", e);
+               }
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeDoubleClickListener.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeDoubleClickListener.java
new file mode 100644 (file)
index 0000000..2461d3a
--- /dev/null
@@ -0,0 +1,75 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.cms.ui.workbench.util.CommandUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
+import org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
+import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+
+/** Listen to double-clicks on the distributions view tree. */
+public class DistTreeDoubleClickListener implements IDoubleClickListener {
+
+       private TreeViewer treeViewer;
+
+       public DistTreeDoubleClickListener(TreeViewer treeViewer) {
+               this.treeViewer = treeViewer;
+       }
+
+       public void doubleClick(DoubleClickEvent event) {
+               if (event.getSelection() == null || event.getSelection().isEmpty())
+                       return;
+               Object obj = ((IStructuredSelection) event.getSelection())
+                               .getFirstElement();
+
+               if (obj instanceof RepoElem) {
+                       RepoElem rpNode = (RepoElem) obj;
+                       if (!rpNode.isConnected()) {
+                               rpNode.login();
+                               treeViewer.refresh(obj);
+                       }
+               } else if (obj instanceof WorkspaceElem) {
+                       WorkspaceElem we = (WorkspaceElem) obj;
+                       RepoElem repoElem = we.getRepoElem();
+                       Map<String, String> params = new HashMap<String, String>();
+                       params.put(OpenWorkspaceEditor.PARAM_REPO_NODE_PATH,
+                                       repoElem.getRepoNodePath());
+                       params.put(OpenWorkspaceEditor.PARAM_REPO_URI, repoElem.getUri());
+                       params.put(OpenWorkspaceEditor.PARAM_WORKSPACE_NAME,
+                                       we.getWorkspaceName());
+                       CommandUtils.callCommand(OpenWorkspaceEditor.ID, params);
+
+               } else if (obj instanceof ModularDistVersionElem) {
+                       ModularDistVersionElem modDistElem = (ModularDistVersionElem) obj;
+                       WorkspaceElem wkspElem = modDistElem.getWorkspaceElem();
+                       Node moduleNode = modDistElem.getModularDistVersionNode();
+                       RepoElem repoElem = wkspElem.getRepoElem();
+                       Map<String, String> params = new HashMap<String, String>();
+                       params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+                                       repoElem.getRepoNodePath());
+                       params.put(OpenModuleEditor.PARAM_REPO_URI, repoElem.getUri());
+                       params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+                                       wkspElem.getWorkspaceName());
+                       try {
+                               params.put(OpenModuleEditor.PARAM_MODULE_PATH,
+                                               moduleNode.getPath());
+                       } catch (RepositoryException re) {
+                               throw new SlcException("Cannot get path for node " + moduleNode
+                                               + " while setting parameters for "
+                                               + "command OpenModuleEditor", re);
+                       }
+                       CommandUtils.callCommand(OpenModuleEditor.ID, params);
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeLabelProvider.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeLabelProvider.java
new file mode 100644 (file)
index 0000000..661c987
--- /dev/null
@@ -0,0 +1,48 @@
+package org.argeo.slc.client.ui.dist.controllers;
+
+import org.argeo.cms.ui.jcr.JcrImages;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.argeo.slc.client.ui.dist.model.DistParentElem;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
+import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
+import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/** Manage icons and labels for the Distributions tree browser */
+public class DistTreeLabelProvider extends ColumnLabelProvider {
+       private static final long serialVersionUID = -7889294105284404373L;
+
+       @Override
+       public String getText(Object element) {
+               if (element instanceof DistParentElem)
+                       return ((DistParentElem) element).getName();
+               else
+                       return element.toString();
+       }
+
+       @Override
+       public Image getImage(Object element) {
+               if (element instanceof RepoElem) {
+                       RepoElem re = ((RepoElem) element);
+                       if (re.inHome())
+                               return DistImages.IMG_HOME_REPO;
+                       else if (re.isConnected())
+                               return JcrImages.REPOSITORY_CONNECTED;
+                       else
+                               return JcrImages.REPOSITORY_DISCONNECTED;
+               } else if (element instanceof WorkspaceElem) {
+                       return JcrImages.WORKSPACE_CONNECTED;
+               } else if (element instanceof WkspGroupElem)
+                       return DistImages.IMG_WKSP_GROUP;
+               // else if (element instanceof GroupBaseElem)
+               // return DistImages.IMG_GROUP_BASE;
+               else if (element instanceof ModularDistVersionBaseElem)
+                       return DistImages.IMG_MODULAR_DIST_BASE;
+               else if (element instanceof ModularDistVersionElem)
+                       return DistImages.IMG_MODULAR_DIST_VERSION;
+               return super.getImage(element);
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ArtifactVersionEditor.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ArtifactVersionEditor.java
new file mode 100644 (file)
index 0000000..4853fe2
--- /dev/null
@@ -0,0 +1,116 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.repo.RepoService;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/** Artifact editor in a multiple repository environment */
+public class ArtifactVersionEditor extends FormEditor implements SlcNames {
+       private static final long serialVersionUID = 1109872666962757000L;
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".artifactVersionEditor";
+
+       /* DEPENDENCY INJECTION */
+       private RepoService repoService;
+
+       // Business Objects
+       private Session businessSession;
+       private Node artifact;
+
+       private ModuleEditorInput editorInput;
+
+       @Override
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               editorInput = (ModuleEditorInput) input;
+               businessSession = repoService.getRemoteSession(
+                               editorInput.getRepoNodePath(), editorInput.getUri(),
+                               editorInput.getWorkspaceName());
+               try {
+                       artifact = businessSession.getNode(editorInput.getModulePath());
+               } catch (RepositoryException e) {
+                       throw new PartInitException(
+                                       "Unable to initialise editor for artifact "
+                                                       + editorInput.getModulePath() + " in workspace "
+                                                       + editorInput.getWorkspaceName(), e);
+               }
+               super.init(site, input);
+       }
+
+       /** Override to provide a specific part name */
+       protected String getFormattedName() {
+               try {
+                       String partName = null;
+                       if (artifact.hasProperty(SLC_ARTIFACT_ID))
+                               partName = artifact.getProperty(SLC_ARTIFACT_ID).getString();
+                       else
+                               partName = artifact.getName();
+
+                       if (partName.length() > 10) {
+                               partName = "..." + partName.substring(partName.length() - 10);
+                       }
+                       return partName;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "unable to get slc:artifactId Property for node "
+                                                       + artifact, re);
+               }
+       }
+
+       @Override
+       protected void addPages() {
+               setPartName(getFormattedName());
+
+               try {
+                       addPage(new BundleDetailPage(this, "Details ", artifact));
+                       addPage(new BundleDependencyPage(this, "Dependencies ", artifact));
+                       addPage(new BundleRawPage(this, "Raw Meta-Data ", artifact));
+               } catch (PartInitException e) {
+                       throw new SlcException("Cannot add distribution editor pages", e);
+               }
+
+       }
+
+       @Override
+       public void doSave(IProgressMonitor arg0) {
+       }
+
+       @Override
+       public void dispose() {
+               JcrUtils.logoutQuietly(businessSession);
+               super.dispose();
+       }
+
+       @Override
+       public void doSaveAs() {
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return false;
+       }
+
+       protected RepoService getRepoService() {
+               return repoService;
+       }
+
+       protected Node getArtifact() {
+               return artifact;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDependencyPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDependencyPage.java
new file mode 100644 (file)
index 0000000..938710d
--- /dev/null
@@ -0,0 +1,458 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * Present main information of a given OSGI bundle
+ */
+public class BundleDependencyPage extends FormPage implements SlcNames {
+       // private final static Log log =
+       // LogFactory.getLog(ArtifactDetailsPage.class);
+
+       // Main business Objects
+       private Node currBundle;
+
+       // This page widgets
+       private FormToolkit toolkit;
+
+       public BundleDependencyPage(FormEditor editor, String title,
+                       Node currentNode) {
+               super(editor, "id", title);
+               this.currBundle = currentNode;
+       }
+
+       protected void createFormContent(IManagedForm managedForm) {
+               ScrolledForm form = managedForm.getForm();
+               toolkit = managedForm.getToolkit();
+               try {
+                       if (currBundle.hasProperty(DistConstants.SLC_BUNDLE_NAME))
+                               form.setText(currBundle.getProperty(
+                                               DistConstants.SLC_BUNDLE_NAME).getString());
+                       Composite body = form.getBody();
+                       GridLayout layout = new GridLayout(1, false);
+                       layout.horizontalSpacing = layout.marginWidth = 0;
+                       layout.verticalSpacing = layout.marginHeight = 0;
+                       body.setLayout(layout);
+
+                       Composite part = toolkit.createComposite(body);
+                       createExportPackageSection(part);
+                       GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
+                       gd.heightHint = 180;
+                       part.setLayoutData(gd);
+
+                       part = toolkit.createComposite(body);
+                       createImportPackageSection(part);
+                       gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+                       // gd.heightHint = 200;
+                       part.setLayoutData(gd);
+
+                       part = toolkit.createComposite(body);
+                       createReqBundleSection(part);
+                       gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+                       part.setLayoutData(gd);
+
+                       managedForm.reflow(true);
+
+               } catch (RepositoryException e) {
+                       throw new SlcException("unexpected error "
+                                       + "while creating bundle details page");
+               }
+       }
+
+       // Workaround to add an artificial level to the export package browser
+       private class LevelElem {
+               private String label;
+               private Object parent;
+
+               public LevelElem(String label, Object parent) {
+                       this.label = label;
+                       this.parent = parent;
+               }
+
+               public String toString() {
+                       return label;
+               }
+
+               public Object getParent() {
+                       return parent;
+               }
+       }
+
+       /** Export Package Section */
+       private void createExportPackageSection(Composite parent)
+                       throws RepositoryException {
+               parent.setLayout(new GridLayout());
+
+               // Define the TableViewer
+
+               Section section = addSection(parent, "Export packages");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               TreeViewer viewer = new TreeViewer(section, SWT.H_SCROLL | SWT.V_SCROLL
+                               | SWT.BORDER);
+               final Tree tree = viewer.getTree();
+               tree.setHeaderVisible(false);
+               tree.setLinesVisible(true);
+               tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.FILL);
+               col.getColumn().setWidth(400);
+
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = 1376400790495130862L;
+
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof Node)
+                                       return JcrUtils.get((Node) element, SlcNames.SLC_NAME);
+                               else
+                                       return element.toString();
+                       }
+
+                       @Override
+                       public Image getImage(Object element) {
+                               if (element instanceof Node) {
+                                       try {
+                                               Node node = (Node) element;
+                                               if (node.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE))
+                                                       return DistImages.IMG_PACKAGE;
+                                       } catch (RepositoryException e) {
+                                               throw new SlcException("Error retriving "
+                                                               + "image for the labelProvider", e);
+                                       }
+                               }
+                               return null;
+                       }
+               });
+
+               viewer.setContentProvider(new ITreeContentProvider() {
+                       private static final long serialVersionUID = 1898086304761992568L;
+
+                       public void dispose() {
+                       }
+
+                       public void inputChanged(Viewer viewer, Object oldInput,
+                                       Object newInput) {
+                       }
+
+                       public Object[] getElements(Object inputElement) {
+                               try {
+                                       List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
+                                                       currBundle, SlcTypes.SLC_EXPORTED_PACKAGE,
+                                                       SlcNames.SLC_NAME));
+                                       return nodes.toArray();
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot list children Nodes", e);
+                               }
+                       }
+
+                       public Object[] getChildren(Object parentElement) {
+                               // Only 2 levels for the time being
+                               try {
+                                       if (parentElement instanceof LevelElem) {
+                                               Node node = (Node) ((LevelElem) parentElement)
+                                                               .getParent();
+                                               List<Node> nodes = JcrUtils
+                                                               .nodeIteratorToList(listNodes(node,
+                                                                               SlcTypes.SLC_JAVA_PACKAGE,
+                                                                               SlcNames.SLC_NAME));
+                                               return nodes.toArray();
+                                       } else if (parentElement instanceof Node) {
+                                               Node pNode = (Node) parentElement;
+                                               if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
+                                                       if (listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
+                                                                       SlcNames.SLC_NAME).getSize() > 0) {
+                                                               Object[] result = { new LevelElem("uses", pNode) };
+                                                               return result;
+                                                       }
+                                               }
+                                       }
+                                       return null;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot list children Nodes", e);
+                               }
+                       }
+
+                       public Object getParent(Object element) {
+                               // useless
+                               return null;
+                       }
+
+                       public boolean hasChildren(Object element) {
+                               try {
+                                       if (element instanceof LevelElem)
+                                               return true;
+                                       else {
+                                               Node pNode = (Node) element;
+                                               if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
+                                                       return listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
+                                                                       SlcNames.SLC_NAME).getSize() > 0;
+                                               }
+                                       }
+                                       return false;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot check children Nodes", e);
+                               }
+                       }
+               });
+
+               section.setClient(tree);
+               viewer.setInput("Initialize");
+               // work around a display problem : the tree table has only a few lines
+               // when the tree is not expended
+               // viewer.expandToLevel(2);
+       }
+
+       /** Import Package Section */
+       private void createImportPackageSection(Composite parent)
+                       throws RepositoryException {
+               parent.setLayout(new GridLayout());
+
+               // Define the TableViewer
+               // toolkit.createLabel(parent, "Import packages", SWT.NONE).setFont(
+               // EclipseUiUtils.getBoldFont(parent));
+
+               Section section = addSection(parent, "Import packages");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               TableViewer viewer = new TableViewer(section, SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.BORDER);
+
+               final Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               // Name
+               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(350);
+               col.getColumn().setText("Name");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = -7836022945221936898L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_NAME);
+                       }
+
+                       public Image getImage(Object element) {
+                               return DistImages.IMG_PACKAGE;
+                       }
+
+               });
+
+               // Version
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(100);
+               col.getColumn().setText("Version");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = -8277731617775091641L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_VERSION);
+                       }
+               });
+
+               // Optional
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(100);
+               col.getColumn().setText("Optional");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = -2388533169594840688L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_OPTIONAL);
+                       }
+               });
+
+               viewer.setContentProvider(new TableContentProvider(
+                               SlcTypes.SLC_IMPORTED_PACKAGE, SLC_NAME));
+               section.setClient(table);
+               viewer.setInput("Initialize");
+       }
+
+       /** Required Bundle Section */
+       private void createReqBundleSection(Composite parent)
+                       throws RepositoryException {
+               parent.setLayout(new GridLayout());
+
+               // Define the TableViewer
+               Section section = addSection(parent, "Required bundles");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               // toolkit.createLabel(parent, "Required bundles", SWT.NONE).setFont(
+               // EclipseUiUtils.getBoldFont(parent));
+               TableViewer viewer = new TableViewer(section, SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.BORDER);
+
+               final Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               // Name
+               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(300);
+               col.getColumn().setText("Name");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = 4423640365819800247L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
+                       }
+
+                       @Override
+                       public Image getImage(Object element) {
+                               return DistImages.IMG_BUNDLE;
+                       }
+               });
+
+               // Version
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(140);
+               col.getColumn().setText("Version");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = 1898477425996646270L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
+                       }
+               });
+
+               // Optional
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(100);
+               col.getColumn().setText("Optional");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = -7029999152302445581L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_OPTIONAL);
+                       }
+               });
+
+               viewer.setContentProvider(new TableContentProvider(
+                               SlcTypes.SLC_REQUIRED_BUNDLE, SLC_SYMBOLIC_NAME));
+               section.setClient(table);
+               viewer.setInput("Initialize");
+       }
+
+       /**
+        * Build repository request
+        * 
+        * FIXME Workaround for remote repository, the path to bundleartifact (for
+        * instance
+        * .../org/argeo/slc/org.argeo.slc.client.ui.dist/1.1.12/org.argeo.slc
+        * .client.ui.dist-1.1.12/ ) is not valid for method factory.childNode(); it
+        * fails parsing the "1.1.12" part, trying to cast it as a BigDecimal
+        * 
+        * */
+       private NodeIterator listNodes(Node parent, String nodeType, String orderBy)
+                       throws RepositoryException {
+               // QueryManager queryManager = currBundle.getSession().getWorkspace()
+               // .getQueryManager();
+               // QueryObjectModelFactory factory = queryManager.getQOMFactory();
+               //
+               // final String nodeSelector = "nodes";
+               // Selector source = factory.selector(nodeType, nodeSelector);
+               //
+               // Constraint childOf = factory.childNode(nodeSelector,
+               // parent.getPath());
+               //
+               // Ordering order =
+               // factory.ascending(factory.propertyValue(nodeSelector,
+               // orderBy));
+               // Ordering[] orderings = { order };
+               //
+               // QueryObjectModel query = factory.createQuery(source, childOf,
+               // orderings, null);
+               //
+               // QueryResult result = query.execute();
+
+               String pattern = null;
+               if (SlcTypes.SLC_EXPORTED_PACKAGE.equals(nodeType))
+                       pattern = "slc:Export-Package*";
+               else if (SlcTypes.SLC_JAVA_PACKAGE.equals(nodeType))
+                       pattern = "slc:uses*";
+               else if (SlcTypes.SLC_IMPORTED_PACKAGE.equals(nodeType))
+                       pattern = "slc:Import-Package*";
+               else if (SlcTypes.SLC_REQUIRED_BUNDLE.equals(nodeType))
+                       pattern = "slc:Require-Bundle*";
+
+               return parent.getNodes(pattern);
+       }
+
+       private class TableContentProvider implements IStructuredContentProvider {
+               private static final long serialVersionUID = 4133284637336320455L;
+               private String nodeType;
+               private String orderBy;
+
+               TableContentProvider(String nodeType, String orderBy) {
+                       this.nodeType = nodeType;
+                       this.orderBy = orderBy;
+               }
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+               public Object[] getElements(Object arg0) {
+                       try {
+                               List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
+                                               currBundle, nodeType, orderBy));
+                               return nodes.toArray();
+                       } catch (RepositoryException e) {
+                               ErrorFeedback.show("Cannot list children Nodes", e);
+                               return null;
+                       }
+               }
+       }
+
+       /* HELPERS */
+       private Section addSection(Composite parent, String title) {
+               Section section = toolkit.createSection(parent, Section.TITLE_BAR);
+               section.setText(title);
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               return section;
+       }
+
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDetailPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleDetailPage.java
new file mode 100644 (file)
index 0000000..c300af1
--- /dev/null
@@ -0,0 +1,503 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import java.net.URL;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.build.License;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.utils.HyperlinkAdapter;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+/** Show details for a given bundle. */
+public class BundleDetailPage extends FormPage implements SlcNames {
+       private final static Log log = LogFactory.getLog(BundleDetailPage.class);
+
+       final static String PAGE_ID = "BundleDetailPage";
+
+       // Business Objects
+       private Node bundle;
+
+       // This page widgets
+       private FormToolkit tk;
+
+       public BundleDetailPage(FormEditor formEditor, String title, Node bundle) {
+               super(formEditor, PAGE_ID, title);
+               this.bundle = bundle;
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm managedForm) {
+               // General settings for this page
+               ScrolledForm form = managedForm.getForm();
+               tk = managedForm.getToolkit();
+               Composite body = form.getBody();
+
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = 5;
+               layout.marginRight = 15;
+               layout.verticalSpacing = 0;
+               body.setLayout(layout);
+               try {
+                       form.setText(bundle.hasProperty(SlcNames.SLC_SYMBOLIC_NAME) ? bundle
+                                       .getProperty(SlcNames.SLC_SYMBOLIC_NAME).getString() : "");
+                       form.setMessage(bundle
+                                       .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? bundle
+                                       .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
+                                       .getString() : "", IMessageProvider.NONE);
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to get bundle name for node "
+                                       + bundle, re);
+               }
+
+               // Main layout
+               Composite header = tk.createComposite(body);
+               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               populateHeaderPart(header);
+
+               Composite mavenSnipet = tk.createComposite(body);
+               mavenSnipet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               populateMavenSnippetPart(mavenSnipet);
+       }
+
+       private void populateHeaderPart(Composite parent) {
+               GridLayout layout = new GridLayout(6, false);
+               // layout.marginWidth = layout.horizontalSpacing = layout.marginHeight =
+               // 0;
+               layout.horizontalSpacing = 10;
+               parent.setLayout(layout);
+               try {
+                       // 1st Line: Category, name version
+                       createLT(parent, "Category",
+                                       bundle.hasProperty(SlcNames.SLC_GROUP_ID) ? bundle
+                                                       .getProperty(SlcNames.SLC_GROUP_ID).getString()
+                                                       : "");
+                       createLT(parent, "Name",
+                                       bundle.hasProperty(SlcNames.SLC_ARTIFACT_ID) ? bundle
+                                                       .getProperty(SlcNames.SLC_ARTIFACT_ID).getString()
+                                                       : "");
+                       createLT(parent, "Version",
+                                       bundle.hasProperty(SlcNames.SLC_ARTIFACT_VERSION) ? bundle
+                                                       .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
+                                                       .getString() : "");
+
+                       // 3rd Line: Vendor, licence, sources
+                       createLT(
+                                       parent,
+                                       "Vendor",
+                                       bundle.hasProperty(DistConstants.SLC_BUNDLE_VENDOR) ? bundle
+                                                       .getProperty(DistConstants.SLC_BUNDLE_VENDOR)
+                                                       .getString() : "N/A");
+
+                       createLicencesLink(parent, "Licence",
+                                       DistConstants.SLC_BUNDLE_LICENCE);
+                       addSourceLink(parent);
+
+                       // 2nd Line: The Jar itself and the Manifest
+                       createJarLink(parent);
+                       createManifestLink(parent);
+
+                       // Last line
+                       createPomLink(parent);
+
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to get bundle name for node "
+                                       + bundle, re);
+               }
+
+       }
+
+       private void populateMavenSnippetPart(Composite parent) {
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
+               parent.setLayout(layout);
+
+               Section section = tk.createSection(parent, Section.TITLE_BAR
+                               | Section.DESCRIPTION);
+               section.setText("Maven");
+               section.setDescription("Add the below tag to your Artifact pom dependencies");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               Text snippetTxt = createMavenSnippet(section);
+               section.setClient(snippetTxt);
+       }
+
+       // /////////////////////
+       // HELPERS
+
+       private Text createLT(Composite parent, String labelValue, String textValue) {
+               Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
+               // label.setFont(EclipseUiUtils.getBoldFont(parent));
+               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+               // Add a trailing space to workaround a display glitch in RAP 1.3
+               Text text = new Text(parent, SWT.LEFT);
+               text.setText(textValue + " ");
+               text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               text.setEditable(false);
+               return text;
+       }
+
+       private void createLicencesLink(Composite parent, String label,
+                       String jcrPropName) throws RepositoryException {
+               tk.createLabel(parent, label, SWT.NONE);
+               if (bundle.hasProperty(jcrPropName)) {
+
+                       String licenceLinkVal = bundle.getProperty(jcrPropName).getString();
+
+                       // FIXME Hack until license generation is done cleanly
+                       // Problem is with description that contains a "," like
+                       // "Apache License, Version 2"
+                       String[] licenceVals;
+                       if (licenceLinkVal.contains("description="))
+                               licenceVals = new String[] { licenceLinkVal };
+                       else
+                               // multiple license, form non-regenerated manifests
+                               licenceVals = licenceLinkVal.split(", ");
+
+                       Composite body = tk.createComposite(parent);
+                       body.setLayout(new RowLayout(SWT.WRAP));
+
+                       for (final String value : licenceVals) {
+                               final License currLicense = parseLicenseString(value);
+
+                               Hyperlink link = tk.createHyperlink(body,
+                                               currLicense.getName(), SWT.NONE);
+                               link.addHyperlinkListener(new HyperlinkAdapter() {
+                                       @Override
+                                       public void linkActivated(HyperlinkEvent e) {
+                                               try {
+                                                       IWorkbenchBrowserSupport browserSupport = PlatformUI
+                                                                       .getWorkbench().getBrowserSupport();
+                                                       IWebBrowser browser = browserSupport
+                                                                       .createBrowser(
+                                                                                       IWorkbenchBrowserSupport.LOCATION_BAR
+                                                                                                       | IWorkbenchBrowserSupport.NAVIGATION_BAR,
+                                                                                       "SLC Distribution browser",
+                                                                                       "SLC Distribution browser",
+                                                                                       "A tool tip");
+                                                       browser.openURL(new URL(currLicense.getUri()));
+                                               } catch (Exception ex) {
+                                                       throw new SlcException("error opening browser", ex); //$NON-NLS-1$
+                                               }
+                                       }
+                               });
+                       }
+               } else
+                       tk.createLabel(parent, "N/A", SWT.NONE);
+       }
+
+       // TODO this must be moved to a better place once the standard has been
+       // defined
+       // Enable licence encoding in a single JCR Value
+       private final static String LICENSE_SEPARATOR = ";";
+       // The human readable name of the licence
+       private final static String LICENSE_NAME = "description";
+       // A link on the internet with some more info on this licence
+       private final static String LICENSE_LINK = "link";
+
+       private License parseLicenseString(String licenseStr) {
+               String uri = null, name = null, link = null, text = null;
+               // TODO enhance this
+               String[] values = licenseStr.split(LICENSE_SEPARATOR);
+               for (String value : values) {
+                       if (value.startsWith(LICENSE_NAME))
+                               name = value.substring(LICENSE_NAME.length() + 1); // +1 for the
+                                                                                                                                       // '='
+                       else if (value.startsWith(LICENSE_LINK))
+                               link = value.substring(LICENSE_LINK.length() + 1);
+                       else if (uri == null)
+                               uri = value;
+                       // TODO manage text
+               }
+               return new SimpleLicense(name, uri, link, text);
+       }
+
+       class SimpleLicense implements License {
+               private final String name;
+               private final String uri;
+               private final String link;
+               private final String text;
+
+               public SimpleLicense(String name, String uri, String link, String text) {
+                       if (uri == null)
+                               throw new SlcException(
+                                               "Cannot manage a licence with a null URI ");
+                       this.uri = uri;
+
+                       this.name = name;
+                       this.link = link;
+                       this.text = text;
+               }
+
+               public String getUri() {
+                       return uri;
+               }
+
+               public String getText() {
+                       return text;
+               }
+
+               public String getName() {
+                       return name != null ? name : uri;
+               }
+
+               public String getLink() {
+                       return link;
+               }
+       }
+
+       private void createJarLink(Composite parent) throws RepositoryException {
+               Label label = tk.createLabel(parent, "Jar", SWT.RIGHT);
+               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+               Composite body = tk.createComposite(parent);
+               RowLayout rl = new RowLayout(SWT.HORIZONTAL);
+               rl.spacing = 6;
+               body.setLayout(rl);
+               body.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
+
+               Hyperlink jarLink = tk
+                               .createHyperlink(body, bundle.getName(), SWT.NONE);
+               jarLink.addHyperlinkListener(new OpenFileLinkListener(bundle.getPath()));
+
+               // Corresponding check sums
+
+               String name = bundle.getName() + ".md5";
+               if (bundle.getParent().hasNode(name)) {
+                       Node md5 = bundle.getParent().getNode(name);
+                       Hyperlink md5Link = tk.createHyperlink(body, "MD5", SWT.NONE);
+                       md5Link.addHyperlinkListener(new OpenFileLinkListener(md5.getPath()));
+               }
+
+               name = bundle.getName() + ".sha1";
+               if (bundle.getParent().hasNode(name)) {
+                       Node sha1 = bundle.getParent().getNode(name);
+                       Hyperlink sha1Link = tk.createHyperlink(body, "SHA1", SWT.NONE);
+                       sha1Link.addHyperlinkListener(new OpenFileLinkListener(sha1
+                                       .getPath()));
+               }
+       }
+
+       private void createPomLink(Composite parent) throws RepositoryException {
+               Label label = tk.createLabel(parent, "Pom", SWT.RIGHT);
+               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+               String name = bundle.getName().substring(0,
+                               bundle.getName().length() - "jar".length())
+                               + "pom";
+
+               if (bundle.getParent().hasNode(name)) {
+                       Node pom = bundle.getParent().getNode(name);
+
+                       Composite body = tk.createComposite(parent);
+                       RowLayout rl = new RowLayout(SWT.HORIZONTAL);
+                       rl.spacing = 6;
+                       body.setLayout(rl);
+                       body.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
+                                       3, 1));
+
+                       Hyperlink pomLink = tk.createHyperlink(body, "pom.xml", SWT.NONE);
+                       pomLink.addHyperlinkListener(new OpenFileLinkListener(pom.getPath()));
+
+                       // Corresponding check sums
+                       name = pom.getName() + ".md5";
+                       if (pom.getParent().hasNode(name)) {
+                               Node md5 = pom.getParent().getNode(name);
+                               Hyperlink md5Link = tk.createHyperlink(body, "MD5", SWT.NONE);
+                               md5Link.addHyperlinkListener(new OpenFileLinkListener(md5
+                                               .getPath()));
+                       }
+
+                       name = pom.getName() + ".sha1";
+                       if (pom.getParent().hasNode(name)) {
+                               Node sha1 = pom.getParent().getNode(name);
+                               Hyperlink sha1Link = tk.createHyperlink(body, "SHA1", SWT.NONE);
+                               sha1Link.addHyperlinkListener(new OpenFileLinkListener(sha1
+                                               .getPath()));
+                       }
+               } else
+                       tk.createLabel(parent, "N/A", SWT.NONE);
+       }
+
+       private void createManifestLink(Composite parent)
+                       throws RepositoryException {
+               tk.createLabel(parent, "Manifest", SWT.NONE);
+               // Hyperlink link =
+               // TODO fix this when file download has been implemented for the
+               // manifest
+               tk.createHyperlink(parent, "MANIFEST.MF", SWT.NONE);
+               // link.addHyperlinkListener(new
+               // OpenFileLinkListener(bundle.getPath()));
+       }
+
+       // private void createHyperlink(Composite parent, String label,
+       // String jcrPropName) throws RepositoryException {
+       // tk.createLabel(parent, label, SWT.NONE);
+       // if (bundle.hasProperty(jcrPropName)) {
+       // final Hyperlink link = tk.createHyperlink(parent, bundle
+       // .getProperty(jcrPropName).getString(), SWT.NONE);
+       // link.addHyperlinkListener(new AbstractHyperlinkListener() {
+       // @Override
+       // public void linkActivated(HyperlinkEvent e) {
+       // try {
+       // IWorkbenchBrowserSupport browserSupport = PlatformUI
+       // .getWorkbench().getBrowserSupport();
+       // IWebBrowser browser = browserSupport
+       // .createBrowser(
+       // IWorkbenchBrowserSupport.LOCATION_BAR
+       // | IWorkbenchBrowserSupport.NAVIGATION_BAR,
+       // "SLC Distribution browser",
+       // "SLC Distribution browser",
+       // "A tool tip");
+       // browser.openURL(new URL(link.getText()));
+       // } catch (Exception ex) {
+       //                                              throw new SlcException("error opening browser", ex); //$NON-NLS-1$
+       // }
+       // }
+       // });
+       // } else
+       // tk.createLabel(parent, "N/A", SWT.NONE);
+       // }
+
+       // helper to check if sources are available
+       private void addSourceLink(Composite parent) {
+               try {
+                       String srcPath = RepoUtils.relatedPdeSourcePath(
+                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, bundle);
+                       if (!bundle.getSession().nodeExists(srcPath)) {
+                               createLT(parent, "Sources", "N/A");
+                       } else {
+                               final Node sourcesNode = bundle.getSession().getNode(srcPath);
+
+                               String srcName = null;
+                               if (sourcesNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME))
+                                       srcName = sourcesNode.getProperty(
+                                                       SlcNames.SLC_SYMBOLIC_NAME).getString();
+                               else
+                                       srcName = sourcesNode.getName();
+                               Label label = tk.createLabel(parent, "Sources", SWT.RIGHT);
+                               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
+                                               false));
+                               final Hyperlink link = tk.createHyperlink(parent, srcName,
+                                               SWT.NONE);
+                               link.addHyperlinkListener(new OpenFileLinkListener(sourcesNode
+                                               .getPath()));
+
+                               // {
+                               // @Override
+                               // public void linkActivated(HyperlinkEvent e) {
+                               // try {
+                               // ModuleEditorInput editorInput = (ModuleEditorInput)
+                               // getEditorInput();
+                               // Map<String, String> params = new HashMap<String, String>();
+                               // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
+                               // editorInput.getRepoNodePath());
+                               // params.put(OpenJcrFile.PARAM_REPO_URI,
+                               // editorInput.getUri());
+                               // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
+                               // editorInput.getWorkspaceName());
+                               // params.put(OpenJcrFile.PARAM_FILE_PATH,
+                               // );
+                               // CommandUtils.callCommand(OpenJcrFile.ID, params);
+                               // } catch (Exception ex) {
+                               //                                                      throw new SlcException("error opening browser", ex); //$NON-NLS-1$
+                               // }
+                               // }
+                               // });
+
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unable to configure sources link for "
+                                       + bundle, e);
+               }
+       }
+
+       private class OpenFileLinkListener extends HyperlinkAdapter {
+               final private String path;
+
+               public OpenFileLinkListener(String path) {
+                       this.path = path;
+               }
+
+               @Override
+               public void linkActivated(HyperlinkEvent e) {
+                       log.warn("File download must be implemented. Cannot provide access to "
+                                       + path);
+
+                       // try {
+                       // ModuleEditorInput editorInput = (ModuleEditorInput)
+                       // getEditorInput();
+                       // Map<String, String> params = new HashMap<String, String>();
+                       // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
+                       // editorInput.getRepoNodePath());
+                       // params.put(OpenJcrFile.PARAM_REPO_URI, editorInput.getUri());
+                       // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
+                       // editorInput.getWorkspaceName());
+                       // params.put(OpenJcrFile.PARAM_FILE_PATH, path);
+                       //
+                       // String cmdId = (new OpenJcrFileCmdId()).getCmdId();
+                       // if (log.isTraceEnabled())
+                       // log.debug("Retrieved openFile Cmd ID: " + cmdId);
+                       // CommandUtils.callCommand(cmdId, params);
+                       // } catch (Exception ex) {
+                       //                              throw new SlcException("error opening browser", ex); //$NON-NLS-1$
+                       // }
+               }
+       }
+
+       /** Creates a text area with corresponding maven snippet */
+       private Text createMavenSnippet(Composite parent) {
+               Text mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               gd.heightHint = 100;
+               mavenSnippet.setLayoutData(gd);
+               mavenSnippet.setText(generateXmlSnippet());
+               return mavenSnippet;
+       }
+
+       private String generateXmlSnippet() {
+               try {
+                       StringBuffer sb = new StringBuffer();
+                       sb.append("<dependency>\n");
+                       sb.append("\t<groupId>");
+                       sb.append(bundle.getProperty(SLC_GROUP_ID).getString());
+                       sb.append("</groupId>\n");
+                       sb.append("\t<artifactId>");
+                       sb.append(bundle.getProperty(SLC_ARTIFACT_ID).getString());
+                       sb.append("</artifactId>\n");
+                       sb.append("\t<version>");
+                       sb.append(bundle.getProperty(SLC_ARTIFACT_VERSION).getString());
+                       sb.append("</version>\n");
+                       sb.append("</dependency>");
+                       return sb.toString();
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "unexpected error while generating maven snippet");
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleRawPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/BundleRawPage.java
new file mode 100644 (file)
index 0000000..0ac7e4e
--- /dev/null
@@ -0,0 +1,325 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.argeo.slc.client.ui.dist.utils.DistUiHelpers;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/** List all properties of current bundle as a tree */
+public class BundleRawPage extends FormPage implements SlcNames, SlcTypes {
+       // private final static Log log =
+       // LogFactory.getLog(ArtifactDetailsPage.class);
+
+       // Main business Objects
+       private Node currBundle;
+
+       // This page widgets
+       private TreeViewer complexTree;
+
+       public BundleRawPage(FormEditor editor, String title, Node currentNode) {
+               super(editor, "id", title);
+               this.currBundle = currentNode;
+       }
+
+       protected void createFormContent(IManagedForm managedForm) {
+               ScrolledForm form = managedForm.getForm();
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = 5;
+               form.getBody().setLayout(layout);
+               createViewer(form.getBody());
+       }
+
+       private void createViewer(Composite parent) {
+
+               // Create the viewer
+               int style = SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION;
+               Tree tree = new Tree(parent, style);
+               GridData gd = new GridData(GridData.FILL_BOTH);
+               gd.grabExcessHorizontalSpace = true;
+               gd.grabExcessVerticalSpace = true;
+               tree.setLayoutData(gd);
+               createColumn(tree, "Attribute", SWT.LEFT, 200);
+               createColumn(tree, "Value", SWT.LEFT, 200);
+               tree.setLinesVisible(true);
+               tree.setHeaderVisible(true);
+
+               complexTree = new TreeViewer(tree);
+               complexTree.setContentProvider(new TreeContentProvider());
+               complexTree.setLabelProvider(new TreeLabelProvider());
+
+               // Initialize
+               complexTree.setInput(currBundle);
+               // result.expandAll();
+               complexTree.expandToLevel(2);
+
+       }
+
+       private static TreeColumn createColumn(Tree parent, String name, int style,
+                       int width) {
+               TreeColumn result = new TreeColumn(parent, style);
+               result.setText(name);
+               result.setWidth(width);
+               result.setMoveable(true);
+               result.setResizable(true);
+               return result;
+       }
+
+       // View specific object
+       private class ViewSpecificItems {
+               private String key;
+               private Object value;
+               private boolean isFolder;
+               private Node curNode;
+
+               public ViewSpecificItems(String key, Object value, boolean isFolder) {
+                       this.key = key;
+                       this.value = value;
+                       this.isFolder = isFolder;
+               }
+
+               public String getKey() {
+                       return key;
+               }
+
+               public void setNode(Node node) {
+                       this.curNode = node;
+               }
+
+               public Node getNode() {
+                       return curNode;
+               }
+
+               public Object getValue() {
+                       return value;
+               }
+
+               public boolean isFolder() {
+                       return isFolder;
+               }
+
+       }
+
+       // providers
+       private class TreeLabelProvider extends ColumnLabelProvider implements
+                       SlcTypes, SlcNames {
+               private static final long serialVersionUID = -6385445983392621937L;
+
+               public void update(ViewerCell cell) {
+                       try {
+
+                               int colIndex = cell.getColumnIndex();
+                               Object element = cell.getElement();
+                               if (element instanceof Property) {
+                                       Property prop = (Property) element;
+                                       if (colIndex == 0)
+                                               cell.setText(DistUiHelpers.getLabelJcrName(prop
+                                                               .getName()));
+                                       else if (colIndex == 1)
+                                               cell.setText(DistUiHelpers.formatValueAsString(prop
+                                                               .getValue()));
+
+                               } else if (element instanceof ViewSpecificItems) {
+                                       if (colIndex == 0)
+                                               cell.setText(((ViewSpecificItems) element).getKey());
+                                       else if (colIndex == 1)
+                                               cell.setText(DistUiHelpers
+                                                               .formatAsString(((ViewSpecificItems) element)
+                                                                               .getValue()));
+
+                               } else if (element instanceof Node) {
+                                       Node node = (Node) element;
+                                       if (colIndex == 0) {
+                                               if (node.isNodeType(NodeType.NT_FILE)) {
+                                                       cell.setImage(DistImages.IMG_FILE);
+                                                       cell.setText(node.getName());
+                                               } else if (node.isNodeType(SLC_IMPORTED_PACKAGE))
+                                                       cell.setText("Import package");
+                                               else if (node.isNodeType(SLC_EXPORTED_PACKAGE))
+                                                       cell.setText("Export package");
+
+                                       } else if (colIndex == 1) {
+                                               if (node.isNodeType(SLC_ARTIFACT)) {
+                                                       StringBuffer sb = new StringBuffer("");
+                                                       if (node.hasProperty(SLC_ARTIFACT_CLASSIFIER)) {
+                                                               sb.append(node.getProperty(
+                                                                               SLC_ARTIFACT_CLASSIFIER).getString());
+                                                               sb.append(" ");
+                                                       }
+                                                       if (node.hasProperty(SLC_ARTIFACT_EXTENSION))
+                                                               sb.append(node.getProperty(
+                                                                               SLC_ARTIFACT_EXTENSION).getString());
+                                                       cell.setText(sb.toString());
+                                               } else if (node.isNodeType(SLC_IMPORTED_PACKAGE)
+                                                               || node.isNodeType(SLC_EXPORTED_PACKAGE))
+                                                       cell.setText(node.getProperty(SLC_NAME).getString());
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "unexpected error while getting artifact information",
+                                               e);
+                       }
+               }
+       }
+
+       private class TreeContentProvider implements ITreeContentProvider {
+               private static final long serialVersionUID = -4315686158836938052L;
+
+               public Object[] getElements(Object parent) {
+                       List<Object> elements = new ArrayList<Object>();
+
+                       try {
+                               Node node = (Node) parent;
+                               elements = new ArrayList<Object>();
+
+                               // Maven coordinates
+//                             elements.add(node.getProperty(SLC_GROUP_ID));
+//                             elements.add(node.getProperty(SLC_ARTIFACT_ID));
+//                             elements.add(node.getProperty(SLC_ARTIFACT_VERSION));
+
+                               // Meta information
+                               // boolean gotSource = false;
+                               // // TODO: implement this check
+                               // elements.add(new ViewSpecificItems("Sources available",
+                               // gotSource));
+
+                               // Jars
+                               NodeIterator ni = node.getNodes();
+                               while (ni.hasNext()) {
+                                       Node child = ni.nextNode();
+                                       if (child.isNodeType(SLC_ARTIFACT)) {
+                                               // we skip sha1 files for the time being.
+                                               elements.add(child);
+                                       }
+                               }
+
+                               // Properties
+                               PropertyIterator pi = node.getProperties();
+                               while (pi.hasNext()) {
+                                       Property curProp = pi.nextProperty();
+                                       if (!curProp.getName().startsWith("jcr:")
+                                                       && !curProp.isMultiple())
+                                               elements.add(curProp);
+                               }
+
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "Unexpected exception while listing node properties", e);
+                       }
+                       return elements.toArray();
+               }
+
+               public Object getParent(Object child) {
+                       return null;
+               }
+
+               public Object[] getChildren(Object parent) {
+                       Object[] result = null;
+                       try {
+                               if (parent instanceof Property) {
+                                       Property prop = (Property) parent;
+                                       if (prop.isMultiple()) {
+                                               Value[] values = prop.getValues();
+                                               return values;
+                                       }
+                               } else if (parent instanceof Node) {
+                                       Node node = (Node) parent;
+                                       if (node.hasNodes()) {
+                                               List<Object> elements = new ArrayList<Object>();
+                                               PropertyIterator pi = node.getProperties();
+                                               while (pi.hasNext()) {
+                                                       Property curProp = pi.nextProperty();
+                                                       if (!curProp.getName().startsWith("jcr:")
+                                                                       && !curProp.isMultiple())
+                                                               elements.add(curProp);
+                                               }
+
+                                               NodeIterator ni = node.getNodes();
+                                               while (ni.hasNext()) {
+                                                       Node curNode = ni.nextNode();
+                                                       if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
+                                                                       || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
+                                                               ViewSpecificItems vsi = new ViewSpecificItems(
+                                                                               "Bundle dependencies", "", true);
+                                                               vsi.setNode(node);
+                                                               elements.add(vsi);
+                                                               break;
+                                                       }
+                                               }
+                                               return elements.toArray();
+                                       }
+                               } else if (parent instanceof ViewSpecificItems
+                                               && ((ViewSpecificItems) parent).isFolder()) {
+                                       NodeIterator ni = ((ViewSpecificItems) parent).getNode()
+                                                       .getNodes();
+                                       List<Node> elements = new ArrayList<Node>();
+                                       while (ni.hasNext()) {
+                                               Node curNode = ni.nextNode();
+                                               if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
+                                                               || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
+                                                       elements.add(curNode);
+                                               }
+                                       }
+                                       return elements.toArray();
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "Unexpected error getting multiple values property.", e);
+                       }
+                       return result;
+               }
+
+               public boolean hasChildren(Object parent) {
+                       try {
+                               if (parent instanceof Property
+                                               && ((Property) parent).isMultiple()) {
+                                       return true;
+                               } else if (parent instanceof Node && ((Node) parent).hasNodes()
+                                               && ((Node) parent).isNodeType(SLC_BUNDLE_ARTIFACT)) {
+                                       return true;
+                               } else if (parent instanceof ViewSpecificItems
+                                               && ((ViewSpecificItems) parent).isFolder()) {
+                                       return true;
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "Unexpected exception while checking if property is multiple",
+                                               e);
+                       }
+                       return false;
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+               public void dispose() {
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspBrowserPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspBrowserPage.java
new file mode 100644 (file)
index 0000000..e377b53
--- /dev/null
@@ -0,0 +1,283 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+
+import org.argeo.cms.ui.workbench.util.CommandUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
+import org.argeo.slc.repo.RepoConstants;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Expose Maven artifacts of a given workspace as a tree. Artifacts are grouped
+ * by Maven group.
+ */
+public class DistWkspBrowserPage extends FormPage implements DistConstants,
+               RepoConstants {
+       // private final static Log log = LogFactory
+       // .getLog(ArtifactsBrowserPage.class);
+
+       final static String PAGE_ID = "artifactsBrowserPage";
+
+       // Business object
+       private Session session;
+
+       // This page widgets
+       private TreeViewer artifactTreeViewer;
+
+       public DistWkspBrowserPage(FormEditor editor, String title, Session session) {
+               super(editor, PAGE_ID, title);
+               this.session = session;
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm managedForm) {
+               try {
+                       ScrolledForm form = managedForm.getForm();
+                       Composite parent = form.getBody();
+                       parent.setLayout(new FillLayout());
+                       createMavenBrowserPart(parent);
+                       getEditor().getSite().setSelectionProvider(artifactTreeViewer);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot create artifact browser page", e);
+               }
+       }
+
+       /** Aether specific browser for the current workspace */
+       private void createMavenBrowserPart(Composite parent)
+                       throws RepositoryException {
+
+               int style = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL
+                               | SWT.FULL_SELECTION | SWT.BORDER;
+               
+               Tree tree = new Tree(parent, style);
+               createColumn(tree, "Maven browser", SWT.LEFT, 450);
+               tree.setLinesVisible(true);
+               tree.setHeaderVisible(true);
+
+               artifactTreeViewer = new TreeViewer(tree);
+
+               artifactTreeViewer.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = 2648269889876058461L;
+
+                       @Override
+                       public String getText(Object element) {
+                               Node node = (Node) element;
+                               try {
+                                       if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
+                                               return JcrUtils.get((Node) element,
+                                                               SlcNames.SLC_GROUP_BASE_ID);
+                                       else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
+                                               return JcrUtils.get((Node) element,
+                                                               SlcNames.SLC_ARTIFACT_ID);
+                                       else
+                                               return node.getName();
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot browse artifacts", e);
+                               }
+                       }
+
+                       @Override
+                       public Image getImage(Object element) {
+                               Node node = (Node) element;
+                               try {
+
+                                       if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
+                                               return DistImages.IMG_GROUP_BASE;
+                                       else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
+                                               return DistImages.IMG_ARTIFACT_BASE;
+                                       else if (node
+                                                       .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE))
+                                               return DistImages.IMG_ARTIFACT_VERSION_BASE;
+                                       else
+                                               return null;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot get images for artifacts", e);
+                               }
+                       }
+               });
+
+               artifactTreeViewer.setContentProvider(new ITreeContentProvider() {
+                       private static final long serialVersionUID = -2381555428857519326L;
+
+                       public void dispose() {
+                       }
+
+                       public void inputChanged(Viewer viewer, Object oldInput,
+                                       Object newInput) {
+                       }
+
+                       public Object[] getElements(Object inputElement) {
+                               try {
+                                       List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
+                                                       SlcTypes.SLC_GROUP_BASE, SlcNames.SLC_NAME));
+                                       return nodes.toArray();
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot list children Nodes", e);
+                               }
+                       }
+
+                       public Object[] getChildren(Object parentElement) {
+                               // Only 3 levels for the time being
+                               try {
+                                       Node pNode = (Node) parentElement;
+                                       if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)) {
+                                               return getArtifactBase(pNode,
+                                                               SlcTypes.SLC_ARTIFACT_BASE);
+                                       } else if (pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
+                                               return getArtifactBase(pNode,
+                                                               SlcTypes.SLC_ARTIFACT_VERSION_BASE);
+                                       }
+                                       return null;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot list children Nodes", e);
+                               }
+                       }
+
+                       // Helper to get children because current version of Jackrabbit is
+                       // buggy in remote
+                       private Object[] getArtifactBase(Node parent, String nodeType)
+                                       throws RepositoryException {
+                               List<Node> nodes = new ArrayList<Node>();
+                               NodeIterator ni = parent.getNodes();
+                               while (ni.hasNext()) {
+                                       Node node = ni.nextNode();
+                                       if (node.isNodeType(nodeType))
+                                               nodes.add(node);
+                               }
+                               return nodes.toArray();
+                       }
+
+                       public Object getParent(Object element) {
+                               return null;
+                       }
+
+                       public boolean hasChildren(Object element) {
+                               try {
+                                       Node pNode = (Node) element;
+                                       if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)
+                                                       || pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
+                                               // might return true even if there is no "valid" child
+                                               return pNode.hasNodes();
+                                       } else
+                                               return false;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot check children Nodes", e);
+                               }
+                       }
+               });
+
+               artifactTreeViewer.addDoubleClickListener(new DoubleClickListener());
+
+               artifactTreeViewer.setInput("Initialize");
+       }
+
+       private class DoubleClickListener implements IDoubleClickListener {
+
+               public void doubleClick(DoubleClickEvent event) {
+                       Object obj = ((IStructuredSelection) event.getSelection())
+                                       .getFirstElement();
+                       if (obj instanceof Node) {
+                               Node node = (Node) obj;
+                               try {
+                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+                                               NodeIterator nit = node.getNodes();
+                                               while (nit.hasNext()) {
+                                                       Node curr = nit.nextNode();
+                                                       if (curr.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                                               node = curr;
+                                                               break;
+                                                       }
+                                               }
+                                       }
+
+                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                               DistWkspEditorInput dwip = (DistWkspEditorInput) getEditorInput();
+                                               Map<String, String> params = new HashMap<String, String>();
+                                               params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+                                                               dwip.getRepoNodePath());
+                                               params.put(OpenModuleEditor.PARAM_REPO_URI,
+                                                               dwip.getUri());
+                                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+                                                               dwip.getWorkspaceName());
+                                               String path = node.getPath();
+                                               params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
+                                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
+                                       }
+                               } catch (RepositoryException re) {
+                                       throw new SlcException("Cannot get path for node " + node
+                                                       + " while setting parameters for "
+                                                       + "command OpenModuleEditor", re);
+                               }
+
+                       }
+               }
+       }
+
+       private static TreeColumn createColumn(Tree parent, String name, int style,
+                       int width) {
+               TreeColumn result = new TreeColumn(parent, style);
+               result.setText(name);
+               result.setWidth(width);
+               result.setMoveable(true);
+               result.setResizable(true);
+               return result;
+       }
+
+       private NodeIterator listNodes(String nodeType, String orderBy)
+                       throws RepositoryException {
+               QueryManager queryManager = session.getWorkspace().getQueryManager();
+               QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+               final String nodeSelector = "nodes";
+               Selector source = factory.selector(nodeType, nodeSelector);
+
+               Ordering order = factory.ascending(factory.propertyValue(nodeSelector,
+                               orderBy));
+               Ordering[] orderings = { order };
+
+               QueryObjectModel query = factory.createQuery(source, null, orderings,
+                               null);
+
+               QueryResult result = query.execute();
+
+               return result.getNodes();
+       }
+
+       
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspEditorInput.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspEditorInput.java
new file mode 100644 (file)
index 0000000..5929706
--- /dev/null
@@ -0,0 +1,103 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+/** An editor input pointing to a distribution workspace */
+public class DistWkspEditorInput implements IEditorInput, SlcNames {
+
+       // Injected
+       // private RepositoryFactory repositoryFactory;
+       // private Keyring keyring;
+       // private Node repoNode;
+       private String repoNodePath;
+       private String uri;
+
+       // Local variables
+       private String workspaceName;
+
+       // public WorkspaceEditorInput(RepositoryFactory repositoryFactory,
+       // Keyring keyring, Repository localRepository, Node repoNode,
+       // String uri) {
+       // // this.repositoryFactory = repositoryFactory;
+       // // this.keyring = keyring;
+       // this.localRepository = localRepository;
+       // // this.repoNode= repoNode;
+       // this.uri = uri;
+       //
+       // }
+
+       /** uri and workspace name cannot be null */
+       public DistWkspEditorInput(String repoNodePath, String uri,
+                       String workspaceName) {
+               if (workspaceName == null)
+                       throw new SlcException("Workspace name cannot be null");
+               if (uri == null)
+                       throw new SlcException("URI for repository cannot be null");
+               this.repoNodePath = repoNodePath;
+               this.workspaceName = workspaceName;
+               this.uri = uri;
+       }
+
+       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+               return null;
+       }
+
+       public boolean exists() {
+               return true;
+       }
+
+       public ImageDescriptor getImageDescriptor() {
+               return null;
+       }
+
+       // Dummy compulsory methods
+       public String getToolTipText() {
+               return "Editor for workspace " + workspaceName
+                               + " in repository of URI " + uri;
+       }
+
+       public String getName() {
+               return workspaceName + "@" + uri;
+       }
+
+       public IPersistableElement getPersistable() {
+               return null;
+       }
+
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (!(obj instanceof DistWkspEditorInput))
+                       return false;
+
+               DistWkspEditorInput other = (DistWkspEditorInput) obj;
+
+               if (!workspaceName.equals(other.getWorkspaceName()))
+                       return false;
+               if (!uri.equals(other.getUri()))
+                       return false;
+
+               if (repoNodePath == null)
+                       return other.getRepoNodePath() == null;
+               else
+                       return repoNodePath.equals(other.getRepoNodePath());
+       }
+
+       public String getUri() {
+               return uri;
+       }
+
+       public String getWorkspaceName() {
+               return workspaceName;
+       }
+
+       public String getRepoNodePath() {
+               return repoNodePath;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWkspSearchPage.java
new file mode 100644 (file)
index 0000000..1a959a5
--- /dev/null
@@ -0,0 +1,515 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.DynamicOperand;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+import javax.jcr.query.qom.StaticOperand;
+
+import org.argeo.cms.ui.workbench.util.CommandUtils;
+import org.argeo.cms.ui.workbench.util.PrivilegedJob;
+import org.argeo.eclipse.ui.EclipseJcrMonitor;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.commands.DeleteArtifacts;
+import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
+import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+/** Show all bundles contained in a given workspace as filter-able table */
+public class DistWkspSearchPage extends FormPage implements SlcNames {
+       // final private static Log log = LogFactory
+       // .getLog(DistributionOverviewPage.class);
+
+       final static String PAGE_ID = "distributionOverviewPage";
+
+       // Business Objects
+       private Session session;
+
+       // This page widgets
+       private DistWorkspaceEditor formEditor;
+       private FormToolkit tk;
+
+       private DistNodeViewerComparator comparator;
+       private TableViewer viewer;
+
+       // private Composite header;
+       private Text artifactTxt;
+       private final static String FILTER_HELP_MSG = "Filter criterion, separated by a space";
+
+       public DistWkspSearchPage(DistWorkspaceEditor formEditor, String title,
+                       Session session) {
+               super(formEditor, PAGE_ID, title);
+               this.formEditor = formEditor;
+               this.session = session;
+       }
+
+       private void asynchronousRefresh() {
+               RefreshJob job = new RefreshJob(artifactTxt.getText(), viewer,
+                               getSite().getShell().getDisplay());
+               job.setUser(true);
+               job.schedule();
+       }
+
+       private class RefreshJob extends PrivilegedJob {
+               private TableViewer viewer;
+               private String filter;
+               private Display display;
+
+               public RefreshJob(String filter, TableViewer viewer, Display display) {
+                       super("Get bundle list");
+                       this.filter = filter;
+                       this.viewer = viewer;
+                       this.display = display;
+               }
+
+               @Override
+               protected IStatus doRun(IProgressMonitor progressMonitor) {
+                       try {
+                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
+                               monitor.beginTask("Getting bundle list", -1);
+                               final List<Node> result = JcrUtils
+                                               .nodeIteratorToList(listBundleArtifacts(session, filter));
+
+                               display.asyncExec(new Runnable() {
+                                       public void run() {
+                                               viewer.setInput(result);
+                                       }
+                               });
+                       } catch (Exception e) {
+                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
+                                               "Cannot get bundle list", e);
+                       }
+                       return Status.OK_STATUS;
+               }
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm managedForm) {
+               ScrolledForm form = managedForm.getForm();
+               tk = managedForm.getToolkit();
+
+               // Main Layout
+               GridLayout layout = new GridLayout(1, false);
+               Composite body = form.getBody();
+               body.setLayout(layout);
+
+               // Meta info about current workspace
+               Composite header = tk.createComposite(body);
+               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               createHeaderPart(form, header);
+
+               Composite modules = tk.createComposite(body);
+               modules.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               populateModuleSection(modules);
+       }
+
+       private void createHeaderPart(ScrolledForm form, Composite parent) {
+               GridLayout layout = new GridLayout(4, false);
+               // layout.marginWidth = layout.marginHeight = layout.verticalSpacing =
+               // 0;
+               // layout.horizontalSpacing = 2;
+               parent.setLayout(layout);
+
+               String wkspName = ((DistWkspEditorInput) getEditorInput())
+                               .getWorkspaceName();
+               wkspName = wkspName.replaceAll("-", " ");
+               form.setText(wkspName);
+
+               String repoAlias = "";
+               Node repoNode = ((DistWorkspaceEditor) getEditor()).getRepoNode();
+               if (repoNode != null)
+                       try {
+                               repoAlias = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+                                               .getProperty(Property.JCR_TITLE).getString() : repoNode
+                                               .getName();
+                       } catch (RepositoryException e1) {
+                               throw new SlcException("Unable to get repository alias ", e1);
+                       }
+               else
+                       repoAlias = " - ";
+
+               createLT(parent, "Repository alias", repoAlias);
+               createLT(parent, "URI",
+                               ((DistWkspEditorInput) getEditorInput()).getUri());
+       }
+
+       private void populateModuleSection(Composite parent) {
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
+               parent.setLayout(layout);
+
+               Section section = tk.createSection(parent, Section.TITLE_BAR
+                               | Section.DESCRIPTION);
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               section.setText("Artifacts");
+               section.setDescription("Search among all artifacts that are referenced in the current workspace");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               Composite body = tk.createComposite(section);
+               layout = new GridLayout(1, false);
+               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
+               body.setLayout(new GridLayout());
+
+               // Filter
+               Composite filter = tk.createComposite(body);
+               filter.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               createFilterPart(filter);
+
+               // Table
+               Composite tableCmp = tk.createComposite(body);
+               tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               createTableViewer(tableCmp);
+
+               section.setClient(body);
+       }
+
+       /** Build repository request */
+       private NodeIterator listBundleArtifacts(Session session, String filter)
+                       throws RepositoryException {
+               QueryManager queryManager = session.getWorkspace().getQueryManager();
+               QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+               final String bundleArtifactsSelector = "bundleArtifacts";
+               Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
+                               bundleArtifactsSelector);
+
+               // Create a dynamic operand for each property on which we want to filter
+               DynamicOperand symbNameDO = factory.propertyValue(
+                               source.getSelectorName(), SlcNames.SLC_SYMBOLIC_NAME);
+               DynamicOperand versionDO = factory.propertyValue(
+                               source.getSelectorName(), SlcNames.SLC_BUNDLE_VERSION);
+               DynamicOperand nameDO = factory.propertyValue(source.getSelectorName(),
+                               DistConstants.SLC_BUNDLE_NAME);
+
+               // Default Constraint: no source artifacts
+               Constraint defaultC = factory.not(factory.comparison(
+                               symbNameDO,
+                               QueryObjectModelFactory.JCR_OPERATOR_LIKE,
+                               factory.literal(session.getValueFactory().createValue(
+                                               "%.source"))));
+
+               // Build constraints based the textArea content
+               if (filter != null && !"".equals(filter.trim())) {
+                       // Parse the String
+                       String[] strs = filter.trim().split(" ");
+                       for (String token : strs) {
+                               token = token.replace('*', '%');
+                               StaticOperand so = factory.literal(session.getValueFactory()
+                                               .createValue("%" + token + "%"));
+
+                               Constraint currC = factory.comparison(symbNameDO,
+                                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
+                               currC = factory.or(currC, factory.comparison(versionDO,
+                                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+                               currC = factory.or(currC, factory.comparison(nameDO,
+                                               QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+
+                               defaultC = factory.and(defaultC, currC);
+                       }
+               }
+
+               Ordering order = factory.descending(factory.propertyValue(
+                               bundleArtifactsSelector, SlcNames.SLC_BUNDLE_VERSION));
+               Ordering order2 = factory.ascending(factory.propertyValue(
+                               bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
+               Ordering[] orderings = { order, order2 };
+
+               QueryObjectModel query = factory.createQuery(source, defaultC,
+                               orderings, null);
+
+               QueryResult result = query.execute();
+               return result.getNodes();
+
+       }
+
+       private Text createLT(Composite parent, String labelValue, String textValue) {
+               Label label = new Label(parent, SWT.RIGHT);
+               label.setText(labelValue);
+               // label.setFont(EclipseUiUtils.getBoldFont(parent));
+               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+               // Add a trailing space to workaround a display glitch in RAP 1.3
+               Text text = new Text(parent, SWT.LEFT); // | SWT.BORDER
+               text.setText(textValue + " ");
+               text.setEditable(false);
+               return text;
+       }
+
+       private void createFilterPart(Composite parent) {
+               GridLayout layout = new GridLayout();
+               layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
+               layout.horizontalSpacing = 5;
+               parent.setLayout(layout);
+
+               // Text Area to filter
+               artifactTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
+                               | SWT.SEARCH | SWT.CANCEL);
+               artifactTxt.setMessage(FILTER_HELP_MSG);
+               GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
+               gd.grabExcessHorizontalSpace = true;
+               artifactTxt.setLayoutData(gd);
+               artifactTxt.addModifyListener(new ModifyListener() {
+                       private static final long serialVersionUID = -2422321852703208573L;
+
+                       public void modifyText(ModifyEvent event) {
+                               if ("".equals(artifactTxt.getText().trim()))
+                                       asynchronousRefresh();
+                               else
+                                       refreshFilteredList();
+                       }
+               });
+       }
+
+       private void refreshFilteredList() {
+               List<Node> nodes;
+               try {
+                       nodes = JcrUtils.nodeIteratorToList(listBundleArtifacts(session,
+                                       artifactTxt.getText()));
+                       viewer.setInput(nodes);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unable to list bundles", e);
+               }
+       }
+
+       private void createTableViewer(Composite parent) {
+               parent.setLayout(new FillLayout());
+               // helpers to enable sorting by column
+               List<String> propertiesList = new ArrayList<String>();
+               List<Integer> propertyTypesList = new ArrayList<Integer>();
+
+               // Define the TableViewer
+               viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+               // Name
+               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(300);
+               col.getColumn().setText("Name");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = -760226161605987538L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element,
+                                               DistConstants.SLC_BUNDLE_NAME);
+                       }
+               });
+               col.getColumn().addSelectionListener(getSelectionAdapter(0));
+               propertiesList.add(DistConstants.SLC_BUNDLE_NAME);
+               propertyTypesList.add(PropertyType.STRING);
+
+               // Symbolic name
+               col = new TableViewerColumn(viewer, SWT.V_SCROLL);
+               col.getColumn().setWidth(300);
+               col.getColumn().setText("Symbolic Name");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = 4431447542158431355L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
+                       }
+               });
+               col.getColumn().addSelectionListener(getSelectionAdapter(1));
+               propertiesList.add(SLC_SYMBOLIC_NAME);
+               propertyTypesList.add(PropertyType.STRING);
+
+               // Version
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(130);
+               col.getColumn().setText("Version");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = -5616215547236158504L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
+                       }
+               });
+               col.getColumn().addSelectionListener(getSelectionAdapter(2));
+               propertiesList.add(SLC_BUNDLE_VERSION);
+               propertyTypesList.add(DistNodeViewerComparator.VERSION_TYPE);
+
+               final Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+
+               viewer.setContentProvider(new DistributionsContentProvider());
+               getSite().setSelectionProvider(viewer);
+
+               comparator = new DistNodeViewerComparator(2,
+                               DistNodeViewerComparator.ASCENDING, propertiesList,
+                               propertyTypesList);
+               viewer.setComparator(comparator);
+
+               // Context Menu
+               MenuManager menuManager = new MenuManager();
+               Menu menu = menuManager.createContextMenu(viewer.getTable());
+               menuManager.addMenuListener(new IMenuListener() {
+                       private static final long serialVersionUID = -3886983092940055195L;
+
+                       public void menuAboutToShow(IMenuManager manager) {
+                               contextMenuAboutToShow(manager);
+                       }
+               });
+               viewer.getTable().setMenu(menu);
+               getSite().registerContextMenu(menuManager, viewer);
+
+               // Double click
+               viewer.addDoubleClickListener(new DoubleClickListener());
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTable().setFocus();
+       }
+
+       /** force refresh of the artifact list */
+       public void refresh() {
+               asynchronousRefresh();
+       }
+
+       /** Programmatically configure the context menu */
+       protected void contextMenuAboutToShow(IMenuManager menuManager) {
+               IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
+                               .getActiveWorkbenchWindow();
+               // Build conditions
+               // Delete selected artifacts
+               CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
+                               DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
+                               true);
+       }
+
+       private SelectionAdapter getSelectionAdapter(final int index) {
+               SelectionAdapter selectionAdapter = new SelectionAdapter() {
+                       private static final long serialVersionUID = 5515884441510882460L;
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               Table table = viewer.getTable();
+                               comparator.setColumn(index);
+                               int dir = table.getSortDirection();
+                               if (table.getSortColumn() == table.getColumn(index)) {
+                                       dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
+                               } else {
+                                       dir = SWT.DOWN;
+                               }
+                               table.setSortDirection(dir);
+                               table.setSortColumn(table.getColumn(index));
+                               viewer.refresh();
+                       }
+               };
+               return selectionAdapter;
+       }
+
+       /* LOCAL CLASSES */
+       private class DistributionsContentProvider implements
+                       IStructuredContentProvider {
+               private static final long serialVersionUID = -635451814876234147L;
+
+               // we keep a cache of the Nodes in the content provider to be able to
+               // manage long request
+               private List<Node> nodes;
+
+               public void dispose() {
+               }
+
+               // We expect a list of nodes as a new input
+               @SuppressWarnings("unchecked")
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       nodes = (List<Node>) newInput;
+               }
+
+               public Object[] getElements(Object arg0) {
+                       return nodes.toArray();
+               }
+       }
+
+       private class DoubleClickListener implements IDoubleClickListener {
+
+               public void doubleClick(DoubleClickEvent event) {
+                       Object obj = ((IStructuredSelection) event.getSelection())
+                                       .getFirstElement();
+                       if (obj instanceof Node) {
+                               Node node = (Node) obj;
+                               try {
+                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                               DistWkspEditorInput dwip = (DistWkspEditorInput) formEditor
+                                                               .getEditorInput();
+                                               Map<String, String> params = new HashMap<String, String>();
+                                               params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+                                                               dwip.getRepoNodePath());
+                                               params.put(OpenModuleEditor.PARAM_REPO_URI,
+                                                               dwip.getUri());
+                                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+                                                               dwip.getWorkspaceName());
+                                               String path = node.getPath();
+                                               params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
+                                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
+                                       }
+                               } catch (RepositoryException re) {
+                                       throw new SlcException("Cannot get path for node " + node
+                                                       + " while setting parameters for "
+                                                       + "command OpenModuleEditor", re);
+                               }
+
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWorkspaceEditor.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/DistWorkspaceEditor.java
new file mode 100644 (file)
index 0000000..3f8f98d
--- /dev/null
@@ -0,0 +1,115 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.api.security.Keyring;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/** Browse, analyse and modify a workspace containing software distributions */
+public class DistWorkspaceEditor extends FormEditor implements SlcNames {
+       private static final long serialVersionUID = 5373719580281643675L;
+
+       // private final static Log log =
+       // LogFactory.getLog(DistributionEditor.class);
+       public final static String ID = DistPlugin.PLUGIN_ID + ".distWorkspaceEditor";
+
+       /* DEPENDENCY INJECTION */
+       private RepositoryFactory repositoryFactory;
+       private Repository localRepository;
+       private Keyring keyring;
+
+       // Business objects
+       private Node repoNode;
+       // Session that provides the node in the home of the local repository
+       private Session localSession = null;
+       // The business Session on optionally remote repository
+       private Session businessSession;
+       private DistWkspEditorInput editorInput;
+
+       @Override
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               editorInput = (DistWkspEditorInput) input;
+               try {
+                       localSession = localRepository.login();
+                       if (editorInput.getRepoNodePath() != null
+                                       && localSession.nodeExists(editorInput.getRepoNodePath()))
+                               repoNode = localSession.getNode(editorInput.getRepoNodePath());
+
+                       businessSession = RepoUtils.getRemoteSession(
+                                       repositoryFactory, keyring, repoNode, editorInput.getUri(),
+                                       editorInput.getWorkspaceName());
+               } catch (RepositoryException e) {
+                       throw new PartInitException("Cannot log to workspace "
+                                       + editorInput.getName(), e);
+               }
+               setPartName(editorInput.getWorkspaceName());
+               super.init(site, input);
+       }
+
+       @Override
+       protected void addPages() {
+               try {
+                       addPage(new DistWkspSearchPage(this, "Details ", businessSession));
+                       addPage(new DistWkspBrowserPage(this, "Maven ", businessSession));
+                       addPage(new WkspCategoryBaseListPage(this, "Groups ",
+                                       businessSession));
+               } catch (PartInitException e) {
+                       throw new SlcException("Cannot add distribution editor pages", e);
+               }
+       }
+
+       @Override
+       public void doSave(IProgressMonitor arg0) {
+       }
+
+       @Override
+       public void dispose() {
+               JcrUtils.logoutQuietly(businessSession);
+               JcrUtils.logoutQuietly(localSession);
+               super.dispose();
+       }
+
+       @Override
+       public void doSaveAs() {
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return false;
+       }
+
+       protected Node getRepoNode() {
+               return repoNode;
+       }
+
+       protected Session getSession() {
+               return businessSession;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+
+       public void setLocalRepository(Repository localRepository) {
+               this.localRepository = localRepository;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionDetailPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionDetailPage.java
new file mode 100644 (file)
index 0000000..0b9f9a3
--- /dev/null
@@ -0,0 +1,116 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+/** Show the details for a given bundle. */
+public class ModularDistVersionDetailPage extends FormPage implements SlcNames {
+
+       final static String PAGE_ID = "ModularDistVersionDetailPage";
+
+       // Business Objects
+       private Node modularDistVersion;
+
+       // This page widgets
+       private FormToolkit tk;
+
+       public ModularDistVersionDetailPage(FormEditor formEditor, String title,
+                       Node modularDistVersion) {
+               super(formEditor, PAGE_ID, title);
+               this.modularDistVersion = modularDistVersion;
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm managedForm) {
+               // General settings for this page
+               ScrolledForm form = managedForm.getForm();
+               tk = managedForm.getToolkit();
+               Composite body = form.getBody();
+
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = 5;
+               layout.marginRight = 15;
+               layout.verticalSpacing = 0;
+               body.setLayout(layout);
+               try {
+                       form.setText(modularDistVersion.hasProperty(SLC_NAME) ? modularDistVersion
+                                       .getProperty(SLC_NAME).getString() : "");
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to get slc:name for node "
+                                       + modularDistVersion, re);
+               }
+
+               // Main layout
+               Composite mavenSnipet = tk.createComposite(body);
+               mavenSnipet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               populateMavenSnippetPart(mavenSnipet);
+       }
+
+       private void populateMavenSnippetPart(Composite parent) {
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
+               parent.setLayout(layout);
+
+               Section section = tk.createSection(parent, Section.TITLE_BAR
+                               | Section.DESCRIPTION);
+               section.setText("Maven");
+               section.setDescription("In order to rely on the versions defined by this distribution, "
+                               + "add the below tag to the dependency management of your parent pom.");
+               section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               Text snippetTxt = createMavenSnippet(section);
+               section.setClient(snippetTxt);
+       }
+
+       // /////////////////////
+       // HELPERS
+       /** Creates a text area with corresponding maven snippet */
+       private Text createMavenSnippet(Composite parent) {
+               Text mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               gd.heightHint = 100;
+               mavenSnippet.setLayoutData(gd);
+               mavenSnippet.setText(generateXmlSnippet());
+               mavenSnippet.setEditable(false);
+               return mavenSnippet;
+       }
+
+       private String generateXmlSnippet() {
+               try {
+                       StringBuffer sb = new StringBuffer();
+                       sb.append("<dependency>\n");
+                       sb.append("\t<groupId>");
+                       sb.append(modularDistVersion.getProperty(SLC_GROUP_ID).getString());
+                       sb.append("</groupId>\n");
+                       sb.append("\t<artifactId>");
+                       sb.append(modularDistVersion.getProperty(SLC_ARTIFACT_ID)
+                                       .getString());
+                       sb.append("</artifactId>\n");
+                       sb.append("\t<version>");
+                       sb.append(modularDistVersion.getProperty(SLC_ARTIFACT_VERSION)
+                                       .getString());
+                       sb.append("</version>\n");
+                       sb.append("\t<type>pom</type>\n");
+                       sb.append("\t<scope>import</scope>\n");
+                       sb.append("</dependency>");
+                       return sb.toString();
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "unexpected error while generating maven snippet");
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionEditor.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionEditor.java
new file mode 100644 (file)
index 0000000..cdb15ea
--- /dev/null
@@ -0,0 +1,60 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * Manage a modular distribution version contained in a specific workspace of a
+ * repository
+ */
+public class ModularDistVersionEditor extends ArtifactVersionEditor {
+       private static final long serialVersionUID = -2223542780164288554L;
+
+       // private final static Log log =
+       // LogFactory.getLog(ModularDistVersionEditor.class);
+       public final static String ID = DistPlugin.PLUGIN_ID + ".modularDistVersionEditor";
+
+       @Override
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+               super.init(site, input);
+       }
+
+       @Override
+       protected void addPages() {
+               setPartName(getFormattedName());
+               try {
+                       addPage(new ModularDistVersionOverviewPage(this, "Modules ",
+                                       getArtifact()));
+                       addPage(new RunInOsgiPage(this, "Run as OSGi ", getArtifact()));
+                       addPage(new ModularDistVersionDetailPage(this, "Details",
+                                       getArtifact()));
+               } catch (PartInitException e) {
+                       throw new SlcException("Cannot add distribution editor pages", e);
+               }
+       }
+
+       protected String getFormattedName() {
+               try {
+                       String partName = null;
+                       if (getArtifact().hasProperty(SLC_NAME))
+                               partName = getArtifact().getProperty(SLC_NAME).getString();
+                       else
+                               partName = getArtifact().getName();
+
+                       if (partName.length() > 10) {
+                               partName = "..." + partName.substring(partName.length() - 10);
+                       }
+                       return partName;
+               } catch (RepositoryException re) {
+                       throw new SlcException("unable to get slc:name property for node "
+                                       + getArtifact(), re);
+               }
+       }
+
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionOverviewPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModularDistVersionOverviewPage.java
new file mode 100644 (file)
index 0000000..d3ab885
--- /dev/null
@@ -0,0 +1,628 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.DynamicOperand;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+import javax.jcr.query.qom.StaticOperand;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.ui.workbench.util.CommandUtils;
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
+import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
+import org.argeo.slc.client.ui.dist.utils.HyperlinkAdapter;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.slc.repo.maven.MavenConventionsUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Show all modules contained in a given modular distribution as filter-able
+ * table
+ */
+public class ModularDistVersionOverviewPage extends FormPage implements
+               SlcNames {
+
+       private final static Log log = LogFactory
+                       .getLog(ModularDistVersionOverviewPage.class);
+
+       final static String PAGE_ID = "ModularDistVersionOverviewPage";
+
+       // Business Objects
+       private Node modularDistribution;
+       // private Node modularDistributionBase;
+
+       // This page widgets
+       private DistNodeViewerComparator comparator;
+       private TableViewer viewer;
+       private FormToolkit tk;
+       private Text filterTxt;
+       private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
+
+       public ModularDistVersionOverviewPage(FormEditor formEditor, String title,
+                       Node modularDistribution) {
+               super(formEditor, PAGE_ID, title);
+               this.modularDistribution = modularDistribution;
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm managedForm) {
+               // General settings for this page
+               ScrolledForm form = managedForm.getForm();
+               tk = managedForm.getToolkit();
+               Composite body = form.getBody();
+
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = 5;
+               layout.marginRight = 15;
+               layout.verticalSpacing = 0;
+               body.setLayout(layout);
+               try {
+                       form.setText(modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
+                                       .getProperty(SlcNames.SLC_NAME).getString() : "");
+                       form.setMessage(
+                                       modularDistribution
+                                                       .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? modularDistribution
+                                                       .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
+                                                       .getString() : "", IMessageProvider.NONE);
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to get bundle name for node "
+                                       + modularDistribution, re);
+               }
+
+               // Main layout
+               Composite header = tk.createComposite(body);
+               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               populateHeaderPart(header);
+
+               Composite moduleTablePart = tk.createComposite(body);
+               moduleTablePart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+                               true));
+               populateModuleTablePart(moduleTablePart);
+       }
+
+       private void populateHeaderPart(Composite parent) {
+               GridLayout layout = new GridLayout(6, false);
+               layout.horizontalSpacing = 10;
+               parent.setLayout(layout);
+               try {
+                       // 1st Line: Category, name version
+                       createLT(
+                                       parent,
+                                       "Category",
+                                       modularDistribution.hasProperty(SlcNames.SLC_CATEGORY) ? modularDistribution
+                                                       .getProperty(SlcNames.SLC_CATEGORY).getString()
+                                                       : "");
+                       createLT(
+                                       parent,
+                                       "Name",
+                                       modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
+                                                       .getProperty(SlcNames.SLC_NAME).getString() : "");
+                       createLT(
+                                       parent,
+                                       "Version",
+                                       modularDistribution.hasProperty(SlcNames.SLC_VERSION) ? modularDistribution
+                                                       .getProperty(SlcNames.SLC_VERSION).getString() : "");
+
+                       // 2nd Line: Vendor, licence, sources
+                       createLT(
+                                       parent,
+                                       "Vendor",
+                                       modularDistribution
+                                                       .hasProperty(DistConstants.SLC_BUNDLE_VENDOR) ? modularDistribution
+                                                       .getProperty(DistConstants.SLC_BUNDLE_VENDOR)
+                                                       .getString() : "N/A");
+
+                       createHyperlink(parent, "Licence", DistConstants.SLC_BUNDLE_LICENCE);
+                       addSourceSourcesLink(parent);
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to get bundle name for node "
+                                       + modularDistribution, re);
+               }
+
+       }
+
+       private Text createLT(Composite parent, String labelValue, String textValue) {
+               Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
+               // label.setFont(EclipseUiUtils.getBoldFont(parent));
+               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+               // Add a trailing space to workaround a display glitch in RAP 1.3
+               Text text = new Text(parent, SWT.LEFT);
+               text.setText(textValue + " ");
+               text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               text.setEditable(false);
+               return text;
+       }
+
+       private void createHyperlink(Composite parent, String label,
+                       String jcrPropName) throws RepositoryException {
+               tk.createLabel(parent, label, SWT.NONE);
+               if (modularDistribution.hasProperty(jcrPropName)) {
+                       final Hyperlink link = tk.createHyperlink(parent,
+                                       modularDistribution.getProperty(jcrPropName).getString(),
+                                       SWT.NONE);
+                       link.addHyperlinkListener(new HyperlinkAdapter() {
+                               @Override
+                               public void linkActivated(HyperlinkEvent e) {
+                                       try {
+                                               IWorkbenchBrowserSupport browserSupport = PlatformUI
+                                                               .getWorkbench().getBrowserSupport();
+                                               IWebBrowser browser = browserSupport
+                                                               .createBrowser(
+                                                                               IWorkbenchBrowserSupport.LOCATION_BAR
+                                                                                               | IWorkbenchBrowserSupport.NAVIGATION_BAR,
+                                                                               "SLC Distribution browser",
+                                                                               "SLC Distribution browser",
+                                                                               "A tool tip");
+                                               browser.openURL(new URL(link.getText()));
+                                       } catch (Exception ex) {
+                                               throw new SlcException("error opening browser", ex); //$NON-NLS-1$
+                                       }
+                               }
+                       });
+               } else
+                       tk.createLabel(parent, "N/A", SWT.NONE);
+       }
+
+       // helper to check if sources are available
+       private void addSourceSourcesLink(Composite parent) {
+               try {
+                       String srcPath = RepoUtils.relatedPdeSourcePath(
+                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH,
+                                       modularDistribution);
+                       if (!modularDistribution.getSession().nodeExists(srcPath)) {
+                               createLT(parent, "Sources", "N/A");
+                       } else {
+                               final Node sourcesNode = modularDistribution.getSession()
+                                               .getNode(srcPath);
+
+                               String srcName = null;
+                               if (sourcesNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME))
+                                       srcName = sourcesNode.getProperty(
+                                                       SlcNames.SLC_SYMBOLIC_NAME).getString();
+                               else
+                                       srcName = sourcesNode.getName();
+                               Label label = tk.createLabel(parent, "Sources", SWT.RIGHT);
+                               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
+                                               false));
+                               Hyperlink link = tk.createHyperlink(parent, srcName, SWT.NONE);
+                               link.addHyperlinkListener(new OpenFileLinkListener(sourcesNode
+                                               .getPath()));
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unable to configure sources link for "
+                                       + modularDistribution, e);
+               }
+       }
+
+       private class OpenFileLinkListener extends HyperlinkAdapter {
+               final private String path;
+
+               public OpenFileLinkListener(String path) {
+                       this.path = path;
+               }
+
+               @Override
+               public void linkActivated(HyperlinkEvent e) {
+                       log.warn("File download must be implemented. Cannot provide access to "
+                                       + path);
+
+                       // try {
+                       // ModuleEditorInput editorInput = (ModuleEditorInput)
+                       // getEditorInput();
+                       // Map<String, String> params = new HashMap<String, String>();
+                       // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
+                       // editorInput.getRepoNodePath());
+                       // params.put(OpenJcrFile.PARAM_REPO_URI, editorInput.getUri());
+                       // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
+                       // editorInput.getWorkspaceName());
+                       // params.put(OpenJcrFile.PARAM_FILE_PATH, path);
+                       //
+                       // String cmdId = (new OpenJcrFileCmdId()).getCmdId();
+                       // CommandUtils.callCommand(cmdId, params);
+                       // } catch (Exception ex) {
+                       //                              throw new SlcException("error opening browser", ex); //$NON-NLS-1$
+                       // }
+               }
+       }
+
+       private void populateModuleTablePart(Composite parent) {
+               GridLayout layout = new GridLayout(1, false);
+               layout.marginWidth = layout.horizontalSpacing = 0;
+               layout.verticalSpacing = 5;
+               layout.marginTop = 15;
+               parent.setLayout(layout);
+               // A sub title
+               Label label = tk.createLabel(parent,
+                               "Modules included in the current distribution", SWT.NONE);
+               label.setFont(EclipseUiUtils.getBoldFont(parent));
+
+               // Add the filter section
+               Composite filterPart = tk.createComposite(parent);
+               filterPart.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               createFilterPart(filterPart);
+
+               // Add the table
+               Composite tablePart = tk.createComposite(parent);
+               tablePart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               createTableViewer(tablePart);
+               // populate it on first pass.
+               refresh();
+       }
+
+       private void createFilterPart(Composite parent) {
+               GridLayout layout = new GridLayout(2, false);
+               layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
+               layout.horizontalSpacing = 5;
+               parent.setLayout(layout);
+
+               // Text Area to filter
+               filterTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
+                               | SWT.SEARCH | SWT.CANCEL);
+               filterTxt.setMessage(FILTER_HELP_MSG);
+               filterTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+               filterTxt.addModifyListener(new ModifyListener() {
+                       private static final long serialVersionUID = -276152321986407726L;
+
+                       public void modifyText(ModifyEvent event) {
+                               refresh();
+                       }
+               });
+
+               Button resetBtn = tk.createButton(parent, null, SWT.PUSH);
+               resetBtn.setImage(DistImages.IMG_CLEAR);
+               resetBtn.addSelectionListener(new SelectionAdapter() {
+                       private static final long serialVersionUID = -3549303742841670919L;
+
+                       public void widgetSelected(SelectionEvent e) {
+                               filterTxt.setText("");
+                               filterTxt.setMessage(FILTER_HELP_MSG);
+                       }
+               });
+       }
+
+       private void createTableViewer(Composite parent) {
+               parent.setLayout(new FillLayout());
+               // helpers to enable sorting by column
+               List<String> propertiesList = new ArrayList<String>();
+               List<Integer> propertyTypesList = new ArrayList<Integer>();
+
+               // Define the TableViewer
+               viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+               // Name
+               TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(220);
+               col.getColumn().setText("Category");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = 5875398301711336875L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SlcNames.SLC_CATEGORY);
+                       }
+               });
+               col.getColumn().addSelectionListener(getSelectionAdapter(0));
+               propertiesList.add(SlcNames.SLC_CATEGORY);
+               propertyTypesList.add(PropertyType.STRING);
+
+               // Symbolic name
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(220);
+               col.getColumn().setText("Name");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = 3880240676256465072L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_NAME);
+                       }
+               });
+               col.getColumn().addSelectionListener(getSelectionAdapter(1));
+               propertiesList.add(SLC_NAME);
+               propertyTypesList.add(PropertyType.STRING);
+
+               // Version
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(160);
+               col.getColumn().setText("Version");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = -4706438113850571784L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_VERSION);
+                       }
+               });
+               col.getColumn().addSelectionListener(getSelectionAdapter(2));
+               propertiesList.add(SLC_VERSION);
+               propertyTypesList.add(DistNodeViewerComparator.VERSION_TYPE);
+
+               // Exists in workspace
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(160);
+               col.getColumn().setText("Exists in workspace");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = 8190063212920414300L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return getRealizedModule((Node) element) != null ? "Yes" : "No";
+                               // return JcrUtils.get((Node) element, SLC_VERSION);
+                       }
+               });
+               // col.getColumn().addSelectionListener(getSelectionAdapter(2));
+               // propertiesList.add(SLC_VERSION);
+               // propertyTypesList.add(PropertyType.STRING);
+
+               final Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+
+               viewer.setContentProvider(new DistributionsContentProvider());
+               getSite().setSelectionProvider(viewer);
+
+               comparator = new DistNodeViewerComparator(2,
+                               DistNodeViewerComparator.ASCENDING, propertiesList,
+                               propertyTypesList);
+               viewer.setComparator(comparator);
+
+               // // Context Menu
+               // MenuManager menuManager = new MenuManager();
+               // Menu menu = menuManager.createContextMenu(viewer.getTable());
+               // menuManager.addMenuListener(new IMenuListener() {
+               // public void menuAboutToShow(IMenuManager manager) {
+               // contextMenuAboutToShow(manager);
+               // }
+               // });
+               // viewer.getTable().setMenu(menu);
+               // getSite().registerContextMenu(menuManager, viewer);
+
+               // Double click
+               viewer.addDoubleClickListener(new DoubleClickListener());
+       }
+
+       private Node getRealizedModule(Node moduleCoordinates) {
+               try {
+                       String category = JcrUtils.get(moduleCoordinates, SLC_CATEGORY);
+                       String name = JcrUtils.get(moduleCoordinates, SLC_NAME);
+                       String version = JcrUtils.get(moduleCoordinates, SLC_VERSION);
+                       Artifact artifact = new DefaultArtifact(category + ":" + name + ":"
+                                       + version);
+                       String parentPath = MavenConventionsUtils.artifactParentPath(
+                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, artifact);
+
+                       Session session = modularDistribution.getSession();
+                       if (session.nodeExists(parentPath)) {
+                               Node parent = session.getNode(parentPath);
+                               NodeIterator nit = parent.getNodes();
+                               while (nit.hasNext()) {
+                                       Node currN = nit.nextNode();
+                                       if (currN.isNodeType(SlcTypes.SLC_ARTIFACT))
+                                               return currN;
+                               }
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "unable to retrieve realized module with coordinates "
+                                                       + moduleCoordinates, re);
+               }
+               return null;
+       }
+
+       private void refresh() {
+               final List<Node> result = JcrUtils
+                               .nodeIteratorToList(listBundleArtifacts());
+               viewer.setInput(result);
+       }
+
+       /** Build repository request */
+       private NodeIterator listBundleArtifacts() {
+               try {
+                       Session session = modularDistribution.getSession();
+                       QueryManager queryManager = session.getWorkspace()
+                                       .getQueryManager();
+                       QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+                       Selector source = factory.selector(SlcTypes.SLC_MODULE_COORDINATES,
+                                       SlcTypes.SLC_MODULE_COORDINATES);
+
+                       // Create a dynamic operand for each property on which we want to
+                       // filter
+                       DynamicOperand catDO = factory.propertyValue(
+                                       source.getSelectorName(), SlcNames.SLC_CATEGORY);
+                       DynamicOperand nameDO = factory.propertyValue(
+                                       source.getSelectorName(), SlcNames.SLC_NAME);
+                       DynamicOperand versionDO = factory.propertyValue(
+                                       source.getSelectorName(), SlcNames.SLC_VERSION);
+
+                       String path = modularDistribution.getPath() + "/"
+                                       + SlcNames.SLC_MODULES;
+
+                       // Default Constraint: correct children
+                       Constraint defaultC = factory.descendantNode(
+                                       source.getSelectorName(), path);
+
+                       String filter = filterTxt.getText();
+
+                       // Build constraints based the textArea content
+                       if (filter != null && !"".equals(filter.trim())) {
+                               // Parse the String
+                               String[] strs = filter.trim().split(" ");
+                               for (String token : strs) {
+                                       token = token.replace('*', '%');
+                                       StaticOperand so = factory.literal(session
+                                                       .getValueFactory().createValue("%" + token + "%"));
+
+                                       Constraint currC = factory.comparison(catDO,
+                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
+                                       currC = factory.or(currC, factory.comparison(versionDO,
+                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+                                       currC = factory.or(currC, factory.comparison(nameDO,
+                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+
+                                       defaultC = factory.and(defaultC, currC);
+                               }
+                       }
+
+                       QueryObjectModel query = factory.createQuery(source, defaultC,
+                                       null, null);
+                       QueryResult result = query.execute();
+                       return result.getNodes();
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to refresh module list for node "
+                                       + modularDistribution, re);
+               }
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTable().setFocus();
+       }
+
+       // /** Programmatically configure the context menu */
+       // protected void contextMenuAboutToShow(IMenuManager menuManager) {
+       // IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
+       // .getActiveWorkbenchWindow();
+       // // Build conditions
+       // // Delete selected artifacts
+       // // CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
+       // // DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
+       // // true);
+       // }
+
+       private SelectionAdapter getSelectionAdapter(final int index) {
+               SelectionAdapter selectionAdapter = new SelectionAdapter() {
+                       private static final long serialVersionUID = 1260801795934660840L;
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               Table table = viewer.getTable();
+                               comparator.setColumn(index);
+                               int dir = table.getSortDirection();
+                               if (table.getSortColumn() == table.getColumn(index)) {
+                                       dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
+                               } else {
+                                       dir = SWT.DOWN;
+                               }
+                               table.setSortDirection(dir);
+                               table.setSortColumn(table.getColumn(index));
+                               viewer.refresh();
+                       }
+               };
+               return selectionAdapter;
+       }
+
+       /* LOCAL CLASSES */
+       private class DistributionsContentProvider implements
+                       IStructuredContentProvider {
+               private static final long serialVersionUID = 8385338190908823791L;
+               // we keep a cache of the Nodes in the content provider to be able to
+               // manage long request
+               private List<Node> nodes;
+
+               public void dispose() {
+               }
+
+               // We expect a list of nodes as a new input
+               @SuppressWarnings("unchecked")
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       nodes = (List<Node>) newInput;
+               }
+
+               public Object[] getElements(Object arg0) {
+                       return nodes.toArray();
+               }
+       }
+
+       private class DoubleClickListener implements IDoubleClickListener {
+
+               public void doubleClick(DoubleClickEvent event) {
+                       Object obj = ((IStructuredSelection) event.getSelection())
+                                       .getFirstElement();
+                       if (obj instanceof Node) {
+                               Node node = (Node) obj;
+                               try {
+                                       if (node.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
+                                               Node realizedModule = getRealizedModule(node);
+                                               if (realizedModule != null) {
+                                                       ModuleEditorInput dwip = (ModuleEditorInput) getEditorInput();
+                                                       Map<String, String> params = new HashMap<String, String>();
+                                                       params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+                                                                       dwip.getRepoNodePath());
+                                                       params.put(OpenModuleEditor.PARAM_REPO_URI,
+                                                                       dwip.getUri());
+                                                       params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+                                                                       dwip.getWorkspaceName());
+                                                       String path = realizedModule.getPath();
+                                                       params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
+                                                       CommandUtils.callCommand(OpenModuleEditor.ID,
+                                                                       params);
+                                               }
+                                       }
+                               } catch (RepositoryException re) {
+                                       throw new SlcException("Cannot get path for node " + node
+                                                       + " while setting parameters for "
+                                                       + "command OpenModuleEditor", re);
+                               }
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java
new file mode 100644 (file)
index 0000000..52d7a20
--- /dev/null
@@ -0,0 +1,103 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+/** Editor input for a JCR node object in a multi-repository environment */
+public class ModuleEditorInput implements IEditorInput, SlcNames {
+
+       // Define relevant workspace on a given repository
+       private String repoNodePath;
+       private String uri;
+       private String workspaceName;
+       private String modulePath;
+
+       public ModuleEditorInput(String repoNodePath, String uri,
+                       String workspaceName, String artifactPath) {
+               if (workspaceName == null)
+                       throw new SlcException("Workspace name cannot be null");
+               if (uri == null && repoNodePath == null)
+                       throw new SlcException("Define at least one of the 2 "
+                                       + "parameters URI or Repo Node Path");
+               if (artifactPath == null)
+                       throw new SlcException("Module path cannot be null");
+               this.repoNodePath = repoNodePath;
+               this.uri = uri;
+               this.workspaceName = workspaceName;
+               this.modulePath = artifactPath;
+       }
+
+       public String getModulePath() {
+               return modulePath;
+       }
+
+       public String getWorkspaceName() {
+               return workspaceName;
+       }
+
+       public String getRepoNodePath() {
+               return repoNodePath;
+       }
+
+       public String getUri() {
+               return uri;
+       }
+
+       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+               return null;
+       }
+
+       public boolean exists() {
+               return true;
+       }
+
+       public ImageDescriptor getImageDescriptor() {
+               return null;
+       }
+
+       // Dummy compulsory methods
+       public String getToolTipText() {
+               return getModulePath();
+       }
+
+       public String getName() {
+               return JcrUtils.lastPathElement(modulePath);
+       }
+
+       public IPersistableElement getPersistable() {
+               return null;
+       }
+
+       /**
+        * equals method based on coordinates
+        */
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+
+               ModuleEditorInput other = (ModuleEditorInput) obj;
+
+               if (!modulePath.equals(other.getModulePath()))
+                       return false;
+               if (!workspaceName.equals(other.getWorkspaceName()))
+                       return false;
+
+               if (uri == null && other.getUri() != null
+                               || !uri.equals(other.getUri()))
+                       return false;
+
+               if (repoNodePath == null && other.getRepoNodePath() != null
+                               || !repoNodePath.equals(other.getRepoNodePath()))
+                       return false;
+
+               return true;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/RunInOsgiPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/RunInOsgiPage.java
new file mode 100644 (file)
index 0000000..5e11e77
--- /dev/null
@@ -0,0 +1,96 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import javax.jcr.Node;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Enable launch of the current distribution in a separate osgi run time.
+ * Display also a console to interract with the launched runtime
+ */
+public class RunInOsgiPage extends FormPage implements SlcNames {
+
+       final static String PAGE_ID = "RunInOsgiPage";
+
+       // Business Objects
+       private Node modularDistribution;
+
+       // This page widgets
+       private Button launchBtn;
+       private Text consoleTxt;
+
+       private FormToolkit tk;
+
+       public RunInOsgiPage(FormEditor formEditor, String title,
+                       Node modularDistribution) {
+               super(formEditor, PAGE_ID, title);
+               this.modularDistribution = modularDistribution;
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm managedForm) {
+               ScrolledForm form = managedForm.getForm();
+               tk = managedForm.getToolkit();
+               // Main Layout
+               Composite body = form.getBody();
+               GridLayout layout = new GridLayout();
+               layout.marginTop = layout.marginWidth = 0;
+               body.setLayout(layout);
+
+               // The header
+               Composite header = tk.createComposite(body);
+               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               createHeaderPart(header);
+
+               // The console
+               Composite console = tk.createComposite(body);
+               console.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               createConsolePart(console);
+               body.layout();
+       }
+
+       private void createHeaderPart(Composite parent) {
+               GridLayout layout = new GridLayout();
+               parent.setLayout(layout);
+
+               // Text Area to filter
+               launchBtn = tk.createButton(parent, " Launch ", SWT.PUSH);
+               launchBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
+
+               launchBtn.addSelectionListener(new SelectionAdapter() {
+                       private static final long serialVersionUID = -1633658484882130602L;
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               super.widgetSelected(e);
+                               throw new SlcException("Implement this");
+                       }
+               });
+       }
+
+       private void createConsolePart(Composite parent) {
+               parent.setLayout(new GridLayout());
+               consoleTxt = tk.createText(parent, "OSGi > ", SWT.MULTI | SWT.WRAP
+                               | SWT.BORDER);
+               consoleTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+       }
+
+       @Override
+       public void setFocus() {
+               launchBtn.setFocus();
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/WkspCategoryBaseListPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/editors/WkspCategoryBaseListPage.java
new file mode 100644 (file)
index 0000000..a482e9d
--- /dev/null
@@ -0,0 +1,492 @@
+package org.argeo.slc.client.ui.dist.editors;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.observation.Event;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.DynamicOperand;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+import javax.jcr.query.qom.StaticOperand;
+
+import org.argeo.cms.ui.workbench.util.CommandUtils;
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
+import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
+import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
+import org.argeo.slc.repo.RepoConstants;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Show all category base (currently only Aether group base) contained in a
+ * given workspace as filter-able table. Enable to definition of which of them
+ * should be managed as modular distribution
+ */
+public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
+
+       final static String PAGE_ID = "WkspCategoryBaseListPage";
+
+       // Business Objects
+       private Session session;
+
+       // This page widgets
+       private DistNodeViewerComparator comparator;
+       private TableViewer viewer;
+       private FormToolkit tk;
+       private Text filterTxt;
+       private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
+
+       // Observes changes
+       // private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE
+       // };
+       // private CategoryObserver categoriesObserver;
+
+       public WkspCategoryBaseListPage(FormEditor formEditor, String title,
+                       Session session) {
+               super(formEditor, PAGE_ID, title);
+               this.session = session;
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm managedForm) {
+               ScrolledForm form = managedForm.getForm();
+               tk = managedForm.getToolkit();
+
+               form.setText("Define Relevant Categories");
+               form.setMessage("Choose in the below list "
+                               + "the categories that can be used as base for "
+                               + "modular distributions maintained via the current workspace",
+                               IMessageProvider.NONE);
+
+               // Main Layout
+               GridLayout layout = new GridLayout(1, false);
+               Composite body = form.getBody();
+               body.setLayout(layout);
+
+               // filter section
+               Composite header = tk.createComposite(body);
+               header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               createFilterPart(header);
+
+               // the table
+               Composite tableCmp = tk.createComposite(body);
+               tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               createTableViewer(tableCmp);
+
+               // categoriesObserver = new CategoryObserver(viewer.getTable()
+               // .getDisplay());
+               // try {
+               // ObservationManager observationManager = session.getWorkspace()
+               // .getObservationManager();
+               // // FIXME Will not be notified if empty result is deleted
+               // observationManager.addEventListener(categoriesObserver,
+               // Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
+               // false);
+               // } catch (RepositoryException e) {
+               // throw new SlcException("Cannot register listeners", e);
+               // }
+
+               refresh();
+       }
+
+       private void refresh() {
+               final List<Node> result = JcrUtils.nodeIteratorToList(listGroupBase());
+               viewer.setInput(result);
+       }
+
+       /** Build repository request */
+       private NodeIterator listGroupBase() {
+               try {
+                       QueryManager queryManager = session.getWorkspace()
+                                       .getQueryManager();
+                       QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+                       Selector source = factory.selector(SlcTypes.SLC_GROUP_BASE,
+                                       SlcTypes.SLC_MODULE_COORDINATES);
+
+                       // Create a dynamic operand for each property on which we want to
+                       // filter
+                       DynamicOperand catDO = factory.propertyValue(
+                                       source.getSelectorName(), SlcNames.SLC_CATEGORY);
+                       DynamicOperand nameDO = factory.propertyValue(
+                                       source.getSelectorName(), SlcNames.SLC_NAME);
+
+                       String filter = filterTxt.getText();
+
+                       Constraint defaultC = null;
+                       // Build constraints based the textArea content
+                       if (filter != null && !"".equals(filter.trim())) {
+                               // Parse the String
+                               String[] strs = filter.trim().split(" ");
+                               for (String token : strs) {
+                                       token = token.replace('*', '%');
+                                       StaticOperand so = factory.literal(session
+                                                       .getValueFactory().createValue("%" + token + "%"));
+
+                                       Constraint currC = factory.comparison(catDO,
+                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
+                                       currC = factory.or(currC, factory.comparison(nameDO,
+                                                       QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
+
+                                       if (defaultC == null)
+                                               defaultC = currC;
+                                       else
+                                               defaultC = factory.and(defaultC, currC);
+                               }
+                       }
+
+                       QueryObjectModel query = factory.createQuery(source, defaultC,
+                                       null, null);
+                       QueryResult result = query.execute();
+                       return result.getNodes();
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unable to refresh group list for workspace "
+                                                       + getEditorInput().getName(), re);
+               }
+       }
+
+       private void createFilterPart(Composite parent) {
+               GridLayout layout = new GridLayout(2, false);
+               layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
+               layout.horizontalSpacing = 5;
+               parent.setLayout(layout);
+
+               // Text Area to filter
+               filterTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
+                               | SWT.SEARCH | SWT.CANCEL);
+               filterTxt.setMessage(FILTER_HELP_MSG);
+               filterTxt.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               filterTxt.addModifyListener(new ModifyListener() {
+                       private static final long serialVersionUID = 8727389523069041623L;
+
+                       public void modifyText(ModifyEvent event) {
+                               refresh();
+                       }
+               });
+
+               Button resetBtn = tk.createButton(parent, null, SWT.PUSH);
+               resetBtn.setImage(DistImages.IMG_REPO_READONLY);
+               resetBtn.addSelectionListener(new SelectionAdapter() {
+                       private static final long serialVersionUID = -6523538838444581321L;
+
+                       public void widgetSelected(SelectionEvent e) {
+                               resetFilter();
+                       }
+               });
+       }
+
+       private void resetFilter() {
+               filterTxt.setText("");
+               filterTxt.setMessage(FILTER_HELP_MSG);
+       }
+
+       private void createTableViewer(Composite parent) {
+               parent.setLayout(new FillLayout());
+               // helpers to enable sorting by column
+               List<String> propertiesList = new ArrayList<String>();
+               List<Integer> propertyTypesList = new ArrayList<Integer>();
+
+               // Define the TableViewer
+               viewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+
+               TableViewerColumn col;
+               // Name
+               // TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
+               // col.getColumn().setWidth(220);
+               // col.getColumn().setText("Category");
+               // col.setLabelProvider(new ColumnLabelProvider() {
+               // @Override
+               // public String getText(Object element) {
+               // return JcrUtils.get((Node) element, SlcNames.SLC_CATEGORY);
+               // }
+               // });
+               // col.getColumn().addSelectionListener(getSelectionAdapter(0));
+               // propertiesList.add(SlcNames.SLC_CATEGORY);
+               // propertyTypesList.add(PropertyType.STRING);
+
+               // Group base name
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(220);
+               col.getColumn().setText("Group Name");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = 6186787928630825293L;
+
+                       @Override
+                       public String getText(Object element) {
+                               return JcrUtils.get((Node) element, SLC_GROUP_BASE_ID);
+                       }
+               });
+               col.getColumn().addSelectionListener(getSelectionAdapter(0));
+               propertiesList.add(SLC_GROUP_BASE_ID);
+               propertyTypesList.add(PropertyType.STRING);
+
+               // Version
+               col = new TableViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(80);
+               col.getColumn().setText("Has binaries");
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       private static final long serialVersionUID = -2017377132642062464L;
+
+                       @Override
+                       public String getText(Object element) {
+                               try {
+                                       Node currNode = (Node) element;
+
+                                       return currNode.hasNode(RepoConstants.BINARIES_ARTIFACT_ID) ? "Yes"
+                                                       : "No";
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("unable to check type of node "
+                                                       + element, e);
+                               }
+                       }
+               });
+               // col.getColumn().addSelectionListener(getSelectionAdapter(2));
+               // propertiesList.add(SLC_VERSION);
+               // propertyTypesList.add(PropertyType.STRING);
+
+               final Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+
+               viewer.setContentProvider(new DistributionsContentProvider());
+               getSite().setSelectionProvider(viewer);
+
+               comparator = new DistNodeViewerComparator(0,
+                               DistNodeViewerComparator.ASCENDING, propertiesList,
+                               propertyTypesList);
+               viewer.setComparator(comparator);
+
+               // Context Menu
+               MenuManager menuManager = new MenuManager();
+               Menu menu = menuManager.createContextMenu(viewer.getTable());
+               menuManager.addMenuListener(new IMenuListener() {
+                       private static final long serialVersionUID = 739004528695501335L;
+
+                       public void menuAboutToShow(IMenuManager manager) {
+                               contextMenuAboutToShow(manager);
+                       }
+               });
+               viewer.getTable().setMenu(menu);
+               getSite().registerContextMenu(menuManager, viewer);
+
+               // Double click
+               viewer.addDoubleClickListener(new DoubleClickListener());
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTable().setFocus();
+       }
+
+       /** Programmatically configure the context menu */
+       protected void contextMenuAboutToShow(IMenuManager menuManager) {
+               IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
+                               .getActiveWorkbenchWindow();
+               // Build conditions
+               // Mark as category base
+               Object firstElement = ((IStructuredSelection) viewer.getSelection())
+                               .getFirstElement();
+               Node currSelected = (Node) firstElement;
+
+               DistWkspEditorInput input = (DistWkspEditorInput) getEditorInput();
+
+               Map<String, String> params = new HashMap<String, String>();
+               params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
+                               input.getRepoNodePath());
+               try {
+                       params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
+                                       currSelected.getPath());
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unable to get path for " + currSelected, e);
+               }
+               params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
+                               input.getWorkspaceName());
+
+               CommandUtils.refreshParameterizedCommand(menuManager, window,
+                               OpenGenerateBinariesWizard.ID,
+                               OpenGenerateBinariesWizard.DEFAULT_LABEL,
+                               OpenGenerateBinariesWizard.DEFAULT_ICON, true, params);
+
+               // boolean isRelevant = false;
+               // try {
+               // isRelevant = currSelected.isNodeType(SlcTypes.SLC_CATEGORY);
+               // boolean canEdit = currSelected.canAddMixin(SlcTypes.SLC_CATEGORY);
+               //
+               // } catch (RepositoryException e) {
+               // throw new SlcException("unable to check type of node "
+               // + firstElement, e);
+               // }
+               // // Add
+               // if (isRelevant) {// Remove
+               // CommandUtils.refreshCommand(menuManager, window,
+               // MarkAsRelevantCategory.ID,
+               // MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
+               // MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
+               // } else {
+               // CommandUtils.refreshCommand(menuManager, window,
+               // MarkAsRelevantCategory.ID,
+               // MarkAsRelevantCategory.DEFAULT_LABEL,
+               // MarkAsRelevantCategory.DEFAULT_ICON, true);
+               // }
+       }
+
+       private SelectionAdapter getSelectionAdapter(final int index) {
+               SelectionAdapter selectionAdapter = new SelectionAdapter() {
+                       private static final long serialVersionUID = -1723894288128081757L;
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               Table table = viewer.getTable();
+                               comparator.setColumn(index);
+                               int dir = table.getSortDirection();
+                               if (table.getSortColumn() == table.getColumn(index)) {
+                                       dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
+                               } else {
+                                       dir = SWT.DOWN;
+                               }
+                               table.setSortDirection(dir);
+                               table.setSortColumn(table.getColumn(index));
+                               viewer.refresh();
+                       }
+               };
+               return selectionAdapter;
+       }
+
+       /* LOCAL CLASSES */
+       private class DistributionsContentProvider implements
+                       IStructuredContentProvider {
+               private static final long serialVersionUID = -5939763615620837492L;
+
+               // we keep a cache of the Nodes in the content provider to be able to
+               // manage long request
+               private List<Node> nodes;
+
+               public void dispose() {
+               }
+
+               // We expect a list of nodes as a new input
+               @SuppressWarnings("unchecked")
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       nodes = (List<Node>) newInput;
+               }
+
+               public Object[] getElements(Object arg0) {
+                       return nodes.toArray();
+               }
+       }
+
+       private class DoubleClickListener implements IDoubleClickListener {
+
+               public void doubleClick(DoubleClickEvent event) {
+                       Object obj = ((IStructuredSelection) event.getSelection())
+                                       .getFirstElement();
+                       if (obj instanceof Node) {
+                               Node node = (Node) obj;
+                               try {
+                                       if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                                               DistWkspEditorInput dwip = (DistWkspEditorInput) getEditorInput();
+                                               Map<String, String> params = new HashMap<String, String>();
+                                               params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+                                                               dwip.getRepoNodePath());
+                                               params.put(OpenModuleEditor.PARAM_REPO_URI,
+                                                               dwip.getUri());
+                                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+                                                               dwip.getWorkspaceName());
+                                               String path = node.getPath();
+                                               params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
+                                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
+                                       }
+                               } catch (RepositoryException re) {
+                                       throw new SlcException("Cannot get path for node " + node
+                                                       + " while setting parameters for "
+                                                       + "command OpenModuleEditor", re);
+                               }
+
+                       }
+               }
+       }
+
+       class CategoryObserver extends AsyncUiEventListener {
+
+               public CategoryObserver(Display display) {
+                       super(display);
+               }
+
+               @Override
+               protected Boolean willProcessInUiThread(List<Event> events)
+                               throws RepositoryException {
+                       for (Event event : events) {
+                               String path = event.getPath();
+                               if (JcrUtils.lastPathElement(path).equals(
+                                               DistConstants.JCR_MIXIN_TYPES))
+                                       return true;
+                       }
+                       return false;
+               }
+
+               protected void onEventInUiThread(List<Event> events)
+                               throws RepositoryException {
+                       if (getLog().isTraceEnabled())
+                               getLog().trace("Refresh table");
+                       viewer.refresh();
+               }
+       }
+
+       @Override
+       public void setActive(boolean active) {
+               super.setActive(active);
+               if (active) {
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/DistParentElem.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/DistParentElem.java
new file mode 100644 (file)
index 0000000..fe960b4
--- /dev/null
@@ -0,0 +1,62 @@
+package org.argeo.slc.client.ui.dist.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.argeo.eclipse.ui.TreeParent;
+
+/** Common super class for all tree elements of the Distributions View */
+public abstract class DistParentElem extends TreeParent {
+       protected final static Character VERSION_SEP = '-';
+
+       protected static final List<String> ARGEO_SYSTEM_WKSP;
+       static {
+               List<String> tmpList = new ArrayList<String>();
+               tmpList.add("main");
+               tmpList.add("proxy");
+               tmpList.add("security");
+               tmpList.add("localrepo");
+               ARGEO_SYSTEM_WKSP = Collections.unmodifiableList(tmpList);
+       }
+
+       private boolean inHome = false;
+       private boolean isReadOnly = false;
+
+       public DistParentElem(String name, boolean inHome, boolean isReadOnly) {
+               super(name);
+               this.inHome = inHome;
+               this.isReadOnly = isReadOnly;
+       }
+
+       public DistParentElem(String name) {
+               super(name);
+       }
+
+       // public abstract String getLabel();
+       //
+       // public abstract Object[] getChildren();
+       //
+       // public boolean hasChildren() {
+       // return true;
+       // }
+       //
+       // public void dispose() {
+       // }
+
+       public void setInHome(boolean inHome) {
+               this.inHome = inHome;
+       }
+
+       public void setReadOnly(boolean isReadOnly) {
+               this.isReadOnly = isReadOnly;
+       }
+
+       public boolean inHome() {
+               return inHome;
+       }
+
+       public boolean isReadOnly() {
+               return isReadOnly;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/GroupBaseElem.java
new file mode 100644 (file)
index 0000000..2b9a8fe
--- /dev/null
@@ -0,0 +1,41 @@
+package org.argeo.slc.client.ui.dist.model;
+
+/**
+ * Abstract a node of type slc:groupBase that gathers a set of artifacts that
+ * have the same group ID
+ */
+public class GroupBaseElem extends DistParentElem {
+       // private WorkspaceElem wkspElem;
+       private String groupId;
+
+       public GroupBaseElem(WorkspaceElem wkspElem, String groupId) {
+               super(groupId, wkspElem.inHome(), wkspElem.isReadOnly());
+
+               setParent(wkspElem);
+               // this.wkspElem = wkspElem;
+               this.groupId = groupId;
+       }
+
+       public Object[] getChildren() {
+               return null;
+       }
+
+       public String getLabel() {
+               return groupId;
+       }
+
+       // public String toString() {
+       // return getLabel();
+       // }
+
+       // public void dispose() {
+       // }
+
+       public WorkspaceElem getWorkspaceElem() {
+               return (WorkspaceElem) getParent();
+       }
+
+       public String getGroupId() {
+               return getName();
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionBaseElem.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionBaseElem.java
new file mode 100644 (file)
index 0000000..4ee0b59
--- /dev/null
@@ -0,0 +1,123 @@
+package org.argeo.slc.client.ui.dist.model;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+
+/**
+ * Abstract the base of a given modular distribution set i.e. the parent of all
+ * versions of a given modular distribution
+ */
+public class ModularDistVersionBaseElem extends DistParentElem {
+
+       // final static public String AETHER_CATEGORY_BASE = "categoryBase";
+       final static public String AETHER_BINARIES_TYPE = "binaries";
+       final static public String AETHER_DEP_TYPE = "dep";
+       private String type;
+       private Node modularDistVersionBase;
+
+       public ModularDistVersionBaseElem(WorkspaceElem wkspElem, String name,
+                       Node modularDistVersionBase, String type) {
+               super(name, wkspElem.inHome(), wkspElem.isReadOnly());
+               setParent(wkspElem);
+               this.modularDistVersionBase = modularDistVersionBase;
+               this.type = type;
+       }
+
+       public Node getModularDistBase() {
+               // // TODO clean this
+               // if (type.equals(AETHER_CATEGORY_BASE))
+               // return modularDistVersionBase;
+               // else
+               try {
+                       return modularDistVersionBase.getParent();
+               } catch (RepositoryException e) {
+                       throw new SlcException("unable to get parent node for "
+                                       + modularDistVersionBase, e);
+               }
+       }
+
+       public WorkspaceElem getWkspElem() {
+               return (WorkspaceElem) getParent();
+       }
+
+       /**
+        * Override normal behaviour to initialise children only when first
+        * requested
+        */
+       @Override
+       public synchronized boolean hasChildren() {
+               if (isLoaded()) {
+                       return super.hasChildren();
+               } else {
+                       return true;
+               }
+       };
+
+       /**
+        * Override normal behaviour to initialise children only when first
+        * requested
+        */
+       @Override
+       public synchronized Object[] getChildren() {
+               if (isLoaded()) {
+                       return super.getChildren();
+               } else {
+                       try {
+                               NodeIterator ni = getDistVersions();
+                               while (ni != null && ni.hasNext()) {
+                                       Node curNode = ni.nextNode();
+                                       if (curNode.hasProperty(SlcNames.SLC_ARTIFACT_VERSION))
+                                               addChild(new ModularDistVersionElem(this, curNode
+                                                               .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
+                                                               .getString(), curNode));
+                               }
+                               return super.getChildren();
+                       } catch (RepositoryException re) {
+                               throw new SlcException("Unable to retrieve children for "
+                                               + modularDistVersionBase, re);
+                       }
+               }
+       }
+
+       private NodeIterator getDistVersions() {
+               try {
+                       // if (AETHER_CATEGORY_BASE.equals(type))
+                       // return null;
+
+                       QueryManager queryManager = modularDistVersionBase.getSession()
+                                       .getWorkspace().getQueryManager();
+                       QueryObjectModelFactory factory = queryManager.getQOMFactory();
+                       Selector source = factory.selector(
+                                       SlcTypes.SLC_MODULAR_DISTRIBUTION,
+                                       SlcTypes.SLC_MODULAR_DISTRIBUTION);
+                       Constraint constraint = factory.descendantNode(
+                                       source.getSelectorName(), modularDistVersionBase.getPath());
+                       // Ordering order = factory.descending(factory.propertyValue(
+                       // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
+                       // Ordering[] orderings = { order };
+                       QueryObjectModel query = factory.createQuery(source, constraint,
+                                       null, null);
+                       QueryResult queryResult = query.execute();
+                       return queryResult.getNodes();
+               } catch (RepositoryException e) {
+                       throw new SlcException(
+                                       "Unable to version for modular distribution: " + getName(),
+                                       e);
+               }
+       }
+
+       public String getType() {
+               return type;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionElem.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/ModularDistVersionElem.java
new file mode 100644 (file)
index 0000000..23c7578
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.slc.client.ui.dist.model;
+
+import javax.jcr.Node;
+
+/**
+ * Abstract a node of type slc:modularDistribution that has a child node that
+ * lists the modules contained in the current distribution
+ */
+public class ModularDistVersionElem extends DistParentElem {
+       private final Node modularDistVersionNode;
+
+       public ModularDistVersionElem(ModularDistVersionBaseElem modularDistGroupElem,
+                       String version, Node modularDistVersionNode) {
+               super(version, modularDistGroupElem.inHome(), modularDistGroupElem
+                               .isReadOnly());
+               setParent(modularDistGroupElem);
+               this.modularDistVersionNode = modularDistVersionNode;
+       }
+
+       public Object[] getChildren() {
+               return null;
+       }
+
+       public String getLabel() {
+               return getName();
+       }
+
+       public WorkspaceElem getWorkspaceElem() {
+               return (WorkspaceElem) getParent().getParent();
+       }
+
+       public Node getModularDistVersionNode() {
+               return modularDistVersionNode;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/RepoElem.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/RepoElem.java
new file mode 100644 (file)
index 0000000..8ae8e8b
--- /dev/null
@@ -0,0 +1,239 @@
+package org.argeo.slc.client.ui.dist.model;
+
+import java.security.AccessControlException;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.api.NodeConstants;
+import org.argeo.api.NodeUtils;
+import org.argeo.api.security.Keyring;
+import org.argeo.cms.ArgeoNames;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoUtils;
+
+/**
+ * Abstract a repository. It might be persisted by a node in the current user
+ * home Node or just an URI and a label if user is anonymous
+ */
+public class RepoElem extends DistParentElem {
+       // private final static Log log = LogFactory.getLog(RepoElem.class);
+
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+       private Credentials credentials;
+       private Session defaultSession = null;
+
+       // Defines current repo
+       private Node repoNode = null;
+       private String label;
+       private String uri;
+
+       private Repository repository;
+
+       /**
+        * Creates a RepoElement for anonymous user. The {@code RepositoryFactory}
+        * is used to enable lazy initialisation
+        */
+       public RepoElem(RepositoryFactory repoFactory, String uri, String label) {
+               super(label);
+               this.repositoryFactory = repoFactory;
+               this.uri = uri;
+               this.label = label;
+       }
+
+       /**
+        * Creates a RepoElement for an authenticated user. The
+        * {@code RepositoryFactory} and {@code Keyring} are used to enable lazy
+        * initialisation
+        * 
+        */
+       public RepoElem(RepositoryFactory repoFactory, Keyring keyring, Node repoNode, String alias) {
+               super(alias);
+               this.label = alias;
+               // label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
+               // .getProperty(Property.JCR_TITLE).getString() : repoNode
+               // .getName();
+               this.repoNode = repoNode;
+               this.repositoryFactory = repoFactory;
+               this.keyring = keyring;
+               try {
+                       // Initialize this repo information
+                       setInHome(RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS.equals(repoNode.getName()));
+                       if (inHome())
+                               // Directly log and retrieve children for local repository
+                               login();
+                       else
+                               setReadOnly(!repoNode.hasNode(ArgeoNames.ARGEO_PASSWORD));
+                       uri = JcrUtils.get(repoNode, ArgeoNames.ARGEO_URI);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unable to " + "initialize repo element", e);
+               }
+       }
+
+       /** Effective login. Does nothing if the session is already there. */
+       public void login() {
+               if (isConnected())
+                       return;
+
+               if (repository == null)
+                       if (repoNode == null)
+                               // Anonymous
+                               repository = NodeUtils.getRepositoryByUri(repositoryFactory, uri);
+                       else {
+                               repository = RepoUtils.getRepository(repositoryFactory, keyring, repoNode);
+                               credentials = RepoUtils.getRepositoryCredentials(keyring, repoNode);
+                       }
+
+               try {
+                       // FIXME make it more generic
+                       String defaultWorkspace = NodeConstants.SYS_WORKSPACE;
+                       defaultSession = repository.login(credentials, defaultWorkspace);
+                       refreshChildren();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot login repository " + label + " with credential " + credentials, e);
+               }
+       }
+
+       protected void refreshChildren() {
+               try {
+                       // TODO also remove deleted children (only adds for the time being
+                       String[] workspaceNames = defaultSession.getWorkspace().getAccessibleWorkspaceNames();
+                       buildWksp: for (String workspaceName : workspaceNames) {
+                               if (!isWorkspaceVisible(workspaceName))
+                                       continue buildWksp;
+
+                               String prefix = getPrefix(workspaceName);
+                               if (getChildByName(prefix) == null) {
+                                       WkspGroupElem wkspGpElem = new WkspGroupElem(RepoElem.this, prefix);
+                                       addChild(wkspGpElem);
+                               }
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot list workspaces for " + repoNode, e);
+               }
+       }
+
+       @Override
+       public synchronized void dispose() {
+               JcrUtils.logoutQuietly(defaultSession);
+               super.dispose();
+       }
+
+       private String getPrefix(String workspaceName) {
+               // Here is the tricks - we rely on a "hard coded" convention
+               // Workspace name should be like: name-major.minor
+               if (workspaceName.lastIndexOf(VERSION_SEP) > 0)
+                       return workspaceName.substring(0, workspaceName.lastIndexOf(VERSION_SEP));
+               else
+                       return workspaceName;
+       }
+
+       /* Exposes this to the children workspace group */
+       protected boolean isWorkspaceVisible(String wkspName) {
+               Boolean result = true;
+               if (ARGEO_SYSTEM_WKSP.contains(wkspName))
+                       return false;
+               // Add a supplementary check to hide workspace that are not
+               // public to anonymous user
+               if (repoNode == null) {
+                       Session tmpSession = null;
+                       try {
+                               tmpSession = repository.login(wkspName);
+                               try {
+                                       tmpSession.checkPermission("/", "read");
+                               } catch (AccessControlException e) {
+                                       result = false;
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot list workspaces for anonymous user", e);
+                       } finally {
+                               JcrUtils.logoutQuietly(tmpSession);
+                       }
+               }
+               return result;
+       }
+
+       /**
+        * Actual call to the
+        * {@link Repository#login(javax.jcr.Credentials, String)} method. To be
+        * overridden.
+        * 
+        * Creates a new session with correct credentials using the information
+        * contained in the corresponding repo node. It provides all UI children
+        * elements an unique entry point to retrieve a new Session. Caller must
+        * close the session when it is not in use anymore.
+        * 
+        */
+       protected Session repositoryLogin(String workspaceName) {
+               try {
+                       if (workspaceName == null)
+                               workspaceName = NodeConstants.SYS_WORKSPACE;// FIXME make it more generic
+                       return repository.login(credentials, workspaceName);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot login repository " + label + " with credential " + credentials, e);
+               }
+       }
+
+       public Boolean isConnected() {
+               if (defaultSession != null && defaultSession.isLive())
+                       return true;
+               else
+                       return false;
+       }
+
+       /** Exposes URI to the current repository */
+       public String getUri() {
+               return uri;
+       }
+
+       public String getRepoNodePath() {
+               if (repoNode == null)
+                       return null;
+               else
+                       try {
+                               return repoNode.getPath();
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get node path for repository " + label, e);
+                       }
+       }
+
+       /**
+        * Exposes the local repoNode that completely define a connection to a
+        * repository (including a set of credentials). Might return null in case of
+        * an anonymous user
+        */
+       protected Node getRepoNode() {
+               return repoNode;
+       }
+
+       protected Repository getRepository() {
+               return repository;
+       }
+
+       protected Credentials getCredentials() {
+               return credentials;
+       }
+
+       // META INFO
+       public String getDescription() {
+               String desc = label;
+               if (repoNode != null)
+                       desc = label + " (" + uri + ")";
+               return desc;
+       }
+
+       public String getLabel() {
+               return label;
+       }
+
+       public String toString() {
+               return repoNode != null ? repoNode.toString() : label;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WkspGroupElem.java
new file mode 100644 (file)
index 0000000..0c10777
--- /dev/null
@@ -0,0 +1,53 @@
+package org.argeo.slc.client.ui.dist.model;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+
+/**
+ * Abstract set of similar workspaces, that is a bunch of workspaces with same
+ * prefix.
+ */
+public class WkspGroupElem extends DistParentElem {
+
+       private Session defaultSession;
+
+       public WkspGroupElem(RepoElem repoElem, String prefix) {
+               super(prefix, repoElem.inHome(), repoElem.isReadOnly());
+               setParent(repoElem);
+               // Directly adds children upon creation
+               try {
+                       defaultSession = repoElem.repositoryLogin(null);
+                       String[] wkpNames = defaultSession.getWorkspace()
+                                       .getAccessibleWorkspaceNames();
+                       for (String wkpName : wkpNames) {
+                               if (prefix.equals(getPrefix(wkpName))
+                               // if (wkpName.startsWith(prefix)
+                                               && repoElem.isWorkspaceVisible(wkpName))
+                                       addChild(new WorkspaceElem(WkspGroupElem.this, repoElem,
+                                                       wkpName));
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot retrieve workspace names", e);
+               }
+       }
+
+       // FIXME - we rely on a "hard coded" convention : Workspace name must have
+       // this format: name-major.minor
+       // We might expose this method as static public, to be used among others by
+       // the RepoElem parent objects when building its children
+       private String getPrefix(String workspaceName) {
+               if (workspaceName.lastIndexOf(VERSION_SEP) > 0)
+                       return workspaceName.substring(0,
+                                       workspaceName.lastIndexOf(VERSION_SEP));
+               else
+                       return workspaceName;
+       }
+
+       public void dispose() {
+               JcrUtils.logoutQuietly(defaultSession);
+               super.dispose();
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java
new file mode 100644 (file)
index 0000000..4c78511
--- /dev/null
@@ -0,0 +1,155 @@
+package org.argeo.slc.client.ui.dist.model;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+
+/** Abstract a workspace that contains a software distribution */
+public class WorkspaceElem extends DistParentElem {
+       private final RepoElem repoElem;
+       private String workspaceName;
+       private Session currSession;
+
+       public WorkspaceElem(WkspGroupElem parent, RepoElem repoElem,
+                       String workspaceName) {
+               super(workspaceName, repoElem.inHome(), repoElem.isReadOnly());
+               this.repoElem = repoElem;
+               this.workspaceName = workspaceName;
+               setParent(parent);
+       }
+
+       public String getWorkspaceName() {
+               return workspaceName;
+       }
+
+       public RepoElem getRepoElem() {
+               return repoElem;
+       }
+
+       public Boolean isConnected() {
+               if (currSession != null && currSession.isLive())
+                       return true;
+               else
+                       return false;
+       }
+
+       public void login() {
+               currSession = repoElem.repositoryLogin(getName());
+       }
+
+       /** Utility to create a new Session with correct credential in this context */
+       public Session getNewSession() {
+               return repoElem.repositoryLogin(getName());
+       }
+
+       public boolean hasChildren() {
+               try {
+                       if (isConnected())
+                               return currSession.getRootNode().hasNodes();
+                       else
+                               return true;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while checking children node existence",
+                                       re);
+               }
+       }
+
+       /** Override normal behaviour to initialize display of the workspace */
+       @Override
+       public synchronized Object[] getChildren() {
+               if (isLoaded()) {
+                       return super.getChildren();
+               } else {
+                       // initialize current object
+                       try {
+                               // Lazy connect the first time we retrieve children
+                               if (currSession == null)
+                                       login();
+
+                               // Retrieve already existing distribution
+
+                               // Use QOM rather than SQL2 - it seems more robust for remoting
+                               // with JCR 2.2 (might also be some model refresh issue with the
+                               // remoting)
+                               QueryManager queryManager = currSession.getWorkspace()
+                                               .getQueryManager();
+                               QueryObjectModelFactory factory = queryManager.getQOMFactory();
+                               Selector selector = factory.selector(
+                                               SlcTypes.SLC_MODULAR_DISTRIBUTION,
+                                               SlcTypes.SLC_MODULAR_DISTRIBUTION);
+                               // Curiously this works...
+                               // Selector selector = factory.selector(
+                               // SlcTypes.SLC_JAR_FILE,
+                               // SlcTypes.SLC_JAR_FILE);
+
+                               QueryObjectModel query = factory.createQuery(selector, null,
+                                               null, null);
+
+                               // Query groupQuery = currSession
+                               // .getWorkspace()
+                               // .getQueryManager()
+                               // .createQuery(
+                               // "select * from ["
+                               // + SlcTypes.SLC_MODULAR_DISTRIBUTION
+                               // + "]", Query.JCR_SQL2);
+                               NodeIterator distributions = null;
+                               try {
+                                       distributions = query.execute().getNodes();
+                               } catch (InvalidQueryException iqe) {
+                                       // For legacy only does not throw an exception while
+                                       // browsing
+                                       // legacy repositories that does not know
+                                       // SLC_MODULAR_DISTRIBUTION type
+                               }
+                               distribs: while (distributions != null
+                                               && distributions.hasNext()) {
+                                       Node currDist = distributions.nextNode();
+                                       Node distBase = currDist.getParent().getParent();
+                                       if (!distBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
+                                               continue distribs;
+                                       String groupId = distBase
+                                                       .getProperty(SlcNames.SLC_GROUP_ID).getString();
+                                       String artifactId = distBase.getProperty(
+                                                       SlcNames.SLC_ARTIFACT_ID).getString();
+
+                                       String name;
+                                       String type;
+                                       if (ModularDistVersionBaseElem.AETHER_BINARIES_TYPE
+                                                       .equals(artifactId)) {
+                                               name = groupId;
+                                               type = ModularDistVersionBaseElem.AETHER_BINARIES_TYPE;
+                                       } else {
+                                               name = artifactId;
+                                               type = ModularDistVersionBaseElem.AETHER_DEP_TYPE;
+                                       }
+                                       if (getChildByName(name) == null)
+                                               addChild(new ModularDistVersionBaseElem(
+                                                               WorkspaceElem.this, name, distBase, type));
+                               }
+                               return super.getChildren();
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "Cannot initialize WorkspaceNode UI object."
+                                                               + getName(), e);
+                       }
+               }
+       }
+
+       @Override
+       public synchronized void dispose() {
+               JcrUtils.logoutQuietly(currSession);
+               super.dispose();
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ArtifactsTableConfigurer.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ArtifactsTableConfigurer.java
new file mode 100644 (file)
index 0000000..dcdfc93
--- /dev/null
@@ -0,0 +1,202 @@
+package org.argeo.slc.client.ui.dist.utils;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.query.Row;
+
+import org.argeo.eclipse.ui.GenericTableComparator;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.TableColumn;
+
+/**
+ * Centralizes and factorizes useful methods to create and manage tables that
+ * display artifacts for both editors and views.
+ */
+public class ArtifactsTableConfigurer implements SlcNames, SlcTypes,
+               DistConstants {
+       // private final static Log log = LogFactory
+       // .getLog(ArtifactsTableConfigurer.class);
+       // Used in the comparator to be able to retrieve the value from a row
+       // knowing the corresponding column index.
+       private Map<Integer, String> indexToName = new HashMap<Integer, String>();
+
+       private CurrentTableComparator comparator;
+       private TableViewer viewer;
+
+       protected DateFormat timeFormatter = new SimpleDateFormat(DATE_TIME_FORMAT);
+
+       /**
+        * Create and initialize the table configurer.
+        */
+       public ArtifactsTableConfigurer(TableViewer viewer,
+                       int defaultSortColumnIndex, int direction) {
+               this.viewer = viewer;
+               comparator = new CurrentTableComparator(defaultSortColumnIndex,
+                               direction);
+       }
+
+       public GenericTableComparator getComparator() {
+               return comparator;
+       }
+
+       /**
+        * Configure column width and header label depending on the value that will
+        * be displayed in the current column.
+        * 
+        * @param jcrColumnName
+        * @param column
+        * @param columnIndex
+        */
+       public void configureColumn(String jcrColumnName, TableViewerColumn column,
+                       int columnIndex) {
+
+               if (columnIndex != -1
+                               && getSelectionAdapter(column.getColumn(), columnIndex) != null) {
+                       column.getColumn().addSelectionListener(
+                                       getSelectionAdapter(column.getColumn(), columnIndex));
+                       indexToName.put(new Integer(columnIndex), jcrColumnName);
+               }
+               Object[] objs = DistUiHelpers
+                               .getLabelAndDefaultValueWidth(jcrColumnName);
+               column.getColumn().setWidth((Integer) objs[1]);
+               column.getColumn().setText((String) objs[0]);
+       }
+
+       /**
+        * Might be used by client classes to sort the table with based on selected
+        * columns.
+        * 
+        * @param column
+        * @param index
+        * @return
+        */
+       public SelectionAdapter getSelectionAdapter(final TableColumn column,
+                       final int index) {
+
+               // A comparator must be define
+               if (comparator == null)
+                       return null;
+
+               SelectionAdapter selectionAdapter = new SelectionAdapter() {
+                       private static final long serialVersionUID = 5239138629878556374L;
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+
+                               try {
+
+                                       comparator.setColumn(index);
+                                       int dir = viewer.getTable().getSortDirection();
+                                       if (viewer.getTable().getSortColumn() == column) {
+                                               dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
+                                       } else {
+
+                                               dir = SWT.DOWN;
+                                       }
+                                       viewer.getTable().setSortDirection(dir);
+                                       viewer.getTable().setSortColumn(column);
+                                       viewer.refresh();
+                               } catch (Exception exc) {
+                                       exc.printStackTrace();
+                               }
+                       }
+               };
+               return selectionAdapter;
+       }
+
+       /**
+        * provides a label provider that returns the content of a specific cell.
+        * Specific treatment is done for some columns when the query returns a code
+        * that must be translated to the corresponding value at display time.
+        */
+       public ColumnLabelProvider getLabelProvider(final String columnName) {
+               boolean test = false;
+
+               if (test) {
+                       return new ColumnLabelProvider() {
+                               private static final long serialVersionUID = 7996387354459551737L;
+
+                               public String getText(Object element) {
+                                       return null;
+                               }
+
+                               public Image getImage(Object element) {
+                                       return null;
+                               }
+                       };
+               } else
+                       return new ColumnLabelProvider() {
+                               private static final long serialVersionUID = 6746632988975282759L;
+
+                               public String getText(Object element) {
+                                       Row row = (Row) element;
+                                       try {
+                                               return row.getValue(columnName).getString();
+                                       } catch (RepositoryException e) {
+                                               throw new SlcException("Cannot display row " + row, e);
+                                       }
+                               }
+
+                               public Image getImage(Object element) {
+                                       return null;
+                               }
+                       };
+       }
+
+       /** Implements comparator for various types of Artifact Table row */
+       private class CurrentTableComparator extends GenericTableComparator {
+               private static final long serialVersionUID = -4737460932326339442L;
+
+               public CurrentTableComparator(int colIndex, int direction) {
+                       super(colIndex, direction);
+               }
+
+               @Override
+               public int compare(Viewer viewer, Object e1, Object e2) {
+                       int rc = 0;
+
+                       if (e1 instanceof Row) {
+                               try {
+
+                                       Value v1 = ((Row) e1).getValue(indexToName
+                                                       .get(propertyIndex));
+                                       Value v2 = ((Row) e2).getValue(indexToName
+                                                       .get(propertyIndex));
+
+                                       if (v1.getType() == PropertyType.STRING)
+                                               rc = v1.getString().compareTo(v2.getString());
+                                       else if (v1.getType() == PropertyType.DATE)
+                                               rc = v1.getDate().compareTo(v2.getDate());
+                                       else
+                                               throw new SlcException("comparator for object type "
+                                                               + v1.getType() + " is not yet implemented");
+                               } catch (Exception e) {
+                                       throw new SlcException("rows cannot be compared ", e);
+                               }
+                       } else
+                               throw new SlcException("Unsupported row type");
+                       // If descending order, flip the direction
+                       if (direction == DESCENDING) {
+                               rc = -rc;
+                       }
+                       return rc;
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/CommandHelpers.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/CommandHelpers.java
new file mode 100644 (file)
index 0000000..e1134c6
--- /dev/null
@@ -0,0 +1,144 @@
+package org.argeo.slc.client.ui.dist.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.Parameterization;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
+import org.eclipse.ui.services.IServiceLocator;
+
+/**
+ * Centralizes useful methods to manage command updates
+ */
+public class CommandHelpers {
+
+       /**
+        * Refresh the given command. 
+        */
+       public static void refreshCommand(IMenuManager menuManager,
+                       IServiceLocator locator, String cmdId, String label, String iconPath,
+                       boolean showCommand) {
+               IContributionItem ici = menuManager.find(cmdId);
+               if (ici != null)
+                       menuManager.remove(ici);
+
+               if (showCommand) {
+                       // Set Params
+                       CommandContributionItemParameter contributionItemParameter = new CommandContributionItemParameter(
+                                       locator, null, cmdId, SWT.PUSH);
+                       contributionItemParameter.label = label;
+                       contributionItemParameter.icon = DistPlugin.getImageDescriptor(iconPath);
+                       CommandContributionItem cci = new CommandContributionItem(
+                                       contributionItemParameter);
+                       cci.setId(cmdId);
+                       menuManager.add(cci);
+               }
+       }
+
+       /**
+        * Refresh the given command and optionally corresponding parameters.
+        * 
+        * @param menuManager
+        * @param locator
+        * @param cmdId
+        * @param label
+        * @param showCommand
+        *            Command must be explicitly removed from the context menu at
+        *            each refresh setting this to false.
+        * @param params
+        *            maps a paramId with a String value
+        */
+       public static void refreshParameterizedCommand(IMenuManager menuManager,
+                       IServiceLocator locator, String cmdId, String label, String iconPath,
+                       boolean showCommand, Map<String, String> params) {
+               IContributionItem ici = menuManager.find(cmdId);
+               if (ici != null)
+                       menuManager.remove(ici);
+               
+               if (showCommand) {
+                       // Set Params
+                       CommandContributionItemParameter contributionItemParameter = new CommandContributionItemParameter(
+                                       locator, null, cmdId, SWT.PUSH);
+                       contributionItemParameter.label = label;
+                       contributionItemParameter.icon = DistPlugin.getImageDescriptor(iconPath);
+
+                       if (params != null)
+                               contributionItemParameter.parameters = params;
+
+                       CommandContributionItem cci = new CommandContributionItem(
+                                       contributionItemParameter);
+                       cci.setId(cmdId);
+                       menuManager.add(cci);
+               }
+       }
+
+       /** Helper to call a command without parameter easily */
+       public static void callCommand(String commandID) {
+               callCommand(commandID, null);
+       }
+
+       /** Helper to call a command with a single parameter easily */
+       public static void callCommand(String commandID, String parameterID,
+                       String parameterValue) {
+               Map<String, String> params = new HashMap<String, String>();
+               params.put(parameterID, parameterValue);
+               callCommand(commandID, params);
+       }
+
+       /**
+        * Helper to call a command with a map of parameters easily
+        * 
+        * @param paramMap
+        *            a map that links various commands ids with corresponding
+        *            String values.
+        */
+       public static void callCommand(String commandID,
+                       Map<String, String> paramMap) {
+               try {
+                       IWorkbench iw = DistPlugin.getDefault().getWorkbench();
+                       IHandlerService handlerService = (IHandlerService) iw
+                                       .getService(IHandlerService.class);
+                       ICommandService cmdService = (ICommandService) iw
+                                       .getActiveWorkbenchWindow().getService(
+                                                       ICommandService.class);
+                       Command cmd = cmdService.getCommand(commandID);
+
+                       ArrayList<Parameterization> parameters = null;
+                       ParameterizedCommand pc; 
+
+                       if (paramMap != null) {
+                               // Set parameters of the command to launch :
+                               parameters = new ArrayList<Parameterization>();
+                               Parameterization parameterization;
+                               for (String id : paramMap.keySet()) {
+                                       parameterization = new Parameterization(
+                                                       cmd.getParameter(id), paramMap.get(id));
+                                       parameters.add(parameterization);
+                               }
+                               pc = new ParameterizedCommand(cmd,
+                                               parameters.toArray(new Parameterization[parameters.size()]));
+                       } else 
+                               pc = new ParameterizedCommand(cmd, null);
+                       
+                       // build the parameterized command
+                       // execute the command
+                       handlerService.executeCommand(pc, null);
+               } catch (Exception e) {
+                       throw new SlcException(
+                                       "Unexepected exception while opening node editor", e);
+               }
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistNodeViewerComparator.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistNodeViewerComparator.java
new file mode 100644 (file)
index 0000000..1411996
--- /dev/null
@@ -0,0 +1,167 @@
+package org.argeo.slc.client.ui.dist.utils;
+
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.GenericTableComparator;
+import org.argeo.slc.SlcException;
+import org.eclipse.jface.viewers.Viewer;
+
+/** Add ability to order by name version and version */
+public class DistNodeViewerComparator extends GenericTableComparator {
+       private static final long serialVersionUID = -5966120108210992211L;
+
+       private final static Log log = LogFactory
+                       .getLog(DistNodeViewerComparator.class);
+
+       // Jcr property type goes to 12
+       public final static int NAME_VERSION_TYPE = 100;
+       public final static int VERSION_TYPE = 101;
+
+       protected List<String> propertiesList;
+       protected List<Integer> propertyTypesList;
+       protected Integer propertyType;
+       protected String property;
+
+       private NameVersionComparator nvc = new NameVersionComparator();
+       private VersionComparator vc = new VersionComparator();
+
+       public DistNodeViewerComparator(int defaultColIndex, int defaultDirection,
+                       List<String> propertiesList, List<Integer> propertyTypesList) {
+               super(defaultColIndex, defaultDirection);
+               this.propertiesList = propertiesList;
+               this.propertyTypesList = propertyTypesList;
+               this.propertyIndex = defaultColIndex;
+               this.propertyType = propertyTypesList.get(defaultColIndex);
+               this.property = propertiesList.get(defaultColIndex);
+               setColumn(defaultColIndex);
+       }
+
+       @Override
+       public int compare(Viewer viewer, Object e1, Object e2) {
+               int rc = 0;
+               long lc = 0;
+
+               try {
+                       Node n1 = (Node) e1;
+                       Node n2 = (Node) e2;
+
+                       Value v1 = null;
+                       Value v2 = null;
+                       if (n1.hasProperty(property))
+                               v1 = n1.getProperty(property).getValue();
+                       if (n2.hasProperty(property))
+                               v2 = n2.getProperty(property).getValue();
+
+                       if (v2 == null && v1 == null)
+                               return 0;
+                       else if (v2 == null)
+                               return -1;
+                       else if (v1 == null)
+                               return 1;
+
+                       switch (propertyType) {
+                       case NAME_VERSION_TYPE:
+                               rc = nvc.compare(viewer, v1.getString(), v2.getString());
+                               break;
+                       case VERSION_TYPE:
+                               rc = vc.compare(viewer, v1.getString(), v2.getString());
+                               break;
+                       case PropertyType.STRING:
+                               rc = v1.getString().compareTo(v2.getString());
+                               break;
+                       case PropertyType.BOOLEAN:
+                               boolean b1 = v1.getBoolean();
+                               boolean b2 = v2.getBoolean();
+                               if (b1 == b2)
+                                       rc = 0;
+                               else
+                                       // we assume true is greater than false
+                                       rc = b1 ? 1 : -1;
+                               break;
+                       case PropertyType.DATE:
+                               Calendar c1 = v1.getDate();
+                               Calendar c2 = v2.getDate();
+                               if (c1 == null || c2 == null)
+                                       log.trace("undefined date");
+                               lc = c1.getTimeInMillis() - c2.getTimeInMillis();
+                               if (lc < Integer.MIN_VALUE)
+                                       // rc = Integer.MIN_VALUE;
+                                       rc = -1;
+                               else if (lc > Integer.MAX_VALUE)
+                                       // rc = Integer.MAX_VALUE;
+                                       rc = 1;
+                               else
+                                       rc = (int) lc;
+                               break;
+                       case PropertyType.LONG:
+                               long l1;
+                               long l2;
+                               // FIXME sometimes an empty string is set instead of the id
+                               try {
+                                       l1 = v1.getLong();
+                               } catch (ValueFormatException ve) {
+                                       l1 = 0;
+                               }
+                               try {
+                                       l2 = v2.getLong();
+                               } catch (ValueFormatException ve) {
+                                       l2 = 0;
+                               }
+
+                               lc = l1 - l2;
+                               if (lc < Integer.MIN_VALUE)
+                                       // rc = Integer.MIN_VALUE;
+                                       rc = -1;
+                               else if (lc > Integer.MAX_VALUE)
+                                       // rc = Integer.MAX_VALUE;
+                                       rc = 1;
+                               else
+                                       rc = (int) lc;
+                               break;
+                       case PropertyType.DECIMAL:
+                               BigDecimal bd1 = v1.getDecimal();
+                               BigDecimal bd2 = v2.getDecimal();
+                               rc = bd1.compareTo(bd2);
+                               break;
+                       default:
+                               throw new SlcException(
+                                               "Unimplemented comparaison for PropertyType "
+                                                               + propertyType);
+                       }
+
+                       // If descending order, flip the direction
+                       if (direction == DESCENDING) {
+                               rc = -rc;
+                       }
+
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unexpected error "
+                                       + "while comparing nodes", re);
+               }
+               return rc;
+       }
+
+       @Override
+       public void setColumn(int column) {
+               if (column == this.propertyIndex) {
+                       // Same column as last sort; toggle the direction
+                       direction = 1 - direction;
+               } else {
+                       // New column; do a descending sort
+                       this.propertyIndex = column;
+                       this.propertyType = propertyTypesList.get(column);
+                       this.property = propertiesList.get(column);
+                       direction = ASCENDING;
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistUiHelpers.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/DistUiHelpers.java
new file mode 100644 (file)
index 0000000..b53fe01
--- /dev/null
@@ -0,0 +1,131 @@
+package org.argeo.slc.client.ui.dist.utils;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistConstants;
+
+public class DistUiHelpers implements DistConstants, SlcTypes, SlcNames {
+       private final static Log log = LogFactory.getLog(DistUiHelpers.class);
+       private final static DateFormat df = new SimpleDateFormat(DATE_TIME_FORMAT);
+
+       /**
+        * Returns a user-friendly label for a given jcr property name. If the
+        * corresponding mapping is not found, the input String is returned. If
+        * input String is null "(No name)" is returned
+        */
+       public static String getLabelJcrName(String jcrName) {
+               return (String) getLabelAndDefaultValueWidth(jcrName)[0];
+       }
+
+       /**
+        * Returns a label ( (String) object[0] )and default value width ( (int)
+        * object[1] ) for a given property name
+        */
+       public static Object[] getLabelAndDefaultValueWidth(String propertyName) {
+               // to avoid npe :
+               if (propertyName == null)
+                       return new Object[] { "(No name)", 60 };
+
+               // ArtifactId
+               if (propertyName.equals(SLC_ARTIFACT + "." + SLC_ARTIFACT_ID)
+                               || propertyName.equals(SLC_ARTIFACT_BASE + "."
+                                               + SLC_ARTIFACT_ID)
+                               || propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
+                                               + SLC_ARTIFACT_ID)
+                               || propertyName.equals(SLC_ARTIFACT_ID)) {
+                       return new Object[] { "Artifact ID", 200 };
+               } // GroupId
+               else if (propertyName.equals(SLC_ARTIFACT + "." + SLC_GROUP_ID)
+                               || propertyName.equals(SLC_ARTIFACT_BASE + "." + SLC_GROUP_ID)
+                               || propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
+                                               + SLC_GROUP_ID) || propertyName.equals(SLC_GROUP_ID)) {
+                       return new Object[] { "Group ID", 120 };
+               } // Version
+               else if (propertyName.equals(SLC_ARTIFACT + "." + SLC_ARTIFACT_VERSION)
+                               || propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
+                                               + SLC_ARTIFACT_VERSION)
+                               || propertyName.equals(SLC_ARTIFACT_VERSION)) {
+                       return new Object[] { "Version", 60 };
+               } else if (propertyName.equals(SLC_ARTIFACT + "."
+                               + SLC_ARTIFACT_CLASSIFIER)
+                               || propertyName.equals(SLC_ARTIFACT_CLASSIFIER)) {
+                       return new Object[] { "Classifier", 60 };
+               } else if (propertyName.equals(SLC_ARTIFACT + "."
+                               + SLC_ARTIFACT_EXTENSION)
+                               || propertyName.equals(SLC_ARTIFACT_EXTENSION)) {
+                       return new Object[] { "Type", 40 };
+               } else if (propertyName.equals(SLC_BUNDLE_ARTIFACT + "."
+                               + SLC_SYMBOLIC_NAME)
+                               || propertyName.equals(SLC_SYMBOLIC_NAME)) {
+                       return new Object[] { "Symbolic name", 180 };
+               } else if (propertyName.equals(SLC_BUNDLE_ARTIFACT + "."
+                               + SLC_BUNDLE_VERSION)
+                               || propertyName.equals(SLC_BUNDLE_VERSION)) {
+                       return new Object[] { "Bundle version", 120 };
+               } else if (propertyName
+                               .equals(SLC_BUNDLE_ARTIFACT + "." + SLC_MANIFEST)
+                               || propertyName.equals(SLC_MANIFEST)) {
+                       return new Object[] { "Manifest", 60 };
+               } // TODO remove hard coded strings
+               else if (propertyName.equals("slc:Bundle-ManifestVersion")) {
+                       return new Object[] { "Bundle Manifest Version", 60 };
+               } else if (propertyName.equals("slc:Manifest-Version")) {
+                       return new Object[] { "Manifest Version", 60 };
+               } else if (propertyName.equals("slc:Bundle-Vendor")) {
+                       return new Object[] { "Bundle Vendor", 60 };
+               } else if (propertyName.equals("slc:Bundle-SymbolicName")) {
+                       return new Object[] { "Bundle symbolic name", 60 };
+               } else if (propertyName.equals("slc:Bundle-Name")) {
+                       return new Object[] { "Bundle name", 60 };
+               } else if (propertyName.equals("slc:Bundle-DocURL")) {
+                       return new Object[] { "Doc URL", 120 };
+               } else if (propertyName.equals("slc:Bundle-Licence")) {
+                       return new Object[] { "Bundle licence", 120 };
+               } else if (propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
+                               + JCR_IDENTIFIER)) {
+                       return new Object[] { "UUID", 0 };
+               } else {
+                       if (log.isTraceEnabled())
+                               log.trace("No Column label provider defined for property: ["
+                                               + propertyName + "]");
+                       return new Object[] { propertyName, 60 };
+               }
+       }
+
+       public static String formatValueAsString(Value value) {
+               try {
+                       String strValue;
+
+                       if (value.getType() == PropertyType.BINARY)
+                               strValue = "<binary>";
+                       else if (value.getType() == PropertyType.DATE)
+                               strValue = df.format(value.getDate().getTime());
+                       else
+                               strValue = value.getString();
+                       return strValue;
+               } catch (RepositoryException e) {
+                       throw new SlcException("unexpected error while formatting value",
+                                       e);
+               }
+       }
+
+       public static String formatAsString(Object value) {
+               String strValue;
+               if (value instanceof Calendar)
+                       strValue = df.format(((Calendar) value).getTime());
+               else
+                       strValue = value.toString();
+               return strValue;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/HyperlinkAdapter.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/HyperlinkAdapter.java
new file mode 100644 (file)
index 0000000..13d71f8
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.slc.client.ui.dist.utils;
+
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+
+/** Convenience class to reduce the number of methods to implement */
+public abstract class HyperlinkAdapter implements IHyperlinkListener {
+
+       public void linkEntered(HyperlinkEvent e) {
+       }
+
+       public void linkExited(HyperlinkEvent e) {
+       }
+
+       /** Must be overriden **/
+       public abstract void linkActivated(HyperlinkEvent e);
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/NameVersionComparator.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/NameVersionComparator.java
new file mode 100644 (file)
index 0000000..0c4903f
--- /dev/null
@@ -0,0 +1,83 @@
+package org.argeo.slc.client.ui.dist.utils;
+
+import org.argeo.eclipse.ui.TreeParent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+/**
+ * Enable comparison of two names version string with form org.argeo.slc-1.2.x.
+ * with following rules and assumptions:
+ * <ul>
+ * <li>
+ * Names are ordered using Lexicographical order</li>
+ * <li>
+ * Version are parsed and compared segment by segment; doing best effort to
+ * convert major, minor and micro to integer and compare them as such (to have
+ * 0.1 < 0.9 < 0.10 not 0.1 < 0.10 < 0.9).</li>
+ * <li>Version should not contain any dash (-), version segments should be
+ * separated by dots (.)</li>
+ * </ul>
+ */
+
+public class NameVersionComparator extends ViewerComparator {
+       private static final long serialVersionUID = 8290130681918221197L;
+       
+       private VersionComparator vc = new VersionComparator();
+
+       @Override
+       public int category(Object element) {
+               if (element instanceof String) {
+                       int lastInd = ((String) element).lastIndexOf('-');
+                       if (lastInd > 0)
+                               return 10;
+               }
+               // unvalid names always last
+               return 5;
+       }
+
+       @Override
+       public int compare(Viewer viewer, Object e1, Object e2) {
+               int cat1 = category(e1);
+               int cat2 = category(e2);
+
+               if (cat1 != cat2) {
+                       return cat1 - cat2;
+               }
+
+               int result = 0;
+
+               String s1, s2;
+
+               if (e1 instanceof TreeParent) {
+                       s1 = ((TreeParent) e1).getName();
+                       s2 = ((TreeParent) e2).getName();
+               } else {
+                       s1 = e1.toString();
+                       s2 = e2.toString();
+               }
+
+               int i1 = s1.lastIndexOf('-');
+               int i2 = s2.lastIndexOf('-');
+
+               // Specific cases, unvalid Strings
+               if (i1 < 0)
+                       if (i2 < 0)
+                               return s1.compareTo(s2);
+                       else
+                               return 1;
+               else if (i2 < 0)
+                       return -1;
+
+               String aName = s1.substring(0, s1.lastIndexOf('-'));
+               String aVersion = s1.substring(s1.lastIndexOf('-'));
+
+               String bName = s2.substring(0, s2.lastIndexOf('-'));
+               String bVersion = s2.substring(s2.lastIndexOf('-'));
+
+               result = aName.compareTo(bName);
+               if (result != 0)
+                       return result;
+               else
+                       return vc.compare(viewer, aVersion, bVersion);
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/VersionComparator.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/VersionComparator.java
new file mode 100644 (file)
index 0000000..34aff22
--- /dev/null
@@ -0,0 +1,69 @@
+package org.argeo.slc.client.ui.dist.utils;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+/**
+ * Enable comparison of two version string with form "1.2.5.qualifier" with
+ * following rules and assumptions:
+ * <ul>
+ * <li>
+ * Version are parsed and compared segment by segment; doing best effort to
+ * convert major, minor and micro to integer and compare them as such (to have
+ * 0.1 < 0.9 < 0.10 not 0.1 < 0.10 < 0.9).</li>
+ * <li>Version should not contain any dash (-), version segments should be
+ * separated by dots (.)</li>
+ * </ul>
+ */
+
+public class VersionComparator extends ViewerComparator {
+       private static final long serialVersionUID = 3760077835650538982L;
+
+       @Override
+       public int compare(Viewer viewer, Object e1, Object e2) {
+               String s1 = (String) e1;
+               String s2 = (String) e2;
+               return compareVersion(s1, s2);
+       }
+
+       /**
+        * Enable comparison of two versions of the form
+        * "major.minor.micro.qualifier". We assume the separator is always a "."
+        * and make best effort to convert major, minor and micro to int.
+        */
+       private int compareVersion(String v1, String v2) {
+               String[] t1 = v1.split("\\.");
+               String[] t2 = v2.split("\\.");
+
+               for (int i = 0; i < t1.length && i < t2.length; i++) {
+                       int result = compareToken(t1[i], t2[i]);
+                       if (result != 0)
+                               return result;
+               }
+               if (t1.length > t2.length)
+                       return 1;
+               else if (t1.length < t2.length)
+                       return -1;
+               else
+                       return 0;
+       }
+
+       private int compareToken(String t1, String t2) {
+               if (t1 == null && t2 == null)
+                       return 0;
+               else if (t1 == null)
+                       return -1;
+               else if (t2 == null)
+                       return 1;
+
+               Integer i1 = null, i2 = null;
+               try {
+                       i1 = new Integer(t1);
+                       i2 = new Integer(t2);
+               } catch (NumberFormatException nfe) {
+                       // the format is not valid we silently compare as String
+                       return t1.compareTo(t2);
+               }
+               return i1.compareTo(i2);
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/utils/ViewerUtils.java
new file mode 100644 (file)
index 0000000..8faa891
--- /dev/null
@@ -0,0 +1,54 @@
+package org.argeo.slc.client.ui.dist.utils;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TreeColumn;
+
+/** Useful methods to manage table to display nodes list. */
+public class ViewerUtils {
+
+       /**
+        * Creates a basic column for the given table. For the time being, we do not
+        * support moveable columns.
+        */
+       public static TableColumn createColumn(Table parent, String name,
+                       int style, int width) {
+               TableColumn result = new TableColumn(parent, style);
+               result.setText(name);
+               result.setWidth(width);
+               result.setResizable(true);
+               return result;
+       }
+
+       /**
+        * Creates a TableViewerColumn for the given viewer. For the time being, we
+        * do not support moveable columns.
+        */
+       public static TableViewerColumn createTableViewerColumn(TableViewer parent,
+                       String name, int style, int width) {
+               TableViewerColumn tvc = new TableViewerColumn(parent, style);
+               final TableColumn column = tvc.getColumn();
+               column.setText(name);
+               column.setWidth(width);
+               column.setResizable(true);
+               return tvc;
+       }
+
+       /**
+        * Creates a TreeViewerColumn for the given viewer. For the time being, we
+        * do not support moveable columns.
+        */
+       public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent,
+                       String name, int style, int width) {
+               TreeViewerColumn tvc = new TreeViewerColumn(parent, style);
+               final TreeColumn column = tvc.getColumn();
+               column.setText(name);
+               column.setWidth(width);
+               column.setResizable(true);
+               return tvc;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AbstractQueryArtifactsView.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AbstractQueryArtifactsView.java
new file mode 100644 (file)
index 0000000..e6552eb
--- /dev/null
@@ -0,0 +1,218 @@
+package org.argeo.slc.client.ui.dist.views;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.GenericTableComparator;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.utils.ArtifactsTableConfigurer;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.part.ViewPart;
+
+/** Factorizes useful methods to build a query view in a sashForm */
+public abstract class AbstractQueryArtifactsView extends ViewPart implements
+               SlcTypes {
+       private static final Log log = LogFactory
+                       .getLog(AbstractQueryArtifactsView.class);
+
+       // shortcuts
+       final protected static String SAVB = "[" + SLC_ARTIFACT_VERSION_BASE + "]";
+       final protected static String SBA = "[" + SLC_BUNDLE_ARTIFACT + "]";
+       final protected static String SIP = "[" + SLC_IMPORTED_PACKAGE + "]";
+       final protected static String SEP = "[" + SLC_EXPORTED_PACKAGE + "]";
+
+       /* DEPENDENCY INJECTION */
+       private Session session;
+       private List<String> columnProperties;
+
+       // This page widgets
+       private TableViewer viewer;
+       private List<TableViewerColumn> tableViewerColumns = new ArrayList<TableViewerColumn>();
+       private ArtifactsTableConfigurer tableConfigurer;
+       private GenericTableComparator comparator;
+
+       // to be set by client to display all columns
+       private boolean displayAllColumns = false;
+
+       protected void createResultPart(Composite parent) {
+               viewer = new TableViewer(parent);
+               Table table = viewer.getTable();
+               table.getParent().setLayout(new GridLayout(1, false));
+               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               viewer.getTable().setHeaderVisible(true);
+               viewer.getTable().setLinesVisible(true);
+
+               viewer.setLabelProvider(new ViewLabelProvider());
+               viewer.setContentProvider(new ViewContentProvider());
+               // viewer.addDoubleClickListener(new GenericDoubleClickListener());
+
+               tableConfigurer = new ArtifactsTableConfigurer(viewer, 1,
+                               GenericTableComparator.DESCENDING);
+
+               comparator = tableConfigurer.getComparator();
+               viewer.setComparator(comparator);
+       }
+
+       protected void executeQuery(String statement) {
+               try {
+                       Calendar stStamp = new GregorianCalendar();
+                       if (log.isDebugEnabled()) {
+                               log.debug("Executed query: " + statement);
+                       }
+                       QueryResult qr = session.getWorkspace().getQueryManager()
+                                       .createQuery(statement, Query.JCR_SQL2).execute();
+
+                       if (log.isDebugEnabled()) {
+                               Calendar enStamp = new GregorianCalendar();
+                               long duration = enStamp.getTimeInMillis()
+                                               - stStamp.getTimeInMillis();
+                               log.debug("Query executed in : " + duration / 1000 + "s.");
+                       }
+
+                       // remove previous columns
+                       for (TableViewerColumn tvc : tableViewerColumns)
+                               tvc.getColumn().dispose();
+
+                       // If a pre(-defined list of columns has been injected, we use it,
+                       // otherwise we display all results of the resultSet
+                       if (!displayAllColumns && columnProperties != null) {
+                               int i = 0;
+
+                               Iterator<String> it = columnProperties.iterator();
+                               while (it.hasNext()) {
+                                       String columnName = it.next();
+
+                                       TableViewerColumn tvc = new TableViewerColumn(viewer,
+                                                       SWT.NONE);
+                                       tableConfigurer.configureColumn(columnName, tvc, i);
+                                       tvc.setLabelProvider(tableConfigurer
+                                                       .getLabelProvider(columnName));
+                                       tableViewerColumns.add(tvc);
+                                       i++;
+                               }
+                       } else {
+                               int i = 0;
+                               for (final String columnName : qr.getColumnNames()) {
+                                       TableViewerColumn tvc = new TableViewerColumn(viewer,
+                                                       SWT.NONE);
+                                       // Small hack to remove prefix from the column name
+                                       // String tmpStr = columnName.substring(columnName
+                                       // .lastIndexOf(".") + 1);
+                                       tableConfigurer.configureColumn(columnName, tvc, i);
+                                       tvc.setLabelProvider(tableConfigurer
+                                                       .getLabelProvider(columnName));
+                                       tableViewerColumns.add(tvc);
+                                       i++;
+                               }
+                       }
+                       // We must create a local list because query result can be read only
+                       // once.
+                       try {
+                               List<Row> rows = new ArrayList<Row>();
+                               RowIterator rit = qr.getRows();
+                               while (rit.hasNext()) {
+                                       rows.add(rit.nextRow());
+                               }
+                               viewer.setInput(rows);
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot read query result", e);
+                       }
+
+               } catch (RepositoryException e) {
+                       ErrorDialog.openError(null, "Error", "Cannot execute JCR query: "
+                                       + statement, new Status(IStatus.ERROR,
+                                       "org.argeo.eclipse.ui.jcr", e.getMessage()));
+               }
+       }
+
+       /**
+        * Client must use this method to display all columns of the result set
+        * instead of a limited predifined and injected set
+        **/
+       public void displayAllColumns(boolean flag) {
+               displayAllColumns = flag;
+       }
+
+       // Can be overridden by subclasses.
+       protected String generateSelectStatement() {
+               StringBuffer sb = new StringBuffer("select " + SAVB + ".* ");
+               return sb.toString();
+       }
+
+       protected String generateFromStatement() {
+               StringBuffer sb = new StringBuffer(" from ");
+               sb.append(SAVB);
+               sb.append(" ");
+               return sb.toString();
+       }
+
+       // Providers
+       protected class ViewContentProvider implements IStructuredContentProvider {
+               private static final long serialVersionUID = 5286293288979552056L;
+
+               public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+               }
+
+               public void dispose() {
+               }
+
+               @SuppressWarnings("unchecked")
+               public Object[] getElements(Object obj) {
+                       return ((List<String[]>) obj).toArray();
+               }
+       }
+
+       protected class ViewLabelProvider extends LabelProvider implements
+                       ITableLabelProvider {
+               private static final long serialVersionUID = -2407263563879116348L;
+
+               public String getColumnText(Object obj, int index) {
+                       if (!(obj instanceof String[]))
+                               return "Object is not properly formatted ";
+
+                       String[] value = (String[]) obj;
+
+                       return value[index];
+               }
+
+               public Image getColumnImage(Object obj, int index) {
+                       return null;
+               }
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setSession(Session session) {
+               this.session = session;
+       }
+
+       public void setColumnProperties(List<String> columnProperties) {
+               this.columnProperties = columnProperties;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AnonymousDistributionsView.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/AnonymousDistributionsView.java
new file mode 100644 (file)
index 0000000..b511c4e
--- /dev/null
@@ -0,0 +1,79 @@
+package org.argeo.slc.client.ui.dist.views;
+
+import org.argeo.cms.ArgeoNames;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.controllers.DistTreeComparator;
+import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
+import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Browse, manipulate and manage distributions accross multiple repositories
+ * (like fetch, merge, publish, etc.).
+ */
+public class AnonymousDistributionsView extends ViewPart implements SlcNames,
+               ArgeoNames {
+       // private final static Log log = LogFactory
+       // .getLog(AnonymousDistributionsView.class);
+       public final static String ID = DistPlugin.PLUGIN_ID
+                       + ".anonymousDistributionsView";
+
+       /* DEPENDENCY INJECTION */
+       private ITreeContentProvider treeContentProvider;
+
+       // This view widgets
+       private TreeViewer viewer;
+
+       @Override
+       public void createPartControl(Composite parent) {
+               // Define the TableViewer
+               viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
+                               | SWT.FULL_SELECTION | SWT.BORDER);
+
+               TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(400);
+               col.setLabelProvider(new DistTreeLabelProvider());
+
+               final Tree tree = viewer.getTree();
+               tree.setHeaderVisible(false);
+               tree.setLinesVisible(false);
+
+               // viewer.setContentProvider(new DistTreeContentProvider());
+               viewer.setContentProvider(treeContentProvider);
+               viewer.addDoubleClickListener(new DistTreeDoubleClickListener(viewer));
+               viewer.setComparator(new DistTreeComparator());
+
+               // Initialize
+               refresh();
+       }
+
+       /**
+        * Force refresh of the whole view
+        */
+       public void refresh() {
+               Object[] ee = viewer.getExpandedElements();
+               viewer.setInput(DistConstants.DEFAULT_PUBLIC_REPOSITORY_URI);
+               // viewer.expandToLevel(2);
+               viewer.setExpandedElements(ee);
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTree().setFocus();
+       }
+
+       /*
+        * DEPENDENCY INJECTION
+        */
+       public void setTreeContentProvider(ITreeContentProvider treeContentProvider) {
+               this.treeContentProvider = treeContentProvider;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/ArtifactsBrowser.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/ArtifactsBrowser.java
new file mode 100644 (file)
index 0000000..9eef477
--- /dev/null
@@ -0,0 +1,278 @@
+package org.argeo.slc.client.ui.dist.views;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistConstants;
+import org.argeo.slc.client.ui.dist.DistImages;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.controllers.ArtifactsTreeContentProvider;
+import org.argeo.slc.repo.RepoConstants;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Basic View to browse a maven based repository.
+ * 
+ * By Default size of the various bundles is not computed but it can be
+ * activated the view command.
+ */
+
+public class ArtifactsBrowser extends ViewPart implements DistConstants,
+               RepoConstants {
+       // private final static Log log = LogFactory.getLog(ArtifactsBrowser.class);
+       public final static String ID = DistPlugin.PLUGIN_ID + ".artifactsBrowser";
+
+       /* DEPENDENCY INJECTION */
+       private Session jcrSession;
+
+       // Business objects
+       private Node rootNode;
+
+       // This page widgets
+       private TreeViewer artifactTreeViewer;
+       private boolean isSizeVisible = false;
+
+       // To be able to configure columns easily
+       public static final int COLUMN_TREE = 0;
+       public static final int COLUMN_DATE = 1;
+       public static final int COLUMN_SIZE = 2;
+       private static final int SIZE_COL_WIDTH = 55;
+
+       @Override
+       public void createPartControl(Composite parent) {
+               // Enable the different parts to fill the whole page when the tab is
+               // maximized
+               parent.setLayout(new FillLayout());
+               artifactTreeViewer = createArtifactsTreeViewer(parent);
+
+               // context menu : it is completely defined in the plugin.xml file.
+               // Nothing in the context menu for the time being
+               // MenuManager menuManager = new MenuManager();
+               // Menu menu =
+               // menuManager.createContextMenu(artifactTreeViewer.getTree());
+               // artifactTreeViewer.getTree().setMenu(menu);
+               // getSite().registerContextMenu(menuManager, artifactTreeViewer);
+
+               getSite().setSelectionProvider(artifactTreeViewer);
+               // packagesViewer.setComparer(new NodeViewerComparer());
+
+               // Model initialisation
+               if (jcrSession != null) {
+                       try {
+                               rootNode = jcrSession.getNode(DEFAULT_ARTIFACTS_BASE_PATH);
+                               artifactTreeViewer.setInput(rootNode);
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot load base artifact nodes", e);
+                       }
+               }
+       }
+
+       protected TreeViewer createArtifactsTreeViewer(Composite parent) {
+               int style = SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION;
+               Tree tree = new Tree(parent, style);
+               createColumn(tree, "Artifacts", SWT.LEFT, 300);
+               createColumn(tree, "Date created", SWT.LEFT, 105);
+               createColumn(tree, "Size", SWT.RIGHT, 0);
+               tree.setLinesVisible(true);
+               tree.setHeaderVisible(true);
+
+               TreeViewer viewer = new TreeViewer(tree);
+
+               viewer.setContentProvider(new ArtifactsTreeContentProvider());
+               viewer.setLabelProvider(new ArtifactLabelProvider());
+               viewer.addSelectionChangedListener(new ArtifactTreeSelectionListener());
+               // viewer.addDoubleClickListener(new GenericDoubleClickListener());
+               viewer.setInput(rootNode);
+
+               return viewer;
+       }
+
+       private static TreeColumn createColumn(Tree parent, String name, int style,
+                       int width) {
+               TreeColumn result = new TreeColumn(parent, style);
+               result.setText(name);
+               result.setWidth(width);
+               result.setMoveable(true);
+               result.setResizable(true);
+               return result;
+       }
+
+       protected TreeViewer getArtifactTreeViewer() {
+               return artifactTreeViewer;
+       }
+
+       @Override
+       public void setFocus() {
+               // TODO Auto-generated method stub
+
+       }
+
+       /**
+        * Refresh the given element of the tree browser. If null is passed as a
+        * parameter, it refreshes the whole tree
+        */
+       public void refresh(Object element) {
+               if (element == null) {
+                       artifactTreeViewer.refresh(rootNode);
+               } else
+                       artifactTreeViewer.refresh(element);
+       }
+
+       /** Returns wether size column is visible or not */
+       public boolean isSizeVisible() {
+               return isSizeVisible;
+       }
+
+       /** Sets the visibility of the size column */
+       public void setSizeVisible(boolean visible) {
+               if (isSizeVisible == visible)
+                       return; // nothing has changed
+               else
+                       isSizeVisible = visible;
+
+               if (visible) {
+                       artifactTreeViewer.getTree().getColumn(COLUMN_SIZE)
+                                       .setWidth(SIZE_COL_WIDTH);
+               } else {
+                       // we just hide the column, we don't refresh the whole tree.
+                       artifactTreeViewer.getTree().getColumn(COLUMN_SIZE).setWidth(0);
+               }
+       }
+
+       private class ArtifactLabelProvider extends ColumnLabelProvider implements
+                       DistConstants, SlcTypes {
+               private static final long serialVersionUID = 7516705499556141806L;
+
+               // Utils
+               protected DateFormat timeFormatter = new SimpleDateFormat(
+                               DATE_TIME_FORMAT);
+
+               public void update(ViewerCell cell) {
+                       int colIndex = cell.getColumnIndex();
+                       Object element = cell.getElement();
+                       cell.setText(getColumnText(element, colIndex));
+
+                       if (element instanceof Node && colIndex == 0) {
+                               Node node = (Node) element;
+                               try {
+                                       if (node.isNodeType(SLC_ARTIFACT_BASE))
+                                               cell.setImage(DistImages.IMG_ARTIFACT_BASE);
+                                       else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE))
+                                               cell.setImage(DistImages.IMG_ARTIFACT_VERSION_BASE);
+                               } catch (RepositoryException e) {
+                                       // Silent
+                               }
+                       }
+               }
+
+               @Override
+               public Image getImage(Object element) {
+
+                       if (element instanceof Node) {
+                               Node node = (Node) element;
+                               try {
+                                       if (node.isNodeType(SLC_ARTIFACT_BASE)) {
+                                               return DistImages.IMG_ARTIFACT_BASE;
+                                       } else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) {
+                                               return DistImages.IMG_ARTIFACT_VERSION_BASE;
+                                       }
+                               } catch (RepositoryException e) {
+                                       // Silent
+                               }
+                       }
+                       return null;
+               }
+
+               public String getColumnText(Object element, int columnIndex) {
+                       try {
+                               if (element instanceof Node) {
+                                       Node node = (Node) element;
+                                       switch (columnIndex) {
+                                       case COLUMN_TREE:
+                                               return node.getName();
+                                       case COLUMN_SIZE:
+                                               if (isSizeVisible) {
+                                                       long size = JcrUtils.getNodeApproxSize(node) / 1024;
+                                                       if (size > 1024)
+                                                               return size / 1024 + " MB";
+                                                       else
+                                                               return size + " KB";
+                                               } else
+                                                       return "";
+                                       case COLUMN_DATE:
+                                               if (node.hasProperty(Property.JCR_CREATED))
+                                                       return timeFormatter.format(node
+                                                                       .getProperty(Property.JCR_CREATED)
+                                                                       .getDate().getTime());
+                                               else
+                                                       return null;
+                                       }
+                               }
+                       } catch (RepositoryException re) {
+                               throw new SlcException(
+                                               "Unexepected error while getting property values", re);
+                       }
+                       return null;
+               }
+
+               // private String formatValueAsString(Value value) {
+               // // TODO enhance this method
+               // try {
+               // String strValue;
+               //
+               // if (value.getType() == PropertyType.BINARY)
+               // strValue = "<binary>";
+               // else if (value.getType() == PropertyType.DATE)
+               // strValue = timeFormatter.format(value.getDate().getTime());
+               // else
+               // strValue = value.getString();
+               // return strValue;
+               // } catch (RepositoryException e) {
+               // throw new SlcException(
+               // "unexpected error while formatting value", e);
+               // }
+               // }
+       }
+
+       private class ArtifactTreeSelectionListener implements
+                       ISelectionChangedListener {
+
+               public void selectionChanged(SelectionChangedEvent event) {
+                       ISelection selection = event.getSelection();
+                       if (selection != null && selection instanceof IStructuredSelection) {
+                               IStructuredSelection iss = (IStructuredSelection) selection;
+                               if (iss.size() == 1) {
+                                       artifactTreeViewer.refresh(iss.getFirstElement());
+                               }
+                       }
+
+               }
+
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setJcrSession(Session jcrSession) {
+               this.jcrSession = jcrSession;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/DistributionsView.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/DistributionsView.java
new file mode 100644 (file)
index 0000000..ffebf6a
--- /dev/null
@@ -0,0 +1,370 @@
+package org.argeo.slc.client.ui.dist.views;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+
+import org.argeo.cms.ArgeoNames;
+import org.argeo.cms.ui.workbench.util.CommandUtils;
+import org.argeo.eclipse.ui.TreeParent;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.commands.CopyLocalJavaWorkspace;
+import org.argeo.slc.client.ui.dist.commands.CopyWorkspace;
+import org.argeo.slc.client.ui.dist.commands.CreateLocalJavaWorkspace;
+import org.argeo.slc.client.ui.dist.commands.CreateWorkspace;
+import org.argeo.slc.client.ui.dist.commands.DeleteWorkspace;
+import org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation;
+import org.argeo.slc.client.ui.dist.commands.Fetch;
+import org.argeo.slc.client.ui.dist.commands.NormalizeDistribution;
+import org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace;
+import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
+import org.argeo.slc.client.ui.dist.commands.PublishWorkspace;
+import org.argeo.slc.client.ui.dist.commands.RegisterRepository;
+import org.argeo.slc.client.ui.dist.commands.RunInOsgi;
+import org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo;
+import org.argeo.slc.client.ui.dist.controllers.DistTreeComparator;
+import org.argeo.slc.client.ui.dist.controllers.DistTreeComparer;
+import org.argeo.slc.client.ui.dist.controllers.DistTreeContentProvider;
+import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
+import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
+import org.argeo.slc.client.ui.dist.model.DistParentElem;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
+import org.argeo.slc.client.ui.dist.model.RepoElem;
+import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
+import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Browse, manipulate and manage distributions across multiple repositories
+ * (like fetch, merge, publish, etc.).
+ */
+public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames {
+       // private final static Log log =
+       // LogFactory.getLog(DistributionsView.class);
+
+       public final static String ID = DistPlugin.PLUGIN_ID + ".distributionsView";
+
+       /* DEPENDENCY INJECTION */
+       private Repository nodeRepository;
+       private DistTreeContentProvider treeContentProvider;
+
+       private TreeViewer viewer;
+
+       @Override
+       public void createPartControl(Composite parent) {
+               // Define the TableViewer
+               viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
+                               | SWT.FULL_SELECTION | SWT.BORDER);
+
+               TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.NONE);
+               col.getColumn().setWidth(400);
+               col.setLabelProvider(new DistTreeLabelProvider());
+
+               final Tree tree = viewer.getTree();
+               tree.setHeaderVisible(false);
+               tree.setLinesVisible(false);
+
+               // viewer.setContentProvider(new DistTreeContentProvider());
+               viewer.setContentProvider(treeContentProvider);
+               viewer.addDoubleClickListener(new DistTreeDoubleClickListener(viewer));
+               viewer.setComparer(new DistTreeComparer());
+               viewer.setComparator(new DistTreeComparator());
+
+               @SuppressWarnings("unused")
+               ViewerComparator vc = viewer.getComparator();
+
+               // Enable retrieving current tree selected items from outside the view
+               getSite().setSelectionProvider(viewer);
+
+               MenuManager menuManager = new MenuManager();
+               Menu menu = menuManager.createContextMenu(viewer.getTree());
+               menuManager.addMenuListener(new IMenuListener() {
+                       private static final long serialVersionUID = -1454108001335038652L;
+
+                       public void menuAboutToShow(IMenuManager manager) {
+                               contextMenuAboutToShow(manager);
+                       }
+               });
+               viewer.getTree().setMenu(menu);
+               getSite().registerContextMenu(menuManager, viewer);
+
+               // Initialize
+               refresh();
+       }
+
+       /** Programatically configure the context menu */
+       protected void contextMenuAboutToShow(IMenuManager menuManager) {
+               IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
+                               .getActiveWorkbenchWindow();
+
+               // Most of the implemented commands support only one selected
+               // element
+               boolean singleElement = ((IStructuredSelection) viewer.getSelection())
+                               .size() == 1;
+               // Get Current selected item :
+               Object firstElement = ((IStructuredSelection) viewer.getSelection())
+                               .getFirstElement();
+
+               try {
+
+                       if (firstElement instanceof TreeParent
+                                       || firstElement instanceof DistParentElem) {
+
+                               String targetRepoPath = null, workspaceName = null, workspacePrefix = null;
+                               String modularDistBasePath = null;
+                               String modularDistPath = null;
+                               // String targetRepoUri = null;
+                               // Build conditions depending on element type
+                               boolean isDistribElem = false, isModularDistVersionBaseElem = false, isRepoElem = false, isDistribGroupElem = false;
+                               boolean isLocal = false, isReadOnly = true;
+
+                               RepoElem re = null;
+
+                               if (firstElement instanceof RepoElem) {
+                                       re = (RepoElem) firstElement;
+                                       isRepoElem = true;
+                                       isLocal = re.inHome();
+                                       isReadOnly = re.isReadOnly();
+                               } else if (firstElement instanceof WkspGroupElem) {
+                                       WkspGroupElem wge = (WkspGroupElem) firstElement;
+                                       isReadOnly = wge.isReadOnly();
+                                       isDistribGroupElem = true;
+                                       re = (RepoElem) wge.getParent();
+                                       workspacePrefix = wge.getName();
+                               } else if (firstElement instanceof WorkspaceElem) {
+                                       WorkspaceElem we = (WorkspaceElem) firstElement;
+                                       re = we.getRepoElem();
+                                       isDistribElem = true;
+                                       isReadOnly = we.isReadOnly();
+                                       workspaceName = we.getWorkspaceName();
+                                       isLocal = we.inHome();
+                               } else if (firstElement instanceof ModularDistVersionBaseElem) {
+                                       ModularDistVersionBaseElem mdbe = (ModularDistVersionBaseElem) firstElement;
+                                       isModularDistVersionBaseElem = true;
+                                       re = mdbe.getWkspElem().getRepoElem();
+                                       isLocal = re.inHome();
+                                       isReadOnly = re.isReadOnly();
+                                       workspaceName = mdbe.getWkspElem().getWorkspaceName();
+                                       modularDistBasePath = mdbe.getModularDistBase().getPath();
+                               } else if (firstElement instanceof ModularDistVersionElem) {
+                                       ModularDistVersionElem mdbe = (ModularDistVersionElem) firstElement;
+                                       re = mdbe.getWorkspaceElem().getRepoElem();
+                                       isLocal = re.inHome();
+                                       isReadOnly = re.isReadOnly();
+                                       workspaceName = mdbe.getWorkspaceElem().getWorkspaceName();
+                                       modularDistPath = mdbe.getModularDistVersionNode()
+                                                       .getPath();
+                               }
+
+                               if (re != null) {
+                                       targetRepoPath = re.getRepoNodePath();
+                               }
+
+                               // Display repo info
+                               CommandUtils.refreshCommand(menuManager, window,
+                                               DisplayRepoInformation.ID,
+                                               DisplayRepoInformation.DEFAULT_LABEL,
+                                               DisplayRepoInformation.DEFAULT_ICON, isRepoElem
+                                                               && singleElement);
+
+                               // create workspace
+                               Map<String, String> params = new HashMap<String, String>();
+                               params.put(CreateWorkspace.PARAM_TARGET_REPO_PATH,
+                                               targetRepoPath);
+                               params.put(CreateWorkspace.PARAM_WORKSPACE_PREFIX,
+                                               workspacePrefix);
+                               CommandUtils.refreshParameterizedCommand(menuManager, window,
+                                               CreateWorkspace.ID, CreateWorkspace.DEFAULT_LABEL,
+                                               CreateWorkspace.DEFAULT_ICON,
+                                               (isRepoElem || isDistribGroupElem) && singleElement
+                                                               && !isReadOnly && !isLocal, params);
+
+                               // TODO Manage the case where it is not a java workspace
+                               params = new HashMap<String, String>();
+                               params.put(CreateLocalJavaWorkspace.PARAM_WORKSPACE_PREFIX,
+                                               workspacePrefix);
+                               CommandUtils.refreshParameterizedCommand(menuManager, window,
+                                               CreateLocalJavaWorkspace.ID,
+                                               CreateLocalJavaWorkspace.DEFAULT_LABEL,
+                                               CreateLocalJavaWorkspace.DEFAULT_ICON,
+                                               (isRepoElem || isDistribGroupElem) && singleElement
+                                                               && !isReadOnly && isLocal, params);
+
+                               // Register a remote repository
+                               CommandUtils.refreshCommand(menuManager, window,
+                                               RegisterRepository.ID,
+                                               RegisterRepository.DEFAULT_LABEL,
+                                               RegisterRepository.DEFAULT_ICON, isRepoElem
+                                                               && singleElement);
+
+                               // Unregister a remote repository
+                               params = new HashMap<String, String>();
+                               params.put(UnregisterRemoteRepo.PARAM_REPO_PATH, targetRepoPath);
+                               CommandUtils.refreshParameterizedCommand(menuManager, window,
+                                               UnregisterRemoteRepo.ID,
+                                               UnregisterRemoteRepo.DEFAULT_LABEL,
+                                               UnregisterRemoteRepo.DEFAULT_ICON, isRepoElem
+                                                               && !isLocal && singleElement, params);
+
+                               // Fetch repository
+                               params = new HashMap<String, String>();
+                               params.put(Fetch.PARAM_TARGET_REPO_PATH, targetRepoPath);
+                               CommandUtils.refreshParameterizedCommand(menuManager, window,
+                                               Fetch.ID, Fetch.DEFAULT_LABEL, Fetch.DEFAULT_ICON,
+                                               isRepoElem && isLocal && singleElement && !isReadOnly,
+                                               params);
+
+                               // Normalize workspace
+                               params = new HashMap<String, String>();
+                               params.put(NormalizeWorkspace.PARAM_TARGET_REPO_PATH,
+                                               targetRepoPath);
+                               params.put(NormalizeWorkspace.PARAM_WORKSPACE_NAME,
+                                               workspaceName);
+
+                               CommandUtils.refreshParameterizedCommand(menuManager, window,
+                                               NormalizeWorkspace.ID, "Normalize...",
+                                               NormalizeWorkspace.DEFAULT_ICON, isDistribElem
+                                                               && singleElement && !isReadOnly, params);
+
+                               // Copy workspace
+                               params = new HashMap<String, String>();
+                               params.put(CopyWorkspace.PARAM_TARGET_REPO_PATH, targetRepoPath);
+                               params.put(CopyWorkspace.PARAM_SOURCE_WORKSPACE_NAME,
+                                               workspaceName);
+                               CommandUtils.refreshParameterizedCommand(menuManager, window,
+                                               CopyWorkspace.ID, CopyWorkspace.DEFAULT_LABEL,
+                                               CopyWorkspace.DEFAULT_ICON, isDistribElem
+                                                               && singleElement && !isLocal, params);
+
+                               params = new HashMap<String, String>();
+                               params.put(CopyLocalJavaWorkspace.PARAM_SOURCE_WORKSPACE_NAME,
+                                               workspaceName);
+                               CommandUtils.refreshParameterizedCommand(menuManager, window,
+                                               CopyLocalJavaWorkspace.ID,
+                                               CopyLocalJavaWorkspace.DEFAULT_LABEL,
+                                               CopyLocalJavaWorkspace.DEFAULT_ICON, isDistribElem
+                                                               && singleElement && isLocal, params);
+
+                               // Clear Workspace
+                               params = new HashMap<String, String>();
+                               params.put(DeleteWorkspace.PARAM_TARGET_REPO_PATH,
+                                               targetRepoPath);
+                               params.put(DeleteWorkspace.PARAM_WORKSPACE_NAME, workspaceName);
+                               CommandUtils.refreshParameterizedCommand(menuManager, window,
+                                               DeleteWorkspace.ID, DeleteWorkspace.DEFAULT_LABEL,
+                                               DeleteWorkspace.DEFAULT_ICON, isDistribElem
+                                                               && singleElement && !isReadOnly, params);
+
+                               // Advanced submenu
+                               MenuManager submenu = new MenuManager("Advanced",
+                                               DistPlugin.PLUGIN_ID + ".advancedSubmenu");
+                               IContributionItem ici = menuManager.find(DistPlugin.PLUGIN_ID
+                                               + ".advancedSubmenu");
+                               if (ici != null)
+                                       menuManager.remove(ici);
+
+                               // Publish workspace
+                               params = new HashMap<String, String>();
+                               params.put(PublishWorkspace.PARAM_TARGET_REPO_PATH,
+                                               targetRepoPath);
+                               params.put(PublishWorkspace.PARAM_WORKSPACE_NAME, workspaceName);
+                               CommandUtils.refreshParameterizedCommand(submenu, window,
+                                               PublishWorkspace.ID, PublishWorkspace.DEFAULT_LABEL,
+                                               PublishWorkspace.DEFAULT_ICON, isDistribElem
+                                                               && singleElement && !isReadOnly, params);
+
+                               // Normalize distribution (Legacy)
+                               params = new HashMap<String, String>();
+                               params.put(NormalizeDistribution.PARAM_TARGET_REPO_PATH,
+                                               targetRepoPath);
+                               params.put(NormalizeDistribution.PARAM_WORKSPACE_NAME,
+                                               workspaceName);
+                               CommandUtils.refreshParameterizedCommand(submenu, window,
+                                               NormalizeDistribution.ID,
+                                               NormalizeDistribution.DEFAULT_LABEL,
+                                               NormalizeDistribution.DEFAULT_ICON, isDistribElem
+                                                               && singleElement && !isReadOnly, params);
+
+                               // Run in OSGi
+                               params = new HashMap<String, String>();
+                               params.put(RunInOsgi.PARAM_MODULE_PATH, modularDistPath);
+                               params.put(RunInOsgi.PARAM_WORKSPACE_NAME, workspaceName);
+                               CommandUtils.refreshParameterizedCommand(submenu, window,
+                                               RunInOsgi.ID, RunInOsgi.DEFAULT_LABEL,
+                                               RunInOsgi.DEFAULT_ICON, modularDistPath != null
+                                                               && singleElement && isLocal, params);
+
+                               // Open generate binaries
+                               params = new HashMap<String, String>();
+                               params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
+                                               targetRepoPath);
+                               params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
+                                               modularDistBasePath);
+                               params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
+                                               workspaceName);
+
+                               CommandUtils.refreshParameterizedCommand(submenu, window,
+                                               OpenGenerateBinariesWizard.ID,
+                                               OpenGenerateBinariesWizard.DEFAULT_LABEL,
+                                               OpenGenerateBinariesWizard.DEFAULT_ICON,
+                                               isModularDistVersionBaseElem && !isReadOnly, params);
+
+                               if (submenu.getSize() > 0)
+                                       menuManager.add(submenu);
+
+                               // // Manage workspace authorizations
+                               // params = new HashMap<String, String>();
+                               // params.put(ManageWorkspaceAuth.PARAM_WORKSPACE_NAME, wsName);
+                               // CommandHelpers.refreshParameterizedCommand(menuManager,
+                               // window,
+                               // ManageWorkspaceAuth.ID, ManageWorkspaceAuth.DEFAULT_LABEL,
+                               // ManageWorkspaceAuth.DEFAULT_ICON_PATH, isDistribElem
+                               // && singleElement && !isReadOnly, params);
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("unexpected errror while "
+                                       + "building context menu for element " + firstElement, e);
+               }
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTree().setFocus();
+       }
+
+       /**
+        * Force refresh of the whole view
+        */
+       public void refresh() {
+               viewer.setInput(nodeRepository);
+               viewer.expandToLevel(2);
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setTreeContentProvider(
+                       DistTreeContentProvider treeContentProvider) {
+               this.treeContentProvider = treeContentProvider;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/HelpView.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/HelpView.java
new file mode 100644 (file)
index 0000000..105f36d
--- /dev/null
@@ -0,0 +1,31 @@
+package org.argeo.slc.client.ui.dist.views;
+
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+/** Display some info about the distribution */
+public class HelpView extends ViewPart {
+       public final static String ID = DistPlugin.PLUGIN_ID + ".helpView";
+
+       @Override
+       public void createPartControl(Composite parent) {
+               parent.setLayout(new GridLayout(2, false));
+               Browser browser = new Browser(parent, SWT.NONE);
+               browser.setUrl("/repo/howto.html");
+               browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+       }
+
+       /** Force refresh of the whole view */
+       public void refresh() {
+       }
+
+       @Override
+       public void setFocus() {
+       }
+
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsForm.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsForm.java
new file mode 100644 (file)
index 0000000..9ce41d4
--- /dev/null
@@ -0,0 +1,156 @@
+package org.argeo.slc.client.ui.dist.views;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+/** Query SLC Repo to get some artifacts given some predefined parameters */
+public class QueryArtifactsForm extends AbstractQueryArtifactsView implements
+               SlcNames {
+       // private static final Log log = LogFactory.getLog(QueryArtifactsForm.class);
+       public static final String ID = DistPlugin.PLUGIN_ID + ".queryArtifactsForm";
+
+       // widgets
+       private Button executeBtn;
+       private Text groupId;
+       private Text artifactId;
+       private Text version;
+       private SashForm sashForm;
+
+       private Composite top, bottom;
+
+       @Override
+       public void createPartControl(Composite parent) {
+
+               sashForm = new SashForm(parent, SWT.VERTICAL);
+               sashForm.setSashWidth(4);
+               // Enable the different parts to fill the whole page when the tab is
+               // maximized
+               sashForm.setLayout(new FillLayout());
+
+               top = new Composite(sashForm, SWT.NONE);
+               top.setLayout(new GridLayout(1, false));
+
+               bottom = new Composite(sashForm, SWT.NONE);
+               bottom.setLayout(new GridLayout(1, false));
+
+               sashForm.setWeights(new int[] { 25, 75 });
+
+               createQueryForm(top);
+               createResultPart(bottom);
+       }
+
+       public void createQueryForm(Composite parent) {
+               Label lbl;
+               GridData gd;
+
+               GridLayout gl = new GridLayout(2, false);
+               gl.marginTop = 5;
+               parent.setLayout(gl);
+
+               // lbl = new Label(parent, SWT.SINGLE);
+               // lbl.setText("Query by coordinates");
+               // gd = new GridData();
+               // gd.horizontalSpan = 2;
+               // lbl.setLayoutData(gd);
+
+               // Group ID
+               lbl = new Label(parent, SWT.SINGLE);
+               lbl.setText("Group ID");
+               groupId = new Text(parent, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               groupId.setLayoutData(gd);
+
+               // Artifact ID
+               lbl = new Label(parent, SWT.SINGLE);
+               lbl.setText("Artifact ID");
+               artifactId = new Text(parent, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               artifactId.setLayoutData(gd);
+
+               // Version
+               lbl = new Label(parent, SWT.SINGLE);
+               lbl.setText("Version");
+               version = new Text(parent, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               version.setLayoutData(gd);
+
+               executeBtn = new Button(parent, SWT.PUSH);
+               executeBtn.setText("Search");
+               gd = new GridData();
+               gd.horizontalSpan = 2;
+               executeBtn.setLayoutData(gd);
+
+               Listener executeListener = new Listener() {
+                       private static final long serialVersionUID = 7161585477628774129L;
+
+                       public void handleEvent(Event event) {
+                               refreshQuery();
+                       }
+               };
+               executeBtn.addListener(SWT.Selection, executeListener);
+       }
+
+       public void refreshQuery() {
+               String queryStr = generateSelectStatement() + generateFromStatement()
+                               + generateWhereStatement();
+               executeQuery(queryStr);
+               bottom.layout();
+               sashForm.layout();
+       }
+
+       private String generateWhereStatement() {
+               try {
+                       boolean hasFirstClause = false;
+                       StringBuffer sb = new StringBuffer(" where ");
+
+                       if (groupId.getText() != null
+                                       && !groupId.getText().trim().equals("")) {
+                               sb.append("[" + SLC_GROUP_ID + "] like '"
+                                               + groupId.getText().replace('*', '%') + "'");
+                               hasFirstClause = true;
+                       }
+
+                       if (artifactId.getText() != null
+                                       && !artifactId.getText().trim().equals("")) {
+                               if (hasFirstClause)
+                                       sb.append(" AND ");
+                               sb.append("[" + SLC_ARTIFACT_ID + "] like '"
+                                               + artifactId.getText().replace('*', '%') + "'");
+                               hasFirstClause = true;
+                       }
+
+                       if (version.getText() != null
+                                       && !version.getText().trim().equals("")) {
+                               if (hasFirstClause)
+                                       sb.append(" AND ");
+                               sb.append("[" + SLC_ARTIFACT_VERSION + "] like '"
+                                               + version.getText().replace('*', '%') + "'");
+                       }
+
+                       return sb.toString();
+               } catch (Exception e) {
+                       throw new SlcException(
+                                       "Cannot generate where statement to get artifacts", e);
+               }
+       }
+
+       @Override
+       public void setFocus() {
+               executeBtn.setFocus();
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsText.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryArtifactsText.java
new file mode 100644 (file)
index 0000000..3b0be10
--- /dev/null
@@ -0,0 +1,103 @@
+package org.argeo.slc.client.ui.dist.views;
+
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+/** Query SLC Repo to get some artifacts with a JCR SQL 2 request. */
+public class QueryArtifactsText extends AbstractQueryArtifactsView implements
+               SlcNames {
+       // private static final Log log =
+       // LogFactory.getLog(QueryArtifactsText.class);
+       public static final String ID = DistPlugin.PLUGIN_ID + ".queryArtifactsText";
+
+       // widgets
+       private Button executeBtn;
+       private Text queryText;
+       private SashForm sashForm;
+
+       private Composite top, bottom;
+
+       @Override
+       public void createPartControl(Composite parent) {
+
+               sashForm = new SashForm(parent, SWT.VERTICAL);
+               sashForm.setSashWidth(4);
+               // Enable the different parts to fill the whole page when the tab is
+               // maximized
+               sashForm.setLayout(new FillLayout());
+
+               top = new Composite(sashForm, SWT.NONE);
+               top.setLayout(new GridLayout(1, false));
+
+               bottom = new Composite(sashForm, SWT.NONE);
+               bottom.setLayout(new GridLayout(1, false));
+
+               sashForm.setWeights(new int[] { 25, 75 });
+
+               createQueryForm(top);
+               createResultPart(bottom);
+       }
+
+       public void createQueryForm(Composite parent) {
+               Label lbl;
+               GridData gd;
+
+               GridLayout gl = new GridLayout(2, false);
+               gl.marginTop = 5;
+               parent.setLayout(gl);
+
+               lbl = new Label(parent, SWT.SINGLE);
+               lbl.setText("Enter a JCR:SQL2 Query");
+
+               executeBtn = new Button(parent, SWT.PUSH);
+               executeBtn.setText("Search");
+
+               queryText = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               gd.heightHint = 100;
+               gd.horizontalSpan = 2;
+               queryText.setLayoutData(gd);
+
+               String query = generateSelectStatement() + generateFromStatement()
+                               + generateWhereStatement();
+               queryText.setText(query);
+
+               Listener executeListener = new Listener() {
+                       private static final long serialVersionUID = -5028331930076117569L;
+
+                       public void handleEvent(Event event) {
+                               refreshQuery();
+                       }
+               };
+               executeBtn.addListener(SWT.Selection, executeListener);
+       }
+
+       public void refreshQuery() {
+               String queryStr = queryText.getText();
+               executeQuery(queryStr);
+               bottom.layout();
+               sashForm.layout();
+       }
+
+       private String generateWhereStatement() {
+               StringBuffer sb = new StringBuffer(" where ");
+               return sb.toString();
+       }
+
+       @Override
+       public void setFocus() {
+               executeBtn.setFocus();
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryBundlesForm.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/views/QueryBundlesForm.java
new file mode 100644 (file)
index 0000000..c4980d5
--- /dev/null
@@ -0,0 +1,174 @@
+package org.argeo.slc.client.ui.dist.views;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+/** Query SLC Repo to get some artifacts given some predefined parameters */
+public class QueryBundlesForm extends AbstractQueryArtifactsView implements
+               SlcNames, SlcTypes {
+       // private static final Log log = LogFactory.getLog(QueryBundlesForm.class);
+       public static final String ID = DistPlugin.PLUGIN_ID + ".queryBundlesForm";
+
+       // widgets
+       private Button executeBtn;
+       private Text symbolicName;
+       private Text importedPackage;
+       private Text exportedPackage;
+       private SashForm sashForm;
+
+       private Composite top, bottom;
+
+       @Override
+       public void createPartControl(Composite parent) {
+
+               sashForm = new SashForm(parent, SWT.VERTICAL);
+               sashForm.setSashWidth(4);
+               // Enable the different parts to fill the whole page when the tab is
+               // maximized
+               sashForm.setLayout(new FillLayout());
+
+               top = new Composite(sashForm, SWT.NONE);
+               top.setLayout(new GridLayout(1, false));
+
+               bottom = new Composite(sashForm, SWT.NONE);
+               bottom.setLayout(new GridLayout(1, false));
+
+               sashForm.setWeights(new int[] { 25, 75 });
+
+               createQueryForm(top);
+               createResultPart(bottom);
+       }
+
+       public void createQueryForm(Composite parent) {
+               Label lbl;
+               GridData gd;
+
+               GridLayout gl = new GridLayout(2, false);
+               gl.marginTop = 5;
+               parent.setLayout(gl);
+
+               // Bundle Name
+               lbl = new Label(parent, SWT.SINGLE);
+               lbl.setText("Symbolic name");
+               symbolicName = new Text(parent, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               symbolicName.setLayoutData(gd);
+
+               // imported package
+               lbl = new Label(parent, SWT.SINGLE);
+               lbl.setText("Imported package");
+               importedPackage = new Text(parent, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               importedPackage.setLayoutData(gd);
+
+               // exported package
+               lbl = new Label(parent, SWT.SINGLE);
+               lbl.setText("Exported package");
+               exportedPackage = new Text(parent, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.grabExcessHorizontalSpace = true;
+               exportedPackage.setLayoutData(gd);
+
+               executeBtn = new Button(parent, SWT.PUSH);
+               executeBtn.setText("Search");
+               gd = new GridData();
+               gd.horizontalSpan = 2;
+               executeBtn.setLayoutData(gd);
+
+               Listener executeListener = new Listener() {
+                       private static final long serialVersionUID = 6267263421349073712L;
+
+                       public void handleEvent(Event event) {
+                               refreshQuery();
+                       }
+               };
+               executeBtn.addListener(SWT.Selection, executeListener);
+       }
+
+       public void refreshQuery() {
+               String queryStr = generateStatement();
+               executeQuery(queryStr);
+               bottom.layout();
+               sashForm.layout();
+       }
+
+       private String generateStatement() {
+               try {
+                       // shortcuts
+                       boolean hasFirstClause = false;
+                       boolean ipClause = importedPackage.getText() != null
+                                       && !importedPackage.getText().trim().equals("");
+                       boolean epClause = exportedPackage.getText() != null
+                                       && !exportedPackage.getText().trim().equals("");
+
+                       StringBuffer sb = new StringBuffer();
+                       // Select
+                       sb.append("select " + SBA + ".*, " + SAVB + ".* ");
+                       sb.append(" from " + SAVB);
+
+                       // join
+                       sb.append(" inner join ");
+                       sb.append(SBA);
+                       sb.append(" on isdescendantnode(" + SBA + ", " + SAVB + ") ");
+                       if (ipClause) {
+                               sb.append(" inner join ");
+                               sb.append(SIP);
+                               sb.append(" on isdescendantnode(" + SIP + ", " + SBA + ") ");
+                       }
+
+                       if (epClause) {
+                               sb.append(" inner join ");
+                               sb.append(SEP);
+                               sb.append(" on isdescendantnode(" + SEP + ", " + SBA + ") ");
+                       }
+
+                       // where
+                       sb.append(" where ");
+                       if (symbolicName.getText() != null
+                                       && !symbolicName.getText().trim().equals("")) {
+                               sb.append(SBA + ".[" + SLC_SYMBOLIC_NAME + "] like '"
+                                               + symbolicName.getText().replace('*', '%') + "'");
+                               hasFirstClause = true;
+                       }
+
+                       if (ipClause) {
+                               if (hasFirstClause)
+                                       sb.append(" AND ");
+                               sb.append(SIP + ".[" + SLC_NAME + "] like '"
+                                               + importedPackage.getText().replace('*', '%') + "'");
+                               hasFirstClause = true;
+                       }
+
+                       if (epClause) {
+                               if (hasFirstClause)
+                                       sb.append(" AND ");
+                               sb.append(SEP + ".[" + SLC_NAME + "] like '"
+                                               + exportedPackage.getText().replace('*', '%') + "'");
+                       }
+                       return sb.toString();
+               } catch (Exception e) {
+                       throw new SlcException(
+                                       "Cannot generate where statement to get artifacts", e);
+               }
+       }
+
+       @Override
+       public void setFocus() {
+               executeBtn.setFocus();
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChangeRightsWizard.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChangeRightsWizard.java
new file mode 100644 (file)
index 0000000..9dce9a0
--- /dev/null
@@ -0,0 +1,49 @@
+package org.argeo.slc.client.ui.dist.wizards;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.eclipse.jface.wizard.Wizard;
+
+/**
+ * Small wizard to manage authorizations on the root node of the current
+ * workspace
+ */
+public class ChangeRightsWizard extends Wizard {
+
+       private Session currentSession;
+
+       // This page widget
+       private ChooseRightsPage page;
+
+       public ChangeRightsWizard(Session currentSession) {
+               super();
+               this.currentSession = currentSession;
+       }
+
+       @Override
+       public void addPages() {
+               try {
+                       page = new ChooseRightsPage();
+                       addPage(page);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot add page to wizard ", e);
+               }
+       }
+
+       @Override
+       public boolean performFinish() {
+               if (!canFinish())
+                       return false;
+               try {
+                       JcrUtils.addPrivilege(currentSession, "/", page.getGroupName(),
+                                       page.getAuthTypeStr());
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while setting privileges", re);
+               }
+               return true;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChooseRightsPage.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/ChooseRightsPage.java
new file mode 100644 (file)
index 0000000..fcd4097
--- /dev/null
@@ -0,0 +1,94 @@
+package org.argeo.slc.client.ui.dist.wizards;
+
+import javax.jcr.security.Privilege;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class ChooseRightsPage extends WizardPage implements ModifyListener {
+       private static final long serialVersionUID = 3016024222014878781L;
+
+       // This page widget
+       private Text groupNameTxt;
+       private Combo authorizationCmb;
+
+       // Define acceptable chars for the technical name
+       // private static Pattern p = Pattern.compile("^[A-Za-z0-9]+$");
+
+       // USABLE SHORTCUTS
+       protected final static String[] validAuthType = { Privilege.JCR_READ,
+                       Privilege.JCR_WRITE, Privilege.JCR_ALL };
+
+       public ChooseRightsPage() {
+               super("Main");
+               setTitle("Manage authorizations on the current workspace");
+       }
+
+       public void createControl(Composite parent) {
+               // specify subject
+               Composite composite = new Composite(parent, SWT.NONE);
+               composite.setLayout(new GridLayout(2, false));
+               Label lbl = new Label(composite, SWT.LEAD);
+               lbl.setText("Group or user name (no blank, no special chars)");
+               lbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+               groupNameTxt = new Text(composite, SWT.LEAD | SWT.BORDER);
+               groupNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
+                               false));
+               if (groupNameTxt != null)
+                       groupNameTxt.addModifyListener(this);
+
+               // Choose rigths
+               new Label(composite, SWT.NONE).setText("Choose corresponding rights");
+               authorizationCmb = new Combo(composite, SWT.BORDER | SWT.V_SCROLL);
+               authorizationCmb.setItems(validAuthType);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               authorizationCmb.setLayoutData(gd);
+
+               authorizationCmb.select(0);
+
+               // Compulsory
+               setControl(composite);
+       }
+
+       protected String getGroupName() {
+               return groupNameTxt.getText();
+       }
+
+       protected String getAuthTypeStr() {
+               return authorizationCmb.getItem(authorizationCmb.getSelectionIndex());
+       }
+
+       // private static boolean match(String s) {
+       // return p.matcher(s).matches();
+       // }
+
+       public void modifyText(ModifyEvent event) {
+               String message = checkComplete();
+               if (message != null)
+                       setMessage(message, WizardPage.ERROR);
+               else {
+                       setMessage("Complete", WizardPage.INFORMATION);
+                       setPageComplete(true);
+               }
+       }
+
+       /** @return error message or null if complete */
+       protected String checkComplete() {
+               String groupStr = groupNameTxt.getText();
+               if (groupStr == null || "".equals(groupStr))
+                       return "Please enter the name of the corresponding group.";
+               // Remove regexp check for the time being.
+               // else if (!match(groupStr))
+               // return
+               // "Please use only alphanumerical chars for the short technical name.";
+               return null;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java
new file mode 100644 (file)
index 0000000..888478d
--- /dev/null
@@ -0,0 +1,671 @@
+package org.argeo.slc.client.ui.dist.wizards;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.api.NodeUtils;
+import org.argeo.api.security.Keyring;
+import org.argeo.cms.ArgeoNames;
+import org.argeo.cms.ArgeoTypes;
+import org.argeo.cms.ui.workbench.util.PrivilegedJob;
+import org.argeo.eclipse.ui.EclipseJcrMonitor;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.ViewerUtils;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoSync;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Defines parameters for the fetch process and run it using a {@link RepoSync}
+ * object.
+ */
+public class FetchWizard extends Wizard {
+       // private final static Log log = LogFactory.getLog(FetchWizard.class);
+
+       // Business objects
+       private Keyring keyring;
+       private RepositoryFactory repositoryFactory;
+       private Session currSession;
+       private Node targetRepoNode, sourceRepoNode;
+
+       private List<WkspObject> selectedWorkspaces = new ArrayList<WkspObject>();
+
+       // The pages
+       private ChooseWkspPage chooseWkspPage;
+       private RecapPage recapPage;
+
+       // Cache the advanced pages
+       private Map<WkspObject, AdvancedFetchPage> advancedPages = new HashMap<FetchWizard.WkspObject, FetchWizard.AdvancedFetchPage>();
+
+       // Controls with parameters
+       private Button filesOnlyBtn;
+       private Button advancedBtn;
+       private CheckboxTableViewer wkspViewer;
+
+       public FetchWizard(Keyring keyring, RepositoryFactory repositoryFactory,
+                       Repository nodeRepository) {
+               super();
+               this.keyring = keyring;
+               this.repositoryFactory = repositoryFactory;
+               try {
+                       currSession = nodeRepository.login();
+               } catch (RepositoryException e) {
+                       throw new SlcException(
+                                       "Unexpected error while initializing fetch wizard", e);
+               }
+       }
+
+       @Override
+       public void dispose() {
+               JcrUtils.logoutQuietly(currSession);
+               super.dispose();
+       }
+
+       @Override
+       public void addPages() {
+               try {
+                       chooseWkspPage = new ChooseWkspPage();
+                       addPage(chooseWkspPage);
+                       recapPage = new RecapPage();
+                       addPage(recapPage);
+                       setWindowTitle("Define Fetch Procedure");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot add page to wizard ", e);
+               }
+       }
+
+       @Override
+       public boolean performFinish() {
+               if (!canFinish())
+                       return false;
+               try {
+                       // Target Repository
+                       String targetRepoUri = targetRepoNode.getProperty(
+                                       ArgeoNames.ARGEO_URI).getString();
+                       Repository targetRepo = RepoUtils.getRepository(repositoryFactory,
+                                       keyring, targetRepoNode);
+                       Credentials targetCredentials = RepoUtils.getRepositoryCredentials(
+                                       keyring, targetRepoNode);
+
+                       // Source Repository
+                       String sourceRepoUri = sourceRepoNode.getProperty(
+                                       ArgeoNames.ARGEO_URI).getString();
+                       Repository sourceRepo = RepoUtils.getRepository(repositoryFactory,
+                                       keyring, sourceRepoNode);
+                       Credentials sourceCredentials = RepoUtils.getRepositoryCredentials(
+                                       keyring, sourceRepoNode);
+
+                       String msg = "Your are about to fetch data from repository: \n\t"
+                                       + sourceRepoUri + "\ninto target repository: \n\t"
+                                       + targetRepoUri + "\nDo you really want to proceed ?";
+
+                       boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
+                                       .getWorkbench().getDisplay().getActiveShell(),
+                                       "Confirm Fetch Launch", msg);
+
+                       if (result) {
+                               RepoSync repoSync = new RepoSync(sourceRepo, sourceCredentials,
+                                               targetRepo, targetCredentials);
+                               repoSync.setTargetRepoUri(targetRepoUri);
+                               repoSync.setSourceRepoUri(sourceRepoUri);
+
+                               // Specify workspaces to synchronise
+                               Map<String, String> wksps = new HashMap<String, String>();
+                               for (Object obj : wkspViewer.getCheckedElements()) {
+                                       WkspObject stn = (WkspObject) obj;
+                                       wksps.put(stn.srcName, stn.targetName);
+                               }
+                               repoSync.setWkspMap(wksps);
+
+                               // Set the import files only option
+                               repoSync.setFilesOnly(filesOnlyBtn.getSelection());
+                               FetchJob job = new FetchJob(repoSync);
+                               job.setUser(true);
+                               job.schedule();
+                       }
+               } catch (Exception e) {
+                       throw new SlcException(
+                                       "Unexpected error while launching the fetch", e);
+               }
+               return true;
+       }
+
+       // ///////////////////////////////
+       // ////// THE PAGES
+
+       private class ChooseWkspPage extends WizardPage {
+               private static final long serialVersionUID = 211336700788047638L;
+
+               private Map<String, Node> sourceReposMap;
+               private Combo chooseSourceRepoCmb;
+
+               public ChooseWkspPage() {
+                       super("Main");
+                       setTitle("Choose workspaces to fetch");
+                       setDescription("Check 'advanced fetch' box to "
+                                       + "rename workspaces and fine tune the process");
+
+                       // Initialise with registered Repositories
+                       sourceReposMap = getSourceRepoUris();
+               }
+
+               public void createControl(Composite parent) {
+                       Composite composite = new Composite(parent, SWT.NO_FOCUS);
+                       composite.setLayout(new GridLayout(2, false));
+
+                       // Choose source repository combo
+                       new Label(composite, SWT.NONE)
+                                       .setText("Choose a source repository");
+                       chooseSourceRepoCmb = new Combo(composite, SWT.BORDER
+                                       | SWT.V_SCROLL);
+                       chooseSourceRepoCmb.setItems(sourceReposMap.keySet().toArray(
+                                       new String[sourceReposMap.size()]));
+                       GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+                       chooseSourceRepoCmb.setLayoutData(gd);
+
+                       // Check boxes
+                       final Button selectAllBtn = new Button(composite, SWT.CHECK);
+                       selectAllBtn.setText("Select/Unselect all");
+
+                       advancedBtn = new Button(composite, SWT.CHECK);
+                       advancedBtn.setText("Advanced fetch");
+                       advancedBtn.setToolTipText("Check this for further "
+                                       + "parameterization of the fetch process");
+
+                       // Workspace table
+                       Table table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL
+                                       | SWT.BORDER | SWT.CHECK);
+                       gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+                       gd.horizontalSpan = 2;
+                       table.setLayoutData(gd);
+                       configureWkspTable(table);
+
+                       // Import only files
+                       filesOnlyBtn = new Button(composite, SWT.CHECK | SWT.WRAP);
+                       filesOnlyBtn
+                                       .setText("Import only files (faster, a normalized action should be launched once done)");
+                       filesOnlyBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
+                                       false, 2, 1));
+
+                       // Listeners
+                       selectAllBtn.addSelectionListener(new SelectionAdapter() {
+                               private static final long serialVersionUID = -2071840477444152170L;
+
+                               public void widgetSelected(SelectionEvent e) {
+                                       wkspViewer.setAllChecked(selectAllBtn.getSelection());
+                                       getContainer().updateButtons();
+                               }
+                       });
+
+                       // advancedBtn.addSelectionListener(new SelectionAdapter() {
+                       // public void widgetSelected(SelectionEvent e) {
+                       // if (advancedBtn.getSelection()){
+                       //
+                       // }
+                       // wkspViewer.setAllChecked();
+                       // }
+                       // });
+
+                       chooseSourceRepoCmb.addModifyListener(new ModifyListener() {
+                               private static final long serialVersionUID = 932462568382594523L;
+
+                               public void modifyText(ModifyEvent e) {
+                                       String chosenUri = chooseSourceRepoCmb
+                                                       .getItem(chooseSourceRepoCmb.getSelectionIndex());
+                                       sourceRepoNode = sourceReposMap.get(chosenUri);
+                                       wkspViewer.setInput(sourceRepoNode);
+                               }
+                       });
+
+                       wkspViewer.addCheckStateListener(new ICheckStateListener() {
+                               public void checkStateChanged(CheckStateChangedEvent event) {
+                                       getContainer().updateButtons();
+                               }
+                       });
+
+                       // Initialise to first available repo
+                       if (chooseSourceRepoCmb.getItemCount() > 0)
+                               chooseSourceRepoCmb.select(0);
+
+                       // Compulsory
+                       setControl(composite);
+               }
+
+               @Override
+               public boolean isPageComplete() {
+                       return wkspViewer.getCheckedElements().length != 0;
+               }
+
+               @Override
+               public IWizardPage getNextPage() {
+                       // WARNING: page are added and never removed.
+                       if (advancedBtn.getSelection()
+                                       && wkspViewer.getCheckedElements().length != 0) {
+                               IWizardPage toReturn = null;
+                               for (Object obj : wkspViewer.getCheckedElements()) {
+                                       WkspObject curr = (WkspObject) obj;
+                                       // currSelecteds.add(curr);
+                                       AdvancedFetchPage page;
+                                       if (!advancedPages.containsKey(curr)) {
+                                               page = new AdvancedFetchPage(curr.srcName, curr);
+                                               addPage(page);
+                                               advancedPages.put(curr, page);
+                                       } else
+                                               page = advancedPages.get(curr);
+                                       if (toReturn == null)
+                                               toReturn = page;
+                               }
+                               return toReturn;
+                       } else {
+                               return recapPage;
+                       }
+               }
+
+               // Configure the workspace table
+               private void configureWkspTable(Table table) {
+                       table.setLinesVisible(true);
+                       table.setHeaderVisible(true);
+                       wkspViewer = new CheckboxTableViewer(table);
+
+                       // WORKSPACE COLUMNS
+                       TableViewerColumn column = ViewerUtils.createTableViewerColumn(
+                                       wkspViewer, "Source names", SWT.NONE, 250);
+                       column.setLabelProvider(new ColumnLabelProvider() {
+                               private static final long serialVersionUID = 5906079281065061967L;
+
+                               @Override
+                               public String getText(Object element) {
+                                       return ((WkspObject) element).srcName;
+                               }
+                       });
+
+                       // column = ViewerUtils.createTableViewerColumn(wkspViewer, "Size",
+                       // SWT.NONE, 250);
+                       // column.setLabelProvider(new ColumnLabelProvider() {
+                       // @Override
+                       // public String getText(Object element) {
+                       // return ((WkspObject) element).getFormattedSize();
+                       // }
+                       // });
+
+                       wkspViewer.setContentProvider(new WkspContentProvider());
+                       // A basic comparator
+                       wkspViewer.setComparator(new ViewerComparator());
+               }
+       }
+
+       private class AdvancedFetchPage extends WizardPage {
+               private static final long serialVersionUID = 1109183561920445169L;
+
+               private final WkspObject currentWorkspace;
+
+               private Text targetNameTxt;
+
+               protected AdvancedFetchPage(String pageName, WkspObject currentWorkspace) {
+                       super(pageName);
+                       this.currentWorkspace = currentWorkspace;
+               }
+
+               @Override
+               public void setVisible(boolean visible) {
+                       super.setVisible(visible);
+                       if (visible) {
+                               String msg = "Define advanced parameters to fetch workspace "
+                                               + currentWorkspace.srcName;
+                               setMessage(msg);
+                               targetNameTxt.setText(currentWorkspace.targetName);
+                       }
+                       // else
+                       // currentWorkspace.targetName = targetNameTxt.getText();
+               }
+
+               public void createControl(Composite parent) {
+                       Composite body = new Composite(parent, SWT.NO_FOCUS);
+                       body.setLayout(new GridLayout(2, false));
+                       new Label(body, SWT.NONE).setText("Choose a new name");
+                       targetNameTxt = new Text(body, SWT.BORDER);
+                       targetNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
+                                       true, false));
+                       setControl(body);
+               }
+
+               protected WkspObject getWorkspaceObject() {
+                       currentWorkspace.targetName = targetNameTxt.getText();
+                       return currentWorkspace;
+               }
+
+               @Override
+               public IWizardPage getNextPage() {
+                       // WARNING: page are added and never removed.
+                       // IWizardPage toReturn = null;
+                       // IWizardPage[] pages = ((Wizard) getContainer()).getPages();
+                       Object[] selected = wkspViewer.getCheckedElements();
+                       for (int i = 0; i < selected.length - 1; i++) {
+                               WkspObject curr = (WkspObject) selected[i];
+                               if (curr.equals(currentWorkspace))
+                                       return advancedPages.get((WkspObject) selected[i + 1]);
+                       }
+                       return recapPage;
+               }
+       }
+
+       private class RecapPage extends WizardPage {
+               private static final long serialVersionUID = -7064862323304300989L;
+               private TableViewer recapViewer;
+
+               public RecapPage() {
+                       super("Validate and launch");
+                       setTitle("Validate and launch");
+               }
+
+               @Override
+               public boolean isPageComplete() {
+                       return isCurrentPage();
+               }
+
+               public IWizardPage getNextPage() {
+                       // always last....
+                       return null;
+               }
+
+               @Override
+               public void setVisible(boolean visible) {
+                       super.setVisible(visible);
+                       if (visible) {
+                               try {
+                                       String targetRepoUri = targetRepoNode.getProperty(
+                                                       ArgeoNames.ARGEO_URI).getString();
+                                       String sourceRepoUri = sourceRepoNode.getProperty(
+                                                       ArgeoNames.ARGEO_URI).getString();
+
+                                       String msg = "Fetch data from: " + sourceRepoUri
+                                                       + "\ninto target repository: " + targetRepoUri;
+                                       // + "\nDo you really want to proceed ?";
+                                       setMessage(msg);
+
+                                       // update values that will be used for the fetch
+                                       selectedWorkspaces.clear();
+
+                                       for (Object obj : wkspViewer.getCheckedElements()) {
+                                               WkspObject curr = (WkspObject) obj;
+
+                                               if (advancedBtn.getSelection()) {
+                                                       AdvancedFetchPage page = advancedPages.get(curr);
+                                                       selectedWorkspaces.add(page.getWorkspaceObject());
+                                               } else
+                                                       selectedWorkspaces.add(curr);
+                                       }
+                                       recapViewer.setInput(selectedWorkspaces);
+                                       recapViewer.refresh();
+
+                               } catch (RepositoryException re) {
+                                       throw new SlcException("Unable to get repositories URIs",
+                                                       re);
+                               }
+                       }
+               }
+
+               public void createControl(Composite parent) {
+                       Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL
+                                       | SWT.BORDER);
+                       table.setLinesVisible(true);
+                       table.setHeaderVisible(true);
+                       recapViewer = new TableViewer(table);
+
+                       // WORKSPACE COLUMNS
+                       TableViewerColumn column = ViewerUtils.createTableViewerColumn(
+                                       recapViewer, "Sources", SWT.NONE, 250);
+                       column.setLabelProvider(new ColumnLabelProvider() {
+                               private static final long serialVersionUID = 3913459002502680377L;
+
+                               @Override
+                               public String getText(Object element) {
+                                       return ((WkspObject) element).srcName;
+                               }
+                       });
+
+                       column = ViewerUtils.createTableViewerColumn(recapViewer,
+                                       "targets", SWT.NONE, 250);
+                       column.setLabelProvider(new ColumnLabelProvider() {
+                               private static final long serialVersionUID = -517920072332563632L;
+
+                               @Override
+                               public String getText(Object element) {
+                                       return ((WkspObject) element).targetName;
+                               }
+                       });
+
+                       recapViewer.setContentProvider(new IStructuredContentProvider() {
+                               private static final long serialVersionUID = 4926999891003040865L;
+
+                               public void inputChanged(Viewer viewer, Object oldInput,
+                                               Object newInput) {
+                                       // TODO Auto-generated method stub
+                               }
+
+                               public void dispose() {
+                               }
+
+                               public Object[] getElements(Object inputElement) {
+                                       return selectedWorkspaces.toArray();
+                               }
+                       });
+
+                       // A basic comparator
+                       recapViewer.setComparator(new ViewerComparator());
+                       setControl(table);
+               }
+       }
+
+       /**
+        * Define the privileged job that will be run asynchronously to accomplish
+        * the sync
+        */
+       private class FetchJob extends PrivilegedJob {
+               private RepoSync repoSync;
+
+               public FetchJob(RepoSync repoSync) {
+                       super("Fetch");
+                       this.repoSync = repoSync;
+               }
+
+               @Override
+               protected IStatus doRun(IProgressMonitor progressMonitor) {
+                       try {
+                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
+                               repoSync.setMonitor(monitor);
+                               repoSync.run();
+                       } catch (Exception e) {
+                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
+                                               "Cannot fetch repository", e);
+                       }
+                       return Status.OK_STATUS;
+               }
+       }
+
+       // ///////////////////////
+       // Local classes
+       private class WkspObject {
+               protected final String srcName;
+               protected String targetName;
+
+               protected WkspObject(String srcName) {
+                       this.srcName = srcName;
+                       this.targetName = srcName;
+               }
+
+               @Override
+               public String toString() {
+                       return "[" + srcName + " to " + targetName + "]";
+               }
+       }
+
+       // private class WkspComparator extends ViewerComparator {
+       //
+       // }
+
+       private class WkspContentProvider implements IStructuredContentProvider {
+               private static final long serialVersionUID = -925058051598536307L;
+               // caches current repo
+               private Node currSourceNodeRepo;
+               private Repository currSourceRepo;
+               private Credentials currSourceCred;
+
+               private List<WkspObject> workspaces = new ArrayList<WkspObject>();
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       if (newInput != null && newInput instanceof Node) {
+                               Session session = null;
+                               try {
+                                       Node newRepoNode = (Node) newInput;
+                                       if (currSourceNodeRepo == null
+                                                       || !newRepoNode.getPath().equals(
+                                                                       currSourceNodeRepo.getPath())) {
+
+                                               // update cache
+                                               currSourceNodeRepo = newRepoNode;
+                                               currSourceRepo = RepoUtils.getRepository(
+                                                               repositoryFactory, keyring, currSourceNodeRepo);
+                                               currSourceCred = RepoUtils.getRepositoryCredentials(
+                                                               keyring, currSourceNodeRepo);
+
+                                               // reset workspace list
+                                               wkspViewer.setAllChecked(false);
+                                               workspaces.clear();
+                                               // FIXME make it more generic
+                                               session = currSourceRepo.login(currSourceCred,RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
+                                               // remove unvalid elements
+                                               for (String name : session.getWorkspace()
+                                                               .getAccessibleWorkspaceNames())
+                                                       // TODO implement a cleaner way to filter
+                                                       // workspaces out
+                                                       if (name.lastIndexOf('-') > 0) {
+                                                               WkspObject currWksp = new WkspObject(name);
+                                                               // compute wkspace size
+                                                               // TODO implement this
+                                                               // Session currSession = null;
+                                                               // try {
+                                                               // currSession = currSourceRepo.login(
+                                                               // currSourceCred, name);
+                                                               // currWksp.size = JcrUtils
+                                                               // .getNodeApproxSize(currSession
+                                                               // .getNode("/"));
+                                                               //
+                                                               // } catch (RepositoryException re) {
+                                                               // log.warn(
+                                                               // "unable to compute size of workspace "
+                                                               // + name, re);
+                                                               // } finally {
+                                                               // JcrUtils.logoutQuietly(currSession);
+                                                               // }
+                                                               workspaces.add(currWksp);
+                                                       }
+                                       }
+
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Unexpected error while "
+                                                       + "initializing fetch wizard", e);
+                               } finally {
+                                       JcrUtils.logoutQuietly(session);
+                               }
+                               viewer.refresh();
+                       }
+               }
+
+               public void dispose() {
+               }
+
+               public Object[] getElements(Object obj) {
+                       return workspaces.toArray();
+               }
+       }
+
+       // ////////////////////////////
+       // // Helpers
+
+       // populate available source repo list
+       private Map<String, Node> getSourceRepoUris() {
+               try {
+                       Node repoList = currSession.getNode(NodeUtils.getUserHome(
+                                       currSession).getPath()
+                                       + RepoConstants.REPOSITORIES_BASE_PATH);
+
+                       String targetRepoUri = null;
+                       if (targetRepoNode != null) {
+                               targetRepoUri = targetRepoNode
+                                               .getProperty(ArgeoNames.ARGEO_URI).getString();
+                       }
+                       NodeIterator ni = repoList.getNodes();
+                       // List<String> sourceRepoNames = new ArrayList<String>();
+                       // // caches a map of the source repo nodes with their URI as a key
+                       // // to ease further processing
+                       Map<String, Node> sourceReposMap = new HashMap<String, Node>();
+                       while (ni.hasNext()) {
+                               Node currNode = ni.nextNode();
+                               if (currNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
+                                       String currUri = currNode.getProperty(ArgeoNames.ARGEO_URI)
+                                                       .getString();
+                                       if (targetRepoUri == null || !targetRepoUri.equals(currUri)) {
+                                               sourceReposMap.put(currUri, currNode);
+                                               // sourceRepoNames.add(currUri);
+                                       }
+                               }
+                       }
+                       return sourceReposMap;
+                       // sourceRepoNames.toArray(new String[sourceRepoNames
+                       // .size()]);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Error while getting repo aliases", e);
+               }
+       }
+
+       public void setTargetRepoNode(Node targetRepoNode) {
+               this.targetRepoNode = targetRepoNode;
+       }
+
+       public void setSourceRepoNode(Node sourceRepoNode) {
+               this.sourceRepoNode = sourceRepoNode;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/GenerateBinariesWizard.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/GenerateBinariesWizard.java
new file mode 100644 (file)
index 0000000..1f353e0
--- /dev/null
@@ -0,0 +1,335 @@
+package org.argeo.slc.client.ui.dist.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.ui.workbench.util.PrivilegedJob;
+import org.argeo.eclipse.ui.EclipseJcrMonitor;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.ViewerUtils;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoService;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.slc.repo.maven.GenerateBinaries;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Define parameters to asynchronously generate binaries, sources and sdk pom
+ * artifacts for this group using a {@link GenerateBinaries} runnable
+ */
+public class GenerateBinariesWizard extends Wizard {
+       private final static Log log = LogFactory
+                       .getLog(GenerateBinariesWizard.class);
+
+       // Business objects
+       private final RepoService repoService;
+       private final String repoNodePath;
+       private String wkspName;
+       private String groupNodePath;
+
+       // The pages
+       private RecapPage recapPage;
+
+       // Controls with parameters
+       private Text versionTxt;
+       private Text latestVersionTxt;
+       private Text highestArtifactVersionTxt;
+
+       public GenerateBinariesWizard(RepoService repoService, String repoNodePath,
+                       String wkspName, String groupNodePath) {
+               super();
+               this.repoService = repoService;
+               this.repoNodePath = repoNodePath;
+               this.wkspName = wkspName;
+               this.groupNodePath = groupNodePath;
+       }
+
+       @Override
+       public void dispose() {
+               super.dispose();
+       }
+
+       @Override
+       public void addPages() {
+               try {
+                       recapPage = new RecapPage();
+                       addPage(recapPage);
+                       setWindowTitle("Define Binary Generation Procedure");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot add page to wizard ", e);
+               }
+       }
+
+       @Override
+       public boolean performFinish() {
+               if (!canFinish())
+                       return false;
+               try {
+                       String msg = "Your are about to generate binaries, sources and sdk "
+                                       + "pom artifacts for this group, "
+                                       + "do you really want to proceed ?";
+
+                       boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
+                                       .getWorkbench().getDisplay().getActiveShell(),
+                                       "Confirm Launch", msg);
+
+                       if (result) {
+                               GenerateBinaryJob job = new GenerateBinaryJob(repoService,
+                                               repoNodePath, wkspName, groupNodePath,
+                                               versionTxt.getText());
+                               job.setUser(true);
+                               job.schedule();
+                       }
+               } catch (Exception e) {
+                       throw new SlcException(
+                                       "Unexpected error while launching the fetch", e);
+               }
+               return true;
+       }
+
+       // ///////////////////////////////
+       // ////// THE PAGES
+       private class RecapPage extends WizardPage {
+               private static final long serialVersionUID = 904196417910874087L;
+               private TableViewer recapViewer;
+
+               public RecapPage() {
+                       super("Define parameters and launch");
+                       setTitle("Define parameters and launch");
+               }
+
+               @Override
+               public boolean isPageComplete() {
+                       return isCurrentPage();
+               }
+
+               public IWizardPage getNextPage() {
+                       return null; // always last
+               }
+
+               private void refreshValues() {
+                       Session session = null;
+                       try {
+                               session = repoService.getRemoteSession(repoNodePath, null,
+                                               wkspName);
+                               Node groupNode = session.getNode(groupNodePath);
+                               GenerateBinaries gb = GenerateBinaries.preProcessGroupNode(
+                                               groupNode, null);
+
+                               List<Artifact> binaries = new ArrayList<Artifact>();
+                               binaries.addAll(gb.getBinaries());
+
+                               Artifact highestVersion = gb.getHighestArtifactVersion();
+                               if (highestVersion != null)
+                                       highestArtifactVersionTxt.setText(highestVersion
+                                                       .getBaseVersion());
+
+                               if (groupNode.hasNode(RepoConstants.BINARIES_ARTIFACT_ID)) {
+                                       Node binaryNode = groupNode
+                                                       .getNode(RepoConstants.BINARIES_ARTIFACT_ID);
+                                       Artifact currHighestVersion = null;
+                                       for (NodeIterator ni = binaryNode.getNodes(); ni.hasNext();) {
+                                               Node currN = ni.nextNode();
+                                               if (currN
+                                                               .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+                                                       Artifact currVersion = RepoUtils.asArtifact(currN);
+
+                                                       if (currHighestVersion == null
+                                                                       || currVersion.getBaseVersion()
+                                                                                       .compareTo(
+                                                                                                       currHighestVersion
+                                                                                                                       .getBaseVersion()) > 0)
+                                                               currHighestVersion = currVersion;
+                                               }
+                                       }
+                                       if (currHighestVersion != null)
+                                               latestVersionTxt.setText(currHighestVersion
+                                                               .getBaseVersion());
+                               }
+                               recapViewer.setInput(binaries);
+                               recapViewer.refresh();
+                       } catch (RepositoryException re) {
+                               throw new SlcException("Unable to get repositories URIs", re);
+                       } finally {
+                               JcrUtils.logoutQuietly(session);
+                       }
+               }
+
+               public void createControl(Composite parent) {
+                       setMessage("Configure Maven Indexing", IMessageProvider.NONE);
+
+                       Composite composite = new Composite(parent, SWT.NO_FOCUS);
+                       composite.setLayout(new GridLayout(2, false));
+
+                       versionTxt = createLT(composite, "Version");
+                       versionTxt
+                                       .setToolTipText("Enter a version for the new Modular Distribution");
+
+                       latestVersionTxt = createLT(composite, "Latest version");
+                       latestVersionTxt.setEditable(false);
+                       latestVersionTxt
+                                       .setToolTipText("The actual latest version of this modular distribution");
+
+                       highestArtifactVersionTxt = createLT(composite,
+                                       "Highest version in current category");
+                       highestArtifactVersionTxt.setEditable(false);
+                       highestArtifactVersionTxt
+                                       .setToolTipText("The highest version among all version of the below listed modules.");
+
+                       // Creates the table
+                       Table table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL
+                                       | SWT.BORDER);
+                       table.setLinesVisible(true);
+                       table.setHeaderVisible(true);
+                       table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2,
+                                       1));
+                       recapViewer = new TableViewer(table);
+
+                       TableViewerColumn column = ViewerUtils.createTableViewerColumn(
+                                       recapViewer, "Name", SWT.NONE, 250);
+                       column.setLabelProvider(new ColumnLabelProvider() {
+                               private static final long serialVersionUID = -9145709097621022043L;
+
+                               @Override
+                               public String getText(Object element) {
+                                       return ((Artifact) element).getArtifactId();
+                               }
+                       });
+
+                       column = ViewerUtils.createTableViewerColumn(recapViewer,
+                                       "Version", SWT.NONE, 250);
+                       column.setLabelProvider(new ColumnLabelProvider() {
+                               private static final long serialVersionUID = 5524185741667651628L;
+
+                               @Override
+                               public String getText(Object element) {
+                                       return ((Artifact) element).getBaseVersion();
+                               }
+                       });
+
+                       recapViewer.setContentProvider(new IStructuredContentProvider() {
+                               private static final long serialVersionUID = -4579434453554442858L;
+
+                               
+                               List<Artifact> artifacts;
+
+                               @SuppressWarnings("unchecked")
+                               public void inputChanged(Viewer viewer, Object oldInput,
+                                               Object newInput) {
+                                       artifacts = (List<Artifact>) newInput;
+                                       if (artifacts != null)
+                                               recapViewer.refresh();
+                               }
+
+                               public void dispose() {
+                               }
+
+                               public Object[] getElements(Object inputElement) {
+                                       return artifacts == null ? null : artifacts.toArray();
+                               }
+                       });
+
+                       // A basic comparator
+                       recapViewer.setComparator(new ViewerComparator());
+                       refreshValues();
+                       setControl(composite);
+               }
+       }
+
+       /**
+        * Define the privileged job that will be run asynchronously generate
+        * corresponding artifacts
+        */
+       private class GenerateBinaryJob extends PrivilegedJob {
+
+               private final RepoService repoService;
+               private final String repoNodePath;
+               private final String wkspName;
+               private final String groupNodePath;
+               private final String version;
+
+               public GenerateBinaryJob(RepoService repoService, String repoNodePath,
+                               String wkspName, String groupNodePath, String version) {
+                       super("Fetch");
+                       this.version = version;
+                       this.repoService = repoService;
+                       this.repoNodePath = repoNodePath;
+                       this.wkspName = wkspName;
+                       this.groupNodePath = groupNodePath;
+               }
+
+               @Override
+               protected IStatus doRun(IProgressMonitor progressMonitor) {
+                       Session session = null;
+                       try {
+                               JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
+                               session = repoService.getRemoteSession(repoNodePath, null,
+                                               wkspName);
+                               Node groupBaseNode = session.getNode(groupNodePath);
+                               GenerateBinaries.processGroupNode(groupBaseNode, version,
+                                               monitor);
+                       } catch (Exception e) {
+                               if (log.isDebugEnabled())
+                                       e.printStackTrace();
+                               return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
+                                               "Cannot normalize group", e);
+                       } finally {
+                               JcrUtils.logoutQuietly(session);
+                       }
+                       return Status.OK_STATUS;
+               }
+       }
+
+       // ////////////////////////////
+       // // Helpers
+       /** Creates label and text. */
+       protected Text createLT(Composite parent, String label) {
+               new Label(parent, SWT.NONE).setText(label);
+               Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER
+                               | SWT.NONE);
+               text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               return text;
+       }
+
+       /** Creates label and check. */
+       protected Button createLC(Composite parent, String label) {
+               new Label(parent, SWT.NONE).setText(label);
+               Button check = new Button(parent, SWT.CHECK);
+               check.setSelection(false);
+               check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               return check;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java b/legacy/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java
new file mode 100644 (file)
index 0000000..75a8015
--- /dev/null
@@ -0,0 +1,261 @@
+package org.argeo.slc.client.ui.dist.wizards;
+
+import java.net.URI;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.api.NodeConstants;
+import org.argeo.api.NodeUtils;
+import org.argeo.api.security.Keyring;
+import org.argeo.cms.ArgeoNames;
+import org.argeo.cms.ArgeoTypes;
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.RepoConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * 
+ * Registers a new remote repository in the current Node.
+ * 
+ */
+public class RegisterRepoWizard extends Wizard {
+
+       // Business objects
+       private Keyring keyring;
+       private RepositoryFactory repositoryFactory;
+       private Repository nodeRepository;
+
+       // Pages
+       private DefineModelPage page;
+
+       // Widgets of model page
+       private Text name;
+       private Text uri;
+       private Text username;
+       private Text password;
+       private Button saveInKeyring;
+
+       // Default values
+       private final static String DEFAULT_NAME = "Argeo Public Repository";
+       private final static String DEFAULT_URI = "https://forge.argeo.org/jcr/java";
+       private final static String DEFAULT_USER_NAME = "anonymous";
+       private final static boolean DEFAULT_ANONYMOUS = true;
+
+       public RegisterRepoWizard(Keyring keyring, RepositoryFactory repositoryFactory, Repository nodeRepository) {
+               super();
+               this.keyring = keyring;
+               this.repositoryFactory = repositoryFactory;
+               this.nodeRepository = nodeRepository;
+       }
+
+       @Override
+       public void addPages() {
+               try {
+                       page = new DefineModelPage();
+                       addPage(page);
+                       setWindowTitle("Register a new remote repository");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot add page to wizard ", e);
+               }
+       }
+
+       @Override
+       public boolean performFinish() {
+               if (!canFinish())
+                       return false;
+
+               Session nodeSession = null;
+               try {
+                       nodeSession = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
+                       String reposPath = NodeUtils.getUserHome(nodeSession).getPath() + RepoConstants.REPOSITORIES_BASE_PATH;
+
+                       Node repos = nodeSession.getNode(reposPath);
+                       String repoNodeName = JcrUtils.replaceInvalidChars(name.getText());
+                       if (repos.hasNode(repoNodeName))
+                               throw new SlcException("There is already a remote repository named " + repoNodeName);
+
+                       // check if the same URI has already been registered
+                       NodeIterator ni = repos.getNodes();
+                       while (ni.hasNext()) {
+                               Node node = ni.nextNode();
+                               if (node.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY) && node.hasProperty(ArgeoNames.ARGEO_URI)
+                                               && node.getProperty(ArgeoNames.ARGEO_URI).getString().equals(uri.getText()))
+                                       throw new SlcException("This URI " + uri.getText() + " is already registered, "
+                                                       + "for the time being, only one instance of a single "
+                                                       + "repository at a time is implemented.");
+                       }
+
+                       Node repoNode = repos.addNode(repoNodeName, ArgeoTypes.ARGEO_REMOTE_REPOSITORY);
+                       repoNode.setProperty(ArgeoNames.ARGEO_URI, uri.getText());
+                       repoNode.setProperty(ArgeoNames.ARGEO_USER_ID, username.getText());
+                       repoNode.addMixin(NodeType.MIX_TITLE);
+                       repoNode.setProperty(Property.JCR_TITLE, name.getText());
+                       nodeSession.save();
+                       if (saveInKeyring.getSelection()) {
+                               String pwdPath = repoNode.getPath() + '/' + ArgeoNames.ARGEO_PASSWORD;
+                               keyring.set(pwdPath, password.getText().toCharArray());
+                               nodeSession.save();
+                       }
+                       MessageDialog.openInformation(getShell(), "Repository Added",
+                                       "Remote repository " + uri.getText() + "' added");
+               } catch (Exception e) {
+                       ErrorFeedback.show("Cannot add remote repository", e);
+               } finally {
+                       JcrUtils.logoutQuietly(nodeSession);
+               }
+               return true;
+       }
+
+       private class DefineModelPage extends WizardPage {
+               private static final long serialVersionUID = 874386824101995060L;
+
+               public DefineModelPage() {
+                       super("Main");
+                       setTitle("Fill information to register a repository");
+               }
+
+               public void createControl(Composite parent) {
+
+                       // main layout
+                       Composite composite = new Composite(parent, SWT.NONE);
+                       composite.setLayout(new GridLayout(2, false));
+                       composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+                       // Create various fields
+                       // setMessage("Login to remote repository", IMessageProvider.NONE);
+                       name = createLT(composite, "Name", DEFAULT_NAME);
+                       uri = createLT(composite, "URI", DEFAULT_URI);
+
+                       final Button anonymousLogin = createLC(composite, "Log as anonymous", true);
+                       anonymousLogin.addSelectionListener(new SelectionListener() {
+                               private static final long serialVersionUID = 4874716406036981039L;
+
+                               public void widgetSelected(SelectionEvent e) {
+                                       if (anonymousLogin.getSelection()) {
+                                               username.setText(DEFAULT_USER_NAME);
+                                               password.setText("");
+                                               username.setEnabled(false);
+                                               password.setEnabled(false);
+                                       } else {
+                                               username.setText("");
+                                               password.setText("");
+                                               username.setEnabled(true);
+                                               password.setEnabled(true);
+                                       }
+                               }
+
+                               public void widgetDefaultSelected(SelectionEvent e) {
+                               }
+                       });
+
+                       username = createLT(composite, "User", DEFAULT_USER_NAME);
+                       password = createLP(composite, "Password");
+                       saveInKeyring = createLC(composite, "Remember password", false);
+
+                       if (DEFAULT_ANONYMOUS) {
+                               username.setEnabled(false);
+                               password.setEnabled(false);
+                       }
+
+                       Button test = createButton(composite, "Test");
+                       GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1);
+                       gd.widthHint = 140;
+                       test.setLayoutData(gd);
+
+                       test.addSelectionListener(new SelectionAdapter() {
+                               private static final long serialVersionUID = -4034851916548656293L;
+
+                               public void widgetSelected(SelectionEvent arg0) {
+                                       testConnection();
+                               }
+                       });
+
+                       // Compulsory
+                       setControl(composite);
+               }
+
+               /** Creates label and text. */
+               protected Text createLT(Composite parent, String label, String initial) {
+                       new Label(parent, SWT.RIGHT).setText(label);
+                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
+                       text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+                       text.setText(initial);
+                       return text;
+               }
+
+               /** Creates label and check. */
+               protected Button createLC(Composite parent, String label, Boolean initial) {
+                       new Label(parent, SWT.RIGHT).setText(label);
+                       Button check = new Button(parent, SWT.CHECK);
+                       check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       check.setSelection(initial);
+                       return check;
+               }
+
+               /** Creates a button with a label. */
+               protected Button createButton(Composite parent, String label) {
+                       Button button = new Button(parent, SWT.PUSH);
+                       button.setText(label);
+                       button.setFont(JFaceResources.getDialogFont());
+                       setButtonLayoutData(button);
+                       return button;
+               }
+
+               /** Creates label and password field */
+               protected Text createLP(Composite parent, String label) {
+                       new Label(parent, SWT.NONE).setText(label);
+                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER | SWT.PASSWORD);
+                       text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       return text;
+               }
+
+       }
+
+       void testConnection() {
+               Session session = null;
+               try {
+                       if (uri.getText().startsWith("http")) {// http, https
+                               URI checkedUri = new URI(uri.getText());
+                               String checkedUriStr = checkedUri.toString();
+                               Repository repository = NodeUtils.getRepositoryByUri(repositoryFactory, checkedUriStr);
+                               if (username.getText().trim().equals("")) {// anonymous
+                                       session = repository.login(RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
+                               } else {
+                                       char[] pwd = password.getTextChars();
+                                       SimpleCredentials sc = new SimpleCredentials(username.getText(), pwd);
+                                       session = repository.login(sc, RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
+                               }
+                       } else {// alias
+                               Repository repository = NodeUtils.getRepositoryByAlias(repositoryFactory, uri.getText());
+                               session = repository.login();
+                       }
+                       MessageDialog.openInformation(getShell(), "Success", "Connection to '" + uri.getText() + "' successful");
+               } catch (Exception e) {
+                       ErrorFeedback.show("Connection test failed for " + uri.getText(), e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/.classpath b/legacy/org.argeo.slc.client.ui/.classpath
new file mode 100644 (file)
index 0000000..120e381
--- /dev/null
@@ -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/JavaSE-1.7"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/legacy/org.argeo.slc.client.ui/.gitignore b/legacy/org.argeo.slc.client.ui/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/org.argeo.slc.client.ui/.project b/legacy/org.argeo.slc.client.ui/.project
new file mode 100644 (file)
index 0000000..ed71a2e
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.client.ui</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/legacy/org.argeo.slc.client.ui/.settings/org.eclipse.jdt.core.prefs b/legacy/org.argeo.slc.client.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..95d6b05
--- /dev/null
@@ -0,0 +1,12 @@
+#Wed Aug 04 16:31:36 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/legacy/org.argeo.slc.client.ui/.settings/org.eclipse.pde.core.prefs b/legacy/org.argeo.slc.client.ui/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..31cbfae
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Jul 27 14:24:51 CEST 2010
+eclipse.preferences.version=1
+resolve.requirebundle=false
diff --git a/legacy/org.argeo.slc.client.ui/META-INF/.gitignore b/legacy/org.argeo.slc.client.ui/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.client.ui/META-INF/spring/commands.xml b/legacy/org.argeo.slc.client.ui/META-INF/spring/commands.xml
new file mode 100644 (file)
index 0000000..6ed132d
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+       <bean id="updateModule"
+               class="org.argeo.slc.client.ui.commands.UpdateModule"
+               scope="prototype">
+               <property name="modulesManager" ref="modulesManager"/>
+       </bean>
+<!--   <bean name="runSlc/Flow" -->
+<!--           class="org.argeo.slc.client.ui.commands.RunSlcFlow" -->
+<!--           scope="prototype"> -->
+<!--           <property name="modulesManager" ref="modulesManager"/> -->
+<!--   </bean> -->
+
+       <!-- Result list view commands-->
+<!--   <bean id="org.argeo.slc.client.ui.refreshResultList" -->
+<!--           class="org.argeo.slc.client.ui.commands.ResultListViewRefreshHandler" -->
+<!--           scope="prototype"> -->
+<!--   </bean> -->
+
+<!--   <bean id="org.argeo.slc.client.ui.removeSelectedResultFromResultList" -->
+<!--           class="org.argeo.slc.client.ui.commands.RemoveSelectedResultFromResultList" -->
+<!--           scope="prototype"> -->
+<!--   </bean> -->
+
+
+<!--   <bean id="org.argeo.slc.client.ui.refreshExecutionModulesView" -->
+<!--           class="org.argeo.slc.client.ui.commands.ExecutionModulesViewRefreshHandler" -->
+<!--           scope="prototype"> -->
+<!--   </bean> -->
+<!--   <bean id="org.argeo.slc.client.ui.refreshProcessList" -->
+<!--           class="org.argeo.slc.client.ui.commands.ProcessListViewRefreshHandler" -->
+<!--           scope="prototype"> -->
+<!--   </bean> -->
+<!--   <bean id="org.argeo.slc.client.ui.displayProcessDetails" -->
+<!--           class="org.argeo.slc.client.ui.commands.ProcessDetailsDisplayHandler" -->
+<!--           scope="prototype"> -->
+<!--   </bean> -->
+<!--   <bean id="org.argeo.slc.client.ui.displayResultDetails" -->
+<!--           class="org.argeo.slc.client.ui.commands.ResultDetailsDisplayHandler" -->
+<!--           scope="prototype"> -->
+<!--   </bean> -->
+<!--   <bean id="org.argeo.slc.client.ui.launchBatch" class="org.argeo.slc.client.ui.commands.LaunchBatchHandler" -->
+<!--           scope="prototype"> -->
+<!--   </bean> -->
+<!--   <bean id="org.argeo.slc.client.ui.removeSelectedFromBatch" -->
+<!--           class="org.argeo.slc.client.ui.commands.RemoveSelectedProcessFromBatchHandler" -->
+<!--           scope="prototype"> -->
+<!--   </bean> -->
+<!--   <bean id="org.argeo.slc.client.ui.clearBatch" class="org.argeo.slc.client.ui.commands.ClearBatchHandler" -->
+<!--           scope="prototype"> -->
+<!--   </bean> -->
+<!--   <bean id="org.argeo.slc.client.ui.manageBundles" class="org.argeo.slc.client.ui.commands.ManageBundlesHandler" -->
+<!--           scope="prototype"> -->
+<!--   </bean>  -->
+</beans>
diff --git a/legacy/org.argeo.slc.client.ui/META-INF/spring/controllers.xml b/legacy/org.argeo.slc.client.ui/META-INF/spring/controllers.xml
new file mode 100644 (file)
index 0000000..774b9da
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+       <bean id="processController" class="org.argeo.slc.client.ui.controllers.ProcessController">
+               <property name="agent" ref="agent" />
+       </bean>
+</beans>
diff --git a/legacy/org.argeo.slc.client.ui/META-INF/spring/editors.xml b/legacy/org.argeo.slc.client.ui/META-INF/spring/editors.xml
new file mode 100644 (file)
index 0000000..fd98808
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+       <bean id="processEditor" class="org.argeo.slc.client.ui.editors.ProcessEditor"
+               scope="prototype">
+               <property name="processController" ref="processController" />
+               <property name="modulesManager" ref="modulesManager" />
+               <property name="repository" ref="repository" />
+       </bean>
+</beans>
diff --git a/legacy/org.argeo.slc.client.ui/META-INF/spring/osgi.xml b/legacy/org.argeo.slc.client.ui/META-INF/spring/osgi.xml
new file mode 100644 (file)
index 0000000..79eb6bc
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xmlns:osgi="http://www.springframework.org/schema/osgi"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
+       osgi:default-timeout="30000">\r
+\r
+       <beans:description>SLC UI</beans:description>\r
+\r
+       <!-- REFERENCES -->\r
+       <reference id="repository" interface="javax.jcr.Repository"\r
+               filter="(cn=ego)" />\r
+\r
+       <reference id="agent" interface="org.argeo.slc.execution.SlcAgent" />\r
+\r
+       <reference id="modulesManager"\r
+               interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
+</beans:beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/META-INF/spring/views.xml b/legacy/org.argeo.slc.client.ui/META-INF/spring/views.xml
new file mode 100644 (file)
index 0000000..eca8f68
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+       <bean id="jcrExecutionModulesView" class="org.argeo.slc.client.ui.views.JcrExecutionModulesView"
+               scope="prototype">
+               <property name="repository" ref="repository" />
+               <property name="modulesManager" ref="modulesManager" />
+       </bean>
+
+       <bean id="jcrProcessListView" class="org.argeo.slc.client.ui.views.JcrProcessListView"
+               scope="prototype">
+               <property name="repository" ref="repository" />
+       </bean>
+
+       <bean id="jcrResultListView" class="org.argeo.slc.client.ui.views.JcrResultListView"
+               scope="prototype">
+               <property name="repository" ref="repository" />
+       </bean>
+
+       <bean id="jcrResultTreeView" class="org.argeo.slc.client.ui.views.JcrResultTreeView"
+               scope="prototype">
+               <property name="repository" ref="repository" />
+       </bean>
+
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/bnd.bnd b/legacy/org.argeo.slc.client.ui/bnd.bnd
new file mode 100644 (file)
index 0000000..d24c331
--- /dev/null
@@ -0,0 +1,13 @@
+Bundle-SymbolicName: org.argeo.slc.client.ui;singleton=true
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.ui;resolution:=optional,\
+org.eclipse.core.runtime,\
+org.eclipse.rap.ui;resolution:=optional,\
+org.eclipse.rap.ui.workbench;resolution:=optional
+
+Bundle-Activator: org.argeo.slc.client.ui.ClientUiPlugin
+Import-Package: org.argeo.eclipse.spring,\
+org.argeo.api,\
+org.eclipse.core.runtime,\
+org.osgi.*;version=0.0.0,\
+*
diff --git a/legacy/org.argeo.slc.client.ui/build.properties b/legacy/org.argeo.slc.client.ui/build.properties
new file mode 100644 (file)
index 0000000..54c55c6
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src
+bin.includes = plugin.xml,\
+               META-INF/,\
+               .,\
+               icons/
diff --git a/legacy/org.argeo.slc.client.ui/icons/agent.gif b/legacy/org.argeo.slc.client.ui/icons/agent.gif
new file mode 100644 (file)
index 0000000..0a1fa96
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/agent.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/agentFactory.gif b/legacy/org.argeo.slc.client.ui/icons/agentFactory.gif
new file mode 100644 (file)
index 0000000..b51ae39
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/agentFactory.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/archive.png b/legacy/org.argeo.slc.client.ui/icons/archive.png
new file mode 100644 (file)
index 0000000..fb36f36
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/archive.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/batch.gif b/legacy/org.argeo.slc.client.ui/icons/batch.gif
new file mode 100644 (file)
index 0000000..b8ca14a
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/batch.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/choices.gif b/legacy/org.argeo.slc.client.ui/icons/choices.gif
new file mode 100644 (file)
index 0000000..da2f577
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/choices.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/clear_batch.gif b/legacy/org.argeo.slc.client.ui/icons/clear_batch.gif
new file mode 100644 (file)
index 0000000..28a3785
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/clear_batch.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/computer.png b/legacy/org.argeo.slc.client.ui/icons/computer.png
new file mode 100644 (file)
index 0000000..ff64b84
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/computer.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/edit_parameters.gif b/legacy/org.argeo.slc.client.ui/icons/edit_parameters.gif
new file mode 100644 (file)
index 0000000..94eedf6
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/edit_parameters.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/error.gif b/legacy/org.argeo.slc.client.ui/icons/error.gif
new file mode 100644 (file)
index 0000000..64b4384
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/error.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/excel.png b/legacy/org.argeo.slc.client.ui/icons/excel.png
new file mode 100644 (file)
index 0000000..eb6158e
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/excel.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/executionError.gif b/legacy/org.argeo.slc.client.ui/icons/executionError.gif
new file mode 100644 (file)
index 0000000..e861399
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/executionError.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/executionPassed.gif b/legacy/org.argeo.slc.client.ui/icons/executionPassed.gif
new file mode 100644 (file)
index 0000000..20fc2f2
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/executionPassed.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/executionSpec.gif b/legacy/org.argeo.slc.client.ui/icons/executionSpec.gif
new file mode 100644 (file)
index 0000000..1ff93cb
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/executionSpec.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/executionSpecAttribute.gif b/legacy/org.argeo.slc.client.ui/icons/executionSpecAttribute.gif
new file mode 100644 (file)
index 0000000..bee687c
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/executionSpecAttribute.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/executionSpecs.gif b/legacy/org.argeo.slc.client.ui/icons/executionSpecs.gif
new file mode 100644 (file)
index 0000000..0b63124
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/executionSpecs.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/execution_module.gif b/legacy/org.argeo.slc.client.ui/icons/execution_module.gif
new file mode 100644 (file)
index 0000000..983932f
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/execution_module.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/failed.gif b/legacy/org.argeo.slc.client.ui/icons/failed.gif
new file mode 100644 (file)
index 0000000..3e9d893
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/failed.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/flow.png b/legacy/org.argeo.slc.client.ui/icons/flow.png
new file mode 100644 (file)
index 0000000..114193f
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/flow.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/folder.gif b/legacy/org.argeo.slc.client.ui/icons/folder.gif
new file mode 100644 (file)
index 0000000..42e027c
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/folder.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/folder.png b/legacy/org.argeo.slc.client.ui/icons/folder.png
new file mode 100644 (file)
index 0000000..6937ed4
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/folder.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/kill.png b/legacy/org.argeo.slc.client.ui/icons/kill.png
new file mode 100644 (file)
index 0000000..cfbf9d1
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/kill.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/launch.gif b/legacy/org.argeo.slc.client.ui/icons/launch.gif
new file mode 100644 (file)
index 0000000..ec477ea
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/launch.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/module.png b/legacy/org.argeo.slc.client.ui/icons/module.png
new file mode 100644 (file)
index 0000000..0afea5b
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/module.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/module_stopped.gif b/legacy/org.argeo.slc.client.ui/icons/module_stopped.gif
new file mode 100644 (file)
index 0000000..c88284a
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/module_stopped.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/myResult.png b/legacy/org.argeo.slc.client.ui/icons/myResult.png
new file mode 100644 (file)
index 0000000..93053b7
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/myResult.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/passed.gif b/legacy/org.argeo.slc.client.ui/icons/passed.gif
new file mode 100644 (file)
index 0000000..23c97f0
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/passed.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/process_completed.png b/legacy/org.argeo.slc.client.ui/icons/process_completed.png
new file mode 100644 (file)
index 0000000..0ad64e7
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/process_completed.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/process_details.gif b/legacy/org.argeo.slc.client.ui/icons/process_details.gif
new file mode 100644 (file)
index 0000000..c81630a
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/process_details.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/process_error.png b/legacy/org.argeo.slc.client.ui/icons/process_error.png
new file mode 100644 (file)
index 0000000..e66c98e
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/process_error.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/process_running.png b/legacy/org.argeo.slc.client.ui/icons/process_running.png
new file mode 100644 (file)
index 0000000..471c091
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/process_running.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/process_scheduled.gif b/legacy/org.argeo.slc.client.ui/icons/process_scheduled.gif
new file mode 100644 (file)
index 0000000..b7f03d5
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/process_scheduled.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/processes.gif b/legacy/org.argeo.slc.client.ui/icons/processes.gif
new file mode 100644 (file)
index 0000000..364c0e7
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/processes.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/processes.png b/legacy/org.argeo.slc.client.ui/icons/processes.png
new file mode 100644 (file)
index 0000000..364c0e7
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/processes.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/refresh.png b/legacy/org.argeo.slc.client.ui/icons/refresh.png
new file mode 100644 (file)
index 0000000..a3884fb
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/refresh.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/relaunch.gif b/legacy/org.argeo.slc.client.ui/icons/relaunch.gif
new file mode 100644 (file)
index 0000000..8f943a8
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/relaunch.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/removeAll.png b/legacy/org.argeo.slc.client.ui/icons/removeAll.png
new file mode 100644 (file)
index 0000000..73053c4
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/removeAll.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/remove_one.gif b/legacy/org.argeo.slc.client.ui/icons/remove_one.gif
new file mode 100644 (file)
index 0000000..2cd9c54
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/remove_one.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/rename.png b/legacy/org.argeo.slc.client.ui/icons/rename.png
new file mode 100644 (file)
index 0000000..a388417
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/rename.png differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/result_details.gif b/legacy/org.argeo.slc.client.ui/icons/result_details.gif
new file mode 100644 (file)
index 0000000..4017f6d
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/result_details.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/results.gif b/legacy/org.argeo.slc.client.ui/icons/results.gif
new file mode 100644 (file)
index 0000000..0dc862c
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/results.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/slc_execution_perspective.gif b/legacy/org.argeo.slc.client.ui/icons/slc_execution_perspective.gif
new file mode 100644 (file)
index 0000000..b8ca14a
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/slc_execution_perspective.gif differ
diff --git a/legacy/org.argeo.slc.client.ui/icons/system.png b/legacy/org.argeo.slc.client.ui/icons/system.png
new file mode 100644 (file)
index 0000000..71f44d0
Binary files /dev/null and b/legacy/org.argeo.slc.client.ui/icons/system.png differ
diff --git a/legacy/org.argeo.slc.client.ui/plugin.xml b/legacy/org.argeo.slc.client.ui/plugin.xml
new file mode 100644 (file)
index 0000000..b446629
--- /dev/null
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+       <!-- Views --> 
+   <extension
+         point="org.eclipse.ui.views">
+          <view
+                id="org.argeo.slc.client.ui.jcrExecutionModulesView"
+                class="org.argeo.eclipse.spring.SpringExtensionFactory"
+                icon="icons/execution_module.gif"
+                name="Execution"
+                restorable="true">
+          </view>
+          <view
+                id="org.argeo.slc.client.ui.jcrResultListView"
+                class="org.argeo.eclipse.spring.SpringExtensionFactory"
+                icon="icons/results.gif"
+                name="Results"
+                restorable="true">
+          </view>
+          <view
+                id="org.argeo.slc.client.ui.jcrResultTreeView"
+                class="org.argeo.eclipse.spring.SpringExtensionFactory"
+                icon="icons/results.gif"
+                name="Results"
+                restorable="true">
+          </view>
+          <view
+                id="org.argeo.slc.client.ui.jcrProcessListView"
+                class="org.argeo.eclipse.spring.SpringExtensionFactory"
+                name="Processes"
+                icon="icons/processes.gif"
+                restorable="true">
+          </view>
+   </extension>
+       
+       <!-- Commands definitions --> 
+       <extension
+       point="org.eclipse.ui.commands">
+               <command
+               defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+               id="org.argeo.slc.client.ui.updateModule"
+               name="Update Module">
+           </command>
+           
+           <!-- Commands that do not need dependency injection --> 
+           <command
+               defaultHandler="org.argeo.slc.client.ui.commands.AddResultFolder"
+               id="org.argeo.slc.client.ui.addResultFolder"
+               name="Add result folder">
+           </command>
+           <command
+               id="org.argeo.slc.client.ui.deleteItems"
+            defaultHandler="org.argeo.slc.client.ui.commands.DeleteItems"
+            name="Delete selected item(s)">
+       </command>
+           <command
+               defaultHandler="org.argeo.slc.client.ui.commands.RenameResultFolder"
+               id="org.argeo.slc.client.ui.renameResultFolder"
+               name="Rename folder">
+           </command>
+           <command
+               defaultHandler="org.argeo.slc.client.ui.commands.RenameResultNode"
+               id="org.argeo.slc.client.ui.renameResultNode"
+               name="Rename result">
+           </command>
+           <command
+               defaultHandler="org.argeo.slc.client.ui.commands.RefreshJcrResultTreeView"
+               id="org.argeo.slc.client.ui.refreshJcrResultTreeView"
+               name="Refresh">
+               <commandParameter
+                       id="org.argeo.slc.client.ui.param.refreshType"
+                       name="Refresh type">
+                       </commandParameter>
+           </command>
+    </extension>
+   
+       <!-- Menu definitions -->
+       <extension
+       id="menu:org.eclipse.ui.main.menu"
+        point="org.eclipse.ui.menus">
+               <menuContribution
+               locationURI="toolbar:org.argeo.slc.client.ui.jcrExecutionModulesView">
+                       <command
+                               commandId="org.argeo.slc.client.ui.updateModule"
+                               icon="icons/refresh.png"
+                               label="Update module"
+                               tooltip="Update module">
+                       </command>
+               </menuContribution>   
+       </extension>
+   <extension
+         point="org.eclipse.ui.perspectives">
+      <perspective
+            class="org.argeo.slc.client.ui.SlcExecutionPerspective"
+            icon="icons/slc_execution_perspective.gif"
+            id="org.argeo.slc.client.ui.slcExecutionPerspective"
+            name="SLC Execution">
+      </perspective>
+   </extension>
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.argeo.eclipse.spring.SpringExtensionFactory"
+            default="false"
+            icon="icons/batch.gif"
+            id="org.argeo.slc.client.ui.processEditor"
+            name="Process">
+      </editor>
+   </extension>
+   <extension
+         point="org.eclipse.ui.elementFactories">
+      <factory
+            class="org.argeo.slc.client.ui.editors.ProcessEditorInputFactory"
+            id="org.argeo.slc.client.ui.processEditorInputFactory">
+      </factory>
+   </extension>
+   <extension
+           point="org.eclipse.ui.activities">
+     </extension>
+  <extension
+           point="org.eclipse.ui.activities">
+        <activity
+              description="SLC users"
+              id="org.argeo.slc.client.ui.slcActivity"
+              name="SLC">
+                 <enabledWhen>
+                   <with variable="roles">
+                     <iterate ifEmpty="false" operator="or">
+                       <equals value="cn=org.argeo.slc.user,ou=roles,ou=node" />
+                     </iterate>
+                   </with>
+                 </enabledWhen>
+        </activity>
+        <!-- TODO: find a way to exclude evrything -->
+        <activityPatternBinding
+              activityId="org.argeo.slc.client.ui.slcActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.slc.client.ui/org.argeo.slc.client.ui.slcExecutionPerspective">
+        </activityPatternBinding>
+        <activityPatternBinding
+              activityId="org.argeo.security.ui.adminActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.slc.client.ui/org.argeo.slc.client.ui.slcExecutionPerspective">
+        </activityPatternBinding>
+        <activityPatternBinding
+              activityId="org.argeo.security.ui.adminActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.jcr.ui.explorer/org.argeo.jcr.ui.explorer.perspective">
+        </activityPatternBinding>
+        <activityPatternBinding
+              activityId="org.argeo.security.ui.adminActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.security.ui/org.argeo.security.ui.userHomePerspective">
+        </activityPatternBinding>
+  </extension>
+</plugin>
diff --git a/legacy/org.argeo.slc.client.ui/pom.xml b/legacy/org.argeo.slc.client.ui/pom.xml
new file mode 100644 (file)
index 0000000..6fe69c8
--- /dev/null
@@ -0,0 +1,53 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.client.ui</artifactId>
+       <name>SLC Client UI</name>
+       <packaging>jar</packaging>
+       <dependencies>
+               <!-- SLC -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.spring</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Argeo Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.api</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.eclipse.ui</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.eclipse.ui.rap</artifactId>
+                       <version>${version.argeo-commons}</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc.legacy.commons</groupId>
+                       <artifactId>org.argeo.cms.ui.workbench</artifactId>
+                       <version>${version.argeo-commons-legacy}</version>
+               </dependency>
+
+               <!-- RAP workbench -->
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>argeo-tp-rap-e3</artifactId>
+                       <version>${version.argeo-tp}</version>
+                       <type>pom</type>
+                       <scope>provided</scope>
+               </dependency>
+
+       </dependencies>
+</project>
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/ClientUiPlugin.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/ClientUiPlugin.java
new file mode 100644 (file)
index 0000000..abf62a0
--- /dev/null
@@ -0,0 +1,98 @@
+package org.argeo.slc.client.ui;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.BasicNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.deploy.ModulesManager;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/** The activator class controls the plug-in life cycle */
+public class ClientUiPlugin extends AbstractUIPlugin implements SlcNames {
+       public static final String ID = "org.argeo.slc.client.ui";
+       private static ClientUiPlugin plugin;
+
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+               plugin = this;
+       }
+
+       public void stop(BundleContext context) throws Exception {
+               plugin = null;
+               super.stop(context);
+       }
+
+       public static ClientUiPlugin getDefault() {
+               return plugin;
+       }
+
+       /** Creates the image */
+       public static Image img(String path) {
+               return getImageDescriptor(path).createImage();
+       }
+
+       public static ImageDescriptor getImageDescriptor(String path) {
+               return imageDescriptorFromPlugin(ID, path);
+       }
+
+       /** Start execution module if it was stopped and vice-versa */
+       public static void startStopExecutionModule(
+                       final ModulesManager modulesManager, Node node) {
+               try {
+                       if (!node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE))
+                               throw new SlcException(node + " is not an execution module");
+
+                       String name = node.getProperty(SLC_NAME).getString();
+                       String version = node.getProperty(SLC_VERSION).getString();
+                       final NameVersion nameVersion = new BasicNameVersion(name, version);
+                       Boolean started = node.getProperty(SLC_STARTED).getBoolean();
+
+                       Job job;
+                       if (started) {
+                               job = new Job("Stop " + nameVersion) {
+                                       protected IStatus run(IProgressMonitor monitor) {
+                                               monitor.beginTask("Stop " + nameVersion, 1);
+                                               modulesManager.stop(nameVersion);
+                                               monitor.worked(1);
+                                               return Status.OK_STATUS;
+                                       }
+
+                                       protected void canceling() {
+                                               getThread().interrupt();
+                                               super.canceling();
+                                       }
+                               };
+                       } else {
+                               job = new Job("Start " + nameVersion) {
+                                       protected IStatus run(IProgressMonitor monitor) {
+                                               monitor.beginTask("Start " + nameVersion, 1);
+                                               modulesManager.start(nameVersion);
+                                               monitor.worked(1);
+                                               return Status.OK_STATUS;
+                                       }
+
+                                       protected void canceling() {
+                                               getThread().interrupt();
+                                               super.canceling();
+                                       }
+                               };
+                       }
+                       job.setUser(true);
+                       job.schedule();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot start " + node, e);
+               }
+
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcExecutionPerspective.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcExecutionPerspective.java
new file mode 100644 (file)
index 0000000..7e9cc52
--- /dev/null
@@ -0,0 +1,28 @@
+package org.argeo.slc.client.ui;
+
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/** Perspective to manage SLC execution flows. */
+public class SlcExecutionPerspective implements IPerspectiveFactory {
+
+       public void createInitialLayout(IPageLayout layout) {
+               String editorArea = layout.getEditorArea();
+               layout.setEditorAreaVisible(true);
+               layout.setFixed(false);
+
+               IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
+                               0.35f, editorArea);
+               left.addView(ClientUiPlugin.ID + ".jcrExecutionModulesView");
+               // left.addView(ClientUiPlugin.ID + ".jcrResultListView");
+               left.addView(ClientUiPlugin.ID + ".jcrResultTreeView");
+               // Sleak view for SWT resource debugging
+               // left.addView("org.eclipse.swt.tools.views.SleakView");
+
+               IFolderLayout bottom = layout.createFolder("bottom",
+                               IPageLayout.BOTTOM, 0.65f, editorArea);
+//             BOTTOM.ADDVIEW(SECURITYUIPLUGIN.PLUGIN_ID + ".LOGVIEW");
+               bottom.addView(ClientUiPlugin.ID + ".jcrProcessListView");
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcImages.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcImages.java
new file mode 100644 (file)
index 0000000..c93ec9b
--- /dev/null
@@ -0,0 +1,40 @@
+package org.argeo.slc.client.ui;
+
+import static org.argeo.slc.client.ui.ClientUiPlugin.getImageDescriptor;
+import static org.argeo.slc.client.ui.ClientUiPlugin.img;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+
+/** Shared images. */
+public class SlcImages {
+       public final static Image AGENT = img("icons/agent.gif");
+       public final static Image AGENT_FACTORY = img("icons/agentFactory.gif");
+       public final static Image MODULE = img("icons/module.png");
+       public final static Image MODULE_STOPPED = img("icons/module_stopped.gif");
+       public final static Image FOLDER = img("icons/folder.gif");
+       public final static Image MY_RESULTS_FOLDER = img("icons/myResult.png");
+       public final static Image RENAME = img("icons/rename.png");
+       public final static Image FLOW = img("icons/flow.png");
+       public final static Image PROCESSES = img("icons/processes.gif");
+       public final static Image PASSED = img("icons/passed.gif");
+       public final static Image ERROR = img("icons/error.gif");
+       public final static Image LAUNCH = img("icons/launch.gif");
+       public final static Image RELAUNCH = img("icons/relaunch.gif");
+       public final static Image KILL = img("icons/kill.png");
+       public final static Image REMOVE_ONE = img("icons/remove_one.gif");
+       public final static Image REMOVE_ALL = img("icons/removeAll.png");
+       public final static Image EXECUTION_SPECS = img("icons/executionSpecs.gif");
+       public final static Image EXECUTION_SPEC = img("icons/executionSpec.gif");
+       public final static Image EXECUTION_SPEC_ATTRIBUTE = img("icons/executionSpecAttribute.gif");
+       public final static Image CHOICES = img("icons/choices.gif");
+       public final static Image PROCESS_ERROR = img("icons/process_error.png");
+       public final static Image PROCESS_SCHEDULED = img("icons/process_scheduled.gif");
+       public final static Image PROCESS_RUNNING = img("icons/process_running.png");
+       public final static Image PROCESS_COMPLETED = img("icons/process_completed.png");
+
+       // Decorators
+       public final static ImageDescriptor EXECUTION_ERROR = getImageDescriptor("icons/executionError.gif");
+       public final static ImageDescriptor EXECUTION_PASSED = getImageDescriptor("icons/executionPassed.gif");
+
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcUiConstants.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/SlcUiConstants.java
new file mode 100644 (file)
index 0000000..27d05d6
--- /dev/null
@@ -0,0 +1,15 @@
+package org.argeo.slc.client.ui;
+
+/** SLC UI common constants */
+public interface SlcUiConstants {
+
+       /*
+        * Labels
+        */
+       public final static String DEFAULT_MY_RESULTS_FOLDER_LABEL = "My Results";
+       
+       /*
+        * MISCEALLENEOUS
+        */
+       public final static String DEFAULT_DISPLAY_DATE_TIME_FORMAT = "yyyy-MM-dd, HH:mm:ss";
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/AddResultFolder.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/AddResultFolder.java
new file mode 100644 (file)
index 0000000..5cc8b65
--- /dev/null
@@ -0,0 +1,76 @@
+package org.argeo.slc.client.ui.commands;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.argeo.eclipse.ui.dialogs.SingleValue;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.model.ParentNodeFolder;
+import org.argeo.slc.client.ui.model.ResultFolder;
+import org.argeo.slc.jcr.SlcJcrResultUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Add a new SlcType.SLC_RESULT_FOLDER node to the current user "my result"
+ * tree. This handler is only intended to bu used with JcrResultTreeView and its
+ * descendants.
+ */
+
+public class AddResultFolder extends AbstractHandler {
+       public final static String ID = ClientUiPlugin.ID + ".addResultFolder";
+       public final static String DEFAULT_ICON_REL_PATH = "icons/addFolder.gif";
+       public final static String DEFAULT_LABEL = "Add folder...";
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               IStructuredSelection selection = (IStructuredSelection) HandlerUtil
+                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
+
+               // Sanity check, already done when populating the corresponding popup
+               // menu.
+               if (selection != null && selection.size() == 1) {
+                       Object obj = selection.getFirstElement();
+                       try {
+                               Node parentNode = null;
+                               if (obj instanceof ResultFolder) {
+                                       ResultFolder rf = (ResultFolder) obj;
+                                       parentNode = rf.getNode();
+                               } else if (obj instanceof ParentNodeFolder) {
+                                       Node node = ((ParentNodeFolder) obj).getNode();
+                                       if (node.getPath().startsWith(
+                                                       SlcJcrResultUtils.getMyResultsBasePath(node
+                                                                       .getSession())))
+                                               parentNode = node;
+                               }
+
+                               if (parentNode != null) {
+                                       String folderName = SingleValue.ask("Folder name",
+                                                       "Enter folder name");
+                                       if (folderName != null) {
+                                               if (folderName.contains("/")) {
+                                                       ErrorFeedback
+                                                                       .show("Folder names can't contain a '/'.");
+                                                       return null;
+                                               }
+
+                                               String absPath = parentNode.getPath() + "/"
+                                                               + folderName;
+                                               SlcJcrResultUtils.createResultFolderNode(
+                                                               parentNode.getSession(), absPath);
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "Unexpected exception while creating result folder", e);
+                       }
+               } else {
+                       ErrorFeedback.show("Can only add file folder to a node");
+               }
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/DeleteItems.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/DeleteItems.java
new file mode 100644 (file)
index 0000000..7401667
--- /dev/null
@@ -0,0 +1,119 @@
+package org.argeo.slc.client.ui.commands;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.model.ResultFolder;
+import org.argeo.slc.client.ui.model.ResultParent;
+import org.argeo.slc.client.ui.model.ResultParentUtils;
+import org.argeo.slc.client.ui.model.SingleResultNode;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Deletes one or many results */
+public class DeleteItems extends AbstractHandler {
+       public final static String ID = ClientUiPlugin.ID + ".deleteItems";
+       public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
+                       .getImageDescriptor("icons/removeAll.png");
+       public final static String DEFAULT_LABEL = "Delete selected item(s)";
+
+       public Object execute(final ExecutionEvent event) throws ExecutionException {
+               final ISelection selection = HandlerUtil
+                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
+
+               // confirmation
+               StringBuilder buf = new StringBuilder("");
+               Iterator<?> lst = ((IStructuredSelection) selection).iterator();
+               while (lst.hasNext()) {
+                       Object obj = lst.next();
+                       if (obj instanceof ResultParent) {
+                               ResultParent rp = ((ResultParent) obj);
+                               buf.append(rp.getName()).append(", ");
+                       }
+               }
+
+               String msg = "Nothing to delete";
+               // remove last separator
+               if (buf.lastIndexOf(", ") > -1) {
+                       msg = "Do you want to delete following objects (and their children): "
+                                       + buf.substring(0, buf.lastIndexOf(", ")) + "?";
+               }
+               Boolean ok = MessageDialog.openConfirm(
+                               HandlerUtil.getActiveShell(event), "Confirm deletion", msg);
+
+               if (!ok)
+                       return null;
+
+               Job job = new Job("Delete results") {
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               if (selection != null
+                                               && selection instanceof IStructuredSelection) {
+                                       Map<String, Node> nodes = new HashMap<String, Node>();
+                                       Iterator<?> it = ((IStructuredSelection) selection)
+                                                       .iterator();
+                                       Object obj = null;
+                                       try {
+
+                                               while (it.hasNext()) {
+                                                       obj = it.next();
+                                                       if (obj instanceof ResultFolder) {
+                                                               Node node = ((ResultFolder) obj).getNode();
+                                                               nodes.put(node.getPath(), node);
+                                                       } else if (obj instanceof SingleResultNode) {
+                                                               Node node = ((SingleResultNode) obj).getNode();
+                                                               nodes.put(node.getPath(), node);
+                                                       }
+                                               }
+                                               if (!nodes.isEmpty()) {
+                                                       Session session = null;
+                                                       monitor.beginTask("Delete results", nodes.size());
+                                                       for (String path : nodes.keySet()) {
+                                                               if (session == null)
+                                                                       session = nodes.get(path).getSession();
+
+                                                               // check if the item has not already been
+                                                               // deleted while deleting one of its ancestor
+                                                               if (session.itemExists(path)) {
+                                                                       Node parent = nodes.get(path).getParent();
+                                                                       nodes.get(path).remove();
+                                                                       ResultParentUtils.updatePassedStatus(
+                                                                                       parent, true);
+                                                               }
+                                                               monitor.worked(1);
+                                                       }
+                                                       session.save();
+                                               }
+
+                                       } catch (RepositoryException e) {
+                                               throw new SlcException(
+                                                               "Unexpected error while deleteting node(s)", e);
+                                       }
+                                       monitor.done();
+                               }
+                               return Status.OK_STATUS;
+                       }
+
+               };
+               job.setUser(true);
+               job.schedule();
+               return null;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshJcrResultTreeView.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RefreshJcrResultTreeView.java
new file mode 100644 (file)
index 0000000..fdfa852
--- /dev/null
@@ -0,0 +1,54 @@
+package org.argeo.slc.client.ui.commands;
+
+import java.util.Iterator;
+
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.model.ResultParent;
+import org.argeo.slc.client.ui.views.JcrResultTreeView;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Force refresh the ResultTreeView. This command is only intended to be called
+ * by either the toolbar menu of the view or by the popup menu. Refresh due to
+ * data changes must be triggered by Observers
+ */
+public class RefreshJcrResultTreeView extends AbstractHandler {
+       public final static String ID = ClientUiPlugin.ID
+                       + ".refreshJcrResultTreeView";
+       public final static String PARAM_REFRESH_TYPE = ClientUiPlugin.ID
+                       + ".param.refreshType";
+       public final static String PARAM_REFRESH_TYPE_FULL = "fullRefresh";
+       public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
+       .getImageDescriptor("icons/refresh.png");
+       public final static String DEFAULT_LABEL = "Refresh selected";
+
+       public Object execute(final ExecutionEvent event) throws ExecutionException {
+               String refreshType = event.getParameter(PARAM_REFRESH_TYPE);
+               JcrResultTreeView view = (JcrResultTreeView) HandlerUtil
+                               .getActiveWorkbenchWindow(event).getActivePage()
+                               .getActivePart();
+
+               // force full refresh without preserving selection from the tool bar
+               if (PARAM_REFRESH_TYPE_FULL.equals(refreshType))
+                       view.refresh(null);
+               else {
+                       IStructuredSelection selection = (IStructuredSelection) HandlerUtil
+                                       .getActiveWorkbenchWindow(event).getActivePage()
+                                       .getSelection();
+                       @SuppressWarnings("rawtypes")
+                       Iterator it = selection.iterator();
+                       while (it.hasNext()) {
+                               Object obj = it.next();
+                               if (obj instanceof ResultParent) {
+                                       view.refresh((ResultParent) obj);
+                               }
+                       }
+               }
+               return null;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultFolder.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultFolder.java
new file mode 100644 (file)
index 0000000..bbab7d7
--- /dev/null
@@ -0,0 +1,60 @@
+package org.argeo.slc.client.ui.commands;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.eclipse.ui.dialogs.SingleValue;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.model.ResultFolder;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Rename a node of type SlcType.SLC_RESULT_FOLDER by moving it.
+ */
+
+public class RenameResultFolder extends AbstractHandler {
+       public final static String ID = ClientUiPlugin.ID + ".renameResultFolder";
+       public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
+                       .getImageDescriptor("icons/rename.png");
+       public final static String DEFAULT_LABEL = "Rename...";
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               IStructuredSelection selection = (IStructuredSelection) HandlerUtil
+                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
+
+               // Sanity check, already done when populating the corresponding popup
+               // menu.
+               if (selection != null && selection.size() == 1) {
+                       Object obj = selection.getFirstElement();
+                       try {
+                               if (obj instanceof ResultFolder) {
+                                       ResultFolder rf = (ResultFolder) obj;
+                                       Node sourceNode = rf.getNode();
+                                       String folderName = SingleValue.ask("Rename folder",
+                                                       "Enter a new folder name");
+                                       if (folderName != null) {
+                                               String sourcePath = sourceNode.getPath();
+                                               String targetPath = JcrUtils.parentPath(sourcePath)
+                                                               + "/" + folderName;
+                                               Session session = sourceNode.getSession();
+                                               session.move(sourcePath, targetPath);
+                                               session.save();
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "Unexpected exception while refactoring result folder",
+                                               e);
+                       }
+               }
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultNode.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RenameResultNode.java
new file mode 100644 (file)
index 0000000..d9717cc
--- /dev/null
@@ -0,0 +1,74 @@
+package org.argeo.slc.client.ui.commands;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.eclipse.ui.dialogs.SingleValue;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.model.SingleResultNode;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Rename a node of type SlcType.SLC_RESULT_FOLDER by moving it.
+ */
+
+public class RenameResultNode extends AbstractHandler {
+       public final static String ID = ClientUiPlugin.ID + ".renameResultNode";
+       public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
+                       .getImageDescriptor("icons/rename.png");
+       public final static String DEFAULT_LABEL = "Rename result";
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               IStructuredSelection selection = (IStructuredSelection) HandlerUtil
+                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
+
+               // Sanity check, already done when populating the corresponding popup
+               // menu.
+               if (selection != null && selection.size() == 1) {
+                       Object obj = selection.getFirstElement();
+                       try {
+                               if (obj instanceof SingleResultNode) {
+                                       SingleResultNode rf = (SingleResultNode) obj;
+                                       Node sourceNode = rf.getNode();
+                                       String folderName = SingleValue.ask("Rename result",
+                                                       "Enter a new result name");
+                                       if (folderName != null) {
+
+                                               if (sourceNode.getParent().hasNode(folderName)) {
+                                                       MessageDialog
+                                                                       .openError(Display.getDefault()
+                                                                                       .getActiveShell(), "Error",
+                                                                                       "Another object with the same name already exists.");
+                                                       return null;
+                                               }
+
+                                               String sourcePath = sourceNode.getPath();
+                                               String targetPath = JcrUtils.parentPath(sourcePath)
+                                                               + "/" + folderName;
+                                               Session session = sourceNode.getSession();
+                                               session.move(sourcePath, targetPath);
+                                               session.getNode(targetPath).setProperty(
+                                                               Property.JCR_TITLE, folderName);
+                                               session.save();
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "Unexpected exception while refactoring result folder",
+                                               e);
+                       }
+               }
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RunSlcFlow.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/RunSlcFlow.java
new file mode 100644 (file)
index 0000000..5e70dfb
--- /dev/null
@@ -0,0 +1,66 @@
+package org.argeo.slc.client.ui.commands;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.execution.RealizedFlow;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IParameter;
+
+@Deprecated
+public class RunSlcFlow extends AbstractHandler {
+       private ExecutionModulesManager modulesManager;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               try {
+                       Command command = event.getCommand();
+                       String name = command.getName();
+                       String module = name.substring(0, name.indexOf(':'));
+                       String flowName = name.substring(name.indexOf(':') + 1);
+
+                       final RealizedFlow realizedFlow = new RealizedFlow();
+                       realizedFlow.setModuleName(module);
+                       // FIXME deal with version
+                       String version = "0.0.0";
+                       realizedFlow.setModuleVersion(version);
+                       ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
+                       efd.setName(flowName);
+
+                       Map<String, Object> values = new HashMap<String, Object>();
+                       if (command.getParameters() != null) {
+                               for (IParameter param : command.getParameters()) {
+                                       String argName = param.getId();
+                                       // FIXME make it safer
+                                       Object value = param.getValues().getParameterValues()
+                                                       .values().iterator().next();
+                                       values.put(argName, value);
+                               }
+                               efd.setValues(values);
+                       }
+                       realizedFlow.setFlowDescriptor(efd);
+                       // new Thread("SLC Flow " + name + " from Eclipse command "
+                       // + command.getId()) {
+                       // public void run() {
+                       modulesManager.start(realizedFlow.getModuleNameVersion());
+                       modulesManager.execute(realizedFlow);
+                       // }
+                       // }.start();
+                       return null;
+               } catch (Exception e) {
+                       throw new SlcException("Could not execute command "
+                                       + event.getCommand() + " as SLC flow", e);
+               }
+       }
+
+       public void setModulesManager(
+                       ExecutionModulesManager executionModulesManager) {
+               this.modulesManager = executionModulesManager;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/UpdateModule.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/UpdateModule.java
new file mode 100644 (file)
index 0000000..7cf8509
--- /dev/null
@@ -0,0 +1,112 @@
+package org.argeo.slc.client.ui.commands;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jcr.Node;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.BasicNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.deploy.ModulesManager;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Deletes one or many results */
+public class UpdateModule extends AbstractHandler {
+       private final static Log log = LogFactory.getLog(UpdateModule.class);
+
+       private ModulesManager modulesManager;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               final ISelection selection = HandlerUtil
+                               .getActiveWorkbenchWindow(event).getActivePage().getSelection();
+               if (selection != null && selection instanceof IStructuredSelection) {
+                       UpdateJob job = new UpdateJob(selection);
+                       job.setUser(true);
+                       job.schedule();
+               }
+               return null;
+       }
+
+       private class UpdateJob extends Job {
+               private final IStructuredSelection selection;
+
+               public UpdateJob(ISelection selection) {
+                       super("Update modules");
+                       this.selection = ((IStructuredSelection) selection);
+               }
+
+               @Override
+               protected IStatus run(IProgressMonitor monitor) {
+                       Iterator<?> it = selection.iterator();
+                       Object obj = null;
+                       try {
+                               Map<String, Node> nodes = new HashMap<String, Node>();
+                               nodes: while (it.hasNext()) {
+                                       obj = it.next();
+                                       if (obj instanceof Node) {
+                                               Node node = (Node) obj;
+                                               Node executionModuleNode = null;
+                                               while (executionModuleNode == null) {
+                                                       if (node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) {
+                                                               executionModuleNode = node;
+                                                       }
+                                                       node = node.getParent();
+                                                       if (node.getPath().equals("/"))// root
+                                                               continue nodes;
+                                               }
+
+                                               if (!nodes.containsKey(executionModuleNode.getPath()))
+                                                       nodes.put(executionModuleNode.getPath(),
+                                                                       executionModuleNode);
+                                       }
+                               }
+
+                               monitor.beginTask("Update modules", nodes.size());
+                               for (Node executionModuleNode : nodes.values()) {
+                                       monitor.subTask("Update " + executionModuleNode.getName());
+                                       NameVersion nameVersion = new BasicNameVersion(
+                                                       executionModuleNode.getProperty(SlcNames.SLC_NAME)
+                                                                       .getString(), executionModuleNode
+                                                                       .getProperty(SlcNames.SLC_VERSION)
+                                                                       .getString());
+                                       modulesManager.upgrade(nameVersion);
+                                       monitor.worked(1);
+                                       log.info("Module " + nameVersion + " updated");
+                                       if (monitor.isCanceled())
+                                               return Status.CANCEL_STATUS;
+                               }
+                               return Status.OK_STATUS;
+                       } catch (Exception e) {
+                               throw new SlcException("Cannot update module " + obj, e);
+                               // return Status.CANCEL_STATUS;
+                       }
+               }
+
+               @Override
+               protected void canceling() {
+                       getThread().interrupt();
+                       super.canceling();
+               }
+
+       }
+
+       public void setModulesManager(ModulesManager modulesManager) {
+               this.modulesManager = modulesManager;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/controllers/ProcessController.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/controllers/ProcessController.java
new file mode 100644 (file)
index 0000000..4a660ad
--- /dev/null
@@ -0,0 +1,103 @@
+package org.argeo.slc.client.ui.controllers;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.SlcAgent;
+import org.argeo.slc.jcr.execution.JcrExecutionProcess;
+
+/**
+ * We use a separate class (not in UI components) so that it can be a singleton
+ * in an application context.
+ */
+public class ProcessController {
+       // private final static Log log =
+       // LogFactory.getLog(ProcessController.class);
+       // private Map<String, SlcAgentFactory> agentFactories = new HashMap<String,
+       // SlcAgentFactory>();
+
+       private SlcAgent agent;
+
+       public ExecutionProcess process(Node processNode) {
+               JcrExecutionProcess process = new JcrExecutionProcess(processNode);
+               try {
+                       SlcAgent slcAgent = findAgent(processNode);
+                       if (slcAgent == null)
+                               throw new SlcException("Cannot find agent for " + processNode);
+                       slcAgent.process(process);
+                       return process;
+               } catch (Exception e) {
+                       if (!process.getStatus().equals(ExecutionProcess.ERROR))
+                               process.setStatus(ExecutionProcess.ERROR);
+                       throw new SlcException("Cannot execute " + processNode, e);
+               }
+       }
+
+       public void kill(Node processNode) {
+               JcrExecutionProcess process = new JcrExecutionProcess(processNode);
+               try {
+                       SlcAgent slcAgent = findAgent(processNode);
+                       if (slcAgent == null)
+                               throw new SlcException("Cannot find agent for " + processNode);
+                       slcAgent.kill(process.getUuid());
+               } catch (Exception e) {
+                       if (!process.getStatus().equals(ExecutionProcess.ERROR))
+                               process.setStatus(ExecutionProcess.ERROR);
+                       throw new SlcException("Cannot execute " + processNode, e);
+               }
+       }
+
+       /** Always return the default runtime agent */
+       protected SlcAgent findAgent(Node processNode) throws RepositoryException {
+               // we currently only deal with single agents
+               // Node realizedFlowNode = processNode.getNode(SlcNames.SLC_FLOW);
+               // NodeIterator nit = realizedFlowNode.getNodes();
+               // if (nit.hasNext()) {
+               // // TODO find a better way to determine which agent to use
+               // // currently we check the agent of the first registered flow
+               // Node firstRealizedFlow = nit.nextNode();
+               // // we assume there is an nt:address
+               // String firstFlowPath = firstRealizedFlow
+               // .getNode(SlcNames.SLC_ADDRESS)
+               // .getProperty(Property.JCR_PATH).getString();
+               // Node flowNode = processNode.getSession().getNode(firstFlowPath);
+               // String agentFactoryPath = SlcJcrUtils
+               // .flowAgentFactoryPath(firstFlowPath);
+               // if (!agentFactories.containsKey(agentFactoryPath))
+               // throw new SlcException("No agent factory registered under "
+               // + agentFactoryPath);
+               // SlcAgentFactory agentFactory = agentFactories.get(agentFactoryPath);
+               // Node agentNode = ((Node) flowNode
+               // .getAncestor(SlcJcrUtils.AGENT_FACTORY_DEPTH + 1));
+               // String agentUuid = agentNode.getProperty(SlcNames.SLC_UUID)
+               // .getString();
+               //
+               // // process
+               // return agentFactory.getAgent(agentUuid);
+               // }
+
+               return agent;
+       }
+
+       public void setAgent(SlcAgent agent) {
+               this.agent = agent;
+       }
+
+       // public synchronized void register(SlcAgentFactory agentFactory,
+       // Map<String, String> properties) {
+       // String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
+       // if (log.isDebugEnabled())
+       // log.debug("Agent factory registered under " + path);
+       // agentFactories.put(path, agentFactory);
+       // }
+       //
+       // public synchronized void unregister(SlcAgentFactory agentFactory,
+       // Map<String, String> properties) {
+       // String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
+       // if (log.isDebugEnabled())
+       // log.debug("Agent factory unregistered from " + path);
+       // agentFactories.remove(path);
+       // }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/decorators/ResultFailedDecorator.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/decorators/ResultFailedDecorator.java
new file mode 100644 (file)
index 0000000..9d91cc5
--- /dev/null
@@ -0,0 +1,139 @@
+package org.argeo.slc.client.ui.decorators;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.SlcImages;
+import org.argeo.slc.client.ui.SlcUiConstants;
+import org.argeo.slc.client.ui.model.ResultFolder;
+import org.argeo.slc.client.ui.model.ResultParent;
+import org.argeo.slc.client.ui.model.SingleResultNode;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+
+/** Dynamically decorates the results tree. */
+public class ResultFailedDecorator extends LabelProvider implements
+               ILabelDecorator {
+
+       // FIXME why not use? org.eclipse.jface.viewers.DecoratingLabelProvider
+
+       // private final static Log log = LogFactory
+       // .getLog(ResultFailedDecorator.class);
+
+       private final static DateFormat dateFormat = new SimpleDateFormat(
+                       SlcUiConstants.DEFAULT_DISPLAY_DATE_TIME_FORMAT);
+
+       // hack for SWT resource leak
+       // see http://www.eclipse.org/articles/swt-design-2/swt-design-2.html
+       // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=181215
+       private final Image passedFolder;
+       private final Image failedFolder;
+       private final Image failedSingleResult;
+       private final Image errorSingleResult;
+       private final Image passedSingleResult;
+
+       public ResultFailedDecorator() {
+               super();
+               ImageDescriptor failedDesc = ClientUiPlugin.getDefault().getWorkbench()
+                               .getSharedImages()
+                               .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR);
+               failedFolder = new DecorationOverlayIcon(SlcImages.FOLDER, failedDesc,
+                               IDecoration.TOP_LEFT).createImage();
+               passedFolder = new DecorationOverlayIcon(SlcImages.FOLDER,
+                               SlcImages.EXECUTION_PASSED, IDecoration.TOP_LEFT).createImage();
+               failedSingleResult = new DecorationOverlayIcon(
+                               SlcImages.PROCESS_COMPLETED, failedDesc, IDecoration.TOP_LEFT)
+                               .createImage();
+               errorSingleResult = new DecorationOverlayIcon(
+                               SlcImages.PROCESS_COMPLETED, SlcImages.EXECUTION_ERROR,
+                               IDecoration.TOP_LEFT).createImage();
+               passedSingleResult = new DecorationOverlayIcon(
+                               SlcImages.PROCESS_COMPLETED, SlcImages.EXECUTION_PASSED,
+                               IDecoration.TOP_LEFT).createImage();
+       }
+
+       // Method to decorate Image
+       public Image decorateImage(Image image, Object object) {
+
+               // This method returns an annotated image or null if the
+               // image need not be decorated. Returning a null image
+               // decorates resource icon with basic decorations provided
+               // by Eclipse
+               if (object instanceof ResultParent) {
+                       if (((ResultParent) object).isPassed()) {
+                               if (object instanceof SingleResultNode)
+                                       return passedSingleResult;
+                               else if (object instanceof ResultFolder)
+                                       return passedFolder;
+                               else
+                                       return null;
+                       } else {
+                               // ImageDescriptor desc = ClientUiPlugin.getDefault()
+                               // .getWorkbench().getSharedImages()
+                               // .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR);
+                               // DecorationOverlayIcon decoratedImage = new
+                               // DecorationOverlayIcon(
+                               // image, desc, IDecoration.TOP_LEFT);
+                               // return decoratedImage.createImage();
+                               if (object instanceof SingleResultNode) {
+                                       SingleResultNode srn = (SingleResultNode) object;
+                                       boolean isError = false;
+                                       try {
+                                               isError = srn.getNode()
+                                                               .getNode(SlcNames.SLC_AGGREGATED_STATUS)
+                                                               .hasProperty(SlcNames.SLC_ERROR_MESSAGE);
+                                       } catch (RepositoryException re) {
+                                               // Silent node might not exist
+                                       }
+                                       if (isError)
+                                               return errorSingleResult;
+                                       else
+                                               return failedSingleResult;
+
+                               } else
+                                       return failedFolder;
+                       }
+               }
+               return null;
+       }
+
+       // Method to decorate Text
+       public String decorateText(String label, Object object) {
+               if (object instanceof SingleResultNode) {
+                       SingleResultNode srNode = (SingleResultNode) object;
+                       Node node = srNode.getNode();
+                       String decoration = null;
+                       try {
+                               if (node.hasProperty(SlcNames.SLC_COMPLETED))
+                                       decoration = dateFormat.format(node
+                                                       .getProperty(SlcNames.SLC_COMPLETED).getDate()
+                                                       .getTime());
+                       } catch (RepositoryException re) {
+                               throw new SlcException(
+                                               "Unexpected error defining text decoration for result",
+                                               re);
+                       }
+                       return label + " [" + decoration + "]";
+               } else
+                       return null;
+       }
+
+       @Override
+       public void dispose() {
+               failedFolder.dispose();
+               failedSingleResult.dispose();
+               super.dispose();
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java
new file mode 100644 (file)
index 0000000..7c3d532
--- /dev/null
@@ -0,0 +1,804 @@
+package org.argeo.slc.client.ui.editors;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.jcr.LoginException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.SlcImages;
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.jcr.SlcJcrUtils;
+import org.argeo.slc.primitive.PrimitiveAccessor;
+import org.argeo.slc.primitive.PrimitiveUtils;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerDropAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.forms.AbstractFormPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/** Definition of the process. */
+public class ProcessBuilderPage extends FormPage implements SlcNames {
+       // private final static Log log =
+       // LogFactory.getLog(ProcessBuilderPage.class);
+
+       public final static String ID = "processBuilderPage";
+
+       /** To be displayed in empty lists */
+       final static String NONE = "<none>";
+
+       private Node processNode;
+       private Session agentSession;
+
+       private TreeViewer flowsViewer;
+       private TableViewer valuesViewer;
+       private Label statusLabel;
+       private Button run;
+       private Button remove;
+       private Button clear;
+
+       private AbstractFormPart formPart;
+       private EventListener statusObserver;
+
+       public ProcessBuilderPage(ProcessEditor editor, Node processNode) {
+               super(editor, ID, "Definition");
+               this.processNode = processNode;
+               try {
+                       this.agentSession = processNode.getSession().getRepository().login();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot open agent session", e);
+               }
+       }
+
+       @Override
+       protected void createFormContent(IManagedForm mf) {
+               try {
+                       ScrolledForm form = mf.getForm();
+                       form.setExpandHorizontal(true);
+                       form.setExpandVertical(true);
+                       form.setText("Process " + processNode.getName());
+                       GridLayout mainLayout = new GridLayout(1, true);
+                       form.getBody().setLayout(mainLayout);
+
+                       createControls(form.getBody());
+                       createBuilder(form.getBody());
+
+                       // form
+                       formPart = new AbstractFormPart() {
+
+                       };
+                       getManagedForm().addPart(formPart);
+
+                       // observation
+                       statusObserver = new AsyncUiEventListener(form.getDisplay()) {
+                               protected void onEventInUiThread(List<Event> events) {
+                                       statusChanged();
+                               }
+                       };
+                       ObservationManager observationManager = processNode.getSession().getWorkspace().getObservationManager();
+                       observationManager.addEventListener(statusObserver, Event.PROPERTY_CHANGED, processNode.getPath(), true,
+                                       null, null, false);
+
+                       // make sure all controls are in line with status
+                       statusChanged();
+
+                       // add initial flows
+                       addInitialFlows();
+
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot create form content", e);
+               }
+       }
+
+       protected void createControls(Composite parent) {
+               FormToolkit tk = getManagedForm().getToolkit();
+
+               Composite controls = tk.createComposite(parent);
+               controls.setLayout(new RowLayout());
+               controls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+               run = tk.createButton(controls, null, SWT.PUSH);
+               run.setToolTipText("Run");
+               run.setImage(SlcImages.LAUNCH);
+               run.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               if (isFinished(getProcessStatus())) {
+                                       ((ProcessEditor) getEditor()).relaunch();
+                               } else if (isRunning(getProcessStatus())) {
+                                       ((ProcessEditor) getEditor()).kill();
+                               } else {
+                                       ((ProcessEditor) getEditor()).process();
+                               }
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               widgetSelected(e);
+                       }
+               });
+
+               remove = tk.createButton(controls, null, SWT.PUSH);
+               remove.setImage(SlcImages.REMOVE_ONE);
+               remove.setToolTipText("Remove selected flows");
+               remove.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               removeSelectedFlows();
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               widgetSelected(e);
+                       }
+               });
+
+               clear = tk.createButton(controls, null, SWT.PUSH);
+               clear.setImage(SlcImages.REMOVE_ALL);
+               clear.setToolTipText("Clear all flows");
+               clear.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               removeAllFlows();
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               widgetSelected(e);
+                       }
+               });
+
+               Composite statusComposite = tk.createComposite(controls);
+               RowData rowData = new RowData();
+               rowData.width = 100;
+               rowData.height = 16;
+               statusComposite.setLayoutData(rowData);
+               statusComposite.setLayout(new FillLayout());
+               statusLabel = tk.createLabel(statusComposite, getProcessStatus());
+
+       }
+
+       protected void createBuilder(Composite parent) {
+               FormToolkit tk = getManagedForm().getToolkit();
+               SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
+               sashForm.setSashWidth(4);
+               GridData sahFormGd = new GridData(SWT.FILL, SWT.FILL, true, true);
+               sahFormGd.widthHint = 400;
+               sashForm.setLayoutData(sahFormGd);
+
+               Composite flowsComposite = tk.createComposite(sashForm);
+               flowsComposite.setLayout(new GridLayout(1, false));
+
+               flowsViewer = new TreeViewer(flowsComposite);
+               flowsViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               flowsViewer.setLabelProvider(new FlowsLabelProvider());
+               flowsViewer.setContentProvider(new FlowsContentProvider());
+               flowsViewer.addSelectionChangedListener(new FlowsSelectionListener());
+
+               int operations = DND.DROP_COPY | DND.DROP_MOVE;
+               Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
+               flowsViewer.addDropSupport(operations, tt, new FlowsDropListener(flowsViewer));
+
+               // Context menu
+               addContextMenu();
+
+               flowsViewer.setInput(getEditorSite());
+               flowsViewer.setInput(processNode);
+
+               Composite valuesComposite = tk.createComposite(sashForm);
+               valuesComposite.setLayout(new GridLayout(1, false));
+
+               valuesViewer = new TableViewer(valuesComposite);
+               GridData valuedGd = new GridData(SWT.FILL, SWT.FILL, true, true);
+               // valuedGd.widthHint = 200;
+               valuesViewer.getTable().setLayoutData(valuedGd);
+               valuesViewer.getTable().setHeaderVisible(true);
+
+               valuesViewer.setContentProvider(new ValuesContentProvider());
+               initializeValuesViewer(valuesViewer);
+               sashForm.setWeights(getWeights());
+               valuesViewer.setInput(getEditorSite());
+       }
+
+       /** Creates the columns of the values viewer */
+       protected void initializeValuesViewer(TableViewer viewer) {
+               String[] titles = { "Name", "Value" };
+               int[] bounds = { 200, 100 };
+
+               for (int i = 0; i < titles.length; i++) {
+                       TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+                       column.getColumn().setText(titles[i]);
+                       column.getColumn().setWidth(bounds[i]);
+                       column.getColumn().setResizable(true);
+                       column.getColumn().setMoveable(true);
+                       if (i == 0) {
+                               column.setLabelProvider(new ColumnLabelProvider() {
+                                       public String getText(Object element) {
+                                               try {
+                                                       Node specAttrNode = (Node) element;
+                                                       return specAttrNode.getName();
+                                               } catch (RepositoryException e) {
+                                                       throw new SlcException("Cannot get value", e);
+                                               }
+                                       }
+                               });
+                       } else if (i == 1) {
+                               column.setLabelProvider(new ColumnLabelProvider() {
+                                       public String getText(Object element) {
+                                               return getAttributeSpecText((Node) element);
+                                       }
+                               });
+                               column.setEditingSupport(new ValuesEditingSupport(viewer));
+                       }
+
+               }
+               Table table = viewer.getTable();
+               table.setHeaderVisible(false);
+               table.setLinesVisible(true);
+       }
+
+       protected int[] getWeights() {
+               return new int[] { 50, 50 };
+       }
+
+       /*
+        * CONTROLLERS
+        */
+       /** Reflects a status change */
+       protected void statusChanged() {
+               String status = getProcessStatus();
+               statusLabel.setText(status);
+               Boolean isEditable = isEditable(status);
+               run.setEnabled(status.equals(ExecutionProcess.RUNNING) || isEditable);
+               remove.setEnabled(isEditable);
+               clear.setEnabled(isEditable);
+               // flowsViewer.getTree().setEnabled(isEditable);
+               if (status.equals(ExecutionProcess.RUNNING)) {
+                       run.setEnabled(true);
+                       run.setImage(SlcImages.KILL);
+                       run.setToolTipText("Kill");
+               } else if (isFinished(status)) {
+                       run.setEnabled(true);
+                       run.setImage(SlcImages.RELAUNCH);
+                       run.setToolTipText("Relaunch");
+               }
+
+               if (flowsViewer != null)
+                       flowsViewer.refresh();
+       }
+
+       /** Adds initial flows from the editor input if any */
+       protected void addInitialFlows() {
+               for (String path : ((ProcessEditorInput) getEditorInput()).getInitialFlowPaths()) {
+                       addFlow(path);
+               }
+       }
+
+       /**
+        * Adds a new flow.
+        * 
+        * @param path the path of the flow
+        */
+       protected void addFlow(String path) {
+               try {
+                       Node flowNode = agentSession.getNode(path);
+                       Node realizedFlowNode = processNode.getNode(SLC_FLOW).addNode(SLC_FLOW);
+                       realizedFlowNode.setProperty(SLC_NAME, flowNode.getProperty(SLC_NAME).getString());
+                       realizedFlowNode.addMixin(SlcTypes.SLC_REALIZED_FLOW);
+                       Node address = realizedFlowNode.addNode(SLC_ADDRESS, NodeType.NT_ADDRESS);
+                       address.setProperty(Property.JCR_PATH, path);
+
+                       // copy spec attributes
+                       Node specAttrsBase;
+                       if (flowNode.hasProperty(SLC_SPEC)) {
+                               Node executionSpecNode = flowNode.getProperty(SLC_SPEC).getNode();
+                               specAttrsBase = executionSpecNode;
+                               String executionSpecName = executionSpecNode.getProperty(SLC_NAME).getString();
+                               realizedFlowNode.setProperty(SLC_SPEC, executionSpecName);
+                       } else
+                               specAttrsBase = flowNode;
+
+                       specAttrs: for (NodeIterator nit = specAttrsBase.getNodes(); nit.hasNext();) {
+                               Node specAttrNode = nit.nextNode();
+                               String attrName = specAttrNode.getName();
+                               if (!specAttrNode.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
+                                       continue specAttrs;
+                               Node realizedAttrNode = realizedFlowNode.addNode(specAttrNode.getName());
+                               JcrUtils.copy(specAttrNode, realizedAttrNode);
+
+                               // override with flow value
+                               if (flowNode.hasNode(attrName)) {
+                                       // assuming this is a primitive
+                                       Node attrNode = flowNode.getNode(attrName);
+                                       if (attrNode.hasProperty(SLC_VALUE))
+                                               realizedAttrNode.setProperty(SLC_VALUE, attrNode.getProperty(SLC_VALUE).getValue());
+                               }
+                       }
+
+                       // Part title
+                       StringBuilder editorTitle = new StringBuilder();
+                       NodeIterator it = realizedFlowNode.getParent().getNodes(SLC_FLOW);
+                       while (it.hasNext()) {
+                               Node rFlowNode = it.nextNode();
+                               String name = rFlowNode.getProperty(SLC_NAME).getString();
+                               editorTitle.append(name).append(' ');
+                       }
+                       ((ProcessEditor) getEditor()).setEditorTitle(editorTitle.toString());
+
+                       flowsViewer.refresh();
+                       formPart.markDirty();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot add flow " + path, e);
+               }
+       }
+
+       @SuppressWarnings("unchecked")
+       protected void removeSelectedFlows() {
+               if (!flowsViewer.getSelection().isEmpty()) {
+                       Iterator<Object> it = ((StructuredSelection) flowsViewer.getSelection()).iterator();
+                       while (it.hasNext()) {
+                               Node node = (Node) it.next();
+                               try {
+                                       node.remove();
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot remove " + node, e);
+                               }
+                       }
+                       flowsViewer.refresh();
+                       formPart.markDirty();
+               }
+       }
+
+       protected void removeAllFlows() {
+               try {
+                       for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit.hasNext();) {
+                               nit.nextNode().remove();
+                       }
+                       flowsViewer.refresh();
+                       formPart.markDirty();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot remove flows from " + processNode, e);
+               }
+       }
+
+       public void commit(Boolean onSave) {
+               if (onSave)
+                       statusLabel.setText(getProcessStatus());
+               formPart.commit(onSave);
+       }
+
+       /*
+        * STATE
+        */
+       protected String getProcessStatus() {
+               try {
+                       return processNode.getProperty(SLC_STATUS).getString();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot retrieve status for " + processNode, e);
+               }
+       }
+
+       /** Optimization so that we don't call the node each time */
+       protected static Boolean isEditable(String status) {
+               return status.equals(ExecutionProcess.NEW) || status.equals(ExecutionProcess.INITIALIZED);
+       }
+
+       protected static Boolean isFinished(String status) {
+               return status.equals(ExecutionProcess.COMPLETED) || status.equals(ExecutionProcess.ERROR)
+                               || status.equals(ExecutionProcess.KILLED);
+       }
+
+       protected static Boolean isRunning(String status) {
+               return status.equals(ExecutionProcess.RUNNING);
+       }
+
+       /*
+        * LIFECYCLE
+        */
+       @Override
+       public void dispose() {
+               JcrUtils.unregisterQuietly(processNode, statusObserver);
+               JcrUtils.logoutQuietly(agentSession);
+               super.dispose();
+       }
+
+       /*
+        * UTILITIES
+        */
+       protected static String getAttributeSpecText(Node specAttrNode) {
+               try {
+                       if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
+                               if (!specAttrNode.hasProperty(SLC_VALUE))
+                                       return "";
+                               String type = specAttrNode.getProperty(SLC_TYPE).getString();
+                               if (PrimitiveAccessor.TYPE_PASSWORD.equals(type))
+                                       return "****************";
+                               Object value = PrimitiveUtils.convert(type, specAttrNode.getProperty(SLC_VALUE).getString());
+                               return value.toString();
+                       } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
+                               if (specAttrNode.hasProperty(SLC_VALUE)) {
+                                       int value = (int) specAttrNode.getProperty(SLC_VALUE).getLong();
+                                       NodeIterator children = specAttrNode.getNodes();
+                                       int index = 0;
+                                       while (children.hasNext()) {
+                                               Node child = children.nextNode();
+                                               if (index == value)
+                                                       return child.getProperty(Property.JCR_TITLE).getString();
+                                               index++;
+                                       }
+                                       throw new SlcException("No child node with index " + value + " for spec attribute " + specAttrNode);
+                               } else
+                                       return "";
+                       }
+                       throw new SlcException("Unsupported type for spec attribute " + specAttrNode);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot get value", e);
+               }
+       }
+
+       /*
+        * FLOWS SUBCLASSES
+        */
+       class FlowsContentProvider implements ITreeContentProvider {
+               public Object[] getElements(Object obj) {
+                       if (!(obj instanceof Node))
+                               return new Object[0];
+
+                       try {
+                               Node node = (Node) obj;
+                               List<Node> children = new ArrayList<Node>();
+                               for (NodeIterator nit = node.getNode(SLC_FLOW).getNodes(); nit.hasNext();) {
+                                       Node flowNode = nit.nextNode();
+                                       children.add(flowNode);
+                               }
+                               return children.toArray();
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot list flows of " + obj, e);
+                       }
+               }
+
+               public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+               }
+
+               public void dispose() {
+               }
+
+               public Object[] getChildren(Object parentElement) {
+                       // no children for the time being
+                       return null;
+               }
+
+               public Object getParent(Object element) {
+                       return null;
+               }
+
+               public boolean hasChildren(Object element) {
+                       return false;
+               }
+
+       }
+
+       static class FlowsLabelProvider extends ColumnLabelProvider {
+               @Override
+               public String getText(Object element) {
+                       Node node = (Node) element;
+                       try {
+                               if (node.isNodeType(SlcTypes.SLC_REALIZED_FLOW)) {
+                                       if (node.hasNode(SLC_ADDRESS)) {
+                                               String path = node.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString();
+                                               String executionModuleName = SlcJcrUtils.moduleName(path);
+                                               // Node executionModuleNode = node.getSession().getNode(
+                                               // SlcJcrUtils.modulePath(path));
+                                               // String executionModuleName = executionModuleNode
+                                               // .getProperty(SLC_NAME).getString();
+                                               return executionModuleName + ":" + SlcJcrUtils.flowRelativePath(path);
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot display " + element, e);
+                       }
+                       return super.getText(element);
+               }
+
+               @Override
+               public Image getImage(Object element) {
+                       Node node = (Node) element;
+                       try {
+                               if (node.isNodeType(SlcTypes.SLC_REALIZED_FLOW)) {
+                                       if (node.hasProperty(SLC_STATUS)) {
+                                               String status = node.getProperty(SLC_STATUS).getString();
+                                               // TODO: factorize with process view ?
+                                               if (status.equals(ExecutionProcess.RUNNING))
+                                                       return SlcImages.PROCESS_RUNNING;
+                                               else if (status.equals(ExecutionProcess.ERROR) || status.equals(ExecutionProcess.KILLED))
+                                                       return SlcImages.PROCESS_ERROR;
+                                               else if (status.equals(ExecutionProcess.COMPLETED))
+                                                       return SlcImages.PROCESS_COMPLETED;
+                                       }
+                                       return SlcImages.FLOW;
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot display " + element, e);
+                       }
+                       return super.getImage(element);
+               }
+
+       }
+
+       /** Parameter view is updated each time a new line is selected */
+       class FlowsSelectionListener implements ISelectionChangedListener {
+               public void selectionChanged(SelectionChangedEvent evt) {
+                       if (evt.getSelection().isEmpty()) {
+                               valuesViewer.setInput(getEditorSite());
+                               return;
+                       }
+                       Node realizedFlowNode = (Node) ((IStructuredSelection) evt.getSelection()).getFirstElement();
+                       valuesViewer.setInput(realizedFlowNode);
+               }
+       }
+
+       /**
+        * Add a context menu that call private methods. It only relies on selected
+        * item(s) not on parameter that are passed in the menuAboutToShow method
+        **/
+       private void addContextMenu() {
+               Menu menu = new Menu(flowsViewer.getControl());
+
+               MenuItem removeItems = new MenuItem(menu, SWT.PUSH);
+               removeItems.addSelectionListener(new SelectionListener() {
+
+                       public void widgetSelected(SelectionEvent e) {
+                               removeSelectedFlows();
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+               });
+               removeItems.setText("Remove selected flow(s)");
+
+               MenuItem removeAllItems = new MenuItem(menu, SWT.PUSH);
+               removeAllItems.addSelectionListener(new SelectionListener() {
+
+                       public void widgetSelected(SelectionEvent e) {
+                               removeAllFlows();
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+               });
+               removeAllItems.setText("Remove all flows");
+               flowsViewer.getTree().setMenu(menu);
+       }
+
+       /** Manages drop event. */
+       class FlowsDropListener extends ViewerDropAdapter {
+
+               public FlowsDropListener(Viewer viewer) {
+                       super(viewer);
+               }
+
+               @Override
+               public boolean performDrop(Object data) {
+
+                       // Parse the received String, paths are separated with a carriage
+                       // return
+                       String[] paths = data.toString().split(new String("\n"));
+                       SortedSet<String> resultPaths = new TreeSet<String>();
+                       for (String path : paths) {
+                               try {
+                                       // either a node or a whole directory can have been dragged
+                                       QueryManager qm = processNode.getSession().getWorkspace().getQueryManager();
+                                       String statement = "SELECT * FROM [" + SlcTypes.SLC_EXECUTION_FLOW + "] WHERE ISDESCENDANTNODE(['"
+                                                       + path + "']) OR ISSAMENODE(['" + path + "'])";
+                                       Query query = qm.createQuery(statement, Query.JCR_SQL2);
+
+                                       // order paths
+                                       for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
+                                               String currPath = nit.nextNode().getPath();
+                                               // do not add twice a same flow
+                                               if (!resultPaths.contains(currPath))
+                                                       resultPaths.add(currPath);
+                                       }
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot query flows under " + path, e);
+                               }
+                       }
+                       for (String p : resultPaths) {
+                               addFlow(p);
+                       }
+                       return true;
+
+               }
+
+               @Override
+               public boolean validateDrop(Object target, int operation, TransferData transferType) {
+                       return isEditable(getProcessStatus());
+               }
+       }
+
+       /*
+        * VALUES SUBCLASSES
+        */
+       static class ValuesContentProvider implements IStructuredContentProvider {
+
+               public Object[] getElements(Object inputElement) {
+                       if (!(inputElement instanceof Node))
+                               return new Object[0];
+
+                       try {
+                               Node realizedFlowNode = (Node) inputElement;
+                               List<Node> specAttributes = new ArrayList<Node>();
+                               specAttrs: for (NodeIterator nit = realizedFlowNode.getNodes(); nit.hasNext();) {
+                                       Node specAttrNode = nit.nextNode();
+                                       if (!specAttrNode.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
+                                               continue specAttrs;
+                                       // workaround to enable hiding of necessary but unusable
+                                       // flow parameters
+                                       else if (specAttrNode.hasProperty(SlcNames.SLC_IS_HIDDEN)
+                                                       && specAttrNode.getProperty(SlcNames.SLC_IS_HIDDEN).getBoolean())
+                                               continue specAttrs;
+                                       specAttributes.add(specAttrNode);
+                               }
+                               return specAttributes.toArray();
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get elements", e);
+                       }
+               }
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+       }
+
+       class ValuesEditingSupport extends EditingSupport {
+               private final TableViewer tableViewer;
+
+               public ValuesEditingSupport(ColumnViewer viewer) {
+                       super(viewer);
+                       tableViewer = (TableViewer) viewer;
+               }
+
+               @Override
+               protected CellEditor getCellEditor(Object element) {
+                       try {
+                               Node specAttrNode = (Node) element;
+                               if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
+                                       String type = specAttrNode.getProperty(SLC_TYPE).getString();
+                                       if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) {
+                                               return new TextCellEditor(tableViewer.getTable(), SWT.PASSWORD);
+                                       } else {
+                                               return new TextCellEditor(tableViewer.getTable());
+                                       }
+                               } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
+                                       NodeIterator children = specAttrNode.getNodes();
+                                       ArrayList<String> items = new ArrayList<String>();
+                                       while (children.hasNext()) {
+                                               Node child = children.nextNode();
+                                               if (child.isNodeType(NodeType.MIX_TITLE))
+                                                       items.add(child.getProperty(Property.JCR_TITLE).getString());
+                                       }
+                                       return new ComboBoxCellEditor(tableViewer.getTable(), items.toArray(new String[items.size()]));
+                               }
+                               return null;
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get cell editor", e);
+                       }
+               }
+
+               @Override
+               protected boolean canEdit(Object element) {
+                       try {
+                               Node specAttrNode = (Node) element;
+                               Boolean cannotEdit = specAttrNode.getProperty(SLC_IS_IMMUTABLE).getBoolean()
+                                               || specAttrNode.getProperty(SLC_IS_CONSTANT).getBoolean();
+                               return !cannotEdit && isSupportedAttributeType(specAttrNode);
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot check whether " + element + " is editable", e);
+                       }
+               }
+
+               /**
+                * Supports {@link SlcTypes#SLC_PRIMITIVE_SPEC_ATTRIBUTE} and
+                * {@link SlcTypes#SLC_REF_SPEC_ATTRIBUTE}
+                */
+               protected boolean isSupportedAttributeType(Node specAttrNode) throws RepositoryException {
+                       return specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)
+                                       || specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE);
+               }
+
+               @Override
+               protected Object getValue(Object element) {
+                       Node specAttrNode = (Node) element;
+                       try {
+                               if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
+                                       if (!specAttrNode.hasProperty(SLC_VALUE))
+                                               return NONE;
+                                       String type = specAttrNode.getProperty(SLC_TYPE).getString();
+                                       // TODO optimize based on data type?
+                                       Object value = PrimitiveUtils.convert(type, specAttrNode.getProperty(SLC_VALUE).getString());
+                                       return value.toString();
+                               } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
+                                       if (!specAttrNode.hasProperty(SLC_VALUE))
+                                               return 0;
+                                       // return the index of the sub node as set by setValue()
+                                       // in the future we may manage references as well
+                                       return (int) specAttrNode.getProperty(SLC_VALUE).getLong();
+                               }
+                               throw new SlcException("Unsupported type for spec attribute " + specAttrNode);
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get value for " + element, e);
+                       }
+               }
+
+               @Override
+               protected void setValue(Object element, Object value) {
+                       try {
+                               Node specAttrNode = (Node) element;
+                               if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
+                                       String type = specAttrNode.getProperty(SLC_TYPE).getString();
+                                       SlcJcrUtils.setPrimitiveAsProperty(specAttrNode, SLC_VALUE, type, value);
+                                       valuesViewer.refresh();
+                                       formPart.markDirty();
+                               } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
+                                       specAttrNode.setProperty(SLC_VALUE, ((Integer) value).longValue());
+                                       valuesViewer.refresh();
+                                       formPart.markDirty();
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get celle editor", e);
+                       }
+               }
+
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java
new file mode 100644 (file)
index 0000000..38db84a
--- /dev/null
@@ -0,0 +1,248 @@
+package org.argeo.slc.client.ui.editors;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.api.NodeConstants;
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.controllers.ProcessController;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.jcr.SlcJcrUtils;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.rap.rwt.service.ServerPushSession;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/** Editor for an execution process. */
+public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames {
+       private static final long serialVersionUID = 509589737739132467L;
+
+       public final static String ID = ClientUiPlugin.ID + ".processEditor";
+
+       private Repository repository;
+       private Session homeSession;
+       private Session agentSession;
+       private Node processNode;
+       private ProcessController processController;
+       private ServerPushSession pushSession;
+
+       private ProcessBuilderPage builderPage;
+
+       private ExecutionModulesManager modulesManager;
+
+       @Override
+       public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+               super.init(site, input);
+               pushSession = new ServerPushSession();
+               pushSession.start();
+               try {
+                       homeSession = repository.login(NodeConstants.HOME_WORKSPACE);
+                       agentSession = repository.login();
+               } catch (RepositoryException e1) {
+                       throw new SlcException("Cannot log in to repository");
+               }
+
+               ProcessEditorInput pei = (ProcessEditorInput) input;
+               String processPath = pei.getProcessPath();
+               try {
+                       if (processPath != null) {
+                               if (!homeSession.itemExists(processPath))
+                                       throw new SlcException("Process " + processPath + " does not exist");
+                               processNode = homeSession.getNode(processPath);
+                       } else {// new
+                               processNode = newProcessNode(pei);
+                       }
+                       setPartName(processNode.getName());
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot initialize editor for " + pei, e);
+               }
+
+       }
+
+       protected Node newProcessNode(ProcessEditorInput pei) throws RepositoryException {
+               String uuid = UUID.randomUUID().toString();
+               String processPath = SlcJcrUtils.createExecutionProcessPath(homeSession, uuid);
+               Node processNode = JcrUtils.mkdirs(homeSession, processPath, SLC_PROCESS);
+               processNode.setProperty(SLC_UUID, uuid);
+               processNode.setProperty(SLC_STATUS, ExecutionProcess.NEW);
+               Node processFlow = processNode.addNode(SLC_FLOW);
+               processFlow.addMixin(SLC_REALIZED_FLOW);
+               return processNode;
+       }
+
+       @Override
+       public boolean isDirty() {
+               if (getProcessStatus().equals(ExecutionProcess.NEW))
+                       return true;
+               return super.isDirty();
+       }
+
+       protected String getProcessStatus() {
+               try {
+                       return processNode.getProperty(SLC_STATUS).getString();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot retrieve status for " + processNode, e);
+               }
+       }
+
+       @Override
+       public void dispose() {
+               JcrUtils.logoutQuietly(homeSession);
+               JcrUtils.logoutQuietly(agentSession);
+               if (pushSession != null)
+                       pushSession.stop();
+               super.dispose();
+       }
+
+       /** Actually runs the process. */
+       void process() {
+               // the modifications have to be saved before execution
+               try {
+                       processNode.setProperty(SLC_STATUS, ExecutionProcess.SCHEDULED);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot update status of " + processNode, e);
+               }
+
+               // save
+               doSave(null);
+
+               try {
+                       // make sure modules are started for all nodes
+                       for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit.hasNext();) {
+                               Node flowNode = nit.nextNode();
+                               try {
+                                       String flowDefPath = flowNode.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString();
+                                       Node executionModuleNode = agentSession.getNode(SlcJcrUtils.modulePath(flowDefPath));
+                                       if (!executionModuleNode.getProperty(SLC_STARTED).getBoolean())
+                                               ClientUiPlugin.startStopExecutionModule(modulesManager, executionModuleNode);
+                               } catch (Exception e) {
+                                       ErrorFeedback.show("Cannot start execution module related to " + flowNode, e);
+                               }
+                       }
+
+                       // Actually process
+                       ExecutionProcess process = processController.process(processNode);
+                       Map<String, String> properties = new HashMap<String, String>();
+                       properties.put(ExecutionModulesManager.SLC_PROCESS_ID, process.getUuid());
+                       // modulesManager.registerProcessNotifier(this, properties);
+               } catch (Exception e) {
+                       ErrorFeedback.show("Execution of " + processNode + " failed", e);
+               }
+       }
+
+       void kill() {
+               processController.kill(processNode);
+       }
+
+       /** Opens a new editor with a copy of this process */
+       void relaunch() {
+               try {
+                       Node duplicatedNode = duplicateProcess();
+                       IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                       activePage.openEditor(new ProcessEditorInput(duplicatedNode.getPath()), ProcessEditor.ID);
+                       close(false);
+               } catch (Exception e1) {
+                       throw new SlcException("Cannot relaunch " + processNode, e1);
+               }
+       }
+
+       /** Duplicates the process */
+       protected Node duplicateProcess() {
+               try {
+                       Session session = processNode.getSession();
+                       String uuid = UUID.randomUUID().toString();
+                       String destPath = SlcJcrUtils.createExecutionProcessPath(session, uuid);
+                       Node newNode = JcrUtils.mkdirs(session, destPath, SlcTypes.SLC_PROCESS);
+
+                       Node rootRealizedFlowNode = newNode.addNode(SLC_FLOW);
+                       // copy node
+                       JcrUtils.copy(processNode.getNode(SLC_FLOW), rootRealizedFlowNode);
+
+                       newNode.setProperty(SLC_UUID, uuid);
+                       newNode.setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
+
+                       // reset realized flow status
+                       // we just manage one level for the time being
+                       NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW);
+                       while (nit.hasNext()) {
+                               nit.nextNode().setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
+                       }
+
+                       session.save();
+                       return newNode;
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot duplicate process", e);
+               }
+       }
+
+       @Override
+       protected void addPages() {
+               try {
+                       builderPage = new ProcessBuilderPage(this, processNode);
+                       addPage(builderPage);
+                       firePropertyChange(PROP_DIRTY);
+               } catch (PartInitException e) {
+                       throw new SlcException("Cannot add pages", e);
+               }
+
+       }
+
+       @Override
+       public void doSave(IProgressMonitor monitor) {
+               try {
+                       String status = processNode.getProperty(SLC_STATUS).getString();
+                       if (status.equals(ExecutionProcess.NEW))
+                               processNode.setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
+                       homeSession.save();
+                       builderPage.commit(true);
+                       editorDirtyStateChanged();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot save " + processNode, e);
+                       // } finally {
+                       // JcrUtils.discardQuietly(session);
+               }
+       }
+
+       public void setEditorTitle(String title) {
+               setPartName(title);
+       }
+
+       @Override
+       public void doSaveAs() {
+       }
+
+       @Override
+       public boolean isSaveAsAllowed() {
+               return false;
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setProcessController(ProcessController processController) {
+               this.processController = processController;
+       }
+
+       public void setModulesManager(ExecutionModulesManager modulesManager) {
+               this.modulesManager = modulesManager;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInput.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInput.java
new file mode 100644 (file)
index 0000000..f93af3f
--- /dev/null
@@ -0,0 +1,87 @@
+package org.argeo.slc.client.ui.editors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistableElement;
+
+public class ProcessEditorInput implements IEditorInput, IPersistableElement {
+       private String processPath;
+       private List<String> initialFlowPaths = new ArrayList<String>();
+       private Boolean launchImmediately = false;
+
+       /** New empty process */
+       public ProcessEditorInput() {
+       }
+
+       /** New process with some flows */
+       public ProcessEditorInput(List<String> initialFlowPaths,
+                       Boolean launchImmediately) {
+               this.initialFlowPaths = initialFlowPaths;
+               this.launchImmediately = launchImmediately;
+       }
+
+       /** Existing process */
+       public ProcessEditorInput(String processPath) {
+               this.processPath = processPath;
+       }
+
+       @SuppressWarnings("rawtypes")
+       public Object getAdapter(Class arg0) {
+               return null;
+       }
+
+       public boolean exists() {
+               return processPath != null;
+       }
+
+       public ImageDescriptor getImageDescriptor() {
+               return null;
+       }
+
+       public String getName() {
+               return processPath != null ? processPath : "<new process>";
+       }
+
+       public IPersistableElement getPersistable() {
+               return this;
+       }
+
+       public String getToolTipText() {
+               return "";
+       }
+
+       public void saveState(IMemento memento) {
+               memento.putString("processPath", processPath);
+       }
+
+       public String getFactoryId() {
+               return ProcessEditorInputFactory.ID;
+       }
+
+       public String getProcessPath() {
+               return processPath;
+       }
+
+       public List<String> getInitialFlowPaths() {
+               return initialFlowPaths;
+       }
+
+       public Boolean getLaunchImmediately() {
+               return launchImmediately;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (!(obj instanceof ProcessEditorInput))
+                       return false;
+               ProcessEditorInput pei = (ProcessEditorInput) obj;
+               if (processPath != null && pei.processPath != null)
+                       return processPath.equals(pei.processPath);
+               return false;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInputFactory.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditorInputFactory.java
new file mode 100644 (file)
index 0000000..b5a5d70
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.slc.client.ui.editors;
+
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IElementFactory;
+import org.eclipse.ui.IMemento;
+
+public class ProcessEditorInputFactory implements IElementFactory {
+       public final static String ID = ClientUiPlugin.ID
+                       + ".processEditorInputFactory";
+
+       public IAdaptable createElement(IMemento memento) {
+               String path = memento.getString("processPath");
+               return new ProcessEditorInput(path);
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessLogPage.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessLogPage.java
new file mode 100644 (file)
index 0000000..57eff2e
--- /dev/null
@@ -0,0 +1,220 @@
+package org.argeo.slc.client.ui.editors;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Workspace;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventListener;
+import javax.jcr.query.Query;
+
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.execution.ExecutionStep;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class ProcessLogPage extends FormPage {
+       public final static String ID = "processLogPage";
+
+       private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+       /** Where the log is displayed. */
+       private Text text;
+       /**
+        * Stores logs received before the text was shown. TODO : rather store in in
+        * JCR and reads it from there.
+        */
+       private StringBuffer beforeTextInit = new StringBuffer("");
+
+       private Node processNode;
+       /**
+        * optimization field: we compute once the length of the path to slc:log so
+        * that we can easily substring the relative path of logs.
+        */
+       //private Integer logPathLength;
+
+       public ProcessLogPage(FormEditor editor, Node processNode) {
+               super(editor, ID, "Log");
+               this.processNode = processNode;
+
+               EventListener listener = new LogListener(editor.getSite().getPage()
+                               .getWorkbenchWindow().getWorkbench().getDisplay());
+
+               try {
+                       String logBasePath = processNode.getPath() + '/' + SlcNames.SLC_LOG;
+                       //logPathLength = logBasePath.length();
+
+                       Workspace ws = processNode.getSession().getWorkspace();
+
+                       String statement = "SELECT * FROM ["
+                                       + SlcTypes.SLC_LOG_ENTRY
+                                       + "] as logEntry"
+                                       + " WHERE ISDESCENDANTNODE('"
+                                       + logBasePath
+                                       + "')"
+                                       + " ORDER BY logEntry.[slc:timestamp] ASC, NAME(logEntry) ASC";
+                       StringBuffer buf = new StringBuffer("");
+                       NodeIterator it = ws.getQueryManager()
+                                       .createQuery(statement, Query.JCR_SQL2).execute()
+                                       .getNodes();
+                       while (it.hasNext())
+                               appendLogEntry(buf, it.nextNode());
+                       beforeTextInit = new StringBuffer(buf.toString());
+                       // text.setText(buf.toString());
+                       ws.getObservationManager().addEventListener(listener,
+                                       Event.NODE_ADDED, logBasePath, true, null, null, false);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot register listener", e);
+               }
+       }
+
+       @Override
+       public synchronized void createPartControl(Composite parent) {
+               // bypass createFormContent
+               FormToolkit tk = getEditor().getToolkit();
+               // parent.setLayout(new FillLayout());
+               text = tk.createText(parent, "", SWT.MULTI | SWT.H_SCROLL
+                               | SWT.V_SCROLL);
+               text.setEditable(false);
+
+               // transfer the existing buffer the first time
+               if (beforeTextInit.length() > 0) {
+                       text.append(beforeTextInit.toString());
+                       // clear buffer
+                       beforeTextInit.setLength(0);
+               }
+
+       }
+
+       // @Override
+       // protected synchronized void createFormContent(IManagedForm mf) {
+       // ScrolledForm form = mf.getForm();
+       // form.setExpandHorizontal(true);
+       // form.setExpandVertical(true);
+       // // form.setText("Log");
+       // FillLayout mainLayout = new FillLayout();
+       // form.getBody().setLayout(mainLayout);
+       //
+       // FormToolkit tk = getManagedForm().getToolkit();
+       // text = tk.createText(form.getBody(), "", SWT.MULTI | SWT.H_SCROLL
+       // | SWT.V_SCROLL);
+       // text.setEditable(false);
+       // // transfer the existing buffer the first time
+       // if (beforeTextInit.length() > 0) {
+       // text.append(beforeTextInit.toString());
+       // // clear buffer
+       // beforeTextInit.setLength(0);
+       // }
+       // }
+
+       protected void appendLogEntry(StringBuffer buf, Node logEntry)
+                       throws RepositoryException {
+               // +1 in order to remove the first slash
+//             String relPath = logEntry.getPath().substring(logPathLength + 1);
+               //System.out.println("relPath=" + relPath);
+//             int firstSlashIndex = relPath.indexOf('/');
+//             int lastSlashIndex = relPath.lastIndexOf('/');
+//             String thread = relPath.substring(0, firstSlashIndex);
+//             String location = relPath.substring(firstSlashIndex, lastSlashIndex);
+
+               // String date = dateFormat.format(logEntry
+               // .getProperty(SlcNames.SLC_TIMESTAMP).getDate().getTime());
+               String date = logEntry.getProperty(SlcNames.SLC_TIMESTAMP).getString();
+               buf.append(date).append(' ');
+               String type = logEntry.getPrimaryNodeType().getName().substring(7);
+               buf.append(type).append('\t');
+               // buf.append(thread).append('\t');
+               // buf.append(location).append('\t');
+               buf.append(logEntry.getProperty(SlcNames.SLC_MESSAGE).getString());
+               buf.append('\n');
+
+       }
+
+       /** @deprecated */
+       public synchronized void addSteps(List<ExecutionStep> steps) {
+               final StringBuffer buf = new StringBuffer("");
+               for (ExecutionStep step : steps) {
+                       buf.append(dateFormat.format(step.getTimestamp()));
+                       buf.append(' ');
+                       if (step.getType().equals(ExecutionStep.PHASE_START)) {
+                               buf.append("## START ").append(step.getLog());
+                               buf.append('\n');
+                       } else if (step.getType().equals(ExecutionStep.PHASE_END)) {
+                               buf.append("## END   ").append(step.getLog());
+                               buf.append("\n");
+                       } else {
+                               buf.append(step.getLog());
+                       }
+               }
+
+               if (text != null) {
+                       Display.getDefault().asyncExec(new Runnable() {
+                               public void run() {
+                                       text.append(buf.toString());
+                               }
+                       });
+               } else
+                       beforeTextInit.append(buf);
+       }
+
+       @Override
+       public Control getPartControl() {
+               return text;
+       }
+
+       @Override
+       public void setFocus() {
+               if (text != null)
+                       text.setFocus();
+       }
+
+       /** JCR event listener notifying when new nodes are added */
+       private class LogListener extends AsyncUiEventListener {
+
+               public LogListener(Display display) {
+                       super(display);
+               }
+
+               @Override
+               protected void onEventInUiThread(List<Event> events)
+                               throws RepositoryException {
+                       // since we use batch save, order is not guaranteed
+                       // so we need to reorder, according to log line number for the time
+                       // being
+                       SortedMap<Long, Node> nodes = new TreeMap<Long, Node>();
+
+                       for (Event evt : events) {
+                               Node newNode = ProcessLogPage.this.processNode.getSession()
+                                               .getNode(evt.getPath());
+                               if (newNode.isNodeType(SlcTypes.SLC_LOG_ENTRY)) {
+                                       nodes.put(Long.parseLong(newNode.getName()), newNode);
+                               }
+                       }
+
+                       StringBuffer buf = new StringBuffer("");
+                       for (Node logEntry : nodes.values()) {
+                               appendLogEntry(buf, logEntry);
+                       }
+
+                       if (text != null)
+                               text.append(buf.toString());
+                       else
+                               beforeTextInit.append(buf);
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ParentNodeFolder.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ParentNodeFolder.java
new file mode 100644 (file)
index 0000000..c6ffcd8
--- /dev/null
@@ -0,0 +1,97 @@
+package org.argeo.slc.client.ui.model;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+
+/**
+ * UI Tree component that wrap a node of type NT_UNSTRUCTURED or base node for
+ * UI specific, user defined tree structure of type SLC_MY_RESULTS_ROOT_FOLDER.
+ * 
+ * It is used for
+ * <ul>
+ * <li>automatically generated tree structure to store results (typically
+ * Year/Month/Day...)</li>
+ * <li>parent node for user defined tree structure (typically My Results node)</li>
+ * </ul>
+ * It thus lists either result folders, other folders and/or a list of results
+ * and keeps a reference to its parent.
+ */
+public class ParentNodeFolder extends ResultParent {
+       // private final static Log log = LogFactory.getLog(ParentNodeFolder.class);
+
+       private Node node = null;
+
+       /**
+        * 
+        * @param parent
+        * @param node
+        *            throws an exception if null
+        * @param name
+        */
+       public ParentNodeFolder(ParentNodeFolder parent, Node node, String name) {
+               super(name);
+               if (node == null)
+                       throw new SlcException("Node Object cannot be null");
+               setParent(parent);
+               this.node = node;
+       }
+
+       @Override
+       protected void initialize() {
+               try {
+                       NodeIterator ni = node.getNodes();
+                       while (ni.hasNext()) {
+                               Node currNode = ni.nextNode();
+                               if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
+                                       SingleResultNode srn = new SingleResultNode(this, currNode,
+                                                       currNode.getProperty(SlcNames.SLC_TEST_CASE)
+                                                                       .getString());
+                                       addChild(srn);
+                               } else if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
+                                       // FIXME change label
+                                       ResultFolder rf = new ResultFolder(this, currNode,
+                                                       currNode.getName());
+                                       addChild(rf);
+                               } else if (currNode.isNodeType(SlcTypes.SLC_CHECK)) {
+                                       // FIXME : manually skip node types that are not to be
+                                       // displayed
+                                       // Do nothing
+                               } else if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
+                                       addChild(new ParentNodeFolder(this, currNode,
+                                                       currNode.getName()));
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while initializing ParentNodeFolder : "
+                                                       + getName(), re);
+               }
+       }
+
+       public Node getNode() {
+               return node;
+       }
+
+       // /**
+       // * Overriden in the specific case of "My result" root object to return an
+       // * ordered list of children
+       // */
+       // public synchronized Object[] getChildren() {
+       // Object[] children = super.getChildren();
+       // try {
+       // if (node.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
+       // return ResultParentUtils.orderChildren(children);
+       // else
+       // return children;
+       // } catch (RepositoryException re) {
+       // throw new SlcException(
+       // "Unexpected error while initializing simple node folder : "
+       // + getName(), re);
+       // }
+       // }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultFolder.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultFolder.java
new file mode 100644 (file)
index 0000000..25d0259
--- /dev/null
@@ -0,0 +1,47 @@
+package org.argeo.slc.client.ui.model;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+
+/**
+ * UI Tree component that wrap a node of type ResultFolder. list either other
+ * folders and/or a list of results. keeps a reference to its parent.
+ */
+public class ResultFolder extends ParentNodeFolder {
+
+       /**
+        * 
+        * @param parent
+        * @param node
+        *            throws an exception if null
+        * @param name
+        */
+       public ResultFolder(ParentNodeFolder parent, Node node, String name) {
+               super(parent, node, name);
+               try {
+                       // initialize passed status if possible
+                       if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
+                               setPassed(node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
+                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean());
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while initializing result folder : "
+                                                       + getName(), re);
+               }
+       }
+
+       // /**
+       // * Overriden to return an ordered list of children
+       // */
+       // public synchronized Object[] getChildren() {
+       // Object[] children = super.getChildren();
+       // return ResultParentUtils.orderChildren(children);
+       // }
+       //
+       // public int compareTo(ResultFolder o) {
+       // return super.compareTo(o);
+       // }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparator.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparator.java
new file mode 100644 (file)
index 0000000..74ec9ec
--- /dev/null
@@ -0,0 +1,95 @@
+package org.argeo.slc.client.ui.model;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+import org.argeo.eclipse.ui.TreeParent;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+/** Enable specific sorting of the ResultTreeView */
+public class ResultItemsComparator extends ViewerComparator {
+
+       @Override
+       public int category(Object element) {
+               if (element instanceof SingleResultNode) {
+                       return 10;
+
+               }
+               // folder always first
+               return 5;
+       }
+
+       @Override
+       public int compare(Viewer viewer, Object e1, Object e2) {
+               int cat1 = category(e1);
+               int cat2 = category(e2);
+
+               if (cat1 != cat2) {
+                       return cat1 - cat2;
+               }
+
+               int result = 0;
+
+               if (e1 instanceof TreeParent && ((TreeParent) e1).getParent() == null) {
+                       // preserve predefined order on UI root items
+                       return 0;
+               }
+
+               if (e1 instanceof SingleResultNode && e2 instanceof SingleResultNode) {
+                       Node an = ((SingleResultNode) e1).getNode();
+                       Node bn = ((SingleResultNode) e2).getNode();
+                       try {
+                               // Order is different if we are under my Result or )in the
+                               // rest of the tree structure
+                               if (an.getParent().isNodeType(
+                                               SlcTypes.SLC_MY_RESULT_ROOT_FOLDER)
+                                               || an.getParent()
+                                                               .isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
+                                       result = super.compare(viewer, e1, e2);
+                                       // Specific case of two result with same name
+                                       if (result == 0) {
+                                               result = an
+                                                               .getProperty(SlcNames.SLC_COMPLETED)
+                                                               .getDate()
+                                                               .compareTo(
+                                                                               bn.getProperty(SlcNames.SLC_COMPLETED)
+                                                                                               .getDate());
+                                       }
+                               } else {
+                                       result = an
+                                                       .getProperty(Property.JCR_CREATED)
+                                                       .getDate()
+                                                       .compareTo(
+                                                                       bn.getProperty(Property.JCR_CREATED)
+                                                                                       .getDate());
+                                       result = result * -1; // last are displayed first
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Unable to compare date created", e);
+                       }
+               } else if (e1 instanceof ParentNodeFolder
+                               && e2 instanceof ParentNodeFolder) {
+                       try {
+                               Node an = ((ParentNodeFolder) e1).getNode();
+                               // under my Result
+                               if (an.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER)
+                                               || an.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
+                                       result = super.compare(viewer, e1, e2);
+                               } else {
+                                       // only remaining objects for the time being
+                                       // NT_UNSTRUCTURED that display all result tree structures
+                                       // We want the newest folders first
+                                       result = super.compare(viewer, e1, e2) * -1;
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Unable to compare date created", e);
+                       }
+               }
+               return result;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparer.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultItemsComparer.java
new file mode 100644 (file)
index 0000000..14b9b06
--- /dev/null
@@ -0,0 +1,46 @@
+package org.argeo.slc.client.ui.model;
+
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.SlcException;
+import org.eclipse.jface.viewers.IElementComparer;
+
+/**
+ * Override default behaviour to insure that 2 distincts results that have the
+ * same name will be correctly and distincly returned by corresponding
+ * TreeViewer.getSelection() method.
+ * 
+ */
+public class ResultItemsComparer implements IElementComparer {
+       // private final static Log log =
+       // LogFactory.getLog(ResultItemsComparer.class);
+
+       public boolean equals(Object a, Object b) {
+               if (b == null)
+                       return a == null ? true : false;
+
+               if (a.hashCode() != b.hashCode() || !a.getClass().equals(b.getClass()))
+                       return false;
+               else if (a instanceof SingleResultNode) {
+                       try {
+                               String ida = ((SingleResultNode) a).getNode().getIdentifier();
+
+                               String idb = ((SingleResultNode) b).getNode().getIdentifier();
+
+                               if (ida.equals(idb))
+                                       return true;
+                               else
+                                       return false;
+
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot compare single reult nodes", e);
+                       }
+               } else
+                       return true;
+       }
+
+       public int hashCode(Object element) {
+               return element.hashCode();
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParent.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParent.java
new file mode 100644 (file)
index 0000000..8ea91f2
--- /dev/null
@@ -0,0 +1,42 @@
+package org.argeo.slc.client.ui.model;
+
+import org.argeo.eclipse.ui.TreeParent;
+
+/**
+ * Common base UI object to build result Tree.
+ */
+
+public abstract class ResultParent extends TreeParent {
+
+       public ResultParent(String name) {
+               super(name);
+       }
+
+       private boolean isPassed = true;
+
+       protected synchronized void setPassed(boolean isPassed) {
+               this.isPassed = isPassed;
+       }
+
+       public boolean isPassed() {
+               return isPassed;
+       }
+
+       @Override
+       public synchronized boolean hasChildren() {
+               // only initialize when needed : correctly called by the jface framework
+               if (!isLoaded())
+                       initialize();
+               return super.hasChildren();
+       }
+
+       public void forceFullRefresh() {
+               // if (isDisposed)
+               // return;
+               if (hasChildren())
+                       clearChildren();
+               initialize();
+       }
+
+       protected abstract void initialize();
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParentUtils.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/ResultParentUtils.java
new file mode 100644 (file)
index 0000000..98fd194
--- /dev/null
@@ -0,0 +1,154 @@
+package org.argeo.slc.client.ui.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.jcr.SlcJcrResultUtils;
+
+public class ResultParentUtils {
+       // private final static Log log =
+       // LogFactory.getLog(ResultParentUtils.class);
+
+       // public static Object[] orderChildren(Object[] children) {
+       // List<ResultFolder> folders = new ArrayList<ResultFolder>();
+       // List<SingleResultNode> results = new ArrayList<SingleResultNode>();
+       // for (Object child : children) {
+       // if (child instanceof ResultFolder)
+       // folders.add((ResultFolder) child);
+       // else if (child instanceof SingleResultNode)
+       // results.add((SingleResultNode) child);
+       // }
+       //
+       // // Comparator first = Collections.reverseOrder();
+       // Collections.sort(folders);
+       // // Comparator<SingleResultNode> second = Collections.reverseOrder();
+       // Collections.sort(results);
+       //
+       // Object[] orderedChildren = new Object[folders.size() + results.size()];
+       // int i = 0;
+       // Iterator<ResultFolder> it = folders.iterator();
+       // while (it.hasNext()) {
+       // orderedChildren[i] = it.next();
+       // i++;
+       // }
+       // Iterator<SingleResultNode> it2 = results.iterator();
+       // while (it2.hasNext()) {
+       // orderedChildren[i] = it2.next();
+       // i++;
+       // }
+       // return orderedChildren;
+       // }
+
+       public static List<Node> getResultsForDates(Session session,
+                       List<String> dateRelPathes) {
+               if (dateRelPathes == null || dateRelPathes.size() == 0)
+                       throw new SlcException("Specify at least one correct date as Path");
+
+               try {
+                       String basePath = SlcJcrResultUtils.getSlcResultsBasePath(session);
+                       Iterator<String> it = dateRelPathes.iterator();
+                       StringBuffer clause = new StringBuffer();
+                       clause.append("SELECT * FROM [");
+                       clause.append(SlcTypes.SLC_TEST_RESULT);
+                       clause.append("] as results");
+                       clause.append(" WHERE ");
+                       while (it.hasNext()) {
+                               String absPath = basePath + "/" + it.next();
+                               clause.append("ISDESCENDANTNODE(results, [");
+                               clause.append(absPath);
+                               clause.append("]) ");
+                               clause.append(" OR ");
+                       }
+                       // remove last " OR "
+                       clause.delete(clause.length() - 4, clause.length());
+                       clause.append(" ORDER BY results.[" + Property.JCR_CREATED
+                                       + "] DESC");
+
+                       // log.debug("request : " + clause.toString());
+                       QueryManager qm = session.getWorkspace().getQueryManager();
+                       Query q = qm.createQuery(clause.toString(), Query.JCR_SQL2);
+                       QueryResult result = q.execute();
+
+                       NodeIterator ni = result.getNodes();
+                       List<Node> nodes = new ArrayList<Node>();
+                       while (ni.hasNext()) {
+                               nodes.add(ni.nextNode());
+                       }
+                       return nodes;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while getting Results for given date", re);
+               }
+       }
+
+       /**
+        * recursively update passed status of the current ResultFolder and its
+        * parent if needed
+        * 
+        * @param node
+        *            cannot be null
+        * 
+        */
+       public static void updatePassedStatus(Node node, boolean passed) {
+               try {
+                       if (!node.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
+                               // we have reached the root of the tree. stop the
+                               // recursivity
+                               return;
+                       boolean pStatus = node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
+                                       .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
+                       if (pStatus == passed)
+                               // nothing to update
+                               return;
+                       else if (!passed) {
+                               // New status is 'failed' : we only update status of the result
+                               // folder and its
+                               // parent if needed
+                               node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
+                                               SlcNames.SLC_SUCCESS, passed);
+                               updatePassedStatus(node.getParent(), passed);
+                       } else {
+                               // New status is 'passed': we must first check if all siblings
+                               // have also
+                               // successfully completed
+                               boolean success = true;
+                               NodeIterator ni = node.getNodes();
+                               children: while (ni.hasNext()) {
+                                       Node currNode = ni.nextNode();
+                                       if ((currNode.isNodeType(SlcTypes.SLC_DIFF_RESULT) || currNode
+                                                       .isNodeType(SlcTypes.SLC_RESULT_FOLDER))
+                                                       && !currNode
+                                                                       .getNode(SlcNames.SLC_AGGREGATED_STATUS)
+                                                                       .getProperty(SlcNames.SLC_SUCCESS)
+                                                                       .getBoolean()) {
+                                               success = false;
+                                               break children;
+                                       }
+                               }
+                               if (success) {
+                                       node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
+                                                       SlcNames.SLC_SUCCESS, passed);
+                                       updatePassedStatus(node.getParent(), passed);
+                               } else
+                                       // one of the siblings had also the failed status so
+                                       // above tree remains unchanged.
+                                       return;
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot update result passed status", e);
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/SingleResultNode.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/SingleResultNode.java
new file mode 100644 (file)
index 0000000..ff14fcf
--- /dev/null
@@ -0,0 +1,83 @@
+package org.argeo.slc.client.ui.model;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Workspace;
+
+import org.argeo.eclipse.ui.TreeParent;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+
+/**
+ * UI Tree component. Wraps a result node of a JCR {@link Workspace}. It also
+ * keeps a reference to its parent node that can either be a
+ * {@link ResultFolder}, a {@link SingleResultNode} or a {@link VirtualFolder}.
+ * It has no child.
+ */
+
+public class SingleResultNode extends ResultParent implements
+               Comparable<SingleResultNode> {
+
+       private final Node node;
+       private boolean passed;
+
+       // keeps a local reference to the node's name to avoid exception when the
+       // session is lost
+
+       /** Creates a new UiNode in the UI Tree */
+       public SingleResultNode(TreeParent parent, Node node, String name) {
+               super(name);
+               setParent(parent);
+               this.node = node;
+               setPassed(refreshPassedStatus());
+       }
+
+       public boolean refreshPassedStatus() {
+               try {
+                       Node check;
+                       if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS)) {
+                               check = node.getNode(SlcNames.SLC_AGGREGATED_STATUS);
+                               passed = check.getProperty(SlcNames.SLC_SUCCESS).getBoolean();
+                               return passed;
+                       } else
+                               // Happens only if the UI triggers a refresh while the execution
+                               // is in progress and the corresponding node is being built
+                               return false;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while checking result status", re);
+               }
+       }
+
+       /** returns the node wrapped by the current UI object */
+       public Node getNode() {
+               return node;
+       }
+
+       /**
+        * Override normal behavior : Results have no children for this view
+        */
+       @Override
+       public synchronized Object[] getChildren() {
+               return null;
+       }
+
+       @Override
+       public boolean hasChildren() {
+               return false;
+       }
+
+       public boolean isPassed() {
+               return passed;
+       }
+
+       @Override
+       protected void initialize() {
+               // Do nothing this object is fully initialized at instantiation time.
+       }
+
+       public int compareTo(SingleResultNode o) {
+               return super.compareTo(o);
+       }
+
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/VirtualFolder.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/model/VirtualFolder.java
new file mode 100644 (file)
index 0000000..558fe0d
--- /dev/null
@@ -0,0 +1,44 @@
+package org.argeo.slc.client.ui.model;
+
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+
+/**
+ * UI Tree component. Virtual folder to list a list of results. Keeps a
+ * reference to its parent that might be null. It also keeps a reference to all
+ * nodes that must be displayed as children of the current virtual folder.
+ */
+public class VirtualFolder extends ResultParent {
+       List<Node> displayedNodes;
+
+       public VirtualFolder(VirtualFolder parent, List<Node> displayedNodes,
+                       String name) {
+               super(name);
+               setParent(parent);
+               this.displayedNodes = displayedNodes;
+       }
+
+       @Override
+       protected void initialize() {
+               try {
+                       for (Node currNode : displayedNodes) {
+                               if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
+                                       SingleResultNode srn = new SingleResultNode(this, currNode,
+                                                       currNode.getProperty(SlcNames.SLC_TEST_CASE)
+                                                                       .getString());
+                                       addChild(srn);
+                               }
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while initializing ParentNodeFolder : "
+                                                       + getName(), re);
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeContentProvider.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeContentProvider.java
new file mode 100644 (file)
index 0000000..c2594ec
--- /dev/null
@@ -0,0 +1,40 @@
+package org.argeo.slc.client.ui.providers;
+
+import org.argeo.eclipse.ui.TreeParent;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/** Basic content provider for a tree of result */
+public class ResultTreeContentProvider implements ITreeContentProvider {
+
+       /**
+        * @param parent
+        *            Pass current user home as parameter
+        * 
+        */
+       public Object[] getElements(Object parent) {
+               if (parent instanceof Object[])
+                       return (Object[]) parent;
+               else
+                       return null;
+       }
+
+       public Object getParent(Object child) {
+               return ((TreeParent) child).getParent();
+       }
+
+       public Object[] getChildren(Object parent) {
+               return ((TreeParent) parent).getChildren();
+       }
+
+       public boolean hasChildren(Object parent) {
+               return ((TreeParent) parent).hasChildren();
+       }
+
+       public void dispose() {
+               // FIXME implement if needed
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java
new file mode 100644 (file)
index 0000000..3c418d6
--- /dev/null
@@ -0,0 +1,61 @@
+package org.argeo.slc.client.ui.providers;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.eclipse.ui.TreeParent;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.SlcImages;
+import org.argeo.slc.client.ui.SlcUiConstants;
+import org.argeo.slc.client.ui.model.ParentNodeFolder;
+import org.argeo.slc.client.ui.model.ResultParent;
+import org.argeo.slc.client.ui.model.SingleResultNode;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/** Basic label provider for a tree of result */
+public class ResultTreeLabelProvider extends LabelProvider {
+       // private final static Log log = LogFactory
+       // .getLog(ResultTreeLabelProvider.class);
+
+       @Override
+       public String getText(Object element) {
+               try {
+
+                       if (element instanceof SingleResultNode) {
+                               Node node = ((SingleResultNode) element).getNode();
+                               if (node.isNodeType(NodeType.MIX_TITLE))
+                                       return node.getProperty(Property.JCR_TITLE).getString();
+
+                       } else if (element instanceof ParentNodeFolder) {
+                               Node node = ((ParentNodeFolder) element).getNode();
+                               if (node.hasProperty(Property.JCR_TITLE))
+                                       return node.getProperty(Property.JCR_TITLE).getString();
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unexpected error while getting "
+                                       + "custom result label", e);
+               }
+               return ((TreeParent) element).getName();
+       }
+
+       public Image getImage(Object obj) {
+               if (obj instanceof SingleResultNode) {
+                       // FIXME add realtime modification of process icon (SCHEDULED,
+                       // RUNNING, COMPLETED...)
+                       // Node resultNode = ((SingleResultNode) obj).getNode();
+                       // int status = SlcJcrUtils.aggregateTestStatus(resultNode);
+                       return SlcImages.PROCESS_COMPLETED;
+               } else if (obj instanceof ResultParent) {
+                       ResultParent rParent = (ResultParent) obj;
+                       if (SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL.equals(rParent
+                                       .getName()))
+                               return SlcImages.MY_RESULTS_FOLDER;
+                       else
+                               return SlcImages.FOLDER;
+               } else
+                       return null;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java
new file mode 100644 (file)
index 0000000..6ddc197
--- /dev/null
@@ -0,0 +1,417 @@
+package org.argeo.slc.client.ui.views;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.observation.Event;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
+import org.argeo.eclipse.ui.jcr.DefaultNodeLabelProvider;
+import org.argeo.eclipse.ui.jcr.NodeElementComparer;
+import org.argeo.eclipse.ui.jcr.SimpleNodeContentProvider;
+import org.argeo.eclipse.ui.specific.EclipseUiSpecificUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.SlcImages;
+import org.argeo.slc.client.ui.editors.ProcessEditor;
+import org.argeo.slc.client.ui.editors.ProcessEditorInput;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.jcr.SlcJcrConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.rap.rwt.service.ServerPushSession;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+/** JCR based view of the execution modules. */
+public class JcrExecutionModulesView extends ViewPart implements SlcTypes, SlcNames {
+       private final static Log log = LogFactory.getLog(JcrExecutionModulesView.class);
+
+       public static final String ID = ClientUiPlugin.ID + ".jcrExecutionModulesView";
+
+       private TreeViewer viewer;
+
+       private ServerPushSession pushSession;
+
+       /* DEPENDENCY INJECTION */
+       private Repository repository;
+       private Session session;
+       private ExecutionModulesManager modulesManager;
+
+       public void createPartControl(Composite parent) {
+               pushSession = new ServerPushSession();
+               pushSession.start();
+
+               try {
+                       session = repository.login();
+               } catch (RepositoryException e1) {
+                       throw new SlcException("Cannot log in to repository");
+               }
+
+               viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+               EclipseUiSpecificUtils.enableToolTipSupport(viewer);
+               ViewContentProvider contentProvider = new ViewContentProvider(session);
+               viewer.setContentProvider(contentProvider);
+               viewer.setComparer(new NodeElementComparer());
+               final ViewLabelProvider viewLabelProvider = new ViewLabelProvider();
+               viewer.setLabelProvider(viewLabelProvider);
+               viewer.setInput(getViewSite());
+               viewer.addDoubleClickListener(new ViewDoubleClickListener());
+               // context menu
+               // addContextMenu(viewer);
+
+               getViewSite().setSelectionProvider(viewer);
+
+               Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
+               // Transfer[] tt = new Transfer[] { EditorInputTransfer.getInstance() };
+               int operations = DND.DROP_COPY | DND.DROP_MOVE;
+               viewer.addDragSupport(operations, tt, new ViewDragListener());
+
+               try {
+                       String[] nodeTypes = { SlcTypes.SLC_AGENT, SlcTypes.SLC_AGENT_FACTORY, SlcTypes.SLC_EXECUTION_MODULE };
+                       session.getWorkspace().getObservationManager().addEventListener(
+                                       new VmAgentObserver(viewer.getTree().getDisplay()),
+                                       Event.NODE_ADDED | Event.NODE_REMOVED | Event.NODE_MOVED, SlcJcrConstants.VM_AGENT_FACTORY_PATH,
+                                       true, null, nodeTypes, false);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot add observer", e);
+               }
+       }
+
+       public void setFocus() {
+               viewer.getControl().setFocus();
+       }
+
+       public TreeViewer getViewer() {
+               return viewer;
+       }
+
+       public void refreshView() {
+               viewer.setInput(getViewSite());
+       }
+
+       // Controllers
+       class ViewContentProvider extends SimpleNodeContentProvider {
+               private static final long serialVersionUID = 5117887833174813672L;
+
+               public ViewContentProvider(Session session) {
+                       super(session, new String[] { SlcJcrConstants.VM_AGENT_FACTORY_PATH });
+               }
+
+               @Override
+               protected Object[] sort(Object parent, Object[] children) {
+                       Object[] sorted = new Object[children.length];
+                       System.arraycopy(children, 0, sorted, 0, children.length);
+                       Arrays.sort(sorted, new ViewComparator());
+                       return sorted;
+               }
+
+               @Override
+               protected List<Node> filterChildren(List<Node> children) throws RepositoryException {
+                       for (Iterator<Node> it = children.iterator(); it.hasNext();) {
+                               Node node = it.next();
+                               // execution spec definitions
+                               if (node.getName().equals(SLC_EXECUTION_SPECS))
+                                       it.remove();
+                               // flow values
+                               else if (node.getParent().isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
+                                       it.remove();
+                       }
+                       return super.filterChildren(children);
+               }
+
+               @Override
+               public boolean hasChildren(Object element) {
+                       if (element instanceof Node) {
+                               Node node = (Node) element;
+                               try {
+                                       if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
+                                               return false;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot check has children", e);
+                               }
+                       }
+                       return super.hasChildren(element);
+               }
+       }
+
+       static class ViewComparator implements Comparator<Object> {
+
+               public int compare(Object o1, Object o2) {
+                       try {
+                               if (o1 instanceof Node && o2 instanceof Node) {
+                                       Node node1 = (Node) o1;
+                                       Node node2 = (Node) o2;
+
+                                       if (node1.getName().equals(SLC_EXECUTION_SPECS))
+                                               return -100;
+                                       if (node2.getName().equals(SLC_EXECUTION_SPECS))
+                                               return 100;
+
+                                       if (node1.isNodeType(SLC_EXECUTION_FLOW) && node2.isNodeType(SLC_EXECUTION_FLOW)) {
+                                               return node1.getName().compareTo(node2.getName());
+                                       } else if (node1.isNodeType(SLC_EXECUTION_FLOW) && !node2.isNodeType(SLC_EXECUTION_FLOW)) {
+                                               return 1;
+                                       } else if (!node1.isNodeType(SLC_EXECUTION_FLOW) && node2.isNodeType(SLC_EXECUTION_FLOW)) {
+                                               return -1;
+                                       } else {
+                                               // TODO: check title
+                                               return node1.getName().compareTo(node2.getName());
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot compare " + o1 + " and " + o2, e);
+                       }
+                       return 0;
+               }
+
+       }
+
+       // private void addContextMenu(TreeViewer flowsViewer) {
+       //
+       // final MenuManager menuMgr = new MenuManager();
+       // menuMgr.setRemoveAllWhenShown(true);
+       // menuMgr.addMenuListener(new IMenuListener() {
+       //
+       // public void menuAboutToShow(IMenuManager manager) {
+       // menuMgr.add(new Action("Test") {
+       // public void run() {
+       // log.debug("do something");
+       // }
+       // });
+       // }
+       // });
+       // Menu menu = menuMgr.createContextMenu(flowsViewer.getControl());
+       // flowsViewer.getTree().setMenu(menu);
+       // getSite().registerContextMenu(menuMgr, flowsViewer);
+       // }
+
+       class VmAgentObserver extends AsyncUiEventListener {
+
+               public VmAgentObserver(Display display) {
+                       super(display);
+               }
+
+               protected void onEventInUiThread(List<Event> events) {
+                       for (Event event : events) {
+                               try {
+                                       String path = event.getPath();
+
+                                       if (session.itemExists(path)) {
+                                               Node parentNode = session.getNode(path);// .getParent();
+                                               if (log.isTraceEnabled())
+                                                       log.trace("Refresh " + parentNode + " after event " + event);
+                                               viewer.refresh(parentNode);
+                                       }
+                               } catch (RepositoryException e) {
+                                       log.warn("Cannot process event " + event + ": " + e);
+                               }
+                       }
+
+                       // TODO: optimize based on event
+                       viewer.refresh();
+               }
+       }
+
+       class ViewLabelProvider extends DefaultNodeLabelProvider implements ITableLabelProvider {
+               private static final long serialVersionUID = 2410754425574656399L;
+
+               @Override
+               protected String getText(Node node) throws RepositoryException {
+                       if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_TITLE))
+                               return node.getProperty(Property.JCR_TITLE).getString();
+                       else if (node.getName().equals(SLC_EXECUTION_SPECS))
+                               return "Execution Specifications";
+                       else if (node.getPath().equals(SlcJcrConstants.VM_AGENT_FACTORY_PATH))
+                               return "Internal Agents";
+                       return super.getText(node);
+               }
+
+               @Override
+               public Image getImage(Node node) throws RepositoryException {
+                       // we try to optimize a bit by putting deeper nodes first
+                       if (node.getParent().isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
+                               return SlcImages.CHOICES;
+                       else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
+                               return SlcImages.EXECUTION_SPEC_ATTRIBUTE;
+                       else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC))
+                               return SlcImages.EXECUTION_SPEC;
+                       else if (node.getName().equals(SLC_EXECUTION_SPECS))
+                               return SlcImages.EXECUTION_SPECS;
+                       else if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
+                               return SlcImages.FLOW;
+                       else if (node.isNodeType(SlcTypes.SLC_MODULE)) {
+                               if (node.getProperty(SLC_STARTED).getBoolean())
+                                       return SlcImages.MODULE;
+                               else
+                                       return SlcImages.MODULE_STOPPED;
+                       } else if (node.isNodeType(SlcTypes.SLC_AGENT))
+                               return SlcImages.AGENT;
+                       else if (node.isNodeType(SlcTypes.SLC_AGENT_FACTORY))
+                               return SlcImages.AGENT_FACTORY;
+                       else
+                               return SlcImages.FOLDER;
+               }
+
+               public String getToolTipText(Node node) throws RepositoryException {
+                       if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_DESCRIPTION))
+                               return node.getProperty(Property.JCR_DESCRIPTION).getString();
+                       return super.getToolTipText(node);
+               }
+
+               public String getColumnText(Object obj, int index) {
+                       return getText(obj);
+               }
+
+               public Image getColumnImage(Object obj, int index) {
+                       return getImage(obj);
+               }
+
+       }
+
+       class ViewDoubleClickListener implements IDoubleClickListener {
+               public void doubleClick(DoubleClickEvent evt) {
+                       Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement();
+                       try {
+                               if (obj instanceof Node) {
+                                       Node node = (Node) obj;
+                                       if (node.isNodeType(SLC_EXECUTION_MODULE)) {
+                                               ClientUiPlugin.startStopExecutionModule(modulesManager, node);
+                                       } else {
+                                               String path = node.getPath();
+                                               // TODO factorize with editor
+                                               QueryManager qm = node.getSession().getWorkspace().getQueryManager();
+                                               String statement = "SELECT * FROM [" + SlcTypes.SLC_EXECUTION_FLOW
+                                                               + "] WHERE ISDESCENDANTNODE(['" + path + "']) OR ISSAMENODE(['" + path + "'])";
+                                               // log.debug(statement);
+                                               Query query = qm.createQuery(statement, Query.JCR_SQL2);
+
+                                               // order paths
+                                               SortedSet<String> paths = new TreeSet<String>();
+                                               for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
+                                                       paths.add(nit.nextNode().getPath());
+                                               }
+
+                                               IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                                                               .getActivePage();
+                                               activePage.openEditor(new ProcessEditorInput(new ArrayList<String>(paths), true),
+                                                               ProcessEditor.ID);
+                                       }
+                               }
+                       } catch (Exception e) {
+                               throw new SlcException("Cannot open " + obj, e);
+                       }
+               }
+
+       }
+
+       /** Listen to drags */
+       class ViewDragListener extends DragSourceAdapter {
+               private static final long serialVersionUID = 250270504802674171L;
+
+               // Check if the drag action should start.
+               public void dragStart(DragSourceEvent event) {
+                       // we only start drag if at least one of the selected elements is
+                       // valid
+                       boolean doIt = false;
+                       IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+                       @SuppressWarnings("rawtypes")
+                       Iterator it = selection.iterator();
+                       try {
+                               while (it.hasNext()) {
+                                       Object obj = it.next();
+                                       if (obj instanceof Node) {
+                                               Node node = (Node) obj;
+                                               if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW)
+                                                               || node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) {
+                                                       doIt = true;
+                                               }
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot read node to set drag data", e);
+                       }
+                       event.doit = doIt;
+               }
+
+               public void dragSetData(DragSourceEvent event) {
+                       IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+                       StringBuilder buf = new StringBuilder();
+                       @SuppressWarnings("rawtypes")
+                       Iterator it = selection.iterator();
+                       try {
+
+                               while (it.hasNext()) {
+                                       Object obj = it.next();
+
+                                       if (obj instanceof Node) {
+                                               Node node = (Node) obj;
+                                               if ((node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW)
+                                                               || node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE))
+                                                               && TextTransfer.getInstance().isSupportedType(event.dataType)) {
+                                                       buf.append(node.getPath()).append('\n');
+                                               }
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot read node to set drag data", e);
+                       }
+
+                       if (buf.length() > 0) {
+                               if (buf.charAt(buf.length() - 1) == '\n')
+                                       buf.deleteCharAt(buf.length() - 1);
+                               event.data = buf.toString();
+                               log.debug("data set to : " + buf.toString());
+                       }
+               }
+       }
+
+       public void dispose() {
+               JcrUtils.logoutQuietly(session);
+               if (pushSession != null)
+                       pushSession.stop();
+               super.dispose();
+       }
+
+       // DEPENDENCY INJECTION
+
+       public void setModulesManager(ExecutionModulesManager modulesManager) {
+               this.modulesManager = modulesManager;
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java
new file mode 100644 (file)
index 0000000..7a92144
--- /dev/null
@@ -0,0 +1,235 @@
+package org.argeo.slc.client.ui.views;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.Query;
+
+import org.argeo.api.NodeConstants;
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.SlcImages;
+import org.argeo.slc.client.ui.editors.ProcessEditor;
+import org.argeo.slc.client.ui.editors.ProcessEditorInput;
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.jcr.SlcJcrUtils;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.rap.rwt.service.ServerPushSession;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+/** Displays processes. */
+public class JcrProcessListView extends ViewPart {
+       public static final String ID = ClientUiPlugin.ID + ".jcrProcessListView";
+
+       private TableViewer viewer;
+       private ServerPushSession pushSession;
+
+       private Repository repository;
+       private Session session;
+
+       private EventListener processesObserver;
+
+       private DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
+       private Integer queryLimit = 2000;
+
+       public void createPartControl(Composite parent) {
+               pushSession = new ServerPushSession();
+               pushSession.start();
+               try {
+                       session = repository.login(NodeConstants.HOME_WORKSPACE);
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to log in Repository " + repository, re);
+               }
+               Table table = createTable(parent);
+               viewer = new TableViewer(table);
+               viewer.setLabelProvider(new LabelProvider());
+               viewer.setContentProvider(new ContentProvider());
+               viewer.setInput(getViewSite());
+               viewer.addDoubleClickListener(new ViewDoubleClickListener());
+
+               processesObserver = new AsyncUiEventListener(viewer.getTable().getDisplay()) {
+                       protected void onEventInUiThread(List<Event> events) {
+                               // TODO optimize by updating only the changed process
+                               viewer.refresh();
+                       }
+               };
+               try {
+                       ObservationManager observationManager = session.getWorkspace().getObservationManager();
+                       observationManager.addEventListener(processesObserver,
+                                       Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_CHANGED,
+                                       SlcJcrUtils.getSlcProcessesBasePath(session), true, null, null, false);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot register listeners", e);
+               }
+
+       }
+
+       protected Table createTable(Composite parent) {
+               int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
+               // does not function with RAP, commented for the time being
+               // | SWT.HIDE_SELECTION;
+
+               Table table = new Table(parent, style);
+
+               table.setLinesVisible(true);
+               table.setHeaderVisible(true);
+
+               TableColumn column = new TableColumn(table, SWT.LEFT, 0);
+               column.setText("Date");
+               column.setWidth(200);
+
+               column = new TableColumn(table, SWT.LEFT, 1);
+               column.setText("Host");
+               column.setWidth(100);
+
+               column = new TableColumn(table, SWT.LEFT, 2);
+               column.setText("Id");
+               column.setWidth(300);
+
+               column = new TableColumn(table, SWT.LEFT, 3);
+               column.setText("Status");
+               column.setWidth(100);
+
+               return table;
+       }
+
+       public void setFocus() {
+               viewer.getControl().setFocus();
+       }
+
+       class ContentProvider implements IStructuredContentProvider {
+
+               public Object[] getElements(Object inputElement) {
+                       try {
+                               // TODO filter, optimize with virtual table, ...
+                               String sql = "SELECT * from [slc:process] ORDER BY [jcr:lastModified] DESC";
+                               Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
+                               // TODO paging
+                               query.setLimit(queryLimit);
+                               List<Node> nodes = new ArrayList<Node>();
+                               for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
+                                       nodes.add(nit.nextNode());
+                               }
+                               return nodes.toArray();
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot retrieve processes", e);
+                       }
+               }
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+       }
+
+       class LabelProvider extends ColumnLabelProvider implements ITableLabelProvider {
+
+               public Image getColumnImage(Object obj, int columnIndex) {
+                       if (columnIndex != 0)
+                               return null;
+                       try {
+                               Node node = (Node) obj;
+                               String status = node.getProperty(SlcNames.SLC_STATUS).getString();
+                               if (status.equals(ExecutionProcess.NEW) || status.equals(ExecutionProcess.INITIALIZED)
+                                               || status.equals(ExecutionProcess.SCHEDULED))
+                                       return SlcImages.PROCESS_SCHEDULED;
+                               else if (status.equals(ExecutionProcess.ERROR) || status.equals(ExecutionProcess.UNKOWN))
+                                       return SlcImages.PROCESS_ERROR;
+                               else if (status.equals(ExecutionProcess.COMPLETED))
+                                       return SlcImages.PROCESS_COMPLETED;
+                               else if (status.equals(ExecutionProcess.RUNNING))
+                                       return SlcImages.PROCESS_RUNNING;
+                               else if (status.equals(ExecutionProcess.KILLED))
+                                       return SlcImages.PROCESS_ERROR;
+                               else
+                                       throw new SlcException("Unkown status " + status);
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get column text", e);
+                       }
+               }
+
+               public String getColumnText(Object obj, int index) {
+                       try {
+                               Node node = (Node) obj;
+                               switch (index) {
+
+                               case 0:
+                                       return dateFormat.format(node.getProperty(Property.JCR_LAST_MODIFIED).getDate().getTime());
+                               case 1:
+                                       return "local";
+                               case 2:
+                                       return node.getProperty(SlcNames.SLC_UUID).getString();
+                               case 3:
+                                       return node.getProperty(SlcNames.SLC_STATUS).getString();
+                               }
+                               return getText(obj);
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get column text", e);
+                       }
+               }
+
+       }
+
+       class ViewDoubleClickListener implements IDoubleClickListener {
+               public void doubleClick(DoubleClickEvent evt) {
+                       Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement();
+                       try {
+                               if (obj instanceof Node) {
+                                       Node node = (Node) obj;
+                                       if (node.isNodeType(SlcTypes.SLC_PROCESS)) {
+                                               IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                                                               .getActivePage();
+                                               activePage.openEditor(new ProcessEditorInput(node.getPath()), ProcessEditor.ID);
+                                       }
+                               }
+                       } catch (Exception e) {
+                               throw new SlcException("Cannot open " + obj, e);
+                       }
+               }
+
+       }
+
+       public void dispose() {
+               JcrUtils.unregisterQuietly(session.getWorkspace(), processesObserver);
+               JcrUtils.logoutQuietly(session);
+               if (pushSession != null)
+                       pushSession.stop();
+               super.dispose();
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java
new file mode 100644 (file)
index 0000000..41a1d52
--- /dev/null
@@ -0,0 +1,256 @@
+package org.argeo.slc.client.ui.views;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.Query;
+
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
+import org.argeo.eclipse.ui.jcr.NodeElementComparer;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.editors.ProcessEditor;
+import org.argeo.slc.client.ui.editors.ProcessEditorInput;
+import org.argeo.slc.jcr.SlcJcrResultUtils;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+/** Displays results. */
+public class JcrResultListView extends ViewPart implements SlcNames {
+       public static final String ID = ClientUiPlugin.ID + ".jcrResultListView";
+
+       private TableViewer viewer;
+
+       private Repository repository;
+       private Session session;
+
+       private EventListener resultsObserver;
+
+       private DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
+       private Integer queryLimit = 2000;
+
+       public void createPartControl(Composite parent) {
+               try {
+                       session = repository.login();
+               } catch (RepositoryException e1) {
+                       throw new SlcException("Cannot log in to repository");
+               }
+
+               Table table = createTable(parent);
+               viewer = new TableViewer(table);
+               viewer.setLabelProvider(createLabelProvider());
+               viewer.setContentProvider(new ViewContentProvider());
+               viewer.setInput(getViewSite());
+               viewer.addDoubleClickListener(new ViewDoubleClickListener());
+               viewer.setComparer(new NodeElementComparer());
+
+               getViewSite().setSelectionProvider(viewer);
+
+               resultsObserver = new ResultObserver(viewer.getTable().getDisplay());
+               try {
+                       ObservationManager observationManager = session.getWorkspace().getObservationManager();
+                       String[] nodeTypes = { SlcTypes.SLC_TEST_RESULT };
+                       // FIXME Will not be notified if empty result is deleted
+                       observationManager.addEventListener(resultsObserver, Event.PROPERTY_ADDED | Event.NODE_REMOVED,
+                                       SlcJcrResultUtils.getSlcResultsBasePath(session), true, null, nodeTypes, false);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot register listeners", e);
+               }
+
+       }
+
+       protected Table createTable(Composite parent) {
+               int style = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI;
+               // does not work with RAP, commented for the time being
+               // | SWT.HIDE_SELECTION;
+
+               Table table = new Table(parent, style);
+
+               table.setLinesVisible(true);
+               table.setHeaderVisible(true);
+
+               TableColumn column = new TableColumn(table, SWT.LEFT, 0);
+               column.setText("Date");
+               column.setWidth(200);
+
+               column = new TableColumn(table, SWT.LEFT, 1);
+               column.setText("Id");
+               column.setWidth(300);
+
+               return table;
+       }
+
+       // public void refresh() {
+       // viewer.refresh();
+       // }
+
+       /*
+        * METHODS TO BE OVERRIDDEN
+        */
+       protected IBaseLabelProvider createLabelProvider() {
+               return new ViewLabelProvider();
+       }
+
+       protected void processDoubleClick(DoubleClickEvent evt) {
+               Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement();
+               try {
+                       if (obj instanceof Node) {
+                               Node node = (Node) obj;
+                               // FIXME: open a default result editor
+                               if (node.isNodeType(SlcTypes.SLC_PROCESS)) {
+                                       IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+                                       activePage.openEditor(new ProcessEditorInput(node.getPath()), ProcessEditor.ID);
+                               }
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot open " + obj, e);
+               }
+       }
+
+       public void setFocus() {
+               viewer.getControl().setFocus();
+       }
+
+       class ViewContentProvider implements IStructuredContentProvider {
+               private static final long serialVersionUID = -4719077015405546260L;
+
+               public Object[] getElements(Object inputElement) {
+                       try {
+                               // TODO filter, optimize with virtual table, ...
+                               String sql = "SELECT * from [" + SlcTypes.SLC_TEST_RESULT + "] ORDER BY [jcr:lastModified] DESC";
+                               Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
+                               // TODO paging
+                               query.setLimit(queryLimit);
+                               List<Node> nodes = new ArrayList<Node>();
+                               for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
+                                       nodes.add(nit.nextNode());
+                               }
+                               return nodes.toArray();
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot retrieve processes", e);
+                       }
+               }
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+       }
+
+       class ViewLabelProvider extends ColumnLabelProvider implements ITableLabelProvider {
+               private static final long serialVersionUID = -6323202576386795247L;
+
+               public Image getColumnImage(Object obj, int columnIndex) {
+                       if (columnIndex != 0)
+                               return null;
+                       try {
+                               Node node = (Node) obj;
+                               if (node.hasProperty(SLC_COMPLETED)) {
+                                       // TODO
+                               }
+                               return null;
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get column text", e);
+                       }
+               }
+
+               public String getColumnText(Object obj, int index) {
+                       try {
+                               Node node = (Node) obj;
+                               switch (index) {
+
+                               case 0:
+                                       if (node.hasProperty(SLC_COMPLETED)) {
+                                               return dateFormat.format(node.getProperty(SLC_COMPLETED).getDate().getTime());
+                                       } else {
+                                               return "OPEN";
+                                       }
+                               case 1:
+                                       return node.getProperty(SlcNames.SLC_UUID).getString();
+                               }
+                               return getText(obj);
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get column text", e);
+                       }
+               }
+
+       }
+
+       class ViewDoubleClickListener implements IDoubleClickListener {
+               public void doubleClick(DoubleClickEvent evt) {
+                       processDoubleClick(evt);
+               }
+
+       }
+
+       class ResultObserver extends AsyncUiEventListener {
+
+               public ResultObserver(Display display) {
+                       super(display);
+               }
+
+               @Override
+               protected Boolean willProcessInUiThread(List<Event> events) throws RepositoryException {
+                       for (Event event : events) {
+                               // getLog().debug("Received event " + event);
+                               int eventType = event.getType();
+                               if (eventType == Event.NODE_REMOVED)
+                                       return true;
+                               String path = event.getPath();
+                               int index = path.lastIndexOf('/');
+                               String propertyName = path.substring(index + 1);
+                               if (propertyName.equals(SLC_COMPLETED) || propertyName.equals(SLC_UUID)) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+
+               protected void onEventInUiThread(List<Event> events) throws RepositoryException {
+                       if (getLog().isTraceEnabled())
+                               getLog().trace("Refresh result list");
+                       viewer.refresh();
+               }
+       }
+
+       public void dispose() {
+               JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver);
+               JcrUtils.logoutQuietly(session);
+               super.dispose();
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java
new file mode 100644 (file)
index 0000000..824dcfd
--- /dev/null
@@ -0,0 +1,953 @@
+package org.argeo.slc.client.ui.views;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.ObservationManager;
+
+import org.argeo.api.NodeConstants;
+import org.argeo.cms.ui.workbench.util.CommandUtils;
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.SlcUiConstants;
+import org.argeo.slc.client.ui.commands.AddResultFolder;
+import org.argeo.slc.client.ui.commands.DeleteItems;
+import org.argeo.slc.client.ui.commands.RefreshJcrResultTreeView;
+import org.argeo.slc.client.ui.commands.RenameResultFolder;
+import org.argeo.slc.client.ui.commands.RenameResultNode;
+import org.argeo.slc.client.ui.editors.ProcessEditor;
+import org.argeo.slc.client.ui.editors.ProcessEditorInput;
+import org.argeo.slc.client.ui.model.ParentNodeFolder;
+import org.argeo.slc.client.ui.model.ResultFolder;
+import org.argeo.slc.client.ui.model.ResultItemsComparator;
+import org.argeo.slc.client.ui.model.ResultItemsComparer;
+import org.argeo.slc.client.ui.model.ResultParent;
+import org.argeo.slc.client.ui.model.ResultParentUtils;
+import org.argeo.slc.client.ui.model.SingleResultNode;
+import org.argeo.slc.client.ui.model.VirtualFolder;
+import org.argeo.slc.client.ui.providers.ResultTreeContentProvider;
+import org.argeo.slc.client.ui.providers.ResultTreeLabelProvider;
+import org.argeo.slc.jcr.SlcJcrResultUtils;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerDropAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+/** SLC generic JCR Result tree view. */
+public class JcrResultTreeView extends ViewPart {
+       public final static String ID = ClientUiPlugin.ID + ".jcrResultTreeView";
+
+       private final static DateFormat dateFormat = new SimpleDateFormat(
+                       SlcUiConstants.DEFAULT_DISPLAY_DATE_TIME_FORMAT);
+
+       // private final static Log log =
+       // LogFactory.getLog(JcrResultTreeView.class);
+
+       /* DEPENDENCY INJECTION */
+       private Repository repository;
+       private Session session;
+
+       // This page widgets
+       private TreeViewer resultTreeViewer;
+       private TableViewer propertiesViewer;
+
+       private EventListener myResultsObserver = null;
+       private EventListener allResultsObserver = null;
+
+       // under My Results
+       private final static String[] observedNodeTypesUnderMyResult = {
+                       SlcTypes.SLC_TEST_RESULT, SlcTypes.SLC_RESULT_FOLDER,
+                       SlcTypes.SLC_MY_RESULT_ROOT_FOLDER };
+
+       private final static String[] observedNodeTypesUnderAllResults = {
+                       SlcTypes.SLC_TEST_RESULT, NodeType.NT_UNSTRUCTURED };
+
+       private boolean isResultFolder = false;
+
+       /**
+        * To be overridden to adapt size of form and result frames.
+        */
+       protected int[] getWeights() {
+               return new int[] { 70, 30 };
+       }
+
+       @Override
+       public void createPartControl(Composite parent) {
+               try {
+                       session = repository.login(NodeConstants.HOME_WORKSPACE);
+               } catch (RepositoryException e1) {
+                       throw new SlcException("Cannot log in to repository");
+               }
+
+               parent.setLayout(new FillLayout());
+               // Main layout
+               SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
+               sashForm.setSashWidth(4);
+               sashForm.setLayout(new FillLayout());
+
+               // Create the tree on top of the view
+               Composite top = new Composite(sashForm, SWT.NONE);
+               GridLayout gl = new GridLayout(1, false);
+               top.setLayout(gl);
+               resultTreeViewer = createResultsTreeViewer(top);
+
+               // Create the property viewer on the bottom
+               Composite bottom = new Composite(sashForm, SWT.NONE);
+               bottom.setLayout(new GridLayout(1, false));
+               propertiesViewer = createPropertiesViewer(bottom);
+
+               sashForm.setWeights(getWeights());
+
+               setOrderedInput(resultTreeViewer);
+
+               // Initialize observer
+               try {
+                       ObservationManager observationManager = session.getWorkspace()
+                                       .getObservationManager();
+                       myResultsObserver = new MyResultsObserver(resultTreeViewer
+                                       .getTree().getDisplay());
+                       allResultsObserver = new AllResultsObserver(resultTreeViewer
+                                       .getTree().getDisplay());
+
+                       // observe tree changes under MyResults
+                       observationManager.addEventListener(myResultsObserver,
+                                       Event.NODE_ADDED | Event.NODE_REMOVED,
+                                       SlcJcrResultUtils.getMyResultsBasePath(session), true,
+                                       null, observedNodeTypesUnderMyResult, false);
+                       // observe tree changes under All results
+                       observationManager.addEventListener(allResultsObserver,
+                                       Event.NODE_ADDED | Event.NODE_REMOVED,
+                                       SlcJcrResultUtils.getSlcResultsBasePath(session), true,
+                                       null, observedNodeTypesUnderAllResults, false);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot register listeners", e);
+               }
+       }
+
+       /**
+        * Override default behaviour so that default defined order remains
+        * unchanged on first level of the tree
+        */
+       private void setOrderedInput(TreeViewer viewer) {
+               // Add specific ordering
+               viewer.setInput(null);
+               viewer.setComparator(null);
+               viewer.setInput(initializeResultTree());
+               viewer.setComparator(new ResultItemsComparator());
+       }
+
+       // The main tree viewer
+       protected TreeViewer createResultsTreeViewer(Composite parent) {
+               int style = SWT.BORDER | SWT.MULTI;
+
+               TreeViewer viewer = new TreeViewer(parent, style);
+               viewer.getTree().setLayoutData(
+                               new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               viewer.setContentProvider(new ResultTreeContentProvider());
+
+               // Add label provider with label decorator
+               ResultTreeLabelProvider rtLblProvider = new ResultTreeLabelProvider();
+               ILabelDecorator decorator = ClientUiPlugin.getDefault().getWorkbench()
+                               .getDecoratorManager().getLabelDecorator();
+               viewer.setLabelProvider(new DecoratingLabelProvider(rtLblProvider,
+                               decorator));
+               viewer.addDoubleClickListener(new ViewDoubleClickListener());
+
+               // Override default behaviour to insure that 2 distincts results that
+               // have the same name will be correctly and distincly returned by
+               // corresponding TreeViewer.getSelection() method.
+               viewer.setComparer(new ResultItemsComparer());
+
+               // viewer.setLabelProvider(rtLblProvider);
+               getSite().setSelectionProvider(viewer);
+
+               // add drag & drop support
+               int operations = DND.DROP_COPY | DND.DROP_MOVE;
+               Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
+               viewer.addDragSupport(operations, tt, new ViewDragListener());
+               viewer.addDropSupport(operations, tt, new ViewDropListener(viewer));
+
+               // add context menu
+               MenuManager menuManager = new MenuManager();
+               Menu menu = menuManager.createContextMenu(viewer.getTree());
+               menuManager.addMenuListener(new IMenuListener() {
+                       public void menuAboutToShow(IMenuManager manager) {
+                               contextMenuAboutToShow(manager);
+                       }
+               });
+               viewer.getTree().setMenu(menu);
+               menuManager.setRemoveAllWhenShown(true);
+
+               getSite().registerContextMenu(menuManager, viewer);
+
+               // add change listener to display TestResult information in the property
+               // viewer
+               viewer.addSelectionChangedListener(new MySelectionChangedListener());
+               return viewer;
+       }
+
+       // Detailed property viewer
+       protected TableViewer createPropertiesViewer(Composite parent) {
+               propertiesViewer = new TableViewer(parent);
+               propertiesViewer.getTable().setLayoutData(
+                               new GridData(SWT.FILL, SWT.FILL, true, true));
+               propertiesViewer.getTable().setHeaderVisible(true);
+               propertiesViewer.setContentProvider(new PropertiesContentProvider());
+               TableViewerColumn col = new TableViewerColumn(propertiesViewer,
+                               SWT.NONE);
+               col.getColumn().setText("Name");
+               col.getColumn().setWidth(100);
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       public String getText(Object element) {
+                               try {
+                                       String name = ((Property) element).getName();
+                                       String value = null;
+                                       if (SlcNames.SLC_TEST_CASE.equals(name))
+                                               value = "Test case";
+                                       else if (SlcNames.SLC_COMPLETED.equals(name))
+                                               value = "Completed on";
+                                       else if (SlcNames.SLC_SUCCESS.equals(name))
+                                               value = "Status";
+                                       else if (SlcNames.SLC_MESSAGE.equals(name))
+                                               value = "Message";
+                                       else if (SlcNames.SLC_ERROR_MESSAGE.equals(name))
+                                               value = "Error";
+                                       return value;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException(
+                                                       "Unexpected exception in label provider", e);
+                               }
+                       }
+               });
+               col = new TableViewerColumn(propertiesViewer, SWT.NONE);
+               col.getColumn().setText("Value");
+               col.getColumn().setWidth(200);
+               col.setLabelProvider(new ColumnLabelProvider() {
+                       public String getText(Object element) {
+                               try {
+                                       Property property = (Property) element;
+                                       String name = property.getName();
+                                       String value = null;
+
+                                       if (SlcNames.SLC_TEST_CASE.equals(name)
+                                                       || SlcNames.SLC_ERROR_MESSAGE.equals(name)
+                                                       || SlcNames.SLC_MESSAGE.equals(name))
+                                               value = property.getValue().getString();
+                                       else if (SlcNames.SLC_COMPLETED.equals(name)) {
+                                               Calendar date = property.getValue().getDate();
+                                               value = dateFormat.format(date.getTime());
+                                       } else if (SlcNames.SLC_SUCCESS.equals(name)) {
+                                               if (property.getValue().getBoolean())
+                                                       value = "PASSED";
+                                               else {
+                                                       if (property.getParent().hasProperty(
+                                                                       SlcNames.SLC_ERROR_MESSAGE))
+                                                               value = "ERROR";
+                                                       else
+                                                               value = "FAILED";
+                                               }
+                                       }
+                                       return value;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException(
+                                                       "Unexpected exception in label provider", e);
+                               }
+                       }
+               });
+               propertiesViewer.setInput(getViewSite());
+               return propertiesViewer;
+       }
+
+       /**
+        * Override to provide specific behaviour. Typically to enable the display
+        * of a result file.
+        * 
+        * @param evt
+        */
+       protected void processDoubleClick(DoubleClickEvent evt) {
+               Object obj = ((IStructuredSelection) evt.getSelection())
+                               .getFirstElement();
+               try {
+                       if (obj instanceof SingleResultNode) {
+                               SingleResultNode srNode = (SingleResultNode) obj;
+                               Node node = srNode.getNode();
+                               // FIXME: open a default result editor
+                               if (node.isNodeType(SlcTypes.SLC_PROCESS)) {
+                                       IWorkbenchPage activePage = PlatformUI.getWorkbench()
+                                                       .getActiveWorkbenchWindow().getActivePage();
+                                       activePage.openEditor(
+                                                       new ProcessEditorInput(node.getPath()),
+                                                       ProcessEditor.ID);
+                               }
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot open " + obj, e);
+               }
+       }
+
+       @Override
+       public void setFocus() {
+       }
+
+       /**
+        * refreshes the passed resultParent and its corresponding subtree. It
+        * refreshes the whole viewer if null is passed.
+        * 
+        * @param ResultParent
+        * 
+        */
+       public void refresh(ResultParent resultParent) {
+               if (resultParent == null) {
+                       if (!resultTreeViewer.getTree().isDisposed()) {
+                               TreePath[] tps = resultTreeViewer.getExpandedTreePaths();
+                               setOrderedInput(resultTreeViewer);
+                               resultTreeViewer.setExpandedTreePaths(tps);
+                       } else
+                               setOrderedInput(resultTreeViewer);
+               } else {
+                       if (resultParent instanceof ParentNodeFolder) {
+                               ParentNodeFolder currFolder = (ParentNodeFolder) resultParent;
+                               jcrRefresh(currFolder.getNode());
+                               currFolder.forceFullRefresh();
+                       }
+                       // FIXME: specific refresh does not work
+                       // resultTreeViewer.refresh(resultParent, true);
+                       refresh(null);
+               }
+       }
+
+       /**
+        * refreshes the passed node and its corresponding subtree.
+        * 
+        * @param node
+        *            cannot be null
+        * 
+        */
+       public boolean jcrRefresh(Node node) {
+               // if (log.isDebugEnabled())
+               // log.debug(" JCR refreshing " + node + "...");
+               // Thread.dumpStack();
+               boolean isPassed = true;
+               try {
+                       if (node.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
+                               isPassed = node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
+                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
+                       } else if (node.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
+                               NodeIterator ni = node.getNodes();
+                               while (ni.hasNext()) {
+                                       Node currChild = ni.nextNode();
+                                       isPassed = isPassed & jcrRefresh(currChild);
+                               }
+                               if (isPassed != node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
+                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean()) {
+                                       node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
+                                                       SlcNames.SLC_SUCCESS, isPassed);
+                                       node.getSession().save();
+                                       return isPassed;
+                               }
+                       } else
+                               ; // do nothing
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot register listeners", e);
+               }
+               return isPassed;
+       }
+
+       private ResultParent[] initializeResultTree() {
+               try {
+                       // Force initialization of the tree structure if needed
+                       SlcJcrResultUtils.getSlcResultsParentNode(session);
+                       SlcJcrResultUtils.getMyResultParentNode(session);
+                       // Remove yesterday and last 7 days virtual folders
+                       // ResultParent[] roots = new ResultParent[5];
+                       ResultParent[] roots = new ResultParent[3];
+
+                       // My results
+                       roots[0] = new ParentNodeFolder(null,
+                                       SlcJcrResultUtils.getMyResultParentNode(session),
+                                       SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL);
+
+                       // today
+                       Calendar cal = Calendar.getInstance();
+                       String relPath = JcrUtils.dateAsPath(cal);
+                       List<String> datePathes = new ArrayList<String>();
+                       datePathes.add(relPath);
+                       roots[1] = new VirtualFolder(null,
+                                       ResultParentUtils.getResultsForDates(session, datePathes),
+                                       "Today");
+
+                       // // Yesterday
+                       // cal = Calendar.getInstance();
+                       // cal.add(Calendar.DAY_OF_YEAR, -1);
+                       // relPath = JcrUtils.dateAsPath(cal);
+                       // datePathes = new ArrayList<String>();
+                       // datePathes.add(relPath);
+                       // roots[2] = new VirtualFolder(null,
+                       // ResultParentUtils.getResultsForDates(session, datePathes),
+                       // "Yesterday");
+                       // // Last 7 days
+                       //
+                       // cal = Calendar.getInstance();
+                       // datePathes = new ArrayList<String>();
+                       //
+                       // for (int i = 0; i < 7; i++) {
+                       // cal.add(Calendar.DAY_OF_YEAR, -i);
+                       // relPath = JcrUtils.dateAsPath(cal);
+                       // datePathes.add(relPath);
+                       // }
+                       // roots[3] = new VirtualFolder(null,
+                       // ResultParentUtils.getResultsForDates(session, datePathes),
+                       // "Last 7 days");
+
+                       // All results
+                       Node otherResultsPar = session.getNode(SlcJcrResultUtils
+                                       .getSlcResultsBasePath(session));
+                       // roots[4] = new ParentNodeFolder(null, otherResultsPar,
+                       // "All results");
+                       roots[2] = new ParentNodeFolder(null, otherResultsPar,
+                                       "All results");
+                       return roots;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while initializing ResultTree.", re);
+               }
+       }
+
+       // Manage context menu
+       /**
+        * Defines the commands that will pop up in the context menu.
+        **/
+       protected void contextMenuAboutToShow(IMenuManager menuManager) {
+               IWorkbenchWindow window = ClientUiPlugin.getDefault().getWorkbench()
+                               .getActiveWorkbenchWindow();
+
+               IStructuredSelection selection = (IStructuredSelection) resultTreeViewer
+                               .getSelection();
+               boolean canAddSubfolder = false;
+               boolean canRenamefolder = false;
+               boolean isSingleResultNode = false;
+               boolean isUnderMyResult = false;
+               boolean validMultipleDelete = false;
+               try {
+
+                       // Building conditions
+                       if (selection.size() == 1) {
+                               Object obj = selection.getFirstElement();
+                               if (obj instanceof SingleResultNode)
+                                       isSingleResultNode = true;
+                               else if (obj instanceof ParentNodeFolder) {
+                                       Node cNode = ((ParentNodeFolder) obj).getNode();
+                                       if (cNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
+                                               canAddSubfolder = true;
+                                               canRenamefolder = true;
+                                               isUnderMyResult = true;
+                                       } else if (cNode
+                                                       .isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER)) {
+                                               canAddSubfolder = true;
+                                       }
+                               }
+                       } else {
+                               @SuppressWarnings("rawtypes")
+                               Iterator it = selection.iterator();
+                               multicheck: while (it.hasNext()) {
+                                       validMultipleDelete = true;
+                                       Object obj = it.next();
+                                       if (obj instanceof SingleResultNode)
+                                               continue multicheck;
+                                       else if (obj instanceof ParentNodeFolder) {
+                                               Node cNode = ((ParentNodeFolder) obj).getNode();
+                                               if (cNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER))
+                                                       continue multicheck;
+                                               else {
+                                                       validMultipleDelete = false;
+                                                       break multicheck;
+                                               }
+                                       } else {
+                                               validMultipleDelete = false;
+                                               break multicheck;
+                                       }
+                               }
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "unexpected error while building condition for context menu",
+                                       re);
+               }
+
+               // Effective Refresh
+               CommandUtils.refreshCommand(menuManager, window,
+                               RefreshJcrResultTreeView.ID,
+                               RefreshJcrResultTreeView.DEFAULT_LABEL,
+                               RefreshJcrResultTreeView.DEFAULT_IMG_DESCRIPTOR, true);
+
+               CommandUtils.refreshCommand(menuManager, window, DeleteItems.ID,
+                               DeleteItems.DEFAULT_LABEL, DeleteItems.DEFAULT_IMG_DESCRIPTOR,
+                               isUnderMyResult || isSingleResultNode || validMultipleDelete);
+
+               CommandUtils.refreshCommand(menuManager, window, AddResultFolder.ID,
+                               AddResultFolder.DEFAULT_LABEL,
+                               ClientUiPlugin.getDefault().getWorkbench().getSharedImages()
+                                               .getImageDescriptor(ISharedImages.IMG_OBJ_ADD),
+                               canAddSubfolder);
+
+               CommandUtils.refreshCommand(menuManager, window, RenameResultFolder.ID,
+                               RenameResultFolder.DEFAULT_LABEL,
+                               RenameResultFolder.DEFAULT_IMG_DESCRIPTOR, canRenamefolder);
+
+               // Command removed for the time being.
+               CommandUtils.refreshCommand(menuManager, window, RenameResultNode.ID,
+                               RenameResultNode.DEFAULT_LABEL,
+                               RenameResultNode.DEFAULT_IMG_DESCRIPTOR, false);
+
+               // Test to be removed
+               // If you use this pattern, do not forget to call
+               // menuManager.setRemoveAllWhenShown(true);
+               // when creating the menuManager
+
+               // menuManager.add(new Action("Test") {
+               // public void run() {
+               // log.debug("do something");
+               // }
+               // });
+       }
+
+       /* INNER CLASSES */
+       class ViewDragListener implements DragSourceListener {
+
+               public void dragStart(DragSourceEvent event) {
+                       // Check if the drag action should start.
+                       IStructuredSelection selection = (IStructuredSelection) resultTreeViewer
+                                       .getSelection();
+                       boolean doIt = false;
+
+                       // FIXME clean this code.
+                       try {
+                               if (selection.size() == 1) {
+                                       Object obj = selection.getFirstElement();
+                                       if (obj instanceof ResultFolder) {
+                                               Node tNode = ((ResultFolder) obj).getNode();
+                                               if (tNode.getPrimaryNodeType().isNodeType(
+                                                               SlcTypes.SLC_RESULT_FOLDER)) {
+                                                       doIt = true;
+                                                       isResultFolder = true;
+                                               }
+                                       } else
+                                               isResultFolder = false;
+                               } else
+                                       isResultFolder = false;
+
+                               if (!isResultFolder) {
+                                       @SuppressWarnings("rawtypes")
+                                       Iterator it = selection.iterator();
+                                       while (it.hasNext()) {
+                                               Object obj = it.next();
+                                               if (obj instanceof SingleResultNode) {
+                                                       Node tNode = ((SingleResultNode) obj).getNode();
+                                                       if (tNode.getPrimaryNodeType().isNodeType(
+                                                                       SlcTypes.SLC_TEST_RESULT)) {
+                                                               doIt = true;
+                                                       }
+                                               }
+                                       }
+                               }
+
+                       } catch (RepositoryException re) {
+                               throw new SlcException(
+                                               "unexpected error while validating drag source", re);
+                       }
+                       event.doit = doIt;
+               }
+
+               public void dragSetData(DragSourceEvent event) {
+                       IStructuredSelection selection = (IStructuredSelection) resultTreeViewer
+                                       .getSelection();
+
+                       try {
+                               // specific case of a result folder
+                               if (isResultFolder) {
+                                       Object obj = selection.getFirstElement();
+                                       event.data = ((ResultFolder) obj).getNode().getIdentifier();
+                               } else {
+                                       @SuppressWarnings("rawtypes")
+                                       Iterator it = selection.iterator();
+                                       StringBuilder nodes = new StringBuilder();
+                                       while (it.hasNext()) {
+                                               Object obj = it.next();
+                                               if (obj instanceof SingleResultNode) {
+                                                       Node tNode = ((SingleResultNode) obj).getNode();
+                                                       if (tNode.getPrimaryNodeType().isNodeType(
+                                                                       SlcTypes.SLC_TEST_RESULT)) {
+                                                               nodes.append(tNode.getIdentifier()).append(";");
+                                                       }
+                                               }
+                                       }
+                                       event.data = nodes.toString();
+                               }
+                       } catch (RepositoryException re) {
+                               throw new SlcException("unexpected error while setting data",
+                                               re);
+                       }
+               }
+
+               public void dragFinished(DragSourceEvent event) {
+                       // refresh is done via observer
+               }
+       }
+
+       // Implementation of the Drop Listener
+       protected class ViewDropListener extends ViewerDropAdapter {
+               private Node targetParentNode = null;
+
+               public ViewDropListener(Viewer viewer) {
+                       super(viewer);
+               }
+
+               @Override
+               public boolean validateDrop(Object target, int operation,
+                               TransferData transferType) {
+                       boolean validDrop = false;
+                       try {
+                               // We can only drop under myResults
+                               Node tpNode = null;
+                               if (target instanceof SingleResultNode) {
+                                       Node currNode = ((SingleResultNode) target).getNode();
+                                       String pPath = currNode.getParent().getPath();
+                                       if (pPath.startsWith(SlcJcrResultUtils
+                                                       .getMyResultsBasePath(session)))
+                                               tpNode = currNode.getParent();
+                               } else if (target instanceof ResultFolder) {
+                                       tpNode = ((ResultFolder) target).getNode();
+                               } else if (target instanceof ParentNodeFolder) {
+                                       Node node = ((ParentNodeFolder) target).getNode();
+                                       if (node.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
+                                               tpNode = ((ParentNodeFolder) target).getNode();
+                               }
+
+                               if (tpNode != null) {
+                                       targetParentNode = tpNode;
+                                       validDrop = true;
+                               }
+                       } catch (RepositoryException re) {
+                               throw new SlcException(
+                                               "unexpected error while validating drop target", re);
+                       }
+                       return validDrop;
+               }
+
+               @Override
+               public boolean performDrop(Object data) {
+                       // clear selection to prevent unwanted scrolling of the UI
+                       resultTreeViewer.setSelection(null);
+                       try {
+                               if (isResultFolder) {
+                                       // Sanity check : we cannot move a folder to one of its sub
+                                       // folder or neither move an object in the same parent
+                                       // folder
+                                       Node source = session.getNodeByIdentifier((String) data);
+                                       if (targetParentNode.getPath().startsWith(source.getPath())
+                                                       || source.getParent().getPath()
+                                                                       .equals(targetParentNode.getPath()))
+                                               return false;
+
+                                       // Move
+                                       String sourcePath = source.getPath();
+                                       String destPath = targetParentNode.getPath() + "/"
+                                                       + source.getName();
+                                       session.move(sourcePath, destPath);
+                                       // Update passed status of the parent source Node
+                                       ResultParentUtils.updatePassedStatus(
+                                                       session.getNode(JcrUtils.parentPath(sourcePath)),
+                                                       true);
+                                       // Node target = session.getNode(destPath);
+                                       session.save();
+                                       return true;
+                               }
+
+                               String[] datas = ((String) data).split(";");
+                               nodesToCopy: for (String id : datas) {
+
+                                       Node source = session.getNodeByIdentifier(id);
+                                       String name;
+                                       if (source.hasProperty(Property.JCR_TITLE))
+                                               name = source.getProperty(Property.JCR_TITLE)
+                                                               .getString();
+                                       else if (source.hasProperty(SlcNames.SLC_TEST_CASE))
+                                               name = source.getProperty(SlcNames.SLC_TEST_CASE)
+                                                               .getString();
+                                       else
+                                               name = source.getName();
+
+                                       // Check if another copy of the same test instance already
+                                       // exists at target
+                                       NodeIterator ni = targetParentNode.getNodes();
+                                       String slcUid = source.getProperty(SlcNames.SLC_UUID)
+                                                       .getString();
+                                       while (ni.hasNext()) {
+                                               Node curr = ni.nextNode();
+                                               if (curr.hasProperty(SlcNames.SLC_UUID)
+                                                               && slcUid.equals(curr.getProperty(
+                                                                               SlcNames.SLC_UUID).getString())) {
+                                                       MessageDialog
+                                                                       .openWarning(
+                                                                                       PlatformUI.getWorkbench()
+                                                                                                       .getDisplay()
+                                                                                                       .getActiveShell(),
+                                                                                       "Duplicated instance.",
+                                                                                       "An instance of the same test case ("
+                                                                                                       + name
+                                                                                                       + ") exists at destination.\n "
+                                                                                                       + "This item will not be neither copied nor moved.");
+                                                       continue nodesToCopy;
+
+                                               }
+                                       }
+
+                                       Node target;
+                                       boolean passedStatus = false;
+                                       if (source.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
+                                               passedStatus = source
+                                                               .getNode(SlcNames.SLC_AGGREGATED_STATUS)
+                                                               .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
+
+                                       boolean isActionUnderMyResult = source.getPath()
+                                                       .startsWith(
+                                                                       SlcJcrResultUtils
+                                                                                       .getMyResultsBasePath(session));
+
+                                       if (!isActionUnderMyResult) {// Copy
+                                               target = targetParentNode.addNode(source.getName(),
+                                                               source.getPrimaryNodeType().getName());
+                                               JcrUtils.copy(source, target);
+                                       } else {// move
+                                               String sourcePath = source.getPath();
+                                               String destPath = targetParentNode.getPath() + "/"
+                                                               + name;
+                                               session.move(sourcePath, destPath);
+                                               // Update passed status of the parent source Node
+                                               ResultParentUtils
+                                                               .updatePassedStatus(session.getNode(JcrUtils
+                                                                               .parentPath(sourcePath)), true);
+                                               target = session.getNode(destPath);
+
+                                       }
+                                       if (!target.isNodeType(NodeType.MIX_TITLE))
+                                               target.addMixin(NodeType.MIX_TITLE);
+                                       target.setProperty(Property.JCR_TITLE, name);
+                                       ResultParentUtils.updatePassedStatus(target.getParent(),
+                                                       passedStatus);
+                                       session.save();
+                               }
+                       } catch (RepositoryException re) {
+                               throw new SlcException(
+                                               "unexpected error while copying dropped node", re);
+
+                       }
+                       return true;
+               }
+       }
+
+       class MyResultsObserver extends AsyncUiEventListener {
+
+               public MyResultsObserver(Display display) {
+                       super(display);
+               }
+
+               @Override
+               protected Boolean willProcessInUiThread(List<Event> events)
+                               throws RepositoryException {
+                       // unfiltered for the time being
+                       return true;
+               }
+
+               protected void onEventInUiThread(List<Event> events)
+                               throws RepositoryException {
+                       List<Node> nodesToRefresh = new ArrayList<Node>();
+
+                       for (Event event : events) {
+                               String parPath = JcrUtils.parentPath(event.getPath());
+                               if (session.nodeExists(parPath)) {
+                                       Node node = session.getNode(parPath);
+                                       if (!nodesToRefresh.contains(node)) {
+                                               nodesToRefresh.add(node);
+                                       }
+                               }
+                       }
+
+                       // Update check nodes
+                       for (Node node : nodesToRefresh)
+                               jcrRefresh(node);
+                       refresh(null);
+               }
+       }
+
+       class AllResultsObserver extends AsyncUiEventListener {
+
+               public AllResultsObserver(Display display) {
+                       super(display);
+               }
+
+               @Override
+               protected Boolean willProcessInUiThread(List<Event> events)
+                               throws RepositoryException {
+                       // unfiltered for the time being
+                       return true;
+               }
+
+               protected void onEventInUiThread(List<Event> events)
+                               throws RepositoryException {
+                       refresh(null);
+                       // if (lastSelectedSourceElementParent != null)
+                       // refresh(lastSelectedSourceElementParent);
+               }
+       }
+
+       class PropertiesContentProvider implements IStructuredContentProvider {
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+               public Object[] getElements(Object inputElement) {
+                       try {
+                               if (inputElement instanceof Node) {
+                                       Node node = (Node) inputElement;
+                                       if (node.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
+                                               List<Property> props = new ArrayList<Property>();
+                                               if (node.hasProperty(SlcNames.SLC_TEST_CASE))
+                                                       props.add(node.getProperty(SlcNames.SLC_TEST_CASE));
+                                               if (node.hasProperty(SlcNames.SLC_COMPLETED))
+                                                       props.add(node.getProperty(SlcNames.SLC_COMPLETED));
+                                               if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS)) {
+                                                       Node status = node
+                                                                       .getNode(SlcNames.SLC_AGGREGATED_STATUS);
+                                                       props.add(status.getProperty(SlcNames.SLC_SUCCESS));
+                                                       if (status.hasProperty(SlcNames.SLC_MESSAGE))
+                                                               props.add(status
+                                                                               .getProperty(SlcNames.SLC_MESSAGE));
+                                                       if (status.hasProperty(SlcNames.SLC_ERROR_MESSAGE))
+                                                               props.add(status
+                                                                               .getProperty(SlcNames.SLC_ERROR_MESSAGE));
+                                               }
+                                               return props.toArray();
+                                       }
+                               }
+                               return new Object[] {};
+
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get element for "
+                                               + inputElement, e);
+                       }
+               }
+       }
+
+       class MySelectionChangedListener implements ISelectionChangedListener {
+
+               public void selectionChanged(SelectionChangedEvent event) {
+                       if (!event.getSelection().isEmpty()) {
+                               IStructuredSelection sel = (IStructuredSelection) event
+                                               .getSelection();
+                               ResultParent firstItem = (ResultParent) sel.getFirstElement();
+                               if (firstItem instanceof SingleResultNode)
+                                       propertiesViewer.setInput(((SingleResultNode) firstItem)
+                                                       .getNode());
+                               else
+                                       propertiesViewer.setInput(null);
+                               // update cache for Drag & drop
+                               // lastSelectedTargetElement = firstItem;
+                               // lastSelectedSourceElement = firstItem;
+                               // lastSelectedSourceElementParent = (ResultParent) firstItem
+                               // .getParent();
+                               // String pPath = "";
+                               // try {
+                               //
+                               // if (firstItem instanceof ParentNodeFolder)
+                               // pPath = ((ParentNodeFolder) firstItem).getNode()
+                               // .getPath();
+                               // else if (firstItem instanceof SingleResultNode)
+                               // pPath = ((SingleResultNode) firstItem).getNode()
+                               // .getPath();
+                               // } catch (RepositoryException e) {
+                               // throw new SlcException(
+                               // "Unexpected error while checking parent UI tree", e);
+                               // }
+                               // if ((pPath.startsWith(SlcJcrResultUtils
+                               // .getMyResultsBasePath(session))))
+                               // isActionUnderMyResult = true;
+                               // else
+                               // isActionUnderMyResult = false;
+                       }
+               }
+       }
+
+       class ViewDoubleClickListener implements IDoubleClickListener {
+               public void doubleClick(DoubleClickEvent evt) {
+                       processDoubleClick(evt);
+               }
+
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void dispose() {
+               // JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver);
+               JcrUtils.logoutQuietly(session);
+               super.dispose();
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+}
diff --git a/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/wizards/ConfirmOverwriteWizard.java b/legacy/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/wizards/ConfirmOverwriteWizard.java
new file mode 100644 (file)
index 0000000..d766219
--- /dev/null
@@ -0,0 +1,211 @@
+package org.argeo.slc.client.ui.wizards;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.SlcUiConstants;
+import org.argeo.slc.jcr.SlcJcrResultUtils;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+
+public class ConfirmOverwriteWizard extends Wizard {
+
+       // Define widget here to simplify getters
+       private Button overwriteBtn, renameBtn;
+       private Text newNameTxt;
+       private Label newNameLbl;
+
+       // business object
+       private String sourceNodeName;
+       private Node targetParentNode;
+
+       private String newName;
+       private String parentRelPath;
+       private boolean overwrite;
+
+       public ConfirmOverwriteWizard(String sourceNodeName, Node targetParentNode) {
+               setWindowTitle("Confirm overwrite or define a new name");
+               this.sourceNodeName = sourceNodeName;
+               this.targetParentNode = targetParentNode;
+       }
+
+       @Override
+       public void addPages() {
+               try {
+                       addPage(new MyPage());
+               } catch (Exception e) {
+                       throw new SlcException("Cannot add page to wizard ", e);
+               }
+               getShell().setImage(
+                               ClientUiPlugin.getDefault().getWorkbench().getSharedImages()
+                                               .getImageDescriptor(ISharedImages.IMG_LCL_LINKTO_HELP)
+                                               .createImage());
+       }
+
+       // Expose info to the calling view
+       public boolean overwrite() {
+               return overwrite;
+       }
+
+       public String newName() {
+               return newName;
+       }
+
+       @Override
+       public boolean performFinish() {
+               boolean doFinish = false;
+
+               if (canFinish()) {
+                       if (overwriteBtn.getSelection())
+                               doFinish = MessageDialog.openConfirm(Display.getDefault()
+                                               .getActiveShell(), "CAUTION", "All data contained in ["
+                                               + (parentRelPath != null ? parentRelPath : "")
+                                               + "/"+ sourceNodeName
+                                               + "] are about to be definitively destroyed. \n "
+                                               + "Are you sure you want to proceed ?");
+                       else
+                               doFinish = true;
+                       // cache values
+               }
+               if (doFinish) {
+                       overwrite = overwriteBtn.getSelection();
+                       newName = newNameTxt.getText();
+               }
+               return doFinish;
+       }
+
+       class MyPage extends WizardPage implements ModifyListener {
+
+               public MyPage() {
+                       super("");
+                       String msg = "An object with same name (" + sourceNodeName
+                                       + ") already exists at chosen target path";
+
+                       // Add target rel path to the message
+                       Session session;
+                       String relPath;
+                       try {
+                               session = targetParentNode.getSession();
+                               relPath = targetParentNode.getPath();
+                               String basePath = SlcJcrResultUtils
+                                               .getMyResultsBasePath(session);
+                               if (relPath.startsWith(basePath))
+                                       relPath = relPath.substring(basePath.length());
+                               // FIXME currently add the default base label
+                               parentRelPath = SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL
+                                               + relPath;
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Unexpected error while defining "
+                                               + "target parent node rel path", e);
+                       }
+                       msg = msg + (parentRelPath == null ? "." : ": \n" + parentRelPath);
+
+                       // Set Title
+                       setTitle(msg);
+               }
+
+               public void createControl(Composite parent) {
+                       Composite composite = new Composite(parent, SWT.NONE);
+                       composite.setLayout(new GridLayout(2, false));
+
+                       // choose between overwrite and rename
+                       overwriteBtn = new Button(composite, SWT.RADIO);
+                       overwriteBtn.setText("Overwrite");
+                       GridData gd = new GridData();
+                       gd.horizontalIndent = 30;
+                       gd.horizontalSpan = 2;
+                       overwriteBtn.setLayoutData(gd);
+                       overwriteBtn.setSelection(true);
+
+                       renameBtn = new Button(composite, SWT.RADIO);
+                       renameBtn.setText("Rename");
+                       renameBtn.setSelection(false);
+                       renameBtn.setText("Rename");
+                       gd = new GridData();
+                       gd.horizontalIndent = 30;
+                       gd.horizontalSpan = 2;
+                       renameBtn.setLayoutData(gd);
+
+                       newNameLbl = new Label(composite, SWT.LEAD);
+                       newNameLbl.setText("New name");
+                       newNameLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
+                                       false));
+                       newNameLbl.setEnabled(false);
+
+                       newNameTxt = new Text(composite, SWT.LEAD | SWT.BORDER);
+                       newNameTxt.setText(sourceNodeName);
+                       newNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
+                                       false));
+                       if (newNameTxt != null)
+                               newNameTxt.addModifyListener(this);
+                       newNameTxt.setEnabled(false);
+
+                       SelectionAdapter sa = new SelectionAdapter() {
+                               public void widgetSelected(SelectionEvent e) {
+                                       updateSelection(overwriteBtn.getSelection());
+                               }
+                       };
+                       overwriteBtn.addSelectionListener(sa);
+                       renameBtn.addSelectionListener(sa);
+
+                       // Compulsory
+                       setControl(composite);
+               }
+
+               private void updateSelection(boolean overwrite) {
+                       newNameLbl.setEnabled(!overwrite);
+                       newNameTxt.setEnabled(!overwrite);
+                       if (overwrite)
+                               setPageComplete(true);
+                       else
+                               checkComplete();
+               }
+
+               protected String getTechName() {
+                       return newNameTxt.getText();
+               }
+
+               public void modifyText(ModifyEvent event) {
+                       checkComplete();
+               }
+
+               private void checkComplete() {
+                       try {
+
+                               String newName = newNameTxt.getText();
+                               if (newName == null || "".equals(newName.trim())) {
+                                       setMessage("Name cannot be blank or empty",
+                                                       WizardPage.ERROR);
+                                       setPageComplete(false);
+                               } else if (targetParentNode.hasNode(newName)) {
+                                       setMessage("An object with the same name already exists.",
+                                                       WizardPage.ERROR);
+                                       setPageComplete(false);
+                               } else {
+                                       setMessage("Complete", WizardPage.INFORMATION);
+                                       setPageComplete(true);
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Unexpected error while checking "
+                                               + "children node with same name", e);
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.ant/.gitignore b/legacy/org.argeo.slc.demo.ant/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/org.argeo.slc.demo.ant/.project b/legacy/org.argeo.slc.demo.ant/.project
new file mode 100644 (file)
index 0000000..5a20f60
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.demo.ant</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <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>
+       </natures>
+</projectDescription>
diff --git a/legacy/org.argeo.slc.demo.ant/.settings/org.eclipse.pde.core.prefs b/legacy/org.argeo.slc.demo.ant/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..fd871b4
--- /dev/null
@@ -0,0 +1,4 @@
+#Wed Jan 06 20:27:20 CET 2010
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/legacy/org.argeo.slc.demo.ant/META-INF/.gitignore b/legacy/org.argeo.slc.demo.ant/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.demo.ant/META-INF/spring/ant.xml b/legacy/org.argeo.slc.demo.ant/META-INF/spring/ant.xml
new file mode 100644 (file)
index 0000000..3cff3b4
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="main" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean class="org.argeo.slc.ant.AntRun">\r
+                                       <property name="buildFile" value="osgibundle:/ant/hello/build.xml" />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.ant/META-INF/spring/flowGenerator.xml b/legacy/org.argeo.slc.demo.ant/META-INF/spring/flowGenerator.xml
new file mode 100644 (file)
index 0000000..d25caf9
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean class="org.argeo.slc.ant.AntFlowGenerator">\r
+               <property name="antFiles">\r
+                       <list>\r
+                               <value>osgibundle:/ant/hello/build.xml\r
+                               </value>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.ant/META-INF/spring/imports.xml b/legacy/org.argeo.slc.demo.ant/META-INF/spring/imports.xml
new file mode 100644 (file)
index 0000000..3428e8b
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <import resource="classpath:org/argeo/slc/core/execution/simple.xml" />
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.ant/META-INF/spring/osgi.xml b/legacy/org.argeo.slc.demo.ant/META-INF/spring/osgi.xml
new file mode 100644 (file)
index 0000000..f505229
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
+</beans:beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.ant/ant/hello/build.xml b/legacy/org.argeo.slc.demo.ant/ant/hello/build.xml
new file mode 100644 (file)
index 0000000..78dffa3
--- /dev/null
@@ -0,0 +1,5 @@
+<project default="hello">
+       <target name="hello">
+               <echo message="Hello World!" />
+       </target>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.ant/bnd.bnd b/legacy/org.argeo.slc.demo.ant/bnd.bnd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/legacy/org.argeo.slc.demo.ant/build.properties b/legacy/org.argeo.slc.demo.ant/build.properties
new file mode 100644 (file)
index 0000000..5f22cdd
--- /dev/null
@@ -0,0 +1 @@
+bin.includes = META-INF/
diff --git a/legacy/org.argeo.slc.demo.ant/pom.xml b/legacy/org.argeo.slc.demo.ant/pom.xml
new file mode 100644 (file)
index 0000000..761c208
--- /dev/null
@@ -0,0 +1,10 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>lib</artifactId>
+               <version>2.3-SNAPSHOT</version>
+       </parent>
+       <artifactId>org.argeo.slc.demo.ant</artifactId>
+       <name>SLC Demo Ant</name>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/.classpath b/legacy/org.argeo.slc.demo.basic/.classpath
new file mode 100644 (file)
index 0000000..acad1c2
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/legacy/org.argeo.slc.demo.basic/.gitignore b/legacy/org.argeo.slc.demo.basic/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/org.argeo.slc.demo.basic/.project b/legacy/org.argeo.slc.demo.basic/.project
new file mode 100644 (file)
index 0000000..1792645
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.demo.basic</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/legacy/org.argeo.slc.demo.basic/.settings/org.eclipse.pde.core.prefs b/legacy/org.argeo.slc.demo.basic/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..e2c3c3e
--- /dev/null
@@ -0,0 +1,5 @@
+#Fri Mar 13 13:44:23 CET 2009
+eclipse.preferences.version=1
+pluginProject.equinox=false
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/.gitignore b/legacy/org.argeo.slc.demo.basic/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/basic-001.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/basic-001.xml
new file mode 100644 (file)
index 0000000..cc121f2
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="basic.001" parent="basic.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="testData1" value-ref="basic.001.testData" />\r
+                               <entry key="testData2">\r
+                                       <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                               <aop:scoped-proxy />\r
+                                               <property name="expected" value="tata101" />\r
+                                               <property name="reached" value="tata@{testedComponentId}" />\r
+                                       </bean>\r
+                               </entry>\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+\r
+       <bean id="basic.001.testData" class="org.argeo.slc.runtime.test.BasicTestData"\r
+               scope="execution">\r
+               <aop:scoped-proxy />\r
+               <property name="expected" value="tata100" />\r
+               <property name="reached" value="tata@{testedComponentId}" />\r
+       </bean>\r
+\r
+       <bean id="basic.001.testData2" class="org.argeo.slc.core.test.context.DefaultContextTestData">\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/basic-002.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/basic-002.xml
new file mode 100644 (file)
index 0000000..4baf291
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <bean id="basic.002" parent="basic.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="testData1">\r
+                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                               <property name="expected" value="toto" />\r
+                                               <property name="reached" value="toto" />\r
+                                       </bean>\r
+                               </entry>\r
+                               <entry key="testData2">\r
+                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                               <property name="expected" value="tata" />\r
+                                               <property name="reached" value="toto" />\r
+                                       </bean>\r
+                               </entry>\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/basic.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/basic.xml
new file mode 100644 (file)
index 0000000..a2e34c1
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <bean id="basic.spec" parent="slcTemplate.simpleSpec">\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="testedComponentId">\r
+                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
+                                               p:type="integer" />\r
+                               </entry>\r
+                               <entry key="testData1">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
+                               </entry>\r
+                               <entry key="testData2">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="basic.flowTemplate" parent="slcTemplate.simpleFlow"\r
+               abstract="true">\r
+               <constructor-arg ref="basic.spec" />\r
+               <property name="path" value="/test/basic" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo" scope="execution">\r
+                                       <property name="message" value="From basic @{testedComponentId}" />\r
+                                       <aop:scoped-proxy />\r
+                               </bean>\r
+                               <bean parent="basic.testRun">\r
+                                       <property name="testDefinition" ref="basic.testDef" />\r
+                                       <property name="testData">\r
+                                               <bean parent="parameterRef">\r
+                                                       <constructor-arg value="testData1" />\r
+                                               </bean>\r
+                                       </property>\r
+                               </bean>\r
+                               <bean parent="basic.testRun">\r
+                                       <property name="testDefinition" ref="basic.testDef" />\r
+                                       <property name="testData" ref="ref1" />\r
+                               </bean>\r
+\r
+                               <bean class="org.argeo.slc.jcr.JcrMetadataWriter">\r
+                                       <property name="metadata">\r
+                                               <map>\r
+                                                       <entry key="metadata1" value="value1" />\r
+                                                       <entry key="slc:metadata2" value="value2" />\r
+                                               </map>\r
+                                       </property>\r
+                                       <property name="baseNode">\r
+                                               <bean factory-bean="basic.testResult" factory-method="getNode" />\r
+                                       </property>\r
+                                       <flow:variable />\r
+                               </bean>\r
+\r
+                               <!-- Attachments -->\r
+                               <bean parent="task.echo">\r
+                                       <property name="message" value="DATA" />\r
+                                       <property name="writeTo" ref="basic.writeTo" />\r
+                               </bean>\r
+\r
+                               <bean parent="task.uploadAttachments">\r
+                                       <property name="attachmentUploader" ref="attachmentUploader" />\r
+                                       <property name="attachment">\r
+                                               <bean parent="taskArg.attachment">\r
+                                                       <property name="name" value="myAttachment.txt" />\r
+                                               </bean>\r
+                                       </property>\r
+                                       <property name="resource" ref="basic.writeTo" />\r
+                                       <property name="attachTo">\r
+                                               <list>\r
+                                                       <ref bean="basic.testResult" />\r
+                                               </list>\r
+                                       </property>\r
+                               </bean>\r
+\r
+                               <bean parent="task.closeTestResult" scope="execution">\r
+                                       <property name="testResult" ref="basic.testResult" />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="ref1" parent="parameterRef" scope="prototype">\r
+               <constructor-arg value="testData2" />\r
+       </bean>\r
+\r
+       <bean id="basic.testData" class="org.argeo.slc.runtime.test.BasicTestData">\r
+               <aop:scoped-proxy />\r
+               <property name="expected" value="tata" />\r
+               <property name="reached" value="tata" />\r
+       </bean>\r
+\r
+       <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition"\r
+               scope="prototype" />\r
+\r
+       <bean id="basic.testResult" class="org.argeo.slc.jcr.JcrTestResult"\r
+               init-method="init" destroy-method="destroy">\r
+               <flow:variable />\r
+               <property name="resultType" value="slc:diffResult" />\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="testCase" value="@{slcVar.flow.name}" />\r
+                       </map>\r
+               </property>\r
+               <property name="repository" ref="repository" />\r
+       </bean>\r
+\r
+       <!-- <bean id="basic.testResult" parent="slcDefault.test.basicTreeTestResult" -->\r
+       <!-- scope="execution"> -->\r
+       <!-- <property name="listeners" ref="resultListeners" /> -->\r
+       <!-- <property name="attributes"> -->\r
+       <!-- <map> -->\r
+       <!-- <entry key="testedComponentId" value="@{testedComponentId}" /> -->\r
+       <!-- </map> -->\r
+       <!-- </property> -->\r
+       <!-- <aop:scoped-proxy /> -->\r
+       <!-- </bean> -->\r
+\r
+       <bean id="basic.testRun" class="org.argeo.slc.runtime.test.SimpleTestRun"\r
+               abstract="true">\r
+               <property name="testResult" ref="basic.testResult" />\r
+       </bean>\r
+\r
+       <bean id="basic.writeTo" factory-bean="basic.resourcesManager"\r
+               factory-method="getWritableResource" scope="execution">\r
+               <constructor-arg value="subdir/writeTo" />\r
+               <aop:scoped-proxy />\r
+       </bean>\r
+\r
+       <bean id="basic.resourcesManager" parent="slcTemplate.fileResources">\r
+               <property name="executionContext" ref="executionContext" />\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-001.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-001.xml
new file mode 100644 (file)
index 0000000..181e3e7
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="canonic.001" parent="canonic.flowTemplate">\r
+               <description>Canonic 001</description>\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation" value="1" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-002.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-002.xml
new file mode 100644 (file)
index 0000000..5916c08
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="canonic.002" parent="canonic.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation" value="2" />\r
+                               <entry key="displayWithoutControl" value="102" />\r
+                               <entry key="displayWithControl" value="202" />\r
+                               <entry key="hide" value="202" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-001.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-001.xml
new file mode 100644 (file)
index 0000000..5b1dbf6
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="canonic-ns.001" parent="canonic-ns.flowTemplate">\r
+               <description>Canonic 001</description>\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation" value="1" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-002.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns-002.xml
new file mode 100644 (file)
index 0000000..991f67f
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <flow:flow id="canonic-ns.002" parent="canonic-ns.flowTemplate">\r
+               <flow:arg name="parameterAtInstantiation" value="2" />\r
+               <flow:arg name="displayWithoutControl" value="102" />\r
+               <flow:arg name="displayWithControl" value="202" />\r
+               <flow:arg name="hide" value="202" />\r
+       </flow:flow>\r
+</beans>\r
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic-ns.xml
new file mode 100644 (file)
index 0000000..8fe234b
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <flow:spec id="canonic-ns.spec">\r
+               <flow:primitive name="parameterAtInstantiation"\r
+                       isParameter="true" type="integer" />\r
+               <flow:primitive name="displayWithoutControl" value="100"\r
+                       isParameter="true" type="integer" isFrozen="true" />\r
+               <flow:primitive name="displayWithControl" value="200"\r
+                       isParameter="true" type="integer" />\r
+               <flow:primitive name="hide" value="300" isParameter="true"\r
+                       type="integer" isHidden="true" />\r
+               <flow:ref name="refWithValue" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                       isParameter="true" ref="testDataNok" />\r
+               <flow:ref name="refWithoutValue" targetClass="org.argeo.slc.runtime.test.BasicTestData" />\r
+               <flow:ref name="refWithoutValueFrozen" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                       isParameter="true" isFrozen="true">\r
+                       <flow:value>\r
+                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                       <aop:scoped-proxy />\r
+                                       <property name="expected" value="tata" />\r
+                                       <property name="reached" value="tata" />\r
+                               </bean>\r
+                       </flow:value>\r
+               </flow:ref>\r
+       </flow:spec>\r
+\r
+       <flow:flow id="canonic-ns.flowTemplate" abstract="true"\r
+               spec="canonic-ns.spec">\r
+               <bean parent="task.echo"\r
+                       p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
+                       scope="execution">\r
+                       <aop:scoped-proxy />\r
+               </bean>\r
+       </flow:flow>\r
+\r
+       <bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
+               <aop:scoped-proxy />\r
+               <property name="expected" value="tata" />\r
+               <property name="reached" value="tata" />\r
+       </bean>\r
+\r
+       <bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
+               <aop:scoped-proxy />\r
+               <property name="expected" value="tata" />\r
+               <property name="reached" value="toto" />\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/canonic.xml
new file mode 100644 (file)
index 0000000..f45b1ae
--- /dev/null
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="canonic.spec" parent="slcTemplate.simpleSpec">\r
+               <description>Covers various combinations of specs</description>\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation">\r
+                                       <bean parent="specAttr.primitive" p:isParameter="true" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="displayWithoutControl">\r
+                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="false"\r
+                                               p:isFrozen="true" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="displayWithControl">\r
+                                       <bean parent="specAttr.primitive" p:value="200" p:isParameter="false"\r
+                                               p:isFrozen="false" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="hide">\r
+                                       <bean parent="specAttr.primitive" p:value="300" p:isParameter="true"\r
+                                               p:isFrozen="false" p:isHidden="true" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="refWithValue">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:value-ref="testDataNok" p:isParameter="true" p:isFrozen="false" />\r
+                               </entry>\r
+                               <entry key="refWithoutValue">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:isParameter="false" p:isFrozen="false" />\r
+                               </entry>\r
+                               <entry key="refWithoutValueFrozen">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true">\r
+                                               <property name="value">\r
+                                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                               <aop:scoped-proxy />\r
+                                                               <property name="expected" value="tata" />\r
+                                                               <property name="reached" value="tata" />\r
+                                                       </bean>\r
+                                               </property>\r
+                                       </bean>\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="canonic.flowTemplate" parent="slcTemplate.simpleFlow"\r
+               abstract="true">\r
+               <constructor-arg ref="canonic.spec" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo"\r
+                                       p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
+                                       scope="execution">\r
+                                       <aop:scoped-proxy />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
+               <aop:scoped-proxy />\r
+               <property name="expected" value="tata" />\r
+               <property name="reached" value="tata" />\r
+       </bean>\r
+\r
+       <bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
+               <aop:scoped-proxy />\r
+               <property name="expected" value="tata" />\r
+               <property name="reached" value="toto" />\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/imports.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/imports.xml
new file mode 100644 (file)
index 0000000..dc44a31
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />
+
+       <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />
+
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/main.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/main.xml
new file mode 100644 (file)
index 0000000..a2ee7a2
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <bean id="main" parent="slcTemplate.simpleFlow">\r
+               <description>The Main Flow</description>\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="testKey">\r
+                                                       <bean parent="specAttr.primitive" p:value="660" />\r
+                                               </entry>\r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+               <property name="executables">\r
+                       <list>\r
+                               <ref local="echo1" />\r
+                               <ref bean="basic.001" />\r
+                               <ref bean="basic.001" />\r
+                               <ref bean="basic.002" />\r
+                               <ref bean="canonic.001" />\r
+                               <ref bean="canonic.002" />\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="noArg" parent="slcTemplate.simpleFlow">\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo">\r
+                                       <property name="message" value="No arg!" />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="echo1" parent="task.echo" scope="execution">\r
+               <property name="message" value="From main! @{testKey}" />\r
+               <aop:scoped-proxy />\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/namespace.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/namespace.xml
new file mode 100644 (file)
index 0000000..610f5ee
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <!-- Flow definition is simplified thanks to the 'flow:flow' element -->\r
+       <flow:flow name="/namespace/flow" >\r
+               <bean p:message="TEST in flow" class="org.argeo.slc.core.execution.tasks.Echo" />\r
+               <ref bean="referencedRunnable" />\r
+       </flow:flow>\r
+\r
+       <bean id="referencedRunnable" p:message="TEST in referenced Runnable"\r
+               class="org.argeo.slc.core.execution.tasks.Echo" />\r
+\r
+       <!--\r
+               Standalone beans implementing Runnable can be exposed as flows via the\r
+               'flow:as-flow' attribute\r
+       -->\r
+       <bean id="standaloneRunnable" flow:as-flow="implicitFlow"\r
+               p:message="TEST in implicit flow" class="org.argeo.slc.core.execution.tasks.Echo" />\r
+\r
+       <!-- Specs definition is also simplified -->\r
+       <flow:spec id="namespaceSpec">\r
+               <flow:primitive name="primitive" value="100"\r
+                       isParameter="true" type="integer" />\r
+       </flow:spec>\r
+\r
+       <flow:flow name="/namespace/flowSpec" spec="namespaceSpec">\r
+               <bean p:message="TEST in flow @{primitive}" class="org.argeo.slc.core.execution.tasks.Echo"\r
+                       scope="execution">\r
+                       <aop:scoped-proxy />\r
+               </bean>\r
+               <ref bean="referencedRunnable" />\r
+       </flow:flow>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/osgi.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/osgi.xml
new file mode 100644 (file)
index 0000000..099ecd5
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
+\r
+       <reference id="attachmentUploader"\r
+               interface="org.argeo.slc.core.attachment.AttachmentUploader"\r
+               cardinality="0..1" />\r
+\r
+       <!-- REFERENCES -->\r
+       <reference id="repository" interface="javax.jcr.Repository"\r
+               filter="(cn=slc)" />\r
+</beans:beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/META-INF/spring/systemCall.xml b/legacy/org.argeo.slc.demo.basic/META-INF/spring/systemCall.xml
new file mode 100644 (file)
index 0000000..5b88539
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <!-- Basic echo, should work on all OSs -->\r
+       <flow:flow name="os/systemCall">\r
+               <bean p:cmd="echo Hello World!" class="org.argeo.slc.core.execution.tasks.SystemCall" />\r
+       </flow:flow>\r
+\r
+       <!-- Must disable requiretty in sudoers file -->\r
+       <flow:flow name="os/sudo">\r
+               <bean p:cmd="sudo id" class="org.argeo.slc.core.execution.tasks.SystemCall">\r
+                       <property name="environmentVariables">\r
+                               <map>\r
+                                       <entry key="SUDO_ASKPASS" value="/usr/libexec/openssh/gnome-ssh-askpass" />\r
+                               </map>\r
+                       </property>\r
+               </bean>\r
+       </flow:flow>\r
+\r
+       <!-- SSH -->\r
+       <flow:flow name="os/ssh">\r
+               <bean p:cmd="ls /etc" class="org.argeo.slc.core.execution.tasks.SystemCall">\r
+                       <property name="executor" ref="sshExecutor" />\r
+               </bean>\r
+       </flow:flow>\r
+\r
+       <bean name="sshExecutor" class="org.argeo.slc.jsch.JschExecutor">\r
+               <property name="sshTarget">\r
+                       <bean p:host="localhost" p:port="22" p:user="${user.name}"\r
+                               p:localPrivateKey="${user.home}/.ssh/id_rsa" class="org.argeo.slc.jsch.SshTarget">\r
+                               <property name="userInfo">\r
+                                       <bean class="org.argeo.slc.jsch.SwingUserInfo" />\r
+                               </property>\r
+                       </bean>\r
+               </property>\r
+       </bean>\r
+\r
+\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.basic/bnd.bnd b/legacy/org.argeo.slc.demo.basic/bnd.bnd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/legacy/org.argeo.slc.demo.basic/build.properties b/legacy/org.argeo.slc.demo.basic/build.properties
new file mode 100644 (file)
index 0000000..d7751b8
--- /dev/null
@@ -0,0 +1,6 @@
+bin.includes = .settings/,\
+               .project,\
+               META-INF/,\
+               conf/,\
+               pom.xml,\
+               .svn/
diff --git a/legacy/org.argeo.slc.demo.basic/pom.xml b/legacy/org.argeo.slc.demo.basic/pom.xml
new file mode 100644 (file)
index 0000000..0fda348
--- /dev/null
@@ -0,0 +1,41 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>lib</artifactId>
+               <version>2.3-SNAPSHOT</version>
+       </parent>
+       <artifactId>org.argeo.slc.demo.basic</artifactId>
+       <name>SLC Demo Basic</name>
+<!--   <build> -->
+<!--           <plugins> -->
+<!--                   <plugin> -->
+<!--                           <groupId>org.apache.felix</groupId> -->
+<!--                           <artifactId>maven-bundle-plugin</artifactId> -->
+<!--                           <configuration> -->
+<!--                                   <instructions> -->
+<!--                                           <SLC-ExecutionModule>default</SLC-ExecutionModule> -->
+<!--                                           <Import-Package> -->
+<!--                                                   *, -->
+<!--                                                   org.argeo.slc.core.structure.tree, -->
+
+<!--                                                   net.sf.cglib.core, -->
+<!--                                                   net.sf.cglib.proxy, -->
+<!--                                                   net.sf.cglib.reflect, -->
+<!--                                                   org.aopalliance.aop, -->
+<!--                                                   org.argeo.slc.core.execution, -->
+<!--                                                   org.argeo.slc.core.execution.tasks, -->
+<!--                                                   org.argeo.slc.execution, -->
+<!--                                                   org.argeo.slc.osgi, -->
+<!--                                                   org.springframework.aop, -->
+<!--                                                   org.springframework.aop.framework, -->
+<!--                                                   org.springframework.aop.scope, -->
+<!--                                                   org.springframework.beans.factory.config, -->
+<!--                                                   org.springframework.core.io,                                                                                             -->
+<!--                                           </Import-Package> -->
+<!--                                   </instructions> -->
+<!--                           </configuration> -->
+<!--                   </plugin> -->
+<!--           </plugins> -->
+<!--   </build> -->
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.minimal/.gitignore b/legacy/org.argeo.slc.demo.minimal/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/org.argeo.slc.demo.minimal/.project b/legacy/org.argeo.slc.demo.minimal/.project
new file mode 100644 (file)
index 0000000..ba8b1b5
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.demo.minimal</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <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>
+       </natures>
+</projectDescription>
diff --git a/legacy/org.argeo.slc.demo.minimal/.settings/org.eclipse.pde.core.prefs b/legacy/org.argeo.slc.demo.minimal/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..5886cbf
--- /dev/null
@@ -0,0 +1,4 @@
+#Wed Jan 06 20:27:49 CET 2010
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/legacy/org.argeo.slc.demo.minimal/META-INF/.gitignore b/legacy/org.argeo.slc.demo.minimal/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.demo.minimal/META-INF/spring/common.xml b/legacy/org.argeo.slc.demo.minimal/META-INF/spring/common.xml
new file mode 100644 (file)
index 0000000..a753d4e
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+       <import resource="classpath:org/argeo/slc/core/execution/simple.xml" />
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.minimal/META-INF/spring/helloworld-raw.xml b/legacy/org.argeo.slc.demo.minimal/META-INF/spring/helloworld-raw.xml
new file mode 100644 (file)
index 0000000..6f61494
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"\r
+       >\r
+\r
+       <!-- Hello world without namespace (for reference, do not use) -->\r
+       <bean name="HelloWorld/Raw" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
+               <description>Print Hello World!</description>\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean p:message="Hello World!" class="org.argeo.slc.core.execution.tasks.Echo" />\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean name="HelloWorld/RawWithVar" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
+               <description>Print Hello World! with variable</description>\r
+               <constructor-arg>\r
+                       <bean class="org.argeo.slc.core.execution.DefaultExecutionSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="testKey">\r
+                                                       <bean p:value="777"\r
+                                                               class="org.argeo.slc.primitive.PrimitiveSpecAttribute" />\r
+                                               </entry>\r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean p:message="Hello World! @{testKey}" class="org.argeo.slc.core.execution.tasks.Echo"\r
+                                       scope="execution">\r
+                                       <aop:scoped-proxy proxy-target-class="false" />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml b/legacy/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml
new file mode 100644 (file)
index 0000000..0d249dc
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-1.2.xsd">\r
+\r
+       <!-- Hello world -->\r
+       <flow:flow name="hello">\r
+               <description>Print Hello World!</description>\r
+               <bean p:message="Hello World!" class="org.argeo.slc.core.execution.tasks.Echo" />\r
+       </flow:flow>\r
+\r
+\r
+       <flow:flow name="HelloWorld/WithVar">\r
+               <description>Print Hello World! with variable</description>\r
+               <flow:spec>\r
+                       <flow:primitive name="testKey" value="777" />\r
+               </flow:spec>\r
+               <bean p:message="Hello World! @{testKey}" class="org.argeo.slc.core.execution.tasks.Echo">\r
+                       <flow:variable proxy-target-class="false" />\r
+               </bean>\r
+       </flow:flow>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.minimal/META-INF/spring/osgi.xml b/legacy/org.argeo.slc.demo.minimal/META-INF/spring/osgi.xml
new file mode 100644 (file)
index 0000000..f505229
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
+</beans:beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.minimal/bnd.bnd b/legacy/org.argeo.slc.demo.minimal/bnd.bnd
new file mode 100644 (file)
index 0000000..758b56d
--- /dev/null
@@ -0,0 +1,2 @@
+#Import-Package: org.argeo.slc.runtime,\
+#*
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.demo.minimal/build.properties b/legacy/org.argeo.slc.demo.minimal/build.properties
new file mode 100644 (file)
index 0000000..5f22cdd
--- /dev/null
@@ -0,0 +1 @@
+bin.includes = META-INF/
diff --git a/legacy/org.argeo.slc.demo.minimal/pom.xml b/legacy/org.argeo.slc.demo.minimal/pom.xml
new file mode 100644 (file)
index 0000000..86a74c5
--- /dev/null
@@ -0,0 +1,10 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>lib</artifactId>
+               <version>2.3-SNAPSHOT</version>
+       </parent>
+       <artifactId>org.argeo.slc.demo.minimal</artifactId>
+       <name>SLC Demo Minimal</name>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.launcher/.classpath b/legacy/org.argeo.slc.launcher/.classpath
new file mode 100644 (file)
index 0000000..5609932
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" output="target/classes" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/legacy/org.argeo.slc.launcher/.gitignore b/legacy/org.argeo.slc.launcher/.gitignore
new file mode 100644 (file)
index 0000000..c2bdee8
--- /dev/null
@@ -0,0 +1,2 @@
+/target/
+/.slc/
diff --git a/legacy/org.argeo.slc.launcher/.project b/legacy/org.argeo.slc.launcher/.project
new file mode 100644 (file)
index 0000000..7254f6d
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.launcher</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.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/legacy/org.argeo.slc.launcher/META-INF/.gitignore b/legacy/org.argeo.slc.launcher/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.launcher/bnd.bnd b/legacy/org.argeo.slc.launcher/bnd.bnd
new file mode 100644 (file)
index 0000000..8acf4c9
--- /dev/null
@@ -0,0 +1 @@
+Main-Class: org.argeo.slc.cli.SlcMain
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.launcher/build.properties b/legacy/org.argeo.slc.launcher/build.properties
new file mode 100644 (file)
index 0000000..f0cc4f1
--- /dev/null
@@ -0,0 +1,2 @@
+source.. = src/main/java/,\
+           src/main/resources/
diff --git a/legacy/org.argeo.slc.launcher/pom.xml b/legacy/org.argeo.slc.launcher/pom.xml
new file mode 100644 (file)
index 0000000..c073f60
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.launcher</artifactId>
+       <packaging>jar</packaging>
+       <name>SLC Launcher</name>
+       <build>
+               <plugins>
+<!--                   <plugin> -->
+<!--                           <groupId>org.apache.maven.plugins</groupId> -->
+<!--                           <artifactId>maven-assembly-plugin</artifactId> -->
+<!--                           <configuration> -->
+<!--                                   <descriptors> -->
+<!--                                           <descriptor>assembly/base.xml</descriptor> -->
+<!--                                   </descriptors> -->
+<!--                           </configuration> -->
+<!--                           <executions> -->
+<!--                                   <execution> -->
+<!--                                           <id>assembly-base</id> -->
+<!--                                           <phase>package</phase> -->
+<!--                                           <goals> -->
+<!--                                                   <goal>single</goal> -->
+<!--                                           </goals> -->
+<!--                                   </execution> -->
+<!--                           </executions> -->
+<!--                   </plugin> -->
+<!--                   <plugin> -->
+<!--                           <groupId>org.apache.felix</groupId> -->
+<!--                           <artifactId>maven-bundle-plugin</artifactId> -->
+<!--                           <configuration> -->
+<!--                                   <instructions> -->
+<!--                                           <Main-Class>org.argeo.slc.cli.SlcMain</Main-Class> -->
+<!--                                   </instructions> -->
+<!--                           </configuration> -->
+<!--                   </plugin> -->
+<!--                   <plugin> -->
+<!--                           <artifactId>maven-resources-plugin</artifactId> -->
+<!--                           <executions> -->
+<!--                                   <execution> -->
+<!--                                           <phase>validate</phase> -->
+<!--                                           <goals> -->
+<!--                                                   <goal>copy-resources</goal> -->
+<!--                                           </goals> -->
+<!--                                           <configuration> -->
+<!--                                                   <outputDirectory>${basedir}/target/base</outputDirectory> -->
+<!--                                                   <resources> -->
+<!--                                                           <resource> -->
+<!--                                                                   <directory>base</directory> -->
+<!--                                                                   <filtering>true</filtering> -->
+<!--                                                           </resource> -->
+<!--                                                   </resources> -->
+<!--                                           </configuration> -->
+<!--                                   </execution> -->
+<!--                           </executions> -->
+<!--                   </plugin> -->
+               </plugins>
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.osgi.boot</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java b/legacy/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java
new file mode 100644 (file)
index 0000000..8717b50
--- /dev/null
@@ -0,0 +1,323 @@
+package org.argeo.slc.cli;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.UUID;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+
+import org.argeo.osgi.boot.OsgiBoot;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/** Configures an SLC runtime and runs a process. */
+public class SlcMain implements PrivilegedAction<String> {
+       public final static String NIX = "NIX";
+       public final static String WINDOWS = "WINDOWS";
+       public final static String SOLARIS = "SOLARIS";
+
+       public final static String os;
+       public final static String slcDirName = ".slc";
+       final static File homeDir = new File(System.getProperty("user.home"));
+
+       static {
+               String osName = System.getProperty("os.name");
+               if (osName.startsWith("Win"))
+                       os = WINDOWS;
+               else if (osName.startsWith("Solaris"))
+                       os = SOLARIS;
+               else
+                       os = NIX;
+       }
+
+       private Long timeout = 30 * 1000l;
+       private final String[] args;
+       private final File confDir;
+       private final File dataDir;
+       private final File modulesDir;
+
+       private final List<String> bundlesToStart = new ArrayList<String>();
+
+       public SlcMain(String[] args, File confDir, File dataDir, File modulesDir) {
+               this.args = args;
+               this.confDir = confDir;
+               this.dataDir = dataDir;
+               this.modulesDir = modulesDir;
+
+               bundlesToStart.add("org.eclipse.equinox.cm");
+               bundlesToStart.add("org.argeo.cms");
+               bundlesToStart.add("org.eclipse.gemini.blueprint.extender");
+               bundlesToStart.add("org.argeo.slc.agent");
+               bundlesToStart.add("org.argeo.slc.agent.jcr");
+
+               // bundlesToStart.add("org.springframework.osgi.extender");
+               // bundlesToStart.add("org.argeo.node.repo.jackrabbit");
+               // bundlesToStart.add("org.argeo.security.dao.os");
+               // bundlesToStart.add("org.argeo.slc.node.jackrabbit");
+               // bundlesToStart.add("org.argeo.slc.agent");
+               // bundlesToStart.add("org.argeo.slc.agent.jcr");
+               // if (args.length == 0)
+               // bundlesToStart.add("org.argeo.slc.support.equinox");
+               // bundlesToStart.add("org.argeo.slc.agent.cli");
+       }
+
+       public String run() {
+               long begin = System.currentTimeMillis();
+
+               Framework framework = null;
+               try {
+                       info("## Date : " + new Date());
+                       info("## Data : " + dataDir.getCanonicalPath());
+
+                       // Start Equinox
+                       ServiceLoader<FrameworkFactory> ff = ServiceLoader.load(FrameworkFactory.class);
+                       FrameworkFactory frameworkFactory = ff.iterator().next();
+                       Map<String, String> configuration = new HashMap<String, String>();
+                       configuration.put("osgi.configuration.area", confDir.getCanonicalPath());
+                       configuration.put("osgi.instance.area", dataDir.getCanonicalPath());
+                       // Do clean
+                       configuration.put("osgi.clean", "true");
+                       if (args.length == 0) {
+                               configuration.put("osgi.console", "");
+                       }
+
+                       // Spring configs currently require System properties
+                       System.getProperties().putAll(configuration);
+
+                       framework = frameworkFactory.newFramework(configuration);
+                       framework.start();
+                       BundleContext bundleContext = framework.getBundleContext();
+
+                       // OSGi bootstrap
+                       OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
+
+                       // working copy modules
+                       if (modulesDir.exists())
+                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(modulesDir.getCanonicalPath() + ";in=*;ex=.gitignore"));
+
+                       // system modules
+                       if (System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES) != null)
+                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES)));
+                       else
+                               osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty("user.home") + "/.slc/modules/;in=**"));
+
+                       // Start runtime
+                       osgiBoot.startBundles(bundlesToStart);
+
+                       // Find SLC Agent
+                       ServiceReference sr = null;
+                       while (sr == null) {
+                               sr = bundleContext.getServiceReference("org.argeo.slc.execution.SlcAgentCli");
+                               if (System.currentTimeMillis() - begin > timeout)
+                                       throw new RuntimeException("Cannot find SLC agent CLI");
+                               Thread.sleep(100);
+                       }
+                       Object agentCli = bundleContext.getService(sr);
+
+                       // Initialization completed
+                       long duration = System.currentTimeMillis() - begin;
+                       info("[[ Initialized in " + (duration / 1000) + "s " + (duration % 1000) + "ms ]]");
+
+                       if (args.length == 0)
+                               return null;// console mode
+
+                       // Subject.doAs(Subject.getSubject(AccessController.getContext()),
+                       // new AgentCliCall(agentCli));
+                       Class<?>[] parameterTypes = { String[].class };
+                       Method method = agentCli.getClass().getMethod("process", parameterTypes);
+                       Object[] methodArgs = { args };
+                       Object ret = method.invoke(agentCli, methodArgs);
+
+                       // Shutdown OSGi runtime
+                       framework.stop();
+                       framework.waitForStop(60 * 1000);
+
+                       return ret.toString();
+               } catch (Exception e) {
+                       // Shutdown OSGi runtime
+                       if (framework != null)
+                               try {
+                                       framework.stop();
+                                       framework.waitForStop(15 * 1000);
+                               } catch (Exception silent) {
+                               }
+                       throw new RuntimeException("Cannot run SLC command line", e);
+               } finally {
+
+               }
+       }
+
+       public static void main(String[] args) {
+               try {
+                       // Prepare directories
+                       File executionDir = new File(System.getProperty("user.dir"));
+                       File slcDir;
+                       Boolean isTransient = false;
+                       if (isTransient) {
+                               File tempDir = new File(System.getProperty("java.io.tmpdir") + "/" + System.getProperty("user.name"));
+                               slcDir = new File(tempDir, "slc-" + UUID.randomUUID().toString());
+                               slcDir.mkdirs();
+                               System.setProperty("argeo.node.repo.configuration", "osgibundle:repository-memory.xml");
+                       } else {
+                               slcDir = findSlcDir(executionDir);
+                               if (slcDir == null) {
+                                       slcDir = new File(executionDir, slcDirName);
+                                       slcDir.mkdirs();
+                                       info("## Creating an SLC node at " + slcDir + " ...");
+                               }
+                       }
+
+                       File dataDir = new File(slcDir, "data");
+                       if (!dataDir.exists())
+                               dataDir.mkdirs();
+
+                       File confDir = new File(slcDir, "conf");
+                       if (!confDir.exists())
+                               confDir.mkdirs();
+
+                       File modulesDir = new File(slcDir, "modules");
+
+                       // JAAS
+                       // File jaasFile = new File(confDir, "jaas.config");
+                       // if (!jaasFile.exists())
+                       // copyResource("/org/argeo/slc/cli/jaas.config", jaasFile);
+                       // System.setProperty("java.security.auth.login.config",
+                       // jaasFile.getCanonicalPath());
+
+                       // log4j
+                       File log4jFile = new File(confDir, "log4j.properties");
+                       if (!log4jFile.exists())
+                               copyResource("/org/argeo/slc/cli/log4j.properties", log4jFile);
+                       System.setProperty("log4j.configuration", "file://" + log4jFile.getCanonicalPath());
+                       // Run as a privileged action
+                       // LoginContext lc = new LoginContext(os);
+                       // lc.login();
+                       //
+                       // Subject subject =
+                       // Subject.getSubject(AccessController.getContext());
+                       // Subject.doAs(subject, new SlcMain(args, confDir, dataDir,
+                       // modulesDir));
+                       SlcMain slcMain = new SlcMain(args, confDir, dataDir, modulesDir);
+                       slcMain.run();
+                       if (args.length != 0)
+                               System.exit(0);
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       System.exit(1);
+               }
+       }
+
+       /**
+        * Recursively look in parent directories for a directory named
+        * {@link #slcDirName}
+        */
+       protected static File findSlcDir(File currentDir) {
+               File slcDir = new File(currentDir, slcDirName);
+               // covers the use case of running from the home directory
+               if (slcDir.exists() && slcDir.isDirectory())
+                       return slcDir;
+               File parentDir = currentDir.getParentFile();
+               if (parentDir == null)
+                       return null;
+               try {
+                       // ~/.slc reserved for agent
+                       if (parentDir.getCanonicalPath().equals(homeDir.getCanonicalPath()))
+                               return null;
+               } catch (IOException e) {
+                       throw new RuntimeException("Cannot check home directory", e);
+               }
+               return findSlcDir(parentDir);
+       }
+
+       protected static void copyResource(String resource, File targetFile) {
+               InputStream input = null;
+               FileOutputStream output = null;
+               try {
+                       input = SlcMain.class.getResourceAsStream(resource);
+                       output = new FileOutputStream(targetFile);
+                       byte[] buf = new byte[8192];
+                       while (true) {
+                               int length = input.read(buf);
+                               if (length < 0)
+                                       break;
+                               output.write(buf, 0, length);
+                       }
+               } catch (Exception e) {
+                       throw new RuntimeException("Cannot write " + resource + " file to " + targetFile, e);
+               } finally {
+                       try {
+                               input.close();
+                       } catch (Exception ignore) {
+                       }
+                       try {
+                               output.close();
+                       } catch (Exception ignore) {
+                       }
+               }
+
+       }
+
+       protected static void info(Object msg) {
+               System.out.println(msg);
+       }
+
+       protected static void err(Object msg) {
+               System.err.println(msg);
+       }
+
+       protected static void debug(Object msg) {
+               System.out.println(msg);
+       }
+
+}
+
+// private String bundlesToInstall = System.getProperty("user.home")
+// +
+// "/dev/src/slc/dep/org.argeo.slc.dep.minimal/target/dependency;in=*.jar,"
+// + System.getProperty("user.home")
+// + "/dev/src/slc/demo/modules;in=*;ex=pom.xml;ex=.svn";
+
+// ServiceTracker agentTracker = new ServiceTracker(bundleContext,
+// "org.argeo.slc.execution.SlcAgentCli", null);
+// agentTracker.open();
+// final Object agentCli = agentTracker.waitForService(30 * 1000);
+// if (agentCli == null)
+// throw new RuntimeException("Cannot find SLC agent CLI");
+
+// protected class AgentCliCall implements PrivilegedAction<String> {
+// private final Object agentCli;
+//
+// public AgentCliCall(Object agentCli) {
+// super();
+// this.agentCli = agentCli;
+// }
+//
+// public String run() {
+// try {
+// Class<?>[] parameterTypes = { String[].class };
+// Method method = agentCli.getClass().getMethod("process",
+// parameterTypes);
+// Object[] methodArgs = { args };
+// Object ret = method.invoke(agentCli, methodArgs);
+// return ret.toString();
+// } catch (Exception e) {
+// throw new RuntimeException("Cannot run "
+// + Arrays.toString(args) + " on " + agentCli, e);
+// }
+// }
+//
+// }
diff --git a/legacy/org.argeo.slc.launcher/src/org/argeo/slc/cli/jaas.config b/legacy/org.argeo.slc.launcher/src/org/argeo/slc/cli/jaas.config
new file mode 100644 (file)
index 0000000..2fc1198
--- /dev/null
@@ -0,0 +1,7 @@
+NIX {
+   com.sun.security.auth.module.UnixLoginModule required;
+};
+
+WINDOWS {
+   com.sun.security.auth.module.NTLoginModule required;
+};
diff --git a/legacy/org.argeo.slc.launcher/src/org/argeo/slc/cli/log4j.properties b/legacy/org.argeo.slc.launcher/src/org/argeo/slc/cli/log4j.properties
new file mode 100644 (file)
index 0000000..6770d0a
--- /dev/null
@@ -0,0 +1,20 @@
+log4j.rootLogger=WARN, console
+#log4j.rootLogger=DEBUG, development
+
+## Levels
+log4j.logger.org.argeo=INFO
+
+log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR
+log4j.logger.org.apache.jackrabbit.core.config.ConfigurationErrorHandler=ERROR
+log4j.logger.org.apache.jackrabbit.core.util.db.DbUtility=FATAL
+
+## Appenders
+# default appender
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %m%n
+
+# development appender
+log4j.appender.development=org.apache.log4j.ConsoleAppender
+log4j.appender.development.layout=org.apache.log4j.PatternLayout
+log4j.appender.development.layout.ConversionPattern=%d{HH:mm:ss,SSS} %5p %m [%16.16t] %c%n
diff --git a/legacy/org.argeo.slc.server.repo/.gitignore b/legacy/org.argeo.slc.server.repo/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/legacy/org.argeo.slc.server.repo/.project b/legacy/org.argeo.slc.server.repo/.project
new file mode 100644 (file)
index 0000000..8cec3fd
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.server.repo</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <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>
+       </natures>
+</projectDescription>
diff --git a/legacy/org.argeo.slc.server.repo/.settings/org.eclipse.pde.core.prefs b/legacy/org.argeo.slc.server.repo/.settings/org.eclipse.pde.core.prefs
new file mode 100644 (file)
index 0000000..b3540fa
--- /dev/null
@@ -0,0 +1,4 @@
+#Sun Feb 06 14:17:19 CET 2011
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/legacy/org.argeo.slc.server.repo/META-INF/.gitignore b/legacy/org.argeo.slc.server.repo/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.server.repo/META-INF/spring/jcr.xml b/legacy/org.argeo.slc.server.repo/META-INF/spring/jcr.xml
new file mode 100644 (file)
index 0000000..423779b
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <!-- JCR repositories -->\r
+       <!-- <bean id="javaRepository" parent="template.jcrRepository"> -->\r
+       <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/java" \r
+               /> -->\r
+       <!-- <property name="configuration" value="${slc.repo.jcr.configuration.java}" \r
+               /> -->\r
+       <!-- </bean> -->\r
+       <!-- <bean id="distRepository" parent="template.jcrRepository"> -->\r
+       <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/dist" \r
+               /> -->\r
+       <!-- <property name="configuration" value="${slc.repo.jcr.configuration.dist}" \r
+               /> -->\r
+       <!-- </bean> -->\r
+       <!-- <bean id="rpmRepository" parent="template.jcrRepository"> -->\r
+       <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/rpm" \r
+               /> -->\r
+       <!-- <property name="configuration" value="${slc.repo.jcr.configuration.rpm}" \r
+               /> -->\r
+       <!-- </bean> -->\r
+       <!-- <bean id="docsRepository" parent="template.jcrRepository"> -->\r
+       <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/docs" \r
+               /> -->\r
+       <!-- <property name="configuration" value="${slc.repo.jcr.configuration.docs}" \r
+               /> -->\r
+       <!-- </bean> -->\r
+\r
+       <!-- JCR authorizations -->\r
+       <bean parent="template.jcrAuthorizations">\r
+               <property name="repository" ref="javaRepository" />\r
+       </bean>\r
+       <bean parent="template.jcrAuthorizations">\r
+               <property name="repository" ref="distRepository" />\r
+       </bean>\r
+       <bean parent="template.jcrAuthorizations">\r
+               <property name="repository" ref="rpmRepository" />\r
+       </bean>\r
+       <bean parent="template.jcrAuthorizations">\r
+               <property name="repository" ref="docsRepository" />\r
+       </bean>\r
+\r
+       <!-- Templates -->\r
+       <!-- <bean id="template.jcrRepository" abstract="true" -->\r
+       <!-- class="org.argeo.jackrabbit.JackrabbitContainer" init-method="init" -->\r
+       <!-- destroy-method="destroy"> -->\r
+       <!-- <property name="variables" value="osgibundle:/repo.properties" /> -->\r
+       <!-- <property name="cndFiles"> -->\r
+       <!-- <list> -->\r
+       <!-- <value>/org/argeo/jcr/argeo.cnd</value> -->\r
+       <!-- <value>/org/argeo/slc/jcr/slc.cnd</value> -->\r
+       <!-- <value>/org/argeo/slc/repo/repo.cnd</value> -->\r
+       <!-- </list> -->\r
+       <!-- </property> -->\r
+       <!-- <property name="bundleContext" ref="bundleContext" /> -->\r
+       <!-- <property name="forceCndImport" value="${slc.repo.jcr.forceCndImport}" \r
+               /> -->\r
+       <!-- </bean> -->\r
+\r
+       <bean id="template.jcrAuthorizations" abstract="true"\r
+               class="org.argeo.jcr.JcrAuthorizations" init-method="run">\r
+               <property name="principalPrivileges">\r
+                       <map>\r
+                               <entry key="jcr:all" value="cn=org.argeo.slc.user,ou=roles,ou=node" />\r
+                       </map>\r
+               </property>\r
+               <property name="workspace" value="*" />\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.server.repo/META-INF/spring/repo-osgi.xml b/legacy/org.argeo.slc.server.repo/META-INF/spring/repo-osgi.xml
new file mode 100644 (file)
index 0000000..830303c
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xmlns:security="http://www.springframework.org/schema/security"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd">\r
+\r
+       <!-- REFERENCES -->\r
+       <reference id="userAdmin" interface="org.osgi.service.useradmin.UserAdmin" />\r
+       <reference id="userTransaction" interface="javax.transaction.UserTransaction" />\r
+\r
+       <set id="defaultRpmRepositories" cardinality="0..N"\r
+               interface="org.argeo.slc.rpmfactory.RpmRepository" />\r
+\r
+       <reference id="javaRepository" interface="javax.jcr.Repository"\r
+               filter="(cn=java)" />\r
+       <reference id="distRepository" interface="javax.jcr.Repository"\r
+               filter="(cn=dist)" />\r
+       <reference id="rpmRepository" interface="javax.jcr.Repository"\r
+               filter="(cn=rpm)" />\r
+       <reference id="docsRepository" interface="javax.jcr.Repository"\r
+               filter="(cn=docs)" />\r
+\r
+       <!-- SERVICES -->\r
+       <service ref="slcRepoManager" interface="org.argeo.slc.repo.SlcRepoManager" />\r
+\r
+<!--   <service ref="mavenProxyService" interface="org.argeo.slc.repo.MavenProxyService" /> -->\r
+<!--   <service ref="rpmProxyService" interface="org.argeo.slc.rpmfactory.RpmProxyService" /> -->\r
+\r
+       <!-- LABEL -->\r
+       <beans:bean class="org.argeo.cms.spring.osgi.OsgiModuleLabel">\r
+               <beans:property name="bundleContext" ref="bundleContext" />\r
+       </beans:bean>\r
+\r
+       <!-- ROLES -->\r
+       <beans:bean id="ROLE_SLC"\r
+               class="org.argeo.cms.spring.SimpleRoleRegistration" init-method="run">\r
+               <beans:property name="role" value="org.argeo.slc.user" />\r
+               <beans:property name="userAdmin" ref="userAdmin" />\r
+               <beans:property name="userTransaction" ref="userTransaction" />\r
+       </beans:bean>\r
+\r
+       <beans:bean\r
+               class="org.argeo.cms.spring.AuthenticatedApplicationContextInitialization">\r
+       </beans:bean>\r
+</beans:beans>\r
+\r
+<!-- <reference id="mavenRepositorySystem" interface="org.sonatype.aether.RepositorySystem" -->\r
+<!-- filter="(aether.repositorySystemType=maven)" /> -->\r
+<!-- <reference id="mavenRepositorySystemSession" interface="org.sonatype.aether.RepositorySystemSession" -->\r
+<!-- filter="(aether.repositorySystemType=maven)" /> -->\r
+\r
diff --git a/legacy/org.argeo.slc.server.repo/META-INF/spring/services.xml b/legacy/org.argeo.slc.server.repo/META-INF/spring/services.xml
new file mode 100644 (file)
index 0000000..454009e
--- /dev/null
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
+       ">
+
+       <bean
+               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
+               <property name="locations">
+                       <value>osgibundle:repo.properties</value>
+               </property>
+       </bean>
+
+       <bean id="slcRepoManager" class="org.argeo.slc.repo.core.SlcRepoManagerImpl"
+               init-method="init" destroy-method="destroy">
+               <property name="javaRepoManager" ref="javaRepoManager" />
+       </bean>
+
+       <!-- Java -->
+       <bean id="javaRepoManager" class="org.argeo.slc.repo.core.JavaRepoManagerImpl"
+               init-method="init" destroy-method="destroy" depends-on="ROLE_SLC">
+               <property name="nodeIndexers">
+                       <list>
+                               <bean class="org.argeo.slc.repo.ModularDistributionIndexer" />
+                               <bean class="org.argeo.slc.repo.JarFileIndexer" />
+                               <bean class="org.argeo.slc.repo.ArtifactIndexer" />
+                               <bean class="org.argeo.slc.repo.PdeSourcesIndexer" />
+                       </list>
+               </property>
+               <property name="jcrRepository" ref="javaRepository" />
+       </bean>
+
+       <!-- <bean id="mavenProxyService" class="org.argeo.slc.repo.maven.MavenProxyServiceImpl" -->
+       <!-- init-method="init" destroy-method="destroy" depends-on="ROLE_SLC"> -->
+       <!-- <property name="jcrRepository" ref="javaRepository" /> -->
+       <!-- <property name="proxyWorkspace" value="${slc.repo.jcr.proxyWorkspace}" 
+               /> -->
+       <!-- <property name="defaultRepositories" ref="defaultMavenRepositories" 
+               /> -->
+       <!-- </bean> -->
+
+       <!-- RPM -->
+       <bean id="rpmRepoManager" class="org.argeo.slc.repo.core.RpmRepoManagerImpl"
+               init-method="init" destroy-method="destroy" depends-on="ROLE_SLC">
+               <property name="nodeIndexers">
+                       <list>
+                               <bean class="org.argeo.slc.repo.RpmIndexer" />
+                       </list>
+               </property>
+               <property name="jcrRepository" ref="rpmRepository" />
+       </bean>
+
+       <!-- <bean id="rpmProxyService" class="org.argeo.slc.rpmfactory.core.RpmProxyServiceImpl" -->
+       <!-- init-method="init" destroy-method="destroy" depends-on="ROLE_SLC"> -->
+       <!-- <property name="jcrRepository" ref="rpmRepository" /> -->
+       <!-- <property name="proxyWorkspace" value="${slc.repo.jcr.proxyWorkspace}" 
+               /> -->
+       <!-- <property name="defaultRepositories" ref="defaultRpmRepositories" /> -->
+       <!-- </bean> -->
+
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.server.repo/bnd.bnd b/legacy/org.argeo.slc.server.repo/bnd.bnd
new file mode 100644 (file)
index 0000000..45f2f02
--- /dev/null
@@ -0,0 +1,8 @@
+Import-Package: org.argeo.jcr,\
+org.argeo.security.jackrabbit,\
+org.argeo.slc.jcr,\
+org.argeo.slc.repo,\
+org.h2;resolution:=optional,\
+org.postgresql;resolution:=optional,\
+org.osgi.*;version=0.0.0,\
+*
diff --git a/legacy/org.argeo.slc.server.repo/build.properties b/legacy/org.argeo.slc.server.repo/build.properties
new file mode 100644 (file)
index 0000000..ba1e43a
--- /dev/null
@@ -0,0 +1,3 @@
+bin.includes = META-INF/,\
+               repo.properties,\
+               repository-h2.xml
diff --git a/legacy/org.argeo.slc.server.repo/pom.xml b/legacy/org.argeo.slc.server.repo/pom.xml
new file mode 100644 (file)
index 0000000..a34ec70
--- /dev/null
@@ -0,0 +1,11 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.server.repo</artifactId>
+       <name>SLC Repo</name>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.server.repo/repo.properties b/legacy/org.argeo.slc.server.repo/repo.properties
new file mode 100644 (file)
index 0000000..8c10e86
--- /dev/null
@@ -0,0 +1,23 @@
+slc.repo.jcr.reposBase=${osgi.instance.area}/repos
+slc.repo.jcr.forceCndImport=true
+slc.repo.jcr.proxyWorkspace=proxy
+
+slc.repo.jcr.configuration.java=osgibundle:repository-localfs.xml
+slc.repo.jcr.configuration.dist=osgibundle:repository-localfs.xml
+slc.repo.jcr.configuration.rpm=osgibundle:repository-localfs.xml
+slc.repo.jcr.configuration.docs=osgibundle:repository-localfs.xml
+argeo.node.repo.defaultWorkspace=main
+argeo.node.repo.bundleCacheMB=8
+argeo.node.repo.extractorPoolSize=0
+argeo.node.repo.searchCacheSize=1000
+argeo.node.repo.maxVolatileIndexSize=1048576
+
+slc.repo.jcr.dbuser=sa
+slc.repo.jcr.dbpassword=
+slc.repo.jcr.maxPoolSize=10
+
+# Postgres
+slc.repo.jcr.dburl.java=jdbc:postgresql://localhost/slc_repo_java
+slc.repo.jcr.dburl.dist=jdbc:postgresql://localhost/slc_repo_dist
+slc.repo.jcr.dburl.rpm=jdbc:postgresql://localhost/slc_repo_rpm
+slc.repo.jcr.dburl.docs=jdbc:postgresql://localhost/slc_repo_docs
diff --git a/legacy/org.argeo.slc.spring/.classpath b/legacy/org.argeo.slc.spring/.classpath
new file mode 100644 (file)
index 0000000..70b08e8
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" output="target/classes" path="src"/>
+       <classpathentry kind="src" path="ext/test"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/legacy/org.argeo.slc.spring/.gitignore b/legacy/org.argeo.slc.spring/.gitignore
new file mode 100644 (file)
index 0000000..09e3bc9
--- /dev/null
@@ -0,0 +1,2 @@
+/bin/
+/target/
diff --git a/legacy/org.argeo.slc.spring/.project b/legacy/org.argeo.slc.spring/.project
new file mode 100644 (file)
index 0000000..c45aff2
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.spring</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.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/legacy/org.argeo.slc.spring/META-INF/.gitignore b/legacy/org.argeo.slc.spring/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.spring/META-INF/spring.handlers b/legacy/org.argeo.slc.spring/META-INF/spring.handlers
new file mode 100644 (file)
index 0000000..417a952
--- /dev/null
@@ -0,0 +1 @@
+http\://www.argeo.org/schema/slc-flow=org.argeo.slc.core.execution.xml.FlowNamespaceHandler
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/META-INF/spring.schemas b/legacy/org.argeo.slc.spring/META-INF/spring.schemas
new file mode 100644 (file)
index 0000000..229d4c5
--- /dev/null
@@ -0,0 +1,3 @@
+http\://www.argeo.org/schema/slc-flow.xsd=org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd
+http\://www.argeo.org/schema/slc-flow-1.2.xsd=org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd
+http\://www.argeo.org/schema/slc-flow-0.12.xsd=org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd
diff --git a/legacy/org.argeo.slc.spring/bnd.bnd b/legacy/org.argeo.slc.spring/bnd.bnd
new file mode 100644 (file)
index 0000000..682a5ea
--- /dev/null
@@ -0,0 +1,11 @@
+Import-Package: javax.jcr.nodetype,\
+javax.jcr.security,\
+org.argeo.api,\
+aQute.bnd.osgi,\
+org.apache.tools.ant.*;resolution:="optional",\
+junit.framework;resolution:="optional",\
+org.osgi.*;version=0.0.0,\
+*
+
+Export-Package: org.argeo.slc.core.test,\
+*
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/build.properties b/legacy/org.argeo.slc.spring/build.properties
new file mode 100644 (file)
index 0000000..25c77f2
--- /dev/null
@@ -0,0 +1,16 @@
+additional.bundles = org.springframework.context,\
+                     org.slf4j.api,\
+                     org.slf4j.commons.logging,\
+                     org.slf4j.log4j12,\
+                     org.apache.log4j,\
+                     org.springframework.aop,\
+                     org.springframework.aspects,\
+                     org.springframework.beans,\
+                     org.springframework.context.support,\
+                     org.springframework.core,\
+                     org.springframework.expression,\
+                     org.springframework.instrument,\
+                     org.aopalliance
+bin.includes = META-INF/,.
+source.. = src/,\
+           ext/test/
diff --git a/legacy/org.argeo.slc.spring/ext/test/log4j.properties b/legacy/org.argeo.slc.spring/ext/test/log4j.properties
new file mode 100644 (file)
index 0000000..0133bab
--- /dev/null
@@ -0,0 +1,22 @@
+# Set root logger level to DEBUG and its only appender to A1.\r
+log4j.rootLogger=WARN, console\r
+\r
+## Levels\r
+# Slc\r
+log4j.logger.org.argeo=DEBUG\r
+\r
+# Castor\r
+log4j.logger.org.exolab.castor=WARN\r
+\r
+# Spring\r
+log4j.logger.org.springframework=WARN\r
+\r
+\r
+## Appenders\r
+# A1 is set to be a ConsoleAppender.\r
+log4j.appender.console=org.apache.log4j.ConsoleAppender\r
+\r
+# A1 uses PatternLayout.\r
+log4j.appender.console.layout=org.apache.log4j.PatternLayout\r
+log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n\r
+\r
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/DefaultResourceSetTest.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/DefaultResourceSetTest.java
new file mode 100644 (file)
index 0000000..e433d66
--- /dev/null
@@ -0,0 +1,27 @@
+package org.argeo.slc.core.deploy;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.core.test.context.AbstractInternalSpringTestCase;
+import org.springframework.core.io.Resource;
+
+public class DefaultResourceSetTest extends AbstractInternalSpringTestCase {
+       private final static Log log = LogFactory
+                       .getLog(DefaultResourceSetTest.class);
+
+       public void testListResources() {
+               DefaultResourceSet rrs = getBean("relativeResourceSet");
+               Map<String, Resource> res = rrs.listResources();
+               for (String relativePath : res.keySet())
+                       log.debug(relativePath + "=" + res.get(relativePath));
+               assertEquals(2, res.size());
+       }
+
+       @Override
+       protected String getApplicationContextLocation() {
+               return inPackage("relativeResourceSet.xml");
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/file1.txt b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/file1.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/subdir/file2.txt b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/data/subdir/file2.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/relativeResourceSet.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/deploy/relativeResourceSet.xml
new file mode 100644 (file)
index 0000000..074c205
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <bean id="relativeResourceSet" class="org.argeo.slc.core.deploy.DefaultResourceSet">\r
+               <property name="base" value="classpath:/org/argeo/slc/core/deploy/data" />\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/AbstractExecutionFlowTestCase.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/AbstractExecutionFlowTestCase.java
new file mode 100644 (file)
index 0000000..3a5e8a7
--- /dev/null
@@ -0,0 +1,68 @@
+package org.argeo.slc.core.execution;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.runtime.test.SimpleTestResult;
+import org.argeo.slc.test.TestResultPart;
+import org.argeo.slc.test.TestStatus;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public abstract class AbstractExecutionFlowTestCase extends TestCase {
+
+       protected final Log log = LogFactory.getLog(getClass());
+
+       protected void logException(Throwable ex) {
+               log.info("Got Exception of class " + ex.getClass().toString()
+                               + " with message '" + ex.getMessage() + "'.");
+       }
+
+       protected void validateTestResult(SimpleTestResult testResult) {
+               validateTestResult(testResult, TestStatus.PASSED);
+       }
+
+       protected void validateTestResult(SimpleTestResult testResult,
+                       int expectedStatus) {
+               for (TestResultPart part : testResult.getParts()) {
+                       if (part.getStatus() != expectedStatus) {
+                               fail("Error found in TestResult: " + part.getMessage());
+                       }
+               }
+       }
+
+       protected ConfigurableApplicationContext createApplicationContext(
+                       String applicationContextSuffix) {
+               ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext(
+                               inPackage(applicationContextSuffix));
+               // applicationContext.start();
+               return applicationContext;
+       }
+
+       protected void configureAndExecuteSlcFlow(String applicationContextSuffix,
+                       String beanName) {
+               ConfigurableApplicationContext applicationContext = createApplicationContext(applicationContextSuffix);
+               ExecutionContext executionContext = (ExecutionContext) applicationContext
+                               .getBean("executionContext");
+               ExecutionFlow executionFlow = (ExecutionFlow) applicationContext
+                               .getBean(beanName);
+               if (executionFlow instanceof DefaultExecutionFlow)
+                       ((DefaultExecutionFlow) executionFlow)
+                                       .setExecutionContext(executionContext);
+               try {
+                       executionContext.beforeFlow(executionFlow);
+                       executionFlow.run();
+               } finally {
+                       executionContext.afterFlow(executionFlow);
+               }
+               applicationContext.close();
+       }
+
+       protected String inPackage(String suffix) {
+               String prefix = getClass().getPackage().getName().replace('.', '/');
+               return prefix + '/' + suffix;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/BasicExecutionFlowTest.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/BasicExecutionFlowTest.java
new file mode 100644 (file)
index 0000000..b79fe44
--- /dev/null
@@ -0,0 +1,170 @@
+package org.argeo.slc.core.execution;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.runtime.test.SimpleTestResult;
+import org.argeo.slc.test.TestStatus;
+import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.context.ConfigurableApplicationContext;
+
+public class BasicExecutionFlowTest extends AbstractExecutionFlowTestCase {
+       // TO TEST
+       // - post-processing for @{} replacement in beans with complex properties
+       // - bean of scope other than execution are not resolved at execution
+
+       // public void testMyTest() throws Exception {
+       // ConfigurableApplicationContext applicationContext =
+       // createApplicationContext("test.xml");
+       // log.info("Start Execution");
+       // ((ExecutionFlow) applicationContext.getBean("flow1")).execute();
+       // applicationContext.close();
+       // }
+
+       public void XXXtestSpecOverriding() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("specOverriding.xml");
+               ((ExecutionFlow) applicationContext.getBean("flow2")).run();
+               SimpleTestResult res = (SimpleTestResult) applicationContext
+                               .getBean("myTestResult");
+               validateTestResult(res);
+       }
+
+       public void testMultipleFlows() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("multipleFlow.xml");
+               ((ExecutionFlow) applicationContext.getBean("flow1")).run();
+               SimpleTestResult res = (SimpleTestResult) applicationContext
+                               .getBean("myTestResult");
+               validateTestResult(res);
+               res.getParts().clear();
+               ((ExecutionFlow) applicationContext.getBean("flow2")).run();
+               validateTestResult(res, TestStatus.FAILED);
+               applicationContext.close();
+       }
+
+       /**
+        * Test placeholder resolution in a context without scope execution or proxy
+        * and with cascading flows (the flow A contains the flow B)
+        * 
+        * @throws Exception
+        */
+       public void testPlaceHolders() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.xml");
+               ((ExecutionFlow) applicationContext.getBean("flowA")).run();
+               validateTestResult((SimpleTestResult) applicationContext
+                               .getBean("myTestResult"));
+               applicationContext.close();
+       }
+
+       /**
+        * Test placeholder resolution in a context without scope execution or proxy
+        * and with cascading flows (the flow A contains the flow B) setting
+        * execution values (should have no effect)
+        * 
+        * @throws Exception
+        */
+       public void testPlaceHoldersWithExecutionValues() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.xml");
+
+               ExecutionContext executionContext = (ExecutionContext) applicationContext
+                               .getBean("executionContext");
+               Map<String, String> executionParameters = new HashMap<String, String>();
+               executionParameters.put("p1", "e1");
+               executionParameters.put("p2", "e2");
+               executionParameters.put("p3", "e3");
+               executionParameters.put("p4", "e4");
+               executionParameters.put("p5", "e5");
+               executionParameters.put("p6", "e6");
+               executionParameters.put("p7", "e7");
+               executionParameters.put("p8", "e8");
+               addVariables(executionContext, executionParameters);
+
+               ((ExecutionFlow) applicationContext.getBean("flowA")).run();
+               validateTestResult((SimpleTestResult) applicationContext
+                               .getBean("myTestResult"));
+               applicationContext.close();
+       }
+
+       public void XXXtestPlaceHoldersExec() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.exec.xml");
+
+               ExecutionContext executionContext = (ExecutionContext) applicationContext
+                               .getBean("executionContext");
+               Map<String, String> executionParameters = new HashMap<String, String>();
+               executionParameters.put("p1", "e1");
+               executionParameters.put("p2", "e2");
+               executionParameters.put("p3", "e3");
+               executionParameters.put("p4", "e4");
+               executionParameters.put("p5", "e5");
+               executionParameters.put("p6", "e6");
+               addVariables(executionContext, executionParameters);
+
+               ((ExecutionFlow) applicationContext.getBean("flowA")).run();
+               validateTestResult((SimpleTestResult) applicationContext
+                               .getBean("myTestResult"));
+               applicationContext.close();
+       }
+
+       public void testCanonicFlowParameters() throws Exception {
+               configureAndExecuteSlcFlow("canonic-001.xml", "canonic.001");
+       }
+
+       public void testCanonicDefaultValues() throws Exception {
+               configureAndExecuteSlcFlow("canonic-002.xml", "canonic.002");
+       }
+
+       public void testCanonicMissingValues() throws Exception {
+               try {
+                       configureAndExecuteSlcFlow("canonic-003.error.xml", "canonic.003");
+                       fail("Parameter not set - should be rejected.");
+               } catch (BeanCreationException e) {
+                       // exception expected
+                       logException(e);
+               }
+       }
+
+       public void testCanonicUnknownParameter() throws Exception {
+               try {
+                       configureAndExecuteSlcFlow("canonic-004.error.xml", "canonic.004");
+                       fail("Unknown parameter set - should be rejected.");
+               } catch (BeanCreationException e) {
+                       // exception expected
+                       logException(e);
+               }
+       }
+
+       public void testListSetMap() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("listSetMap.xml");
+               ExecutionFlow executionFlow = (ExecutionFlow) applicationContext
+                               .getBean("myFlow");
+               executionFlow.run();
+
+               validateTestResult((SimpleTestResult) applicationContext
+                               .getBean("myTestResult"));
+
+               // BasicTestData res = (BasicTestData)
+               // applicationContext.getBean("cascadingComplex.testData");
+               // log.info("res=" + res.getReached().toString());
+
+               applicationContext.close();
+       }
+
+       public void testListSetMapMultipleFlows() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("listSetMapMultipleFlow.xml");
+               ((ExecutionFlow) applicationContext.getBean("flow1")).run();
+               SimpleTestResult res = (SimpleTestResult) applicationContext
+                               .getBean("myTestResult");
+               validateTestResult(res);
+               res.getParts().clear();
+               ((ExecutionFlow) applicationContext.getBean("flow2")).run();
+               validateTestResult(res, TestStatus.FAILED);
+               applicationContext.close();
+       }
+
+       protected void addVariables(ExecutionContext executionContext,
+                       Map<String, String> vars) {
+               for (String key : vars.keySet())
+                       executionContext.setVariable(key, vars.get(key));
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/DefaultAgentCliTest.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/DefaultAgentCliTest.java
new file mode 100644 (file)
index 0000000..a7d9b8b
--- /dev/null
@@ -0,0 +1,18 @@
+package org.argeo.slc.core.execution;
+
+import java.net.URI;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class DefaultAgentCliTest extends TestCase {
+       public void testArgsToUris() {
+               String[] args = { "org.argeo.slc.demo.minimal", "HelloWorld/WithVar",
+                               "--testKey", "555" };
+               List<URI> uris = DefaultAgentCli.asURIs(args);
+               assertEquals(1, uris.size());
+               assertEquals(
+                               "flow:/org.argeo.slc.demo.minimal/HelloWorld/WithVar?testKey=555",
+                               uris.get(0).toString());
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ExceptionIfInitCalledTwice.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ExceptionIfInitCalledTwice.java
new file mode 100644 (file)
index 0000000..7ba7c82
--- /dev/null
@@ -0,0 +1,27 @@
+package org.argeo.slc.core.execution;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.beans.factory.InitializingBean;
+
+public class ExceptionIfInitCalledTwice implements Runnable, InitializingBean {
+       private final static Log log = LogFactory
+                       .getLog(ExceptionIfInitCalledTwice.class);
+
+       private Boolean calledOnce = false;
+
+       public void run() {
+               log.info(getClass().getSimpleName() + " ran properly");
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               log.info(getClass().getSimpleName() + " init method called");
+
+               if (calledOnce)
+                       throw new SlcException(getClass().getSimpleName()
+                                       + "init method called twice.");
+               else
+                       calledOnce = true;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesSpringTest.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesSpringTest.java
new file mode 100644 (file)
index 0000000..0d1223a
--- /dev/null
@@ -0,0 +1,53 @@
+package org.argeo.slc.core.execution;
+
+import java.io.File;
+
+public class FileExecutionResourcesSpringTest extends
+               AbstractExecutionFlowTestCase {
+       private String basePath = FileExecutionResources.DEFAULT_EXECUTION_RESOURCES_TMP_PATH;
+
+       public void testSimple() throws Exception {
+               File file = getFile("subdir/writeTo");
+               try {
+                       assertFalse(file.exists());
+                       configureAndExecuteSlcFlow("executionResources.xml",
+                                       "executionResources.simple");
+                       assertTrue(file.exists());
+               } finally {
+                       file.deleteOnExit();
+               }
+       }
+
+       public void testPlaceholderPass() throws Exception {
+               File file = getFile("subdir/60");
+               try {
+                       assertFalse(file.exists());
+                       configureAndExecuteSlcFlow("executionResources.xml",
+                                       "executionResources.placeholderPass");
+                       assertTrue(file.exists());
+               } finally {
+                       file.deleteOnExit();
+               }
+       }
+
+       /**
+        * Test that it generate the wrong file because of issue when using
+        * execution placeholder in contructor-arg
+        */
+       public void testPlaceholderFail() throws Exception {
+               File file = getFile("subdir/@{var}");
+               try {
+                       assertFalse(file.exists());
+                       configureAndExecuteSlcFlow("executionResources.xml",
+                                       "executionResources.placeholderFail");
+                       assertTrue(file.exists());
+               } finally {
+                       file.deleteOnExit();
+               }
+       }
+
+       protected File getFile(String relativePath) {
+               return new File(basePath + File.separator
+                               + relativePath.replace('/', File.separatorChar));
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesTest.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/FileExecutionResourcesTest.java
new file mode 100644 (file)
index 0000000..63bd58c
--- /dev/null
@@ -0,0 +1,43 @@
+package org.argeo.slc.core.execution;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+import org.argeo.slc.execution.ExecutionContext;
+import org.springframework.core.io.Resource;
+
+public class FileExecutionResourcesTest extends TestCase {
+       public void testGetWritableFile() throws Exception {
+               FileExecutionResources executionResources = new FileExecutionResources();
+               ExecutionContext executionContext = new MapExecutionContext();
+               executionResources.setExecutionContext(executionContext);
+
+               String expected = "TEST";
+               String reached = "";
+               try {
+                       // Resource
+                       Resource resource = executionResources
+                                       .getWritableResource("subdir1/textRes.txt");
+                       assertTrue(resource.getFile().getParentFile().exists());
+                       assertFalse(resource.getFile().exists());
+                       FileUtils.writeStringToFile(resource.getFile(), expected);
+                       reached = FileUtils.readFileToString(resource.getFile());
+                       assertEquals(expected, reached);
+
+                       // File
+                       File file = executionResources.getFile("subdir2/textFile.txt");
+                       assertFalse(file.getParentFile().exists());
+                       assertFalse(file.exists());
+                       FileUtils.writeStringToFile(file, expected);
+                       reached = FileUtils.readFileToString(file);
+                       assertEquals(expected, reached);
+               } finally {
+                       if (executionResources.getBaseDir() != null
+                                       && executionResources.getBaseDir().exists())
+                               FileUtils.deleteDirectory(executionResources.getBaseDir());
+               }
+
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ParameterRefTest.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/ParameterRefTest.java
new file mode 100644 (file)
index 0000000..6b954b9
--- /dev/null
@@ -0,0 +1,21 @@
+package org.argeo.slc.core.execution;
+
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.runtime.test.SimpleTestResult;
+import org.argeo.slc.test.TestStatus;
+import org.springframework.context.ConfigurableApplicationContext;
+
+public class ParameterRefTest extends AbstractExecutionFlowTestCase {
+       public void test001() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("parameterRef.xml");
+               ((ExecutionFlow) applicationContext.getBean("parameterRef.001")).run();
+
+               SimpleTestResult res = (SimpleTestResult) applicationContext
+                               .getBean("parameterRef.testResult");
+               assertEquals(res.getParts().get(0).getStatus(), TestStatus.PASSED);
+               assertEquals(res.getParts().get(1).getStatus(), TestStatus.FAILED);
+
+               applicationContext.close();
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/applicationContext.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/applicationContext.xml
new file mode 100644 (file)
index 0000000..d83c2c1
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" /> \r
+\r
+       <bean id="executionModule_1" class="org.argeo.slc.core.execution.SimpleSpringExecutionModule" >\r
+               <property name="executionContext">\r
+                       <ref bean="executionContext" />\r
+               </property>     \r
+               <property name="name" value="dummyname" />\r
+               <property name="version" value="dummyversion" />\r
+       </bean>\r
\r
+       <bean id="main" parent="slcTemplate.simpleFlow">\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="testKey">\r
+                                                       <bean parent="specAttr.primitive" p:value="660" />\r
+                                               </entry>\r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+               <property name="executables">\r
+                       <list>\r
+                               <ref local="echo1" />\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="echo1" parent="task.echo" scope="execution">\r
+               <property name="message"\r
+                       value="From main! @{testKey}" />\r
+               <aop:scoped-proxy />\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-001.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-001.xml
new file mode 100644 (file)
index 0000000..a1c59c9
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="canonic.xml" />\r
+\r
+       <bean id="canonic.001" parent="canonic.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation" value="1" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-002.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-002.xml
new file mode 100644 (file)
index 0000000..57f0c8a
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="canonic.xml" />\r
+\r
+       <bean id="canonic.002" parent="canonic.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation" value="2" />\r
+                               <entry key="displayWithoutControl" value="102" />\r
+                               <entry key="displayWithControl" value="202" />\r
+                               <entry key="hide" value="202" />\r
+                               <entry key="notParameterAtInstantiation" value="202" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-003.error.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-003.error.xml
new file mode 100644 (file)
index 0000000..6de8810
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="canonic.xml" />\r
+\r
+       <bean id="canonic.003" parent="canonic.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <!-- missing parameter -->\r
+                               <entry key="displayWithoutControl" value="102" />\r
+                               <entry key="displayWithControl" value="202" />\r
+                               <entry key="hide" value="202" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-004.error.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic-004.error.xml
new file mode 100644 (file)
index 0000000..2638ed6
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="canonic.xml" />\r
+\r
+       <bean id="canonic.004" parent="canonic.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation" value="2" />\r
+                               <entry key="displayWithoutControl" value="102" />\r
+                               <entry key="displayWithControl" value="202" />\r
+                               <entry key="hide" value="202" />\r
+                               <entry key="unknownParameter" value="1" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/canonic.xml
new file mode 100644 (file)
index 0000000..8d6af0e
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" />\r
+\r
+       <bean id="canonic.spec" parent="slcTemplate.simpleSpec">\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation">\r
+                                       <bean parent="specAttr.primitive" p:isParameter="true" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="displayWithoutControl">\r
+                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
+                                               p:isFrozen="true" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="displayWithControl">\r
+                                       <bean parent="specAttr.primitive" p:value="200" p:isParameter="true"\r
+                                               p:isFrozen="false" p:type="integer" />\r
+                               </entry>\r
+                               <entry key="hide">\r
+                                       <bean parent="specAttr.primitive" p:value="300" p:isParameter="true"\r
+                                               p:isFrozen="false" p:isHidden="true" p:type="integer" />\r
+                               </entry>                        \r
+                               <entry key="notParameterAtInstantiation">\r
+                                       <bean parent="specAttr.primitive" p:value="400" p:isParameter="false"\r
+                                               p:isFrozen="false" p:isHidden="false" p:type="integer" />\r
+                               </entry>                                                        \r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="canonic.flowTemplate" parent="slcTemplate.simpleFlow"\r
+               abstract="true">\r
+               <constructor-arg ref="canonic.spec" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo"\r
+                                       p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}">\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/executionResources.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/executionResources.xml
new file mode 100644 (file)
index 0000000..654f8b4
--- /dev/null
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" />\r
+\r
+       <bean id="executionResources.spec" parent="slcTemplate.simpleSpec">\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="var">\r
+                                       <bean parent="specAttr.primitive" p:isParameter="false"\r
+                                               p:type="integer" p:value="60" />\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="executionResources.placeholderPass" parent="slcTemplate.simpleFlow">\r
+               <constructor-arg ref="executionResources.spec" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo">\r
+                                       <property name="message" value="DATA" />\r
+                                       <property name="writeTo">\r
+                                               <bean parent="slcTemplate.resourcesFactoryBean" scope="execution">\r
+                                                       <property name="executionResources" ref="executionResources" />\r
+                                                       <property name="relativePath" value="subdir/@{var}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="executionResources.placeholderFail" parent="slcTemplate.simpleFlow">\r
+               <constructor-arg ref="executionResources.spec" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo">\r
+                                       <property name="message" value="DATA" />\r
+                                       <property name="writeTo">\r
+                                               <bean factory-bean="executionResources" factory-method="getWritableResource"\r
+                                                       scope="execution">\r
+                                                       <constructor-arg value="subdir/@{var}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="executionResources.simple" parent="slcTemplate.simpleFlow">\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo">\r
+                                       <property name="message" value="DATA" />\r
+                                       <property name="writeTo">\r
+                                               <bean factory-bean="executionResources" factory-method="getWritableResource"\r
+                                                       scope="execution">\r
+                                                       <constructor-arg value="subdir/writeTo" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="executionResources" parent="slcTemplate.fileResources">\r
+               <property name="executionContext" ref="executionContext" />\r
+               <property name="withExecutionSubdirectory" value="false" />\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/imports.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/imports.xml
new file mode 100644 (file)
index 0000000..7ddb4ea
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2007-2012 Argeo GmbH
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+            http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<!-- Copyright (C) 2007-2012 Mathieu Baudier Licensed under the Apache License, 
+       Version 2.0 (the "License"); you may not use this file except in compliance 
+       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
+       Unless required by applicable law or agreed to in writing, software distributed 
+       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
+       OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
+       the specific language governing permissions and limitations under the License. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+       <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />
+       <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />
+
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMap.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMap.xml
new file mode 100644 (file)
index 0000000..8aaed84
--- /dev/null
@@ -0,0 +1,309 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" /> \r
+\r
+       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
+               <property name="testDefinition" ref="basic.testDef" />\r
+               <property name="testResult" ref="myTestResult"/>\r
+       </bean>         \r
+\r
+       <bean id="myFlow" parent="slcTemplate.simpleFlow">\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="testKey">\r
+                                                       <bean parent="specAttr.primitive" p:value="myValue" />\r
+                                               </entry>\r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+               <property name="executables">\r
+                       <list>\r
+                               <ref local="echo1" />\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="simpleMap.testData" />\r
+                               </bean>                         \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingMap.testData" />\r
+                               </bean>                         \r
+                                               \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="simpleList.testData" />\r
+                               </bean>                         \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingList.testData" />\r
+                               </bean>                         \r
+                                                       \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="simpleSet.testData" />\r
+                               </bean>                         \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingSet.testData" />\r
+                               </bean> \r
+                                                       \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingListMap.testData" />\r
+                               </bean>                         \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingSetMap.testData" />\r
+                               </bean> \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingComplex.testData" />\r
+                               </bean>                                 \r
+       \r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+\r
+       <bean id="simpleMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <map>\r
+                               <entry key="key1" value="myValue_myValue" />\r
+                       </map>\r
+               </property>\r
+               <property name="reached">\r
+                       <map>\r
+                               <entry key="key1" value="@{testKey}_@{testKey}" />\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+       \r
+       <bean id="cascadingMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <map>\r
+                               <entry key="key3">\r
+                                       <map>\r
+                                               <entry key="key2">\r
+                                                       <map>\r
+                                                               <entry key="key1" value="myValue" />\r
+                                                       </map>\r
+                                               </entry>\r
+                                               <entry key="key2bis" value="myValue" />\r
+                                       </map>\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+               <property name="reached">\r
+                       <map>\r
+                               <entry key="key3">\r
+                                       <map>\r
+                                               <entry key="key2">\r
+                                                       <map>\r
+                                                               <entry key="key1" value="@{testKey}" />\r
+                                                       </map>\r
+                                               </entry>\r
+                                               <entry key="key2bis" value="@{testKey}" />\r
+                                       </map>\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean> \r
+       \r
+       <bean id="simpleList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <list>\r
+                               <value>myValue</value>\r
+                               <value>_myValue_</value>\r
+                       </list>\r
+               </property>\r
+               <property name="reached">\r
+                       <list>\r
+                               <value>@{testKey}</value>\r
+                               <value>_@{testKey}_</value>                             \r
+                       </list>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="cascadingList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <list>\r
+                               <list>\r
+                                       <value>myValue</value>\r
+                                       <value>_myValue_</value>\r
+                               </list>\r
+                               <value>myValue</value>\r
+                       </list>\r
+               </property>\r
+               <property name="reached">\r
+                       <list>\r
+                               <list>\r
+                                       <value>@{testKey}</value>\r
+                                       <value>_@{testKey}_</value>\r
+                               </list>\r
+                               <value>@{testKey}</value>\r
+                       </list>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="simpleSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <set>\r
+                               <value>myValue</value>\r
+                               <value>_myValue_</value>\r
+                       </set>\r
+               </property>\r
+               <property name="reached">\r
+                       <set>\r
+                               <value>@{testKey}</value>\r
+                               <value>_@{testKey}_</value>                             \r
+                       </set>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="cascadingSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <set>\r
+                               <set>\r
+                                       <value>myValue</value>\r
+                                       <value>_myValue_</value>\r
+                               </set>\r
+                               <value>myValue</value>\r
+                       </set>\r
+               </property>\r
+               <property name="reached">\r
+                       <set>\r
+                               <set>\r
+                                       <value>@{testKey}</value>\r
+                                       <value>_@{testKey}_</value>\r
+                               </set>\r
+                               <value>@{testKey}</value>\r
+                       </set>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="cascadingListMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <list>\r
+                               <map>\r
+                                       <entry key="key1" value="myValue" />\r
+                               </map>                                          \r
+                       </list>\r
+               </property>\r
+               <property name="reached">\r
+                       <list>\r
+                               <map>\r
+                                       <entry key="key1" value="@{testKey}" />\r
+                               </map>                                  \r
+                       </list>\r
+               </property>\r
+       </bean> \r
+       \r
+       <bean id="cascadingSetMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <set>\r
+                               <map>\r
+                                       <entry key="key1" value="myValue" />\r
+                               </map>                                          \r
+                       </set>\r
+               </property>\r
+               <property name="reached">\r
+                       <set>\r
+                               <map>\r
+                                       <entry key="key1" value="@{testKey}" />\r
+                               </map>                                  \r
+                       </set>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="cascadingComplex.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <set>\r
+                               <map>\r
+                                       <entry key="key1" value="myValue" />\r
+                               </map>  \r
+                               <list>\r
+                                       <map>\r
+                                               <entry key="key1" value="myValue" />\r
+                                       </map>          \r
+                                       <set>\r
+                                               <set>\r
+                                                       <value>myValue</value>\r
+                                                       <value>_myValue_</value>\r
+                                                       <list>\r
+                                                               <list>\r
+                                                                       <value>myValue</value>\r
+                                                                       <value>_myValue_</value>\r
+                                                               </list>\r
+                                                               <value>myValue</value>\r
+                                                       </list>                                                 \r
+                                               </set>\r
+                                               <value>myValue</value>\r
+                                       </set>                                                                  \r
+                               </list> \r
+                               <set>\r
+                                       <map>\r
+                                               <entry key="key1" value="myValue" />\r
+                                       </map>  \r
+                               </set>                                                                                          \r
+                       </set>\r
+               </property>\r
+               <property name="reached">\r
+                       <set>\r
+                               <map>\r
+                                       <entry key="key1" value="@{testKey}" />\r
+                               </map>  \r
+                               <list>\r
+                                       <map>\r
+                                               <entry key="key1" value="@{testKey}" />\r
+                                       </map>          \r
+                                       <set>\r
+                                               <set>\r
+                                                       <value>@{testKey}</value>\r
+                                                       <value>_@{testKey}_</value>\r
+                                                       <list>\r
+                                                               <list>\r
+                                                                       <value>@{testKey}</value>\r
+                                                                       <value>_@{testKey}_</value>\r
+                                                               </list>\r
+                                                               <value>@{testKey}</value>\r
+                                                       </list>                                                 \r
+                                               </set>\r
+                                               <value>@{testKey}</value>\r
+                                       </set>                                                                  \r
+                               </list> \r
+                               <set>\r
+                                       <map>\r
+                                               <entry key="key1" value="@{testKey}" />\r
+                                       </map>  \r
+                               </set>                                                                                          \r
+                       </set>\r
+               </property>\r
+       </bean>                 \r
+       \r
+       <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition">\r
+       </bean> \r
+\r
+\r
+       <bean id="echo1" parent="task.echo" scope="prototype">\r
+               <property name="message"\r
+                       value="testKey=@{testKey}" />\r
+       </bean>\r
+       \r
+       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMapMultipleFlow.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/listSetMapMultipleFlow.xml
new file mode 100644 (file)
index 0000000..94ddd35
--- /dev/null
@@ -0,0 +1,326 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" /> \r
+\r
+       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
+               <property name="testDefinition" ref="basic.testDef" />\r
+               <property name="testResult" ref="myTestResult"/>\r
+       </bean>         \r
+\r
+       <bean id="abstractFlow" parent="slcTemplate.simpleFlow" abstract="true">\r
+               <property name="executables">\r
+                       <list>\r
+                               <ref local="echo1" />\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="simpleMap.testData" />\r
+                               </bean>                         \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingMap.testData" />\r
+                               </bean>                         \r
+                                               \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="simpleList.testData" />\r
+                               </bean>                         \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingList.testData" />\r
+                               </bean>                         \r
+                                                       \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="simpleSet.testData" />\r
+                               </bean>                         \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingSet.testData" />\r
+                               </bean> \r
+                                                       \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingListMap.testData" />\r
+                               </bean>                         \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingSetMap.testData" />\r
+                               </bean> \r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData" ref="cascadingComplex.testData" />\r
+                               </bean>                                 \r
+       \r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="flow1" parent="abstractFlow" scope="prototype">\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="testKey">\r
+                                                       <bean parent="specAttr.primitive" p:value="myValue" />\r
+                                               </entry>\r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+       </bean> \r
+\r
+       <bean id="flow2" parent="abstractFlow" scope="prototype">\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="testKey">\r
+                                                       <bean parent="specAttr.primitive" p:value="myValue2" />\r
+                                               </entry>\r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+       </bean> \r
+\r
+\r
+       <bean id="simpleMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <map>\r
+                               <entry key="key1" value="myValue_myValue" />\r
+                       </map>\r
+               </property>\r
+               <property name="reached">\r
+                       <map>\r
+                               <entry key="key1" value="@{testKey}_@{testKey}" />\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+       \r
+       <bean id="cascadingMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <map>\r
+                               <entry key="key3">\r
+                                       <map>\r
+                                               <entry key="key2">\r
+                                                       <map>\r
+                                                               <entry key="key1" value="myValue" />\r
+                                                       </map>\r
+                                               </entry>\r
+                                               <entry key="key2bis" value="myValue" />\r
+                                       </map>\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+               <property name="reached">\r
+                       <map>\r
+                               <entry key="key3">\r
+                                       <map>\r
+                                               <entry key="key2">\r
+                                                       <map>\r
+                                                               <entry key="key1" value="@{testKey}" />\r
+                                                       </map>\r
+                                               </entry>\r
+                                               <entry key="key2bis" value="@{testKey}" />\r
+                                       </map>\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean> \r
+       \r
+       <bean id="simpleList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <list>\r
+                               <value>myValue</value>\r
+                               <value>_myValue_</value>\r
+                       </list>\r
+               </property>\r
+               <property name="reached">\r
+                       <list>\r
+                               <value>@{testKey}</value>\r
+                               <value>_@{testKey}_</value>                             \r
+                       </list>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="cascadingList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <list>\r
+                               <list>\r
+                                       <value>myValue</value>\r
+                                       <value>_myValue_</value>\r
+                               </list>\r
+                               <value>myValue</value>\r
+                       </list>\r
+               </property>\r
+               <property name="reached">\r
+                       <list>\r
+                               <list>\r
+                                       <value>@{testKey}</value>\r
+                                       <value>_@{testKey}_</value>\r
+                               </list>\r
+                               <value>@{testKey}</value>\r
+                       </list>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="simpleSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <set>\r
+                               <value>myValue</value>\r
+                               <value>_myValue_</value>\r
+                       </set>\r
+               </property>\r
+               <property name="reached">\r
+                       <set>\r
+                               <value>@{testKey}</value>\r
+                               <value>_@{testKey}_</value>                             \r
+                       </set>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="cascadingSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <set>\r
+                               <set>\r
+                                       <value>myValue</value>\r
+                                       <value>_myValue_</value>\r
+                               </set>\r
+                               <value>myValue</value>\r
+                       </set>\r
+               </property>\r
+               <property name="reached">\r
+                       <set>\r
+                               <set>\r
+                                       <value>@{testKey}</value>\r
+                                       <value>_@{testKey}_</value>\r
+                               </set>\r
+                               <value>@{testKey}</value>\r
+                       </set>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="cascadingListMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <list>\r
+                               <map>\r
+                                       <entry key="key1" value="myValue" />\r
+                               </map>                                          \r
+                       </list>\r
+               </property>\r
+               <property name="reached">\r
+                       <list>\r
+                               <map>\r
+                                       <entry key="key1" value="@{testKey}" />\r
+                               </map>                                  \r
+                       </list>\r
+               </property>\r
+       </bean> \r
+       \r
+       <bean id="cascadingSetMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <set>\r
+                               <map>\r
+                                       <entry key="key1" value="myValue" />\r
+                               </map>                                          \r
+                       </set>\r
+               </property>\r
+               <property name="reached">\r
+                       <set>\r
+                               <map>\r
+                                       <entry key="key1" value="@{testKey}" />\r
+                               </map>                                  \r
+                       </set>\r
+               </property>\r
+       </bean>         \r
+       \r
+       <bean id="cascadingComplex.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
+               <property name="expected">\r
+                       <set>\r
+                               <map>\r
+                                       <entry key="key1" value="myValue" />\r
+                               </map>  \r
+                               <list>\r
+                                       <map>\r
+                                               <entry key="key1" value="myValue" />\r
+                                       </map>          \r
+                                       <set>\r
+                                               <set>\r
+                                                       <value>myValue</value>\r
+                                                       <value>_myValue_</value>\r
+                                                       <list>\r
+                                                               <list>\r
+                                                                       <value>myValue</value>\r
+                                                                       <value>_myValue_</value>\r
+                                                               </list>\r
+                                                               <value>myValue</value>\r
+                                                       </list>                                                 \r
+                                               </set>\r
+                                               <value>myValue</value>\r
+                                       </set>                                                                  \r
+                               </list> \r
+                               <set>\r
+                                       <map>\r
+                                               <entry key="key1" value="myValue" />\r
+                                       </map>  \r
+                               </set>                                                                                          \r
+                       </set>\r
+               </property>\r
+               <property name="reached">\r
+                       <set>\r
+                               <map>\r
+                                       <entry key="key1" value="@{testKey}" />\r
+                               </map>  \r
+                               <list>\r
+                                       <map>\r
+                                               <entry key="key1" value="@{testKey}" />\r
+                                       </map>          \r
+                                       <set>\r
+                                               <set>\r
+                                                       <value>@{testKey}</value>\r
+                                                       <value>_@{testKey}_</value>\r
+                                                       <list>\r
+                                                               <list>\r
+                                                                       <value>@{testKey}</value>\r
+                                                                       <value>_@{testKey}_</value>\r
+                                                               </list>\r
+                                                               <value>@{testKey}</value>\r
+                                                       </list>                                                 \r
+                                               </set>\r
+                                               <value>@{testKey}</value>\r
+                                       </set>                                                                  \r
+                               </list> \r
+                               <set>\r
+                                       <map>\r
+                                               <entry key="key1" value="@{testKey}" />\r
+                                       </map>  \r
+                               </set>                                                                                          \r
+                       </set>\r
+               </property>\r
+       </bean>                 \r
+               \r
+       <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition">\r
+       </bean> \r
+\r
+\r
+       <bean id="echo1" parent="task.echo" scope="prototype">\r
+               <property name="message"\r
+                       value="testKey=@{testKey}" />\r
+       </bean>\r
+       \r
+       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/minimal.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/minimal.xml
new file mode 100644 (file)
index 0000000..5b16697
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" /> \r
+\r
+       <bean id="minimal" parent="slcTemplate.simpleFlow">\r
+               <property name="executionSpec">\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+<!--                           <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="testKey">\r
+                                                       <bean parent="specAttr.primitive" p:value="660" />\r
+                                               </entry>\r
+                                       </map>\r
+                               </property> -->\r
+                       </bean>\r
+               </property>\r
+               <property name="executables">\r
+                       <list>\r
+                               <ref local="echo1" />\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="echo1" parent="task.echo" scope="execution">\r
+               <property name="message"\r
+                       value="From minimal" />\r
+               <aop:scoped-proxy />\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/multipleFlow.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/multipleFlow.xml
new file mode 100644 (file)
index 0000000..69b3efe
--- /dev/null
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" /> \r
+\r
+       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
+\r
+       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
+               <property name="testDefinition" ref="myTestDef" />\r
+               <property name="testResult" ref="myTestResult"/>\r
+       </bean>         \r
+\r
+       <bean id="fileDiff.spec" parent="slcTemplate.simpleSpec">\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="fileName">\r
+                                       <bean parent="specAttr.primitive" p:isParameter="true" p:type="string"\r
+                                               p:isFrozen="true" />\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+\r
+       <bean id="fileDiff.flowTemplate" parent="slcTemplate.simpleFlow"\r
+               abstract="true">\r
+               <property name="path" value="/fileDiff/testcases" />\r
+               <constructor-arg ref="fileDiff.spec" />\r
+               <property name="executables">\r
+                       <list>                  \r
+                               <bean parent="task.echo">\r
+                                       <property name="message" value="fileName=@{fileName}" />\r
+                               </bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="file1" />\r
+                                                       <property name="reached" value="@{fileName}" />\r
+                                               </bean>\r
+                                       </property>     \r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+       \r
+       <bean id="echo" parent="task.echo" scope="prototype">\r
+               <property name="message" value="fileName=@{fileName}" />\r
+       </bean>                 \r
+       \r
+       <bean id="flow1" parent="fileDiff.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="fileName" value="file1" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean> \r
+\r
+       <bean id="flow2" parent="fileDiff.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="fileName" value="file2" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean> \r
\r
\r
+ <!-- \r
+       <bean id="flow1" parent="slcTemplate.simpleFlow">\r
+               <property name="path" value="/fileDiff/testcases" />\r
+               <constructor-arg ref="fileDiff.spec" />\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="fileName" value="file1" />\r
+                       </map>\r
+               </constructor-arg>              \r
+               <property name="executables">\r
+                       <list>                  \r
+                               <bean parent="task.echo" scope="execution">\r
+                                       <property name="message" value="fileName=@{fileName}" />\r
+                                       <aop:scoped-proxy />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="flow2" parent="slcTemplate.simpleFlow">\r
+               <property name="path" value="/fileDiff/testcases" />\r
+               <constructor-arg ref="fileDiff.spec" />\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="fileName" value="file2" />\r
+                       </map>\r
+               </constructor-arg>              \r
+               <property name="executables">\r
+                       <list>                  \r
+                               <bean parent="task.echo" scope="execution">\r
+                                       <property name="message" value="fileName=@{fileName}" />\r
+                                       <aop:scoped-proxy />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+ -->\r
+<!-- \r
+       <bean id="main" parent="slcTemplate.simpleFlow">\r
+               <property name="executables">\r
+                       <list>          \r
+                               <ref bean="flow1"/>     \r
+                               <ref bean="flow2"/>     \r
+                       </list>\r
+               </property>\r
+       </bean>\r
+ -->\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/parameterRef.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/parameterRef.xml
new file mode 100644 (file)
index 0000000..e9e389a
--- /dev/null
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" />\r
+\r
+       <!-- DEFINITIONS -->\r
+       <bean id="parameterRef.spec" parent="slcTemplate.simpleSpec">\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="exceptionIfInitCalledTwice">\r
+                                       <bean parent="specAttr.ref"\r
+                                               p:targetClass="org.argeo.slc.core.execution.ExceptionIfInitCalledTwice"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
+                               </entry>\r
+                               <entry key="testData1">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
+                               </entry>\r
+                               <entry key="testData2">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
+                               </entry>\r
+                               <entry key="testedComponentId">\r
+                                       <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
+                                               p:type="integer" />\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="parameterRef.flowTemplate" parent="slcTemplate.simpleFlow"\r
+               abstract="true">\r
+               <constructor-arg ref="parameterRef.spec" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <!-- Primitive -->\r
+                               <bean parent="task.echo" scope="execution">\r
+                                       <property name="message" value="testedComponentId=@{testedComponentId}" />\r
+                               </bean>\r
+\r
+                               <!-- Exception if init called twice -->\r
+                               <bean parent="parameterRef">\r
+                                       <constructor-arg value="exceptionIfInitCalledTwice" />\r
+                               </bean>\r
+                               <bean parent="parameterRef">\r
+                                       <property name="name" value="exceptionIfInitCalledTwice" />\r
+                               </bean>\r
+\r
+                               <!-- Basic tests -->\r
+                               <bean parent="parameterRef.testRun">\r
+                                       <property name="testData">\r
+                                               <bean parent="parameterRef">\r
+                                                       <constructor-arg value="testData1" />\r
+                                               </bean>\r
+                                       </property>\r
+                               </bean>\r
+                               <bean parent="parameterRef.testRun">\r
+                                       <property name="testData" ref="ref1" />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <!-- TEST CASES -->\r
+       <bean id="parameterRef.001" parent="parameterRef.flowTemplate">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="exceptionIfInitCalledTwice">\r
+                                       <bean class="org.argeo.slc.core.execution.ExceptionIfInitCalledTwice" />\r
+                               </entry>\r
+                               <entry key="testData1">\r
+                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                               <property name="expected" value="toto" />\r
+                                               <property name="reached" value="toto" />\r
+                                       </bean>\r
+                               </entry>\r
+                               <entry key="testData2">\r
+                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                               <property name="expected" value="tata" />\r
+                                               <property name="reached" value="toto" />\r
+                                       </bean>\r
+                               </entry>\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+\r
+       <!-- UTILITIES -->\r
+\r
+       <bean id="ref1" parent="parameterRef">\r
+               <constructor-arg value="testData2" />\r
+       </bean>\r
+\r
+       <bean id="parameterRef.testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+       <bean id="parameterRef.testRun" class="org.argeo.slc.runtime.test.SimpleTestRun"\r
+               abstract="true">\r
+               <property name="testResult" ref="parameterRef.testResult" />\r
+               <property name="testDefinition">\r
+                       <bean class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
+               </property>\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.exec.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.exec.xml
new file mode 100644 (file)
index 0000000..6481d96
--- /dev/null
@@ -0,0 +1,327 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" /> \r
+\r
+       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
+\r
+       <bean id="echo1" parent="task.echo">\r
+               <property name="message" value="From minimal" />\r
+       </bean>\r
+\r
+       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
+               <property name="testDefinition" ref="myTestDef" />\r
+               <property name="testResult" ref="myTestResult"/>\r
+       </bean>         \r
+\r
+       <!-- \r
+               The Flow A contains the flow B as executable.\r
+       \r
+               Parameters\r
+               p1: flow A: default - flow B: - \r
+               p2: flow A: set     - flow B: - \r
+               p3: flow A: default - flow B: default \r
+               p4: flow A: set     - flow B: default\r
+               p5: flow A: default - flow B: set \r
+               p6: flow A: set     - flow B: set\r
+               p7: flow A: -       - flow B: default\r
+               p8: flow A: -       - flow B: set\r
+                \r
+               \r
+        -->\r
+\r
+       <bean id="flowA" parent="slcTemplate.simpleFlow">\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="p1"><bean parent="specAttr.primitive" p:value="da1" /></entry>\r
+                                               <entry key="p2"><bean parent="specAttr.primitive" p:value="da2" /></entry>                                              \r
+                                               <entry key="p3"><bean parent="specAttr.primitive" p:value="da3" /></entry>                                              \r
+                                               <entry key="p4"><bean parent="specAttr.primitive" p:value="da4" /></entry>                                              \r
+                                               <entry key="p5"><bean parent="specAttr.primitive" p:value="da5" /></entry>                                              \r
+                                               <entry key="p6"><bean parent="specAttr.primitive" p:value="da6" /></entry>                                              \r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+               <constructor-arg>               \r
+                       <map>\r
+                               <entry key="p2" value="va2"/>\r
+                               <entry key="p4" value="va4"/>\r
+                               <entry key="p6" value="va6"/>\r
+                       </map>\r
+               </constructor-arg>\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da1" />\r
+                                                       <property name="reached" value="@{p1}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>\r
+                               <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va2" />\r
+                                                       <property name="reached" value="@{p2}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da3" />\r
+                                                       <property name="reached" value="@{p3}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va4" />\r
+                                                       <property name="reached" value="@{p4}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                 \r
+                               <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da5" />\r
+                                                       <property name="reached" value="@{p5}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va6" />\r
+                                                       <property name="reached" value="@{p6}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                 \r
+                               <ref bean="flowB"/>                             \r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="flowB" parent="slcTemplate.simpleFlow" scope="prototype">\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="p3"><bean parent="specAttr.primitive" p:value="db3" /></entry>                                              \r
+                                               <entry key="p4"><bean parent="specAttr.primitive" p:value="db4" /></entry>\r
+                                               <entry key="p5"><bean parent="specAttr.primitive" p:value="db5" /></entry>                                              \r
+                                               <entry key="p6"><bean parent="specAttr.primitive" p:value="db6" /></entry>\r
+                                               <entry key="p7"><bean parent="specAttr.primitive" p:value="db7" /></entry>                                              \r
+                                               <entry key="p8"><bean parent="specAttr.primitive" p:value="db8" /></entry>\r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+               <constructor-arg>               \r
+                       <map>\r
+                               <entry key="p3" value="vb3"/>\r
+                               <entry key="p4" value="vb4"/>\r
+                               <entry key="p7" value="vb7"/>\r
+                       </map>\r
+               </constructor-arg>              \r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da1" />\r
+                                                       <property name="reached" value="@{p1}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>\r
+                               <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va2" />\r
+                                                       <property name="reached" value="@{p2}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da3" />\r
+                                                       <property name="reached" value="@{p3}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va4" />\r
+                                                       <property name="reached" value="@{p4}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                 \r
+                               <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da5" />\r
+                                                       <property name="reached" value="@{p5}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va6" />\r
+                                                       <property name="reached" value="@{p6}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p7=@{p7}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="vb7" />\r
+                                                       <property name="reached" value="@{p7}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                                         \r
+                               <bean parent="task.echo"><property name="message" value="p8=@{p8}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="db8" />\r
+                                                       <property name="reached" value="@{p8}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean> \r
+                               \r
+                               <!-- test in scope execution -->\r
+                               <bean parent="task.echo" scope="execution"><property name="message" value="p1=@{p1}" /><aop:scoped-proxy /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                                       <property name="expected" value="e1" />\r
+                                                       <property name="reached" value="@{p1}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>\r
+                               <bean parent="task.echo" scope="execution"><property name="message" value="p2=@{p2}" /><aop:scoped-proxy /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                                       <property name="expected" value="e2" />\r
+                                                       <property name="reached" value="@{p2}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo" scope="execution"><property name="message" value="p3=@{p3}" /><aop:scoped-proxy /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                                       <property name="expected" value="e3" />\r
+                                                       <property name="reached" value="@{p3}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo" scope="execution"><property name="message" value="p4=@{p4}" /><aop:scoped-proxy /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                                       <property name="expected" value="e4" />\r
+                                                       <property name="reached" value="@{p4}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                 \r
+                               <bean parent="task.echo" scope="execution"><property name="message" value="p5=@{p5}" /><aop:scoped-proxy /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                                       <property name="expected" value="e5" />\r
+                                                       <property name="reached" value="@{p5}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo" scope="execution"><property name="message" value="p6=@{p6}" /><aop:scoped-proxy /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                                       <property name="expected" value="e6" />\r
+                                                       <property name="reached" value="@{p6}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>\r
+                                                               \r
+                               <!-- \r
+                                       p7 and p8 are not in the spec of FlowA and therefore can not be overridden\r
+                                       at the execution\r
+                                -->\r
+                               <bean parent="task.echo" scope="execution"><property name="message" value="p7=@{p7}" /><aop:scoped-proxy /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                                       <property name="expected" value="vb7" />\r
+                                                       <property name="reached" value="@{p7}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                                         \r
+                               <bean parent="task.echo" scope="execution"><property name="message" value="p8=@{p8}" /><aop:scoped-proxy /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                                       <property name="expected" value="db8" />\r
+                                                       <property name="reached" value="@{p8}" />\r
+                                                       <aop:scoped-proxy />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>         \r
+                                                                                       \r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/placeHolders.cascading.xml
new file mode 100644 (file)
index 0000000..ba72f88
--- /dev/null
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" /> \r
+\r
+       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
+\r
+       <bean id="echo1" parent="task.echo">\r
+               <property name="message" value="From minimal" />\r
+       </bean>\r
+\r
+       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
+               <property name="testDefinition" ref="myTestDef" />\r
+               <property name="testResult" ref="myTestResult"/>\r
+       </bean>         \r
+\r
+       <!-- \r
+               The Flow A contains the flow B as executable.\r
+       \r
+               Parameters\r
+               p1: flow A: default - flow B: - \r
+               p2: flow A: set     - flow B: - \r
+               p3: flow A: default - flow B: default \r
+               p4: flow A: set     - flow B: default\r
+               p5: flow A: default - flow B: set \r
+               p6: flow A: set     - flow B: set\r
+               p7: flow A: -       - flow B: default\r
+               p8: flow A: -       - flow B: set\r
+                \r
+               \r
+        -->\r
+\r
+       <bean id="flowA" parent="slcTemplate.simpleFlow">\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="p1"><bean parent="specAttr.primitive" p:value="da1" /></entry>\r
+                                               <entry key="p2"><bean parent="specAttr.primitive" p:value="da2" /></entry>                                              \r
+                                               <entry key="p3"><bean parent="specAttr.primitive" p:value="da3" /></entry>                                              \r
+                                               <entry key="p4"><bean parent="specAttr.primitive" p:value="da4" /></entry>                                              \r
+                                               <entry key="p5"><bean parent="specAttr.primitive" p:value="da5" /></entry>                                              \r
+                                               <entry key="p6"><bean parent="specAttr.primitive" p:value="da6" /></entry>                                              \r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+               <constructor-arg>               \r
+                       <map>\r
+                               <entry key="p2" value="va2"/>\r
+                               <entry key="p4" value="va4"/>\r
+                               <entry key="p6" value="va6"/>\r
+                       </map>\r
+               </constructor-arg>\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da1" />\r
+                                                       <property name="reached" value="@{p1}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>\r
+                               <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va2" />\r
+                                                       <property name="reached" value="@{p2}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da3" />\r
+                                                       <property name="reached" value="@{p3}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va4" />\r
+                                                       <property name="reached" value="@{p4}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                 \r
+                               <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da5" />\r
+                                                       <property name="reached" value="@{p5}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va6" />\r
+                                                       <property name="reached" value="@{p6}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                 \r
+                               <ref bean="flowB"/>                             \r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="flowB" parent="slcTemplate.simpleFlow" scope="prototype">\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="p3"><bean parent="specAttr.primitive" p:value="db3" /></entry>                                              \r
+                                               <entry key="p4"><bean parent="specAttr.primitive" p:value="db4" /></entry>\r
+                                               <entry key="p5"><bean parent="specAttr.primitive" p:value="db5" /></entry>                                              \r
+                                               <entry key="p6"><bean parent="specAttr.primitive" p:value="db6" /></entry>\r
+                                               <entry key="p7"><bean parent="specAttr.primitive" p:value="db7" /></entry>                                              \r
+                                               <entry key="p8"><bean parent="specAttr.primitive" p:value="db8" /></entry>\r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+               <constructor-arg>               \r
+                       <map>\r
+                               <entry key="p3" value="vb3"/>\r
+                               <entry key="p4" value="vb4"/>\r
+                               <entry key="p7" value="vb7"/>\r
+                       </map>\r
+               </constructor-arg>              \r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da1" />\r
+                                                       <property name="reached" value="@{p1}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>\r
+                               <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va2" />\r
+                                                       <property name="reached" value="@{p2}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da3" />\r
+                                                       <property name="reached" value="@{p3}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va4" />\r
+                                                       <property name="reached" value="@{p4}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                 \r
+                               <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="da5" />\r
+                                                       <property name="reached" value="@{p5}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="va6" />\r
+                                                       <property name="reached" value="@{p6}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                         \r
+                               <bean parent="task.echo"><property name="message" value="p7=@{p7}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="vb7" />\r
+                                                       <property name="reached" value="@{p7}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean>                                                         \r
+                               <bean parent="task.echo"><property name="message" value="p8=@{p8}" /></bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                                       <property name="expected" value="db8" />\r
+                                                       <property name="reached" value="@{p8}" />\r
+                                               </bean>\r
+                                       </property>                                     \r
+                               </bean> \r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/specOverriding.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/specOverriding.xml
new file mode 100644 (file)
index 0000000..7a70f71
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" /> \r
\r
+       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
+\r
+       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
+               <property name="testDefinition" ref="myTestDef" />\r
+               <property name="testResult" ref="myTestResult"/>\r
+       </bean>         \r
\r
+       <bean id="spec1" parent="slcTemplate.simpleSpec">\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="testedComponentId">\r
+                                       <bean parent="specAttr.primitive" p:isParameter="true"\r
+                                               p:type="integer" />\r
+                               </entry>\r
+                               <entry key="testData1">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="flowTemplate1" parent="slcTemplate.simpleFlow"\r
+               abstract="true">\r
+               <constructor-arg ref="spec1" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo" scope="execution">\r
+                                       <property name="message" value="From basic @{testedComponentId}" />\r
+                                       <aop:scoped-proxy />\r
+                               </bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean parent="parameterRef">\r
+                                                       <constructor-arg value="testData1" />\r
+                                               </bean>\r
+                                       </property>\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="flow1" parent="flowTemplate1" scope="prototype">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="testedComponentId" value="200" />\r
+                               <entry key="testData1">\r
+                                       <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                               <aop:scoped-proxy/>\r
+                                               <property name="expected" value="tata101" />\r
+                                               <property name="reached" value="tata@{testedComponentId}" />\r
+                                       </bean>\r
+                               </entry>\r
+                       </map>                  \r
+               </constructor-arg>\r
+       </bean>\r
+\r
+       <bean id="spec2" parent="slcTemplate.simpleSpec">\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="testData1">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="flowTemplate2" parent="slcTemplate.simpleFlow" abstract="true">\r
+               <constructor-arg ref="spec2" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <ref bean="flow1"/>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+       \r
+       <bean id="flow2" parent="flowTemplate2">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="testData1">\r
+                                       <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                               <property name="expected" value="tata100" />\r
+                                               <property name="reached" value="tata100" />\r
+                                       </bean>\r
+                               </entry>\r
+                       </map>                  \r
+               </constructor-arg>\r
+       </bean> \r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/SystemCallTest.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/SystemCallTest.java
new file mode 100644 (file)
index 0000000..b007b9a
--- /dev/null
@@ -0,0 +1,44 @@
+package org.argeo.slc.core.execution.tasks;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.core.execution.AbstractExecutionFlowTestCase;
+
+public class SystemCallTest extends AbstractExecutionFlowTestCase {
+       private final static Log log = LogFactory.getLog(SystemCallTest.class);
+
+       private final String defFile = "systemCall.xml";
+
+       public void testSystemCallSimple() throws Exception {
+               if (isOsSupported())
+                       configureAndExecuteSlcFlow(defFile, "systemCallSimple");
+       }
+
+       public void testSystemCallList() throws Exception {
+               if (isOsSupported())
+                       configureAndExecuteSlcFlow(defFile, "systemCallList");
+       }
+
+       public void testSystemCallOsSpecific() throws Exception {
+               if (isOsSupported())
+                       configureAndExecuteSlcFlow(defFile, "systemCallOsSpecific");
+       }
+
+       public void testSystemCallWithVar() throws Exception {
+               if (isOsSupported())
+                       configureAndExecuteSlcFlow(defFile, "systemCallWithVar");
+       }
+
+       protected boolean isOsSupported() {
+               String osName = System.getProperty("os.name");
+               final Boolean ret;
+               if (osName.contains("Windows"))
+                       ret = false;
+               else
+                       ret = true;
+
+               if (ret == false)
+                       log.warn("Skip test because OS '" + osName + "' is not supported.");
+               return ret;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/systemCall.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/tasks/systemCall.xml
new file mode 100644 (file)
index 0000000..8d35650
--- /dev/null
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="../imports.xml" />\r
+\r
+       <bean id="systemCallSimple" parent="slcTemplate.simpleFlow">\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo">\r
+                                       <property name="message" value="os.name=${os.name}" />\r
+                               </bean>\r
+                               <bean parent="task.systemCall">\r
+                                       <property name="cmd" value="echo Hello World" />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="systemCallList" parent="slcTemplate.simpleFlow">\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.systemCall">\r
+                                       <property name="command">\r
+                                               <list>\r
+                                                       <value>echo</value>\r
+                                                       <value>Hello</value>\r
+                                                       <value>World</value>\r
+                                               </list>\r
+                                       </property>\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="systemCallOsSpecific" parent="slcTemplate.simpleFlow">\r
+               <!-- Direct call to dir under Windows isnot working -->\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.systemCall">\r
+                                       <property name="cmd" value="dir" />\r
+                                       <property name="execDir" value="../.." />\r
+                                       <property name="osCmds">\r
+                                               <map>\r
+                                                       <entry key="Linux" value="ls" />\r
+                                                       <entry key="Mac OS X" value="ls" />\r
+                                               </map>\r
+                                       </property>\r
+                               </bean>\r
+                               <bean parent="task.systemCall">\r
+                                       <property name="command">\r
+                                               <list>\r
+                                                       <value>dir</value>\r
+                                               </list>\r
+                                       </property>\r
+                                       <property name="osCommands">\r
+                                               <map>\r
+                                                       <entry key="Linux">\r
+                                                               <list>\r
+                                                                       <value>ls</value>\r
+                                                               </list>\r
+                                                       </entry>\r
+                                                       <entry key="Mac OS X">\r
+                                                               <list>\r
+                                                                       <value>ls</value>\r
+                                                               </list>\r
+                                                       </entry>\r
+                                               </map>\r
+                                       </property>\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="systemCallWithVar" parent="slcTemplate.simpleFlow">\r
+               <constructor-arg>\r
+                       <bean parent="slcTemplate.simpleSpec">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="var">\r
+                                                       <bean parent="specAttr.primitive" p:value="660" />\r
+                                               </entry>\r
+                                       </map>\r
+                               </property>\r
+                       </bean>\r
+               </constructor-arg>\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.systemCall" scope="execution">\r
+                                       <property name="cmd" value="echo var=@{var}" />\r
+                                       <aop:scoped-proxy />\r
+                               </bean>\r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/test.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/test.xml
new file mode 100644 (file)
index 0000000..5ae7501
--- /dev/null
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
+\r
+       <import resource="imports.xml" /> \r
+\r
+       <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+       <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
+\r
+       <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
+               <property name="testDefinition" ref="myTestDef" />\r
+               <property name="testResult" ref="myTestResult"/>\r
+       </bean>         \r
\r
+       <bean id="spec1" parent="slcTemplate.simpleSpec">\r
+               <property name="attributes">\r
+                       <map>\r
+                               <entry key="testedComponentId">\r
+                                       <bean parent="specAttr.primitive" p:isParameter="true"\r
+                                               p:type="integer" />\r
+                               </entry>\r
+                               <entry key="testData1">\r
+                                       <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                                               p:isParameter="true" p:isFrozen="true" />\r
+                               </entry>\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="flowTemplate1" parent="slcTemplate.simpleFlow"\r
+               abstract="true">\r
+               <constructor-arg ref="spec1" />\r
+               <property name="executables">\r
+                       <list>\r
+                               <bean parent="task.echo">\r
+                                       <property name="message" value="From basic @{testedComponentId}" />\r
+                               </bean>\r
+                               <bean parent="myTestRunTemplate">\r
+                                       <property name="testData">\r
+                                               <bean parent="parameterRef">\r
+                                                       <constructor-arg value="testData1" />\r
+                                               </bean>\r
+                                       </property>\r
+                               </bean>\r
+                               <bean parent="task.echo">\r
+                                       <property name="message"><value>From basic @{testedComponentId}</value></property>\r
+                               </bean>         \r
+                               <bean parent="task.echo">\r
+                                       <property name="message"><value>testData1='@{testData1}'</value></property>\r
+                               </bean>                                                 \r
+                       </list>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="flow1" parent="flowTemplate1" scope="prototype">\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="testedComponentId" value="200" />\r
+                               <entry key="testData1">\r
+                                       <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
+                                               <aop:scoped-proxy/>\r
+                                               <property name="expected" value="tata101" />\r
+                                               <property name="reached" value="tata@{testedComponentId}" />\r
+                                       </bean>\r
+                               </entry>\r
+                       </map>                  \r
+               </constructor-arg>\r
+       </bean>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/FlowNamespaceTest.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/FlowNamespaceTest.java
new file mode 100644 (file)
index 0000000..4ebb667
--- /dev/null
@@ -0,0 +1,50 @@
+package org.argeo.slc.core.execution.xml;
+
+import org.argeo.slc.core.execution.AbstractExecutionFlowTestCase;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.runtime.test.SimpleTestResult;
+import org.springframework.context.ConfigurableApplicationContext;
+
+public abstract class FlowNamespaceTest extends AbstractExecutionFlowTestCase {
+       public void XXXtestCanonical() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("canonic-ns.xml");
+               ((ExecutionFlow) applicationContext.getBean("canonic-ns.001")).run();
+               ((ExecutionFlow) applicationContext.getBean("canonic-ns.002")).run();
+       }
+
+       public void XXXtestAdvanced() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("advanced.xml");
+               ((ExecutionFlow) applicationContext.getBean("flow1")).run();
+               ((ExecutionFlow) applicationContext.getBean("flow2")).run();
+               ((ExecutionFlow) applicationContext.getBean("flow3")).run();
+
+               validateTestResult((SimpleTestResult) applicationContext
+                               .getBean("testResult"));
+       }
+
+       public void XXXtestAdvancedExecution() throws Exception {
+               ConfigurableApplicationContext applicationContext = createApplicationContext("advanced.xml");
+
+               ExecutionContext executionContext = (ExecutionContext) applicationContext
+                               .getBean("executionContext");
+               executionContext.setVariable("param2", 4);
+
+               ((ExecutionFlow) applicationContext.getBean("flow4")).run();
+
+               validateTestResult((SimpleTestResult) applicationContext
+                               .getBean("testResult"));
+       }
+
+       // These tests causes pb when using Spring 3
+       
+       // public void testContainers() throws Exception {
+       // ConfigurableApplicationContext applicationContext =
+       // createApplicationContext("containers.xml");
+       // ((ExecutionFlow) applicationContext.getBean("test.list.flow1")).run();
+       // ((ExecutionFlow) applicationContext.getBean("test.list.flow2")).run();
+       //
+       // validateTestResult((SimpleTestResult) applicationContext
+       // .getBean("testResult"));
+       // }
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/advanced.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/advanced.xml
new file mode 100644 (file)
index 0000000..c316de6
--- /dev/null
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
+       <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
+\r
+       <bean id="testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+       <bean id="testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
+\r
+       <bean id="testRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
+               <property name="testDefinition" ref="testDef" />\r
+               <property name="testResult" ref="testResult"/>\r
+       </bean> \r
+\r
+       <flow:spec id="advanced.spec">\r
+               <description>spec description</description>\r
+               <flow:primitive name="param1" isParameter="true"\r
+                       type="integer" />\r
+               <flow:primitive name="param2" isParameter="true"\r
+                       type="integer" />                       \r
+       </flow:spec>\r
+\r
+\r
+       <flow:flow id="advanced.flowTemplate" abstract="true" spec="advanced.spec"\r
+               path="/path">\r
+               <description>flow description</description>\r
+               <bean parent="task.echo">\r
+                       <property name="message" value="Advanced: param1=@{param1}, param2=@{param2}" />\r
+                       <flow:variable/>\r
+               </bean> \r
+               <flow:flow>\r
+                       <bean parent="task.echo" p:message="Flow in Flow - param1=@{param1}, param2=@{param2} [Not variable]" />\r
+               </flow:flow>\r
\r
+               <bean parent="testRunTemplate">\r
+                       <property name="testData">\r
+                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                       <flow:variable/>\r
+                                       <property name="expected" value="@{param1}" />\r
+                                       <property name="reached" value="@{param2}" />\r
+                               </bean>\r
+                       </property>                                     \r
+               </bean>\r
\r
+       </flow:flow>\r
+\r
+       <flow:flow id="advanced.flowTemplate2" abstract="true" spec="advanced.spec"\r
+               path="/path">\r
+               <bean parent="task.echo" p:message="Advanced2: param1=@{param1}, param2=@{param2}">\r
+                       <flow:variable/>\r
+               </bean>\r
+               <flow:flow parent="advanced.flowTemplate">\r
+                       <flow:arg name="param1" value="@{param1}"/>\r
+                       <flow:arg name="param2">\r
+                               <!-- flow:param in flow:arg -->\r
+                               <flow:param name="param2" />\r
+                       </flow:arg>\r
+               </flow:flow>\r
+       </flow:flow>\r
+\r
+       \r
+       <flow:flow id="flow1" parent="advanced.flowTemplate">\r
+               <flow:arg name="param1" value="1" />\r
+               <flow:arg name="param2" value="1" />\r
+       </flow:flow>\r
+       \r
+       <flow:flow id="flow2">\r
+               <flow:flow parent="advanced.flowTemplate">\r
+                       <flow:arg name="param1" value="2" />\r
+                       <flow:arg name="param2" value="2" />\r
+               </flow:flow>\r
+       </flow:flow>\r
+\r
+       <flow:flow id="flow3" parent="advanced.flowTemplate2">\r
+               <flow:arg name="param1" value="3" />\r
+               <flow:arg name="param2" value="3" />\r
+       </flow:flow>\r
+       \r
+       <flow:flow id="flow4" parent="advanced.flowTemplate">\r
+               <description>Would fail if param 2 is not changed at execution</description>\r
+               <flow:arg name="param1" value="4" />\r
+               <flow:arg name="param2" value="3" />\r
+       </flow:flow>    \r
+\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-001.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-001.xml
new file mode 100644 (file)
index 0000000..aeef3a3
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <bean id="canonic-ns.001" parent="canonic-ns.flowTemplate">\r
+               <description>Canonic 001</description>\r
+               <constructor-arg>\r
+                       <map>\r
+                               <entry key="parameterAtInstantiation" value="1" />\r
+                       </map>\r
+               </constructor-arg>\r
+       </bean>\r
+</beans>\r
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-002.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns-002.xml
new file mode 100644 (file)
index 0000000..6668e67
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans:beans xmlns="http://www.argeo.org/schema/slc-flow"\r
+       xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:p="http://www.springframework.org/schema/p"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <flow id="canonic-ns.002" parent="canonic-ns.flowTemplate">\r
+               <arg name="parameterAtInstantiation" value="2" />\r
+               <arg name="displayWithoutControl" value="102" />\r
+               <arg name="displayWithControl" value="202" />\r
+               <arg name="hide" value="202" />\r
+               <arg name="refWithoutValue">\r
+                       <beans:bean id="testDataOk" p:expected="tata" p:reached="tata"\r
+                               class="org.argeo.slc.runtime.test.BasicTestData" />\r
+               </arg>\r
+       </flow>\r
+</beans:beans>\r
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/canonic-ns.xml
new file mode 100644 (file)
index 0000000..67bf012
--- /dev/null
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans:beans xmlns="http://www.argeo.org/schema/slc-flow"\r
+       xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <beans:import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
+       <beans:import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
+\r
+       <beans:import resource="canonic-ns-001.xml" />\r
+       <beans:import resource="canonic-ns-002.xml" />\r
+       <beans:import resource="tests.xml" />\r
+\r
+       <!--\r
+               Specifications definition is greatly simplified by the flow namespace\r
+       -->\r
+       <spec id="canonic-ns.spec">\r
+               <primitive name="parameterAtInstantiation" isParameter="true"\r
+                       type="integer" />\r
+               <primitive name="displayWithoutControl" value="100"\r
+                       isParameter="true" type="integer" isFrozen="true" />\r
+               <primitive name="displayWithControl" value="200"\r
+                       isParameter="true" type="integer" />\r
+               <primitive name="hide" value="300" isParameter="true" type="integer"\r
+                       isHidden="true" />\r
+               <ref name="refWithValue" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                       isParameter="true" ref="testDataNok" />\r
+               <ref name="refWithoutValue" targetClass="org.argeo.slc.runtime.test.BasicTestData" />\r
+               <ref name="refWithoutValueFrozen" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
+                       isParameter="true" isFrozen="true">\r
+                       <value>\r
+                               <beans:bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                       <aop:scoped-proxy />\r
+                                       <beans:property name="expected" value="tata" />\r
+                                       <beans:property name="reached" value="tata" />\r
+                               </beans:bean>\r
+                       </value>\r
+               </ref>\r
+       </spec>\r
+\r
+       <flow id="canonic-ns.flowTemplate" abstract="true" spec="canonic-ns.spec"\r
+               path="/path">\r
+               <beans:bean parent="task.echo"\r
+                       p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
+                       scope="execution">\r
+                       <aop:scoped-proxy />\r
+               </beans:bean>\r
+               <beans:ref bean="testRun" />\r
+       </flow>\r
+\r
+       <beans:bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
+               <aop:scoped-proxy />\r
+               <beans:property name="expected" value="tata" />\r
+               <beans:property name="reached" value="tata" />\r
+       </beans:bean>\r
+\r
+       <beans:bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
+               <aop:scoped-proxy />\r
+               <beans:property name="expected" value="tata" />\r
+               <beans:property name="reached" value="toto" />\r
+       </beans:bean>\r
+</beans:beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/containers.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/containers.xml
new file mode 100644 (file)
index 0000000..518e5f7
--- /dev/null
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
+       <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
+\r
+       <bean id="testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
+\r
+       <bean id="testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
+\r
+       <bean id="testRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
+               <property name="testDefinition" ref="testDef" />\r
+               <property name="testResult" ref="testResult"/>\r
+       </bean> \r
+\r
+       <flow:spec id="test.list.spec">\r
+               <flow:ref name="list1" targetClass="java.util.List">\r
+                       <flow:value>\r
+                               <!-- a list element can be used directly as default value-->\r
+                               <list>\r
+                                       <value>val1</value>\r
+                               </list>\r
+                       </flow:value>\r
+               </flow:ref>\r
+               <flow:ref name="list2" targetClass="java.util.List" />\r
+               <!-- following parameters are not used in flow -->\r
+               <flow:ref name="dummyMap" targetClass="java.util.Map">\r
+                       <flow:value>\r
+                               <map></map>\r
+                       </flow:value>\r
+               </flow:ref>\r
+               <flow:ref name="dummySet" targetClass="java.util.Set">\r
+                       <flow:value>\r
+                               <set></set>\r
+                       </flow:value>\r
+               </flow:ref>\r
+               <flow:ref name="dummyProperties" targetClass="java.util.Properties">\r
+                       <flow:value>\r
+                               <props></props>\r
+                       </flow:value>\r
+               </flow:ref>\r
+               \r
+       </flow:spec>\r
+\r
+\r
+       <flow:flow id="test.list.flowTemplate" abstract="true" spec="test.list.spec"\r
+               path="/path">\r
+               <bean parent="task.echo">\r
+                       <property name="message" value="list1=@{list1}, list2=@{list2}" />\r
+                       <flow:variable/>\r
+               </bean> \r
+\r
+               <bean parent="testRunTemplate">\r
+                       <property name="testData">\r
+                               <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
+                                       <property name="expected">\r
+                                               <flow:param name="list1"/>\r
+                                       </property>\r
+                                       <property name="reached">\r
+                                               <flow:param name="list2"/>\r
+                                       </property>\r
+                               </bean>\r
+                       </property>                                     \r
+               </bean>\r
\r
+       </flow:flow>\r
+\r
+       <flow:flow id="test.list.flow1" parent="test.list.flowTemplate">\r
+               <flow:arg name="list1">\r
+                       <list>\r
+                               <value>val1</value>\r
+                               <value>val2</value>                     \r
+                       </list>\r
+               </flow:arg>\r
+               <flow:arg name="list2">\r
+                       <list>\r
+                               <value>val1</value>\r
+                               <value>val2</value>                     \r
+                       </list>\r
+               </flow:arg>\r
+               \r
+               <!-- not used in flow (just to test that the syntax is accepted): -->\r
+               <flow:arg name="dummyMap">\r
+                       <map></map>\r
+               </flow:arg>\r
+               <flow:arg name="dummySet">\r
+                       <set></set>\r
+               </flow:arg>\r
+               <flow:arg name="dummyProperties">\r
+                       <props></props>\r
+               </flow:arg>             \r
+               \r
+       </flow:flow>\r
+       \r
+       <flow:flow id="test.list.flow2" parent="test.list.flowTemplate">\r
+               <description>use default value for parameter "list1"</description>\r
+               <flow:arg name="list2">\r
+                       <list>\r
+                               <value>val1</value>\r
+                       </list>\r
+               </flow:arg>\r
+       </flow:flow>\r
+\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/tests.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/execution/xml/tests.xml
new file mode 100644 (file)
index 0000000..5015725
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
+       xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
+\r
+       <bean id="testRun" class="org.argeo.slc.runtime.test.SimpleTestRun">\r
+               <property name="testDefinition">\r
+                       <bean class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
+               </property>\r
+               <property name="testData">\r
+                       <flow:param name="refWithValue" />\r
+               </property>\r
+               <!--            <property name="testData">-->\r
+               <!--                    <bean parent="parameterRef">-->\r
+               <!--                            <constructor-arg value="refWithValue" />-->\r
+               <!--                    </bean>-->\r
+               <!--            </property>-->\r
+               <property name="testResult">\r
+                       <bean parent="slcDefault.test.basicSimpleTestResult" scope="execution">\r
+                               <property name="attributes">\r
+                                       <map>\r
+                                               <entry key="displayWithControl" value="@{displayWithControl}" />\r
+                                       </map>\r
+                               </property>\r
+                               <aop:scoped-proxy />\r
+                       </bean>\r
+               </property>\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/AbstractInternalSpringTestCase.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/AbstractInternalSpringTestCase.java
new file mode 100644 (file)
index 0000000..507bb41
--- /dev/null
@@ -0,0 +1,86 @@
+package org.argeo.slc.core.test.context;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.beans.factory.BeanFactoryUtils;
+import org.springframework.beans.factory.ListableBeanFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/** Helper for tests using a Spring application context. */
+public abstract class AbstractInternalSpringTestCase extends TestCase {
+       protected final Log log = LogFactory.getLog(getClass());
+       private ConfigurableApplicationContext context;
+
+       /**
+        * Gets (and create if necessary) the application context to use. Default
+        * implementation uses a class path xml application context and calls
+        * {@link #getApplicationContextLocation()}.
+        */
+       protected ConfigurableApplicationContext getContext() {
+               if (context == null) {
+                       context = new ClassPathXmlApplicationContext(
+                                       getApplicationContextLocation());
+               }
+               return context;
+       }
+
+       /** Returns a bean from the underlying context */
+       @SuppressWarnings(value = { "unchecked" })
+       protected <T> T getBean(String beanId) {
+               return (T) getContext().getBean(beanId);
+       }
+
+       protected <T> T getBean(Class<? extends T> clss) {
+               T bean = loadSingleFromContext(getContext(), clss);
+               if (bean == null) {
+                       throw new SlcException("Cannot retrieve a unique bean of type "
+                                       + clss);
+               } else {
+                       return bean;
+               }
+       }
+
+       /**
+        * Th location of the application to load. The default implementation
+        * returns <i>applicationContext.xml</i> found in the same package as the
+        * test.
+        */
+       protected String getApplicationContextLocation() {
+               return inPackage("applicationContext.xml");
+       }
+
+       /**
+        * Prefixes the package of the class after converting the '.' to '/' in
+        * order to have a resource path.
+        */
+       protected String inPackage(String suffix) {
+               String prefix = getClass().getPackage().getName().replace('.', '/');
+               return prefix + '/' + suffix;
+       }
+
+       @SuppressWarnings(value = { "unchecked" })
+       protected <T> T loadSingleFromContext(ListableBeanFactory context,
+                       Class<T> clss) {
+               Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
+                               context, clss, false, false);
+               if (beans.size() == 1) {
+                       return beans.values().iterator().next();
+               } else if (beans.size() > 1) {
+                       if (log.isDebugEnabled()) {
+                               log
+                                               .debug(("Found more that on bean for type " + clss
+                                                               + ": " + beans.keySet()));
+                       }
+                       return null;
+               } else {
+                       return null;
+               }
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/ContextTest.java b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/ContextTest.java
new file mode 100644 (file)
index 0000000..64a4369
--- /dev/null
@@ -0,0 +1,31 @@
+package org.argeo.slc.core.test.context;
+
+import java.util.List;
+
+import org.argeo.slc.runtime.test.ContextUtils;
+import org.argeo.slc.runtime.test.SimpleTestResult;
+import org.argeo.slc.test.TestResultPart;
+import org.argeo.slc.test.TestStatus;
+import org.argeo.slc.test.context.ContextAware;
+
+public class ContextTest extends AbstractInternalSpringTestCase {
+
+       public void testComplexContext() {
+               SimpleTestResult testResult = new SimpleTestResult();
+               ContextUtils.compareReachedExpected(
+                               (ContextAware) getBean("context.c1"), testResult);
+               ContextUtils.compareReachedExpected(
+                               (ContextAware) getBean("context.c2"), testResult);
+               ContextUtils.compareReachedExpected(
+                               (ContextAware) getBean("context.c3"), testResult);
+
+               List<TestResultPart> parts = testResult.getParts();
+               assertEquals(6, parts.size());
+               assertEquals(TestStatus.PASSED, parts.get(0).getStatus());
+               assertEquals(TestStatus.PASSED, parts.get(1).getStatus());
+               assertEquals(TestStatus.PASSED, parts.get(2).getStatus());
+               assertEquals(TestStatus.FAILED, parts.get(3).getStatus());
+               assertEquals(TestStatus.PASSED, parts.get(4).getStatus());
+               assertEquals(TestStatus.PASSED, parts.get(5).getStatus());
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/applicationContext.xml b/legacy/org.argeo.slc.spring/ext/test/org/argeo/slc/core/test/context/applicationContext.xml
new file mode 100644 (file)
index 0000000..4949c4e
--- /dev/null
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
+\r
+       <bean id="parentContext.pc1" parent="parentContext.template">\r
+               <property name="values">\r
+                       <map>\r
+                               <entry key="rootvar" value="text" />\r
+                       </map>\r
+               </property>\r
+               <property name="expectedValues">\r
+                       <map>\r
+                               <entry key="reference" value="20" />\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="context.c1" parent="context.template">\r
+               <property name="parentContext" ref="parentContext.pc1" />\r
+               <property name="values">\r
+                       <map>\r
+                               <entry key="reference" value="20" />\r
+                               <entry key="any" value="999" />\r
+                               <entry key="skipped" value="999" />\r
+                       </map>\r
+               </property>\r
+               <property name="expectedValues">\r
+                       <map>\r
+                               <entry key="reference" value="21" />\r
+                               <entry key="any" value="*" />\r
+                               <entry key="skipped" value="!" />\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="context.c2" parent="context.template">\r
+               <property name="parentContext" ref="parentContext.pc1" />\r
+               <property name="values">\r
+                       <map>\r
+                               <entry key="var" value="37" />\r
+                               <entry key="bad" value="56" />\r
+                       </map>\r
+               </property>\r
+               <property name="expectedValues">\r
+                       <map>\r
+                               <entry key="var" value="37" />\r
+                               <entry key="bad" value="57" />\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="parentContext.pc2" parent="parentContext.template">\r
+               <property name="parentContext" ref="parentContext.pc1" />\r
+               <property name="expectedValues">\r
+                       <map>\r
+                               <entry key="reference" value="40" />\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean id="context.c3" parent="context.template">\r
+               <property name="parentContext" ref="parentContext.pc2" />\r
+               <property name="values">\r
+                       <map>\r
+                               <entry key="reference" value="41" />\r
+                               <entry key="rootvar" value="textX" />\r
+                       </map>\r
+               </property>\r
+               <property name="expectedValues">\r
+                       <map>\r
+                               <entry key="reference" value="40" />\r
+                               <entry key="rootvar" value="text" />\r
+                       </map>\r
+               </property>\r
+       </bean>\r
+\r
+\r
+       <bean id="parentContext.template"\r
+               class="org.argeo.slc.core.test.context.SimpleParentContextAware"\r
+               abstract="true">\r
+       </bean>\r
+\r
+       <bean id="context.template"\r
+               class="org.argeo.slc.core.test.context.SimpleContextAware"\r
+               abstract="true">\r
+       </bean>\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/pom.xml b/legacy/org.argeo.slc.spring/pom.xml
new file mode 100644 (file)
index 0000000..fc025e6
--- /dev/null
@@ -0,0 +1,95 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.spring</artifactId>
+       <name>SLC Spring Runtime</name>
+       <dependencies>
+               <!-- Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.enterprise</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.api</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.cms</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.jcr</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+
+               <!-- Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.osgi.boot</artifactId>
+                       <version>${version.argeo-commons}</version>
+                       <scope>provided</scope>
+               </dependency>
+
+               <!-- SLC -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.api</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.jcr</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.repo</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Spring -->
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.beans</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.context</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.expression</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.spring</groupId>
+                       <artifactId>org.springframework.aop</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.gemini</groupId>
+                       <artifactId>org.eclipse.gemini.blueprint.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.tp.gemini</groupId>
+                       <artifactId>org.eclipse.gemini.blueprint.io</artifactId>
+               </dependency>
+
+               <!-- Ant -->
+               <dependency>
+                       <groupId>org.argeo.tp.apache.ant</groupId>
+                       <artifactId>org.apache.ant</artifactId>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/ant/AntFlowGenerator.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/ant/AntFlowGenerator.java
new file mode 100644 (file)
index 0000000..1a6f692
--- /dev/null
@@ -0,0 +1,36 @@
+package org.argeo.slc.ant;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.argeo.slc.core.execution.AbstractExecutionFlowGenerator;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.core.io.Resource;
+
+public class AntFlowGenerator extends AbstractExecutionFlowGenerator {
+       private List<Resource> antFiles = new ArrayList<Resource>();
+
+       protected Map<String, BeanDefinition> createExecutionFlowDefinitions(
+                       ConfigurableListableBeanFactory beanFactory) {
+               Map<String, BeanDefinition> definitions = new HashMap<String, BeanDefinition>();
+
+               for (Resource antFile : antFiles) {
+                       AntRun antRun = new AntRun();
+                       antRun.setBuildFile(antFile);
+
+                       List<Runnable> executables = new ArrayList<Runnable>();
+                       executables.add(antRun);
+                       definitions.put("ant." + antFile.getFilename(),
+                                       createDefaultFlowDefinition(executables));
+               }
+               return definitions;
+       }
+
+       public void setAntFiles(List<Resource> antFiles) {
+               this.antFiles = antFiles;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/ant/AntRun.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/ant/AntRun.java
new file mode 100644 (file)
index 0000000..238e225
--- /dev/null
@@ -0,0 +1,157 @@
+package org.argeo.slc.ant;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.helper.ProjectHelper2;
+import org.argeo.slc.SlcException;
+import org.springframework.core.io.Resource;
+
+public class AntRun implements Runnable {
+       private final static Log log = LogFactory.getLog(AntRun.class);
+
+       private Resource buildFile;
+       private File baseDir;
+
+       private List<String> targets = new ArrayList<String>();
+       private Map<Object, Object> properties = new HashMap<Object, Object>();
+
+       public void run() {
+               Project project = new Project();
+
+               try {
+                       String path = buildFile.getURL().getPath();
+                       project.setUserProperty("ant.file", path);
+                       project.setBaseDir(extractBaseDir(path));
+
+                       project.init();
+                       ProjectHelper projectHelper = new ProjectHelper2();
+                       project.addReference(ProjectHelper.PROJECTHELPER_REFERENCE,
+                                       projectHelper);
+                       projectHelper.parse(project, buildFile.getURL());
+               } catch (Exception e) {
+                       throw new SlcException("Could not parse " + buildFile, e);
+               }
+
+               if (properties != null) {
+                       for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+                               project.setUserProperty(entry.getKey().toString(), entry
+                                               .getValue().toString());
+                       }
+               }
+
+               project.fireBuildStarted();
+               Throwable exception = null;
+               try {
+                       project.addBuildListener(new LoggingListener());
+                       if (targets.size() == 0) {
+                               project.executeTarget(project.getDefaultTarget());
+                       } else {
+                               project.executeTargets(new Vector<String>(targets));
+                       }
+               } catch (Throwable e) {
+                       exception = e;
+                       throw new SlcException("Could not run Ant script " + buildFile, e);
+               } finally {
+                       project.fireBuildFinished(exception);
+               }
+       }
+
+       private File extractBaseDir(String path) {
+               if(this.baseDir!=null)
+                       return this.baseDir;
+               
+               String baseDir = null;
+               if (path.length() > 1) {
+                       int indx = path.lastIndexOf('/', path.length() - 1);
+                       if (indx == -1 || indx == 0) {
+                               baseDir = "/";
+                       } else {
+                               baseDir = path.substring(0, indx) + "/";
+                       }
+               } else {
+                       baseDir = "/";
+               }
+               File file = new File(baseDir);
+               if (file.exists()) {
+                       return file;
+               } else {
+                       return new File(System.getProperty("user.dir"));
+               }
+       }
+
+       public void setBuildFile(Resource buildFile) {
+               this.buildFile = buildFile;
+       }
+
+       public void setTargets(List<String> targets) {
+               this.targets = targets;
+       }
+
+       public void setProperties(Map<Object, Object> properties) {
+               this.properties = properties;
+       }
+
+       public void setBaseDir(File baseDir) {
+               this.baseDir = baseDir;
+       }
+
+       protected static class LoggingListener implements BuildListener {
+
+               public void buildFinished(BuildEvent event) {
+                       if (log.isDebugEnabled())
+                               log.debug("Ant build finished: " + event);
+               }
+
+               public void buildStarted(BuildEvent event) {
+                       if (log.isDebugEnabled())
+                               log.debug("Ant build started: " + event);
+               }
+
+               public void messageLogged(BuildEvent event) {
+                       if (event.getPriority() == Project.MSG_DEBUG) {
+                               if (log.isTraceEnabled())
+                                       log.trace(event.getMessage());
+                       } else if (event.getPriority() == Project.MSG_VERBOSE) {
+                               if (log.isDebugEnabled())
+                                       log.debug(event.getMessage());
+                       } else if (event.getPriority() == Project.MSG_INFO) {
+                               log.info(event.getMessage());
+
+                       } else if (event.getPriority() == Project.MSG_WARN) {
+                               log.warn(event.getMessage());
+
+                       } else if (event.getPriority() == Project.MSG_ERR) {
+                               log.error(event.getMessage());
+                       } else {
+                               log.error(event.getMessage());
+                       }
+               }
+
+               public void targetFinished(BuildEvent event) {
+                       if (log.isTraceEnabled())
+                               log.debug("Target finished: " + event.getTarget());
+               }
+
+               public void targetStarted(BuildEvent event) {
+                       if (log.isTraceEnabled())
+                               log.debug("Target started: " + event.getTarget());
+               }
+
+               public void taskFinished(BuildEvent event) {
+               }
+
+               public void taskStarted(BuildEvent event) {
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentUploader.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/AttachmentUploader.java
new file mode 100644 (file)
index 0000000..fcd2657
--- /dev/null
@@ -0,0 +1,8 @@
+package org.argeo.slc.core.attachment;
+
+import org.argeo.slc.attachment.Attachment;
+import org.springframework.core.io.Resource;
+
+public interface AttachmentUploader {
+       public void upload(Attachment attachment, Resource resource);
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/FileAttachmentsStorage.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/FileAttachmentsStorage.java
new file mode 100644 (file)
index 0000000..b5c9e3c
--- /dev/null
@@ -0,0 +1,163 @@
+package org.argeo.slc.core.attachment;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.attachment.Attachment;
+import org.argeo.slc.attachment.AttachmentsStorage;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
+
+public class FileAttachmentsStorage implements AttachmentsStorage,
+               AttachmentUploader, InitializingBean {
+       private final static Log log = LogFactory
+                       .getLog(FileAttachmentsStorage.class);
+
+       private File attachmentsDirectory;
+
+       private String attachmentsTocFileName = "attachmentsToc.csv";
+
+       private DateFormat dateFormatDay = new SimpleDateFormat("yyyy-MM-dd");
+       private DateFormat dateFormatTime = new SimpleDateFormat("HH:mm:ss");
+
+       public void afterPropertiesSet() {
+               if (attachmentsDirectory == null) {
+
+                       String osgiInstanceArea = System.getProperty("osgi.instance.area");
+                       if (osgiInstanceArea != null) {
+                               if (osgiInstanceArea.startsWith("file:"))
+                                       osgiInstanceArea = osgiInstanceArea.substring("file:"
+                                                       .length());
+                               attachmentsDirectory = new File(osgiInstanceArea
+                                               + File.separator + "slcAttachments");
+                       }
+
+                       if (attachmentsDirectory == null) {
+                               String tempDir = System.getProperty("java.io.tmpdir");
+                               attachmentsDirectory = new File(tempDir + File.separator
+                                               + "slcAttachments");
+                       }
+               }
+               if (!attachmentsDirectory.exists())
+                       attachmentsDirectory.mkdirs();
+               if (log.isDebugEnabled())
+                       log.debug("File attachment storage initialized in directory "
+                                       + attachmentsDirectory);
+       }
+
+       public void retrieveAttachment(Attachment attachment,
+                       OutputStream outputStream) {
+               File file = getFile(attachment);
+               InputStream in = null;
+               try {
+                       byte[] buffer = new byte[1024 * 1024];
+                       in = new FileInputStream(file);
+                       int read = -1;
+                       while ((read = in.read(buffer)) >= 0) {
+                               outputStream.write(buffer, 0, read);
+                       }
+                       if (log.isTraceEnabled())
+                               log.trace("Read " + attachment + " from " + file);
+               } catch (IOException e) {
+                       throw new SlcException("Cannot write attachment " + attachment
+                                       + " to " + file, e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+               }
+       }
+
+       public void storeAttachment(Attachment attachment, InputStream inputStream) {
+               File file = getFile(attachment);
+               FileOutputStream out = null;
+               try {
+                       byte[] buffer = new byte[1024 * 1024];
+                       out = new FileOutputStream(file);
+                       int read = -1;
+                       while ((read = inputStream.read(buffer)) >= 0) {
+                               out.write(buffer, 0, read);
+                       }
+                       if (log.isTraceEnabled())
+                               log.trace("Wrote " + attachment + " to " + file);
+                       updateAttachmentToc(attachment, file);
+               } catch (IOException e) {
+                       throw new SlcException("Cannot write attachment " + attachment
+                                       + " to " + file, e);
+               } finally {
+                       IOUtils.closeQuietly(out);
+               }
+
+       }
+
+       public void upload(Attachment attachment, Resource resource) {
+               try {
+                       storeAttachment(attachment, resource.getInputStream());
+               } catch (IOException e) {
+                       throw new SlcException("Cannot upload attachment " + attachment, e);
+               }
+       }
+
+       /** For monitoring purposes only */
+       protected void updateAttachmentToc(Attachment attachment, File file) {
+               Date date = new Date(file.lastModified());
+               FileWriter writer = null;
+               try {
+                       writer = new FileWriter(attachmentsDirectory + File.separator
+                                       + attachmentsTocFileName, true);
+                       writer.append(dateFormatDay.format(date));
+                       writer.append(',');
+                       writer.append(dateFormatTime.format(date));
+                       writer.append(',');
+                       writer.append(attachment.getUuid());
+                       writer.append(',');
+                       writer.append(attachment.getName());
+                       writer.append(',');
+                       writer.append(attachment.getContentType());
+                       writer.append(',');
+                       writer.append(Long.toString(file.length()));
+                       writer.append(',');
+                       writer.append(file.getCanonicalPath());
+                       writer.append('\n');
+               } catch (IOException e) {
+                       log.warn("Could not update attachments TOC for " + attachment
+                                       + " and file " + file, e);
+               } finally {
+                       IOUtils.closeQuietly(writer);
+               }
+
+       }
+
+       protected File getFile(Attachment attachment) {
+               File file = new File(attachmentsDirectory + File.separator
+                               + attachment.getUuid());
+               return file;
+       }
+
+       public void setAttachmentsDirectory(File attachmentsDirectory) {
+               this.attachmentsDirectory = attachmentsDirectory;
+       }
+
+       public void setAttachmentsTocFileName(String attachmentsTocFileName) {
+               this.attachmentsTocFileName = attachmentsTocFileName;
+       }
+
+       public void setDateFormatDay(DateFormat dateFormatDay) {
+               this.dateFormatDay = dateFormatDay;
+       }
+
+       public void setDateFormatTime(DateFormat dateFormatTime) {
+               this.dateFormatTime = dateFormatTime;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/SimpleAttachment.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/attachment/SimpleAttachment.java
new file mode 100644 (file)
index 0000000..5319d59
--- /dev/null
@@ -0,0 +1,65 @@
+package org.argeo.slc.core.attachment;
+
+import java.io.Serializable;
+import java.util.UUID;
+
+import org.argeo.slc.attachment.Attachment;
+
+public class SimpleAttachment implements Attachment, Serializable {
+       private static final long serialVersionUID = 6615155908800610606L;
+       private String uuid = UUID.randomUUID().toString();
+       private String name;
+       private String contentType = "";
+
+       public SimpleAttachment() {
+       }
+
+       public SimpleAttachment(String uuid, String name, String contentType) {
+               super();
+               this.uuid = uuid;
+               this.name = name;
+               this.contentType = contentType;
+       }
+
+       public String getUuid() {
+               return uuid;
+       }
+
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getContentType() {
+               return contentType;
+       }
+
+       public void setContentType(String contentType) {
+               this.contentType = contentType;
+       }
+
+       public String toString() {
+               return "Attachment #" + uuid + "(" + name + ", " + contentType + ")";
+       }
+
+       public boolean equals(Object obj) {
+               if (obj instanceof Attachment) {
+                       Attachment attachment = (Attachment) obj;
+                       if (uuid != null && attachment.getUuid() != null)
+                               return uuid.equals(attachment.getUuid());
+
+                       if (name != null && attachment.getName() != null)
+                               return name.equals(attachment.getName());
+
+                       return hashCode() == attachment.hashCode();
+               }
+               return false;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/ResourceDistribution.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/ResourceDistribution.java
new file mode 100644 (file)
index 0000000..e449331
--- /dev/null
@@ -0,0 +1,47 @@
+package org.argeo.slc.core.build;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.StreamReadable;
+import org.argeo.slc.build.Distribution;
+import org.springframework.core.io.Resource;
+
+/** A software distribution archive accessible via a {@link Resource}. */
+public class ResourceDistribution implements Distribution, StreamReadable {
+       private Resource resource;
+
+       public ResourceDistribution() {
+       }
+
+       public ResourceDistribution(Resource location) {
+               this.resource = location;
+       }
+
+       public String getDistributionId() {
+               return resource.toString();
+       }
+
+       public Resource getResource() {
+               return resource;
+       }
+
+       public void setResource(Resource resource) {
+               this.resource = resource;
+       }
+
+       public InputStream getInputStream() {
+               try {
+                       return resource.getInputStream();
+               } catch (IOException e) {
+                       throw new SlcException("Cannot get input stream", e);
+               }
+       }
+
+       @Override
+       public String toString() {
+               return resource.toString();
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionDistributionId.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionDistributionId.java
new file mode 100644 (file)
index 0000000..932ecc7
--- /dev/null
@@ -0,0 +1,82 @@
+package org.argeo.slc.core.build;
+
+import java.util.StringTokenizer;
+
+/**
+ * <p>
+ * An implementation of the distribution id using the standard
+ * Major.Minor.Release notation. And additional arbitrary string can also be
+ * added.
+ * </p>
+ * 
+ * <p>
+ * <b>Examples:</b><br>
+ * 0.2.6<br>
+ * 2.4.12.RC1
+ * </p>
+ */
+public class VersionDistributionId {
+
+       private Integer major;
+       private Integer minor;
+       private Integer release;
+       private String additional;
+
+       /** Parse the provided string in order to set the various components. */
+       public void setVersionString(String str) {
+               StringTokenizer st = new StringTokenizer(str, ".");
+               if (st.hasMoreTokens())
+                       major = Integer.parseInt(st.nextToken());
+               if (st.hasMoreTokens())
+                       minor = Integer.parseInt(st.nextToken());
+               if (st.hasMoreTokens())
+                       release = Integer.parseInt(st.nextToken());
+               if (st.hasMoreTokens())
+                       additional = st.nextToken();
+       }
+
+       public Integer getMajor() {
+               return major;
+       }
+
+       public void setMajor(Integer major) {
+               this.major = major;
+       }
+
+       public Integer getMinor() {
+               return minor;
+       }
+
+       public void setMinor(Integer minor) {
+               this.minor = minor;
+       }
+
+       public Integer getRelease() {
+               return release;
+       }
+
+       public void setRelease(Integer release) {
+               this.release = release;
+       }
+
+       public String getAdditional() {
+               return additional;
+       }
+
+       public void setAdditional(String additional) {
+               this.additional = additional;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               // TODO Auto-generated method stub
+               return super.equals(obj);
+       }
+
+       @Override
+       public String toString() {
+               return major + "." + minor + "." + release
+                               + (additional != null ? "." + additional : "");
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionedResourceDistribution.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/VersionedResourceDistribution.java
new file mode 100644 (file)
index 0000000..414a12b
--- /dev/null
@@ -0,0 +1,47 @@
+package org.argeo.slc.core.build;
+
+import org.argeo.slc.NameVersion;
+import org.springframework.core.io.Resource;
+
+/**
+ * The distribution of a software package (jar, zip, RPM, etc.) which is
+ * versioned. The archive itself is accessible via a {@link Resource}.
+ */
+public class VersionedResourceDistribution extends ResourceDistribution
+               implements NameVersion {
+       private String name;
+       private String version;
+
+       public VersionedResourceDistribution() {
+               super();
+       }
+
+       public VersionedResourceDistribution(NameVersion nameVersion,
+                       Resource resource) {
+               this(nameVersion.getName(), nameVersion.getVersion(), resource);
+       }
+
+       public VersionedResourceDistribution(String name, String version,
+                       Resource resource) {
+               super(resource);
+               this.name = name;
+               this.version = version;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getVersion() {
+               return version;
+       }
+
+       public void setVersion(String version) {
+               this.version = version;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/package.html b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/build/package.html
new file mode 100644 (file)
index 0000000..5da2052
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+SLC Build: building of software systems.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DefaultResourceSet.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DefaultResourceSet.java
new file mode 100644 (file)
index 0000000..a5b8536
--- /dev/null
@@ -0,0 +1,171 @@
+package org.argeo.slc.core.deploy;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.util.AntPathMatcher;
+import org.springframework.util.PathMatcher;
+
+public class DefaultResourceSet implements ResourceLoaderAware,
+               InitializingBean, ResourceSet {
+       private final static Log log = LogFactory.getLog(DefaultResourceSet.class);
+       public final static String DEFAULT_EXCLUDES = "**/.svn/**";
+
+       private String base;
+       private String include;
+       private List<String> includes = new ArrayList<String>();
+       private String exclude;
+       private List<String> excludes = new ArrayList<String>();
+       private Boolean useDefaultExcludes = true;
+       private ResourcePatternResolver resourcePatternResolver;
+       private PathMatcher excludePathMatcher = new AntPathMatcher();
+
+       private ResourceLoader resourceLoader;
+
+       /** List the resources, identified by their relative path. */
+       public Map<String, Resource> listResources() {
+               try {
+                       Map<String, Resource> res = new TreeMap<String, Resource>();
+                       if (base == null)
+                               return res;
+                       String baseResUrl = getResourceLoaderToUse().getResource(base)
+                                       .getURL().toString();
+                       for (String includePattern : includes)
+                               processInclude(res, includePattern, baseResUrl);
+                       return res;
+               } catch (IOException e) {
+                       throw new SlcException("Cannot list resource from " + base, e);
+               }
+       }
+
+       protected void processInclude(Map<String, Resource> res, String include,
+                       String baseResUrl) throws IOException {
+               String pattern = base + "/" + include;
+               if (log.isTraceEnabled())
+                       log.trace("Look for resources with pattern '" + pattern
+                                       + "' in base url " + baseResUrl);
+               Resource[] resources = resourcePatternResolver.getResources(pattern);
+               resources: for (Resource resource : resources) {
+                       String url = resource.getURL().toString();
+                       String relPath = url.substring(baseResUrl.length());
+
+                       // skip dir
+                       if (relPath.charAt(relPath.length() - 1) == '/') {
+                               if (log.isTraceEnabled())
+                                       log.trace("Skip directory " + relPath + "=" + resource);
+                               continue resources;
+                       }
+
+                       // make sure there is not starting '/'
+                       if (relPath.charAt(0) == '/')
+                               relPath = relPath.substring(1);
+
+                       // skip excludes
+                       for (String exclude : excludes)
+                               if (excludePathMatcher.match(exclude, relPath)) {
+                                       if (log.isTraceEnabled())
+                                               log.trace("Exclude " + relPath + "=" + resource);
+                                       continue resources;
+                               }
+
+                       // check if already exists
+                       if (res.containsKey(relPath))
+                               log.warn(relPath + " already matched by " + res.get(relPath)
+                                               + ", " + resource + " will override it.");
+
+                       // store the marched resource
+                       res.put(relPath, resource);
+                       if (log.isTraceEnabled())
+                               log.trace(relPath + "=" + resource);
+               }
+
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               if (resourcePatternResolver == null)
+                       resourcePatternResolver = new PathMatchingResourcePatternResolver(
+                                       getResourceLoaderToUse());
+               if (include != null)
+                       addCommaSeparatedToList(include, includes);
+               if (exclude != null)
+                       addCommaSeparatedToList(exclude, excludes);
+
+               if (includes.size() == 0)
+                       includes.add("**");
+
+               if (useDefaultExcludes)
+                       addCommaSeparatedToList(DEFAULT_EXCLUDES, excludes);
+       }
+
+       private void addCommaSeparatedToList(String str, List<String> lst) {
+               StringTokenizer st = new StringTokenizer(str, ",");
+               while (st.hasMoreTokens()) {
+                       String token = st.nextToken();
+                       if (!lst.contains(token))
+                               lst.add(token);
+               }
+       }
+
+       public void setResourceLoader(ResourceLoader resourceLoader) {
+               this.resourceLoader = resourceLoader;
+       }
+
+       /**
+        * Can be overridden in order to provide the proper resource loader used to
+        * resolve resources.
+        */
+       public ResourceLoader getResourceLoaderToUse() {
+               return resourceLoader;
+       }
+
+       public void setBase(String base) {
+               this.base = base;
+       }
+
+       public void setInclude(String include) {
+               this.include = include;
+       }
+
+       public void setIncludes(List<String> includes) {
+               this.includes = includes;
+       }
+
+       public void setExclude(String exclude) {
+               this.exclude = exclude;
+       }
+
+       public void setExcludes(List<String> excludes) {
+               this.excludes = excludes;
+       }
+
+       public void setUseDefaultExcludes(Boolean useDefaultExcludes) {
+               this.useDefaultExcludes = useDefaultExcludes;
+       }
+
+       public void setExcludePathMatcher(PathMatcher excludePathMatcher) {
+               this.excludePathMatcher = excludePathMatcher;
+       }
+
+       public void setResourcePatternResolver(
+                       ResourcePatternResolver resourcePatternResolver) {
+               this.resourcePatternResolver = resourcePatternResolver;
+       }
+
+       public ResourcePatternResolver getResourcePatternResolver() {
+               return resourcePatternResolver;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DigestCheck.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/DigestCheck.java
new file mode 100644 (file)
index 0000000..e7908eb
--- /dev/null
@@ -0,0 +1,26 @@
+package org.argeo.slc.core.deploy;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.argeo.slc.SlcException;
+import org.springframework.core.io.Resource;
+import org.springframework.util.DigestUtils;
+
+/** Add Spring capabilities to {@link DigestUtils} */
+public class DigestCheck extends DigestUtils {
+       public static String digest(String algorithm, Resource resource) {
+               try {
+                       File file = resource.getFile();
+                       return org.argeo.util.DigestUtils.digest(algorithm, file);
+               } catch (IOException e) {
+                       try {
+                               return org.argeo.util.DigestUtils.digest(algorithm,
+                                               resource.getInputStream());
+                       } catch (IOException e1) {
+                               throw new SlcException("Cannot digest " + resource
+                                               + " with algorithm " + algorithm, e);
+                       }
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/LocalFilesDeployment.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/LocalFilesDeployment.java
new file mode 100644 (file)
index 0000000..d339b94
--- /dev/null
@@ -0,0 +1,59 @@
+package org.argeo.slc.core.deploy;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.argeo.slc.SlcException;
+import org.springframework.core.io.Resource;
+
+public class LocalFilesDeployment implements Runnable {
+       private String targetBase = "";
+       private ResourceSet resourceSet;
+
+       public LocalFilesDeployment() {
+       }
+
+       public LocalFilesDeployment(ResourceSet resourceSet) {
+               this.resourceSet = resourceSet;
+       }
+
+       public void run() {
+               Map<String, Resource> resources = resourceSet.listResources();
+               for (String relPath : resources.keySet()) {
+                       File targetFile = new File(targetBase + File.separator + relPath);
+                       File parentDir = targetFile.getParentFile();
+                       if (!parentDir.exists())
+                               parentDir.mkdirs();
+
+                       Resource resource = resources.get(relPath);
+
+                       InputStream in = null;
+                       OutputStream out = null;
+                       try {
+                               in = resource.getInputStream();
+                               out = FileUtils.openOutputStream(targetFile);
+                               IOUtils.copy(in, out);
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot extract " + resource + " to "
+                                               + targetFile, e);
+                       } finally {
+                               IOUtils.closeQuietly(in);
+                               IOUtils.closeQuietly(out);
+                       }
+               }
+       }
+
+       public void setTargetBase(String targetBase) {
+               this.targetBase = targetBase;
+       }
+
+       public void setResourceSet(ResourceSet resourceSet) {
+               this.resourceSet = resourceSet;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/MultiResourceSet.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/MultiResourceSet.java
new file mode 100644 (file)
index 0000000..2086712
--- /dev/null
@@ -0,0 +1,30 @@
+package org.argeo.slc.core.deploy;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.core.io.Resource;
+
+public class MultiResourceSet implements ResourceSet {
+       private List<ResourceSet> resourceSets = new ArrayList<ResourceSet>();
+
+       public Map<String, Resource> listResources() {
+               Map<String, Resource> res = new HashMap<String, Resource>();
+               for (ResourceSet resourceSet : resourceSets) {
+                       res.putAll(resourceSet.listResources());
+               }
+               return res;
+       }
+
+       /** Last listed override previous for the same relative paths. */
+       public void setResourceSets(List<ResourceSet> resourceSets) {
+               this.resourceSets = resourceSets;
+       }
+
+       public List<ResourceSet> getResourceSets() {
+               return resourceSets;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/ResourceSet.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/ResourceSet.java
new file mode 100644 (file)
index 0000000..6d670e0
--- /dev/null
@@ -0,0 +1,13 @@
+package org.argeo.slc.core.deploy;
+
+import java.util.Map;
+
+import org.springframework.core.io.Resource;
+
+public interface ResourceSet {
+       /**
+        * List the resources, identified by their relative path. Relative paths
+        * must NOT start with a '/'.
+        */
+       public Map<String, Resource> listResources();
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/SimpleExecutables.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/SimpleExecutables.java
new file mode 100644 (file)
index 0000000..6c93368
--- /dev/null
@@ -0,0 +1,75 @@
+package org.argeo.slc.core.deploy;
+
+import java.io.File;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.InstalledExecutables;
+import org.argeo.slc.deploy.TargetData;
+
+public class SimpleExecutables implements InstalledExecutables {
+       private final static Log log = LogFactory.getLog(SimpleExecutables.class);
+
+       private String baseDir;
+       private Map<String, String> paths = new TreeMap<String, String>();
+
+       private Distribution distribution;
+
+       public String getExecutablePath(String key) {
+               String path = paths.get(key);
+               if (path == null) {
+                       if (log.isDebugEnabled())
+                               log.debug("No executable path found for key " + key
+                                               + ", using the key as executable name.");
+                       path = key;
+               }
+
+               if (baseDir != null)
+                       path = baseDir + File.separator + path;
+               return path;
+       }
+
+       public String getDeployedSystemId() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public DeploymentData getDeploymentData() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public Distribution getDistribution() {
+               return distribution;
+       }
+
+       public TargetData getTargetData() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public String getBaseDir() {
+               return baseDir;
+       }
+
+       public void setBaseDir(String baseDir) {
+               this.baseDir = baseDir;
+       }
+
+       public Map<String, String> getPaths() {
+               return paths;
+       }
+
+       public void setPaths(Map<String, String> paths) {
+               this.paths = paths;
+       }
+
+       public void setDistribution(Distribution distribution) {
+               this.distribution = distribution;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/VersionedDirSync.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/VersionedDirSync.java
new file mode 100644 (file)
index 0000000..40f6735
--- /dev/null
@@ -0,0 +1,68 @@
+package org.argeo.slc.core.deploy;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.deploy.VersioningDriver;
+
+/**
+ * Synchronizes an URL to a local directory, taking into account versioning
+ * information if possible.
+ */
+public class VersionedDirSync implements Runnable {
+       private final static Log log = LogFactory.getLog(VersionedDirSync.class);
+
+       private VersioningDriver versioningDriver;
+       private File dir;
+       private String url;
+       private Boolean clean = false;
+
+       private Boolean changed = null;
+
+       public void run() {
+               changed = null;
+               if (clean) {
+                       try {
+                               log.info("Clean " + dir);
+                               FileUtils.deleteDirectory(dir);
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot delete checkout directory "
+                                               + dir, e);
+                       }
+                       dir.mkdirs();
+               }
+               log.info("Checkout " + url + " to " + dir);
+               changed = versioningDriver.checkout(url, dir, true);
+               if (log.isDebugEnabled())
+                       log.debug("Synchronized " + url + " to " + dir);
+       }
+
+       public void setVersioningDriver(VersioningDriver versioningDriver) {
+               this.versioningDriver = versioningDriver;
+       }
+
+       public void setDir(File dir) {
+               this.dir = dir;
+       }
+
+       public void setUrl(String url) {
+               this.url = url;
+       }
+
+       /** Delete before checkout */
+       public void setClean(Boolean clean) {
+               this.clean = clean;
+       }
+
+       /** Whether last call has changed the directory */
+       public Boolean getChanged() {
+               if (changed == null)
+                       throw new SlcException("Sync has not run");
+               return changed;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/package.html b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/deploy/package.html
new file mode 100644 (file)
index 0000000..f3a4c5b
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+SLC Deploy: deployment of software systems.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractExecutionFlowGenerator.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractExecutionFlowGenerator.java
new file mode 100644 (file)
index 0000000..1986115
--- /dev/null
@@ -0,0 +1,59 @@
+package org.argeo.slc.core.execution;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+import org.springframework.core.Ordered;
+import org.springframework.core.PriorityOrdered;
+
+public abstract class AbstractExecutionFlowGenerator implements
+               BeanFactoryPostProcessor, PriorityOrdered {
+       private final Log log = LogFactory.getLog(getClass());
+
+       protected abstract Map<String, BeanDefinition> createExecutionFlowDefinitions(
+                       ConfigurableListableBeanFactory beanFactory);
+
+       public void postProcessBeanFactory(
+                       ConfigurableListableBeanFactory beanFactory) throws BeansException {
+               if (!(beanFactory instanceof BeanDefinitionRegistry)) {
+                       throw new SlcException("Can only work on "
+                                       + BeanDefinitionRegistry.class);
+               }
+
+               Map<String, BeanDefinition> definitions = createExecutionFlowDefinitions(beanFactory);
+
+               for (String beanName : definitions.keySet()) {
+                       if (log.isTraceEnabled())
+                               log.debug("Registering execution flow " + beanName);
+                       ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(
+                                       beanName, definitions.get(beanName));
+               }
+       }
+
+       protected GenericBeanDefinition createDefaultFlowDefinition(
+                       List<Runnable> executables) {
+               GenericBeanDefinition bd = new GenericBeanDefinition();
+               bd.setBeanClass(DefaultExecutionFlow.class);
+
+               MutablePropertyValues mpv = new MutablePropertyValues();
+               mpv.addPropertyValue("executables", executables);
+
+               bd.setPropertyValues(mpv);
+               return bd;
+       }
+
+       public int getOrder() {
+               return Ordered.HIGHEST_PRECEDENCE;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/AbstractSpringExecutionModule.java
new file mode 100644 (file)
index 0000000..366b8d4
--- /dev/null
@@ -0,0 +1,117 @@
+package org.argeo.slc.core.execution;
+
+import org.argeo.slc.execution.ExecutionModule;
+
+@Deprecated
+public abstract class AbstractSpringExecutionModule implements ExecutionModule
+                {
+/*
+       protected ApplicationContext applicationContext;
+
+       protected ExecutionContext executionContext;
+
+       protected ExecutionFlowDescriptorConverter descriptorConverter = new DefaultDescriptorConverter();
+
+       public ExecutionModuleDescriptor getDescriptor() {
+               ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
+               md.setName(getName());
+               md.setVersion(getVersion());
+
+               Map<String, ExecutionFlow> executionFlows = listFlows();
+               for (String name : executionFlows.keySet()) {
+                       ExecutionFlow executionFlow = executionFlows.get(name);
+
+                       Assert.notNull(executionFlow.getName());
+                       Assert.state(name.equals(executionFlow.getName()));
+
+                       ExecutionSpec executionSpec = executionFlow.getExecutionSpec();
+                       Assert.notNull(executionSpec);
+                       Assert.notNull(executionSpec.getName());
+
+                       Map<String, Object> values = new TreeMap<String, Object>();
+                       for (String key : executionSpec.getAttributes().keySet()) {
+                               ExecutionSpecAttribute attribute = executionSpec
+                                               .getAttributes().get(key);
+
+                               if (executionFlow.isSetAsParameter(key)) {
+                                       Object value = executionFlow.getParameter(key);
+                                       if (attribute instanceof PrimitiveSpecAttribute) {
+                                               PrimitiveValue primitiveValue = new PrimitiveValue();
+                                               primitiveValue
+                                                               .setType(((PrimitiveSpecAttribute) attribute)
+                                                                               .getType());
+                                               primitiveValue.setValue(value);
+                                               values.put(key, primitiveValue);
+                                       } else if (attribute instanceof RefSpecAttribute) {
+                                               RefValue refValue = new RefValue();
+                                               if (value instanceof ScopedObject) {
+                                                       refValue.setLabel("RUNTIME "
+                                                                       + value.getClass().getName());
+                                               } else {
+                                                       refValue.setLabel("STATIC "
+                                                                       + value.getClass().getName());
+                                               }
+                                               values.put(key, refValue);
+                                       } else if (attribute instanceof ResourceSpecAttribute) {
+                                               PrimitiveValue primitiveValue = new PrimitiveValue();
+                                               primitiveValue
+                                                               .setType(((ResourceSpecAttribute) attribute)
+                                                                               .getType());
+                                               primitiveValue.setValue(value);
+                                               values.put(key, primitiveValue);
+                                       } else {
+                                               throw new SlcException("Unkown spec attribute type "
+                                                               + attribute.getClass());
+                                       }
+                               }
+
+                       }
+
+                       ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name,
+                                       values, executionSpec);
+                       if (executionFlow.getPath() != null)
+                               efd.setPath(executionFlow.getPath());
+
+                       // Add execution spec if necessary
+                       if (!md.getExecutionSpecs().contains(executionSpec))
+                               md.getExecutionSpecs().add(executionSpec);
+
+                       // Add execution flow
+                       md.getExecutionFlows().add(efd);
+               }
+
+               return md;
+       }
+
+       protected Map<String, ExecutionFlow> listFlows() {
+               GenericBeanFactoryAccessor accessor = new GenericBeanFactoryAccessor(
+                               applicationContext);
+               Map<String, ExecutionFlow> executionFlows = accessor
+                               .getBeansOfType(ExecutionFlow.class);
+               return executionFlows;
+       }
+
+       public void execute(ExecutionFlowDescriptor executionFlowDescriptor) {
+               if (descriptorConverter != null)
+                       executionContext.addVariables(descriptorConverter
+                                       .convertValues(executionFlowDescriptor));
+               ExecutionFlow flow = (ExecutionFlow) applicationContext.getBean(
+                               executionFlowDescriptor.getName(), ExecutionFlow.class);
+               flow.run();
+       }
+
+       public void setApplicationContext(ApplicationContext applicationContext)
+                       throws BeansException {
+               this.applicationContext = applicationContext;
+       }
+
+       public void setExecutionContext(ExecutionContext executionContext) {
+               this.executionContext = executionContext;
+       }
+
+       public void setDescriptorConverter(
+                       ExecutionFlowDescriptorConverter descriptorConverter) {
+               this.descriptorConverter = descriptorConverter;
+       }*/
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgent.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgent.java
new file mode 100644 (file)
index 0000000..c878e24
--- /dev/null
@@ -0,0 +1,11 @@
+package org.argeo.slc.core.execution;
+
+/** Implements the base methods of an SLC agent. */
+@Deprecated
+public class DefaultAgent extends org.argeo.slc.runtime.DefaultAgent {
+
+       public DefaultAgent() {
+               super();
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgentCli.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultAgentCli.java
new file mode 100644 (file)
index 0000000..8e0ccd1
--- /dev/null
@@ -0,0 +1,13 @@
+package org.argeo.slc.core.execution;
+
+/**
+ * Authenticates thread and executes synchronously a command line execution.
+ * Reference implementation of args to URIs algorithm.
+ */
+@Deprecated
+public class DefaultAgentCli extends org.argeo.slc.runtime.DefaultAgentCli {
+
+       public DefaultAgentCli() {
+               super();
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlow.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlow.java
new file mode 100644 (file)
index 0000000..f3b4eb1
--- /dev/null
@@ -0,0 +1,32 @@
+package org.argeo.slc.core.execution;
+
+import java.util.Map;
+
+import org.argeo.slc.execution.ExecutionSpec;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.InitializingBean;
+
+/** Default implementation of an execution flow. */
+@Deprecated
+public class DefaultExecutionFlow extends org.argeo.slc.runtime.DefaultExecutionFlow
+               implements InitializingBean, BeanNameAware {
+       public DefaultExecutionFlow() {
+               super();
+       }
+
+       public DefaultExecutionFlow(ExecutionSpec executionSpec, Map<String, Object> parameters) {
+               super(executionSpec, parameters);
+       }
+
+       public DefaultExecutionFlow(ExecutionSpec executionSpec) {
+               super(executionSpec);
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               init();
+       }
+
+       public void setBeanName(String name) {
+               setName(name);
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionFlowDescriptorConverter.java
new file mode 100644 (file)
index 0000000..0bdeb53
--- /dev/null
@@ -0,0 +1,350 @@
+package org.argeo.slc.core.execution;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
+import org.argeo.slc.execution.ExecutionModuleDescriptor;
+import org.argeo.slc.execution.ExecutionSpec;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.FlowConfigurationException;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValue;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveUtils;
+import org.argeo.slc.primitive.PrimitiveValue;
+import org.springframework.aop.scope.ScopedObject;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.util.StringUtils;
+
+/**
+ * Performs conversion in both direction between data exchanged with the agent
+ * and the data in the application context.
+ */
+public class DefaultExecutionFlowDescriptorConverter implements
+               ExecutionFlowDescriptorConverter, ApplicationContextAware {
+       public final static String REF_VALUE_TYPE_BEAN_NAME = "beanName";
+
+       /** Workaround for https://www.spartadn.com/bugzilla/show_bug.cgi?id=206 */
+       private final static String REF_VALUE_INTERNAL = "[internal]";
+
+       private final static Log log = LogFactory
+                       .getLog(DefaultExecutionFlowDescriptorConverter.class);
+
+       private ApplicationContext applicationContext;
+
+       @SuppressWarnings("unused")
+       public Map<String, Object> convertValues(
+                       ExecutionFlowDescriptor executionFlowDescriptor) {
+               Map<String, Object> values = executionFlowDescriptor.getValues();
+               Map<String, Object> convertedValues = new HashMap<String, Object>();
+               ExecutionSpec executionSpec = executionFlowDescriptor
+                               .getExecutionSpec();
+
+               if (executionSpec == null && log.isTraceEnabled())
+                       log.warn("Execution spec is null for " + executionFlowDescriptor);
+
+               if (values != null && executionSpec != null) {
+                       values: for (String key : values.keySet()) {
+                               ExecutionSpecAttribute attribute = executionSpec
+                                               .getAttributes().get(key);
+
+                               if (attribute == null)
+                                       throw new FlowConfigurationException(
+                                                       "No spec attribute defined for '" + key + "'");
+
+                               if (attribute.getIsConstant())
+                                       continue values;
+
+                               Object value = values.get(key);
+                               if (value instanceof PrimitiveValue) {
+                                       PrimitiveValue primitiveValue = (PrimitiveValue) value;
+                                       // TODO: check class <=> type
+                                       convertedValues.put(key, primitiveValue.getValue());
+                               } else if (value instanceof RefValue) {
+                                       RefValue refValue = (RefValue) value;
+                                       String type = refValue.getType();
+                                       if (REF_VALUE_TYPE_BEAN_NAME.equals(type)) {
+                                               // FIXME: UI should send all information about spec
+                                               // - targetClass
+                                               // - name
+                                               // String executionSpecName = executionSpec.getName();
+                                               // ExecutionSpec localSpec = (ExecutionSpec)
+                                               // applicationContext
+                                               // .getBean(executionSpecName);
+                                               // RefSpecAttribute localAttr = (RefSpecAttribute)
+                                               // localSpec
+                                               // .getAttributes().get(key);
+                                               // Class<?> targetClass = localAttr.getTargetClass();
+                                               //
+                                               // String primitiveType = PrimitiveUtils
+                                               // .classAsType(targetClass);
+                                               String primitiveType = null;
+                                               if (primitiveType != null) {
+                                                       // not active
+                                                       String ref = refValue.getRef();
+                                                       Object obj = PrimitiveUtils.convert(primitiveType,
+                                                                       ref);
+                                                       convertedValues.put(key, obj);
+                                               } else {
+                                                       String ref = refValue.getRef();
+                                                       if (ref != null && !ref.equals(REF_VALUE_INTERNAL)) {
+                                                               Object obj = null;
+                                                               if (applicationContext.containsBean(ref)) {
+                                                                       obj = applicationContext.getBean(ref);
+                                                               } else {
+                                                                       // FIXME: hack in order to pass primitive
+                                                                       obj = ref;
+                                                               }
+                                                               convertedValues.put(key, obj);
+                                                       } else {
+                                                               log.warn("Cannot interpret " + refValue);
+                                                       }
+                                               }
+                                       } else if (PrimitiveUtils.typeAsClass(type) != null) {
+                                               String ref = refValue.getRef();
+                                               Object obj = PrimitiveUtils.convert(type, ref);
+                                               convertedValues.put(key, obj);
+                                       } else {
+                                               throw new FlowConfigurationException(
+                                                               "Ref value type not supported: "
+                                                                               + refValue.getType());
+                                       }
+                               } else {
+                                       // default is to take the value as is
+                                       convertedValues.put(key, value);
+                               }
+                       }
+               }
+               return convertedValues;
+       }
+
+       public void addFlowsToDescriptor(ExecutionModuleDescriptor md,
+                       Map<String, ExecutionFlow> executionFlows) {
+               SortedSet<ExecutionFlowDescriptor> set = new TreeSet<ExecutionFlowDescriptor>(
+                               new ExecutionFlowDescriptorComparator());
+               for (String name : executionFlows.keySet()) {
+                       ExecutionFlow executionFlow = executionFlows.get(name);
+
+                       ExecutionFlowDescriptor efd = getExecutionFlowDescriptor(executionFlow);
+                       ExecutionSpec executionSpec = efd.getExecutionSpec();
+
+                       // Add execution spec if necessary
+                       if (!md.getExecutionSpecs().contains(executionSpec))
+                               md.getExecutionSpecs().add(executionSpec);
+
+                       // Add execution flow
+                       set.add(efd);
+                       // md.getExecutionFlows().add(efd);
+               }
+               md.getExecutionFlows().addAll(set);
+       }
+
+       public ExecutionFlowDescriptor getExecutionFlowDescriptor(
+                       ExecutionFlow executionFlow) {
+               if (executionFlow.getName() == null)
+                       throw new FlowConfigurationException("Flow name is null: "
+                                       + executionFlow);
+               String name = executionFlow.getName();
+
+               ExecutionSpec executionSpec = executionFlow.getExecutionSpec();
+               if (executionSpec == null)
+                       throw new FlowConfigurationException("Execution spec is null: "
+                                       + executionFlow);
+               if (executionSpec.getName() == null)
+                       throw new FlowConfigurationException(
+                                       "Execution spec name is null: " + executionSpec);
+
+               Map<String, Object> values = new TreeMap<String, Object>();
+               for (String key : executionSpec.getAttributes().keySet()) {
+                       ExecutionSpecAttribute attribute = executionSpec.getAttributes()
+                                       .get(key);
+
+                       if (attribute instanceof PrimitiveSpecAttribute) {
+                               if (executionFlow.isSetAsParameter(key)) {
+                                       Object value = executionFlow.getParameter(key);
+                                       PrimitiveValue primitiveValue = new PrimitiveValue();
+                                       primitiveValue.setType(((PrimitiveSpecAttribute) attribute)
+                                                       .getType());
+                                       primitiveValue.setValue(value);
+                                       values.put(key, primitiveValue);
+                               } else {
+                                       // no need to add a primitive value if it is not set,
+                                       // all necessary information is in the spec
+                               }
+                       } else if (attribute instanceof RefSpecAttribute) {
+                               if (attribute.getIsConstant()) {
+                                       values.put(key, new RefValue(REF_VALUE_INTERNAL));
+                               } else
+                                       values.put(
+                                                       key,
+                                                       buildRefValue((RefSpecAttribute) attribute,
+                                                                       executionFlow, key));
+                       } else {
+                               throw new FlowConfigurationException(
+                                               "Unkown spec attribute type " + attribute.getClass());
+                       }
+
+               }
+
+               ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name, null,
+                               values, executionSpec);
+               // Takes description from spring
+               BeanFactory bf = getBeanFactory();
+               if (bf != null) {
+                       BeanDefinition bd = getBeanFactory().getBeanDefinition(name);
+                       efd.setDescription(bd.getDescription());
+               }
+               return efd;
+       }
+
+       protected RefValue buildRefValue(RefSpecAttribute rsa,
+                       ExecutionFlow executionFlow, String key) {
+               RefValue refValue = new RefValue();
+               // FIXME: UI should be able to deal with other types
+               refValue.setType(REF_VALUE_TYPE_BEAN_NAME);
+               Class<?> targetClass = rsa.getTargetClass();
+               String primitiveType = PrimitiveUtils.classAsType(targetClass);
+               if (primitiveType != null) {
+                       if (executionFlow.isSetAsParameter(key)) {
+                               Object value = executionFlow.getParameter(key);
+                               refValue.setRef(value.toString());
+                       }
+                       refValue.setType(primitiveType);
+                       return refValue;
+               } else {
+
+                       if (executionFlow.isSetAsParameter(key)) {
+                               String ref = null;
+                               Object value = executionFlow.getParameter(key);
+                               if (applicationContext == null) {
+                                       log.warn("No application context declared, cannot scan ref value.");
+                                       ref = value.toString();
+                               } else {
+
+                                       // look for a ref to the value
+                                       Map<String, ?> beans = getBeanFactory()
+                                                       .getBeansOfType(targetClass, false, false);
+                                       // TODO: also check scoped beans
+                                       beans: for (String beanName : beans.keySet()) {
+                                               Object obj = beans.get(beanName);
+                                               if (value instanceof ScopedObject) {
+                                                       // don't call methods of the target of the scope
+                                                       if (obj instanceof ScopedObject)
+                                                               if (value == obj) {
+                                                                       ref = beanName;
+                                                                       break beans;
+                                                               }
+                                               } else {
+                                                       if (obj.equals(value)) {
+                                                               ref = beanName;
+                                                               break beans;
+                                                       }
+                                               }
+                                       }
+                               }
+                               if (ref == null) {
+                                       if (log.isTraceEnabled())
+                                               log.trace("Cannot define reference for ref spec attribute "
+                                                               + key
+                                                               + " in "
+                                                               + executionFlow
+                                                               + " ("
+                                                               + rsa
+                                                               + ")."
+                                                               + " If it is an inner bean consider put it frozen.");
+                                       ref = REF_VALUE_INTERNAL;
+                               } else {
+                                       if (log.isTraceEnabled())
+                                               log.trace(ref
+                                                               + " is the reference for ref spec attribute "
+                                                               + key + " in " + executionFlow + " (" + rsa
+                                                               + ")");
+                               }
+                               refValue.setRef(ref);
+                       }
+                       return refValue;
+               }
+       }
+
+       /** @return can be null */
+       private ConfigurableListableBeanFactory getBeanFactory() {
+               if (applicationContext == null)
+                       return null;
+               return ((ConfigurableApplicationContext) applicationContext)
+                               .getBeanFactory();
+       }
+
+       /** Must be use within the execution application context */
+       public void setApplicationContext(ApplicationContext applicationContext)
+                       throws BeansException {
+               this.applicationContext = applicationContext;
+       }
+
+       private static class ExecutionFlowDescriptorComparator implements
+                       Comparator<ExecutionFlowDescriptor> {
+               @SuppressWarnings("deprecation")
+               public int compare(ExecutionFlowDescriptor o1,
+                               ExecutionFlowDescriptor o2) {
+                       // TODO: write unit tests for this
+
+                       String name1 = o1.getName();
+                       String name2 = o2.getName();
+
+                       String path1 = o1.getPath();
+                       String path2 = o2.getPath();
+
+                       // Check whether name include path
+                       int lastIndex1 = name1.lastIndexOf('/');
+                       // log.debug(name1+", "+lastIndex1);
+                       if (!StringUtils.hasText(path1) && lastIndex1 >= 0) {
+                               path1 = name1.substring(0, lastIndex1);
+                               name1 = name1.substring(lastIndex1 + 1);
+                       }
+
+                       int lastIndex2 = name2.lastIndexOf('/');
+                       if (!StringUtils.hasText(path2) && lastIndex2 >= 0) {
+                               path2 = name2.substring(0, lastIndex2);
+                               name2 = name2.substring(lastIndex2 + 1);
+                       }
+
+                       // Perform the actual comparison
+                       if (StringUtils.hasText(path1) && StringUtils.hasText(path2)) {
+                               if (path1.equals(path2))
+                                       return name1.compareTo(name2);
+                               else if (path1.startsWith(path2))
+                                       return -1;
+                               else if (path2.startsWith(path1))
+                                       return 1;
+                               else
+                                       return path1.compareTo(path2);
+                       } else if (!StringUtils.hasText(path1)
+                                       && StringUtils.hasText(path2)) {
+                               return 1;
+                       } else if (StringUtils.hasText(path1)
+                                       && !StringUtils.hasText(path2)) {
+                               return -1;
+                       } else if (!StringUtils.hasText(path1)
+                                       && !StringUtils.hasText(path2)) {
+                               return name1.compareTo(name2);
+                       } else {
+                               return 0;
+                       }
+               }
+
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java
new file mode 100644 (file)
index 0000000..e603f71
--- /dev/null
@@ -0,0 +1,98 @@
+package org.argeo.slc.core.execution;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValueChoice;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ConfigurableApplicationContext;
+
+/** Spring based implementation of execution specifications. */
+@Deprecated
+public class DefaultExecutionSpec extends org.argeo.slc.runtime.DefaultExecutionSpec
+               implements BeanNameAware, ApplicationContextAware, InitializingBean {
+       private static final long serialVersionUID = 5159882223926926539L;
+       private final static Log log = LogFactory.getLog(DefaultExecutionSpec.class);
+       private transient ApplicationContext applicationContext;
+
+       public DefaultExecutionSpec() {
+               super();
+       }
+
+       public void setBeanName(String name) {
+               setName(name);
+       }
+
+       private ConfigurableListableBeanFactory getBeanFactory() {
+               return ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
+       }
+
+       public void setApplicationContext(ApplicationContext applicationContext) {
+               this.applicationContext = applicationContext;
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               if (getDescription() == null) {
+                       try {
+                               setDescription(getBeanFactory().getBeanDefinition(getName()).getDescription());
+                       } catch (NoSuchBeanDefinitionException e) {
+                               // silent
+                       }
+               }
+
+               for (String key : getAttributes().keySet()) {
+                       ExecutionSpecAttribute attr = getAttributes().get(key);
+                       if (attr instanceof RefSpecAttribute) {
+                               RefSpecAttribute rsa = (RefSpecAttribute) attr;
+                               if (rsa.getChoices() == null) {
+                                       List<RefValueChoice> choices = buildRefValueChoices(rsa);
+                                       rsa.setChoices(choices);
+                               }
+                               if (log.isTraceEnabled())
+                                       log.debug("Spec attr " + key + " has " + rsa.getChoices().size() + " choices");
+                       }
+               }
+       }
+
+       /**
+        * Generates a list of ref value choices based on the bean available in the
+        * application context.
+        */
+       protected List<RefValueChoice> buildRefValueChoices(RefSpecAttribute rsa) {
+               List<RefValueChoice> choices = new ArrayList<RefValueChoice>();
+               if (applicationContext == null) {
+                       log.warn("No application context declared," + " cannot scan ref value choices.");
+                       return choices;
+               }
+
+               beanNames: for (String beanName : getBeanFactory().getBeanNamesForType(rsa.getTargetClass(), true, false)) {
+
+                       // Since Spring 3, systemProperties is implicitly defined but has no
+                       // bean definition
+                       if (beanName.equals("systemProperties"))
+                               continue beanNames;
+
+                       BeanDefinition bd = getBeanFactory().getBeanDefinition(beanName);
+                       RefValueChoice choice = new RefValueChoice();
+                       choice.setName(beanName);
+                       choice.setDescription(bd.getDescription());
+                       if (log.isTraceEnabled())
+                               log.debug("Found choice " + beanName + " for " + rsa);
+
+                       choices.add(choice);
+
+               }
+               return choices;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionAspect.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionAspect.java
new file mode 100644 (file)
index 0000000..2fb2348
--- /dev/null
@@ -0,0 +1,98 @@
+package org.argeo.slc.core.execution;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionStack;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect
+/** Aspect intercepting calls on execution flows and contexts. */
+public class ExecutionAspect {
+       private final static Log log = LogFactory.getLog(ExecutionAspect.class);
+
+       private ExecutionStack executionStack;
+       private ExecutionContext executionContext;
+
+       @Around("flowExecution()")
+       public void aroundFlow(ProceedingJoinPoint pjp) throws Throwable {
+               // IMPORTANT: Make sure that the execution context is called before the
+               // execution stack
+               executionContext.getUuid();
+
+               ExecutionFlow executionFlow = (ExecutionFlow) pjp.getTarget();
+               executionStack.enterFlow(executionFlow);
+               executionContext.setVariable(ExecutionContext.VAR_FLOW_ID,
+                               executionStack.getCurrentStackLevelUuid());
+               executionContext.setVariable(ExecutionContext.VAR_FLOW_NAME,
+                               executionFlow.getName());
+
+               logStackEvent("=> ", executionFlow);
+               try {
+                       // Actually execute the flow
+                       pjp.proceed();
+               } finally {
+                       logStackEvent("<= ", executionFlow);
+                       executionStack.leaveFlow(executionFlow);
+               }
+       }
+
+       @Around("getVariable()")
+       public Object aroundGetVariable(ProceedingJoinPoint pjp) throws Throwable {
+               Object obj = pjp.proceed();
+               // if the variable was not found, look in the stack starting at the
+               // upper flows
+               if (obj == null) {
+                       String key = pjp.getArgs()[0].toString();
+                       obj = executionStack.findLocalVariable(key);
+               }
+               return obj;
+       }
+
+       @Pointcut("execution(void org.argeo.slc.execution.ExecutionFlow.run())")
+       public void flowExecution() {
+       }
+
+       @Pointcut("execution(* org.argeo.slc.execution.ExecutionContext.getVariable(..))")
+       public void getVariable() {
+       }
+
+       public void setExecutionStack(ExecutionStack executionStack) {
+               this.executionStack = executionStack;
+       }
+
+       public void setExecutionContext(ExecutionContext executionContext) {
+               this.executionContext = executionContext;
+       }
+
+       protected void logStackEvent(String symbol, ExecutionFlow executionFlow) {
+               Integer stackSize = executionStack.getStackSize();
+               if (log.isTraceEnabled())
+                       log.debug(depthSpaces(stackSize) + symbol + executionFlow + " #"
+                                       + executionStack.getCurrentStackLevelUuid() + ", depth="
+                                       + stackSize);
+               if (log.isDebugEnabled())
+                       log.debug(depthSpaces(stackSize) + symbol + executionFlow);
+       }
+
+       protected void logRunnableExecution(ExecutionFlow executionFlow,
+                       Runnable runnable) {
+               Integer stackSize = executionStack.getStackSize();
+               if (log.isDebugEnabled())
+                       log.debug(depthSpaces(stackSize + 1)
+                                       + runnable.getClass().getSimpleName() + " in "
+                                       + executionFlow);
+       }
+
+       private String depthSpaces(int depth) {
+               StringBuffer buf = new StringBuffer(depth * 2);
+               for (int i = 0; i < depth; i++)
+                       buf.append("  ");
+               return buf.toString();
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java
new file mode 100644 (file)
index 0000000..7510504
--- /dev/null
@@ -0,0 +1,293 @@
+package org.argeo.slc.core.execution;
+
+import java.beans.PropertyDescriptor;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.runtime.InstantiationManager;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.PropertyValues;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
+import org.springframework.beans.factory.config.TypedStringValue;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.support.ManagedMap;
+import org.springframework.beans.factory.support.ManagedSet;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+
+/**
+ * Spring post processor which ensures that execution parameters are properly
+ * set. It is used at two levels: first during instantiation for instantiation
+ * parameters which allow to implement templates, then at runtime in order to
+ * interpret @{} placeholders when object of scope execution are instantiated.
+ */
+public class ExecutionParameterPostProcessor extends
+               InstantiationAwareBeanPostProcessorAdapter {
+
+       private final static Log log = LogFactory
+                       .getLog(ExecutionParameterPostProcessor.class);
+
+       private ExecutionContext executionContext;
+       private InstantiationManager instantiationManager;
+
+       private String placeholderPrefix = "@{";
+       private String placeholderSuffix = "}";
+       private String nullValue;
+
+       @Override
+       public PropertyValues postProcessPropertyValues(PropertyValues pvs,
+                       PropertyDescriptor[] pds, Object bean, String beanName)
+                       throws BeansException {
+
+               // TODO: resolve at execution only if scope is execution
+               // TODO: deal with placeholders in RuntimeBeanReference and
+               // RuntimeBeanNameReference
+
+               MutablePropertyValues newPvs = new MutablePropertyValues();
+
+               boolean changesOccured = false;
+
+               for (PropertyValue pv : pvs.getPropertyValues()) {
+                       Object convertedValue = resolveValue(beanName, bean, pv.getValue());
+                       newPvs.addPropertyValue(new PropertyValue(pv, convertedValue));
+                       if (convertedValue != pv.getValue()) {
+                               changesOccured = true;
+                       }
+               }
+
+               return changesOccured ? newPvs : pvs;
+       }
+
+       @Override
+       public boolean postProcessAfterInstantiation(Object bean, String beanName)
+                       throws BeansException {
+               if (bean instanceof ExecutionFlow)
+                       instantiationManager.flowInitializationStarted(
+                                       (ExecutionFlow) bean, beanName);
+               return true;
+       }
+
+       @Override
+       public Object postProcessAfterInitialization(Object bean, String beanName)
+                       throws BeansException {
+               if (bean instanceof ExecutionFlow)
+                       instantiationManager.flowInitializationFinished(
+                                       (ExecutionFlow) bean, beanName);
+               return bean;
+       }
+
+       protected String resolvePlaceholder(Object bean, String placeholder) {
+               if (instantiationManager.isInFlowInitialization())
+                       return instantiationManager.getInitializingFlowParameter(
+                                       placeholder).toString();
+
+               else {// execution
+                               // next call fail if no execution context available
+                       Object obj = executionContext.getVariable(placeholder);
+                       if (obj != null) {
+                               return obj.toString();
+                       }
+               }
+
+               return null;
+       }
+
+       public Object resolveValue(String beanName, Object bean, Object value) {
+               if (value instanceof TypedStringValue) {
+                       TypedStringValue tsv = (TypedStringValue) value;
+                       String originalValue = tsv.getValue();
+
+                       String convertedValue = resolveString(beanName, bean, originalValue);
+                       if (convertedValue == null)
+                               return null;
+                       return convertedValue.equals(originalValue) ? value
+                                       : new TypedStringValue(convertedValue);
+               } else if (value instanceof String) {
+                       String originalValue = value.toString();
+                       String convertedValue = resolveString(beanName, bean, originalValue);
+                       if (convertedValue == null)
+                               return null;
+                       return convertedValue.equals(originalValue) ? value
+                                       : convertedValue;
+               } else if (value instanceof ManagedMap) {
+                       Map<?, ?> mapVal = (Map<?, ?>) value;
+
+                       Map<Object, Object> newContent = new ManagedMap<Object, Object>();
+                       boolean entriesModified = false;
+                       for (Iterator<?> it = mapVal.entrySet().iterator(); it.hasNext();) {
+                               Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
+                               Object key = entry.getKey();
+                               int keyHash = (key != null ? key.hashCode() : 0);
+                               Object newKey = resolveValue(beanName, bean, key);
+                               int newKeyHash = (newKey != null ? newKey.hashCode() : 0);
+                               Object val = entry.getValue();
+                               Object newVal = resolveValue(beanName, bean, val);
+                               newContent.put(newKey, newVal);
+                               entriesModified = entriesModified
+                                               || (newVal != val || newKey != key || newKeyHash != keyHash);
+                       }
+
+                       return entriesModified ? newContent : value;
+               } else if (value instanceof ManagedList) {
+                       List<?> listVal = (List<?>) value;
+                       List<Object> newContent = new ManagedList<Object>();
+                       boolean valueModified = false;
+
+                       for (int i = 0; i < listVal.size(); i++) {
+                               Object elem = listVal.get(i);
+                               Object newVal = resolveValue(beanName, bean, elem);
+                               newContent.add(newVal);
+                               if (!ObjectUtils.nullSafeEquals(newVal, elem)) {
+                                       valueModified = true;
+                               }
+                       }
+                       return valueModified ? newContent : value;
+               } else if (value instanceof ManagedSet) {
+                       Set<?> setVal = (Set<?>) value;
+                       Set<Object> newContent = new ManagedSet<Object>();
+                       boolean entriesModified = false;
+                       for (Iterator<?> it = setVal.iterator(); it.hasNext();) {
+                               Object elem = it.next();
+                               int elemHash = (elem != null ? elem.hashCode() : 0);
+                               Object newVal = resolveValue(beanName, bean, elem);
+                               int newValHash = (newVal != null ? newVal.hashCode() : 0);
+                               newContent.add(newVal);
+                               entriesModified = entriesModified
+                                               || (newVal != elem || newValHash != elemHash);
+                       }
+                       return entriesModified ? newContent : value;
+               } else {
+                       // log.debug(beanName + ": " + value.getClass() + " : " + value);
+                       return value;
+               }
+
+       }
+
+       private String resolveString(String beanName, Object bean, String strVal) {
+               // in case <null/> is passed
+               if (strVal == null)
+                       return null;
+
+               String value = parseStringValue(bean, strVal, new HashSet<String>());
+
+               if (value == null)
+                       throw new SlcException("Could not resolve placeholder '" + strVal
+                                       + "' in bean '" + beanName + "'");
+
+               return (value.equals(nullValue) ? null : value);
+       }
+
+       public void setPlaceholderPrefix(String placeholderPrefix) {
+               this.placeholderPrefix = placeholderPrefix;
+       }
+
+       public void setPlaceholderSuffix(String placeholderSuffix) {
+               this.placeholderSuffix = placeholderSuffix;
+       }
+
+       public void setNullValue(String nullValue) {
+               this.nullValue = nullValue;
+       }
+
+       public void setInstantiationManager(
+                       InstantiationManager instantiationManager) {
+               this.instantiationManager = instantiationManager;
+       }
+
+       public void setExecutionContext(ExecutionContext executionContext) {
+               this.executionContext = executionContext;
+       }
+
+       //
+       // Following methods hacked from the internals of
+       // PropertyPlaceholderConfigurer
+       //
+
+       protected String parseStringValue(Object bean, String strVal,
+                       Set<String> visitedPlaceholders)
+                       throws BeanDefinitionStoreException {
+
+               // in case <null/> is passed
+               if (strVal == null)
+                       return null;
+
+               StringBuffer buf = new StringBuffer(strVal);
+
+               int startIndex = strVal.indexOf(placeholderPrefix);
+               while (startIndex != -1) {
+                       int endIndex = findPlaceholderEndIndex(buf, startIndex);
+                       if (endIndex != -1) {
+                               String placeholder = buf.substring(startIndex
+                                               + placeholderPrefix.length(), endIndex);
+                               if (!visitedPlaceholders.add(placeholder)) {
+                                       throw new BeanDefinitionStoreException(
+                                                       "Circular placeholder reference '" + placeholder
+                                                                       + "' in property definitions");
+                               }
+                               // Recursive invocation, parsing placeholders contained in
+                               // the placeholder key.
+                               placeholder = parseStringValue(bean, placeholder,
+                                               visitedPlaceholders);
+                               // Now obtain the value for the fully resolved key...
+                               String propVal = resolvePlaceholder(bean, placeholder);
+                               if (propVal != null) {
+                                       // Recursive invocation, parsing placeholders contained
+                                       // in the
+                                       // previously resolved placeholder value.
+                                       propVal = parseStringValue(bean, propVal,
+                                                       visitedPlaceholders);
+                                       buf.replace(startIndex,
+                                                       endIndex + placeholderSuffix.length(), propVal);
+                                       if (log.isTraceEnabled()) {
+                                               log.trace("Resolved placeholder '" + placeholder + "'");
+                                       }
+                                       startIndex = buf.indexOf(placeholderPrefix, startIndex
+                                                       + propVal.length());
+                               } else {
+                                       throw new BeanDefinitionStoreException(
+                                                       "Could not resolve placeholder '" + placeholder
+                                                                       + "'");
+                               }
+                               visitedPlaceholders.remove(placeholder);
+                       } else {
+                               startIndex = -1;
+                       }
+               }
+
+               return buf.toString();
+       }
+
+       private int findPlaceholderEndIndex(CharSequence buf, int startIndex) {
+               int index = startIndex + placeholderPrefix.length();
+               int withinNestedPlaceholder = 0;
+               while (index < buf.length()) {
+                       if (StringUtils.substringMatch(buf, index, placeholderSuffix)) {
+                               if (withinNestedPlaceholder > 0) {
+                                       withinNestedPlaceholder--;
+                                       index = index + placeholderSuffix.length();
+                               } else {
+                                       return index;
+                               }
+                       } else if (StringUtils
+                                       .substringMatch(buf, index, placeholderPrefix)) {
+                               withinNestedPlaceholder++;
+                               index = index + placeholderPrefix.length();
+                       } else {
+                               index++;
+                       }
+               }
+               return -1;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResources.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResources.java
new file mode 100644 (file)
index 0000000..772330a
--- /dev/null
@@ -0,0 +1,33 @@
+package org.argeo.slc.core.execution;
+
+import java.io.File;
+
+import org.springframework.core.io.Resource;
+
+/** Provides write access to resources during execution */
+public interface ExecutionResources {
+       /** The base directory where this execution can write */
+       public File getWritableBaseDir();
+
+       /** Allocates a local file in the writable area and return it as a resource. */
+       public Resource getWritableResource(String relativePath);
+
+       /**
+        * Allocates a local file in the writable area and return it as a fully
+        * qualified OS path.
+        */
+       public String getWritableOsPath(String relativePath);
+
+       /**
+        * Allocates a local file in the writable area and return it as a
+        * {@link File}.
+        */
+       public File getWritableOsFile(String relativePath);
+
+       /**
+        * Returns the resource as a file path. If the resource is not writable it
+        * is copied as a file in the writable area and the path to this local file
+        * is returned.
+        */
+       public String getAsOsPath(Resource resource, Boolean overwrite);
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResourcesFactoryBean.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionResourcesFactoryBean.java
new file mode 100644 (file)
index 0000000..b217c3b
--- /dev/null
@@ -0,0 +1,34 @@
+package org.argeo.slc.core.execution;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.core.io.Resource;
+import org.springframework.util.Assert;
+
+/** Workaround when execution placedholders needs to be passed. */
+public class ExecutionResourcesFactoryBean implements FactoryBean<Resource> {
+       private ExecutionResources executionResources;
+       private String relativePath;
+
+       public Resource getObject() throws Exception {
+               Assert.notNull(executionResources, "executionResources is null");
+               Assert.notNull(relativePath, "relativePath is null");
+               return executionResources.getWritableResource(relativePath);
+       }
+
+       public Class<? extends Object> getObjectType() {
+               return Resource.class;
+       }
+
+       public boolean isSingleton() {
+               return true;
+       }
+
+       public void setExecutionResources(ExecutionResources executionResources) {
+               this.executionResources = executionResources;
+       }
+
+       public void setRelativePath(String relativePath) {
+               this.relativePath = relativePath;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionScope.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ExecutionScope.java
new file mode 100644 (file)
index 0000000..19296ab
--- /dev/null
@@ -0,0 +1,137 @@
+package org.argeo.slc.core.execution;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.UnsupportedException;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionSpec;
+import org.argeo.slc.execution.ExecutionStack;
+import org.argeo.slc.runtime.ExecutionThread;
+import org.springframework.beans.factory.ObjectFactory;
+import org.springframework.beans.factory.config.Scope;
+
+/**
+ * When Spring beans are instantiated with this scope, the same instance is
+ * reused across an execution.
+ */
+public class ExecutionScope implements Scope {
+       private final static Log log = LogFactory.getLog(ExecutionScope.class);
+
+       private final ThreadLocal<ExecutionStack> executionStack = new ThreadLocal<ExecutionStack>();
+       public final ThreadLocal<String> executionStackBeanName = new ThreadLocal<String>();
+
+       private final ThreadLocal<ExecutionContext> executionContext = new ThreadLocal<ExecutionContext>();
+       private final ThreadLocal<String> executionContextBeanName = new ThreadLocal<String>();
+
+       public Object get(String name, ObjectFactory<?> objectFactory) {
+               if (log.isTraceEnabled())
+                       log.debug("Get execution scoped bean " + name);
+
+               // shortcuts
+               if (executionStackBeanName.get() != null
+                               && name.equals(executionStackBeanName.get())) {
+                       return executionStack.get();
+               }
+
+               if (executionContextBeanName.get() != null
+                               && name.equals(executionContextBeanName.get())) {
+                       return executionContext.get();
+               }
+
+               // execution context must be defined first
+               if (executionContext.get() == null) {
+                       Object obj = objectFactory.getObject();
+                       if (obj instanceof ExecutionContext) {
+                               return dealWithSpecialScopedObject(name, executionContext,
+                                               executionContextBeanName, (ExecutionContext) obj);
+                       } else {
+                               // TODO: use execution context wrapper
+                               throw new SlcException("No execution context has been defined.");
+                       }
+               }
+
+               // for other scoped objects, an executions stack must be available
+               if (executionStack.get() == null) {
+                       Object obj = objectFactory.getObject();
+                       if (obj instanceof ExecutionStack) {
+                               return dealWithSpecialScopedObject(name, executionStack,
+                                               executionStackBeanName, (ExecutionStack) obj);
+                       } else {
+                               throw new SlcException("No execution stack has been defined.");
+                       }
+               }
+
+               // see if the execution stack already knows the object
+               Object obj = executionStack.get().findScopedObject(name);
+               if (obj == null) {
+                       obj = objectFactory.getObject();
+                       if (obj instanceof ExecutionContext)
+                               throw new SlcException(
+                                               "Only one execution context can be defined per thread");
+                       if (obj instanceof ExecutionStack)
+                               throw new SlcException(
+                                               "Only one execution stack can be defined per thread");
+
+                       checkForbiddenClasses(obj);
+
+                       executionStack.get().addScopedObject(name, obj);
+               }
+               return obj;
+
+       }
+
+       protected <T> T dealWithSpecialScopedObject(String name,
+                       ThreadLocal<T> threadLocal,
+                       ThreadLocal<String> threadLocalBeanName, T newObj) {
+
+               T obj = threadLocal.get();
+               if (obj == null) {
+                       obj = newObj;
+                       threadLocal.set(obj);
+                       threadLocalBeanName.set(name);
+                       if (log.isTraceEnabled()) {
+                               log.debug(obj.getClass() + " instantiated. (beanName=" + name
+                                               + ")");
+                       }
+                       return obj;
+               } else {
+                       throw new SlcException("Only one scoped " + obj.getClass()
+                                       + " can be defined per thread");
+               }
+
+       }
+
+       protected void checkForbiddenClasses(Object obj) {
+               Class<?> clss = obj.getClass();
+               if (ExecutionFlow.class.isAssignableFrom(clss)
+                               || ExecutionSpec.class.isAssignableFrom(clss)) {
+                       throw new UnsupportedException("Execution scoped object", clss);
+               }
+       }
+
+       public String getConversationId() {
+               // TODO: is it the most relevant?
+               return executionContext.get().getUuid();
+       }
+
+       public void registerDestructionCallback(String name, Runnable callback) {
+               if (Thread.currentThread() instanceof ExecutionThread) {
+                       ExecutionThread executionThread = (ExecutionThread) Thread
+                                       .currentThread();
+                       executionThread.registerDestructionCallback(name, callback);
+               }
+       }
+
+       public Object remove(String name) {
+               if (log.isDebugEnabled())
+                       log.debug("Remove object " + name);
+               throw new UnsupportedOperationException();
+       }
+
+       public Object resolveContextualObject(String key) {
+               return executionContext.get().getVariable(key);
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/FileExecutionResources.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/FileExecutionResources.java
new file mode 100644 (file)
index 0000000..41fb694
--- /dev/null
@@ -0,0 +1,209 @@
+package org.argeo.slc.core.execution;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionContext;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+import org.springframework.util.Assert;
+
+/** Implements write access to resources based on standard Java {@link File} */
+public class FileExecutionResources implements ExecutionResources {
+       private final static Log log = LogFactory
+                       .getLog(FileExecutionResources.class);
+       protected final static String DEFAULT_EXECUTION_RESOURCES_DIRNAME = "executionResources";
+       public final static String DEFAULT_EXECUTION_RESOURCES_TMP_PATH = System
+                       .getProperty("java.io.tmpdir")
+                       + File.separator
+                       + System.getProperty("user.name")
+                       + File.separator
+                       + "slc"
+                       + File.separator + DEFAULT_EXECUTION_RESOURCES_DIRNAME;
+
+       private File baseDir;
+       private ExecutionContext executionContext;
+       private String prefixDatePattern = "yyMMdd_HHmmss_SSS";
+       private SimpleDateFormat sdf = null;
+
+       private Boolean withExecutionSubdirectory = true;
+
+       public FileExecutionResources() {
+               // Default base directory
+               String osgiInstanceArea = System.getProperty("osgi.instance.area");
+               String osgiInstanceAreaDefault = System
+                               .getProperty("osgi.instance.area.default");
+
+               if (osgiInstanceArea != null) {
+                       // within OSGi with -data specified
+                       osgiInstanceArea = removeFilePrefix(osgiInstanceArea);
+                       baseDir = new File(osgiInstanceArea + File.separator
+                                       + DEFAULT_EXECUTION_RESOURCES_DIRNAME);
+               } else if (osgiInstanceAreaDefault != null) {
+                       // within OSGi without -data specified
+                       osgiInstanceAreaDefault = removeFilePrefix(osgiInstanceAreaDefault);
+                       baseDir = new File(osgiInstanceAreaDefault + File.separator
+                                       + DEFAULT_EXECUTION_RESOURCES_DIRNAME);
+               } else {// outside OSGi
+                       baseDir = new File(DEFAULT_EXECUTION_RESOURCES_TMP_PATH);
+               }
+       }
+
+       protected SimpleDateFormat sdf() {
+               // Lazy init in case prefix has been externally set
+               if (sdf == null)
+                       sdf = new SimpleDateFormat(prefixDatePattern);
+               return sdf;
+       }
+
+       public Resource getWritableResource(String relativePath) {
+               File file = getFile(relativePath);
+               File parentDir = file.getParentFile();
+
+               if (!parentDir.exists()) {
+                       // Creates if necessary
+                       if (log.isTraceEnabled())
+                               log.trace("Creating parent directory " + parentDir);
+                       parentDir.mkdirs();
+               }
+               Resource resource = new FileSystemResource(file);
+
+               if (log.isTraceEnabled())
+                       log.trace("Returns writable resource " + resource);
+               return resource;
+       }
+
+       public String getWritableOsPath(String relativePath) {
+               try {
+                       return getFile(relativePath).getCanonicalPath();
+               } catch (IOException e) {
+                       throw new SlcException("Cannot find canonical path", e);
+               }
+       }
+
+       public File getWritableOsFile(String relativePath) {
+               return getFile(relativePath);
+       }
+
+       public String getAsOsPath(Resource resource, Boolean overwrite) {
+               File file = fileFromResource(resource);
+               if (file != null)
+                       try {
+                               if (log.isTraceEnabled())
+                                       log.debug("Directly interpret " + resource + " as OS file "
+                                                       + file);
+                               return file.getCanonicalPath();
+                       } catch (IOException e1) {
+                               // silent
+                       }
+
+               if (log.isTraceEnabled())
+                       log.trace("Resource " + resource
+                                       + " is not available on the file system. Retrieving it...");
+
+               InputStream in = null;
+               OutputStream out = null;
+               try {
+                       String path = resource.getURL().getPath();
+                       file = getFile(path);
+                       if (file.exists() && !overwrite)
+                               return file.getCanonicalPath();
+
+                       file.getParentFile().mkdirs();
+                       in = resource.getInputStream();
+                       out = new FileOutputStream(file);
+                       IOUtils.copy(in, out);
+                       if (log.isDebugEnabled())
+                               log.debug("Retrieved " + resource + " to OS file " + file);
+                       return file.getCanonicalPath();
+               } catch (IOException e) {
+                       throw new SlcException("Could not make resource " + resource
+                                       + " an OS file.", e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+                       IOUtils.closeQuietly(out);
+               }
+       }
+
+       /**
+        * Extract the underlying file from the resource.
+        * 
+        * @return the file or null if no files support this resource.
+        */
+       protected File fileFromResource(Resource resource) {
+               try {
+                       return resource.getFile();
+               } catch (IOException e) {
+                       return null;
+               }
+
+       }
+
+       protected File getFile(String relativePath) {
+               File writableBaseDir = getWritableBaseDir();
+               return new File(writableBaseDir.getPath() + File.separator
+                               + relativePath.replace('/', File.separatorChar));
+       }
+
+       public File getWritableBaseDir() {
+               if (withExecutionSubdirectory) {
+                       Date executionContextCreationDate = (Date) executionContext
+                                       .getVariable(ExecutionContext.VAR_EXECUTION_CONTEXT_CREATION_DATE);
+                       Assert.notNull(executionContext, "execution context is null");
+                       String path = baseDir.getPath() + File.separator
+                                       + sdf().format(executionContextCreationDate);
+                       // TODO write execution id somewhere? like in a txt file
+                       return new File(path);
+               } else {
+                       return baseDir;
+               }
+       }
+
+       protected String removeFilePrefix(String url) {
+               if (url.startsWith("file:"))
+                       return url.substring("file:".length());
+               else if (url.startsWith("reference:file:"))
+                       return url.substring("reference:file:".length());
+               else
+                       return url;
+       }
+
+       public void setBaseDir(File baseDir) {
+               this.baseDir = baseDir;
+       }
+
+       public void setExecutionContext(ExecutionContext executionContext) {
+               this.executionContext = executionContext;
+       }
+
+       public void setPrefixDatePattern(String prefixDatePattern) {
+               this.prefixDatePattern = prefixDatePattern;
+       }
+
+       public File getBaseDir() {
+               return baseDir;
+       }
+
+       public ExecutionContext getExecutionContext() {
+               return executionContext;
+       }
+
+       public String getPrefixDatePattern() {
+               return prefixDatePattern;
+       }
+
+       /** Default is true. */
+       public void setWithExecutionSubdirectory(Boolean withExecutionSubdirectory) {
+               this.withExecutionSubdirectory = withExecutionSubdirectory;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/MapExecutionContext.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/MapExecutionContext.java
new file mode 100644 (file)
index 0000000..5a96405
--- /dev/null
@@ -0,0 +1,123 @@
+package org.argeo.slc.core.execution;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionStack;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeanWrapperImpl;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+public class MapExecutionContext implements ExecutionContext,
+               ApplicationContextAware {
+       private final Map<String, Object> variables = Collections
+                       .synchronizedMap(new HashMap<String, Object>());
+
+       private final String uuid;
+
+       private ApplicationContext applicationContext;
+       private ExecutionStack executionStack;
+
+       public MapExecutionContext() {
+               uuid = UUID.randomUUID().toString();
+               variables.put(VAR_EXECUTION_CONTEXT_ID, uuid);
+               variables.put(VAR_EXECUTION_CONTEXT_CREATION_DATE, new Date());
+       }
+
+       public void setVariable(String key, Object value) {
+               // check if we do not refer to a bean
+               int lastInd = key.lastIndexOf('.');
+               if (applicationContext != null && lastInd > 0) {
+                       String beanName = key.substring(0, lastInd);
+                       String propertyName = key.substring(lastInd + 1);
+                       if (applicationContext.containsBean(beanName)) {
+                               BeanWrapper beanWrapper = new BeanWrapperImpl(
+                                               applicationContext.getBean(beanName));
+                               if (!beanWrapper.isWritableProperty(propertyName))
+                                       throw new SlcException("No writable property "
+                                                       + propertyName + " in bean " + beanName);
+                               beanWrapper.setPropertyValue(propertyName, value);
+                       }
+               }
+
+               variables.put(key, value);
+       }
+
+       public Object getVariable(String key) {
+               // check if we do not refer to a bean
+               int lastInd = key.lastIndexOf('.');
+               if (applicationContext != null && lastInd > 0) {
+                       String beanName = key.substring(0, lastInd);
+                       String propertyName = key.substring(lastInd + 1);
+                       if (applicationContext.containsBean(beanName)) {
+                               BeanWrapper beanWrapper = new BeanWrapperImpl(
+                                               applicationContext.getBean(beanName));
+                               if (!beanWrapper.isReadableProperty(propertyName))
+                                       throw new SlcException("No readable property "
+                                                       + propertyName + " in bean " + beanName);
+                               Object obj = beanWrapper.getPropertyValue(propertyName);
+                               return obj;
+                       }
+               }
+
+               Object value = variables.get(key);
+               // try system property in last resort
+               if (value == null)
+                       value = System.getProperty(key);
+
+               // if the variable was not found, look in the stack starting at the
+               // upper flows
+               if (value == null) {
+                       value = executionStack.findLocalVariable(key);
+               }
+               return value;
+       }
+
+       public String getUuid() {
+               return uuid;
+       }
+
+       @Override
+       public void beforeFlow(ExecutionFlow executionFlow) {
+               // getUuid();
+               executionStack.enterFlow(executionFlow);
+               setVariable(ExecutionContext.VAR_FLOW_ID,
+                               executionStack.getCurrentStackLevelUuid());
+               setVariable(ExecutionContext.VAR_FLOW_NAME, executionFlow.getName());
+       }
+
+       @Override
+       public void afterFlow(ExecutionFlow executionFlow) {
+               executionStack.leaveFlow(executionFlow);
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (obj instanceof ExecutionContext)
+                       return uuid.equals(((ExecutionContext) obj).getUuid());
+               return false;
+       }
+
+       @Override
+       public String toString() {
+               return getClass().getSimpleName() + "#" + uuid;
+       }
+
+       public void setApplicationContext(ApplicationContext applicationContext)
+                       throws BeansException {
+               this.applicationContext = applicationContext;
+       }
+
+       public void setExecutionStack(ExecutionStack executionStack) {
+               this.executionStack = executionStack;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/OsFileFactoryBean.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/OsFileFactoryBean.java
new file mode 100644 (file)
index 0000000..7cd6e20
--- /dev/null
@@ -0,0 +1,49 @@
+package org.argeo.slc.core.execution;
+
+import java.io.File;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.core.io.Resource;
+import org.springframework.util.Assert;
+
+/** Retrieve an OS File from the given resource. */
+public class OsFileFactoryBean implements FactoryBean<String> {
+       private ExecutionResources executionResources;
+       private Resource resource;
+       private Boolean overwrite = false;
+
+       /** Return an existing file on the file system. */
+       public String getObject() throws Exception {
+               Assert.notNull(executionResources, "executionResources is null");
+               Assert.notNull(resource, "resource is null");
+               return executionResources.getAsOsPath(resource, overwrite);
+       }
+
+       /** Return {@link Object} because CGLIB is unable to proxy {@link File}. */
+       public Class<? extends Object> getObjectType() {
+               return CharSequence.class;
+       }
+
+       public boolean isSingleton() {
+               return false;
+       }
+
+       /** The execution resources object. */
+       public void setExecutionResources(ExecutionResources executionResources) {
+               this.executionResources = executionResources;
+       }
+
+       /** The resource to access. */
+       public void setResource(Resource resource) {
+               this.resource = resource;
+       }
+
+       /**
+        * Whether to overwrite the resource if it already exists. Default is
+        * <code>false</code>.
+        */
+       public void setOverwrite(Boolean overwrite) {
+               this.overwrite = overwrite;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ParameterRef.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/ParameterRef.java
new file mode 100644 (file)
index 0000000..093f781
--- /dev/null
@@ -0,0 +1,53 @@
+package org.argeo.slc.core.execution;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.runtime.InstantiationManager;
+import org.springframework.beans.factory.FactoryBean;
+
+public class ParameterRef implements FactoryBean<Object> {
+       private final static Log log = LogFactory.getLog(ParameterRef.class);
+
+       private InstantiationManager instantiationManager;
+       private String name;
+
+       /** Cached object. */
+       private Object object;
+
+       public ParameterRef() {
+       }
+
+       public ParameterRef(String name) {
+               this.name = name;
+       }
+
+       public Object getObject() throws Exception {
+               if (log.isTraceEnabled())
+                       log.debug("Parameter ref called for " + name);
+
+               if (object == null)
+                       object = instantiationManager.getInitializingFlowParameter(name);
+               return object;
+       }
+
+       public Class<?> getObjectType() {
+               if (object == null)
+                       return instantiationManager.getInitializingFlowParameterClass(name);
+               else
+                       return object.getClass();
+       }
+
+       public boolean isSingleton() {
+               return true;
+       }
+
+       public void setInstantiationManager(
+                       InstantiationManager instantiationManager) {
+               this.instantiationManager = instantiationManager;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/SedFilteredResource.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/SedFilteredResource.java
new file mode 100644 (file)
index 0000000..728f95c
--- /dev/null
@@ -0,0 +1,129 @@
+package org.argeo.slc.core.execution;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.slc.SlcException;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.core.io.Resource;
+
+/** Experimental and suboptimal */
+public class SedFilteredResource implements FactoryBean<Resource>,
+               InitializingBean {
+       private Resource source;
+
+       private List<String> filters = new ArrayList<String>();
+       private Map<Pattern, String> patterns = new HashMap<Pattern, String>();
+
+       private String charset = "UTF-8";
+       private Charset cs;
+       private CharsetDecoder decoder;
+
+       // private CharsetEncoder encoder;
+
+       public Resource getObject() throws Exception {
+               if (filters.size() == 0)
+                       return source;
+
+               // int capacity = 100 * 1024;// 100 KB
+               ByteBuffer bb;
+               if (source instanceof ByteArrayResource) {
+                       bb = ByteBuffer.wrap(((ByteArrayResource) source).getByteArray());
+               } else {
+                       FileInputStream fis = null;
+                       try {
+                               File file = source.getFile();
+                               fis = new FileInputStream(file);
+                               FileChannel fc = fis.getChannel();
+
+                               // Get the file's size and then map it into memory
+                               int sz = (int) fc.size();
+                               bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);
+                       } catch (IOException e) {
+                               // ReadableByteChannel channel = Channels.newChannel(source
+                               // .getInputStream());
+                               // bb = ByteBuffer.allocateDirect(capacity);
+                               // int read = 0;
+                               // do {
+                               // read = channel.read(bb);
+                               // } while (read > 0);
+                               // FIXME : use nio to parse the stream as it goes
+                               bb = ByteBuffer.wrap(IOUtils.toByteArray(source
+                                               .getInputStream()));
+                       } finally {
+                               IOUtils.closeQuietly(fis);
+                       }
+               }
+               CharBuffer cb = decoder.decode(bb);
+               for (Pattern pattern : patterns.keySet()) {
+                       Matcher matcher = pattern.matcher(cb);
+                       String output = matcher.replaceAll(patterns.get(pattern));
+                       cb = CharBuffer.wrap(output);
+               }
+               // ByteBuffer bbout = encoder.encode(cb);
+               // ByteArrayOutputStream out = new ByteArrayOutputStream(capacity);
+               // WritableByteChannel wchannel = Channels.newChannel(out);
+               // wchannel.write(bbout);
+               ByteArrayResource res = new ByteArrayResource(cb.toString().getBytes());
+               return res;
+       }
+
+       public Class<?> getObjectType() {
+               return Resource.class;
+       }
+
+       public boolean isSingleton() {
+               return true;
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               cs = Charset.forName(charset);
+               decoder = cs.newDecoder();
+               // encoder = cs.newEncoder();
+
+               for (String sedStr : filters) {
+                       sedStr = sedStr.trim();
+                       if (sedStr.length() < 4)
+                               throw new SlcException(sedStr + " not properly formatted.");
+                       if (sedStr.charAt(0) != 's')
+                               throw new SlcException(sedStr + " not properly formatted.");
+                       Character sep = sedStr.charAt(1);
+                       List<String> tokens = new ArrayList<String>(4);
+                       StringTokenizer st = new StringTokenizer(sedStr, sep.toString());
+                       while (st.hasMoreTokens())
+                               tokens.add(st.nextToken());
+                       if (tokens.size() != 3 && tokens.size() != 4)
+                               throw new SlcException(sedStr + " not properly formatted.");
+                       patterns.put(Pattern.compile(tokens.get(1)), tokens.get(2));
+               }
+       }
+
+       public void setSource(Resource source) {
+               this.source = source;
+       }
+
+       public void setFilters(List<String> filters) {
+               this.filters = filters;
+       }
+
+       public void setCharset(String charset) {
+               this.charset = charset;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/defaults.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/defaults.xml
new file mode 100644 (file)
index 0000000..d84ba10
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2007-2012 Argeo GmbH
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+            http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+       <bean id="slcDefault.executionResources" parent="slcTemplate.fileResources"
+               scope="execution" lazy-init="true">
+               <aop:scoped-proxy proxy-target-class="false" />
+               <property name="executionContext" ref="executionContext" />
+       </bean>
+
+       <bean id="slcDefault.writableResource" parent="slcTemplate.writableResource"
+               abstract="true">
+               <property name="executionResources" ref="slcDefault.executionResources" />
+       </bean>
+
+       <bean id="slcDefault.osFile" parent="slcTemplate.osFile" abstract="true">
+               <property name="executionResources" ref="slcDefault.executionResources" />
+       </bean>
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ConsoleContextDescriber.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ConsoleContextDescriber.java
new file mode 100644 (file)
index 0000000..1e8f8f9
--- /dev/null
@@ -0,0 +1,34 @@
+package org.argeo.slc.core.execution.doc;
+
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+public class ConsoleContextDescriber implements ContextDescriber {
+       public void describeContext(BeanDefinitionRegistry registry) {
+               String[] beanNames = registry.getBeanDefinitionNames();
+               for (String beanName : beanNames) {
+                       log("\n## BEAN: " + beanName);
+                       describeBean(registry.getBeanDefinition(beanName));
+               }
+       }
+
+       public void describeBean(BeanDefinition beanDefinition) {
+               log("BeanDefinition class: "+beanDefinition.getClass());
+               log("# ATTRIBUTES");
+               for(String attr:beanDefinition.attributeNames()){
+                       log(attr+"="+beanDefinition.getAttribute(attr));
+               }
+               log("# PROPERTIES");
+               MutablePropertyValues pValues = beanDefinition.getPropertyValues();
+               for (PropertyValue pv : pValues.getPropertyValues()) {
+                       log(pv.getName() + "= (" + pv.getValue().getClass() + ") "
+                                       + pv.getValue());
+               }
+       }
+
+       protected void log(Object obj){
+               System.out.println(obj);
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ContextDescriber.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/doc/ContextDescriber.java
new file mode 100644 (file)
index 0000000..7dd9afe
--- /dev/null
@@ -0,0 +1,9 @@
+package org.argeo.slc.core.execution.doc;
+
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+public interface ContextDescriber {
+       public void describeContext(BeanDefinitionRegistry registry);
+       public void describeBean(BeanDefinition bd);
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/CompositeRunnableFactory.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/CompositeRunnableFactory.java
new file mode 100644 (file)
index 0000000..4fc5dc0
--- /dev/null
@@ -0,0 +1,62 @@
+package org.argeo.slc.core.execution.generator;
+
+import java.util.Map;
+
+import org.argeo.slc.SlcException;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+/**
+ * Composite <code>RunnableFactory</code>, redirecting the Runnable 
+ * creation to on of the configured <code>RunnableFactory</code> depending
+ * on an entry of the data of the <code>RunnableDataNode</code>.
+ */
+public class CompositeRunnableFactory implements RunnableFactory {
+
+       /**
+        * Key used to access factory ID in the data of the <code>RunnableDataNode</code>
+        */
+       private String factoryKey;
+
+       /**
+        * Maps a factory ID to an ExecutionFlowFactory
+        */
+       private Map<String, RunnableFactory> factories;
+
+       public void createAndRegisterRunnable(RunnableDataNode node,
+                       BeanDefinitionRegistry beanDefinitionRegistry) {
+               findFactory(node).createAndRegisterRunnable(node, beanDefinitionRegistry);
+       }       
+       
+       /**
+        * Finds the <code>RunnableFactory</code> to use for a <code>RunnableDataNode</code>
+        * @param node
+        * @return the <code>RunnableFactory</code> to use for the <code>RunnableDataNode</code>
+        */
+       private RunnableFactory findFactory(RunnableDataNode node) {
+               // get the factory ID from the data of the RunnableDescriptor
+               Map<String, Object> data = node.getData();
+               if (!data.containsKey(factoryKey)) {
+                       throw new SlcException("No data value for key '" + factoryKey + "'");
+               }
+               String factoryId = data.get(factoryKey).toString();
+               
+               // see if we have a factory for the factory ID
+               if ((factories != null) && factories.containsKey(factoryId)) {
+                       return factories.get(factoryId);
+               }
+               // if not, look for a bean of name equals to the factory ID
+               else {
+                       throw new SlcException("Not implemented");
+               }               
+       }
+       
+       public void setFactoryKey(String factoryKey) {
+               this.factoryKey = factoryKey;
+       }
+
+       public void setFactories(Map<String, RunnableFactory> factories) {
+               this.factories = factories;
+       }
+
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/DefaultRunnableDataNode.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/DefaultRunnableDataNode.java
new file mode 100644 (file)
index 0000000..cd0eaef
--- /dev/null
@@ -0,0 +1,89 @@
+package org.argeo.slc.core.execution.generator;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Default implementation of <code>RunnableDataNode</code>
+ *
+ */
+public class DefaultRunnableDataNode implements RunnableDataNode {
+
+       private List<RunnableDataNode> children = new ArrayList<RunnableDataNode>();
+       
+       private RunnableDataNode parent;
+       
+       /**
+        * Data of the RunnableDataNode. Does not contain
+        * parent data.
+        */
+       private Map<String, Object> properData = new HashMap<String, Object>();
+       
+       private String path;
+       
+       private String beanName;
+
+       public boolean isLeaf() {
+               return children.size() == 0;
+       }
+       
+       public List<RunnableDataNode> getChildren() {
+               return children;
+       }
+
+       public void addChild(RunnableDataNode child) {
+               child.setParent(this);
+               children.add(child);
+       }
+       
+       public Map<String, Object> getData() {
+               Map<String, Object> data = new HashMap<String, Object>();
+               if(parent != null) {
+                       Map<String, Object> parentData = parent.getData();
+                       if(parentData != null) {
+                               data.putAll(parentData);
+                       }
+               }
+               // entries defined in parentData can be overridden
+               // in properData
+               if(properData != null) {
+                       data.putAll(properData);
+               }
+               return data;
+       }
+
+       public Map<String, Object> getProperData() {
+               return properData;
+       }
+
+       public void setProperData(Map<String, Object> properData) {
+               this.properData = properData;
+       }
+
+       public String getPath() {
+               return path;
+       }
+
+       public void setPath(String path) {
+               this.path = path;
+       }
+
+       public String getBeanName() {
+               return beanName;
+       }
+
+       public void setBeanName(String beanName) {
+               this.beanName = beanName;
+       }
+
+       public void setParent(RunnableDataNode parent) {
+               this.parent = parent;
+       }
+
+       public RunnableDataNode getParent() {
+               return parent;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGenerator.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGenerator.java
new file mode 100644 (file)
index 0000000..0e06f4e
--- /dev/null
@@ -0,0 +1,166 @@
+package org.argeo.slc.core.execution.generator;
+
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.aop.scope.ScopedProxyUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+import org.springframework.core.Ordered;
+
+/**
+ * Generates <code>ExecutionFlows</code> and <code>Runnables</code> as
+ * beans in the Spring Application Context.
+ * Called by the Application Context as a <code>BeanFactoryPostProcessor</code>.
+ * Two kinds of beans are generated:
+ * <code>RunnableCallFlow</code>, calling a list of <code>Runnables</code> from the
+ * Application Context after configuring the <code>ExecutionContext</code>, 
+ * and outputs of a <code>RunnableFactory</code>.
+ */
+public class ExecutionFlowGenerator implements BeanFactoryPostProcessor,
+               Ordered {
+       
+       private final Log log = LogFactory.getLog(getClass());
+
+       /**
+        * Source providing a list of <code>RunnableCallFlowDescriptor</code> 
+        * used to create <code>RunnableCallFlow</code> and a list of 
+        * <code>RunnableDataNode</code> used to create any kind of flow via a factory
+        */
+       protected ExecutionFlowGeneratorSource source;
+       
+       /**
+        * Factory used to create Runnables in the Application context from
+        * the <code>RunnableDataNode</code> provided from the source.
+        */
+       protected RunnableFactory runnableFactory;
+       
+       /**
+        * Bean name of the <code>ExecutionContext</code>.
+        * Used to provide the created <code>RunnableCallFlow</code> beans 
+        * with a <code>RuntimeBeanReference</code> to
+        * the <code>ExecutionContext</code>
+        */
+       private String executionContextBeanName = "executionContext";
+       
+       /**
+        * Bean name of the context values Map.
+        * A bean of class HashMap is created with this name, and a 
+        * <code>RuntimeBeanReference</code> is provided to the created
+        * <code>RunnableCallFlow</code> beans.
+        */
+       private String contextValuesBeanName = "executionFlowGenerator.contextValues";
+       
+       /**
+        * Prefix added to the bean names defined in each 
+        * <code>RunnableCallFlowDescriptor</code>
+        */
+       private String flowBeanNamesPrefix = "";
+       
+       private int order = Ordered.HIGHEST_PRECEDENCE;
+               
+       public void postProcessBeanFactory(
+                       ConfigurableListableBeanFactory beanFactory) throws BeansException {
+
+               // assert that the beanFactory is a BeanDefinitionRegistry
+               if (!(beanFactory instanceof BeanDefinitionRegistry)) {
+                       throw new SlcException("Can only work on "
+                                       + BeanDefinitionRegistry.class);
+               } 
+               
+               // add bean for the Context Values Map
+               createAndRegisterContextValuesBean((BeanDefinitionRegistry) beanFactory);
+               
+               // add beans for each RunnableDataNode
+               for(RunnableDataNode node : source.getRunnableDataNodes()) {
+                       runnableFactory.createAndRegisterRunnable(node, (BeanDefinitionRegistry) beanFactory);
+               }
+               
+               // add beans for each RunnableCallFlowDescriptor of the source to the application context
+               for (RunnableCallFlowDescriptor descriptor : source
+                               .getRunnableCallFlowDescriptors()) {
+                       createAndRegisterFlowFor(descriptor, (BeanDefinitionRegistry) beanFactory);
+               }
+       }
+
+       /**
+        * Creates a <code>RunnableCallFlow</code> bean
+        * for a <code>RunnableCallFlowDescriptor</code> and registers 
+        * it in the <code>BeanDefinitionRegistry</code>
+        * @param flowDescriptor
+        * @param registry
+        */
+       private void createAndRegisterFlowFor(RunnableCallFlowDescriptor flowDescriptor, BeanDefinitionRegistry registry) {
+               // create the flow bean
+               GenericBeanDefinition flowBean = new GenericBeanDefinition();
+               flowBean.setBeanClass(RunnableCallFlow.class);
+               
+               String beanName = flowBeanNamesPrefix + flowDescriptor.getBeanName();
+               
+               MutablePropertyValues mpv = new MutablePropertyValues();                
+               mpv.addPropertyValue("runnableCalls", flowDescriptor.getRunnableCalls());
+               mpv.addPropertyValue("sharedContextValuesMap", new RuntimeBeanReference(contextValuesBeanName));
+               
+               mpv.addPropertyValue("name", beanName);
+               mpv.addPropertyValue("path", flowDescriptor.getPath());
+
+               mpv.addPropertyValue("executionContext", new RuntimeBeanReference(executionContextBeanName));
+               
+               flowBean.setPropertyValues(mpv);
+               
+               // register it
+               if(log.isDebugEnabled()) {
+                       log.debug("Registering bean definition for RunnableCallFlow " + beanName);
+               }
+               registry.registerBeanDefinition(beanName, flowBean);
+       }
+       
+       /**
+        * Creates the Context Values bean and register it in the
+        * <code>BeanDefinitionRegistry</code>
+        * @param registry
+        */
+       private void createAndRegisterContextValuesBean(BeanDefinitionRegistry registry) {
+               GenericBeanDefinition contextValuesBean = new GenericBeanDefinition();
+               contextValuesBean.setBeanClass(HashMap.class);
+               
+               BeanDefinitionHolder bdh = ScopedProxyUtils.createScopedProxy(new BeanDefinitionHolder(contextValuesBean, contextValuesBeanName), registry, true);                                                                                                                      
+               registry.registerBeanDefinition(contextValuesBeanName, bdh.getBeanDefinition());                
+       }
+       
+       public int getOrder() {
+               return order;
+       }
+
+       public void setOrder(int order) {
+               this.order = order;
+       }
+
+       public void setSource(ExecutionFlowGeneratorSource source) {
+               this.source = source;
+       }
+
+       public void setRunnableFactory(RunnableFactory runnableFactory) {
+               this.runnableFactory = runnableFactory;
+       }
+
+       public void setExecutionContextBeanName(String executionContextBeanName) {
+               this.executionContextBeanName = executionContextBeanName;
+       }
+
+       public void setContextValuesBeanName(String contextValuesBeanName) {
+               this.contextValuesBeanName = contextValuesBeanName;
+       }
+
+       public void setFlowBeanNamesPrefix(String flowBeanNamesPrefix) {
+               this.flowBeanNamesPrefix = flowBeanNamesPrefix;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGeneratorSource.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/ExecutionFlowGeneratorSource.java
new file mode 100644 (file)
index 0000000..de29e29
--- /dev/null
@@ -0,0 +1,24 @@
+package org.argeo.slc.core.execution.generator;
+
+import java.util.List;
+
+/**
+ * Provides 2 types of information required by an <code>ExecutionFlowGenerator</code>: 
+ * a list of <code>RunnableCallFlowDescriptor</code> used to create <code>RunnableCallFlow</code>
+ * and a list of <code>RunnableDataNode</code> used to create any kind of flow via a factory.
+ */
+public interface ExecutionFlowGeneratorSource {
+       
+       /**
+        * @return a list of <code>RunnableCallFlowDescriptor</code> used 
+        * by a <code>ExecutionFlowGenerator</code> to create <code>RunnableCallFlow</code>
+        */
+       public List<RunnableCallFlowDescriptor> getRunnableCallFlowDescriptors();
+       
+       /**
+        * @return a list of <code>RunnableDataNode</code> used 
+        * by a <code>ExecutionFlowGenerator</code> to create any kind of flow via a factory
+        */
+       public List<RunnableDataNode> getRunnableDataNodes();
+       
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCall.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCall.java
new file mode 100644 (file)
index 0000000..d774072
--- /dev/null
@@ -0,0 +1,55 @@
+package org.argeo.slc.core.execution.generator;
+
+import java.util.Map;
+
+/**
+ * Storage class for information required to call a flow 
+ * of the Spring execution context: 
+ * bean name of the flow,
+ * variables to add to the Execution Context before the call 
+ * and variables (context values) to add to a Map 
+ * potentially referenced by the called flow 
+ */
+public class RunnableCall {
+       
+       /**
+        * Bean name of the flow to call
+        */
+       private String beanName;
+       
+       /**
+        * Variables to add to the execution context before the call
+        */
+       private Map<String, Object> executionVariables;
+       
+       /**
+        * Variables to add to the Map potentially referenced by
+        * the called flow
+        */
+       private Map<String, Object> contextValues;
+
+       public String getBeanName() {
+               return beanName;
+       }
+
+       public void setBeanName(String beanName) {
+               this.beanName = beanName;
+       }
+
+       public Map<String, Object> getExecutionVariables() {
+               return executionVariables;
+       }
+
+       public void setExecutionVariables(Map<String, Object> executionVariables) {
+               this.executionVariables = executionVariables;
+       }
+
+       public Map<String, Object> getContextValues() {
+               return contextValues;
+       }
+
+       public void setContextValues(Map<String, Object> contextValues) {
+               this.contextValues = contextValues;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlow.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlow.java
new file mode 100644 (file)
index 0000000..04043ac
--- /dev/null
@@ -0,0 +1,228 @@
+package org.argeo.slc.core.execution.generator;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.DefaultExecutionSpec;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionSpec;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Execution Flow calling a list of <code>Runnable</code> (identified by their
+ * bean name in the Spring Application Context) after configuring the Execution
+ * context and a Map potentially shared by the called <code>Runnable</code>
+ * 
+ */
+public class RunnableCallFlow implements ExecutionFlow, ApplicationContextAware {
+
+       private final static Log log = LogFactory.getLog(RunnableCallFlow.class);
+
+       /**
+        * Key in the execution context for the index of the call (e.g. 0 for the
+        * first runnable called, ...)
+        */
+       public final static String VAR_CALL_INDEX = "slcVar.runnableCallFlow.callIndex";
+
+       /**
+        * Name of the flow. Also bean name
+        */
+       private String name;
+
+       /**
+        * Path of the flow
+        */
+       private String path;
+
+       /**
+        * Whether an exception in a <code>Runnable</code> shall stop the execution
+        * of the flow
+        */
+       private Boolean failOnError = true;
+
+       /**
+        * List of <code>Runnable</code> to call, with bean name, execution
+        * variables and context values
+        */
+       private List<RunnableCall> runnableCalls;
+
+       /**
+        * Map potentially referenced by called flows. Updated with the context
+        * values of a Runnable before calling it.
+        */
+       private Map<String, Object> sharedContextValuesMap;
+
+       /**
+        * ExecutionSpec of the flow. Does not contain any attribute.
+        */
+       private ExecutionSpec executionSpec = new DefaultExecutionSpec();
+
+       /**
+        * Reference to the ExecutionContext
+        */
+       private ExecutionContext executionContext;
+
+       /**
+        * Reference to the Spring <code>ApplicationContext</code>. Set via
+        * <code>setApplicationContext</code>, the class implementing
+        * <code>ApplicationContextAware</code>
+        */
+       private ApplicationContext applicationContext;
+
+       /**
+        * Runs a <code>Runnable</code> after configuring the Execution Context and
+        * <code>sharedContextValuesMap</code>
+        * 
+        * @param runnable
+        *            the <code>Runnable</code> to call
+        * @param executionVariables
+        *            the variables to add to the <code>ExecutionContext</code>
+        * @param contextValues
+        *            the variables to add to <code>sharedContextValuesMap</code>
+        * @param callIndex
+        *            index of the call (0 for the first called
+        *            <code>Runnable</code>) set as variable of the
+        *            <code>ExecutionContext</code>
+        */
+       private void run(Runnable runnable, Map<String, Object> executionVariables,
+                       Map<String, Object> contextValues, int callIndex) {
+               // add all variables to the Execution Context
+               for (Map.Entry<String, Object> entry : executionVariables.entrySet()) {
+                       executionContext.setVariable(entry.getKey(), entry.getValue());
+               }
+
+               // add call Index Variable
+               executionContext.setVariable(VAR_CALL_INDEX, callIndex);
+
+               // clear sharedContextValues and add all values of contextValues
+               if (sharedContextValuesMap != null) {
+                       sharedContextValuesMap.clear();
+                       sharedContextValuesMap.putAll(contextValues);
+               }
+
+               // then run the runnable
+               doExecuteRunnable(runnable);
+       }
+
+       public void doExecuteRunnable(Runnable runnable) {
+               runnable.run();
+       }
+
+       /**
+        * Executes the flow. For each <code>RunnableCall</code>, the corresponding
+        * flow is retrieved from the Spring Application Context, the
+        * <code>ExecutionContext</code> and <code>sharedContextValuesMap</code> are
+        * configured and the <code>Runnable</code> is called.
+        */
+       public void run() {
+               if (applicationContext == null) {
+                       throw new SlcException("No ApplicationContext defined");
+               }
+
+               try {
+                       for (int callIndex = 0; callIndex < runnableCalls.size(); ++callIndex) {
+                               RunnableCall runnableCall = runnableCalls.get(callIndex);
+                               Object bean = applicationContext.getBean(
+                                               runnableCall.getBeanName(), Runnable.class);
+                               if (log.isDebugEnabled())
+                                       log.debug("Running flow '" + runnableCall.getBeanName()
+                                                       + "'");
+                               run((Runnable) bean, runnableCall.getExecutionVariables(),
+                                               runnableCall.getContextValues(), callIndex);
+                       }
+               } catch (RuntimeException e) {
+                       if (failOnError)
+                               throw e;
+                       else {
+                               log.error("Execution flow failed,"
+                                               + " but process did not fail"
+                                               + " because failOnError property"
+                                               + " is set to false: " + e);
+                               if (log.isTraceEnabled())
+                                       e.printStackTrace();
+                       }
+               }
+       }
+
+       public Iterator<Runnable> runnables() {
+               List<Runnable> runnables = new ArrayList<Runnable>();
+               for (int callIndex = 0; callIndex < runnableCalls.size(); ++callIndex) {
+                       RunnableCall runnableCall = runnableCalls.get(callIndex);
+                       Object bean = applicationContext.getBean(
+                                       runnableCall.getBeanName(), Runnable.class);
+                       runnables.add((Runnable) bean);
+               }
+               return runnables.iterator();
+       }
+
+       public Runnable getRunnable() {
+               if (runnableCalls.size() == 1)
+                       return runnables().next();
+               else
+                       throw new SlcException("There are " + runnableCalls.size()
+                                       + " runnables in flow " + getName());
+       }
+
+       @Override
+       public String toString() {
+               return new StringBuffer("RunnableCallFlow ").append(name).toString();
+       }
+
+       public ExecutionSpec getExecutionSpec() {
+               return executionSpec;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public Object getParameter(String key) {
+               throw new SlcException("RunnableCallFlow have no parameters");
+       }
+
+       public String getPath() {
+               return path;
+       }
+
+       public Boolean isSetAsParameter(String key) {
+               // The ExecutionSpec having no attribute,
+               // always return false
+               return false;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public void setPath(String path) {
+               this.path = path;
+       }
+
+       public void setExecutionContext(ExecutionContext executionContext) {
+               this.executionContext = executionContext;
+       }
+
+       public void setRunnableCalls(List<RunnableCall> runnableCalls) {
+               this.runnableCalls = runnableCalls;
+       }
+
+       public void setApplicationContext(ApplicationContext applicationContext) {
+               this.applicationContext = applicationContext;
+       }
+
+       public void setSharedContextValuesMap(Map<String, Object> contextValues) {
+               this.sharedContextValuesMap = contextValues;
+       }
+
+       public void setFailOnError(Boolean failOnError) {
+               this.failOnError = failOnError;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlowDescriptor.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableCallFlowDescriptor.java
new file mode 100644 (file)
index 0000000..738b75f
--- /dev/null
@@ -0,0 +1,55 @@
+package org.argeo.slc.core.execution.generator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Storage Class for information required to
+ * instantiate a <code>RunnableCallFlow</code>:
+ * bean name of the flow, 
+ * path of the flow 
+ * and list of <code>RunnableCall</code>. 
+ *
+ */
+public class RunnableCallFlowDescriptor {
+       
+       /**
+        * Bean name of the flow to instantiate
+        */
+       private String beanName;
+       
+       /**
+        * Path of the flow to instantiate
+        */
+       private String path;
+       
+       /**
+        * List of <code>RunnableCall</code> 
+        */
+       private List<RunnableCall> runnableCalls = new ArrayList<RunnableCall>();
+
+       public String getBeanName() {
+               return beanName;
+       }
+
+       public void setBeanName(String beanName) {
+               this.beanName = beanName;
+       }
+
+       public String getPath() {
+               return path;
+       }
+
+       public void setPath(String path) {
+               this.path = path;
+       }
+
+       public List<RunnableCall> getRunnableCalls() {
+               return runnableCalls;
+       }
+
+       public void setRunnableCalls(List<RunnableCall> runnableCalls) {
+               this.runnableCalls = runnableCalls;
+       }
+       
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableDataNode.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableDataNode.java
new file mode 100644 (file)
index 0000000..e526b5e
--- /dev/null
@@ -0,0 +1,59 @@
+package org.argeo.slc.core.execution.generator;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Stores information relative to a Runnable.
+ * Allows to structure the information as a tree, each node
+ * storing data as a Map.
+ */
+public interface RunnableDataNode {
+
+       /**
+        * @return a Map containing the data associated with this node.
+        * Data associated with parent nodes are expected
+        * to be contained in the returned Map
+        */
+       public Map<String, Object> getData();   
+
+       /**
+        * @return the name of the bean to create.
+        * Can be null if no bean shall be created for the 
+        * <code>RunnableDataNode</code> (e.g. is is a sub-node)
+        */
+       public String getBeanName();
+       
+       /**
+        * @return the path of the flow bean to create.
+        * Can be null if the bean to created is not an
+        * <code>ExecutionFlow</code> or if no bean shall be created for the 
+        * <code>RunnableDataNode</code> (e.g. is is a sub-node)
+        */
+       public String getPath();
+               
+       /**
+        * @return whether the <code>RunnableDataNode</code> has
+        * children or not.
+        * Expected to be equivalent to <code>getChildren().empty()</code>
+        */
+       public boolean isLeaf();
+
+       /**
+        * @return the list of <code>RunnableDataNode</code> children.
+        * Can be empty. Shall not be null.
+        */
+       public List<RunnableDataNode> getChildren();
+       
+       /**
+        * @return the <code>RunnableDataNode</code> parent.
+        * Can be null if no parent is defined (top node).
+        */
+       public RunnableDataNode getParent();
+       
+       /**
+        * Sets the <code>RunnableDataNode</code> parent
+        * @param parent
+        */
+       public void setParent(RunnableDataNode parent); 
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableFactory.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/generator/RunnableFactory.java
new file mode 100644 (file)
index 0000000..c81008a
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.core.execution.generator;
+
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+/**
+ * Interprets a <code>RunnableDataNode</code> by creating corresponding
+ * beans and registering them in a <code>BeanDefinitionRegistry</code>
+ *
+ */
+public interface RunnableFactory {
+
+       public void createAndRegisterRunnable(RunnableDataNode node,
+                       BeanDefinitionRegistry beanDefinitionRegistry);
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/runtime.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/runtime.xml
new file mode 100644 (file)
index 0000000..303d55c
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License, 
+       Version 2.0 (the "License"); you may not use this file except in compliance 
+       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
+       Unless required by applicable law or agreed to in writing, software distributed 
+       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
+       OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
+       the specific language governing permissions and limitations under the License. -->
+<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under 
+       the Apache License, Version 2.0 (the "License"); you may not use this file 
+       except in compliance with the License. You may obtain a copy of the License 
+       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
+       law or agreed to in writing, software distributed under the License is distributed 
+       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
+       express or implied. See the License for the specific language governing permissions 
+       and limitations under the License. -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+       <description>Bare minimal runtime configuration. In general you will
+               want to use simple.xml instead.
+       </description>
+
+       <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
+               <property name="scopes">
+                       <map>
+                               <entry key="execution">
+                                       <bean class="org.argeo.slc.core.execution.ExecutionScope" />
+                               </entry>
+                       </map>
+               </property>
+       </bean>
+
+
+       <bean id="executionStack" class="org.argeo.slc.runtime.DefaultExecutionStack"
+               scope="execution">
+               <aop:scoped-proxy proxy-target-class="false" />
+       </bean>
+
+       <bean id="instantiationManager" class="org.argeo.slc.runtime.InstantiationManager" />
+
+       <bean class="org.argeo.slc.core.execution.ExecutionParameterPostProcessor">
+               <property name="executionContext" ref="executionContext" />
+               <property name="instantiationManager" ref="instantiationManager" />
+       </bean>
+
+       <!-- <bean class="org.argeo.slc.core.execution.ExecutionAspect"> -->
+       <!-- <property name="executionStack" ref="executionStack" /> -->
+       <!-- <property name="executionContext" ref="executionContext" /> -->
+       <!-- </bean> -->
+
+       <aop:aspectj-autoproxy />
+
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/simple.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/simple.xml
new file mode 100644 (file)
index 0000000..ff243ba
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License, 
+       Version 2.0 (the "License"); you may not use this file except in compliance 
+       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
+       Unless required by applicable law or agreed to in writing, software distributed 
+       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
+       OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
+       the specific language governing permissions and limitations under the License. -->
+<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under 
+       the Apache License, Version 2.0 (the "License"); you may not use this file 
+       except in compliance with the License. You may obtain a copy of the License 
+       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
+       law or agreed to in writing, software distributed under the License is distributed 
+       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
+       express or implied. See the License for the specific language governing permissions 
+       and limitations under the License. -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+       <description>Default Capabilities</description>
+
+       <import resource="runtime.xml" />
+
+       <bean id="executionContext" class="org.argeo.slc.core.execution.MapExecutionContext"
+               scope="execution">
+               <aop:scoped-proxy proxy-target-class="false" />
+               <property name="executionStack" ref="executionStack" />
+       </bean>
+
+       <bean id="executionFlowDescriptorConverter"
+               class="org.argeo.slc.core.execution.DefaultExecutionFlowDescriptorConverter"></bean>
+
+       <bean
+               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
+               <property name="ignoreUnresolvablePlaceholders" value="true" />
+       </bean>
+
+       <bean id="parameterRef" class="org.argeo.slc.core.execution.ParameterRef"
+               abstract="true">
+               <property name="instantiationManager" ref="instantiationManager" />
+       </bean>
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/specs.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/specs.xml
new file mode 100644 (file)
index 0000000..b1251d3
--- /dev/null
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2007-2012 Argeo GmbH
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+            http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <bean id="specAttr.primitive" class="org.argeo.slc.primitive.PrimitiveSpecAttribute"
+               abstract="true" />
+       <bean id="specAttr.resource" class="org.argeo.slc.core.execution.ResourceSpecAttribute"
+               abstract="true" />
+       <bean id="specAttr.ref" class="org.argeo.slc.execution.RefSpecAttribute"
+               abstract="true" />
+
+       <bean id="slcTemplate.simpleFlow" class="org.argeo.slc.core.execution.DefaultExecutionFlow"
+               abstract="true" />
+       <bean id="slcTemplate.simpleSpec" class="org.argeo.slc.core.execution.DefaultExecutionSpec"
+               abstract="true" />
+
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/spring.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/spring.xml
new file mode 100644 (file)
index 0000000..de1c06b
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2007-2012 Argeo GmbH
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+            http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under 
+       the Apache License, Version 2.0 (the "License"); you may not use this file 
+       except in compliance with the License. You may obtain a copy of the License 
+       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
+       law or agreed to in writing, software distributed under the License is distributed 
+       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
+       express or implied. See the License for the specific language governing permissions 
+       and limitations under the License. -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+       <description>
+               Simple runtime enriched with defaults and templates used
+               to simplify XML files. These templates have been deprecated by the
+               custom XML namespace and will be removed in SLC 2.x. Use the XML
+               namespace instead.
+       </description>
+
+       <import resource="simple.xml" />
+
+       <import resource="specs.xml" />
+       <import resource="templates.xml" />
+       <import resource="defaults.xml" />
+       <import resource="utils.xml" />
+       <import resource="tasks/core.xml" />
+
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/CloseTestResult.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/CloseTestResult.java
new file mode 100644 (file)
index 0000000..76460d6
--- /dev/null
@@ -0,0 +1,16 @@
+package org.argeo.slc.core.execution.tasks;
+
+import org.argeo.slc.test.TestResult;
+
+public class CloseTestResult implements Runnable {
+       private TestResult testResult;
+
+       public void run() {
+               testResult.close();
+       }
+
+       public void setTestResult(TestResult testResult) {
+               this.testResult = testResult;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/Echo.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/Echo.java
new file mode 100644 (file)
index 0000000..8714024
--- /dev/null
@@ -0,0 +1,47 @@
+package org.argeo.slc.core.execution.tasks;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.core.io.Resource;
+
+public class Echo implements Runnable {
+       private final static Log defaultLog = LogFactory.getLog(Echo.class);
+       private Resource writeTo = null;
+
+       private Log log;
+       private Object message;
+
+       public void run() {
+               log().info(message);
+
+               if (writeTo != null) {
+                       try {
+                               File file = writeTo.getFile();
+                               if (log().isDebugEnabled())
+                                       log().debug("Write to " + file);
+                               if (message != null)
+                                       FileUtils.writeStringToFile(file, message.toString());
+                       } catch (IOException e) {
+                               throw new SlcException("Could not write to " + writeTo, e);
+                       }
+               }
+       }
+
+       private Log log() {
+               return log != null ? log : defaultLog;
+       }
+
+       public void setMessage(Object message) {
+               this.message = message;
+       }
+
+       public void setWriteTo(Resource writeTo) {
+               this.writeTo = writeTo;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/If.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/If.java
new file mode 100644 (file)
index 0000000..f8a79d8
--- /dev/null
@@ -0,0 +1,49 @@
+package org.argeo.slc.core.execution.tasks;
+
+import org.argeo.slc.SlcException;
+
+/** Conditional execution */
+public class If implements Runnable {
+       private Boolean is;
+       private Boolean not;
+       private Runnable then;
+       private Runnable els;
+
+       public void run() {
+               if (is == null && not == null)
+                       throw new SlcException("No condition set");
+               if (is != null && not != null)
+                       throw new SlcException("Both is and not cannot be set");
+
+               boolean bool = (is != null ? is : !not);
+               if (bool) {
+                       if (then != null)
+                               then.run();
+               } else {
+                       if (els != null)
+                               els.run();
+               }
+
+       }
+
+       public void setIs(Boolean bool) {
+               this.is = bool;
+       }
+
+       public void setThen(Runnable then) {
+               this.then = then;
+       }
+
+       public void setEls(Runnable els) {
+               this.els = els;
+       }
+
+       public Boolean getNot() {
+               return not;
+       }
+
+       public void setNot(Boolean not) {
+               this.not = not;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/JvmProcess.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/JvmProcess.java
new file mode 100644 (file)
index 0000000..157c150
--- /dev/null
@@ -0,0 +1,238 @@
+package org.argeo.slc.core.execution.tasks;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.slc.SlcException;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
+
+/** A Java Virtual Machine process. */
+public class JvmProcess extends SystemCall implements InitializingBean {
+       private Properties systemProperties = new Properties();
+       private List<Resource> classpath = new ArrayList<Resource>();
+       private List<Resource> pBootClasspath = new ArrayList<Resource>();
+       private Resource jvm = null;
+       private String mainClass;
+       private String mainJar;
+       private List<String> jvmArgs = new ArrayList<String>();
+       private List<String> args = new ArrayList<String>();
+
+       private String systemPropertiesFileProperty = null;
+       private String systemPropertiesFileDir = null;
+       private String systemPropertiesFileName = null;
+
+       public void afterPropertiesSet() throws Exception {
+               List<Object> command = new ArrayList<Object>();
+               if (jvm != null)
+                       command.add(asFile(jvm).getPath());
+               else
+                       command.add("java");
+
+               if (pBootClasspath.size() > 0) {
+                       StringBuffer buf = new StringBuffer("-Xbootclasspath/p:");
+                       Boolean first = true;
+                       for (Resource res : pBootClasspath) {
+                               if (first)
+                                       first = false;
+                               else
+                                       buf.append(File.pathSeparatorChar);
+
+                               buf.append(asFile(res));
+                       }
+                       command.add(buf.toString());
+               }
+
+               for (String jvmArg : jvmArgs) {
+                       command.add(jvmArg);
+               }
+
+               if (classpath.size() > 0) {
+                       command.add("-cp");
+                       StringBuffer buf = new StringBuffer("");
+                       for (Resource res : classpath) {
+                               if (buf.length() != 0)
+                                       buf.append(File.pathSeparatorChar);
+                               buf.append(asFile(res));
+                       }
+                       command.add(buf.toString());
+               }
+
+               if (systemPropertiesFileProperty == null) {
+                       // pass system properties as argument
+                       for (Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
+                               command.add("-D" + entry.getKey() + "=" + entry.getValue());
+                       }
+               } else {
+                       // write system properties in a file to work around OS limitations
+                       // with command line (e.g. Win XP)
+                       String dir = systemPropertiesFileDir;
+                       if (dir == null)
+                               dir = getExecDirToUse();
+                       String fileName = systemPropertiesFileName;
+                       if (fileName == null)
+                               fileName = systemPropertiesFileProperty + ".properties";
+
+                       // Write file
+                       FileOutputStream fos = null;
+                       File file = new File(dir + File.separator + fileName);
+                       try {
+
+                               if (!file.getParentFile().exists())
+                                       file.getParentFile().mkdirs();
+                               fos = new FileOutputStream(file);
+                               systemProperties.store(fos, "Automatically generated by "
+                                               + getClass());
+                               command.add("-D" + systemPropertiesFileProperty + "="
+                                               + file.getCanonicalPath());
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot write to system properties to "
+                                               + file, e);
+                       } finally {
+                               IOUtils.closeQuietly(fos);
+                       }
+               }
+
+               // Program
+               if (mainClass != null) {
+                       command.add(mainClass);
+               } else if (mainJar != null) {
+                       command.add("-jar");
+                       command.add(mainJar);
+               } else {
+                       throw new SlcException("No main class or jar defined");
+               }
+
+               for (String arg : args) {
+                       command.add(arg);
+               }
+
+               setCommand(command);
+       }
+
+       protected File asFile(Resource res) {
+               try {
+                       return res.getFile();
+               } catch (FileNotFoundException e) {
+                       return copyToTempFile(res);
+               } catch (IOException e) {
+                       throw new SlcException("Cannot convert resource to file", e);
+               }
+
+       }
+
+       protected File copyToTempFile(Resource res) {
+               File tempFile;
+               FileOutputStream fos;
+               try {
+                       tempFile = File.createTempFile("slcJvmProcess-", res.getFilename());
+                       tempFile.deleteOnExit();
+                       fos = new FileOutputStream(tempFile);
+                       IOUtils.copy(res.getInputStream(), fos);
+               } catch (IOException e) {
+                       throw new SlcException("Cannot copy " + res + " to temp file.", e);
+               }
+               IOUtils.closeQuietly(fos);
+               return tempFile;
+       }
+
+       /** Append the argument (for chaining) */
+       @Override
+       public SystemCall arg(String arg) {
+               args.add(arg);
+               return this;
+       }
+
+       /** Append the argument (for chaining) */
+       @Override
+       public SystemCall arg(String arg, String value) {
+               args.add(arg);
+               args.add(value);
+               return this;
+       }
+
+       public Properties getSystemProperties() {
+               return systemProperties;
+       }
+
+       public void setSystemProperties(Properties systemProperties) {
+               this.systemProperties = systemProperties;
+       }
+
+       public List<Resource> getClasspath() {
+               return classpath;
+       }
+
+       public void setClasspath(List<Resource> classpath) {
+               this.classpath = classpath;
+       }
+
+       public List<Resource> getPBootClasspath() {
+               return pBootClasspath;
+       }
+
+       public void setPBootClasspath(List<Resource> bootClasspath) {
+               pBootClasspath = bootClasspath;
+       }
+
+       public Resource getJvm() {
+               return jvm;
+       }
+
+       public void setJvm(Resource jvm) {
+               this.jvm = jvm;
+       }
+
+       public String getMainClass() {
+               return mainClass;
+       }
+
+       public void setMainClass(String mainClass) {
+               this.mainClass = mainClass;
+       }
+
+       public String getMainJar() {
+               return mainJar;
+       }
+
+       public void setMainJar(String mainJar) {
+               this.mainJar = mainJar;
+       }
+
+       public List<String> getJvmArgs() {
+               return jvmArgs;
+       }
+
+       public void setJvmArgs(List<String> jvmArgs) {
+               this.jvmArgs = jvmArgs;
+       }
+
+       public List<String> getArgs() {
+               return args;
+       }
+
+       public void setArgs(List<String> args) {
+               this.args = args;
+       }
+
+       public void setSystemPropertiesFileProperty(
+                       String systemPropertiesFilePropertyName) {
+               this.systemPropertiesFileProperty = systemPropertiesFilePropertyName;
+       }
+
+       public void setSystemPropertiesFileDir(String systemPropertiesFileDir) {
+               this.systemPropertiesFileDir = systemPropertiesFileDir;
+       }
+
+       public void setSystemPropertiesFileName(String systemPropertiesFileName) {
+               this.systemPropertiesFileName = systemPropertiesFileName;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MergedLists.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MergedLists.java
new file mode 100644 (file)
index 0000000..bb25c88
--- /dev/null
@@ -0,0 +1,32 @@
+package org.argeo.slc.core.execution.tasks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.FactoryBean;
+
+/** Merge the provided lists in one single list, in the order provided. */
+public class MergedLists implements FactoryBean<List<Object>> {
+       private List<List<Object>> lists = new ArrayList<List<Object>>();
+
+       public void setLists(List<List<Object>> lists) {
+               this.lists = lists;
+       }
+
+       public List<Object> getObject() throws Exception {
+               List<Object> merged = new ArrayList<Object>();
+               for (List<Object> lst : lists) {
+                       merged.addAll(lst);
+               }
+               return merged;
+       }
+
+       public Class<?> getObjectType() {
+               return List.class;
+       }
+
+       public boolean isSingleton() {
+               return false;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MethodCall.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/MethodCall.java
new file mode 100644 (file)
index 0000000..88aeb47
--- /dev/null
@@ -0,0 +1,38 @@
+package org.argeo.slc.core.execution.tasks;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
+
+public class MethodCall implements Runnable {
+       private Object target;
+       private String method;
+       private List<Object> args = new ArrayList<Object>();
+
+       public void run() {
+               Assert.notNull(target, "target");
+               Assert.notNull(method, "method");
+               Method methodRef = ReflectionUtils
+                               .findMethod(target.getClass(), method);
+               if (args.size() == 0)
+                       ReflectionUtils.invokeMethod(methodRef, target);
+               else
+                       ReflectionUtils.invokeMethod(methodRef, methodRef, args.toArray());
+       }
+
+       public void setTarget(Object target) {
+               this.target = target;
+       }
+
+       public void setMethod(String method) {
+               this.method = method;
+       }
+
+       public void setArgs(List<Object> args) {
+               this.args = args;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/OverrideContextAware.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/OverrideContextAware.java
new file mode 100644 (file)
index 0000000..6162ecb
--- /dev/null
@@ -0,0 +1,57 @@
+package org.argeo.slc.core.execution.tasks;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.test.context.SimpleContextAware;
+import org.argeo.slc.test.context.ContextAware;
+
+/**
+ * Overrides Values and Expected values of a target 
+ * <code>SimpleContextAware</code> with the corresponding
+ * values and expected values of a source <code>ContextAware</code>
+ *
+ */
+public class OverrideContextAware implements Runnable {
+
+       private ContextAware source;
+
+       private SimpleContextAware target;
+       
+       /**
+        * Whether an exception shall be thrown if a value
+        * or expected value of the source is not defined
+        * in the target
+        */
+       private Boolean failIfUndefinedInSource = true;
+       
+       public void run() {
+               // override values
+               if(source.getValues() != null)
+                       for(String key : source.getValues().keySet()) {
+                               if(failIfUndefinedInSource && !target.getValues().containsKey(key)) {
+                                       throw new SlcException("No entry in target values for key '" + key + "'");
+                               }
+                               target.getValues().put(key, source.getValues().get(key));
+                       }
+               
+               // override expected values
+               if(source.getExpectedValues() != null)
+                       for(String key : source.getExpectedValues().keySet()) {
+                               if(failIfUndefinedInSource && !target.getExpectedValues().containsKey(key)) {
+                                       throw new SlcException("No entry in target expected values for key '" + key + "'");
+                               }
+                               target.getExpectedValues().put(key, source.getExpectedValues().get(key));
+                       }               
+       }       
+       
+       public void setSource(ContextAware source) {
+               this.source = source;
+       }
+
+       public void setTarget(SimpleContextAware target) {
+               this.target = target;
+       }
+
+       public void setFailIfUndefinedInSource(Boolean failIfUndefinedInSource) {
+               this.failIfUndefinedInSource = failIfUndefinedInSource;
+       }       
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCall.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCall.java
new file mode 100644 (file)
index 0000000..633f8f9
--- /dev/null
@@ -0,0 +1,767 @@
+package org.argeo.slc.core.execution.tasks;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.security.auth.callback.CallbackHandler;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteResultHandler;
+import org.apache.commons.exec.ExecuteStreamHandler;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.LogOutputStream;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.exec.ShutdownHookProcessDestroyer;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.UnsupportedException;
+import org.argeo.slc.core.execution.ExecutionResources;
+import org.argeo.slc.runtime.test.SimpleResultPart;
+import org.argeo.slc.test.TestResult;
+import org.argeo.slc.test.TestStatus;
+import org.springframework.core.io.Resource;
+
+/** Execute an OS specific system call. */
+public class SystemCall implements Runnable {
+       public final static String LOG_STDOUT = "System.out";
+
+       private final Log log = LogFactory.getLog(getClass());
+
+       private String execDir;
+
+       private String cmd = null;
+       private List<Object> command = null;
+
+       private Executor executor = new DefaultExecutor();
+       private Boolean synchronous = true;
+
+       private String stdErrLogLevel = "ERROR";
+       private String stdOutLogLevel = "INFO";
+
+       private Resource stdOutFile = null;
+       private Resource stdErrFile = null;
+
+       private Resource stdInFile = null;
+       /**
+        * If no {@link #stdInFile} provided, writing to this stream will write to
+        * the stdin of the process.
+        */
+       private OutputStream stdInSink = null;
+
+       private Boolean redirectStdOut = false;
+
+       private List<SystemCallOutputListener> outputListeners = Collections
+                       .synchronizedList(new ArrayList<SystemCallOutputListener>());
+
+       private Map<String, List<Object>> osCommands = new HashMap<String, List<Object>>();
+       private Map<String, String> osCmds = new HashMap<String, String>();
+       private Map<String, String> environmentVariables = new HashMap<String, String>();
+
+       private Boolean logCommand = false;
+       private Boolean redirectStreams = true;
+       private Boolean exceptionOnFailed = true;
+       private Boolean mergeEnvironmentVariables = true;
+
+//     private Authentication authentication;
+
+       private String osConsole = null;
+       private String generateScript = null;
+
+       /** 24 hours */
+       private Long watchdogTimeout = 24 * 60 * 60 * 1000l;
+
+       private TestResult testResult;
+
+       private ExecutionResources executionResources;
+
+       /** Sudo the command, as root if empty or as user if not. */
+       private String sudo = null;
+       // TODO make it more secure and robust, test only once
+       private final String sudoPrompt = UUID.randomUUID().toString();
+       private String askPassProgram = "/usr/libexec/openssh/ssh-askpass";
+       @SuppressWarnings("unused")
+       private boolean firstLine = true;
+       @SuppressWarnings("unused")
+       private CallbackHandler callbackHandler;
+       /** Chroot to the this path (must not be empty) */
+       private String chroot = null;
+
+       // Current
+       /** Current watchdog, null if process is completed */
+       ExecuteWatchdog currentWatchdog = null;
+
+       /** Empty constructor */
+       public SystemCall() {
+
+       }
+
+       /**
+        * Constructor based on the provided command list.
+        * 
+        * @param command
+        *            the command list
+        */
+       public SystemCall(List<Object> command) {
+               this.command = command;
+       }
+
+       /**
+        * Constructor based on the provided command.
+        * 
+        * @param cmd
+        *            the command. If the provided string contains no space a
+        *            command list is initialized with the argument as first
+        *            component (useful for chained construction)
+        */
+       public SystemCall(String cmd) {
+               if (cmd.indexOf(' ') < 0) {
+                       command = new ArrayList<Object>();
+                       command.add(cmd);
+               } else {
+                       this.cmd = cmd;
+               }
+       }
+
+       /** Executes the system call. */
+       public void run() {
+//             authentication = SecurityContextHolder.getContext().getAuthentication();
+
+               // Manage streams
+               Writer stdOutWriter = null;
+               OutputStream stdOutputStream = null;
+               Writer stdErrWriter = null;
+               InputStream stdInStream = null;
+               if (stdOutFile != null)
+                       if (redirectStdOut)
+                               stdOutputStream = createOutputStream(stdOutFile);
+                       else
+                               stdOutWriter = createWriter(stdOutFile, true);
+
+               if (stdErrFile != null) {
+                       stdErrWriter = createWriter(stdErrFile, true);
+               } else {
+                       if (stdOutFile != null && !redirectStdOut)
+                               stdErrWriter = createWriter(stdOutFile, true);
+               }
+
+               try {
+                       if (stdInFile != null)
+                               stdInStream = stdInFile.getInputStream();
+                       else {
+                               stdInStream = new PipedInputStream();
+                               stdInSink = new PipedOutputStream(
+                                               (PipedInputStream) stdInStream);
+                       }
+               } catch (IOException e2) {
+                       throw new SlcException("Cannot open a stream for " + stdInFile, e2);
+               }
+
+               if (log.isTraceEnabled()) {
+                       log.debug("os.name=" + System.getProperty("os.name"));
+                       log.debug("os.arch=" + System.getProperty("os.arch"));
+                       log.debug("os.version=" + System.getProperty("os.version"));
+               }
+
+               // Execution directory
+               File dir = new File(getExecDirToUse());
+               // if (!dir.exists())
+               // dir.mkdirs();
+
+               // Watchdog to check for lost processes
+               Executor executorToUse;
+               if (executor != null)
+                       executorToUse = executor;
+               else
+                       executorToUse = new DefaultExecutor();
+               executorToUse.setWatchdog(createWatchdog());
+
+               if (redirectStreams) {
+                       // Redirect standard streams
+                       executorToUse.setStreamHandler(createExecuteStreamHandler(
+                                       stdOutWriter, stdOutputStream, stdErrWriter, stdInStream));
+               } else {
+                       // Dummy stream handler (otherwise pump is used)
+                       executorToUse.setStreamHandler(new DummyexecuteStreamHandler());
+               }
+
+               executorToUse.setProcessDestroyer(new ShutdownHookProcessDestroyer());
+               executorToUse.setWorkingDirectory(dir);
+
+               // Command line to use
+               final CommandLine commandLine = createCommandLine();
+               if (logCommand)
+                       log.info("Execute command:\n" + commandLine
+                                       + "\n in working directory: \n" + dir + "\n");
+
+               // Env variables
+               Map<String, String> environmentVariablesToUse = null;
+               environmentVariablesToUse = new HashMap<String, String>();
+               if (mergeEnvironmentVariables)
+                       environmentVariablesToUse.putAll(System.getenv());
+               if (environmentVariables.size() > 0)
+                       environmentVariablesToUse.putAll(environmentVariables);
+
+               // Execute
+               ExecuteResultHandler executeResultHandler = createExecuteResultHandler(commandLine);
+
+               //
+               // THE EXECUTION PROPER
+               //
+               try {
+                       if (synchronous)
+                               try {
+                                       int exitValue = executorToUse.execute(commandLine,
+                                                       environmentVariablesToUse);
+                                       executeResultHandler.onProcessComplete(exitValue);
+                               } catch (ExecuteException e1) {
+                                       if (e1.getExitValue() == Executor.INVALID_EXITVALUE) {
+                                               Thread.currentThread().interrupt();
+                                               return;
+                                       }
+                                       // Sleep 1s in order to make sure error logs are flushed
+                                       Thread.sleep(1000);
+                                       executeResultHandler.onProcessFailed(e1);
+                               }
+                       else
+                               executorToUse.execute(commandLine, environmentVariablesToUse,
+                                               executeResultHandler);
+               } catch (SlcException e) {
+                       throw e;
+               } catch (Exception e) {
+                       throw new SlcException("Could not execute command " + commandLine,
+                                       e);
+               } finally {
+                       IOUtils.closeQuietly(stdOutWriter);
+                       IOUtils.closeQuietly(stdErrWriter);
+                       IOUtils.closeQuietly(stdInStream);
+                       IOUtils.closeQuietly(stdInSink);
+               }
+
+       }
+
+       public synchronized String function() {
+               final StringBuffer buf = new StringBuffer("");
+               SystemCallOutputListener tempOutputListener = new SystemCallOutputListener() {
+                       private Long lineCount = 0l;
+
+                       public void newLine(SystemCall systemCall, String line,
+                                       Boolean isError) {
+                               if (!isError) {
+                                       if (lineCount != 0l)
+                                               buf.append('\n');
+                                       buf.append(line);
+                                       lineCount++;
+                               }
+                       }
+               };
+               addOutputListener(tempOutputListener);
+               run();
+               removeOutputListener(tempOutputListener);
+               return buf.toString();
+       }
+
+       public String asCommand() {
+               return createCommandLine().toString();
+       }
+
+       @Override
+       public String toString() {
+               return asCommand();
+       }
+
+       /**
+        * Build a command line based on the properties. Can be overridden by
+        * specific command wrappers.
+        */
+       protected CommandLine createCommandLine() {
+               // Check if an OS specific command overrides
+               String osName = System.getProperty("os.name");
+               List<Object> commandToUse = null;
+               if (osCommands.containsKey(osName))
+                       commandToUse = osCommands.get(osName);
+               else
+                       commandToUse = command;
+               String cmdToUse = null;
+               if (osCmds.containsKey(osName))
+                       cmdToUse = osCmds.get(osName);
+               else
+                       cmdToUse = cmd;
+
+               CommandLine commandLine = null;
+
+               // Which command definition to use
+               if (commandToUse == null && cmdToUse == null)
+                       throw new SlcException("Please specify a command.");
+               else if (commandToUse != null && cmdToUse != null)
+                       throw new SlcException(
+                                       "Specify the command either as a line or as a list.");
+               else if (cmdToUse != null) {
+                       if (chroot != null && !chroot.trim().equals(""))
+                               cmdToUse = "chroot \"" + chroot + "\" " + cmdToUse;
+                       if (sudo != null) {
+                               environmentVariables.put("SUDO_ASKPASS", askPassProgram);
+                               if (!sudo.trim().equals(""))
+                                       cmdToUse = "sudo -p " + sudoPrompt + " -u " + sudo + " "
+                                                       + cmdToUse;
+                               else
+                                       cmdToUse = "sudo -p " + sudoPrompt + " " + cmdToUse;
+                       }
+
+                       // GENERATE COMMAND LINE
+                       commandLine = CommandLine.parse(cmdToUse);
+               } else if (commandToUse != null) {
+                       if (commandToUse.size() == 0)
+                               throw new SlcException("Command line is empty.");
+
+                       if (chroot != null && sudo != null) {
+                               commandToUse.add(0, "chroot");
+                               commandToUse.add(1, chroot);
+                       }
+
+                       if (sudo != null) {
+                               environmentVariables.put("SUDO_ASKPASS", askPassProgram);
+                               commandToUse.add(0, "sudo");
+                               commandToUse.add(1, "-p");
+                               commandToUse.add(2, sudoPrompt);
+                               if (!sudo.trim().equals("")) {
+                                       commandToUse.add(3, "-u");
+                                       commandToUse.add(4, sudo);
+                               }
+                       }
+
+                       // GENERATE COMMAND LINE
+                       commandLine = new CommandLine(commandToUse.get(0).toString());
+
+                       for (int i = 1; i < commandToUse.size(); i++) {
+                               if (log.isTraceEnabled())
+                                       log.debug(commandToUse.get(i));
+                               commandLine.addArgument(commandToUse.get(i).toString());
+                       }
+               } else {
+                       // all cases covered previously
+                       throw new UnsupportedException();
+               }
+
+               if (generateScript != null) {
+                       File scriptFile = new File(getExecDirToUse() + File.separator
+                                       + generateScript);
+                       try {
+                               FileUtils.writeStringToFile(scriptFile,
+                                               (osConsole != null ? osConsole + " " : "")
+                                                               + commandLine.toString());
+                       } catch (IOException e) {
+                               throw new SlcException("Could not generate script "
+                                               + scriptFile, e);
+                       }
+                       commandLine = new CommandLine(scriptFile);
+               } else {
+                       if (osConsole != null)
+                               commandLine = CommandLine.parse(osConsole + " "
+                                               + commandLine.toString());
+               }
+
+               return commandLine;
+       }
+
+       /**
+        * Creates a {@link PumpStreamHandler} which redirects streams to the custom
+        * logging mechanism.
+        */
+       protected ExecuteStreamHandler createExecuteStreamHandler(
+                       final Writer stdOutWriter, final OutputStream stdOutputStream,
+                       final Writer stdErrWriter, final InputStream stdInStream) {
+
+               // Log writers
+               OutputStream stdout = stdOutputStream != null ? stdOutputStream
+                               : new LogOutputStream() {
+                                       protected void processLine(String line, int level) {
+                                               // if (firstLine) {
+                                               // if (sudo != null && callbackHandler != null
+                                               // && line.startsWith(sudoPrompt)) {
+                                               // try {
+                                               // PasswordCallback pc = new PasswordCallback(
+                                               // "sudo password", false);
+                                               // Callback[] cbs = { pc };
+                                               // callbackHandler.handle(cbs);
+                                               // char[] pwd = pc.getPassword();
+                                               // char[] arr = Arrays.copyOf(pwd,
+                                               // pwd.length + 1);
+                                               // arr[arr.length - 1] = '\n';
+                                               // IOUtils.write(arr, stdInSink);
+                                               // stdInSink.flush();
+                                               // } catch (Exception e) {
+                                               // throw new SlcException(
+                                               // "Cannot retrieve sudo password", e);
+                                               // }
+                                               // }
+                                               // firstLine = false;
+                                               // }
+
+                                               if (line != null && !line.trim().equals(""))
+                                                       logStdOut(line);
+
+                                               if (stdOutWriter != null)
+                                                       appendLineToFile(stdOutWriter, line);
+                                       }
+                               };
+
+               OutputStream stderr = new LogOutputStream() {
+                       protected void processLine(String line, int level) {
+                               if (line != null && !line.trim().equals(""))
+                                       logStdErr(line);
+                               if (stdErrWriter != null)
+                                       appendLineToFile(stdErrWriter, line);
+                       }
+               };
+
+               PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(stdout,
+                               stderr, stdInStream) {
+
+                       @Override
+                       public void stop() throws IOException {
+                               // prevents the method to block when joining stdin
+                               if (stdInSink != null)
+                                       IOUtils.closeQuietly(stdInSink);
+
+                               super.stop();
+                       }
+               };
+               return pumpStreamHandler;
+       }
+
+       /** Creates the default {@link ExecuteResultHandler}. */
+       protected ExecuteResultHandler createExecuteResultHandler(
+                       final CommandLine commandLine) {
+               return new ExecuteResultHandler() {
+
+                       public void onProcessComplete(int exitValue) {
+                               String msg = "System call '" + commandLine
+                                               + "' properly completed.";
+                               if (log.isTraceEnabled())
+                                       log.trace(msg);
+                               if (testResult != null) {
+                                       forwardPath(testResult);
+                                       testResult.addResultPart(new SimpleResultPart(
+                                                       TestStatus.PASSED, msg));
+                               }
+                               releaseWatchdog();
+                       }
+
+                       public void onProcessFailed(ExecuteException e) {
+
+                               String msg = "System call '" + commandLine + "' failed.";
+                               if (testResult != null) {
+                                       forwardPath(testResult);
+                                       testResult.addResultPart(new SimpleResultPart(
+                                                       TestStatus.ERROR, msg, e));
+                               } else {
+                                       if (exceptionOnFailed)
+                                               throw new SlcException(msg, e);
+                                       else
+                                               log.error(msg, e);
+                               }
+                               releaseWatchdog();
+                       }
+               };
+       }
+
+       @Deprecated
+       protected void forwardPath(TestResult testResult) {
+               // TODO: allocate a TreeSPath
+       }
+
+       /**
+        * Shortcut method getting the execDir to use
+        */
+       protected String getExecDirToUse() {
+               try {
+                       if (execDir != null) {
+                               return execDir;
+                       }
+                       return System.getProperty("user.dir");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot find exec dir", e);
+               }
+       }
+
+       protected void logStdOut(String line) {
+               for (SystemCallOutputListener outputListener : outputListeners)
+                       outputListener.newLine(this, line, false);
+               log(stdOutLogLevel, line);
+       }
+
+       protected void logStdErr(String line) {
+               for (SystemCallOutputListener outputListener : outputListeners)
+                       outputListener.newLine(this, line, true);
+               log(stdErrLogLevel, line);
+       }
+
+       /** Log from the underlying streams. */
+       protected void log(String logLevel, String line) {
+               // TODO optimize
+//             if (SecurityContextHolder.getContext().getAuthentication() == null) {
+//                     SecurityContextHolder.getContext()
+//                                     .setAuthentication(authentication);
+//             }
+
+               if ("ERROR".equals(logLevel))
+                       log.error(line);
+               else if ("WARN".equals(logLevel))
+                       log.warn(line);
+               else if ("INFO".equals(logLevel))
+                       log.info(line);
+               else if ("DEBUG".equals(logLevel))
+                       log.debug(line);
+               else if ("TRACE".equals(logLevel))
+                       log.trace(line);
+               else if (LOG_STDOUT.equals(logLevel))
+                       System.out.println(line);
+               else if ("System.err".equals(logLevel))
+                       System.err.println(line);
+               else
+                       throw new SlcException("Unknown log level " + logLevel);
+       }
+
+       /** Append line to a log file. */
+       protected void appendLineToFile(Writer writer, String line) {
+               try {
+                       writer.append(line).append('\n');
+               } catch (IOException e) {
+                       log.error("Cannot write to log file", e);
+               }
+       }
+
+       /** Creates the writer for the output/err files. */
+       protected Writer createWriter(Resource target, Boolean append) {
+               FileWriter writer = null;
+               try {
+
+                       final File file;
+                       if (executionResources != null)
+                               file = new File(executionResources.getAsOsPath(target, true));
+                       else
+                               file = target.getFile();
+                       writer = new FileWriter(file, append);
+               } catch (IOException e) {
+                       log.error("Cannot get file for " + target, e);
+                       IOUtils.closeQuietly(writer);
+               }
+               return writer;
+       }
+
+       /** Creates an outputstream for the output/err files. */
+       protected OutputStream createOutputStream(Resource target) {
+               FileOutputStream out = null;
+               try {
+
+                       final File file;
+                       if (executionResources != null)
+                               file = new File(executionResources.getAsOsPath(target, true));
+                       else
+                               file = target.getFile();
+                       out = new FileOutputStream(file, false);
+               } catch (IOException e) {
+                       log.error("Cannot get file for " + target, e);
+                       IOUtils.closeQuietly(out);
+               }
+               return out;
+       }
+
+       /** Append the argument (for chaining) */
+       public SystemCall arg(String arg) {
+               if (command == null)
+                       command = new ArrayList<Object>();
+               command.add(arg);
+               return this;
+       }
+
+       /** Append the argument (for chaining) */
+       public SystemCall arg(String arg, String value) {
+               if (command == null)
+                       command = new ArrayList<Object>();
+               command.add(arg);
+               command.add(value);
+               return this;
+       }
+
+       // CONTROL
+       public synchronized Boolean isRunning() {
+               return currentWatchdog != null;
+       }
+
+       private synchronized ExecuteWatchdog createWatchdog() {
+//             if (currentWatchdog != null)
+//                     throw new SlcException("A process is already being monitored");
+               currentWatchdog = new ExecuteWatchdog(watchdogTimeout);
+               return currentWatchdog;
+       }
+
+       private synchronized void releaseWatchdog() {
+               currentWatchdog = null;
+       }
+
+       public synchronized void kill() {
+               if (currentWatchdog != null)
+                       currentWatchdog.destroyProcess();
+       }
+
+       /** */
+       public void setCmd(String command) {
+               this.cmd = command;
+       }
+
+       public void setCommand(List<Object> command) {
+               this.command = command;
+       }
+
+       public void setExecDir(String execdir) {
+               this.execDir = execdir;
+       }
+
+       public void setStdErrLogLevel(String stdErrLogLevel) {
+               this.stdErrLogLevel = stdErrLogLevel;
+       }
+
+       public void setStdOutLogLevel(String stdOutLogLevel) {
+               this.stdOutLogLevel = stdOutLogLevel;
+       }
+
+       public void setSynchronous(Boolean synchronous) {
+               this.synchronous = synchronous;
+       }
+
+       public void setOsCommands(Map<String, List<Object>> osCommands) {
+               this.osCommands = osCommands;
+       }
+
+       public void setOsCmds(Map<String, String> osCmds) {
+               this.osCmds = osCmds;
+       }
+
+       public void setEnvironmentVariables(Map<String, String> environmentVariables) {
+               this.environmentVariables = environmentVariables;
+       }
+
+       public Map<String, String> getEnvironmentVariables() {
+               return environmentVariables;
+       }
+
+       public void setWatchdogTimeout(Long watchdogTimeout) {
+               this.watchdogTimeout = watchdogTimeout;
+       }
+
+       public void setStdOutFile(Resource stdOutFile) {
+               this.stdOutFile = stdOutFile;
+       }
+
+       public void setStdErrFile(Resource stdErrFile) {
+               this.stdErrFile = stdErrFile;
+       }
+
+       public void setStdInFile(Resource stdInFile) {
+               this.stdInFile = stdInFile;
+       }
+
+       public void setTestResult(TestResult testResult) {
+               this.testResult = testResult;
+       }
+
+       public void setLogCommand(Boolean logCommand) {
+               this.logCommand = logCommand;
+       }
+
+       public void setRedirectStreams(Boolean redirectStreams) {
+               this.redirectStreams = redirectStreams;
+       }
+
+       public void setExceptionOnFailed(Boolean exceptionOnFailed) {
+               this.exceptionOnFailed = exceptionOnFailed;
+       }
+
+       public void setMergeEnvironmentVariables(Boolean mergeEnvironmentVariables) {
+               this.mergeEnvironmentVariables = mergeEnvironmentVariables;
+       }
+
+       public void setOsConsole(String osConsole) {
+               this.osConsole = osConsole;
+       }
+
+       public void setGenerateScript(String generateScript) {
+               this.generateScript = generateScript;
+       }
+
+       public void setExecutionResources(ExecutionResources executionResources) {
+               this.executionResources = executionResources;
+       }
+
+       public void setRedirectStdOut(Boolean redirectStdOut) {
+               this.redirectStdOut = redirectStdOut;
+       }
+
+       public void addOutputListener(SystemCallOutputListener outputListener) {
+               outputListeners.add(outputListener);
+       }
+
+       public void removeOutputListener(SystemCallOutputListener outputListener) {
+               outputListeners.remove(outputListener);
+       }
+
+       public void setOutputListeners(
+                       List<SystemCallOutputListener> outputListeners) {
+               this.outputListeners = outputListeners;
+       }
+
+       public void setExecutor(Executor executor) {
+               this.executor = executor;
+       }
+
+       public void setSudo(String sudo) {
+               this.sudo = sudo;
+       }
+
+       public void setCallbackHandler(CallbackHandler callbackHandler) {
+               this.callbackHandler = callbackHandler;
+       }
+
+       public void setChroot(String chroot) {
+               this.chroot = chroot;
+       }
+
+       private class DummyexecuteStreamHandler implements ExecuteStreamHandler {
+
+               public void setProcessErrorStream(InputStream is) throws IOException {
+               }
+
+               public void setProcessInputStream(OutputStream os) throws IOException {
+               }
+
+               public void setProcessOutputStream(InputStream is) throws IOException {
+               }
+
+               public void start() throws IOException {
+               }
+
+               public void stop() {
+               }
+
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCallOutputListener.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/SystemCallOutputListener.java
new file mode 100644 (file)
index 0000000..7972cdc
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.core.execution.tasks;
+
+public interface SystemCallOutputListener {
+       public void newLine(SystemCall systemCall, String line, Boolean isError);
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/UploadAttachments.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/UploadAttachments.java
new file mode 100644 (file)
index 0000000..83f2ee8
--- /dev/null
@@ -0,0 +1,70 @@
+package org.argeo.slc.core.execution.tasks;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.attachment.Attachment;
+import org.argeo.slc.attachment.AttachmentsEnabled;
+import org.argeo.slc.core.attachment.AttachmentUploader;
+import org.springframework.core.io.Resource;
+
+public class UploadAttachments implements Runnable {
+       private AttachmentUploader attachmentUploader;
+       private Attachment attachment = null;
+       private Resource resource = null;
+       private Map<Attachment, Resource> attachments = new HashMap<Attachment, Resource>();
+       private List<AttachmentsEnabled> attachTo = new ArrayList<AttachmentsEnabled>();
+       private Boolean newUuidPerExecution = true;
+
+       public void run() {
+               if (attachment != null) {
+                       if (resource == null)
+                               throw new SlcException("A resource must be specified.");
+                       uploadAndAdd(attachment, resource);
+               }
+
+               for (Attachment attachmentT : attachments.keySet()) {
+                       Resource resourceT = attachments.get(attachmentT);
+                       uploadAndAdd(attachmentT, resourceT);
+               }
+
+       }
+
+       protected void uploadAndAdd(Attachment attachment, Resource resource) {
+               if (newUuidPerExecution)
+                       attachment.setUuid(UUID.randomUUID().toString());
+               attachmentUploader.upload(attachment, resource);
+               for (AttachmentsEnabled attachmentsEnabled : attachTo) {
+                       attachmentsEnabled.addAttachment(attachment);
+               }
+       }
+
+       public void setAttachmentUploader(AttachmentUploader attachmentUploader) {
+               this.attachmentUploader = attachmentUploader;
+       }
+
+       public void setAttachments(Map<Attachment, Resource> attachments) {
+               this.attachments = attachments;
+       }
+
+       public void setAttachTo(List<AttachmentsEnabled> attachTo) {
+               this.attachTo = attachTo;
+       }
+
+       public void setAttachment(Attachment attachment) {
+               this.attachment = attachment;
+       }
+
+       public void setResource(Resource resource) {
+               this.resource = resource;
+       }
+
+       public void setNewUuidPerExecution(Boolean newUuidPerExecution) {
+               this.newUuidPerExecution = newUuidPerExecution;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/core.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/tasks/core.xml
new file mode 100644 (file)
index 0000000..df35944
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2007-2012 Argeo GmbH
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+            http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <bean id="task.echo" class="org.argeo.slc.core.execution.tasks.Echo"
+               abstract="true" />
+       <bean id="task.systemCall" class="org.argeo.slc.core.execution.tasks.SystemCall"
+               abstract="true" />
+       <bean id="task.closeTestResult" class="org.argeo.slc.core.execution.tasks.CloseTestResult"
+               abstract="true" />
+       <bean id="task.slcManager" class="org.argeo.slc.core.execution.tasks.SlcManager"
+               abstract="true" />
+       <bean id="task.overrideContextAware" class="org.argeo.slc.core.execution.tasks.OverrideContextAware"
+               abstract="true" />
+       <bean id="task.uploadAttachments" class="org.argeo.slc.core.execution.tasks.UploadAttachments"
+               abstract="true" />
+
+       <bean id="taskArg.attachment" class="org.argeo.slc.core.attachment.SimpleAttachment"
+               abstract="true" />
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/templates.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/templates.xml
new file mode 100644 (file)
index 0000000..28b742a
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2007-2012 Argeo GmbH
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+            http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <bean id="slcTemplate.fileResources" class="org.argeo.slc.core.execution.FileExecutionResources"
+               abstract="true" />
+
+       <bean id="slcTemplate.resourcesFactoryBean" parent="slcTemplate.writableResource"
+               abstract="true" />
+
+       <bean id="slcTemplate.writableResource"
+               class="org.argeo.slc.core.execution.ExecutionResourcesFactoryBean"
+               abstract="true" />
+
+       <bean id="slcTemplate.osFile" class="org.argeo.slc.core.execution.OsFileFactoryBean"
+               abstract="true" />
+
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/utils.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/utils.xml
new file mode 100644 (file)
index 0000000..527e701
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2007-2012 Argeo GmbH
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+            http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+       <bean id="mergedLists" class="org.argeo.slc.core.execution.tasks.MergedLists"
+               abstract="true">
+       </bean>
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/AsFlowDecorator.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/AsFlowDecorator.java
new file mode 100644 (file)
index 0000000..b68d9c7
--- /dev/null
@@ -0,0 +1,56 @@
+package org.argeo.slc.core.execution.xml;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.DefaultExecutionFlow;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.springframework.beans.BeanMetadataElement;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
+
+/** Publishes a {@link Runnable} as an {@link ExecutionFlow} */
+public class AsFlowDecorator implements BeanDefinitionDecorator {
+       private Log log = LogFactory.getLog(AsFlowDecorator.class);
+
+       public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder bean,
+                       ParserContext ctx) {
+               String attrValue = ((Attr) node).getValue();
+               if (attrValue.charAt(attrValue.length() - 1) == '/')
+                       throw new SlcException(attrValue + " cannot end with a path");
+               final String flowBeanName = attrValue;
+
+               if (log.isTraceEnabled())
+                       log.trace("flowBeanName=" + flowBeanName);
+
+               if (ctx.getRegistry().containsBeanDefinition(flowBeanName))
+                       throw new SlcException("A bean named " + flowBeanName
+                                       + " is already defined.");
+               BeanDefinitionBuilder flow = BeanDefinitionBuilder
+                               .rootBeanDefinition(DefaultExecutionFlow.class);
+               ManagedList<BeanMetadataElement> executables = new ManagedList<BeanMetadataElement>(
+                               1);
+
+               String beanName = bean.getBeanName();
+               if (beanName == null)
+                       executables.add(bean.getBeanDefinition());
+               else
+                       executables.add(new RuntimeBeanReference(beanName));
+
+               // if (path != null)
+               // flow.addPropertyValue("path", path);
+               flow.addPropertyValue("executables", executables);
+
+               if (beanName != null)
+                       ctx.getRegistry().registerBeanDefinition(flowBeanName,
+                                       flow.getBeanDefinition());
+               return bean;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ExecutionScopeDecorator.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ExecutionScopeDecorator.java
new file mode 100644 (file)
index 0000000..b756381
--- /dev/null
@@ -0,0 +1,37 @@
+package org.argeo.slc.core.execution.xml;
+
+import org.springframework.aop.scope.ScopedProxyUtils;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.parsing.BeanComponentDefinition;
+import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Inspired by org.springframework.aop.config.ScopedProxyBeanDefinitionDecorator
+ */
+public class ExecutionScopeDecorator implements BeanDefinitionDecorator {      
+       private static final String PROXY_TARGET_CLASS = "proxy-target-class";  
+       
+       public BeanDefinitionHolder decorate(Node node,
+                       BeanDefinitionHolder definition, ParserContext parserContext) {
+               
+               definition.getBeanDefinition().setScope("execution");
+               
+               // Default: CGLib not used
+               boolean proxyTargetClass = false;
+               if (node instanceof Element) {
+                       Element ele = (Element) node;
+                       if (ele.hasAttribute(PROXY_TARGET_CLASS)) {
+                               proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS)).booleanValue();
+                       }
+               }
+               
+               // Register the original bean definition as it will be referenced by the scoped proxy and is relevant for tooling (validation, navigation).
+               String targetBeanName = ScopedProxyUtils.getTargetBeanName(definition.getBeanName());
+               parserContext.getReaderContext().fireComponentRegistered(new BeanComponentDefinition(definition.getBeanDefinition(), targetBeanName));
+               
+               return ScopedProxyUtils.createScopedProxy(definition, parserContext.getRegistry(), proxyTargetClass);           
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java
new file mode 100644 (file)
index 0000000..60e8699
--- /dev/null
@@ -0,0 +1,167 @@
+package org.argeo.slc.core.execution.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.DefaultExecutionFlow;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.support.ManagedMap;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/** Interprets the <flow:flow> tag */
+public class FlowBeanDefinitionParser extends
+               AbstractSingleBeanDefinitionParser {
+       private Log log = LogFactory.getLog(FlowBeanDefinitionParser.class);
+
+       /** Whether the user has already be warned on path attribute usage. */
+       private Boolean warnedAboutPathAttribute = false;
+
+       @Override
+       protected void doParse(Element element, ParserContext parserContext,
+                       BeanDefinitionBuilder builder) {
+               String path = element.getAttribute("path");
+               if (StringUtils.hasText(path)) {
+                       builder.addPropertyValue("path", path);
+
+                       // warns user only once
+                       if (!warnedAboutPathAttribute)
+                               log.warn("The path=\"\" attribute is deprecated"
+                                               + " and will be removed in a later release."
+                                               + " Use <flow:flow name=\"/my/path/flowName\">.");
+                       warnedAboutPathAttribute = true;
+               }
+
+               String spec = element.getAttribute("spec");
+               if (StringUtils.hasText(spec))
+                       builder.getBeanDefinition().getConstructorArgumentValues()
+                                       .addGenericArgumentValue(new RuntimeBeanReference(spec));
+
+               String abstrac = element.getAttribute("abstract");
+               if (StringUtils.hasText(abstrac))
+                       builder.setAbstract(Boolean.parseBoolean(abstrac));
+
+               String parent = element.getAttribute("parent");
+               if (StringUtils.hasText(parent))
+                       builder.setParentName(parent);
+
+               builder.getBeanDefinition().setDescription(
+                               DomUtils.getChildElementValueByTagName(element, "description"));
+
+               List<Element> argsElems = new ArrayList<Element>();
+               List<Element> execElems = new ArrayList<Element>();
+               List<Element> specElems = new ArrayList<Element>();
+               NodeList nodeList = element.getChildNodes();
+               for (int i = 0; i < nodeList.getLength(); i++) {
+                       Node node = nodeList.item(i);
+                       if (node instanceof Element) {
+                               if (DomUtils.nodeNameEquals(node, "arg"))
+                                       argsElems.add((Element) node);
+                               else if (DomUtils.nodeNameEquals(node, "spec"))
+                                       specElems.add((Element) node);
+                               else if (!DomUtils.nodeNameEquals(node, "description"))
+                                       execElems.add((Element) node);
+                       }
+               }
+
+               // Arguments
+               if (argsElems.size() != 0) {
+                       ManagedMap<String, Object> args = new ManagedMap<String, Object>(
+                                       argsElems.size());
+                       for (Element argElem : argsElems) {
+                               Object value = NamespaceUtils.parseValue(argElem,
+                                               parserContext, builder.getBeanDefinition(), null);
+                               if (value != null)
+                                       args.put(argElem.getAttribute("name"), value);
+                               else
+                                       throw new SlcException("No value defined.");
+                       }
+                       builder.getBeanDefinition().getConstructorArgumentValues()
+                                       .addGenericArgumentValue(args);
+               }
+
+               // Execution specs
+               if (StringUtils.hasText(spec) && specElems.size() != 0)
+                       throw new SlcException("A flow cannot have multiple specs");
+               if (specElems.size() == 1) {
+                       Object specObj = NamespaceUtils.parseBeanOrReference(
+                                       specElems.get(0), parserContext,
+                                       builder.getBeanDefinition());
+                       builder.getBeanDefinition().getConstructorArgumentValues()
+                                       .addGenericArgumentValue(specObj);
+               } else if (specElems.size() > 1)
+                       throw new SlcException("A flow cannot have multiple specs");
+
+               // Executables
+               if (execElems.size() != 0) {
+                       ManagedList<Object> executables = new ManagedList<Object>(
+                                       execElems.size());
+                       for (Element child : execElems) {
+                               // child validity check is performed in xsd
+                               executables.add(NamespaceUtils.parseBeanOrReference(child,
+                                               parserContext, builder.getBeanDefinition()));
+                       }
+                       if (executables.size() > 0)
+                               builder.addPropertyValue("executables", executables);
+               }
+       }
+
+       @SuppressWarnings("unchecked")
+       @Override
+       protected Class<? extends ExecutionFlow> getBeanClass(Element element) {
+               String clss = element.getAttribute("class");
+               if (StringUtils.hasText(clss))
+                       // TODO: check that it actually works
+                       try {
+                               return (Class<? extends ExecutionFlow>) getClass()
+                                               .getClassLoader().loadClass(clss);
+                       } catch (ClassNotFoundException e) {
+                               try {
+                                       return (Class<? extends ExecutionFlow>) Thread
+                                                       .currentThread().getContextClassLoader()
+                                                       .loadClass(clss);
+                               } catch (ClassNotFoundException e1) {
+                                       throw new SlcException("Cannot load class " + clss, e);
+                               }
+                       }
+               else
+                       return DefaultExecutionFlow.class;
+       }
+
+       // parse nested bean definition
+       // private Object parseBeanReference(Element element,
+       // ParserContext parserContext, BeanDefinitionBuilder builder) {
+       // return parserContext.getDelegate().parsePropertySubElement(element,
+       // builder.getBeanDefinition());
+       // }
+
+       @Override
+       protected String resolveId(Element element,
+                       AbstractBeanDefinition definition, ParserContext parserContext)
+                       throws BeanDefinitionStoreException {
+               String name = element.getAttribute("name");
+               if (StringUtils.hasText(name)) {
+                       return name;
+               } else {
+                       return super.resolveId(element, definition, parserContext);
+               }
+       }
+
+       protected boolean shouldGenerateIdAsFallback() {
+               return true;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowNamespaceHandler.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/FlowNamespaceHandler.java
new file mode 100644 (file)
index 0000000..a1d6912
--- /dev/null
@@ -0,0 +1,26 @@
+package org.argeo.slc.core.execution.xml;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+public class FlowNamespaceHandler extends NamespaceHandlerSupport {
+
+       public void init() {
+               registerBeanDefinitionParser("flow", new FlowBeanDefinitionParser());
+               registerBeanDefinitionParser("spec", new SpecBeanDefinitionParser());
+               registerBeanDefinitionDecoratorForAttribute("as-flow",
+                               new AsFlowDecorator());
+               registerBeanDefinitionParser("param", new ParamDecorator());
+                
+               // The objective was to replace
+               // - attribute scope="execution"
+               // - and element "aop:scoped-proxy" 
+               // by a single attribute, using an attribute decorator 
+               // this does not work correctly with other attribute decorators (e.g. 
+               // p namespace) since this decorator needs to be called after all
+               // properties have been set on target bean. 
+               // It works properly with element decorators (called after all attribute
+               // decorators
+               registerBeanDefinitionDecorator("variable", new ExecutionScopeDecorator());
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/NamespaceUtils.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/NamespaceUtils.java
new file mode 100644 (file)
index 0000000..baa0152
--- /dev/null
@@ -0,0 +1,92 @@
+package org.argeo.slc.core.execution.xml;
+
+import org.argeo.slc.SlcException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Utilities to simplify common tasks when interpreting a custom namespace and
+ * converting it into bean definitions.
+ */
+public class NamespaceUtils {
+       // private final static Log log = LogFactory.getLog(NamespaceUtils.class);
+
+       /**
+        * Returns the value defined either: directly by the the 'value' attribute,
+        * as reference by the 'ref' attribute or as a nested bean.
+        */
+       public static Object parseValue(Element element,
+                       ParserContext parserContext,
+                       BeanDefinition containingBeanDefintion, String valueTagName) {
+               Object value = null;
+               if (element.hasAttribute("value")) {
+                       value = element.getAttribute("value");
+               }
+
+               if (element.hasAttribute("ref")) {
+                       if (value != null)
+                               throw new SlcException("Multiple value definition for "
+                                               + element);
+                       value = new RuntimeBeanReference(element.getAttribute("ref"));
+               }
+
+               Element uniqueSubElem = null;
+               if (valueTagName != null) {
+                       Element valueElem = DomUtils.getChildElementByTagName(element,
+                                       valueTagName);
+                       if (valueElem != null) {
+                               uniqueSubElem = findUniqueSubElement(valueElem);
+                               if (uniqueSubElem == null)
+                                       throw new SlcException("No subelement found under "
+                                                       + valueElem);
+                       }
+               } else {// no intermediary tag
+                       uniqueSubElem = findUniqueSubElement(element);
+               }
+
+               if (uniqueSubElem != null) {
+                       if (value != null)
+                               throw new SlcException("Multiple value definition for "
+                                               + element);
+                       value = parseBeanOrReference(uniqueSubElem, parserContext,
+                                       containingBeanDefintion);
+               }
+               return value;
+       }
+
+       public static Element findUniqueSubElement(Element element) {
+               NodeList childNodes = element.getChildNodes();
+
+               Element uniqueSubElem = null;
+               for (int i = 0; i < childNodes.getLength(); i++) {
+                       Node node = childNodes.item(i);
+                       if (node != null && node instanceof Element) {
+                               if (uniqueSubElem == null)
+                                       uniqueSubElem = (Element) node;
+                               else
+                                       throw new SlcException(
+                                                       "There are more than one sub element under "
+                                                                       + element);
+                       }
+               }
+               return uniqueSubElem;
+       }
+
+       public static Object parseBeanOrReference(Element element,
+                       ParserContext parserContext, BeanDefinition beanDefinition) {
+               // return parserContext.getDelegate().parsePropertySubElement(element,
+               // beanDefinition);
+
+               BeanDefinitionParserDelegate deleg = parserContext.getDelegate();
+               // if ("bean".equals(element.getNodeName()))
+               // return deleg.parseBeanDefinitionElement(element, beanDefinition);
+               // else
+               return deleg.parsePropertySubElement(element, beanDefinition);
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ParamDecorator.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/ParamDecorator.java
new file mode 100644 (file)
index 0000000..ed7a223
--- /dev/null
@@ -0,0 +1,46 @@
+package org.argeo.slc.core.execution.xml;
+
+import org.argeo.slc.core.execution.ParameterRef;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.w3c.dom.Element;
+
+public class ParamDecorator extends AbstractSingleBeanDefinitionParser {
+
+       // public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder
+       // bean,
+       // ParserContext ctx) {
+       // String paramName = ((Element) node).getAttribute("name");
+       // String propertyName = ((Element) node.getParentNode())
+       // .getAttribute("name");
+       // BeanDefinitionBuilder parameterRef = BeanDefinitionBuilder
+       // .genericBeanDefinition(ParameterRef.class);
+       // parameterRef.addPropertyReference("instantiationManager",
+       // "instantiationManager");
+       // parameterRef.addConstructorArgValue(paramName);
+       // bean.getBeanDefinition().getPropertyValues().addPropertyValue(
+       // propertyName, parameterRef.getBeanDefinition());
+       // return bean;
+       // }
+
+       @Override
+       protected void doParse(Element element, ParserContext parserContext,
+                       BeanDefinitionBuilder builder) {
+               String paramName = element.getAttribute("name");
+
+               String instantationManagerRef = element
+                               .getAttribute("instantiationManager");
+               if (!StringUtils.hasText(instantationManagerRef))
+                       instantationManagerRef = "instantiationManager";
+               builder.addPropertyReference("instantiationManager",
+                               instantationManagerRef);
+               builder.addConstructorArgValue(paramName);
+       }
+
+       @Override
+       protected Class<ParameterRef> getBeanClass(Element element) {
+               return ParameterRef.class;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java
new file mode 100644 (file)
index 0000000..937e8d0
--- /dev/null
@@ -0,0 +1,131 @@
+package org.argeo.slc.core.execution.xml;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.core.execution.DefaultExecutionSpec;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValueChoice;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.support.ManagedMap;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+/** Interprets the <flow:spec> tag */
+public class SpecBeanDefinitionParser extends
+               AbstractSingleBeanDefinitionParser {
+       private Log log = LogFactory.getLog(SpecBeanDefinitionParser.class);
+
+       @Override
+       protected void doParse(Element element, ParserContext parserContext,
+                       BeanDefinitionBuilder builder) {
+               builder.getBeanDefinition().setDescription(
+                               DomUtils.getChildElementValueByTagName(element, "description"));
+
+               ManagedMap<String, BeanDefinition> attributes = new ManagedMap<String, BeanDefinition>();
+
+               // Primitives
+               for (Element child : (List<Element>) DomUtils
+                               .getChildElementsByTagName(element, "primitive")) {
+                       BeanDefinitionBuilder childBuilder = BeanDefinitionBuilder
+                                       .genericBeanDefinition(PrimitiveSpecAttribute.class);
+                       addCommonProperties(child, parserContext, childBuilder);
+
+                       String type = child.getAttribute("type");
+                       if (StringUtils.hasText(type))
+                               childBuilder.addPropertyValue("type", type);
+
+                       putInAttributes(attributes, child,
+                                       childBuilder.getBeanDefinition(), "primitive");
+               }
+
+               // Refs
+               for (Element refAttrElem : (List<Element>) DomUtils
+                               .getChildElementsByTagName(element, "ref")) {
+                       BeanDefinitionBuilder refAttrBuilder = BeanDefinitionBuilder
+                                       .genericBeanDefinition(RefSpecAttribute.class);
+                       addCommonProperties(refAttrElem, parserContext, refAttrBuilder);
+
+                       String targetClassName = refAttrElem.getAttribute("targetClass");
+                       if (StringUtils.hasText(targetClassName))
+                               refAttrBuilder.addPropertyValue("targetClass", targetClassName);
+
+                       // Choices
+                       Element choicesElem = DomUtils.getChildElementByTagName(
+                                       refAttrElem, "choices");
+                       if (choicesElem != null) {
+                               List<Element> choices = DomUtils.getChildElementsByTagName(
+                                               choicesElem, "choice");
+                               ManagedList<BeanDefinition> choiceBeans = new ManagedList<BeanDefinition>(
+                                               choices.size());
+                               for (Element choiceElem : choices) {
+                                       BeanDefinitionBuilder choiceBuilder = BeanDefinitionBuilder
+                                                       .genericBeanDefinition(RefValueChoice.class);
+                                       choiceBuilder.addPropertyValue("name",
+                                                       choiceElem.getAttribute("name"));
+                                       String desc = choiceElem.getAttribute("description");
+                                       if (StringUtils.hasText(desc))
+                                               choiceBuilder.addPropertyValue("description", desc);
+
+                                       choiceBeans.add(choiceBuilder.getBeanDefinition());
+                               }
+                               refAttrBuilder.addPropertyValue("choices", choiceBeans);
+                       }
+
+                       putInAttributes(attributes, refAttrElem,
+                                       refAttrBuilder.getBeanDefinition(), "ref");
+               }
+
+               builder.addPropertyValue("attributes", attributes);
+       }
+
+       protected void addCommonProperties(Element element,
+                       ParserContext parserContext, BeanDefinitionBuilder specAttr) {
+               addBooleanProperty("isImmutable", specAttr, element);
+               addBooleanProperty("isConstant", specAttr, element);
+               addBooleanProperty("isHidden", specAttr, element);
+               addBooleanProperty("isParameter", specAttr, element);
+               addBooleanProperty("isFrozen", specAttr, element);
+
+               Object value = NamespaceUtils.parseValue(element, parserContext,
+                               specAttr.getBeanDefinition(), "value");
+               if (value != null)
+                       specAttr.addPropertyValue("value", value);
+
+       }
+
+       protected void putInAttributes(
+                       ManagedMap<String, BeanDefinition> attributes, Element child,
+                       BeanDefinition beanDefinition, String nature) {
+               String name = child.getAttribute("name");
+               attributes.put(name, beanDefinition);
+               if (log.isTraceEnabled())
+                       log.debug("Added " + nature + " attribute " + name);
+
+       }
+
+       private void addBooleanProperty(String name,
+                       BeanDefinitionBuilder specAttr, Element element) {
+               String bool = element.getAttribute(name);
+               if (StringUtils.hasText(bool))
+                       specAttr.addPropertyValue(name, Boolean.parseBoolean(bool));
+
+       }
+
+       @Override
+       protected Class<DefaultExecutionSpec> getBeanClass(Element element) {
+               return DefaultExecutionSpec.class;
+       }
+
+       protected boolean shouldGenerateIdAsFallback() {
+               return false;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd
new file mode 100644 (file)
index 0000000..8b31a60
--- /dev/null
@@ -0,0 +1,384 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+       xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns:beans="http://www.springframework.org/schema/beans"
+       targetNamespace="http://www.argeo.org/schema/slc-flow"
+       elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+       <xsd:import namespace="http://www.springframework.org/schema/beans"
+               schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" />
+
+       <xsd:annotation>
+               <xsd:documentation><![CDATA[
+       SLC Flow Schema, version 0.12
+       Authors: Mathieu Baudier
+       
+       This simplifies the definition of SLC flows and their integration with 
+       regular Spring beans.
+               ]]></xsd:documentation>
+       </xsd:annotation>
+
+       <xsd:element name="flow">
+               <xsd:annotation>
+                       <xsd:documentation><![CDATA[
+       Adds an SLC execution flow, using the default implementation.
+                       ]]></xsd:documentation>
+               </xsd:annotation>
+               <xsd:complexType>
+                       <xsd:complexContent>
+                               <xsd:extension base="beans:identifiedType">
+                                       <xsd:sequence>
+                                               <xsd:element ref="beans:description" minOccurs="0" />
+                                               <xsd:sequence>
+                                                       <xsd:element name="arg" minOccurs="0" maxOccurs="unbounded"
+                                                               type="flow:argType">
+                                                               <xsd:annotation>
+                                                                       <xsd:documentation><![CDATA[
+       Parameter for an execution flow which will override at instantiation the 
+       value of the parameter already defined as default value or in a parent bean.
+                                                                       ]]></xsd:documentation>
+                                                               </xsd:annotation>
+                                                       </xsd:element>
+                                               </xsd:sequence>
+                                               <xsd:sequence>
+                                                       <xsd:choice minOccurs="0" maxOccurs="unbounded">
+                                                               <xsd:element ref="beans:bean" />
+                                                               <xsd:element ref="beans:ref" />
+                                                               <xsd:element ref="flow:flow" />
+                                                       </xsd:choice>
+                                                       <!--
+                                                               <xsd:any namespace="##other" processContents="strict"
+                                                               minOccurs="0" maxOccurs="unbounded" />
+                                                       -->
+                                               </xsd:sequence>
+                                       </xsd:sequence>
+                                       <xsd:attribute name="name" type="xsd:string">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       Name of the flow (alternative to ID).
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="class" type="xsd:string">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       Another implementation of execution flow.
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="path" type="xsd:string">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       The hierarchical path under which to register this flow.
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="spec" type="xsd:string">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       A reference to the related specification bean.
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="parent" type="xsd:string">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       The parent bean definition (in Spring sense).
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="abstract" type="xsd:boolean"
+                                               default="false">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       Whether this flow is abstract (in Spring sense).
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                               </xsd:extension>
+                       </xsd:complexContent>
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:element name="spec">
+               <xsd:annotation>
+                       <xsd:documentation><![CDATA[
+       SLC flow specifications, defining the parameters and variables
+       which can be used in related flows, along with their default values and 
+       various constraints.
+                       ]]></xsd:documentation>
+               </xsd:annotation>
+               <xsd:complexType>
+                       <xsd:complexContent>
+                               <xsd:extension base="beans:identifiedType">
+                                       <xsd:sequence>
+                                               <xsd:element ref="beans:description" minOccurs="0" />
+                                               <xsd:choice minOccurs="0" maxOccurs="unbounded">
+                                                       <xsd:element name="primitive" type="flow:primitiveSpecAttributeType"
+                                                               minOccurs="0" maxOccurs="unbounded">
+                                                               <xsd:annotation>
+                                                                       <xsd:documentation><![CDATA[
+       A primitive specification attribute, that is, a plain standard value
+       and not a reference to an object.
+                                                                       ]]></xsd:documentation>
+                                                               </xsd:annotation>
+                                                       </xsd:element>
+                                                       <xsd:element name="ref" type="flow:refSpecAttributeType"
+                                                               minOccurs="0" maxOccurs="unbounded">
+                                                               <xsd:annotation>
+                                                                       <xsd:documentation><![CDATA[
+       A reference specification attribute, that is, a reference to another object.
+                                                                       ]]></xsd:documentation>
+                                                               </xsd:annotation>
+                                                       </xsd:element>
+                                               </xsd:choice>
+                                       </xsd:sequence>
+                               </xsd:extension>
+                       </xsd:complexContent>
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:complexType name="specAttributeType">
+               <xsd:choice>
+                       <xsd:element name="value" minOccurs="0" maxOccurs="1">
+                               <xsd:annotation>
+                                       <xsd:documentation><![CDATA[
+       The default value of the attribute as an inner bean.
+                                       ]]></xsd:documentation>
+                               </xsd:annotation>
+                               <xsd:complexType>
+                                       <xsd:choice minOccurs="1" maxOccurs="1">
+                                               <xsd:element ref="beans:bean" />
+                                               <xsd:element ref="beans:ref" />
+                                               <xsd:element ref="beans:list" />
+                                               <xsd:element ref="beans:set" />
+                                               <xsd:element ref="beans:map" />
+                                               <xsd:element ref="beans:props" />
+                                       </xsd:choice>
+                               </xsd:complexType>
+                       </xsd:element>
+               </xsd:choice>
+               <xsd:attribute name="name" use="required" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The name of the attribute, under which in can then be referenced.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="value" use="optional" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The default value of the attribute.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="ref" use="optional" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The default value of the attribute as a reference to another bean.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="isParameter" use="optional" type="xsd:boolean"
+                       default="false">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Whether the attribute is a parameter, that is, it has to be set at 
+       instantiation but can be modified afterwards for objects of scope execution.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="isFrozen" use="optional" type="xsd:boolean"
+                       default="false">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Whether the attribute is frozen, that is, it cannot be modified at runtime.
+       A frozen attribute has to be a parameter.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="isHidden" use="optional" type="xsd:boolean"
+                       default="false">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Whether the attribute is hidden, that is, it should not be displayed in UIs.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+       </xsd:complexType>
+
+       <xsd:complexType name="primitiveSpecAttributeType">
+               <xsd:complexContent>
+                       <xsd:extension base="flow:specAttributeType">
+                               <xsd:attribute name="type" default="string">
+                                       <xsd:annotation>
+                                               <xsd:documentation><![CDATA[
+       The type of the primitive specification attribute.
+                                               ]]></xsd:documentation>
+                                       </xsd:annotation>
+                                       <xsd:simpleType>
+                                               <xsd:restriction base="xsd:string">
+                                                       <xsd:enumeration value="string" />
+                                                       <xsd:enumeration value="integer" />
+                                                       <xsd:enumeration value="long" />
+                                                       <xsd:enumeration value="float" />
+                                                       <xsd:enumeration value="double" />
+                                                       <xsd:enumeration value="boolean" />
+                                               </xsd:restriction>
+                                       </xsd:simpleType>
+                               </xsd:attribute>
+                       </xsd:extension>
+               </xsd:complexContent>
+       </xsd:complexType>
+
+       <xsd:complexType name="refSpecAttributeType">
+               <xsd:complexContent>
+                       <xsd:extension base="flow:specAttributeType">
+                               <xsd:choice>
+                                       <xsd:element name="choices" minOccurs="0" maxOccurs="1">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       Possible values to chose from, if ommitted, all the beans in the 
+       application context which implement the provided targetClass will 
+       be considered.
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                               <xsd:complexType>
+                                                       <xsd:choice>
+                                                               <xsd:element name="choice" minOccurs="0" maxOccurs="unbounded"
+                                                                       type="flow:refChoiceType">
+                                                                       <xsd:annotation>
+                                                                               <xsd:documentation><![CDATA[
+       A choice for a reference specification attribute.
+                                                                               ]]></xsd:documentation>
+                                                                       </xsd:annotation>
+                                                               </xsd:element>
+                                                       </xsd:choice>
+                                               </xsd:complexType>
+                                       </xsd:element>
+                               </xsd:choice>
+                               <xsd:attribute name="targetClass" use="required" type="xsd:string">
+                                       <xsd:annotation>
+                                               <xsd:documentation><![CDATA[
+       The class that has to be implemented by the underlying object.
+                                       ]]></xsd:documentation>
+                                       </xsd:annotation>
+                               </xsd:attribute>
+                       </xsd:extension>
+               </xsd:complexContent>
+       </xsd:complexType>
+
+       <xsd:complexType name="refChoiceType">
+               <xsd:attribute name="name" use="required" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The name of the related bean.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="description" use="optional" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       A human readable description of this choice.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+       </xsd:complexType>
+
+       <xsd:complexType name="argType">
+               <xsd:choice minOccurs="0" maxOccurs="1">
+                       <xsd:element ref="beans:bean" />
+                       <xsd:element ref="beans:ref" />
+                       <xsd:element ref="flow:param" />
+                       <xsd:element ref="beans:list" />
+                       <xsd:element ref="beans:set" />
+                       <xsd:element ref="beans:map" />
+                       <xsd:element ref="beans:props" />
+               </xsd:choice>
+               <xsd:attribute name="name" use="required" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The name of the related parameter.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="value" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The plain value of the related parameter.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="ref" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The value of the related parameter as a reference to a bean.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+       </xsd:complexType>
+
+       <xsd:attribute name="as-flow" type="xsd:string">
+               <xsd:annotation>
+                       <xsd:documentation><![CDATA[
+       If decorating an executable bean, it will generate an implicit SLC 
+       execution flow with the provided value as name.
+                       ]]></xsd:documentation>
+               </xsd:annotation>
+       </xsd:attribute>
+       <!--
+               <xsd:attribute name="var" type="xsd:boolean"> <xsd:annotation>
+               <xsd:documentation><![CDATA[ If true, the decorated bean is set to
+               scope execution and proxied. ]]></xsd:documentation> </xsd:annotation>
+               </xsd:attribute>
+       -->
+
+       <xsd:element name="variable">
+               <xsd:complexType>
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Marks a bean definition as being variable, i.e. a scoped proxy of scope execution 
+                       ]]></xsd:documentation>
+                       </xsd:annotation>
+                       <xsd:attribute name="proxy-target-class" type="xsd:boolean"
+                               default="true">
+                               <xsd:annotation>
+                                       <xsd:documentation><![CDATA[
+                                               Are class-based (CGLIB) proxies to be created?
+                                               This is the default;
+                                               in order to switch to standard Java
+                                               interface-based proxies, turn this flag to
+                                               "false".
+                                       ]]></xsd:documentation>
+                               </xsd:annotation>
+                       </xsd:attribute>
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:element name="param">
+               <xsd:annotation>
+                       <xsd:documentation><![CDATA[
+       If within a property tag of a bean, it will set the value of this property
+        with a reference to a parameter.
+                       ]]></xsd:documentation>
+               </xsd:annotation>
+               <xsd:complexType>
+                       <xsd:attribute name="name" type="xsd:string" use="required">
+                               <xsd:annotation>
+                                       <xsd:documentation><![CDATA[
+       The name of the related parameter.
+                                       ]]></xsd:documentation>
+                               </xsd:annotation>
+                       </xsd:attribute>
+                       <xsd:attribute name="instantiationManager" type="xsd:string"
+                               use="optional" default="instantiationManager">
+                               <xsd:annotation>
+                                       <xsd:documentation><![CDATA[
+       A reference to the instantiation manager to use instead of the default one
+       (expert usage).
+                                       ]]></xsd:documentation>
+                               </xsd:annotation>
+                       </xsd:attribute>
+               </xsd:complexType>
+       </xsd:element>
+
+</xsd:schema>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd
new file mode 100644 (file)
index 0000000..a70798f
--- /dev/null
@@ -0,0 +1,402 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+       xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns:beans="http://www.springframework.org/schema/beans"
+       targetNamespace="http://www.argeo.org/schema/slc-flow"
+       elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+       <xsd:import namespace="http://www.springframework.org/schema/beans"
+               schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" />
+
+       <xsd:annotation>
+               <xsd:documentation><![CDATA[
+       SLC Flow Schema, version 1.2
+       Authors: Mathieu Baudier
+       
+       This simplifies the definition of SLC flows and their integration with 
+       regular Spring beans.
+               ]]></xsd:documentation>
+       </xsd:annotation>
+
+       <xsd:element name="flow">
+               <xsd:annotation>
+                       <xsd:documentation><![CDATA[
+       Adds an SLC execution flow, using the default implementation.
+                       ]]></xsd:documentation>
+               </xsd:annotation>
+               <xsd:complexType>
+                       <xsd:complexContent>
+                               <xsd:extension base="beans:identifiedType">
+                                       <xsd:sequence>
+                                               <xsd:element ref="beans:description" minOccurs="0" />
+                                               <xsd:sequence>
+                                                       <xsd:element name="arg" minOccurs="0" maxOccurs="unbounded"
+                                                               type="flow:argType">
+                                                               <xsd:annotation>
+                                                                       <xsd:documentation><![CDATA[
+       Parameter for an execution flow which will override at instantiation the 
+       value of the parameter already defined as default value or in a parent bean.
+                                                                       ]]></xsd:documentation>
+                                                               </xsd:annotation>
+                                                       </xsd:element>
+                                               </xsd:sequence>
+                                               <xsd:sequence>
+                                                       <xsd:choice minOccurs="0" maxOccurs="unbounded">
+                                                               <xsd:element ref="beans:bean" />
+                                                               <xsd:element ref="beans:ref" />
+                                                               <xsd:element ref="flow:flow" />
+                                                               <xsd:element ref="flow:spec" />
+                                                       </xsd:choice>
+                                                       <!-- <xsd:any namespace="##other" processContents="strict" minOccurs="0" 
+                                                               maxOccurs="unbounded" /> -->
+                                               </xsd:sequence>
+                                       </xsd:sequence>
+                                       <xsd:attribute name="name" type="xsd:string">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       Name of the flow (alternative to ID).
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="class" type="xsd:string">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       Another implementation of execution flow.
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="path" type="xsd:string">
+                                               <!-- DEPRECATED: not used anymore -->
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       The hierarchical path under which to register this flow.
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="spec" type="xsd:string">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       A reference to the related specification bean.
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="parent" type="xsd:string">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       The parent bean definition (in Spring sense).
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                                       <xsd:attribute name="abstract" type="xsd:boolean"
+                                               default="false">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       Whether this flow is abstract (in Spring sense).
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                       </xsd:attribute>
+                               </xsd:extension>
+                       </xsd:complexContent>
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:element name="spec">
+               <xsd:annotation>
+                       <xsd:documentation><![CDATA[
+       SLC flow specifications, defining the parameters and variables
+       which can be used in related flows, along with their default values and 
+       various constraints.
+                       ]]></xsd:documentation>
+               </xsd:annotation>
+               <xsd:complexType>
+                       <xsd:complexContent>
+                               <xsd:extension base="beans:identifiedType">
+                                       <xsd:sequence>
+                                               <xsd:element ref="beans:description" minOccurs="0" />
+                                               <xsd:choice minOccurs="0" maxOccurs="unbounded">
+                                                       <xsd:element name="primitive" type="flow:primitiveSpecAttributeType"
+                                                               minOccurs="0" maxOccurs="unbounded">
+                                                               <xsd:annotation>
+                                                                       <xsd:documentation><![CDATA[
+       A primitive specification attribute, that is, a plain standard value
+       and not a reference to an object.
+                                                                       ]]></xsd:documentation>
+                                                               </xsd:annotation>
+                                                       </xsd:element>
+                                                       <xsd:element name="ref" type="flow:refSpecAttributeType"
+                                                               minOccurs="0" maxOccurs="unbounded">
+                                                               <xsd:annotation>
+                                                                       <xsd:documentation><![CDATA[
+       A reference specification attribute, that is, a reference to another object.
+                                                                       ]]></xsd:documentation>
+                                                               </xsd:annotation>
+                                                       </xsd:element>
+                                               </xsd:choice>
+                                       </xsd:sequence>
+                               </xsd:extension>
+                       </xsd:complexContent>
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:complexType name="specAttributeType">
+               <xsd:choice>
+                       <xsd:element name="value" minOccurs="0" maxOccurs="1">
+                               <xsd:annotation>
+                                       <xsd:documentation><![CDATA[
+       The default value of the attribute as an inner bean.
+                                       ]]></xsd:documentation>
+                               </xsd:annotation>
+                               <xsd:complexType>
+                                       <xsd:choice minOccurs="1" maxOccurs="1">
+                                               <xsd:element ref="beans:bean" />
+                                               <xsd:element ref="beans:ref" />
+                                               <xsd:element ref="beans:list" />
+                                               <xsd:element ref="beans:set" />
+                                               <xsd:element ref="beans:map" />
+                                               <xsd:element ref="beans:props" />
+                                       </xsd:choice>
+                               </xsd:complexType>
+                       </xsd:element>
+               </xsd:choice>
+               <xsd:attribute name="name" use="required" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The name of the attribute, under which in can then be referenced.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="value" use="optional" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The default value of the attribute.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="ref" use="optional" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The default value of the attribute as a reference to another bean.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="isImmutable" use="optional" type="xsd:boolean"
+                       default="false">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Whether the attribute is a parameter, that is, it has to be set at 
+       instantiation but can be modified afterwards for objects of scope execution.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="isParameter" use="optional" type="xsd:boolean"
+                       default="false">
+                       <!-- DEPRECATED: old name of isImmutable -->
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Whether the attribute is a parameter, that is, it has to be set at 
+       instantiation but can be modified afterwards for objects of scope execution.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="isConstant" use="optional" type="xsd:boolean"
+                       default="false">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Whether the attribute is frozen, that is, it cannot be modified at runtime.
+       A frozen attribute has to be a parameter.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="isFrozen" use="optional" type="xsd:boolean"
+                       default="false">
+                       <!-- DEPRECATED: old name of isConstant -->
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Whether the attribute is frozen, that is, it cannot be modified at runtime.
+       A frozen attribute has to be a parameter.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="isHidden" use="optional" type="xsd:boolean"
+                       default="false">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Whether the attribute is hidden, that is, it should not be displayed in UIs.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+       </xsd:complexType>
+
+       <xsd:complexType name="primitiveSpecAttributeType">
+               <xsd:complexContent>
+                       <xsd:extension base="flow:specAttributeType">
+                               <xsd:attribute name="type" default="string">
+                                       <xsd:annotation>
+                                               <xsd:documentation><![CDATA[
+       The type of the primitive specification attribute.
+                                               ]]></xsd:documentation>
+                                       </xsd:annotation>
+                                       <xsd:simpleType>
+                                               <xsd:restriction base="xsd:string">
+                                                       <xsd:enumeration value="string" />
+                                                       <xsd:enumeration value="password" />
+                                                       <xsd:enumeration value="integer" />
+                                                       <xsd:enumeration value="long" />
+                                                       <xsd:enumeration value="float" />
+                                                       <xsd:enumeration value="double" />
+                                                       <xsd:enumeration value="boolean" />
+                                               </xsd:restriction>
+                                       </xsd:simpleType>
+                               </xsd:attribute>
+                       </xsd:extension>
+               </xsd:complexContent>
+       </xsd:complexType>
+
+       <xsd:complexType name="refSpecAttributeType">
+               <xsd:complexContent>
+                       <xsd:extension base="flow:specAttributeType">
+                               <xsd:choice>
+                                       <xsd:element name="choices" minOccurs="0" maxOccurs="1">
+                                               <xsd:annotation>
+                                                       <xsd:documentation><![CDATA[
+       Possible values to chose from, if ommitted, all the beans in the 
+       application context which implement the provided targetClass will 
+       be considered.
+                                                       ]]></xsd:documentation>
+                                               </xsd:annotation>
+                                               <xsd:complexType>
+                                                       <xsd:choice>
+                                                               <xsd:element name="choice" minOccurs="0" maxOccurs="unbounded"
+                                                                       type="flow:refChoiceType">
+                                                                       <xsd:annotation>
+                                                                               <xsd:documentation><![CDATA[
+       A choice for a reference specification attribute.
+                                                                               ]]></xsd:documentation>
+                                                                       </xsd:annotation>
+                                                               </xsd:element>
+                                                       </xsd:choice>
+                                               </xsd:complexType>
+                                       </xsd:element>
+                               </xsd:choice>
+                               <xsd:attribute name="targetClass" use="required" type="xsd:string">
+                                       <xsd:annotation>
+                                               <xsd:documentation><![CDATA[
+       The class that has to be implemented by the underlying object.
+                                       ]]></xsd:documentation>
+                                       </xsd:annotation>
+                               </xsd:attribute>
+                       </xsd:extension>
+               </xsd:complexContent>
+       </xsd:complexType>
+
+       <xsd:complexType name="refChoiceType">
+               <xsd:attribute name="name" use="required" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The name of the related bean.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="description" use="optional" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       A human readable description of this choice.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+       </xsd:complexType>
+
+       <xsd:complexType name="argType">
+               <xsd:choice minOccurs="0" maxOccurs="1">
+                       <xsd:element ref="beans:bean" />
+                       <xsd:element ref="beans:ref" />
+                       <xsd:element ref="flow:param" />
+                       <xsd:element ref="beans:list" />
+                       <xsd:element ref="beans:set" />
+                       <xsd:element ref="beans:map" />
+                       <xsd:element ref="beans:props" />
+               </xsd:choice>
+               <xsd:attribute name="name" use="required" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The name of the related parameter.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="value" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The plain value of the related parameter.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+               <xsd:attribute name="ref" type="xsd:string">
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       The value of the related parameter as a reference to a bean.
+                               ]]></xsd:documentation>
+                       </xsd:annotation>
+               </xsd:attribute>
+       </xsd:complexType>
+
+       <xsd:attribute name="as-flow" type="xsd:string">
+               <xsd:annotation>
+                       <xsd:documentation><![CDATA[
+       If decorating an executable bean, it will generate an implicit SLC 
+       execution flow with the provided value as name.
+                       ]]></xsd:documentation>
+               </xsd:annotation>
+       </xsd:attribute>
+       <!-- <xsd:attribute name="var" type="xsd:boolean"> <xsd:annotation> <xsd:documentation><![CDATA[ 
+               If true, the decorated bean is set to scope execution and proxied. ]]></xsd:documentation> 
+               </xsd:annotation> </xsd:attribute> -->
+
+       <xsd:element name="variable">
+               <xsd:complexType>
+                       <xsd:annotation>
+                               <xsd:documentation><![CDATA[
+       Marks a bean definition as being variable, i.e. a scoped proxy of scope execution 
+                       ]]></xsd:documentation>
+                       </xsd:annotation>
+                       <xsd:attribute name="proxy-target-class" type="xsd:boolean"
+                               default="true">
+                               <xsd:annotation>
+                                       <xsd:documentation><![CDATA[
+                                               Are class-based (CGLIB) proxies to be created?
+                                               This is the default;
+                                               in order to switch to standard Java
+                                               interface-based proxies, turn this flag to
+                                               "false".
+                                       ]]></xsd:documentation>
+                               </xsd:annotation>
+                       </xsd:attribute>
+               </xsd:complexType>
+       </xsd:element>
+
+       <xsd:element name="param">
+               <xsd:annotation>
+                       <xsd:documentation><![CDATA[
+       If within a property tag of a bean, it will set the value of this property
+        with a reference to a parameter.
+                       ]]></xsd:documentation>
+               </xsd:annotation>
+               <xsd:complexType>
+                       <xsd:attribute name="name" type="xsd:string" use="required">
+                               <xsd:annotation>
+                                       <xsd:documentation><![CDATA[
+       The name of the related parameter.
+                                       ]]></xsd:documentation>
+                               </xsd:annotation>
+                       </xsd:attribute>
+                       <xsd:attribute name="instantiationManager" type="xsd:string"
+                               use="optional" default="instantiationManager">
+                               <xsd:annotation>
+                                       <xsd:documentation><![CDATA[
+       A reference to the instantiation manager to use instead of the default one
+       (expert usage).
+                                       ]]></xsd:documentation>
+                               </xsd:annotation>
+                       </xsd:attribute>
+               </xsd:complexType>
+       </xsd:element>
+
+</xsd:schema>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/DefaultContextTestData.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/DefaultContextTestData.java
new file mode 100644 (file)
index 0000000..2701cd2
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.core.test.context;
+
+import org.argeo.slc.runtime.test.TestDataUtils;
+import org.argeo.slc.test.TestData;
+import org.argeo.slc.test.TestDataProvider;
+
+public class DefaultContextTestData extends SimpleContextAware implements
+               TestData, TestDataProvider {
+
+       public <T extends TestData> T getTestData(Class<T> clss, String key) {
+               return TestDataUtils.getItSelf(clss, this);
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleContextAware.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleContextAware.java
new file mode 100644 (file)
index 0000000..b2d8191
--- /dev/null
@@ -0,0 +1,71 @@
+package org.argeo.slc.core.test.context;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.runtime.test.ContextUtils;
+import org.argeo.slc.test.context.ContextAware;
+import org.argeo.slc.test.context.ParentContextAware;
+import org.springframework.beans.factory.InitializingBean;
+
+public class SimpleContextAware implements ContextAware, InitializingBean {
+       private ParentContextAware parentContext;
+
+       private Map<String, Object> values = new TreeMap<String, Object>();
+       private Map<String, Object> expectedValues = new TreeMap<String, Object>();
+
+       private String contextSkipFlag = DEFAULT_SKIP_FLAG;
+       private String contextAnyFlag = DEFAULT_ANY_FLAG;
+
+       public Map<String, Object> getValues() {
+               return values;
+       }
+
+       public void setValues(Map<String, Object> values) {
+               this.values = values;
+       }
+
+       public Map<String, Object> getExpectedValues() {
+               return expectedValues;
+       }
+
+       public void setExpectedValues(Map<String, Object> expectedValues) {
+               this.expectedValues = expectedValues;
+       }
+
+       /** Used to add this context as a child by setting a property. */
+       public void setParentContext(ParentContextAware parentContextAware) {
+               if (parentContext != null)
+                       throw new SlcException("Parent context already set");
+               this.parentContext = parentContextAware;
+               this.parentContext.addChildContext(this);
+       }
+
+       protected ParentContextAware getParentContext() {
+               return parentContext;
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               if (parentContext != null) {
+                       ContextUtils.synchronize(parentContext);
+               }
+       }
+
+       public String getContextSkipFlag() {
+               return contextSkipFlag;
+       }
+
+       public void setContextSkipFlag(String contextSkipFlag) {
+               this.contextSkipFlag = contextSkipFlag;
+       }
+
+       public String getContextAnyFlag() {
+               return contextAnyFlag;
+       }
+
+       public void setContextAnyFlag(String contextAnyFlag) {
+               this.contextAnyFlag = contextAnyFlag;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleParentContextAware.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/SimpleParentContextAware.java
new file mode 100644 (file)
index 0000000..3c2e7b9
--- /dev/null
@@ -0,0 +1,36 @@
+package org.argeo.slc.core.test.context;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Vector;
+
+import org.argeo.slc.runtime.test.ContextUtils;
+import org.argeo.slc.test.context.ContextAware;
+import org.argeo.slc.test.context.ParentContextAware;
+import org.springframework.beans.factory.InitializingBean;
+
+public class SimpleParentContextAware extends SimpleContextAware implements
+               ParentContextAware, InitializingBean {
+       private List<ContextAware> children = new Vector<ContextAware>();
+
+       public Collection<ContextAware> getChildContexts() {
+               return children;
+       }
+
+       public void addChildContext(ContextAware contextAware) {
+               children.add(contextAware);
+       }
+
+       @Override
+       public void afterPropertiesSet() throws Exception {
+               if (getParentContext() != null) {
+                       // If has a parent, sync it.
+                       super.afterPropertiesSet();
+               } else {
+                       if (children.size() > 0) {
+                               // No need to synchronize if no children
+                               ContextUtils.synchronize(this);
+                       }
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/package.html b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/context/package.html
new file mode 100644 (file)
index 0000000..cd08d63
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+Context variables to be passed between parts of tests.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/package.html b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/package.html
new file mode 100644 (file)
index 0000000..c70d2d1
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+SLC Test: test of software systems.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/spring.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/core/test/spring.xml
new file mode 100644 (file)
index 0000000..28fba40
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (C) 2007-2012 Argeo GmbH
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+            http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
+    default-lazy-init="true">
+
+    <bean name="slcDefault.test.testRun"
+        class="org.argeo.slc.runtime.test.SimpleTestRun"
+        scope="prototype">
+    </bean>
+
+    <bean name="slcDefault.test.uuid" class="java.util.UUID"
+        factory-method="randomUUID" scope="prototype">
+    </bean>
+
+    <bean id="slcDefault.test.basicSimpleTestResult"
+        class="org.argeo.slc.runtime.test.SimpleTestResult"
+        abstract="true">
+        <property name="uuid">
+            <bean factory-bean="slcDefault.test.uuid"
+                factory-method="toString">
+            </bean>
+        </property>
+    </bean>
+
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundleRegister.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundleRegister.java
new file mode 100644 (file)
index 0000000..b04395c
--- /dev/null
@@ -0,0 +1,13 @@
+package org.argeo.slc.osgi;
+
+/** <b>Experimental</b> A structured set of OSGi bundles. */
+public interface BundleRegister {
+       /**
+        * @param pkg
+        *            the Java package
+        * @param version
+        *            the version, can be only major.minor or null
+        * @return the bundle providing this package or null if none was found
+        */
+       public String bundleProvidingPackage(String pkg, String version);
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundlesManager.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/BundlesManager.java
new file mode 100644 (file)
index 0000000..6563d39
--- /dev/null
@@ -0,0 +1,428 @@
+package org.argeo.slc.osgi;
+
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.eclipse.gemini.blueprint.context.BundleContextAware;
+import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextEvent;
+import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextListener;
+import org.eclipse.gemini.blueprint.context.event.OsgiBundleContextClosedEvent;
+import org.eclipse.gemini.blueprint.context.event.OsgiBundleContextFailedEvent;
+import org.eclipse.gemini.blueprint.context.event.OsgiBundleContextRefreshedEvent;
+import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
+import org.eclipse.gemini.blueprint.util.OsgiFilterUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.util.tracker.ServiceTracker;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.util.Assert;
+
+/** Wraps low-level access to a {@link BundleContext} */
+@SuppressWarnings("deprecation")
+public class BundlesManager implements BundleContextAware, FrameworkListener,
+               InitializingBean, DisposableBean,
+               OsgiBundleApplicationContextListener<OsgiBundleApplicationContextEvent> {
+       private final static Log log = LogFactory.getLog(BundlesManager.class);
+
+       private BundleContext bundleContext;
+
+       private Long defaultTimeout = 60 * 1000l;
+       private Long pollingPeriod = 200l;
+
+       // Refresh sync objects
+       private final Object refreshedPackageSem = new Object();
+       private Boolean packagesRefreshed = false;
+
+       public BundlesManager() {
+       }
+
+       public BundlesManager(BundleContext bundleContext) {
+               this.bundleContext = bundleContext;
+       }
+
+       /**
+        * Stop the module, update it, refresh it and restart it. All synchronously.
+        */
+       public void upgradeSynchronous(OsgiBundle osgiBundle) {
+               try {
+                       Bundle bundle = findRelatedBundle(osgiBundle);
+
+                       long begin = System.currentTimeMillis();
+
+                       long bStop = begin;
+                       stopSynchronous(bundle);
+
+                       long bUpdate = System.currentTimeMillis();
+                       updateSynchronous(bundle);
+
+                       // Refresh in case there are fragments
+                       long bRefresh = System.currentTimeMillis();
+                       refreshSynchronous(bundle);
+
+                       long bStart = System.currentTimeMillis();
+                       startSynchronous(bundle);
+
+                       long aStart = System.currentTimeMillis();
+                       if (log.isTraceEnabled()) {
+                               log.debug("OSGi upgrade performed in " + (aStart - begin)
+                                               + "ms for bundle " + osgiBundle);
+                               log.debug(" stop \t: " + (bUpdate - bStop) + "ms");
+                               log.debug(" update\t: " + (bRefresh - bUpdate) + "ms");
+                               log.debug(" refresh\t: " + (bStart - bRefresh) + "ms");
+                               log.debug(" start\t: " + (aStart - bStart) + "ms");
+                               log.debug(" TOTAL\t: " + (aStart - begin) + "ms");
+                       }
+
+                       long bAppContext = System.currentTimeMillis();
+                       String filter = "(Bundle-SymbolicName=" + bundle.getSymbolicName()
+                                       + ")";
+                       // Wait for application context to be ready
+                       // TODO: use service tracker
+                       Collection<ServiceReference<ApplicationContext>> srs = getServiceRefSynchronous(
+                                       ApplicationContext.class, filter);
+                       ServiceReference<ApplicationContext> sr = srs.iterator().next();
+                       long aAppContext = System.currentTimeMillis();
+                       long end = aAppContext;
+
+                       if (log.isTraceEnabled()) {
+                               log.debug("Application context refresh performed in "
+                                               + (aAppContext - bAppContext) + "ms for bundle "
+                                               + osgiBundle);
+                       }
+
+                       if (log.isDebugEnabled())
+                               log.debug("Bundle '" + bundle.getSymbolicName()
+                                               + "' upgraded and ready " + " (upgrade performed in "
+                                               + (end - begin) + "ms).");
+
+                       if (log.isTraceEnabled()) {
+                               ApplicationContext applicationContext = (ApplicationContext) bundleContext
+                                               .getService(sr);
+                               int beanDefCount = applicationContext.getBeanDefinitionCount();
+                               log.debug(" " + beanDefCount + " beans in app context of "
+                                               + bundle.getSymbolicName()
+                                               + ", average init time per bean=" + (end - begin)
+                                               / beanDefCount + "ms");
+                       }
+
+                       bundleContext.ungetService(sr);
+
+               } catch (Exception e) {
+                       throw new SlcException("Cannot update bundle " + osgiBundle, e);
+               }
+       }
+
+       /** Updates bundle synchronously. */
+       protected void updateSynchronous(Bundle bundle) throws BundleException {
+               bundle.update();
+               boolean waiting = true;
+
+               long begin = System.currentTimeMillis();
+               do {
+                       int state = bundle.getState();
+                       if (state == Bundle.INSTALLED || state == Bundle.ACTIVE
+                                       || state == Bundle.RESOLVED)
+                               waiting = false;
+
+                       sleepWhenPolling();
+                       checkTimeout(begin, "Update of bundle " + bundle.getSymbolicName()
+                                       + " timed out. Bundle state = " + bundle.getState());
+               } while (waiting);
+
+               if (log.isTraceEnabled())
+                       log.debug("Bundle " + bundle.getSymbolicName() + " updated.");
+       }
+
+       /** Starts bundle synchronously. Does nothing if already started. */
+       protected void startSynchronous(Bundle bundle) throws BundleException {
+               int originalState = bundle.getState();
+               if (originalState == Bundle.ACTIVE)
+                       return;
+
+               bundle.start();
+               boolean waiting = true;
+
+               long begin = System.currentTimeMillis();
+               do {
+                       if (bundle.getState() == Bundle.ACTIVE)
+                               waiting = false;
+
+                       sleepWhenPolling();
+                       checkTimeout(begin, "Start of bundle " + bundle.getSymbolicName()
+                                       + " timed out. Bundle state = " + bundle.getState());
+               } while (waiting);
+
+               if (log.isTraceEnabled())
+                       log.debug("Bundle " + bundle.getSymbolicName() + " started.");
+       }
+
+       /** Stops bundle synchronously. Does nothing if already started. */
+       protected void stopSynchronous(Bundle bundle) throws BundleException {
+               int originalState = bundle.getState();
+               if (originalState != Bundle.ACTIVE)
+                       return;
+
+               bundle.stop();
+               boolean waiting = true;
+
+               long begin = System.currentTimeMillis();
+               do {
+                       if (bundle.getState() != Bundle.ACTIVE
+                                       && bundle.getState() != Bundle.STOPPING)
+                               waiting = false;
+
+                       sleepWhenPolling();
+                       checkTimeout(begin, "Stop of bundle " + bundle.getSymbolicName()
+                                       + " timed out. Bundle state = " + bundle.getState());
+               } while (waiting);
+
+               if (log.isTraceEnabled())
+                       log.debug("Bundle " + bundle.getSymbolicName() + " stopped.");
+       }
+
+       /** Refresh bundle synchronously. Does nothing if already started. */
+       protected void refreshSynchronous(Bundle bundle) throws BundleException {
+               ServiceReference<PackageAdmin> packageAdminRef = bundleContext
+                               .getServiceReference(PackageAdmin.class);
+               PackageAdmin packageAdmin = (PackageAdmin) bundleContext
+                               .getService(packageAdminRef);
+               Bundle[] bundles = { bundle };
+
+               long begin = System.currentTimeMillis();
+               synchronized (refreshedPackageSem) {
+                       packagesRefreshed = false;
+                       packageAdmin.refreshPackages(bundles);
+                       try {
+                               refreshedPackageSem.wait(defaultTimeout);
+                       } catch (InterruptedException e) {
+                               // silent
+                       }
+                       if (!packagesRefreshed) {
+                               long now = System.currentTimeMillis();
+                               throw new SlcException("Packages not refreshed after "
+                                               + (now - begin) + "ms");
+                       } else {
+                               packagesRefreshed = false;
+                       }
+               }
+
+               if (log.isTraceEnabled())
+                       log.debug("Bundle " + bundle.getSymbolicName() + " refreshed.");
+       }
+
+       public void frameworkEvent(FrameworkEvent event) {
+               if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
+                       synchronized (refreshedPackageSem) {
+                               packagesRefreshed = true;
+                               refreshedPackageSem.notifyAll();
+                       }
+               }
+       }
+
+       public <S> Collection<ServiceReference<S>> getServiceRefSynchronous(
+                       Class<S> clss, String filter) throws InvalidSyntaxException {
+               if (log.isTraceEnabled())
+                       log.debug("Filter: '" + filter + "'");
+               Collection<ServiceReference<S>> sfs = null;
+               boolean waiting = true;
+               long begin = System.currentTimeMillis();
+               do {
+                       sfs = bundleContext.getServiceReferences(clss, filter);
+
+                       if (sfs != null)
+                               waiting = false;
+
+                       sleepWhenPolling();
+                       checkTimeout(begin, "Search of services " + clss + " with filter "
+                                       + filter + " timed out.");
+               } while (waiting);
+
+               return sfs;
+       }
+
+       protected void checkTimeout(long begin, String msg) {
+               long now = System.currentTimeMillis();
+               if (now - begin > defaultTimeout)
+                       throw new SlcException(msg + " (timeout after " + (now - begin)
+                                       + "ms)");
+
+       }
+
+       protected void sleepWhenPolling() {
+               try {
+                       Thread.sleep(pollingPeriod);
+               } catch (InterruptedException e) {
+                       throw new SlcException("Polling interrupted");
+               }
+       }
+
+       /** Creates and open a new service tracker. */
+       public <S> ServiceTracker<S, S> newTracker(Class<S> clss) {
+               ServiceTracker<S, S> st = new ServiceTracker<S, S>(bundleContext, clss,
+                               null);
+               st.open();
+               return st;
+       }
+
+       public <T> T getSingleService(Class<T> clss, String filter,
+                       Boolean synchronous) {
+               if (filter != null)
+                       Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
+               Collection<ServiceReference<T>> sfs;
+               try {
+                       if (synchronous)
+                               sfs = getServiceRefSynchronous(clss, filter);
+                       else
+                               sfs = bundleContext.getServiceReferences(clss, filter);
+               } catch (InvalidSyntaxException e) {
+                       throw new SlcException("Cannot retrieve service reference for "
+                                       + filter, e);
+               }
+
+               if (sfs == null || sfs.size() == 0)
+                       return null;
+               else if (sfs.size() > 1)
+                       throw new SlcException("More than one execution flow found for "
+                                       + filter);
+               return (T) bundleContext.getService(sfs.iterator().next());
+       }
+
+       public <T> T getSingleServiceStrict(Class<T> clss, String filter,
+                       Boolean synchronous) {
+               T service = getSingleService(clss, filter, synchronous);
+               if (service == null)
+                       throw new SlcException("No execution flow found for " + filter);
+               else
+                       return service;
+       }
+
+       public OsgiBundle findRelatedBundle(String moduleName, String moduleVersion) {
+               OsgiBundle osgiBundle = new OsgiBundle(moduleName, moduleVersion);
+               if (osgiBundle.getVersion() == null) {
+                       Bundle bundle = findRelatedBundle(osgiBundle);
+                       osgiBundle = new OsgiBundle(bundle);
+               }
+               return osgiBundle;
+       }
+
+       /**
+        * @param osgiBundle
+        *            cannot be null
+        * @return the related bundle or null if not found
+        * @throws SlcException
+        *             if osgiBundle argument is null
+        */
+       public Bundle findRelatedBundle(OsgiBundle osgiBundle) {
+               if (osgiBundle == null)
+                       throw new SlcException("OSGi bundle cannot be null");
+
+               Bundle bundle = null;
+               if (osgiBundle.getInternalBundleId() != null) {
+                       bundle = bundleContext.getBundle(osgiBundle.getInternalBundleId());
+                       Assert.isTrue(
+                                       osgiBundle.getName().equals(bundle.getSymbolicName()),
+                                       "symbolic name consistent");
+                       if (osgiBundle.getVersion() != null)
+                               Assert.isTrue(
+                                               osgiBundle.getVersion().equals(
+                                                               bundle.getHeaders().get(
+                                                                               Constants.BUNDLE_VERSION)),
+                                               "version consistent");
+               } else if (osgiBundle.getVersion() == null
+                               || osgiBundle.getVersion().equals("0.0.0")) {
+                       bundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
+                                       osgiBundle.getName());
+               } else {// scan all bundles
+                       bundles: for (Bundle b : bundleContext.getBundles()) {
+                               if (b.getSymbolicName() == null) {
+                                       log.warn("Bundle " + b + " has no symbolic name defined.");
+                                       continue bundles;
+                               }
+
+                               if (b.getSymbolicName().equals(osgiBundle.getName())) {
+                                       if (osgiBundle.getVersion() == null) {
+                                               bundle = b;
+                                               break bundles;
+                                       }
+
+                                       if (b.getHeaders().get(Constants.BUNDLE_VERSION)
+                                                       .equals(osgiBundle.getVersion())) {
+                                               bundle = b;
+                                               osgiBundle.setInternalBundleId(b.getBundleId());
+                                               break bundles;
+                                       }
+                               }
+                       }
+               }
+               return bundle;
+       }
+
+       /** Find a single bundle based on a symbolic name pattern. */
+       public OsgiBundle findFromPattern(String pattern) {
+               OsgiBundle osgiBundle = null;
+               for (Bundle b : bundleContext.getBundles()) {
+                       if (b.getSymbolicName().contains(pattern)) {
+                               osgiBundle = new OsgiBundle(b);
+                               break;
+                       }
+               }
+               return osgiBundle;
+       }
+
+       public OsgiBundle getBundle(Long bundleId) {
+               Bundle bundle = bundleContext.getBundle(bundleId);
+               return new OsgiBundle(bundle);
+       }
+
+       public void setBundleContext(BundleContext bundleContext) {
+               this.bundleContext = bundleContext;
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               bundleContext.addFrameworkListener(this);
+       }
+
+       public void destroy() throws Exception {
+               bundleContext.removeFrameworkListener(this);
+       }
+
+       public void setDefaultTimeout(Long defaultTimeout) {
+               this.defaultTimeout = defaultTimeout;
+       }
+
+       /**
+        * Use with caution since it may interfer with some cached information
+        * within this object
+        */
+       public BundleContext getBundleContext() {
+               return bundleContext;
+       }
+
+       public void setPollingPeriod(Long pollingPeriod) {
+               this.pollingPeriod = pollingPeriod;
+       }
+
+       public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {
+               if (event instanceof OsgiBundleContextRefreshedEvent) {
+                       log.debug("App context refreshed: " + event);
+               } else if (event instanceof OsgiBundleContextFailedEvent) {
+                       log.debug("App context failed: " + event);
+               }
+               if (event instanceof OsgiBundleContextClosedEvent) {
+                       log.debug("App context closed: " + event);
+               }
+
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/FileSystemBundleRegister.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/FileSystemBundleRegister.java
new file mode 100644 (file)
index 0000000..605c797
--- /dev/null
@@ -0,0 +1,113 @@
+package org.argeo.slc.osgi;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.Constants;
+
+/** <b>Experimental</b> */
+public class FileSystemBundleRegister implements BundleRegister {
+       private final static Log log = LogFactory
+                       .getLog(FileSystemBundleRegister.class);
+       private Properties packagesBundles = null;
+
+       public String bundleProvidingPackage(String pkg, String version) {
+               if (packagesBundles == null)
+                       return null;
+               return packagesBundles.getProperty(pkg);
+       }
+
+       protected void scan(File baseDirectory) {
+               long begin = System.currentTimeMillis();
+               int bundleCount = 0;
+               int packageCount = 0;
+
+               packagesBundles = new Properties();
+
+               File[] files = baseDirectory.listFiles();
+               for (File file : files) {
+                       if (file.isDirectory()) {
+
+                       } else {
+                               JarFile jarFile = null;
+                               try {
+                                       jarFile = new JarFile(file);
+                                       Manifest manifest = jarFile.getManifest();
+                                       String symbolicName = manifest.getMainAttributes()
+                                                       .getValue(Constants.BUNDLE_SYMBOLICNAME);
+                                       String exportPackage = manifest.getMainAttributes()
+                                                       .getValue(Constants.EXPORT_PACKAGE);
+
+                                       // List exported packages
+                                       Set<String> exportedPackages = exportPackageToPackageNames(exportPackage);
+
+                                       for (String exportedPackage : exportedPackages) {
+                                               packagesBundles.put(exportedPackage, symbolicName);
+                                               packageCount++;
+                                               if (log.isTraceEnabled())
+                                                       log.trace("Register " + exportedPackage + "="
+                                                                       + symbolicName);
+                                       }
+                                       bundleCount++;
+                               } catch (Exception e) {
+                                       log.warn("Cannot scan " + file, e);
+                                       if (log.isTraceEnabled())
+                                               e.printStackTrace();
+                               } finally {
+                                       IOUtils.closeQuietly(jarFile);
+                               }
+                       }
+               }
+               if (log.isDebugEnabled())
+                       log.debug("Scanned " + bundleCount + " bundles with "
+                                       + packageCount + " packages in "
+                                       + (System.currentTimeMillis() - begin) + " ms");
+       }
+
+       protected Set<String> exportPackageToPackageNames(String exportPackage) {
+               Set<String> exportedPackages = new HashSet<String>();
+               if (exportPackage == null)
+                       return exportedPackages;
+               char[] arr = exportPackage.toCharArray();
+
+               StringBuffer currentPkg = new StringBuffer("");
+               boolean skip = false;
+               boolean inQuote = false;
+               for (char c : arr) {
+                       if (c == ' ' || c == '\n') {
+                               // ignore
+                       } else if (c == ';') {
+                               if (!skip)
+                                       skip = true;
+                       } else if (c == ',') {
+                               if (skip && !inQuote) {
+                                       skip = false;
+                                       // add new package
+                                       exportedPackages.add(currentPkg.toString());
+                                       currentPkg = new StringBuffer("");
+                               }
+                       } else if (c == '\"') {
+                               inQuote = inQuote ? false : true;
+                       } else {
+                               if (!skip)
+                                       currentPkg.append(c);
+                       }
+               }
+
+               return exportedPackages;
+       }
+
+       public static void main(String[] args) {
+               FileSystemBundleRegister fsbr = new FileSystemBundleRegister();
+               fsbr.scan(new File(
+                               "/home/mbaudier/dev/src/slc/dist/org.argeo.slc.sdk/target/lib"));
+
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/MultipleServiceExporterPostProcessor.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/MultipleServiceExporterPostProcessor.java
new file mode 100644 (file)
index 0000000..01509c2
--- /dev/null
@@ -0,0 +1,146 @@
+package org.argeo.slc.osgi;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.core.Ordered;
+
+/** Publishes beans of the application context as OSGi services. */
+@SuppressWarnings(value = { "unchecked", "rawtypes" })
+public class MultipleServiceExporterPostProcessor implements
+               ApplicationListener, Ordered {
+       private final static Log log = LogFactory
+                       .getLog(MultipleServiceExporterPostProcessor.class);
+
+       private List<Class> interfaces = new ArrayList<Class>();
+
+       private int order = Ordered.LOWEST_PRECEDENCE;
+
+       private BundleContext bundleContext = null;
+
+       // private Class osgiServiceFactoryClass = OsgiServiceFactoryBean.class;
+       // private Boolean useServiceProviderContextClassLoader = false;
+
+       public void onApplicationEvent(ApplicationEvent event) {
+               Map<String, Object> beans = new HashMap<String, Object>();
+               if (event instanceof ContextRefreshedEvent) {
+                       if (bundleContext != null) {
+                               for (Class clss : interfaces) {
+                                       ApplicationContext ac = ((ContextRefreshedEvent) event)
+                                                       .getApplicationContext();
+                                       beans.putAll(ac.getBeansOfType(clss, false, false));
+                               }
+
+                               int count = 0;
+                               for (String beanName : beans.keySet()) {
+                                       Object bean = beans.get(beanName);
+                                       List<String> classes = new ArrayList<String>();
+                                       for (Class clss : interfaces) {
+                                               if (clss.isAssignableFrom(bean.getClass())) {
+                                                       classes.add(clss.getName());
+                                               }
+                                       }
+                                       Properties props = new Properties();
+                                       Bundle bundle = bundleContext.getBundle();
+                                       props.put(Constants.BUNDLE_SYMBOLICNAME,
+                                                       bundle.getSymbolicName());
+                                       props.put(Constants.BUNDLE_VERSION, bundle.getVersion());
+                                       // retrocompatibility with pre-1.0:
+                                       props.put("org.eclipse.gemini.blueprint.bean.name", beanName);
+                                       bundleContext.registerService(
+                                                       classes.toArray(new String[classes.size()]), bean,
+                                                       new Hashtable(props));
+                                       count++;
+                               }
+                               if (log.isTraceEnabled())
+                                       log.trace("Published " + count + " " + interfaces
+                                                       + " as OSGi services from bundle "
+                                                       + bundleContext.getBundle().getSymbolicName() + " "
+                                                       + bundleContext.getBundle().getVersion());
+                               // note: the services will be automatically unregistered when
+                               // the bundle will be stopped
+                       }
+               }
+       }
+
+       // public void postProcessBeanFactory(
+       // ConfigurableListableBeanFactory beanFactory) throws BeansException {
+       // if (!(beanFactory instanceof BeanDefinitionRegistry)) {
+       // throw new SlcException("Can only work on "
+       // + BeanDefinitionRegistry.class);
+       // }
+       //
+       // long begin = System.currentTimeMillis();
+       //
+       // // Merge all beans implementing these interfaces
+       // Set<String> beanNames = new HashSet<String>();
+       // for (Class clss : interfaces) {
+       // String[] strs = beanFactory.getBeanNamesForType(clss, true, false);
+       // beanNames.addAll(Arrays.asList(strs));
+       // }
+       //
+       // // Register service factory beans for them
+       // for (String beanName : beanNames) {
+       // MutablePropertyValues mpv = new MutablePropertyValues();
+       // mpv.addPropertyValue("interfaces", interfaces.toArray());
+       // mpv.addPropertyValue("targetBeanName", beanName);
+       // if (useServiceProviderContextClassLoader)
+       // mpv.addPropertyValue("contextClassLoader",
+       // ExportContextClassLoader.SERVICE_PROVIDER);
+       // RootBeanDefinition bd = new RootBeanDefinition(
+       // osgiServiceFactoryClass, mpv);
+       //
+       // String exporterBeanName = "osgiService." + beanName;
+       // if (log.isTraceEnabled())
+       // log.debug("Registering OSGi service exporter "
+       // + exporterBeanName);
+       // ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(
+       // exporterBeanName, bd);
+       // }
+       //
+       // long end = System.currentTimeMillis();
+       // if (log.isTraceEnabled())
+       // log.debug("Multiple services exported in " + (end - begin)
+       // + " ms in bundle.");
+       //
+       // }
+
+       public void setInterfaces(List<Class> interfaces) {
+               this.interfaces = interfaces;
+       }
+
+       // public void setOsgiServiceFactoryClass(Class osgiServiceFactoryClass) {
+       // this.osgiServiceFactoryClass = osgiServiceFactoryClass;
+       // }
+
+       public int getOrder() {
+               return order;
+       }
+
+       public void setOrder(int order) {
+               this.order = order;
+       }
+
+       // public void setUseServiceProviderContextClassLoader(
+       // Boolean useServiceProviderContextClassLoader) {
+       // this.useServiceProviderContextClassLoader =
+       // useServiceProviderContextClassLoader;
+       // }
+
+       public void setBundleContext(BundleContext bundleContext) {
+               this.bundleContext = bundleContext;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiBundle.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiBundle.java
new file mode 100644 (file)
index 0000000..01275da
--- /dev/null
@@ -0,0 +1,137 @@
+package org.argeo.slc.osgi;
+
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.core.build.ResourceDistribution;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.Module;
+import org.argeo.slc.deploy.ModuleDescriptor;
+import org.argeo.slc.deploy.TargetData;
+import org.argeo.slc.execution.RealizedFlow;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.springframework.core.io.Resource;
+
+/** A deployed OSGi bundle. */
+public class OsgiBundle extends DefaultNameVersion implements Module {
+       private ResourceDistribution distribution;
+
+       private Long internalBundleId;
+
+       private String title;
+       private String description;
+
+       public OsgiBundle() {
+
+       }
+
+       public OsgiBundle(String name, String version) {
+               super(name, version);
+       }
+
+       public OsgiBundle(NameVersion nameVersion) {
+               super(nameVersion);
+       }
+
+       public OsgiBundle(Bundle bundle) {
+               super(bundle.getSymbolicName(), getVersionSafe(bundle));
+               internalBundleId = bundle.getBundleId();
+       }
+
+       /**
+        * Initialize from a {@link RealizedFlow}.
+        * 
+        * @deprecated introduce an unnecessary dependency. TODO: create a separate
+        *             helper.
+        */
+       public OsgiBundle(RealizedFlow realizedFlow) {
+               super(realizedFlow.getModuleName(), realizedFlow.getModuleVersion());
+       }
+
+       /** Utility to avoid NPE. */
+       private static String getVersionSafe(Bundle bundle) {
+               Object versionObj = bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+               if (versionObj != null)
+                       return versionObj.toString();
+               else
+                       return null;
+       }
+
+       /** Unique deployed system id. TODO: use internal bundle id when available? */
+       public String getDeployedSystemId() {
+               return getName() + ":" + getVersion();
+       }
+
+       /**
+        * OSGi bundle are self-contained and do not require additional deployment
+        * data.
+        * 
+        * @return always null
+        */
+       public DeploymentData getDeploymentData() {
+               return null;
+       }
+
+       /** The related distribution. */
+       public Distribution getDistribution() {
+               return distribution;
+       }
+
+       /**
+        * The related distribution, a jar file with OSGi metadata referenced by a
+        * {@link Resource}.
+        */
+       public ResourceDistribution getResourceDistribution() {
+               return distribution;
+       }
+
+       /** TODO: reference the {@link OsgiRuntime} as target data? */
+       public TargetData getTargetData() {
+               throw new UnsupportedOperationException();
+       }
+
+       public void setResourceDistribution(ResourceDistribution distribution) {
+               this.distribution = distribution;
+       }
+
+       /**
+        * Bundle ID used by the OSGi runtime. To be used for optimization when
+        * looking in the bundle context. Can therefore be null.
+        */
+       public Long getInternalBundleId() {
+               return internalBundleId;
+       }
+
+       /** Only package access for the time being. e.g. from {@link BundlesManager} */
+       void setInternalBundleId(Long internalBundleId) {
+               this.internalBundleId = internalBundleId;
+       }
+
+       /** Value of the <code>Bundle-Name</code> directive. */
+       public String getTitle() {
+               return title;
+       }
+
+       public void setTitle(String label) {
+               this.title = label;
+       }
+
+       /** Value of the <code>Bundle-Description</code> directive. */
+       public String getDescription() {
+               return description;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       public ModuleDescriptor getModuleDescriptor() {
+               ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
+               moduleDescriptor.setName(getName());
+               moduleDescriptor.setVersion(getVersion());
+               moduleDescriptor.setDescription(description);
+               moduleDescriptor.setTitle(title);
+               return moduleDescriptor;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModule.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModule.java
new file mode 100644 (file)
index 0000000..ca3f5fa
--- /dev/null
@@ -0,0 +1,80 @@
+package org.argeo.slc.osgi;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.core.execution.AbstractSpringExecutionModule;
+import org.argeo.slc.execution.ExecutionContext;
+
+@Deprecated
+public class OsgiExecutionModule extends AbstractSpringExecutionModule {
+       private final static Log log = LogFactory.getLog(OsgiExecutionModule.class);
+
+       public OsgiExecutionModule() {
+               log.error("######## ERROR - DEPRECATED APPROACH USED ########");
+               log.error(OsgiExecutionModule.class.getName() + " is deprecated. ");
+               log
+                               .error("It will be removed in the next release. Remove its bean definition.");
+               log
+                               .error("And replace: <service interface=\"org.argeo.slc.execution.ExecutionModule\" ref=\"executionModule\" />");
+               log
+                               .error("by: <beans:import resource=\"classpath:org/argeo/slc/osgi/execution/spring.xml\" /> ");
+               log.error("in osgi.xml.\n\n");
+       }
+
+       public void setExecutionContext(ExecutionContext executionContext) {
+               // do nothing, just for compatibility
+       }
+
+       /*
+        * private BundleContext bundleContext;
+        * 
+        * @Override public void execute(ExecutionFlowDescriptor
+        * executionFlowDescriptor) { if (descriptorConverter != null)
+        * executionContext.addVariables(descriptorConverter
+        * .convertValues(executionFlowDescriptor));
+        * 
+        * ExecutionFlow flow = findExecutionFlow(getName(), getVersion(),
+        * executionFlowDescriptor.getName()); flow.run(); }
+        * 
+        * @Override protected Map<String, ExecutionFlow> listFlows() { String
+        * filter = "(org.argeo.slc.execution.module.name=" + getName() + ")";
+        * ServiceReference[] sfs; try { sfs =
+        * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
+        * filter); } catch (InvalidSyntaxException e) { throw new SlcException(
+        * "Cannot retrieve service reference for flow " + filter, e); }
+        * 
+        * Map<String, ExecutionFlow> flows = new HashMap<String, ExecutionFlow>();
+        * for (ServiceReference sf : sfs) { ExecutionFlow flow = (ExecutionFlow)
+        * bundleContext.getService(sf); flows.put(flow.getName(), flow); } return
+        * flows; }
+        * 
+        * public String getName() { return
+        * bundleContext.getBundle().getSymbolicName(); }
+        * 
+        * public String getVersion() { return
+        * bundleContext.getBundle().getHeaders().get("Bundle-Version") .toString();
+        * }
+        * 
+        * public void setBundleContext(BundleContext bundleContext) {
+        * this.bundleContext = bundleContext; }
+        * 
+        * protected ExecutionFlow findExecutionFlow(String moduleName, String
+        * moduleVersion, String flowName) { String filter =
+        * "(&(org.argeo.slc.execution.module.name=" + moduleName +
+        * ")(org.argeo.slc.execution.flow.name=" + flowName + "))";
+        * log.debug("OSGi filter: " + filter);
+        * 
+        * Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
+        * ServiceReference[] sfs; try { sfs =
+        * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
+        * filter); } catch (InvalidSyntaxException e) { throw new
+        * SlcException("Cannot retrieve service reference for " + filter, e); }
+        * 
+        * if (sfs == null || sfs.length == 0) throw new
+        * SlcException("No execution flow found for " + filter); else if
+        * (sfs.length > 1) throw new
+        * SlcException("More than one execution flow found for " + filter); return
+        * (ExecutionFlow) bundleContext.getService(sfs[0]); }
+        */
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModulesManager.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionModulesManager.java
new file mode 100644 (file)
index 0000000..63eb6f9
--- /dev/null
@@ -0,0 +1,686 @@
+package org.argeo.slc.osgi;
+
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.DefaultExecutionFlowDescriptorConverter;
+import org.argeo.slc.deploy.Module;
+import org.argeo.slc.deploy.ModuleDescriptor;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
+import org.argeo.slc.execution.ExecutionModuleDescriptor;
+import org.argeo.slc.execution.ExecutionModulesListener;
+import org.argeo.slc.execution.RealizedFlow;
+import org.argeo.slc.runtime.AbstractExecutionModulesManager;
+import org.eclipse.gemini.blueprint.service.importer.OsgiServiceLifecycleListener;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Constants;
+import org.osgi.framework.launch.Framework;
+import org.springframework.context.ApplicationContext;
+
+/** Execution modules manager implementation based on an OSGi runtime. */
+public class OsgiExecutionModulesManager extends
+               AbstractExecutionModulesManager implements
+               OsgiServiceLifecycleListener, BundleListener {
+
+       private final static Log log = LogFactory
+                       .getLog(OsgiExecutionModulesManager.class);
+
+       private BundlesManager bundlesManager;
+       private Map<OsgiBundle, ExecutionContext> executionContexts = new HashMap<OsgiBundle, ExecutionContext>();
+       private Map<OsgiBundle, ExecutionFlowDescriptorConverter> executionFlowDescriptorConverters = new HashMap<OsgiBundle, ExecutionFlowDescriptorConverter>();
+       private Map<OsgiBundle, Set<ExecutionFlow>> executionFlows = new HashMap<OsgiBundle, Set<ExecutionFlow>>();
+       private ExecutionFlowDescriptorConverter defaultDescriptorConverter = new DefaultExecutionFlowDescriptorConverter();
+
+       private List<ExecutionModulesListener> executionModulesListeners = new ArrayList<ExecutionModulesListener>();
+
+       private Boolean registerFlowsToJmx = false;
+
+       public void init() throws Exception {
+               bundlesManager.getBundleContext().addBundleListener(this);
+
+               final String module = System.getProperty(UNIQUE_LAUNCH_MODULE_PROPERTY);
+               final String flow = System.getProperty(UNIQUE_LAUNCH_FLOW_PROPERTY);
+               if (module != null) {
+                       // launch a flow and stops
+                       new Thread("Unique Flow") {
+                               @Override
+                               public void run() {
+                                       executeFlowAndExit(module, null, flow);
+                               }
+                       }.start();
+               }
+       }
+
+       public void destroy() {
+               bundlesManager.getBundleContext().removeBundleListener(this);
+       }
+
+       /** Executes a single flow and <b>stops the JVM</b> */
+       protected void executeFlowAndExit(final String module,
+                       final String version, final String flow) {
+               if (log.isDebugEnabled())
+                       log.debug("Launch unique flow " + flow + " from module " + module);
+               try {
+                       OsgiBundle osgiBundle = bundlesManager.findFromPattern(module);
+                       if (osgiBundle == null)
+                               throw new SlcException("No OSGi bundle found for " + module);
+                       // Bundle moduleBundle =
+                       // bundlesManager.findRelatedBundle(osgiBundle);
+                       start(osgiBundle);
+
+                       RealizedFlow lastLaunch = findRealizedFlow(module, flow);
+                       if (lastLaunch == null)
+                               throw new SlcException("Cannot find launch for " + module + " "
+                                               + flow);
+                       execute(lastLaunch);
+               } catch (Exception e) {
+                       log.error(
+                                       "Error in unique flow " + flow + " from module " + module,
+                                       e);
+               } finally {
+                       if (log.isDebugEnabled())
+                               log.debug("Shutdown OSGi runtime...");
+                       Framework framework = (Framework) bundlesManager.getBundleContext()
+                                       .getBundle(0);
+                       try {
+                               // shutdown framework
+                               framework.stop();
+                               // wait 1 min for shutdown
+                               framework.waitForStop(60 * 1000);
+                               // close VM
+                               System.exit(0);
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                               System.exit(1);
+                       }
+               }
+       }
+
+       // public void startExectionModule(String moduleName, String moduleVersion)
+       // {
+       // try {
+       // ServiceReference[] sr = bundlesManager.getServiceRefSynchronous(
+       // ApplicationContext.class.getName(),
+       // "org.springframework.context.service.name=" + moduleName);
+       // // bundlesManager.startSynchronous(moduleBundle);
+       // if (sr == null || sr.length == 0)
+       // throw new SlcException(
+       // "Cannot find execution module application context "
+       // + moduleName);
+       // } catch (InvalidSyntaxException e) {
+       // throw new SlcException("Cannot start exeuction module "
+       // + moduleName, e);
+       // }
+       // }
+
+       public synchronized ExecutionModuleDescriptor getExecutionModuleDescriptor(
+                       String moduleName, String version) {
+               ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
+               OsgiBundle osgiBundle = null;
+               DefaultNameVersion nameVersion = new DefaultNameVersion(moduleName,
+                               version);
+               bundles: for (Iterator<OsgiBundle> iterator = executionContexts
+                               .keySet().iterator(); iterator.hasNext();) {
+                       OsgiBundle ob = iterator.next();
+                       if (nameVersion.getVersion() != null) {
+                               if (ob.equals(nameVersion)) {
+                                       osgiBundle = ob;
+                                       break bundles;
+                               }
+                       } else {
+                               if (ob.getName().equals(nameVersion.getName())) {
+                                       osgiBundle = ob;
+                                       break bundles;
+                               }
+                       }
+               }
+               if (osgiBundle == null)
+                       throw new SlcException("No execution module registered for "
+                                       + nameVersion);
+               md.setName(osgiBundle.getName());
+               md.setVersion(osgiBundle.getVersion());
+               md.setTitle(osgiBundle.getTitle());
+               md.setDescription(osgiBundle.getDescription());
+
+               ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = getExecutionFlowDescriptorConverter(
+                               moduleName, version);
+               if (executionFlowDescriptorConverter == null)
+                       throw new SlcException("No flow converter found.");
+               executionFlowDescriptorConverter.addFlowsToDescriptor(md,
+                               listFlows(moduleName, version));
+               return md;
+       }
+
+       public synchronized List<ExecutionModuleDescriptor> listExecutionModules() {
+               List<ExecutionModuleDescriptor> descriptors = new ArrayList<ExecutionModuleDescriptor>();
+
+               for (Iterator<OsgiBundle> iterator = executionContexts.keySet()
+                               .iterator(); iterator.hasNext();) {
+                       OsgiBundle osgiBundle = iterator.next();
+                       ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
+                       setMetadataFromBundle(md,
+                                       bundlesManager.findRelatedBundle(osgiBundle));
+                       descriptors.add(md);
+               }
+               return descriptors;
+       }
+
+       protected synchronized Map<String, ExecutionFlow> listFlows(
+                       String moduleName, String moduleVersion) {
+
+               Map<String, ExecutionFlow> flows = new HashMap<String, ExecutionFlow>();
+               OsgiBundle key = bundlesManager.findRelatedBundle(moduleName,
+                               moduleVersion);
+               if (!executionFlows.containsKey(key))
+                       return flows;
+               Set<ExecutionFlow> flowsT = executionFlows.get(key);
+               for (ExecutionFlow flow : flowsT)
+                       flows.put(flow.getName(), flow);
+               return flows;
+       }
+
+       protected ExecutionFlow findExecutionFlow(String moduleName,
+                       String moduleVersion, String flowName) {
+               String filter = moduleVersion == null || moduleVersion.equals("0.0.0") ? "(&(Bundle-SymbolicName="
+                               + moduleName
+                               + ")(org.eclipse.gemini.blueprint.bean.name="
+                               + flowName + "))"
+                               : "(&(Bundle-SymbolicName=" + moduleName + ")(Bundle-Version="
+                                               + moduleVersion
+                                               + ")(org.eclipse.gemini.blueprint.bean.name="
+                                               + flowName + "))";
+               return bundlesManager.getSingleServiceStrict(ExecutionFlow.class,
+                               filter, true);
+       }
+
+       protected ExecutionContext findExecutionContext(String moduleName,
+                       String moduleVersion) {
+               String filter = moduleFilter(moduleName, moduleVersion);
+               return bundlesManager.getSingleServiceStrict(ExecutionContext.class,
+                               filter, true);
+       }
+
+       protected ExecutionFlowDescriptorConverter findExecutionFlowDescriptorConverter(
+                       String moduleName, String moduleVersion) {
+               String filter = moduleFilter(moduleName, moduleVersion);
+               return bundlesManager.getSingleService(
+                               ExecutionFlowDescriptorConverter.class, filter, false);
+       }
+
+       /** Only based on symbolic name if version is null or "0.0.0" */
+       protected String moduleFilter(String moduleName, String moduleVersion) {
+               return moduleVersion == null || moduleVersion.equals("0.0.0") ? "(Bundle-SymbolicName="
+                               + moduleName + ")"
+                               : "(&(Bundle-SymbolicName=" + moduleName + ")(Bundle-Version="
+                                               + moduleVersion + "))";
+
+       }
+
+       /**
+        * Builds a minimal realized flow, based on the provided information
+        * (typically from the command line).
+        * 
+        * @param module
+        *            a bundle id, or a pattern contained in a bundle symbolic name
+        * @param module
+        *            the execution flow name
+        * @return a minimal realized flow, to be used in an execution
+        */
+       public RealizedFlow findRealizedFlow(String module, String executionName) {
+               // First check whether we have a bundleId
+               Long bundleId = null;
+               try {
+                       bundleId = Long.parseLong(module);
+               } catch (NumberFormatException e) {
+                       // silent
+               }
+
+               // Look for bundle names containing pattern
+               OsgiBundle bundle = null;
+               if (bundleId != null) {
+                       bundle = bundlesManager.getBundle(bundleId);
+               } else {
+                       bundle = bundlesManager.findFromPattern(module);
+               }
+
+               if (bundle != null) {
+                       RealizedFlow launch = new RealizedFlow();
+                       launch.setModuleName(bundle.getName());
+                       launch.setModuleVersion(bundle.getVersion());
+                       ExecutionFlowDescriptor descriptor = new ExecutionFlowDescriptor();
+                       descriptor.setName(executionName);
+                       launch.setFlowDescriptor(descriptor);
+                       return launch;
+               } else {
+                       log.warn("Could not find any execution module matching these requirements.");
+                       return null;
+               }
+       }
+
+       public void upgrade(NameVersion nameVersion) {
+               OsgiBundle osgiBundle = new OsgiBundle(nameVersion);
+               bundlesManager.upgradeSynchronous(osgiBundle);
+       }
+
+       protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
+                       String moduleName, String moduleVersion) {
+               return findExecutionFlowDescriptorConverter(moduleName, moduleVersion);
+               // OsgiBundle osgiBundle = new OsgiBundle(moduleName, moduleVersion);
+               // return getExecutionFlowDescriptorConverter(osgiBundle);
+       }
+
+       protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
+                       OsgiBundle osgiBundle) {
+               if (executionFlowDescriptorConverters.containsKey(osgiBundle))
+                       return executionFlowDescriptorConverters.get(osgiBundle);
+               else
+                       return defaultDescriptorConverter;
+       }
+
+       public ModuleDescriptor getModuleDescriptor(String moduleName,
+                       String version) {
+               return getExecutionModuleDescriptor(moduleName, version);
+       }
+
+       public List<ModuleDescriptor> listModules() {
+               Bundle[] bundles = bundlesManager.getBundleContext().getBundles();
+               List<ModuleDescriptor> lst = new ArrayList<ModuleDescriptor>();
+               for (Bundle bundle : bundles) {
+                       ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
+                       setMetadataFromBundle(moduleDescriptor, bundle);
+                       lst.add(moduleDescriptor);
+               }
+               return lst;
+       }
+
+       public void start(NameVersion nameVersion) {
+               try {
+                       Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
+                                       nameVersion));
+                       if (bundle == null)
+                               throw new SlcException("Could not find bundle for "
+                                               + nameVersion);
+
+                       bundlesManager.startSynchronous(bundle);
+                       if (isSpringInstrumented(bundle)) {
+                               // Wait for Spring application context to be ready
+                               String filter = "(Bundle-SymbolicName="
+                                               + bundle.getSymbolicName() + ")";
+                               try {
+                                       bundlesManager.getServiceRefSynchronous(
+                                                       ApplicationContext.class, filter);
+                               } catch (Exception e) {
+                                       // stop if application context not found
+                                       bundle.stop();
+                                       throw e;
+                               }
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot start " + nameVersion, e);
+               }
+       }
+
+       /** Do it calmly in order to avoid NPE */
+       private Boolean isSpringInstrumented(Bundle bundle) {
+               Dictionary<?, ?> headers = bundle.getHeaders();
+               if (headers != null && headers.get("Spring-Context") != null)
+                       return true;
+               Enumeration<?> springEntryPaths = bundle
+                               .getEntryPaths("/META-INF/spring");
+               if (springEntryPaths != null && springEntryPaths.hasMoreElements())
+                       return true;
+               return false;
+       }
+
+       public void stop(NameVersion nameVersion) {
+               try {
+                       Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
+                                       nameVersion));
+                       bundlesManager.stopSynchronous(bundle);
+               } catch (BundleException e) {
+                       throw new SlcException("Cannot stop " + nameVersion, e);
+               }
+       }
+
+       protected void setMetadataFromBundle(ModuleDescriptor md, Bundle bundle) {
+               Bundle bdl = bundle;
+               if (bdl == null) {
+                       if (md.getName() == null || md.getVersion() == null)
+                               throw new SlcException("Name and version not available.");
+
+                       Bundle[] bundles = bundlesManager.getBundleContext().getBundles();
+                       for (Bundle b : bundles) {
+                               if (b.getSymbolicName().equals(md.getName())
+                                               && md.getVersion().equals(
+                                                               getHeaderSafe(b, Constants.BUNDLE_VERSION))) {
+                                       bdl = b;
+                                       break;
+                               }
+                       }
+
+               }
+
+               if (bdl == null)
+                       throw new SlcException("Cannot find bundle.");
+
+               md.setName(bdl.getSymbolicName());
+               md.setVersion(getHeaderSafe(bdl, Constants.BUNDLE_VERSION));
+               md.setTitle(getHeaderSafe(bdl, Constants.BUNDLE_NAME));
+               md.setDescription(getHeaderSafe(bdl, Constants.BUNDLE_DESCRIPTION));
+
+               // copy manifets header to meta data
+               Dictionary<?, ?> headers = bundle.getHeaders();
+               Enumeration<?> keys = headers.keys();
+               while (keys.hasMoreElements()) {
+                       Object key = keys.nextElement();
+                       Object value = headers.get(key);
+                       if (value != null)
+                               md.getMetadata().put(key.toString(), value.toString());
+               }
+
+               // check if started
+               if (bundle.getState() == Bundle.ACTIVE
+                               || bundle.getState() == Bundle.STARTING)
+                       md.setStarted(true);
+               else
+                       md.setStarted(false);
+       }
+
+       private String getHeaderSafe(Bundle bundle, Object key) {
+               Object obj = bundle.getHeaders().get(key);
+               if (obj == null)
+                       return null;
+               else
+                       return obj.toString();
+       }
+
+       /*
+        * REGISTRATION
+        */
+
+       /** Registers an execution context. */
+       public synchronized void register(ExecutionContext executionContext,
+                       Map<String, String> properties) {
+               OsgiBundle osgiBundle = asOsgiBundle(properties);
+               Bundle bundle = bundlesManager.findRelatedBundle(osgiBundle);
+               osgiBundle.setTitle(getHeaderSafe(bundle, Constants.BUNDLE_NAME));
+               osgiBundle.setDescription(getHeaderSafe(bundle,
+                               Constants.BUNDLE_DESCRIPTION));
+               executionContexts.put(osgiBundle, executionContext);
+               if (log.isTraceEnabled())
+                       log.trace("Registered execution context from " + osgiBundle);
+               // Notify
+               ModuleDescriptor md = osgiBundle.getModuleDescriptor();
+               md.setStarted(true);
+               for (ExecutionModulesListener listener : executionModulesListeners)
+                       listener.executionModuleAdded(md);
+       }
+
+       /** Unregisters an execution context. */
+       public synchronized void unregister(ExecutionContext executionContext,
+                       Map<String, String> properties) {
+               // FIXME why are properties null?
+               if (properties == null)
+                       return;
+               OsgiBundle osgiBundle = asOsgiBundle(properties);
+               if (executionContexts.containsKey(osgiBundle)) {
+                       executionContexts.remove(osgiBundle);
+                       if (log.isTraceEnabled())
+                               log.trace("Removed execution context from " + osgiBundle);
+                       // Notify
+                       ModuleDescriptor md = osgiBundle.getModuleDescriptor();
+                       md.setStarted(false);
+                       for (ExecutionModulesListener listener : executionModulesListeners)
+                               listener.executionModuleRemoved(md);
+               }
+       }
+
+       /** Registers an execution flow. */
+       public synchronized void register(ExecutionFlow executionFlow,
+                       Map<String, String> properties) {
+               OsgiBundle osgiBundle = asOsgiBundle(properties);
+               if (!executionFlows.containsKey(osgiBundle)) {
+                       executionFlows.put(osgiBundle, new HashSet<ExecutionFlow>());
+               }
+               executionFlows.get(osgiBundle).add(executionFlow);
+               if (log.isTraceEnabled())
+                       log.trace("Registered " + executionFlow + " from " + osgiBundle);
+
+               // notifications
+               if (registerFlowsToJmx)
+                       registerMBean(osgiBundle, executionFlow);
+               ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
+               for (ExecutionModulesListener listener : executionModulesListeners)
+                       listener.executionFlowAdded(osgiBundle.getModuleDescriptor(),
+                                       efdc.getExecutionFlowDescriptor(executionFlow));
+       }
+
+       /** Unregisters an execution flow. */
+       public synchronized void unregister(ExecutionFlow executionFlow,
+                       Map<String, String> properties) {
+               // FIXME why are properties null?
+               if (properties == null)
+                       return;
+               OsgiBundle osgiBundle = asOsgiBundle(properties);
+               if (executionFlows.containsKey(osgiBundle)) {
+                       Set<ExecutionFlow> flows = executionFlows.get(osgiBundle);
+                       flows.remove(executionFlow);
+                       if (log.isTraceEnabled())
+                               log.trace("Removed " + executionFlow + " from " + osgiBundle);
+                       if (flows.size() == 0) {
+                               executionFlows.remove(osgiBundle);
+                               if (log.isTraceEnabled())
+                                       log.trace("Removed flows set from " + osgiBundle);
+                       }
+
+                       // notifications
+                       if (registerFlowsToJmx)
+                               unregisterMBean(osgiBundle, executionFlow);
+                       ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
+                       for (ExecutionModulesListener listener : executionModulesListeners)
+                               listener.executionFlowRemoved(osgiBundle.getModuleDescriptor(),
+                                               efdc.getExecutionFlowDescriptor(executionFlow));
+               }
+       }
+
+       /** Registers an execution module listener. */
+       public synchronized void register(
+                       ExecutionModulesListener executionModulesListener,
+                       Map<String, String> properties) {
+               // sync with current state
+               for (OsgiBundle osgiBundle : executionContexts.keySet()) {
+                       executionModulesListener.executionModuleAdded(osgiBundle
+                                       .getModuleDescriptor());
+               }
+               for (OsgiBundle osgiBundle : executionFlows.keySet()) {
+                       ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
+                       for (ExecutionFlow executionFlow : executionFlows.get(osgiBundle))
+                               executionModulesListener.executionFlowAdded(
+                                               osgiBundle.getModuleDescriptor(),
+                                               efdc.getExecutionFlowDescriptor(executionFlow));
+               }
+               executionModulesListeners.add(executionModulesListener);
+       }
+
+       /** Unregisters an execution module listener. */
+       public synchronized void unregister(
+                       ExecutionModulesListener executionModulesListener,
+                       Map<String, String> properties) {
+               executionModulesListeners.remove(executionModulesListener);
+       }
+
+       /*
+        * INTERFACE IMPLEMENTATIONS
+        */
+
+       public void bundleChanged(BundleEvent evt) {
+               Bundle bundle = evt.getBundle();
+               if (bundle.getHeaders().get(
+                               ExecutionModuleDescriptor.SLC_EXECUTION_MODULE) != null) {
+                       OsgiBundle osgiBundle = new OsgiBundle(bundle);
+                       if (evt.getType() == BundleEvent.INSTALLED)
+                               for (ExecutionModulesListener listener : executionModulesListeners)
+                                       listener.executionModuleAdded(osgiBundle
+                                                       .getModuleDescriptor());
+                       else if (evt.getType() == BundleEvent.UNINSTALLED)
+                               for (ExecutionModulesListener listener : executionModulesListeners)
+                                       listener.executionModuleRemoved(osgiBundle
+                                                       .getModuleDescriptor());
+               }
+
+       }
+
+       @SuppressWarnings({ "rawtypes" })
+       public synchronized void bind(Object service, Map properties)
+                       throws Exception {
+               if (service instanceof ExecutionFlowDescriptorConverter) {
+                       ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = (ExecutionFlowDescriptorConverter) service;
+                       OsgiBundle osgiBundle = asOsgiBundle(properties);
+                       executionFlowDescriptorConverters.put(osgiBundle,
+                                       executionFlowDescriptorConverter);
+                       if (log.isTraceEnabled())
+                               log.debug("Registered execution flow descriptor converter from "
+                                               + osgiBundle);
+               } else {
+                       // ignore
+               }
+       }
+
+       @SuppressWarnings("rawtypes")
+       public synchronized void unbind(Object service, Map properties)
+                       throws Exception {
+               if (service instanceof ExecutionFlowDescriptorConverter) {
+                       OsgiBundle osgiBundle = asOsgiBundle(properties);
+                       if (executionFlowDescriptorConverters.containsKey(osgiBundle)) {
+                               executionFlowDescriptorConverters.remove(osgiBundle);
+                               if (log.isTraceEnabled())
+                                       log.debug("Removed execution flow descriptor converter from "
+                                                       + osgiBundle);
+                       }
+               } else {
+                       // ignore
+               }
+       }
+
+       /*
+        * JMX
+        */
+       protected MBeanServer getMBeanServer() {
+               return ManagementFactory.getPlatformMBeanServer();
+       }
+
+       public void registerMBean(Module module, ExecutionFlow executionFlow) {
+               try {
+                       StandardMBean mbean = new StandardMBean(executionFlow,
+                                       ExecutionFlow.class);
+                       getMBeanServer().registerMBean(mbean,
+                                       flowMBeanName(module, executionFlow));
+               } catch (Exception e) {
+                       String msg = "Cannot register execution flow " + executionFlow
+                                       + " as mbean";
+                       throw new SlcException(msg, e);
+               }
+       }
+
+       public void unregisterMBean(Module module, ExecutionFlow executionFlow) {
+               try {
+                       getMBeanServer().unregisterMBean(
+                                       flowMBeanName(module, executionFlow));
+               } catch (Exception e) {
+                       String msg = "Cannot unregister execution flow " + executionFlow
+                                       + " as mbean";
+                       throw new SlcException(msg, e);
+               }
+       }
+
+       protected ObjectName flowMBeanName(Module module,
+                       ExecutionFlow executionFlow) {
+               String executionModulesPrefix = "SLCExecutionModules";
+               // String path = executionFlow.getPath();
+               String name = executionFlow.getName();
+               // if (path == null && name.indexOf('/') >= 0) {
+               // path = name.substring(0, name.lastIndexOf('/'));
+               // name = name.substring(name.lastIndexOf('/'));
+               // }
+
+               StringBuffer buf = new StringBuffer(executionModulesPrefix + ":"
+                               + "module=" + module.getName() + " [" + module.getVersion()
+                               + "],");
+
+               // if (path != null && !path.equals("")) {
+               // int depth = 0;
+               // for (String token : path.split("/")) {
+               // if (!token.equals("")) {
+               // buf.append("path").append(depth).append('=');
+               // // in order to have directories first
+               // buf.append('/');
+               // buf.append(token).append(',');
+               // depth++;
+               // }
+               // }
+               // }
+               buf.append("name=").append(name);
+               try {
+                       return new ObjectName(buf.toString());
+               } catch (Exception e) {
+                       throw new SlcException("Cannot generate object name based on "
+                                       + buf, e);
+               }
+       }
+
+       /*
+        * UTILITIES
+        */
+       @SuppressWarnings("rawtypes")
+       private OsgiBundle asOsgiBundle(Map properties) {
+               String bundleSymbolicName = checkAndGet(Constants.BUNDLE_SYMBOLICNAME,
+                               properties);
+               String bundleVersion = checkAndGet(Constants.BUNDLE_VERSION, properties);
+               return new OsgiBundle(bundleSymbolicName, bundleVersion);
+       }
+
+       @SuppressWarnings("rawtypes")
+       private String checkAndGet(Object key, Map properties) {
+               if (!properties.containsKey(key) || properties.get(key) == null)
+                       throw new SlcException(key + " not set in " + properties);
+               else
+                       return properties.get(key).toString();
+       }
+
+       public void setBundlesManager(BundlesManager bundlesManager) {
+               this.bundlesManager = bundlesManager;
+       }
+
+       public void setDefaultDescriptorConverter(
+                       ExecutionFlowDescriptorConverter defaultDescriptorConverter) {
+               this.defaultDescriptorConverter = defaultDescriptorConverter;
+       }
+
+       public void setRegisterFlowsToJmx(Boolean registerFlowsToJmx) {
+               this.registerFlowsToJmx = registerFlowsToJmx;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionResources.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiExecutionResources.java
new file mode 100644 (file)
index 0000000..3668b91
--- /dev/null
@@ -0,0 +1,89 @@
+package org.argeo.slc.osgi;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.FileExecutionResources;
+import org.eclipse.gemini.blueprint.context.BundleContextAware;
+import org.eclipse.gemini.blueprint.io.OsgiBundleResource;
+import org.osgi.framework.BundleContext;
+import org.springframework.core.io.Resource;
+
+/** Write access to resources in an OSGi context */
+public class OsgiExecutionResources extends FileExecutionResources implements
+               BundleContextAware {
+       private final static Log log = LogFactory
+                       .getLog(OsgiExecutionResources.class);
+
+       private BundleContext bundleContext;
+
+       @Override
+       protected File fileFromResource(Resource resource) {
+               File file = super.fileFromResource(resource);
+               if (file != null)
+                       return file;
+
+               if (!(resource instanceof OsgiBundleResource))
+                       return null;
+
+               OsgiBundleResource osgiBundleResource = (OsgiBundleResource) resource;
+               try {
+                       return osgiBundleResource.getFile();
+               } catch (IOException e) {
+                       if (log.isTraceEnabled())
+                               log.trace("Resource " + resource
+                                               + " is not available on the file system: " + e);
+               }
+
+               // TODO: ability to access resources in other bundles
+               String location = bundleContext.getBundle().getLocation();
+               String base = null;
+               if (location.startsWith("reference:file:"))
+                       base = location.substring("reference:file:".length());
+               else if (location.startsWith("initial@reference:file:")) {
+                       // TODO: Equinox specific?
+                       String relPath = location.substring("initial@reference:file:"
+                                       .length());
+                       // if (relPath.startsWith("../"))// relative to the framework jar
+                       // relPath = relPath.substring("../".length());
+                       // String framework =
+                       // System.getProperty("osgi.framework").substring(
+                       // "file:".length());
+                       // log.debug(framework);
+                       String installArea = System.getProperty("osgi.install.area")
+                                       .substring("file:".length());
+                       // log.debug(installArea);
+                       base = installArea + '/' + relPath;
+                       // int sepIndex = framework.lastIndexOf(File.separatorChar);
+                       // framework = framework.substring(0, sepIndex);
+                       // base = framework + '/' + relPath;
+               } else {
+                       return null;
+               }
+
+               String path = base + '/' + osgiBundleResource.getPathWithinContext();
+               try {
+                       file = new File(path).getCanonicalFile();
+               } catch (IOException e) {
+                       throw new SlcException("Cannot determine canonical path for "
+                                       + path, e);
+               }
+
+               if (!file.exists())
+                       throw new SlcException(file
+                                       + " was retrieved in bundle located at '" + location
+                                       + "' for resource " + resource + " but it does not exist");
+
+               if (log.isTraceEnabled())
+                       log.debug("OSGi local resource: " + file + " from " + resource);
+               return file;
+       }
+
+       public void setBundleContext(BundleContext bundleContext) {
+               this.bundleContext = bundleContext;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiRuntime.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/OsgiRuntime.java
new file mode 100644 (file)
index 0000000..089baa6
--- /dev/null
@@ -0,0 +1,132 @@
+package org.argeo.slc.osgi;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.StreamReadable;
+import org.argeo.slc.UnsupportedException;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.core.build.VersionedResourceDistribution;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.DynamicRuntime;
+import org.argeo.slc.deploy.TargetData;
+import org.eclipse.gemini.blueprint.context.BundleContextAware;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+
+public class OsgiRuntime implements BundleContextAware, ResourceLoaderAware,
+               DynamicRuntime<OsgiBundle> {
+       private String uuid = UUID.randomUUID().toString();
+       private BundleContext bundleContext;
+       private ResourceLoader resourceLoader;
+
+       public List<OsgiBundle> listModules() {
+               List<OsgiBundle> modules = new ArrayList<OsgiBundle>();
+               Bundle[] bundles = bundleContext.getBundles();
+               for (Bundle bundle : bundles) {
+                       OsgiBundle osgiBundle = new OsgiBundle(bundle);
+                       modules.add(osgiBundle);
+                       String location = bundle.getLocation();
+                       if (location != null) {
+                               Resource resource = resourceLoader.getResource(location);
+                               osgiBundle
+                                               .setResourceDistribution(new VersionedResourceDistribution(
+                                                               osgiBundle.getName(), osgiBundle.getVersion(),
+                                                               resource));
+                       }
+               }
+               return modules;
+       }
+
+       public OsgiBundle installModule(Distribution distribution) {
+               if (!(distribution instanceof StreamReadable))
+                       throw new UnsupportedException("distribution", distribution);
+
+               StreamReadable sr = (StreamReadable) distribution;
+               Bundle bundle;
+               try {
+                       bundle = bundleContext.installBundle(sr.toString(), sr
+                                       .getInputStream());
+               } catch (BundleException e) {
+                       throw new SlcException(
+                                       "Cannot install OSGi bundle " + distribution, e);
+               }
+               return new OsgiBundle(bundle);
+       }
+
+       public void updateModule(NameVersion nameVersion) {
+               Bundle bundle = findBundle(nameVersion);
+               try {
+                       bundle.update();
+               } catch (BundleException e) {
+                       throw new SlcException("Cannot update " + bundle, e);
+               }
+       }
+
+       public void uninstallModule(NameVersion nameVersion) {
+               Bundle bundle = findBundle(nameVersion);
+               try {
+                       bundle.uninstall();
+               } catch (BundleException e) {
+                       throw new SlcException("Cannot uninstall " + bundle, e);
+               }
+       }
+
+       public void startModule(NameVersion nameVersion) {
+               Bundle bundle = findBundle(nameVersion);
+               try {
+                       bundle.start();
+                       // TODO: use bundle manager
+               } catch (BundleException e) {
+                       throw new SlcException("Cannot uninstall " + bundle, e);
+               }
+       }
+
+       protected Bundle findBundle(NameVersion nameVersion) {
+               Bundle[] bundles = bundleContext.getBundles();
+               for (Bundle bundle : bundles) {
+                       OsgiBundle osgiBundle = new OsgiBundle(bundle);
+                       if (osgiBundle.equals(nameVersion)) {
+                               return bundle;
+                       }
+               }
+               throw new SlcException("Could not find bundle " + nameVersion);
+       }
+
+       public void shutdown() {
+               // FIXME use framework
+               throw new UnsupportedException();
+       }
+
+       public String getDeployedSystemId() {
+               return uuid;
+       }
+
+       public DeploymentData getDeploymentData() {
+               throw new UnsupportedException();
+       }
+
+       public Distribution getDistribution() {
+               throw new UnsupportedException();
+       }
+
+       public TargetData getTargetData() {
+               throw new UnsupportedException();
+       }
+
+       public void setBundleContext(BundleContext bundleContext) {
+               this.bundleContext = bundleContext;
+       }
+
+       public void setResourceLoader(ResourceLoader resourceLoader) {
+               this.resourceLoader = resourceLoader;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/AbstractOsgiModularDistribution.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/AbstractOsgiModularDistribution.java
new file mode 100644 (file)
index 0000000..61380c0
--- /dev/null
@@ -0,0 +1,162 @@
+package org.argeo.slc.osgi.build;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.UnsupportedException;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.build.ModularDistribution;
+import org.eclipse.gemini.blueprint.context.BundleContextAware;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.springframework.beans.factory.InitializingBean;
+
+public abstract class AbstractOsgiModularDistribution implements
+               ModularDistribution, BundleContextAware, InitializingBean {
+       private final static Log log = LogFactory
+                       .getLog(AbstractOsgiModularDistribution.class);
+
+       private BundleContext bundleContext;
+       private EclipseUpdateSite eclipseUpdateSite;
+
+       /** Initialized by the object itself. */
+       private SortedMap<NameVersion, Distribution> distributions = new TreeMap<NameVersion, Distribution>();
+
+       protected abstract void fillDistributions(
+                       SortedMap<NameVersion, Distribution> distributions)
+                       throws Exception;
+
+       public Distribution getModuleDistribution(String moduleName,
+                       String moduleVersion) {
+               return distributions.get(new DefaultNameVersion(moduleName,
+                               moduleVersion));
+       }
+
+       public String getDistributionId() {
+               return bundleContext.getBundle().getSymbolicName()
+                               + "-"
+                               + bundleContext.getBundle().getHeaders()
+                                               .get(Constants.BUNDLE_VERSION);
+       }
+
+       public Set<NameVersion> listModulesNameVersions() {
+               return distributions.keySet();
+       }
+
+       public Iterator<NameVersion> nameVersions() {
+               return distributions.keySet().iterator();
+       }
+
+       public void setBundleContext(BundleContext bundleContext) {
+               this.bundleContext = bundleContext;
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               fillDistributions(distributions);
+               if (log.isDebugEnabled())
+                       log.debug("Distribution " + getName() + ":" + getVersion()
+                                       + " loaded (" + distributions.size() + " modules)");
+       }
+
+       protected String findVersion(String name) {
+               Set<String> versions = new HashSet<String>();
+               for (NameVersion key : distributions.keySet()) {
+                       if (key.getName().equals(name))
+                               versions.add(key.getVersion());
+               }
+
+               if (versions.size() == 0)
+                       throw new SlcException("Cannot find version for name " + name);
+               else if (versions.size() > 1)
+                       throw new SlcException("Found more than one version for name "
+                                       + name + ": " + versions);
+               else
+                       return versions.iterator().next();
+
+       }
+
+       public Object getModulesDescriptor(String descriptorType) {
+               if (descriptorType.equals("eclipse"))
+                       return writeEclipseUpdateSite();
+               else
+                       throw new UnsupportedException("descriptorType", descriptorType);
+       }
+
+       protected Set<NameVersion> writePlainUrlList() {
+               return distributions.keySet();
+       }
+
+       protected String writeEclipseUpdateSite() {
+               if (eclipseUpdateSite == null)
+                       throw new SlcException("No eclipse update site declared.");
+
+               StringBuffer buf = new StringBuffer("");
+               buf.append("<site>");
+
+               List<EclipseUpdateSiteCategory> usedCategories = new ArrayList<EclipseUpdateSiteCategory>();
+               for (EclipseUpdateSiteFeature feature : eclipseUpdateSite.getFeatures()) {
+
+                       String featureId = feature.getName();
+                       String featureVersion = findVersion(featureId);
+                       buf.append("<feature");
+                       buf.append(" url=\"features/").append(featureId).append('_')
+                                       .append(featureVersion).append(".jar\"");
+                       buf.append(" id=\"").append(featureId).append("\"");
+                       buf.append(" version=\"").append(featureVersion).append("\"");
+                       buf.append(">\n");
+
+                       for (EclipseUpdateSiteCategory category : feature.getCategories()) {
+                               usedCategories.add(category);
+                               buf.append("  <category name=\"").append(category.getName())
+                                               .append("\"/>\n");
+                       }
+                       buf.append("</feature>\n\n");
+               }
+
+               for (EclipseUpdateSiteCategory category : usedCategories) {
+                       buf.append("<category-def");
+                       buf.append(" name=\"").append(category.getName()).append("\"");
+                       buf.append(" label=\"").append(category.getLabel()).append("\"");
+                       buf.append(">\n");
+                       buf.append("  <description>").append(category.getDescription())
+                                       .append("</description>\n");
+                       buf.append("</category-def>\n\n");
+               }
+
+               buf.append("</site>");
+               return buf.toString();
+       }
+
+       public String getName() {
+               return bundleContext.getBundle().getSymbolicName();
+       }
+
+       public String getVersion() {
+               return bundleContext.getBundle().getHeaders()
+                               .get(Constants.BUNDLE_VERSION).toString();
+       }
+
+       @Override
+       public String toString() {
+               return new DefaultNameVersion(this).toString();
+       }
+
+       public void setEclipseUpdateSite(EclipseUpdateSite eclipseUpdateSite) {
+               this.eclipseUpdateSite = eclipseUpdateSite;
+       }
+
+       public BundleContext getBundleContext() {
+               return bundleContext;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/BundleModularDistribution.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/BundleModularDistribution.java
new file mode 100644 (file)
index 0000000..ec7d2f6
--- /dev/null
@@ -0,0 +1,81 @@
+package org.argeo.slc.osgi.build;
+
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.SortedMap;
+import java.util.StringTokenizer;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.core.build.VersionedResourceDistribution;
+import org.osgi.framework.Constants;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.ResourceLoader;
+
+public class BundleModularDistribution extends AbstractOsgiModularDistribution
+               implements ResourceLoaderAware {
+       private ResourceLoader resourceLoader;
+
+       private String libDirectory = "/lib";
+
+       protected void fillDistributions(
+                       SortedMap<NameVersion, Distribution> distributions)
+                       throws Exception {
+               Enumeration<URL> urls = (Enumeration<URL>) getBundleContext()
+                               .getBundle().findEntries(libDirectory, "*.jar", false);
+               while (urls.hasMoreElements()) {
+                       URL url = urls.nextElement();
+                       JarInputStream in = null;
+                       try {
+                               in = new JarInputStream(url.openStream());
+                               Manifest mf = in.getManifest();
+                               String name = mf.getMainAttributes().getValue(
+                                               Constants.BUNDLE_SYMBOLICNAME);
+                               // Skip additional specs such as
+                               // ; singleton:=true
+                               if (name.indexOf(';') > -1) {
+                                       name = new StringTokenizer(name, " ;").nextToken();
+                               }
+
+                               String version = mf.getMainAttributes().getValue(
+                                               Constants.BUNDLE_VERSION);
+                               DefaultNameVersion nameVersion = new DefaultNameVersion(name,
+                                               version);
+                               distributions.put(nameVersion,
+                                               new VersionedResourceDistribution(name, version,
+                                                               resourceLoader.getResource(url.toString())));
+                       } finally {
+                               IOUtils.closeQuietly(in);
+                       }
+               }
+       }
+
+       public void setLibDirectory(String libDirectory) {
+               this.libDirectory = libDirectory;
+       }
+
+       public void setResourceLoader(ResourceLoader resourceLoader) {
+               this.resourceLoader = resourceLoader;
+       }
+
+       /*
+        * @SuppressWarnings(value = { "unchecked" }) protected URL
+        * findModule(String moduleName, String version) { Enumeration<URL> urls =
+        * (Enumeration<URL>) bundleContext.getBundle() .findEntries(libDirectory,
+        * moduleName + "*", false);
+        * 
+        * if (!urls.hasMoreElements()) throw new SlcException("Cannot find module "
+        * + moduleName);
+        * 
+        * URL url = urls.nextElement();
+        * 
+        * // TODO: check version as well if (urls.hasMoreElements()) throw new
+        * SlcException("More than one module with name " + moduleName); return url;
+        * }
+        */
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSite.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSite.java
new file mode 100644 (file)
index 0000000..b8debf5
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.slc.osgi.build;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class EclipseUpdateSite {
+       private List<EclipseUpdateSiteFeature> features = new ArrayList<EclipseUpdateSiteFeature>();
+
+       public List<EclipseUpdateSiteFeature> getFeatures() {
+               return features;
+       }
+
+       public void setFeatures(List<EclipseUpdateSiteFeature> features) {
+               this.features = features;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteCategory.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteCategory.java
new file mode 100644 (file)
index 0000000..510a555
--- /dev/null
@@ -0,0 +1,32 @@
+package org.argeo.slc.osgi.build;
+
+public class EclipseUpdateSiteCategory {
+       private String name;
+       private String label;
+       private String description;
+
+       public String getLabel() {
+               return label;
+       }
+
+       public void setLabel(String label) {
+               this.label = label;
+       }
+
+       public String getDescription() {
+               return description;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteFeature.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/EclipseUpdateSiteFeature.java
new file mode 100644 (file)
index 0000000..42ded0b
--- /dev/null
@@ -0,0 +1,26 @@
+package org.argeo.slc.osgi.build;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class EclipseUpdateSiteFeature {
+       private String name;
+       private List<EclipseUpdateSiteCategory> categories = new ArrayList<EclipseUpdateSiteCategory>();
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public List<EclipseUpdateSiteCategory> getCategories() {
+               return categories;
+       }
+
+       public void setCategories(List<EclipseUpdateSiteCategory> categories) {
+               this.categories = categories;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/build/OsgiRuntimeModularDistribution.java
new file mode 100644 (file)
index 0000000..acc4bab
--- /dev/null
@@ -0,0 +1,74 @@
+package org.argeo.slc.osgi.build;
+
+import java.net.URL;
+import java.util.SortedMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.core.build.VersionedResourceDistribution;
+import org.argeo.slc.osgi.OsgiBundle;
+import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
+import org.osgi.framework.Bundle;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+
+public class OsgiRuntimeModularDistribution extends
+               AbstractOsgiModularDistribution implements ResourceLoaderAware {
+       private final static Log log = LogFactory
+                       .getLog(OsgiRuntimeModularDistribution.class);
+
+       private ResourceLoader resourceLoader;
+
+       protected void fillDistributions(
+                       SortedMap<NameVersion, Distribution> distributions)
+                       throws Exception {
+
+               String frameworkUrl = System.getProperty("osgi.framework");
+               String frameworkBaseUrl = null;
+               if (frameworkUrl != null)
+                       frameworkBaseUrl = frameworkUrl.substring(0, frameworkUrl
+                                       .lastIndexOf('/'));
+               bundles: for (Bundle bundle : getBundleContext().getBundles()) {
+                       OsgiBundle osgiBundle = new OsgiBundle(bundle);
+
+                       String originalLocation = bundle.getLocation();
+
+                       if (OsgiBundleUtils.isSystemBundle(bundle)) {
+                               continue bundles;
+                       }
+
+                       String location = originalLocation;
+                       if (originalLocation.startsWith("reference:file:"))
+                               location = originalLocation.substring("reference:".length());
+
+                       if (frameworkBaseUrl != null
+                                       && originalLocation.startsWith("initial@reference:file:")) {
+                               location = frameworkBaseUrl
+                                               + '/'
+                                               + originalLocation.substring("initial@reference:file:"
+                                                               .length());
+                       }
+
+                       try {
+                               URL url = new URL(location);
+                               Resource res = resourceLoader.getResource(url.toString());
+                               distributions.put(osgiBundle,
+                                               new VersionedResourceDistribution(osgiBundle, res));
+
+                               if (log.isTraceEnabled())
+                                       log.debug("Added url " + url + " from original location "
+                                                       + originalLocation);
+                       } catch (Exception e) {
+                               log.warn("Cannot interpret location " + location
+                                               + " of bundle " + bundle + ": " + e);
+                       }
+               }
+       }
+
+       public void setResourceLoader(ResourceLoader resourceLoader) {
+               this.resourceLoader = resourceLoader;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/deploy/OsgiResourceSet.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/deploy/OsgiResourceSet.java
new file mode 100644 (file)
index 0000000..bea3949
--- /dev/null
@@ -0,0 +1,61 @@
+package org.argeo.slc.osgi.deploy;
+
+import org.argeo.slc.core.deploy.DefaultResourceSet;
+import org.eclipse.gemini.blueprint.context.BundleContextAware;
+import org.eclipse.gemini.blueprint.io.OsgiBundleResourceLoader;
+import org.eclipse.gemini.blueprint.io.OsgiBundleResourcePatternResolver;
+import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.springframework.core.io.ResourceLoader;
+
+/**
+ * Retrieves ressources from an OSGi bundle either the active one or another one
+ * referenced by its symbolic name.
+ */
+public class OsgiResourceSet extends DefaultResourceSet implements
+               BundleContextAware {
+       private BundleContext bundleContext;
+       private Bundle bundle = null;
+       private String bundleSymbolicName = null;
+
+       private OsgiBundleResourceLoader osgiBundleResourceLoader = null;
+
+       @Override
+       public void afterPropertiesSet() throws Exception {
+               osgiBundleResourceLoader = new OsgiBundleResourceLoader(getBundle());
+               if (getResourcePatternResolver() == null)
+                       setResourcePatternResolver(new OsgiBundleResourcePatternResolver(
+                                       osgiBundleResourceLoader));
+               super.afterPropertiesSet();
+       }
+
+       public Bundle getBundle() {
+               if (bundle != null)
+                       return bundle;
+               else if (bundleSymbolicName != null)// do not cache
+                       return OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
+                                       bundleSymbolicName);
+               else
+                       // containing bundle
+                       return bundleContext.getBundle();
+       }
+
+       public void setBundleContext(BundleContext bundleContext) {
+               this.bundleContext = bundleContext;
+       }
+
+       @Override
+       public ResourceLoader getResourceLoaderToUse() {
+               return osgiBundleResourceLoader;
+       }
+
+       public void setBundle(Bundle bundle) {
+               this.bundle = bundle;
+       }
+
+       public void setBundleSymbolicName(String bundleSymbolicName) {
+               this.bundleSymbolicName = bundleSymbolicName;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/execution.xml b/legacy/org.argeo.slc.spring/src/org/argeo/slc/osgi/execution.xml
new file mode 100644 (file)
index 0000000..cc0aac0
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License, 
+       Version 2.0 (the "License"); you may not use this file except in compliance 
+       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
+       Unless required by applicable law or agreed to in writing, software distributed 
+       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
+       OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
+       the specific language governing permissions and limitations under the License. -->
+<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under 
+       the Apache License, Version 2.0 (the "License"); you may not use this file 
+       except in compliance with the License. You may obtain a copy of the License 
+       at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 
+       law or agreed to in writing, software distributed under the License is distributed 
+       on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
+       express or implied. See the License for the specific language governing permissions 
+       and limitations under the License. -->
+
+<beans xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd
+       http://www.springframework.org/schema/beans   
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <osgi:service interface="org.argeo.slc.execution.ExecutionContext"
+               ref="executionContext" />
+       <osgi:service
+               interface="org.argeo.slc.execution.ExecutionFlowDescriptorConverter"
+               ref="executionFlowDescriptorConverter" />
+
+       <osgi:reference id="callbackHandler"
+               interface="javax.security.auth.callback.CallbackHandler" cardinality="0..1" />
+
+       <bean class="org.argeo.slc.osgi.MultipleServiceExporterPostProcessor">
+               <property name="interfaces">
+                       <list>
+                               <value><![CDATA[org.argeo.slc.execution.ExecutionFlow]]></value>
+                       </list>
+               </property>
+               <property name="bundleContext" ref="bundleContext" />
+       </bean>
+
+       <bean id="osgiExecutionResources" class="org.argeo.slc.osgi.OsgiExecutionResources">
+               <property name="executionContext" ref="executionContext" />
+       </bean>
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/AbstractSystemExecution.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/AbstractSystemExecution.java
new file mode 100644 (file)
index 0000000..2c12838
--- /dev/null
@@ -0,0 +1,49 @@
+package org.argeo.slc.spring;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.api.NodeConstants;
+import org.argeo.slc.SlcException;
+
+/** Provides base method for executing code with system authorization. */
+abstract class AbstractSystemExecution {
+       private final static Log log = LogFactory.getLog(AbstractSystemExecution.class);
+       private final Subject subject = new Subject();
+
+       /** Authenticate the calling thread */
+       protected void authenticateAsSystem() {
+               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
+               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+               try {
+                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
+                       lc.login();
+               } catch (LoginException e) {
+                       throw new SlcException("Cannot login as system", e);
+               } finally {
+                       Thread.currentThread().setContextClassLoader(origClassLoader);
+               }
+               if (log.isTraceEnabled())
+                       log.trace("System authenticated");
+       }
+
+       protected void deauthenticateAsSystem() {
+               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
+               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+               try {
+                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
+                       lc.logout();
+               } catch (LoginException e) {
+                       throw new SlcException("Cannot logout as system", e);
+               } finally {
+                       Thread.currentThread().setContextClassLoader(origClassLoader);
+               }
+       }
+
+       protected Subject getSubject() {
+               return subject;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/AuthenticatedApplicationContextInitialization.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/AuthenticatedApplicationContextInitialization.java
new file mode 100644 (file)
index 0000000..40d562b
--- /dev/null
@@ -0,0 +1,65 @@
+package org.argeo.slc.spring;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.eclipse.gemini.blueprint.context.DependencyInitializationAwareBeanPostProcessor;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.support.AbstractBeanFactory;
+import org.springframework.beans.factory.support.SecurityContextProvider;
+import org.springframework.beans.factory.support.SimpleSecurityContextProvider;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Executes with a system authentication the instantiation and initialization
+ * methods of the application context where it has been defined.
+ */
+public class AuthenticatedApplicationContextInitialization extends
+               AbstractSystemExecution implements
+               DependencyInitializationAwareBeanPostProcessor, ApplicationContextAware {
+       /** If non empty, restricts to these beans */
+       private List<String> beanNames = new ArrayList<String>();
+
+       public Object postProcessBeforeInitialization(Object bean, String beanName)
+                       throws BeansException {
+               if (beanNames.size() == 0 || beanNames.contains(beanName))
+                       authenticateAsSystem();
+               return bean;
+       }
+
+       public Object postProcessAfterInitialization(Object bean, String beanName)
+                       throws BeansException {
+               if (beanNames.size() == 0 || beanNames.contains(beanName))
+                       deauthenticateAsSystem();
+               return bean;
+       }
+
+       public void setBeanNames(List<String> beanNames) {
+               this.beanNames = beanNames;
+       }
+
+       @Override
+       public void setApplicationContext(ApplicationContext applicationContext)
+                       throws BeansException {
+               if (applicationContext.getAutowireCapableBeanFactory() instanceof AbstractBeanFactory) {
+                       final AbstractBeanFactory beanFactory = ((AbstractBeanFactory) applicationContext
+                                       .getAutowireCapableBeanFactory());
+                       // retrieve subject's access control context
+                       // and set it as the bean factory security context
+                       Subject.doAs(getSubject(), new PrivilegedAction<Void>() {
+                               @Override
+                               public Void run() {
+                                       SecurityContextProvider scp = new SimpleSecurityContextProvider(
+                                                       AccessController.getContext());
+                                       beanFactory.setSecurityContextProvider(scp);
+                                       return null;
+                               }
+                       });
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AbstractSystemExecution.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AbstractSystemExecution.java
new file mode 100644 (file)
index 0000000..eb1d731
--- /dev/null
@@ -0,0 +1,49 @@
+package org.argeo.slc.spring.auth;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.api.NodeConstants;
+import org.argeo.slc.SlcException;
+
+/** Provides base method for executing code with system authorization. */
+abstract class AbstractSystemExecution {
+       private final static Log log = LogFactory.getLog(AbstractSystemExecution.class);
+       private final Subject subject = new Subject();
+
+       /** Authenticate the calling thread */
+       protected void authenticateAsSystem() {
+               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
+               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+               try {
+                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
+                       lc.login();
+               } catch (LoginException e) {
+                       throw new SlcException("Cannot login as system", e);
+               } finally {
+                       Thread.currentThread().setContextClassLoader(origClassLoader);
+               }
+               if (log.isTraceEnabled())
+                       log.trace("System authenticated");
+       }
+
+       protected void deauthenticateAsSystem() {
+               ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
+               Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+               try {
+                       LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
+                       lc.logout();
+               } catch (LoginException e) {
+                       throw new SlcException("Cannot logout as system", e);
+               } finally {
+                       Thread.currentThread().setContextClassLoader(origClassLoader);
+               }
+       }
+
+       protected Subject getSubject() {
+               return subject;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AuthenticatedApplicationContextInitialization.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/AuthenticatedApplicationContextInitialization.java
new file mode 100644 (file)
index 0000000..79f7822
--- /dev/null
@@ -0,0 +1,65 @@
+package org.argeo.slc.spring.auth;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.eclipse.gemini.blueprint.context.DependencyInitializationAwareBeanPostProcessor;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.support.AbstractBeanFactory;
+import org.springframework.beans.factory.support.SecurityContextProvider;
+import org.springframework.beans.factory.support.SimpleSecurityContextProvider;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * Executes with a system authentication the instantiation and initialization
+ * methods of the application context where it has been defined.
+ */
+public class AuthenticatedApplicationContextInitialization extends
+               AbstractSystemExecution implements
+               DependencyInitializationAwareBeanPostProcessor, ApplicationContextAware {
+       /** If non empty, restricts to these beans */
+       private List<String> beanNames = new ArrayList<String>();
+
+       public Object postProcessBeforeInitialization(Object bean, String beanName)
+                       throws BeansException {
+               if (beanNames.size() == 0 || beanNames.contains(beanName))
+                       authenticateAsSystem();
+               return bean;
+       }
+
+       public Object postProcessAfterInitialization(Object bean, String beanName)
+                       throws BeansException {
+               if (beanNames.size() == 0 || beanNames.contains(beanName))
+                       deauthenticateAsSystem();
+               return bean;
+       }
+
+       public void setBeanNames(List<String> beanNames) {
+               this.beanNames = beanNames;
+       }
+
+       @Override
+       public void setApplicationContext(ApplicationContext applicationContext)
+                       throws BeansException {
+               if (applicationContext.getAutowireCapableBeanFactory() instanceof AbstractBeanFactory) {
+                       final AbstractBeanFactory beanFactory = ((AbstractBeanFactory) applicationContext
+                                       .getAutowireCapableBeanFactory());
+                       // retrieve subject's access control context
+                       // and set it as the bean factory security context
+                       Subject.doAs(getSubject(), new PrivilegedAction<Void>() {
+                               @Override
+                               public Void run() {
+                                       SecurityContextProvider scp = new SimpleSecurityContextProvider(
+                                                       AccessController.getContext());
+                                       beanFactory.setSecurityContextProvider(scp);
+                                       return null;
+                               }
+                       });
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/SimpleRoleRegistration.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/auth/SimpleRoleRegistration.java
new file mode 100644 (file)
index 0000000..44b7b79
--- /dev/null
@@ -0,0 +1,89 @@
+package org.argeo.slc.spring.auth;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.InvalidNameException;
+import javax.naming.ldap.LdapName;
+import javax.transaction.UserTransaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.osgi.service.useradmin.Role;
+import org.osgi.service.useradmin.UserAdmin;
+
+/**
+ * Register one or many roles via a user admin service. Does nothing if the role
+ * is already registered.
+ */
+public class SimpleRoleRegistration implements Runnable {
+       private final static Log log = LogFactory
+                       .getLog(SimpleRoleRegistration.class);
+
+       private String role;
+       private List<String> roles = new ArrayList<String>();
+       private UserAdmin userAdmin;
+       private UserTransaction userTransaction;
+
+       @Override
+       public void run() {
+               try {
+                       userTransaction.begin();
+                       if (role != null && !roleExists(role))
+                               newRole(toDn(role));
+
+                       for (String r : roles)
+                               if (!roleExists(r))
+                                       newRole(toDn(r));
+                       userTransaction.commit();
+               } catch (Exception e) {
+                       try {
+                               userTransaction.rollback();
+                       } catch (Exception e1) {
+                               log.error("Cannot rollback", e1);
+                       }
+                       throw new SlcException("Cannot add roles", e);
+               }
+       }
+
+       private boolean roleExists(String role) {
+               return userAdmin.getRole(toDn(role).toString()) != null;
+       }
+
+       protected void newRole(LdapName r) {
+               userAdmin.createRole(r.toString(), Role.GROUP);
+               log.info("Added role " + r + " required by application.");
+       }
+
+       public void register(UserAdmin userAdminService, Map<?, ?> properties) {
+               this.userAdmin = userAdminService;
+               run();
+       }
+
+       protected LdapName toDn(String name) {
+               try {
+                       return new LdapName("cn=" + name + ",ou=roles,ou=node");
+               } catch (InvalidNameException e) {
+                       throw new SlcException("Badly formatted role name " + name, e);
+               }
+       }
+
+       public void setRole(String role) {
+               this.role = role;
+       }
+
+       public void setRoles(List<String> roles) {
+               this.roles = roles;
+       }
+
+       public void setUserAdmin(UserAdmin userAdminService) {
+               this.userAdmin = userAdminService;
+       }
+
+       public void setUserTransaction(UserTransaction userTransaction) {
+               this.userTransaction = userTransaction;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/BndWrapper.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/BndWrapper.java
new file mode 100644 (file)
index 0000000..8b52c9a
--- /dev/null
@@ -0,0 +1,20 @@
+package org.argeo.slc.spring.repo.osgi;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanNameAware;
+
+public class BndWrapper extends org.argeo.slc.repo.osgi.BndWrapper implements BeanNameAware {
+       private final static Log log = LogFactory.getLog(BndWrapper.class);
+
+       @Override
+       public void setBeanName(String name) {
+               if (getName() == null) {
+                       setName(name);
+               } else {
+                       if (!name.contains("#"))
+                               log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
+               }
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/MavenWrapper.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/MavenWrapper.java
new file mode 100644 (file)
index 0000000..f351a5b
--- /dev/null
@@ -0,0 +1,20 @@
+package org.argeo.slc.spring.repo.osgi;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanNameAware;
+
+public class MavenWrapper extends org.argeo.slc.repo.osgi.MavenWrapper implements BeanNameAware {
+       private final static Log log = LogFactory.getLog(MavenWrapper.class);
+
+       @Override
+       public void setBeanName(String name) {
+               if (getName() == null) {
+                       setName(name);
+               } else {
+                       if (!name.contains("#"))
+                               log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
+               }
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/UriWrapper.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/repo/osgi/UriWrapper.java
new file mode 100644 (file)
index 0000000..1b5edd1
--- /dev/null
@@ -0,0 +1,20 @@
+package org.argeo.slc.spring.repo.osgi;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanNameAware;
+
+public class UriWrapper extends org.argeo.slc.repo.osgi.UriWrapper implements BeanNameAware {
+       private final static Log log = LogFactory.getLog(UriWrapper.class);
+
+       @Override
+       public void setBeanName(String name) {
+               if (getName() == null) {
+                       setName(name);
+               } else {
+                       if (!name.contains("#"))
+                               log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
+               }
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractExecutionFlowTestcase.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractExecutionFlowTestcase.java
new file mode 100644 (file)
index 0000000..f95296a
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.spring.unit;
+
+import org.argeo.slc.execution.ExecutionFlow;
+
+public abstract class AbstractExecutionFlowTestcase extends AbstractSpringTestCase {
+       @SuppressWarnings(value = { "unchecked" })
+       protected <T extends ExecutionFlow> T executeFlow(String flowName) {
+               ExecutionFlow flow = getBean(flowName);
+               flow.run();
+               return (T) flow;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractOsgiRuntimeTestCase.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractOsgiRuntimeTestCase.java
new file mode 100644 (file)
index 0000000..734a5ec
--- /dev/null
@@ -0,0 +1,231 @@
+package org.argeo.slc.spring.unit;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.osgi.boot.OsgiBoot;
+import org.argeo.slc.SlcException;
+import org.eclipse.core.runtime.adaptor.EclipseStarter;
+import org.eclipse.gemini.blueprint.util.OsgiStringUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.springframework.context.ApplicationContext;
+
+import junit.framework.TestCase;
+
+@SuppressWarnings("restriction")
+public abstract class AbstractOsgiRuntimeTestCase extends TestCase {
+       private final static Log log = LogFactory
+                       .getLog(AbstractOsgiRuntimeTestCase.class);
+
+       protected OsgiBoot osgiBoot = null;
+
+       protected void installBundles() throws Exception {
+
+       }
+
+       public void setUp() throws Exception {
+               // To avoid xerces from the classpath being detected as the provider
+               System
+                               .setProperty("javax.xml.parsers.DocumentBuilderFactory",
+                                               "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
+               System.setProperty("javax.xml.parsers.SAXParserFactory",
+                               "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
+
+               BundleContext bundleContext = startRuntime();
+               osgiBoot = new OsgiBoot(bundleContext);
+               log.info("OSGi runtime started.");
+
+               installBundles();
+
+               List<String> bundlesToStart = getBundlesToStart();
+               osgiBoot.startBundles(bundlesToStart);
+               waitAllBundlesOk(bundlesToStart);
+               if (log.isTraceEnabled())
+                       listInstalledBundles();
+       }
+
+       public void tearDown() throws Exception {
+               osgiBoot = null;
+               stopRuntime();
+               log.info("OSGi runtime stopped.");
+       }
+
+       protected BundleContext startRuntime() throws Exception {
+               String[] args = { "-console", "-clean" };
+               BundleContext bundleContext = EclipseStarter.startup(args, null);
+               return bundleContext;
+       }
+
+       protected void stopRuntime() throws Exception {
+               EclipseStarter.shutdown();
+       }
+
+       protected List<String> getBundlesToStart() {
+               return new ArrayList<String>();
+       }
+
+       protected void listInstalledBundles() {
+               BundleContext bundleContext = osgiBoot.getBundleContext();
+               Bundle[] bundles = bundleContext.getBundles();
+               for (int i = 0; i < bundles.length; i++) {
+                       System.out.println(OsgiStringUtils.nullSafeSymbolicName(bundles[i])
+                                       + " [" + OsgiStringUtils.bundleStateAsString(bundles[i])
+                                       + "] " + bundles[i].getLocation());
+               }
+
+       }
+
+       protected Map<Bundle, ApplicationContext> getOsgiApplicationContexts()
+                       throws Exception {
+               Map<Bundle, ApplicationContext> map = new HashMap<Bundle, ApplicationContext>();
+               BundleContext bundleContext = osgiBoot.getBundleContext();
+               ServiceReference[] srs = bundleContext.getServiceReferences(
+                               ApplicationContext.class.getName(), null);
+               for (ServiceReference sr : srs) {
+                       ApplicationContext context = (ApplicationContext) bundleContext
+                                       .getService(sr);
+                       map.put(sr.getBundle(), context);
+               }
+               return map;
+       }
+
+       /** Wait for all bundles to be either RESOLVED or ACTIVE. */
+       protected void waitAllBundlesOk(List<String> bundlesToStart) {
+               BundleContext bundleContext = osgiBoot.getBundleContext();
+               long begin = System.currentTimeMillis();
+               long duration = 0;
+               boolean allBundlesOk = true;
+               StringBuffer badBundles = null;
+               while (duration < getResolvedTimeout()) {
+                       badBundles = new StringBuffer();
+                       for (Bundle bundle : bundleContext.getBundles()) {
+                               if (bundle.getSymbolicName() != null
+                                               && bundle.getSymbolicName().startsWith(
+                                                               "org.eclipse.jdt")) {
+                                       // don't check Eclipse SDK bundles
+                                       continue;
+                               }
+
+                               if (bundle.getState() == Bundle.INSTALLED) {
+                                       allBundlesOk = false;
+                                       badBundles
+                                                       .append(OsgiStringUtils
+                                                                       .nullSafeSymbolicName(bundle)
+                                                                       + " ["
+                                                                       + OsgiStringUtils
+                                                                                       .bundleStateAsString(bundle) + "]");
+                               }
+
+                               if (bundlesToStart.contains(bundle.getSymbolicName())
+                                               && bundle.getState() != Bundle.ACTIVE) {
+                                       allBundlesOk = false;
+                                       badBundles.append(OsgiStringUtils
+                                                       .nullSafeSymbolicName(bundle)
+                                                       + " ["
+                                                       + OsgiStringUtils.bundleStateAsString(bundle)
+                                                       + "]\n");
+                               }
+                       }
+
+                       if (allBundlesOk)
+                               break;// while
+
+                       sleep(1000);
+
+                       duration = System.currentTimeMillis() - begin;
+               }
+
+               if (!allBundlesOk) {
+                       listInstalledBundles();
+                       throw new SlcException(
+                                       "Some bundles are not at the proper status:\n" + badBundles);
+               }
+       }
+
+       /**
+        * Make sure that the application context of the started bundles starting
+        * with this prefix are properly initialized
+        */
+       protected void assertStartedBundlesApplicationContext(
+                       String bundleSymbolicNamesPrefix) {
+               List<String> bundlesToStart = getBundlesToStart();
+               for (String bundleSName : bundlesToStart) {
+                       if (bundleSName.startsWith(bundleSymbolicNamesPrefix))
+                               assertBundleApplicationContext(bundleSName);
+               }
+       }
+
+       /**
+        * Make sure that the application context of this bundle is properly
+        * initialized
+        */
+       protected void assertBundleApplicationContext(String bundleSymbolicName) {
+               String filter = "(Bundle-SymbolicName=" + bundleSymbolicName + ")";
+               // Wait for application context to be ready
+               try {
+                       ServiceReference[] srs = getServiceRefSynchronous(
+                                       ApplicationContext.class.getName(), filter);
+                       if (srs == null)
+                               throw new SlcException("No application context for "
+                                               + bundleSymbolicName);
+               } catch (InvalidSyntaxException e) {
+                       throw new SlcException(
+                                       "Unexpected exception when looking for application context for bundle "
+                                                       + bundleSymbolicName, e);
+               }
+               log.info("Application context of bundle " + bundleSymbolicName
+                               + " is initalized.");
+       }
+
+       protected ServiceReference[] getServiceRefSynchronous(String clss,
+                       String filter) throws InvalidSyntaxException {
+               // FIXME: factorize
+               if (log.isTraceEnabled())
+                       log.debug("Filter: '" + filter + "'");
+               ServiceReference[] sfs = null;
+               boolean waiting = true;
+               long begin = System.currentTimeMillis();
+               do {
+                       sfs = getBundleContext().getServiceReferences(clss, filter);
+
+                       if (sfs != null)
+                               waiting = false;
+
+                       sleep(100);
+                       if (System.currentTimeMillis() - begin > getDefaultTimeout())
+                               throw new SlcException("Search of services " + clss
+                                               + " with filter " + filter + " timed out.");
+               } while (waiting);
+
+               return sfs;
+       }
+
+       protected BundleContext getBundleContext() {
+               return osgiBoot.getBundleContext();
+       }
+
+       /** Default is 30s */
+       protected long getResolvedTimeout() {
+               return 30 * 1000l;
+       }
+
+       /** Default is 10s */
+       protected long getDefaultTimeout() {
+               return 10 * 1000l;
+       }
+
+       final protected void sleep(long duration) {
+               try {
+                       Thread.sleep(1000);
+               } catch (InterruptedException e) {
+                       // silent
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractSpringTestCase.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/AbstractSpringTestCase.java
new file mode 100644 (file)
index 0000000..ec532eb
--- /dev/null
@@ -0,0 +1,100 @@
+package org.argeo.slc.spring.unit;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.beans.factory.BeanFactoryUtils;
+import org.springframework.beans.factory.ListableBeanFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import junit.framework.TestCase;
+
+/** Helper for tests using a Spring application co,text. */
+public abstract class AbstractSpringTestCase extends TestCase {
+       protected final Log log = LogFactory.getLog(getClass());
+       private ConfigurableApplicationContext context;
+
+       /**
+        * Gets (and create if necessary) the application context to use. Default
+        * implementation uses a class path xml application context and calls
+        * {@link #getApplicationContextLocation()}.
+        */
+       protected ConfigurableApplicationContext getContext() {
+               if (context == null) {
+                       context = new ClassPathXmlApplicationContext(
+                                       getApplicationContextLocation());
+                       if (getIsStartContext())
+                               context.start();
+               }
+               return context;
+       }
+
+       @Override
+       protected void tearDown() throws Exception {
+               if (context != null && context.isActive())
+                       context.close();
+               super.tearDown();
+       }
+
+       /** Whether the context should be started after being created. */
+       protected Boolean getIsStartContext() {
+               return false;
+       }
+
+       /** Returns a bean from the underlying context */
+       @SuppressWarnings(value = { "unchecked" })
+       protected <T> T getBean(String beanId) {
+               return (T) getContext().getBean(beanId);
+       }
+
+       protected <T> T getBean(Class<? extends T> clss) {
+               T bean = loadSingleFromContext(getContext(), clss);
+               if (bean == null) {
+                       throw new SlcException("Cannot retrieve a unique bean of type "
+                                       + clss);
+               } else {
+                       return bean;
+               }
+       }
+
+       /**
+        * Th location of the application to load. The default implementation
+        * returns <i>applicationContext.xml</i> found in the same package as the
+        * test.
+        */
+       protected String getApplicationContextLocation() {
+               return inPackage("applicationContext.xml");
+       }
+
+       /**
+        * Prefixes the package of the class after converting the '.' to '/' in
+        * order to have a resource path.
+        */
+       protected String inPackage(String suffix) {
+               String prefix = getClass().getPackage().getName().replace('.', '/');
+               return prefix + '/' + suffix;
+       }
+
+       @SuppressWarnings(value = { "unchecked" })
+       protected <T> T loadSingleFromContext(ListableBeanFactory context,
+                       Class<T> clss) {
+               Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
+                               context, clss, false, false);
+               if (beans.size() == 1) {
+                       return beans.values().iterator().next();
+               } else if (beans.size() > 1) {
+                       if (log.isDebugEnabled()) {
+                               log
+                                               .debug(("Found more that on bean for type " + clss
+                                                               + ": " + beans.keySet()));
+                       }
+                       return null;
+               } else {
+                       return null;
+               }
+       }
+
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/ExecutionFlowDescriptorTestUtils.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/ExecutionFlowDescriptorTestUtils.java
new file mode 100644 (file)
index 0000000..5e504f6
--- /dev/null
@@ -0,0 +1,58 @@
+package org.argeo.slc.spring.unit;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.argeo.slc.core.execution.DefaultExecutionSpec;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValue;
+import org.argeo.slc.execution.RefValueChoice;
+import org.argeo.slc.primitive.PrimitiveAccessor;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveValue;
+import org.argeo.slc.runtime.test.BasicTestData;
+
+public class ExecutionFlowDescriptorTestUtils {
+       public static ExecutionFlowDescriptor createSimpleExecutionFlowDescriptor() {
+               ExecutionFlowDescriptor flowDescriptor = new ExecutionFlowDescriptor();
+               flowDescriptor.setName("simpleFlow");
+               flowDescriptor.setDescription("my description");
+
+               Map<String, Object> values = new HashMap<String, Object>();
+               values.put("primitiveInteger", new PrimitiveValue(
+                               PrimitiveAccessor.TYPE_INTEGER, 100));
+
+               RefValue refValue = new RefValue("002");
+               values.put("ref1", refValue);
+               flowDescriptor.setValues(values);
+
+               flowDescriptor.setExecutionSpec(createRelatedSimpleSpec());
+               return flowDescriptor;
+       }
+
+       protected static DefaultExecutionSpec createRelatedSimpleSpec() {
+               DefaultExecutionSpec spec = new DefaultExecutionSpec();
+               spec.setBeanName("simpleSpec");
+               Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
+
+               PrimitiveSpecAttribute primitiveInteger = new PrimitiveSpecAttribute();
+               primitiveInteger.setType(PrimitiveAccessor.TYPE_INTEGER);
+               primitiveInteger.setValue(50);
+               attributes.put("primitiveInteger", primitiveInteger);
+
+               RefSpecAttribute ref1 = new RefSpecAttribute();
+               ref1.setTargetClass(BasicTestData.class);
+               ref1.setChoices(new ArrayList<RefValueChoice>());
+               ref1.getChoices().add(new RefValueChoice("001", "desc"));
+               ref1.getChoices().add(new RefValueChoice("002", null));
+               ref1.getChoices().add(new RefValueChoice("003", null));
+               attributes.put("ref1", ref1);
+
+               spec.setAttributes(attributes);
+
+               return spec;
+       }
+}
diff --git a/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/UnitUtils.java b/legacy/org.argeo.slc.spring/src/org/argeo/slc/spring/unit/UnitUtils.java
new file mode 100644 (file)
index 0000000..1e69adf
--- /dev/null
@@ -0,0 +1,42 @@
+package org.argeo.slc.spring.unit;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+public abstract class UnitUtils {
+       public static void assertDateSec(Date expected, Date reached) {
+               if (expected == null) {
+                       assertNull(reached);
+                       return;
+               } else {
+                       assertNotNull(reached);
+               }
+
+               Calendar expectedCal = new GregorianCalendar();
+               expectedCal.setTime(expected);
+               Calendar reachedCal = new GregorianCalendar();
+               reachedCal.setTime(reached);
+               assertEquals(expectedCal.get(Calendar.YEAR), reachedCal
+                               .get(Calendar.YEAR));
+               assertEquals(expectedCal.get(Calendar.MONTH), reachedCal
+                               .get(Calendar.MONTH));
+               assertEquals(expectedCal.get(Calendar.DATE), reachedCal
+                               .get(Calendar.DATE));
+               assertEquals(expectedCal.get(Calendar.HOUR_OF_DAY), reachedCal
+                               .get(Calendar.HOUR_OF_DAY));
+               assertEquals(expectedCal.get(Calendar.MINUTE), reachedCal
+                               .get(Calendar.MINUTE));
+               assertEquals(expectedCal.get(Calendar.SECOND), reachedCal
+                               .get(Calendar.SECOND));
+       }
+
+       private UnitUtils() {
+
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/.classpath b/legacy/org.argeo.slc.support/.classpath
new file mode 100644 (file)
index 0000000..70b08e8
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" output="target/classes" path="src"/>
+       <classpathentry kind="src" path="ext/test"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/legacy/org.argeo.slc.support/.gitignore b/legacy/org.argeo.slc.support/.gitignore
new file mode 100644 (file)
index 0000000..09e3bc9
--- /dev/null
@@ -0,0 +1,2 @@
+/bin/
+/target/
diff --git a/legacy/org.argeo.slc.support/.project b/legacy/org.argeo.slc.support/.project
new file mode 100644 (file)
index 0000000..174f70d
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.support</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.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/legacy/org.argeo.slc.support/META-INF/.gitignore b/legacy/org.argeo.slc.support/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/legacy/org.argeo.slc.support/bnd.bnd b/legacy/org.argeo.slc.support/bnd.bnd
new file mode 100644 (file)
index 0000000..fc72621
--- /dev/null
@@ -0,0 +1,8 @@
+Import-Package: org.apache.commons.logging,\
+org.dbunit.*;resolution:="optional",\
+junit.framework;resolution:="optional",\
+javax.mail.*;resolution:="optional",\
+org.apache.commons.vfs.*,\
+javax.swing.plaf.metal,\
+org.osgi.*;version=0.0.0,\
+*
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.support/ext/test/log4j.properties b/legacy/org.argeo.slc.support/ext/test/log4j.properties
new file mode 100644 (file)
index 0000000..0133bab
--- /dev/null
@@ -0,0 +1,22 @@
+# Set root logger level to DEBUG and its only appender to A1.\r
+log4j.rootLogger=WARN, console\r
+\r
+## Levels\r
+# Slc\r
+log4j.logger.org.argeo=DEBUG\r
+\r
+# Castor\r
+log4j.logger.org.exolab.castor=WARN\r
+\r
+# Spring\r
+log4j.logger.org.springframework=WARN\r
+\r
+\r
+## Appenders\r
+# A1 is set to be a ConsoleAppender.\r
+log4j.appender.console=org.apache.log4j.ConsoleAppender\r
+\r
+# A1 uses PatternLayout.\r
+log4j.appender.console.layout=org.apache.log4j.PatternLayout\r
+log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n\r
+\r
diff --git a/legacy/org.argeo.slc.support/ext/test/org/argeo/slc/diff/LineTokenizerTest.java b/legacy/org.argeo.slc.support/ext/test/org/argeo/slc/diff/LineTokenizerTest.java
new file mode 100644 (file)
index 0000000..58ed61a
--- /dev/null
@@ -0,0 +1,53 @@
+package org.argeo.slc.diff;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class LineTokenizerTest extends TestCase {
+       public void testSimple() throws Exception {
+               testAndAssert("a,b,c", new String[] { "a", "b", "c" });
+               testAndAssert("hello,bonjour,hallo,priviet", new String[] { "hello",
+                               "bonjour", "hallo", "priviet" });
+       }
+
+       public void testTricky() throws Exception {
+               testAndAssert("alone", new String[] { "alone" });
+               testAndAssert("", new String[] { "" });
+
+               testAndAssert(",hello,bonjour,hallo,priviet", new String[] { "",
+                               "hello", "bonjour", "hallo", "priviet" });
+               testAndAssert("hello,bonjour,,hallo,priviet", new String[] { "hello",
+                               "bonjour", "", "hallo", "priviet" });
+               testAndAssert("hello,bonjour,hallo,priviet,", new String[] { "hello",
+                               "bonjour", "hallo", "priviet", "" });
+               testAndAssert(",hello,,bonjour,hallo,,,,priviet,", new String[] { "",
+                               "hello", "", "bonjour", "hallo", "", "", "", "priviet", "" });
+
+               testAndAssert(",,,", new String[] { "", "", "", "" });
+       }
+
+       public void testComplex() throws Exception {
+               testAndAssert("a#b#c", '#', "", new String[] { "a", "b", "c" });
+               testAndAssert("hello!bonjour!hallo!priviet", '!', "", new String[] {
+                               "hello", "bonjour", "hallo", "priviet" });
+
+               testAndAssert("hello,,bonjour,,hallo,priviet", ',', "<EMPTY>",
+                               new String[] { "hello", "<EMPTY>", "bonjour", "<EMPTY>",
+                                               "hallo", "priviet" });
+       }
+
+       private void testAndAssert(String str, String[] expected) {
+               testAndAssert(str, ',', "", expected);
+       }
+
+       private void testAndAssert(String str, Character sep, String noValueStr,
+                       String[] expected) {
+               List<String> res = LineTokenizer.tokenize(str, sep, noValueStr);
+               assertEquals("Size", expected.length, res.size());
+               for (int i = 0; i < res.size(); i++) {
+                       String token = res.get(i);
+                       assertEquals("Value@" + i, expected[i], token);
+               }
+       }
+}
diff --git a/legacy/org.argeo.slc.support/pom.xml b/legacy/org.argeo.slc.support/pom.xml
new file mode 100644 (file)
index 0000000..06f048d
--- /dev/null
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>legacy</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.support</artifactId>
+       <name>SLC Third Party Support</name>
+       <dependencies>
+               <!-- SLC Runtime -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.runtime</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.spring</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DataInterpreter.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DataInterpreter.java
new file mode 100644 (file)
index 0000000..0f2705d
--- /dev/null
@@ -0,0 +1,20 @@
+package org.argeo.slc.diff;
+
+/**
+ * Converts data into a format better adapted for comparison. It is typically
+ * used to convert <code>String</code> into typed format such as
+ * <code>BigDecimal</code>
+ */
+public interface DataInterpreter {
+       /**
+        * Converts data
+        * 
+        * @param key
+        *            any object used to differentiate the type of data (e.g.
+        *            column, path)
+        * @param value
+        *            the data to convert
+        * @return the converted object
+        */
+       public Object convert(Object key, Object value);
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/Diff.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/Diff.java
new file mode 100644 (file)
index 0000000..6bb5f6d
--- /dev/null
@@ -0,0 +1,10 @@
+package org.argeo.slc.diff;
+
+import org.springframework.core.io.Resource;
+
+/** A comparator providing structured information about the differences found. */
+public interface Diff {
+       /** Performs the comparison. */
+       public void compare(Resource expected, Resource reached,
+                       DiffResult diffResult);
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssue.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssue.java
new file mode 100644 (file)
index 0000000..b390d68
--- /dev/null
@@ -0,0 +1,43 @@
+package org.argeo.slc.diff;
+
+/** The root class for issues which happened during a diff. */
+public abstract class DiffIssue implements Comparable<DiffIssue> {
+       /** The position of this issue. */
+       // Was final and is not anymore in order to persist in hibernate
+       protected DiffPosition position;
+
+       // hibernate
+       private long id;
+
+       /** Constructor */
+       public DiffIssue(DiffPosition position) {
+               super();
+               this.position = position;
+       }
+
+       public int compareTo(DiffIssue o) {
+               return position.compareTo(o.position);
+       }
+
+       /** The position of this issue within the test file */
+       public DiffPosition getPosition() {
+               return position;
+       }
+
+       // Hibernate
+       @SuppressWarnings("unused")
+       private void setId(long id) {
+               this.id = id;
+       }
+
+       @SuppressWarnings("unused")
+       private long getId() {
+               return id;
+       }
+
+       @SuppressWarnings("unused")
+       private void setPosition(DiffPosition position) {
+               this.position = position;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssueKey.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffIssueKey.java
new file mode 100644 (file)
index 0000000..c9dde85
--- /dev/null
@@ -0,0 +1,37 @@
+package org.argeo.slc.diff;
+
+/** Intermediate class that can hold the key to be displayed. */
+public abstract class DiffIssueKey extends DiffIssue {
+       /** The position of this issue. */
+       protected DiffKey key;
+
+       /** Constructor without key */
+       public DiffIssueKey(DiffPosition position) {
+               super(position);
+       }
+
+       /** Constructor with key */
+       public DiffIssueKey(DiffPosition position, DiffKey key) {
+               super(position);
+               this.key = key;
+       }
+
+       public Object getKey() {
+               return key;
+       }
+
+       @Override
+       public String toString() {
+               if (key != null) {
+                       return key.toString();
+               } else {
+                       return "";
+               }
+       }
+
+       // Hibernate
+       @SuppressWarnings("unused")
+       private void setKey(DiffKey key) {
+               this.key = key;
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffKey.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffKey.java
new file mode 100644 (file)
index 0000000..89a3496
--- /dev/null
@@ -0,0 +1,9 @@
+package org.argeo.slc.diff;
+
+/**
+ * Object able to uniquely identify an atomic diff part. Used to identify
+ * missings and left-overs.
+ */
+public interface DiffKey {
+       public String toString();
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissing.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissing.java
new file mode 100644 (file)
index 0000000..adea313
--- /dev/null
@@ -0,0 +1,26 @@
+package org.argeo.slc.diff;
+
+/**
+ * A value missing in one of the file. If its position is related to expected,
+ * this means it is a left over in the reached, if its position is related to
+ * the reached it means that it is missing from the reached. If the value is
+ * null it means that the entire line is missing.
+ */
+public class DiffMissing extends DiffIssueKey {
+
+       public DiffMissing(DiffPosition position, DiffKey key) {
+               super(position);
+               super.key = key;
+       }
+
+       @Override
+       public String toString() {
+               if (position.relatedFile == RelatedFile.EXPECTED) {
+                       return position + ": left over " + super.toString();
+               } else if (position.relatedFile == RelatedFile.REACHED) {
+                       return position + ": missing " + super.toString();
+               }
+               return super.toString();
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissingXml.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffMissingXml.java
new file mode 100644 (file)
index 0000000..c182237
--- /dev/null
@@ -0,0 +1,43 @@
+package org.argeo.slc.diff;
+
+/**
+ * <code>DiffMissing</code> using the XPath of the position as
+ * <code>DiffKey</code>
+ */
+public class DiffMissingXml extends DiffMissing {
+
+       public DiffMissingXml(XPathDiffPosition position) {
+               super(position, new DiffKeyXml(position.getXPath()));
+       }
+
+       /** Implementation of <code>DiffKey</code> based on an XPath string. */
+       protected static class DiffKeyXml implements DiffKey {
+               private final String xPath;
+
+               public DiffKeyXml(String xPath) {
+                       this.xPath = xPath;
+               }
+
+               public String getXPath() {
+                       return xPath;
+               }
+
+               @Override
+               public String toString() {
+                       return xPath;
+               }
+
+               @Override
+               public boolean equals(Object obj) {
+                       if (!(obj instanceof DiffKeyXml))
+                               return false;
+                       return xPath.equals(((DiffKeyXml) obj).xPath);
+               }
+
+               @Override
+               public int hashCode() {
+                       return xPath.hashCode();
+               }
+
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffNotMatched.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffNotMatched.java
new file mode 100644 (file)
index 0000000..eba911f
--- /dev/null
@@ -0,0 +1,75 @@
+package org.argeo.slc.diff;
+
+import org.argeo.slc.SlcException;
+
+/** Diff issue where reached and expected values are different. */
+public class DiffNotMatched extends DiffIssueKey {
+
+       // To enable hibernate persistance, these object cannot be final
+       // private final Object expected;
+       // private final Object reached;
+
+       private Object expected;
+       private Object reached;
+
+       public DiffNotMatched(DiffPosition position, Object expected, Object reached) {
+               super(position);
+               this.expected = expected;
+               this.reached = reached;
+       }
+
+       public DiffNotMatched(DiffPosition position, Object expected,
+                       Object reached, DiffKey key) {
+               super(position, key);
+               this.expected = expected;
+               this.reached = reached;
+       }
+
+       public Object getExpected() {
+               return expected;
+       }
+
+       public Object getReached() {
+               return reached;
+       }
+
+       @Override
+       public String toString() {
+               String result = position + ": not matched " + expected + " <> "
+                               + reached;
+               if (super.key != null) {
+                       result = result + " - Key: " + super.toString();
+               }
+
+               return result;
+       }
+
+       @SuppressWarnings("unused")
+       private String getExpectedStr() {
+               if (expected instanceof String)
+                       return (String) expected;
+               else
+                       throw new SlcException(
+                                       "Object 'expected' is of wrong type. Must be a String");
+       }
+
+       @SuppressWarnings("unused")
+       private String getReachedStr() {
+               if (reached instanceof String)
+                       return (String) reached;
+               else
+                       throw new SlcException(
+                                       "Object 'reached' is of wrong type. Must be a String");
+       }
+
+       @SuppressWarnings("unused")
+       private void setReachedStr(String reachedStr) {
+               this.reached = reachedStr;
+       }
+
+       @SuppressWarnings("unused")
+       private void setExpectedStr(String expectedStr) {
+               this.expected = expectedStr;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffPosition.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffPosition.java
new file mode 100644 (file)
index 0000000..9f38d88
--- /dev/null
@@ -0,0 +1,32 @@
+package org.argeo.slc.diff;
+
+/** The position of a diff issue within the test resource. */
+public abstract class DiffPosition implements Comparable<DiffPosition> {
+       protected RelatedFile relatedFile;
+
+       public DiffPosition(RelatedFile relatedFile) {
+               super();
+               this.relatedFile = relatedFile;
+       }
+
+       // For Hibernate
+       DiffPosition() {
+       }
+
+       public RelatedFile getRelatedFile() {
+               return relatedFile;
+       }
+
+       // Added to enable the new data model for persisting TabularDiffTestResult
+       @SuppressWarnings("unused")
+       private Boolean getIsReached() {
+               return relatedFile.equals(RelatedFile.REACHED);
+       }
+
+       @SuppressWarnings("unused")
+       private void setIsReached(Boolean isReached) {
+               this.relatedFile = (isReached ? RelatedFile.REACHED
+                               : RelatedFile.EXPECTED);
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffResult.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/DiffResult.java
new file mode 100644 (file)
index 0000000..8c0f9e2
--- /dev/null
@@ -0,0 +1,10 @@
+package org.argeo.slc.diff;
+
+/**
+ * The result of a diff, to be subclassed in order to provide richer information
+ */
+public interface DiffResult {
+       /** Adds a diff issue */
+       public void addDiffIssue(DiffIssue diffIssue);
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/KeyColumnsDiff.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/KeyColumnsDiff.java
new file mode 100644 (file)
index 0000000..7647321
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.diff;
+
+import java.util.List;
+
+/**
+ * Diff which is based on comparison of multiple-key atomic elements (typically
+ * columns in a tabular content)
+ */
+public interface KeyColumnsDiff extends Diff {
+       /** $The list of key columns. */
+       List<String> getKeyColumns();
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/LineTokenizer.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/LineTokenizer.java
new file mode 100644 (file)
index 0000000..fed4c37
--- /dev/null
@@ -0,0 +1,96 @@
+package org.argeo.slc.diff;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Parses a string as a vector of strings according to a separator, dealing
+ * properly with missing values. This is intended to be used instead of the
+ * standard StringTokenizer, which does not deal well with empty values.
+ * Contrary to the StringTokenizer the provided String is parsed in the
+ * constructor and the values stored as a property. This should therefore not be
+ * used to parse long strings. No reference to the argument passed in
+ * constructor is kept.
+ */
+public class LineTokenizer {
+       private final List<String> tokens;
+
+       /** Complete constructor. */
+       public LineTokenizer(String stringToParse, Character separator,
+                       String noValueString) {
+               this.tokens = parse(stringToParse, separator, noValueString);
+       }
+
+       /**
+        * Parse the string as a vector of strings. Can be overridden in order to
+        * provide another implementation.
+        */
+       protected List<String> parse(final String stringToParse,
+                       final char separator, final String noValueString) {
+               // Init
+               final int NULL = -1;
+               List<String> res = new ArrayList<String>();
+               final char[] array = stringToParse.toCharArray();
+               int lastSeparatorIndex = NULL;
+
+               // Loop on chars
+               for (int currIndex = 0; currIndex < array.length; currIndex++) {
+                       char c = array[currIndex];
+                       if (c == separator) {
+                               if (currIndex == 0) {
+                                       // first char is a separator
+                                       res.add(new String(noValueString));
+                                       lastSeparatorIndex = 0;
+                               } else if (lastSeparatorIndex == NULL) {
+                                       // first separator found
+                                       res.add(new String(array, 0, currIndex));
+                                       lastSeparatorIndex = currIndex;
+                               } else if (lastSeparatorIndex != NULL
+                                               && (lastSeparatorIndex == (currIndex - 1))) {
+                                       // consecutive separators
+                                       res.add(new String(noValueString));
+                                       lastSeparatorIndex = currIndex;
+                               } else {
+                                       // simple case
+                                       res.add(new String(array, lastSeparatorIndex + 1, currIndex
+                                                       - lastSeparatorIndex - 1));
+                                       lastSeparatorIndex = currIndex;
+                               }
+                       }
+               }
+
+               // Finalize
+               if (lastSeparatorIndex == NULL) {
+                       // no separator found
+                       res.add(new String(stringToParse));
+               } else if (lastSeparatorIndex == (array.length - 1)) {
+                       // last char is a separator
+                       res.add(new String(noValueString));
+               } else {
+                       // last token
+                       res.add(new String(array, lastSeparatorIndex + 1, array.length
+                                       - lastSeparatorIndex - 1));
+               }
+               return res;
+       }
+
+       /** The tokens. */
+       public List<String> getTokens() {
+               return tokens;
+       }
+
+       /** Parse */
+       public static List<String> tokenize(String stringToParse,
+                       Character separator, String noValueString) {
+               LineTokenizer lt = new LineTokenizer(stringToParse, separator,
+                               noValueString);
+               return lt.getTokens();
+       }
+
+       /** Parse, using the empty string as no value string. */
+       public static List<String> tokenize(String stringToParse,
+                       Character separator) {
+               return tokenize(stringToParse, separator, "");
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/RelatedFile.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/RelatedFile.java
new file mode 100644 (file)
index 0000000..09b1033
--- /dev/null
@@ -0,0 +1,9 @@
+package org.argeo.slc.diff;
+
+/** Enumeration of the types of resource tested. */
+public enum RelatedFile {
+       /** The expected resource */
+       EXPECTED,
+       /** The reached resource */
+       REACHED
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/TableDiffPosition.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/TableDiffPosition.java
new file mode 100644 (file)
index 0000000..a683843
--- /dev/null
@@ -0,0 +1,86 @@
+package org.argeo.slc.diff;
+
+import org.argeo.slc.UnsupportedException;
+
+/**
+ * A diff position within a table structure such a CSV file or an SQL result
+ * set.
+ */
+public class TableDiffPosition extends DiffPosition {
+       private Integer line;
+       /** Can be null */
+       private Integer column;
+       /** Can be null */
+       private String columnName;
+
+       public TableDiffPosition(RelatedFile relatedFile, Integer line,
+                       Integer column, String columnName) {
+               super(relatedFile);
+               this.line = line;
+               this.column = column;
+               this.columnName = columnName;
+       }
+
+       @SuppressWarnings("unused")
+       private TableDiffPosition() {
+       }
+
+       public Integer getLine() {
+               return line;
+       }
+
+       public Integer getColumn() {
+               return column;
+       }
+
+       public String getColumnName() {
+               return columnName;
+       }
+
+       public int compareTo(DiffPosition dp) {
+               if (!(dp instanceof TableDiffPosition))
+                       throw new UnsupportedException("position", dp);
+
+               TableDiffPosition o = (TableDiffPosition) dp;
+               if (relatedFile.equals(o.relatedFile)) {
+                       if (line == o.line) {
+                               return column.compareTo(o.column);
+                       } else {
+                               return line.compareTo(o.line);
+                       }
+               } else {
+                       return relatedFile.compareTo(o.relatedFile);
+               }
+       }
+
+       @Override
+       public String toString() {
+               StringBuffer buf = new StringBuffer("");
+               buf.append(relatedFile).append('[').append(line);
+               if (column != null) {
+                       buf.append(',').append(column);
+                       if (columnName != null) {
+                               buf.append('-').append(columnName);
+                       }
+               }
+               buf.append(']');
+               return buf.toString();
+       }
+
+       // Hibernate
+       @SuppressWarnings("unused")
+       private void setLine(Integer line) {
+               this.line = line;
+       }
+
+       @SuppressWarnings("unused")
+       private void setColumn(Integer column) {
+               this.column = column;
+       }
+
+       @SuppressWarnings("unused")
+       private void setColumnName(String columnName) {
+               this.columnName = columnName;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/Tolerance.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/Tolerance.java
new file mode 100644 (file)
index 0000000..6bddd1d
--- /dev/null
@@ -0,0 +1,18 @@
+package org.argeo.slc.diff;
+
+/** Compares objects, eventually using tolerance mechanisms. */
+public interface Tolerance {
+       /**
+        * Compares objects
+        * 
+        * @param key
+        *            any object used to differentiate the type of data (e.g.
+        *            column, path)
+        * @param expected
+        *            the expected value
+        * @param reached
+        *            the reached value
+        * @return the converted object
+        */
+       public Boolean compare(Object key, Object expected, Object reached);
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/ToleranceDiff.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/ToleranceDiff.java
new file mode 100644 (file)
index 0000000..8260889
--- /dev/null
@@ -0,0 +1,10 @@
+package org.argeo.slc.diff;
+
+import java.util.Map;
+
+/** A diff which can manage tolerances. */
+public interface ToleranceDiff extends Diff {
+
+       /** Get tolerances, key is the column name. */
+       public Map<String, String> getTolerances();
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/XPathDiffPosition.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/XPathDiffPosition.java
new file mode 100644 (file)
index 0000000..b119421
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.slc.diff;
+
+import org.argeo.slc.UnsupportedException;
+
+/** A diff position within an Xml file. <b>NOT YET IMPLEMENTED</b>. */
+public class XPathDiffPosition extends DiffPosition {
+
+       private String xPath;
+
+       public XPathDiffPosition(RelatedFile relatedFile, String path) {
+               super(relatedFile);
+               xPath = path;
+       }
+
+       public int compareTo(DiffPosition dp) {
+               if (!(dp instanceof XPathDiffPosition))
+                       throw new UnsupportedException("position", dp);
+
+               XPathDiffPosition o = (XPathDiffPosition) dp;
+               if (relatedFile.equals(o.relatedFile)) {
+                       return xPath.compareTo(o.xPath);
+               } else {
+                       return relatedFile.compareTo(o.relatedFile);
+               }
+       }
+
+       public String getXPath() {
+               return xPath;
+       }
+
+       @Override
+       public String toString() {
+               return xPath;
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/package.html b/legacy/org.argeo.slc.support/src/org/argeo/slc/diff/package.html
new file mode 100644 (file)
index 0000000..a58e685
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+Abstraction of diff comparison with structured results.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/AbstractJschTask.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/AbstractJschTask.java
new file mode 100644 (file)
index 0000000..59c0acf
--- /dev/null
@@ -0,0 +1,140 @@
+package org.argeo.slc.jsch;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.PrivilegedAction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Logger;
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.UserAuthGSSAPIWithMIC;
+
+public abstract class AbstractJschTask implements Runnable {
+       private final Log log = LogFactory.getLog(getClass());
+
+       private SshTarget sshTarget;
+
+       protected Session openSession() {
+               if (sshTarget.getSession() != null) {
+                       Session session = sshTarget.getSession();
+                       if (session.isConnected()) {
+                               if (log.isTraceEnabled())
+                                       log.debug("Using cached session to " + getSshTarget() + " via SSH");
+                               return session;
+                       }
+               }
+
+               try {
+                       JSch jsch = new JSch();
+                       if (sshTarget.getUsePrivateKey() && sshTarget.getLocalPrivateKey().exists())
+                               jsch.addIdentity(sshTarget.getLocalPrivateKey().getAbsolutePath());
+                       Session session = jsch.getSession(getSshTarget().getUser(), getSshTarget().getHost(),
+                                       getSshTarget().getPort());
+
+                       session.setUserInfo(getSshTarget().getUserInfo());
+                       session.setConfig("userauth.gssapi-with-mic", UserAuthGSSAPIWithMIC.class.getName());
+                       session.setServerAliveInterval(1000);
+                       session.connect();
+                       if (log.isTraceEnabled())
+                               log.trace("Connected to " + getSshTarget() + " via SSH");
+                       if (sshTarget.getSession() != null) {
+                               if (log.isTraceEnabled())
+                                       log.trace("The cached session to " + getSshTarget() + " was disconnected and was reset.");
+                               sshTarget.setSession(session);
+                       }
+                       return session;
+               } catch (JSchException e) {
+                       if (sshTarget.getUserInfo() instanceof SimpleUserInfo)
+                               ((SimpleUserInfo) sshTarget.getUserInfo()).reset();
+                       throw new SlcException("Could not open session to " + getSshTarget(), e);
+               }
+       }
+
+       public void run() {
+               Session session = openSession();
+               try {
+                       run(session);
+               } finally {
+                       if (sshTarget != null && sshTarget.getSession() == null) {
+                               session.disconnect();
+                               if (log.isTraceEnabled())
+                                       log.trace("Disconnected from " + getSshTarget() + " via SSH");
+                       }
+               }
+       }
+
+       abstract void run(Session session);
+
+       protected int checkAck(InputStream in) throws IOException {
+               int b = in.read();
+               // b may be 0 for success,
+               // 1 for error,
+               // 2 for fatal error,
+               // -1
+               if (b == 0)
+                       return b;
+               else if (b == -1)
+                       return b;// throw new SlcException("SSH ack returned -1");
+               else if (b == 1 || b == 2) {
+                       StringBuffer sb = new StringBuffer();
+                       int c;
+                       do {
+                               c = in.read();
+                               sb.append((char) c);
+                       } while (c != '\n');
+                       if (b == 1) { // error
+                               throw new SlcException("SSH ack error: " + sb.toString());
+                       }
+                       if (b == 2) { // fatal error
+                               throw new SlcException("SSH fatal error: " + sb.toString());
+                       }
+               }
+               return b;
+       }
+
+       public SshTarget getSshTarget() {
+               if (sshTarget == null)
+                       throw new SlcException("No SSH target defined.");
+               return sshTarget;
+       }
+
+       public void setSshTarget(SshTarget sshTarget) {
+               this.sshTarget = sshTarget;
+       }
+
+       PrivilegedAction<Void> asPrivilegedAction() {
+               return new PrivilegedAction<Void>() {
+                       public Void run() {
+                               AbstractJschTask.this.run();
+                               return null;
+                       }
+               };
+       }
+
+       static {
+               JSch.setLogger(new JschLogger());
+       }
+
+       private static class JschLogger implements Logger {
+               private final Log log = LogFactory.getLog(JschLogger.class);
+
+               // TODO better support levels
+               @Override
+               public boolean isEnabled(int level) {
+                       if (log.isTraceEnabled())
+                               return true;
+                       return false;
+               }
+
+               @Override
+               public void log(int level, String message) {
+                       log.trace(message);
+               }
+
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/CallbackHandlerUserInfo.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/CallbackHandlerUserInfo.java
new file mode 100644 (file)
index 0000000..c069a81
--- /dev/null
@@ -0,0 +1,63 @@
+package org.argeo.slc.jsch;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+
+import org.argeo.slc.SlcException;
+
+/** Retrieve a password or a passphrase using a standard callback handler. */
+public final class CallbackHandlerUserInfo extends SimpleUserInfo {
+       private CallbackHandler callbackHandler;
+
+       private Boolean alwaysPrompt = false;
+
+       public boolean promptPassphrase(String message) {
+               if (passphrase != null)
+                       return true;
+
+               if (!alwaysPrompt && passphraseSafe != null)
+                       return true;
+
+               reset();
+               PasswordCallback passwordCb = new PasswordCallback("SSH Passphrase",
+                               false);
+               Callback[] dialogCbs = new Callback[] { passwordCb };
+               try {
+                       callbackHandler.handle(dialogCbs);
+                       passphraseSafe = passwordCb.getPassword();
+                       return passphraseSafe != null;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot ask for a password", e);
+               }
+       }
+
+       public boolean promptPassword(String message) {
+               if (password != null)
+                       return true;
+
+               if (!alwaysPrompt && passwordSafe != null)
+                       return true;
+
+               reset();
+               PasswordCallback passwordCb = new PasswordCallback("SSH Password",
+                               false);
+               Callback[] dialogCbs = new Callback[] { passwordCb };
+               try {
+                       callbackHandler.handle(dialogCbs);
+                       passwordSafe = passwordCb.getPassword();
+                       return passwordSafe != null;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot ask for a password", e);
+               }
+       }
+
+       public void setAlwaysPrompt(Boolean alwaysPrompt) {
+               this.alwaysPrompt = alwaysPrompt;
+       }
+
+       public void setCallbackHandler(CallbackHandler defaultCallbackHandler) {
+               this.callbackHandler = defaultCallbackHandler;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/GetMachineId.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/GetMachineId.java
new file mode 100644 (file)
index 0000000..fc7e88b
--- /dev/null
@@ -0,0 +1,39 @@
+package org.argeo.slc.jsch;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+
+class GetMachineId {
+
+       public static void main(String[] args) {
+               URL url = GetMachineId.class.getResource("jaas.cfg");
+               System.setProperty("java.security.auth.login.config", url.toExternalForm());
+
+               String hostname = args[0];
+               try {
+                       LoginContext lc = new LoginContext("SINGLE_USER");
+                       lc.login();
+
+                       SshTarget sshTarget = new SshTarget();
+                       sshTarget.setHost(hostname);
+                       RemoteExec remoteExec = new RemoteExec();
+                       remoteExec.setCommand("cat /etc/machine-id");
+                       remoteExec.setSshTarget(sshTarget);
+                       List<String> lines = new ArrayList<>();
+                       remoteExec.setStdOutLines(lines);
+
+                       Subject.doAs(lc.getSubject(), remoteExec.asPrivilegedAction());
+
+                       String machineId = lines.get(0);
+                       System.out.println(hostname + ": " + machineId);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/JschContextSession.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/JschContextSession.java
new file mode 100644 (file)
index 0000000..8855beb
--- /dev/null
@@ -0,0 +1,57 @@
+package org.argeo.slc.jsch;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+
+import com.jcraft.jsch.Session;
+
+/** Caches a JSCH session in the the ssh target. */
+public class JschContextSession extends AbstractJschTask implements
+               InitializingBean, DisposableBean {
+       private final static Log log = LogFactory.getLog(JschContextSession.class);
+       private Boolean autoconnect = false;
+
+       @Override
+       void run(Session session) {
+               // clear();
+               getSshTarget().setSession(session);
+               if (log.isDebugEnabled())
+                       log.debug("Cached SSH context session to " + getSshTarget());
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               // if (log.isDebugEnabled())
+               // log.debug(getClass() + ".afterPropertiesSet(), " + beanName + ", "
+               // + this);
+               if (autoconnect)
+                       try {
+                               run();
+                       } catch (Exception e) {
+                               log.error("Could not automatically open session", e);
+                       }
+       }
+
+       public void destroy() throws Exception {
+               clear();
+       }
+
+       public void clear() {
+               SshTarget sshTarget = getSshTarget();
+               synchronized (sshTarget) {
+                       if (sshTarget.getSession() != null) {
+                               sshTarget.getSession().disconnect();
+                               sshTarget.setSession(null);
+                               if (log.isDebugEnabled())
+                                       log.debug("Cleared cached SSH context session to "
+                                                       + getSshTarget());
+                       }
+               }
+       }
+
+       public void setAutoconnect(Boolean autoconnect) {
+               this.autoconnect = autoconnect;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/JschExecutor.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/JschExecutor.java
new file mode 100644 (file)
index 0000000..b9d5f55
--- /dev/null
@@ -0,0 +1,112 @@
+package org.argeo.slc.jsch;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteResultHandler;
+import org.apache.commons.exec.ExecuteStreamHandler;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.ProcessDestroyer;
+
+/** A Commons Exec executor executing remotely via SSH */
+public class JschExecutor implements Executor {
+       private File workingDirectory;
+       private ExecuteStreamHandler streamHandler;
+
+       private SshTarget sshTarget;
+
+       public void setExitValue(int value) {
+               // TODO Auto-generated method stub
+
+       }
+
+       public void setExitValues(int[] values) {
+               // TODO Auto-generated method stub
+
+       }
+
+       public boolean isFailure(int exitValue) {
+               return Executor.INVALID_EXITVALUE == exitValue;
+       }
+
+       public ExecuteStreamHandler getStreamHandler() {
+               return streamHandler;
+       }
+
+       public void setStreamHandler(ExecuteStreamHandler streamHandler) {
+               this.streamHandler = streamHandler;
+       }
+
+       public ExecuteWatchdog getWatchdog() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public void setWatchdog(ExecuteWatchdog watchDog) {
+               // TODO Auto-generated method stub
+
+       }
+
+       public ProcessDestroyer getProcessDestroyer() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public void setProcessDestroyer(ProcessDestroyer processDestroyer) {
+               // TODO Auto-generated method stub
+
+       }
+
+       public File getWorkingDirectory() {
+               return workingDirectory;
+       }
+
+       public void setWorkingDirectory(File workingDirectory) {
+               this.workingDirectory = workingDirectory;
+       }
+
+       public int execute(CommandLine command) throws ExecuteException,
+                       IOException {
+               return execute(command, (Map) null);
+       }
+
+       public int execute(CommandLine command, Map environment)
+                       throws ExecuteException, IOException {
+               String cmd = command.toString();
+               if(workingDirectory!=null)
+                       cmd = "cd "+workingDirectory.getPath()+" && "+cmd;
+               RemoteExec remoteExec = new RemoteExec();
+               remoteExec.setSshTarget(sshTarget);
+               remoteExec.setStreamHandler(streamHandler);
+               remoteExec.setCommand(cmd);
+               if (environment != null)
+                       remoteExec.setEnv(environment);
+               remoteExec.run();
+               return remoteExec.getLastExitStatus() != null ? remoteExec
+                               .getLastExitStatus() : Executor.INVALID_EXITVALUE;
+       }
+
+       public void execute(CommandLine command, ExecuteResultHandler handler)
+                       throws ExecuteException, IOException {
+               // TODO Auto-generated method stub
+
+       }
+
+       public void execute(CommandLine command, Map environment,
+                       ExecuteResultHandler handler) throws ExecuteException, IOException {
+
+       }
+
+       public SshTarget getSshTarget() {
+               return sshTarget;
+       }
+
+       public void setSshTarget(SshTarget sshTarget) {
+               this.sshTarget = sshTarget;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/JschMultiTasks.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/JschMultiTasks.java
new file mode 100644 (file)
index 0000000..3dcba87
--- /dev/null
@@ -0,0 +1,27 @@
+package org.argeo.slc.jsch;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.jcraft.jsch.Session;
+
+public class JschMultiTasks extends AbstractJschTask {
+       private List<AbstractJschTask> tasks = new ArrayList<AbstractJschTask>();
+
+       @Override
+       protected void run(Session session) {
+               for (AbstractJschTask task : tasks) {
+                       task.setSshTarget(getSshTarget());
+                       task.run(session);
+               }
+       }
+
+       public void setTasks(List<AbstractJschTask> tasks) {
+               this.tasks = tasks;
+       }
+
+       public List<AbstractJschTask> getTasks() {
+               return tasks;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/RemoteExec.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/RemoteExec.java
new file mode 100644 (file)
index 0000000..886dc92
--- /dev/null
@@ -0,0 +1,486 @@
+package org.argeo.slc.jsch;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.commons.exec.ExecuteStreamHandler;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.ExecutionResources;
+import org.argeo.slc.core.execution.tasks.SystemCall;
+import org.springframework.core.io.Resource;
+import org.springframework.util.StringUtils;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.ChannelShell;
+import com.jcraft.jsch.Session;
+
+public class RemoteExec extends AbstractJschTask {
+       private final static Log log = LogFactory.getLog(RemoteExec.class);
+
+       private Boolean failOnBadExitStatus = true;
+
+       private List<String> commands = new ArrayList<String>();
+       private String command;
+       private SystemCall systemCall;
+       private List<SystemCall> systemCalls = new ArrayList<SystemCall>();
+       private Resource script;
+       private Boolean xForwarding = false;
+       private Boolean agentForwarding = false;
+       private Boolean forceShell = false;
+       private Map<String, String> env = new HashMap<String, String>();
+       private Resource stdIn = null;
+       private Resource stdOut = null;
+       private ExecutionResources executionResources;
+
+       private String user;
+
+       private ExecuteStreamHandler streamHandler = null;
+
+       private Integer lastExitStatus = null;
+       /**
+        * If set, stdout is written to it as a list of lines. Cleared before each
+        * run.
+        */
+       private List<String> stdOutLines = null;
+       private Boolean logEvenIfStdOutLines = false;
+       private Boolean quiet = false;
+
+       public RemoteExec() {
+       }
+
+       public RemoteExec(SshTarget sshTarget, String cmd) {
+               setSshTarget(sshTarget);
+               setCommand(cmd);
+       }
+
+       public void run(Session session) {
+               List<String> commandsToUse = new ArrayList<String>(commands);
+               String commandToUse = command;
+               // convert system calls
+               if (systemCall != null) {
+                       if (command != null)
+                               throw new SlcException("Cannot specify command AND systemCall");
+                       commandToUse = convertSystemCall(systemCall);
+               }
+
+               if (systemCalls.size() != 0) {
+                       if (commandsToUse.size() != 0)
+                               throw new SlcException(
+                                               "Cannot specify commands AND systemCalls");
+                       for (SystemCall systemCall : systemCalls)
+                               commandsToUse.add(convertSystemCall(systemCall));
+               }
+
+               if (script != null) {
+                       // TODO: simply pass the script as a string command
+                       if (commandsToUse.size() != 0)
+                               throw new SlcException("Cannot specify commands and script");
+                       BufferedReader reader = null;
+                       try {
+                               reader = new BufferedReader(new InputStreamReader(
+                                               script.getInputStream()));
+                               String line = null;
+                               while ((line = reader.readLine()) != null) {
+                                       if (!StringUtils.hasText(line))
+                                               continue;
+                                       commandsToUse.add(line);
+                               }
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot read script " + script, e);
+                       } finally {
+                               IOUtils.closeQuietly(reader);
+                       }
+               }
+
+               if (forceShell) {
+                       // for the time being do not interpret both \n and ;
+                       // priority to \n
+                       // until we know how to parse ; within ""
+                       if (commandToUse.indexOf('\n') >= 0) {
+                               StringTokenizer st = new StringTokenizer(commandToUse, "\n");
+                               while (st.hasMoreTokens()) {
+                                       String cmd = st.nextToken();
+                                       commandsToUse.add(cmd);
+                               }
+                       } else if (commandToUse.indexOf(';') >= 0) {
+                               StringTokenizer st = new StringTokenizer(commandToUse, ";");
+                               while (st.hasMoreTokens()) {
+                                       String cmd = st.nextToken();
+                                       commandsToUse.add(cmd);
+                               }
+                       } else {
+                               commandsToUse.add(commandToUse);
+                       }
+                       commandToUse = null;
+               }
+
+               // run as user
+               if (user != null) {
+                       if (commandsToUse.size() > 0) {
+                               commandsToUse.add(0, "su - " + user);
+                               commandsToUse.add("exit");
+                       } else {
+                               if (command.indexOf('\"') >= 0)
+                                       throw new SlcException(
+                                                       "Don't know how to su a command with \", use shell instead.");
+                               commandToUse = "su - " + user + " -c \"" + command + "\"";
+                       }
+               }
+
+               // execute command(s)
+               if (commandToUse != null) {
+                       if (commandsToUse.size() != 0)
+                               throw new SlcException(
+                                               "Specify either a single command or a list of commands.");
+                       remoteExec(session, commandToUse);
+               } else {
+                       if (commandsToUse.size() == 0)
+                               throw new SlcException(
+                                               "Neither a single command or a list of commands has been specified.");
+
+                       remoteExec(session, commandsToUse, script != null ? "script "
+                                       + script.getFilename() : commandsToUse.size() + " commands");
+               }
+       }
+
+       protected String convertSystemCall(SystemCall systemCall) {
+               // TODO: prepend environment variables
+               // TODO: deal with exec dir
+               return systemCall.asCommand();
+       }
+
+       protected void remoteExec(Session session, final List<String> commands,
+                       String description) {
+               try {
+                       final ChannelShell channel = (ChannelShell) session
+                                       .openChannel("shell");
+                       channel.setInputStream(null);
+                       channel.setXForwarding(xForwarding);
+                       channel.setAgentForwarding(agentForwarding);
+                       channel.setEnv(new Hashtable<String, String>(env));
+
+                       /*
+                        * // Choose the pty-type "vt102".
+                        * ((ChannelShell)channel).setPtyType("vt102");
+                        */
+                       // Writer thread
+                       final BufferedWriter writer = new BufferedWriter(
+                                       new OutputStreamWriter(channel.getOutputStream()));
+
+                       if (log.isDebugEnabled())
+                               log.debug("Run " + description + " on " + getSshTarget()
+                                               + "...");
+                       channel.connect();
+
+                       // write commands to shell
+                       Thread writerThread = new Thread("Shell writer " + getSshTarget()) {
+                               @Override
+                               public void run() {
+                                       try {
+                                               for (String line : commands) {
+                                                       if (!StringUtils.hasText(line))
+                                                               continue;
+                                                       writer.write(line);
+                                                       writer.newLine();
+                                               }
+                                               writer.append("exit");
+                                               writer.newLine();
+                                               writer.flush();
+                                               // channel.disconnect();
+                                       } catch (IOException e) {
+                                               throw new SlcException("Cannot write to shell on "
+                                                               + getSshTarget(), e);
+                                       } finally {
+                                               IOUtils.closeQuietly(writer);
+                                       }
+                               }
+                       };
+                       writerThread.start();
+
+                       readStdOut(channel);
+                       checkExitStatus(channel);
+                       channel.disconnect();
+
+               } catch (Exception e) {
+                       throw new SlcException("Cannot use SSH shell on " + getSshTarget(),
+                                       e);
+               }
+
+       }
+
+       protected void remoteExec(Session session, String command) {
+               try {
+                       final ChannelExec channel = (ChannelExec) session
+                                       .openChannel("exec");
+                       channel.setCommand(command);
+
+                       channel.setInputStream(null);
+                       channel.setXForwarding(xForwarding);
+                       channel.setAgentForwarding(agentForwarding);
+                       channel.setEnv(new Hashtable<String, String>(env));
+                       channel.setErrStream(null);
+
+                       // Standard Error
+                       readStdErr(channel);
+
+                       if (log.isTraceEnabled())
+                               log.trace("Run '" + command + "' on " + getSshTarget() + "...");
+                       channel.connect();
+
+                       readStdIn(channel);
+                       readStdOut(channel);
+
+                       if (streamHandler != null) {
+                               streamHandler.start();
+                               while (!channel.isClosed()) {
+                                       try {
+                                               Thread.sleep(100);
+                                       } catch (Exception e) {
+                                               break;
+                                       }
+                               }
+                       }
+
+                       checkExitStatus(channel);
+                       channel.disconnect();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot execute remotely '" + command
+                                       + "' on " + getSshTarget(), e);
+               }
+       }
+
+       protected void readStdOut(Channel channel) {
+               try {
+                       if (stdOut != null) {
+                               OutputStream localStdOut = createOutputStream(stdOut);
+                               try {
+                                       IOUtils.copy(channel.getInputStream(), localStdOut);
+                               } finally {
+                                       IOUtils.closeQuietly(localStdOut);
+                               }
+                       } else if (streamHandler != null) {
+                               if (channel.getInputStream() != null)
+                                       streamHandler.setProcessOutputStream(channel
+                                                       .getInputStream());
+                       } else {
+                               BufferedReader stdOut = null;
+                               try {
+                                       InputStream in = channel.getInputStream();
+                                       stdOut = new BufferedReader(new InputStreamReader(in));
+                                       String line = null;
+                                       while ((line = stdOut.readLine()) != null) {
+                                               if (!line.trim().equals("")) {
+
+                                                       if (stdOutLines != null) {
+                                                               stdOutLines.add(line);
+                                                               if (logEvenIfStdOutLines && !quiet)
+                                                                       log.info(line);
+                                                       } else {
+                                                               if (!quiet)
+                                                                       log.info(line);
+                                                       }
+                                               }
+                                       }
+                               } finally {
+                                       IOUtils.closeQuietly(stdOut);
+                               }
+                       }
+               } catch (IOException e) {
+                       throw new SlcException("Cannot redirect stdout from "
+                                       + getSshTarget(), e);
+               }
+       }
+
+       protected void readStdErr(final ChannelExec channel) {
+               if (streamHandler != null) {
+                       try {
+                               streamHandler.setProcessOutputStream(channel.getErrStream());
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot read stderr from "
+                                               + getSshTarget(), e);
+                       }
+               } else {
+                       new Thread("stderr " + getSshTarget()) {
+                               public void run() {
+                                       BufferedReader stdErr = null;
+                                       try {
+                                               InputStream in = channel.getErrStream();
+                                               stdErr = new BufferedReader(new InputStreamReader(in));
+                                               String line = null;
+                                               while ((line = stdErr.readLine()) != null) {
+                                                       if (!line.trim().equals(""))
+                                                               log.error(line);
+                                               }
+                                       } catch (IOException e) {
+                                               if (log.isDebugEnabled())
+                                                       log.error("Cannot read stderr from "
+                                                                       + getSshTarget(), e);
+                                       } finally {
+                                               IOUtils.closeQuietly(stdErr);
+                                       }
+                               }
+                       }.start();
+               }
+       }
+
+       protected void readStdIn(final ChannelExec channel) {
+               if (stdIn != null) {
+                       Thread stdInThread = new Thread("Stdin " + getSshTarget()) {
+                               @Override
+                               public void run() {
+                                       OutputStream out = null;
+                                       try {
+                                               out = channel.getOutputStream();
+                                               IOUtils.copy(stdIn.getInputStream(), out);
+                                       } catch (IOException e) {
+                                               throw new SlcException("Cannot write stdin on "
+                                                               + getSshTarget(), e);
+                                       } finally {
+                                               IOUtils.closeQuietly(out);
+                                       }
+                               }
+                       };
+                       stdInThread.start();
+               } else if (streamHandler != null) {
+                       try {
+                               streamHandler.setProcessInputStream(channel.getOutputStream());
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot write stdin on "
+                                               + getSshTarget(), e);
+                       }
+               }
+       }
+
+       protected void checkExitStatus(Channel channel) {
+               if (channel.isClosed()) {
+                       lastExitStatus = channel.getExitStatus();
+                       if (lastExitStatus == 0) {
+                               if (log.isTraceEnabled())
+                                       log.trace("Remote execution exit status: " + lastExitStatus);
+                       } else {
+                               String msg = "Remote execution failed with " + " exit status: "
+                                               + lastExitStatus;
+                               if (failOnBadExitStatus)
+                                       throw new SlcException(msg);
+                               else
+                                       log.error(msg);
+                       }
+               }
+
+       }
+
+       protected OutputStream createOutputStream(Resource target) {
+               FileOutputStream out = null;
+               try {
+
+                       final File file;
+                       if (executionResources != null)
+                               file = new File(executionResources.getAsOsPath(target, true));
+                       else
+                               file = target.getFile();
+                       out = new FileOutputStream(file, false);
+               } catch (IOException e) {
+                       log.error("Cannot get file for " + target, e);
+                       IOUtils.closeQuietly(out);
+               }
+               return out;
+       }
+
+       public Integer getLastExitStatus() {
+               return lastExitStatus;
+       }
+
+       public void setStreamHandler(ExecuteStreamHandler executeStreamHandler) {
+               this.streamHandler = executeStreamHandler;
+       }
+
+       public void setCommand(String command) {
+               this.command = command;
+       }
+
+       public void setCommands(List<String> commands) {
+               this.commands = commands;
+       }
+
+       public void setFailOnBadExitStatus(Boolean failOnBadExitStatus) {
+               this.failOnBadExitStatus = failOnBadExitStatus;
+       }
+
+       public void setSystemCall(SystemCall systemCall) {
+               this.systemCall = systemCall;
+       }
+
+       public void setSystemCalls(List<SystemCall> systemCalls) {
+               this.systemCalls = systemCalls;
+       }
+
+       public void setScript(Resource script) {
+               this.script = script;
+       }
+
+       public void setxForwarding(Boolean xForwarding) {
+               this.xForwarding = xForwarding;
+       }
+
+       public void setAgentForwarding(Boolean agentForwarding) {
+               this.agentForwarding = agentForwarding;
+       }
+
+       public void setEnv(Map<String, String> env) {
+               this.env = env;
+       }
+
+       public void setForceShell(Boolean forceShell) {
+               this.forceShell = forceShell;
+       }
+
+       public List<String> getCommands() {
+               return commands;
+       }
+
+       public void setStdOutLines(List<String> stdOutLines) {
+               this.stdOutLines = stdOutLines;
+       }
+
+       public void setLogEvenIfStdOutLines(Boolean logEvenIfStdOutLines) {
+               this.logEvenIfStdOutLines = logEvenIfStdOutLines;
+       }
+
+       public void setQuiet(Boolean quiet) {
+               this.quiet = quiet;
+       }
+
+       public void setStdIn(Resource stdIn) {
+               this.stdIn = stdIn;
+       }
+
+       public void setStdOut(Resource stdOut) {
+               this.stdOut = stdOut;
+       }
+
+       public void setExecutionResources(ExecutionResources executionResources) {
+               this.executionResources = executionResources;
+       }
+
+       public void setUser(String user) {
+               this.user = user;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpFrom.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpFrom.java
new file mode 100644 (file)
index 0000000..ced80ee
--- /dev/null
@@ -0,0 +1,159 @@
+package org.argeo.slc.jsch;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.core.io.Resource;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.Session;
+
+public class ScpFrom extends AbstractJschTask {
+       private final static Log log = LogFactory.getLog(ScpFrom.class);
+
+       private Resource localResource;
+       private String remotePath;
+       private Boolean mkdir = false;
+
+       public void run(Session session) {
+               if (localResource != null) {
+                       File lFile;
+                       try {
+                               lFile = localResource.getFile();
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot interpret resource "
+                                               + localResource + " as file.", e);
+                       }
+                       downloadFile(session, lFile, remotePath);
+               }
+       }
+
+       protected void downloadFile(Session session, File localFile,
+                       String remoteFile) {
+               OutputStream out = null;
+               OutputStream channelOut;
+               InputStream channelIn;
+               try {
+                       // exec 'scp -f rfile' remotely
+                       String command = "scp -f " + remoteFile;
+                       Channel channel = session.openChannel("exec");
+                       ((ChannelExec) channel).setCommand(command);
+
+                       // get I/O streams for remote scp
+                       channelOut = channel.getOutputStream();
+                       channelIn = channel.getInputStream();
+
+                       channel.connect();
+
+                       byte[] buf = new byte[1024];
+
+                       // send '\0'
+                       buf[0] = 0;
+                       channelOut.write(buf, 0, 1);
+                       channelOut.flush();
+
+                       while (true) {
+                               int c = checkAck(channelIn);
+                               if (c != 'C') {
+                                       break;
+                               }
+
+                               // read '0644 '
+                               channelIn.read(buf, 0, 5);
+
+                               long filesize = 0L;
+                               while (true) {
+                                       if (channelIn.read(buf, 0, 1) < 0) {
+                                               // error
+                                               break;
+                                       }
+                                       if (buf[0] == ' ')
+                                               break;
+                                       filesize = filesize * 10L + (long) (buf[0] - '0');
+                               }
+
+                               String remoteFileName = null;
+                               for (int i = 0;; i++) {
+                                       channelIn.read(buf, i, 1);
+                                       if (buf[i] == (byte) 0x0a) {
+                                               remoteFileName = new String(buf, 0, i);
+                                               break;
+                                       }
+                               }
+
+                               // System.out.println("filesize="+filesize+", file="+file);
+
+                               // send '\0'
+                               buf[0] = 0;
+                               channelOut.write(buf, 0, 1);
+                               channelOut.flush();
+
+                               // Create a s adirectory if it doesn't exists
+                               if (!localFile.exists() && mkdir)
+                                       localFile.mkdirs();
+
+                               // read a content of lfile
+                               String localPath = localFile.isDirectory() ? localFile
+                                               .getPath()
+                                               + File.separator + remoteFileName : localFile.getPath();
+
+                               out = new FileOutputStream(localPath);
+                               int foo;
+                               while (true) {
+                                       if (buf.length < filesize)
+                                               foo = buf.length;
+                                       else
+                                               foo = (int) filesize;
+                                       foo = channelIn.read(buf, 0, foo);
+                                       if (foo < 0) {
+                                               // error
+                                               break;
+                                       }
+                                       out.write(buf, 0, foo);
+                                       filesize -= foo;
+                                       if (filesize == 0L)
+                                               break;
+                               }
+
+                               checkAck(channelIn);
+
+                               // send '\0'
+                               buf[0] = 0;
+                               channelOut.write(buf, 0, 1);
+                               channelOut.flush();
+
+                               if (log.isDebugEnabled())
+                                       log.debug("Finished downloading " + remoteFile + " on "
+                                                       + getSshTarget() + " to " + localPath);
+                       }
+
+                       channel.disconnect();
+                       // session.disconnect();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot download " + remoteFile + " to "
+                                       + localFile, e);
+               } finally {
+                       IOUtils.closeQuietly(out);
+               }
+       }
+
+       public void setLocalResource(Resource localFile) {
+               this.localResource = localFile;
+       }
+
+       public void setRemotePath(String remoteFile) {
+               this.remotePath = remoteFile;
+       }
+
+       public void setMkdir(Boolean mkdir) {
+               this.mkdir = mkdir;
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpTo.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/ScpTo.java
new file mode 100644 (file)
index 0000000..5da5f79
--- /dev/null
@@ -0,0 +1,275 @@
+package org.argeo.slc.jsch;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.core.io.Resource;
+import org.springframework.util.AntPathMatcher;
+import org.springframework.util.PathMatcher;
+import org.springframework.util.StringUtils;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.Session;
+
+public class ScpTo extends AbstractJschTask {
+       private final static Log log = LogFactory.getLog(ScpTo.class);
+
+       private Resource localResource;
+       private String remotePath;
+
+       private String dir;
+       private String remoteDir;
+       private List<String> includes = new ArrayList<String>();
+
+       private List<String> excludes = new ArrayList<String>();
+
+       private PathMatcher pathMatcher;
+
+       public void run(Session session) {
+               if (StringUtils.hasText(dir)) {
+                       if (!StringUtils.hasText(remoteDir))
+                               throw new SlcException("Remote dir has to be specified.");
+
+                       String dirOs = dir.replace('/', File.separatorChar);
+                       if (dirOs.charAt(dir.length() - 1) != File.separatorChar) {
+                               dirOs = dirOs + File.separator;
+                       }
+
+                       if (pathMatcher == null)
+                               pathMatcher = new AntPathMatcher();
+
+                       log.info("Start multiple scp based on " + dirOs);
+                       scanDir(session, dirOs, "", includes, excludes);
+               }
+
+               if (localResource != null) {
+                       uploadResource(session, localResource);
+               }
+       }
+
+       protected void scanDir(Session session, String dir, String currentRelPath,
+                       List<String> includes, List<String> excludes) {
+               File[] files = new File(dir).listFiles();
+               for (File file : files) {
+                       if (!file.isDirectory()) {
+                               String relPath = currentRelPath.concat(file.getName());
+                               if (match(relPath, includes, excludes, false)) {
+                                       uploadFile(session, file, remoteDir + '/' + relPath);
+                               }
+                       } else {
+                               String relPath = currentRelPath.concat(file.getName()).concat(
+                                               "/");
+                               if (match(relPath, includes, excludes, true)) {
+                                       String nextDir = dir.concat(file.getName()).concat(
+                                                       File.separator);
+                                       scanDir(session, nextDir, relPath, includes, excludes);
+                               }
+                       }
+               }
+       }
+
+       protected Boolean match(String path, List<String> includes,
+                       List<String> excludes, boolean matchStart) {
+               for (String patternIn : includes) {
+                       boolean matchIn = matchStart ? pathMatcher.matchStart(patternIn,
+                                       path) : pathMatcher.match(patternIn, path);
+                       if (matchIn) {
+                               // Could be included, check excludes
+                               boolean excluded = false;
+                               ex: for (String patternEx : excludes) {
+                                       boolean matchEx = matchStart ? pathMatcher.matchStart(
+                                                       patternEx, path) : pathMatcher.match(patternEx,
+                                                       path);
+
+                                       if (matchEx) {
+                                               excluded = true;
+                                               break ex;
+                                       }
+                               }
+                               if (!excluded)
+                                       return true;
+                       }
+               }
+               return false;
+       }
+
+       protected void uploadFile(Session session, File file, String remoteFile) {
+               try {
+                       upload(session, new FileInputStream(file), file.length(), file
+                                       .getPath(), file.toString(), remoteFile);
+               } catch (FileNotFoundException e) {
+                       throw new SlcException("Cannot upload " + file, e);
+               }
+       }
+
+       protected void uploadResource(Session session, Resource resource) {
+               String targetPath = remotePath != null ? remotePath : remoteDir + '/'
+                               + resource.getFilename();
+               try {
+                       File lFile = resource.getFile();
+                       uploadFile(session, lFile, targetPath);
+               } catch (IOException e) {
+                       // no underlying file found
+                       // load the resource in memory before transferring it
+                       InputStream in = null;
+                       try {
+                               byte[] arr;
+                               String path;
+                               if (resource instanceof ByteArrayResource) {
+                                       arr = ((ByteArrayResource) resource).getByteArray();
+                                       path = "bytearray";
+                               } else {
+                                       in = resource.getInputStream();
+                                       ByteArrayOutputStream out = new ByteArrayOutputStream();
+                                       IOUtils.copy(in, out);
+                                       arr = out.toByteArray();
+                                       path = resource.getURL().getPath();
+                                       if (path.startsWith("/"))
+                                               path = path.substring(1);
+                               }
+                               ByteArrayInputStream content = new ByteArrayInputStream(arr);
+                               upload(session, content, arr.length, path, resource.toString(),
+                                               targetPath);
+                               arr = null;
+                       } catch (IOException e1) {
+                               throw new SlcException("Can not interpret resource "
+                                               + localResource, e1);
+                       } finally {
+                               IOUtils.closeQuietly(in);
+                               // no need to close byte arrays streams
+                       }
+               }
+       }
+
+       protected void upload(Session session, InputStream in, long size,
+                       String path, String sourceDesc, String remoteFile) {
+               OutputStream channelOut;
+               InputStream channelIn;
+               try {
+
+                       // exec 'scp -t rfile' remotely
+                       String command = "scp -p -t " + remoteFile;
+                       Channel channel = session.openChannel("exec");
+                       ((ChannelExec) channel).setCommand(command);
+
+                       // get I/O streams for remote scp
+                       channelOut = channel.getOutputStream();
+                       channelIn = channel.getInputStream();
+
+                       channel.connect();
+                       checkAck(channelIn);
+
+                       // send "C0644 filesize filename", where filename should not include
+                       // '/'
+                       long filesize = size;
+                       command = "C0644 " + filesize + " ";
+                       int index = path.lastIndexOf('/');
+                       if (index > 0) {
+                               command += path.substring(index + 1);
+                       } else {
+                               command += path;
+                       }
+                       command += "\n";
+
+                       channelOut.write(command.getBytes());
+                       channelOut.flush();
+                       checkAck(channelIn);
+
+                       if (log.isTraceEnabled())
+                               log.debug("Start copy of " + sourceDesc + " to " + remoteFile
+                                               + " on " + getSshTarget() + "...");
+
+                       final long oneMB = 1024l;// in KB
+                       final long tenMB = 10 * oneMB;// in KB
+
+                       // send a content of lfile
+                       byte[] buf = new byte[1024];
+                       long cycleCount = 0;
+                       long nbrOfBytes = 0;
+                       while (true) {
+                               int len = in.read(buf, 0, buf.length);
+                               if (len <= 0)
+                                       break;
+                               channelOut.write(buf, 0, len); // out.flush();
+                               nbrOfBytes = nbrOfBytes + len;
+                               if (((cycleCount % oneMB) == 0) && cycleCount != 0)// each 1 MB
+                                       System.out.print('#');
+                               if (((cycleCount % (tenMB)) == 0) && cycleCount != 0)// each 10
+                                       // MB
+                                       System.out.print(" - " + cycleCount / tenMB + "0 MB\n");
+                               cycleCount++;
+                       }
+                       // send '\0'
+                       buf[0] = 0;
+                       channelOut.write(buf, 0, 1);
+                       channelOut.flush();
+                       checkAck(channelIn);
+
+                       if (log.isDebugEnabled())
+                               log.debug("Transferred to " + remoteFile + " ("
+                                               + sizeDesc(nbrOfBytes) + ") on " + getSshTarget()
+                                               + " from " + sourceDesc);
+
+                       IOUtils.closeQuietly(channelOut);
+
+                       channel.disconnect();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot copy " + path + " to " + remoteFile,
+                                       e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+               }
+       }
+
+       protected String sizeDesc(Long nbrOfBytes) {
+               if (nbrOfBytes < 1024)
+                       return nbrOfBytes + " B";
+               else if (nbrOfBytes < 1024 * 1024)
+                       return (nbrOfBytes / 1024) + " KB";
+               else
+                       return nbrOfBytes / (1024 * 1024) + " MB";
+       }
+
+       public void setLocalResource(Resource localFile) {
+               this.localResource = localFile;
+       }
+
+       public void setRemotePath(String remoteFile) {
+               this.remotePath = remoteFile;
+       }
+
+       public void setDir(String dir) {
+               this.dir = dir;
+       }
+
+       public void setRemoteDir(String remoteDir) {
+               this.remoteDir = remoteDir;
+       }
+
+       public void setIncludes(List<String> includes) {
+               this.includes = includes;
+       }
+
+       public void setExcludes(List<String> excludes) {
+               this.excludes = excludes;
+       }
+
+       public void setPathMatcher(PathMatcher pathMatcher) {
+               this.pathMatcher = pathMatcher;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SimpleUserInfo.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SimpleUserInfo.java
new file mode 100644 (file)
index 0000000..fd84224
--- /dev/null
@@ -0,0 +1,164 @@
+package org.argeo.slc.jsch;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.Arrays;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+
+import com.jcraft.jsch.UserInfo;
+
+/** Basic implementation of user info. */
+public class SimpleUserInfo implements UserInfo {
+       private Boolean permissive = true;
+       private Boolean verbose = false;
+
+       private final static Log log = LogFactory.getLog(SimpleUserInfo.class);
+
+       protected String password;
+       protected char[] passwordSafe;
+       protected String passphrase;
+       protected char[] passphraseSafe;
+
+       public void reset() {
+               if (passwordSafe != null)
+                       Arrays.fill(passwordSafe, (char) 0);
+               passwordSafe = null;
+               if (passphraseSafe != null)
+                       Arrays.fill(passphraseSafe, (char) 0);
+               passphraseSafe = null;
+       }
+
+       public void setPassword(String password) {
+               this.password = password;
+       }
+
+       public void setPassphrase(String passphrase) {
+               this.passphrase = passphrase;
+       }
+
+       public String getPassphrase() {
+               if (passphraseSafe != null)
+                       return new String(passphraseSafe);
+               return passphrase;
+       }
+
+       public String getPassword() {
+               if (passwordSafe != null)
+                       return new String(passwordSafe);
+               return password;
+       }
+
+       public boolean promptPassphrase(String message) {
+               if (permissive)
+                       return true;
+               else {
+                       log.info(message);
+                       passwordSafe = readPassword(System.in);
+                       return passwordSafe != null;
+               }
+       }
+
+       public boolean promptPassword(String message) {
+               if (permissive)
+                       return true;
+               else {
+                       log.info(message);
+                       passwordSafe = readPassword(System.in);
+                       return passwordSafe != null;
+               }
+       }
+
+       public boolean promptYesNo(String message) {
+               String msg = message + " (y/n): ";
+               if (permissive) {
+                       if (verbose)
+                               log.info(msg + "y");
+                       return true;
+               } else {
+                       log.info(msg);
+                       char c;
+                       try {
+                               c = (char) System.in.read();
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot read stdin", e);
+                       }
+                       if (c == 'y')
+                               return true;
+                       else
+                               return false;
+               }
+       }
+
+       public void showMessage(String message) {
+               log.info(message);
+       }
+
+       public void setPermissive(Boolean permissive) {
+               this.permissive = permissive;
+       }
+
+       public void setVerbose(Boolean verbose) {
+               this.verbose = verbose;
+       }
+
+       protected char[] readPassword(InputStream in) {
+
+               try {
+                       char[] lineBuffer;
+                       char[] buf;
+                       // int i;
+
+                       buf = lineBuffer = new char[128];
+
+                       int room = buf.length;
+                       int offset = 0;
+                       int c;
+
+                       loop: while (true) {
+                               switch (c = in.read()) {
+                               case -1:
+                               case '\n':
+                                       break loop;
+
+                               case '\r':
+                                       int c2 = in.read();
+                                       if ((c2 != '\n') && (c2 != -1)) {
+                                               if (!(in instanceof PushbackInputStream)) {
+                                                       in = new PushbackInputStream(in);
+                                               }
+                                               ((PushbackInputStream) in).unread(c2);
+                                       } else
+                                               break loop;
+
+                               default:
+                                       if (--room < 0) {
+                                               buf = new char[offset + 128];
+                                               room = buf.length - offset - 1;
+                                               System.arraycopy(lineBuffer, 0, buf, 0, offset);
+                                               Arrays.fill(lineBuffer, ' ');
+                                               lineBuffer = buf;
+                                       }
+                                       buf[offset++] = (char) c;
+                                       break;
+                               }
+                       }
+
+                       if (offset == 0) {
+                               return null;
+                       }
+
+                       char[] ret = new char[offset];
+                       System.arraycopy(buf, 0, ret, 0, offset);
+                       Arrays.fill(buf, ' ');
+
+                       return ret;
+               } catch (IOException e) {
+                       throw new SlcException("Cannot read password.", e);
+               }
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SshFilesDeployment.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SshFilesDeployment.java
new file mode 100644 (file)
index 0000000..53670e1
--- /dev/null
@@ -0,0 +1,219 @@
+package org.argeo.slc.jsch;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.deploy.DigestCheck;
+import org.argeo.slc.core.deploy.ResourceSet;
+import org.springframework.core.io.Resource;
+
+import com.jcraft.jsch.Session;
+
+public class SshFilesDeployment extends AbstractJschTask implements Runnable {
+       private final static Log log = LogFactory.getLog(SshFilesDeployment.class);
+       private String targetBase = "";
+       private ResourceSet resourceSet;
+       /**
+        * Activate with algorithm as per
+        * http://java.sun.com/j2se/1.5.0/docs/guide/security/CryptoSpec.html#AppA
+        */
+       private String checksum = "MD5";
+       private int remoteChecksumsPerCall = 20;
+
+       public SshFilesDeployment() {
+       }
+
+       public SshFilesDeployment(SshTarget sshTarget, ResourceSet resourceSet) {
+               setSshTarget(sshTarget);
+               this.resourceSet = resourceSet;
+       }
+
+       @Override
+       void run(Session session) {
+               JschMultiTasks multiTasks = new JschMultiTasks();
+
+               Map<String, Resource> resources = resourceSet.listResources();
+
+               // Analyze set
+               List<String> subDirs = new ArrayList<String>();
+               Map<String, String> targetPaths = new HashMap<String, String>();
+               for (String relPath : resources.keySet()) {
+                       String parentDir;
+                       int lastIndexSubDir = relPath.lastIndexOf('/');
+                       if (lastIndexSubDir > 0)
+                               parentDir = targetBase + '/'
+                                               + relPath.substring(0, lastIndexSubDir);
+                       else
+                               parentDir = targetBase;
+
+                       boolean skipDir = false;
+                       registerDirs: for (String registeredDir : new ArrayList<String>(
+                                       subDirs)) {
+                               if (parentDir.equals(registeredDir)) {
+                                       if (log.isTraceEnabled())
+                                               log.trace("Already registered, skip " + parentDir);
+                                       skipDir = true;
+                                       break registerDirs;
+                               }
+
+                               if (parentDir.startsWith(registeredDir))
+                                       if (subDirs.contains(registeredDir)) {
+                                               subDirs.remove(registeredDir);
+                                               if (log.isTraceEnabled())
+                                                       log.trace("Remove parent " + registeredDir + " of "
+                                                                       + parentDir);
+                                               continue registerDirs;
+                                       }
+
+                               if (registeredDir.startsWith(parentDir)) {
+                                       skipDir = true;
+                                       if (log.isTraceEnabled())
+                                               log.trace("Skip " + parentDir
+                                                               + " because child already registered.");
+                                       break registerDirs;
+                               }
+                       }
+
+                       if (!subDirs.contains(parentDir) && !skipDir) {
+                               subDirs.add(parentDir);
+                       }
+
+                       targetPaths.put(relPath, targetBase + "/" + relPath);
+               }
+
+               // checksum
+               List<String> targetPathsEqualsToLocal = new ArrayList<String>();
+               if (checksum != null) {
+                       Map<String, String> remoteChecksums = new HashMap<String, String>();
+                       List<String> csLines = new ArrayList<String>();
+                       String csExecutable;
+                       if ("MD5".equals(checksum))
+                               csExecutable = "/usr/bin/md5sum";
+                       else if ("SHA".equals(checksum))
+                               csExecutable = "/usr/bin/sha1sum";
+                       else if ("SHA-256".equals(checksum))
+                               csExecutable = "/usr/bin/sha256sum";
+                       else if ("SHA-512".equals(checksum))
+                               csExecutable = "/usr/bin/sha512sum";
+                       else
+                               throw new SlcException(
+                                               "Don't know how to remotely execute checksum "
+                                                               + checksum);
+
+                       StringBuffer csCmd = new StringBuffer(csExecutable);
+                       int numberOfPaths = targetPaths.size();
+                       int count = 0;
+                       for (String targetPath : targetPaths.values()) {
+                               csCmd.append(" ").append(targetPath);
+                               count++;
+
+                               if ((count % remoteChecksumsPerCall == 0)
+                                               || count == numberOfPaths) {
+                                       RemoteExec remoteCs = new RemoteExec();
+                                       remoteCs.setSshTarget(getSshTarget());
+                                       remoteCs.setCommand(csCmd.toString());
+                                       remoteCs.setStdOutLines(csLines);
+                                       remoteCs.setFailOnBadExitStatus(false);
+                                       remoteCs.run(session);
+                                       csCmd = new StringBuffer(csExecutable);
+                               }
+
+                       }
+
+                       remoteChecksums: for (String csLine : csLines) {
+                               StringTokenizer st = new StringTokenizer(csLine, ": ");
+                               String cs = st.nextToken();
+                               if (cs.equals(csExecutable)) {
+                                       // remote does not exist
+                                       continue remoteChecksums;
+                               } else {
+                                       String targetPath = st.nextToken();
+                                       if (log.isTraceEnabled())
+                                               log.trace("REMOTE: " + targetPath + "=" + cs);
+                                       remoteChecksums.put(targetPath, cs);
+                               }
+                       }
+
+                       // Local checksums
+                       for (String relPath : resources.keySet()) {
+                               Resource resource = resources.get(relPath);
+                               String targetPath = targetPaths.get(relPath);
+                               if (remoteChecksums.containsKey(targetPath)) {
+                                       String cs = DigestCheck.digest(checksum, resource);
+                                       if (log.isTraceEnabled())
+                                               log.trace("LOCAL : " + targetPath + "=" + cs);
+                                       if (remoteChecksums.get(targetPath).equals(cs))
+                                               targetPathsEqualsToLocal.add(targetPath);
+                               }
+                       }
+               }
+
+               // Prepare multitask
+
+               // Create dirs
+               StringBuffer mkdirCmd = new StringBuffer("mkdir -p");
+               RemoteExec remoteExec = new RemoteExec();
+               for (String dir : subDirs) {
+                       // remoteExec.getCommands().add("mkdir -p " + dir);
+                       mkdirCmd.append(' ');
+                       if (dir.indexOf(' ') >= 0)
+                               mkdirCmd.append('\"').append(dir).append('\"');
+                       else
+                               mkdirCmd.append(dir);
+               }
+               remoteExec.setCommand(mkdirCmd.toString());
+               multiTasks.getTasks().add(remoteExec);
+
+               // Perform copies
+               int copied = 0;
+               int skipped = 0;
+               copy: for (String relPath : resources.keySet()) {
+                       String targetPath = targetPaths.get(relPath);
+                       if (targetPathsEqualsToLocal.contains(targetPath)) {
+                               if (log.isTraceEnabled())
+                                       log.trace("Skip copy of " + relPath
+                                                       + " since it is equal to remote " + targetPath);
+                               skipped++;
+                               continue copy;
+                       }
+                       // Copy resource
+                       Resource resource = resources.get(relPath);
+                       ScpTo scpTo = new ScpTo();
+                       scpTo.setLocalResource(resource);
+                       scpTo.setRemotePath(targetPath);
+                       multiTasks.getTasks().add(scpTo);
+                       copied++;
+                       // TODO: set permissions
+               }
+
+               multiTasks.setSshTarget(getSshTarget());
+               multiTasks.run(session);
+
+               if (checksum != null && log.isDebugEnabled())
+                       log.debug("Copied " + copied + " files, skipped " + skipped
+                                       + " with same checksum.");
+       }
+
+       public void setTargetBase(String targetBase) {
+               this.targetBase = targetBase;
+       }
+
+       public void setResourceSet(ResourceSet resourceSet) {
+               this.resourceSet = resourceSet;
+       }
+
+       public void setChecksum(String checksum) {
+               this.checksum = checksum;
+       }
+
+       /** Number of remote checksums per remote call */
+       public void setRemoteChecksumsPerCall(int remoteChecksumsPerCall) {
+               this.remoteChecksumsPerCall = remoteChecksumsPerCall;
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SshShell.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SshShell.java
new file mode 100644 (file)
index 0000000..2ec2b72
--- /dev/null
@@ -0,0 +1,125 @@
+package org.argeo.slc.jsch;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.springframework.core.io.Resource;
+import org.springframework.util.StringUtils;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.Session;
+
+public class SshShell extends AbstractJschTask {
+       private final static Log log = LogFactory.getLog(SshShell.class);
+       private Resource input;
+
+       @Override
+       void run(Session session) {
+               try {
+                       final Channel channel = session.openChannel("shell");
+
+                       // Enable agent-forwarding.
+                       // ((ChannelShell)channel).setAgentForwarding(true);
+
+                       // channel.setInputStream(System.in);
+                       // channel.setInputStream(input.getInputStream());
+                       /*
+                        * // a hack for MS-DOS prompt on Windows.
+                        * channel.setInputStream(new FilterInputStream(System.in){ public
+                        * int read(byte[] b, int off, int len)throws IOException{ return
+                        * in.read(b, off, (len>1024?1024:len)); } });
+                        */
+
+                       // channel.setOutputStream(System.out);
+
+                       /*
+                        * // Choose the pty-type "vt102".
+                        * ((ChannelShell)channel).setPtyType("vt102");
+                        */
+
+                       /*
+                        * // Set environment variable "LANG" as "ja_JP.eucJP".
+                        * ((ChannelShell)channel).setEnv("LANG", "ja_JP.eucJP");
+                        */
+
+                       // Writer thread
+                       final BufferedWriter writer = new BufferedWriter(
+                                       new OutputStreamWriter(channel.getOutputStream()));
+
+                       // channel.connect();
+                       channel.connect(3 * 1000);
+
+                       // while (!channel.isConnected())
+                       // try {
+                       // Thread.sleep(500);
+                       // } catch (InterruptedException e1) {
+                       // // silent
+                       // }
+
+                       Thread writerThread = new Thread("Shell writer " + getSshTarget()) {
+
+                               @Override
+                               public void run() {
+
+                                       if (log.isDebugEnabled())
+                                               log.debug("Start writing to shell");
+
+                                       BufferedReader reader = null;
+                                       try {
+                                               reader = new BufferedReader(new InputStreamReader(input
+                                                               .getInputStream()));
+                                               String line = null;
+                                               while ((line = reader.readLine()) != null) {
+                                                       if (!StringUtils.hasText(line))
+                                                               continue;
+                                                       writer.write(line);
+                                                       writer.newLine();
+                                               }
+                                               writer.append("exit");
+                                               writer.newLine();
+                                               writer.flush();
+                                               // channel.disconnect();
+                                       } catch (IOException e) {
+                                               throw new SlcException("Cannot write to shell on "
+                                                               + getSshTarget(), e);
+                                       } finally {
+                                               IOUtils.closeQuietly(reader);
+                                       }
+                               }
+                       };
+                       writerThread.start();
+
+                       BufferedReader execIn = null;
+                       try {
+                               execIn = new BufferedReader(new InputStreamReader(channel
+                                               .getInputStream()));
+                               String line = null;
+                               while ((line = execIn.readLine()) != null) {
+                                       if (!line.trim().equals(""))
+                                               log.info(line);
+                               }
+                       } catch (Exception e) {
+                               throw new SlcException("Cannot read from shell on "
+                                               + getSshTarget(), e);
+                       } finally {
+                               IOUtils.closeQuietly(execIn);
+                       }
+
+               } catch (Exception e) {
+                       throw new SlcException("Cannot use SSH shell on " + getSshTarget(),
+                                       e);
+               }
+       }
+
+       public void setInput(Resource input) {
+               this.input = input;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SshTarget.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SshTarget.java
new file mode 100644 (file)
index 0000000..f328f8f
--- /dev/null
@@ -0,0 +1,80 @@
+package org.argeo.slc.jsch;
+
+import java.io.File;
+
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.UserInfo;
+
+public class SshTarget {
+       private String host;
+       private Integer port = 22;
+       private String user;
+       private UserInfo userInfo = new SimpleUserInfo();
+
+       private Boolean usePrivateKey = true;
+       private File localPrivateKey = new File(System.getProperty("user.home")
+                       + File.separator + ".ssh" + File.separator + "id_rsa");
+
+       /** cached session */
+       private transient Session session;
+
+       public String getHost() {
+               return host;
+       }
+
+       public void setHost(String host) {
+               this.host = host;
+       }
+
+       public Integer getPort() {
+               return port;
+       }
+
+       public void setPort(Integer port) {
+               this.port = port;
+       }
+
+       public String getUser() {
+               return user;
+       }
+
+       public void setUser(String user) {
+               this.user = user;
+       }
+
+       public UserInfo getUserInfo() {
+               return userInfo;
+       }
+
+       public void setUserInfo(UserInfo userInfo) {
+               this.userInfo = userInfo;
+       }
+
+       public void setLocalPrivateKey(File localPrivateKey) {
+               this.localPrivateKey = localPrivateKey;
+       }
+
+       public File getLocalPrivateKey() {
+               return localPrivateKey;
+       }
+
+       public Boolean getUsePrivateKey() {
+               return usePrivateKey;
+       }
+
+       public void setUsePrivateKey(Boolean usePrivateKey) {
+               this.usePrivateKey = usePrivateKey;
+       }
+
+       public String toString() {
+               return getUser() + "@" + getHost() + ":" + getPort();
+       }
+
+       public synchronized Session getSession() {
+               return session;
+       }
+
+       public synchronized void setSession(Session session) {
+               this.session = session;
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SwingUserInfo.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/SwingUserInfo.java
new file mode 100644 (file)
index 0000000..14eb16b
--- /dev/null
@@ -0,0 +1,140 @@
+package org.argeo.slc.jsch;
+
+import java.awt.Container;
+import java.awt.GridLayout;
+import java.awt.Panel;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Arrays;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
+
+/** Retrieves a password or a passphrase using standard Swing */
+public class SwingUserInfo extends SimpleUserInfo {
+
+       private Boolean alwaysPrompt = false;
+
+       public boolean promptPassphrase(String message) {
+               if (passphrase != null)
+                       return true;
+
+               if (!alwaysPrompt && passphraseSafe != null)
+                       return true;
+
+               PasswordDialog dialog = new PasswordDialog(message) {
+                       private static final long serialVersionUID = 3266299327166418364L;
+
+                       @Override
+                       protected void useCredentials(char[] password) {
+                               passphraseSafe = new char[password.length];
+                               System.arraycopy(password, 0, passphraseSafe, 0,
+                                               password.length);
+                               // passphraseSafe = Arrays.copyOf(password, password.length);
+                       }
+               };
+               dialog.setVisible(true);
+               return dialog.getWasProvided();
+       }
+
+       public boolean promptPassword(String message) {
+               if (password != null)
+                       return true;
+
+               if (!alwaysPrompt && passwordSafe != null)
+                       return true;
+
+               PasswordDialog dialog = new PasswordDialog(message) {
+                       private static final long serialVersionUID = 3266299327166418364L;
+
+                       @Override
+                       protected void useCredentials(char[] password) {
+                               // passwordSafe = Arrays.copyOf(password, password.length);
+                               passwordSafe = new char[password.length];
+                               System.arraycopy(password, 0, passwordSafe, 0, password.length);
+                       }
+               };
+               dialog.setVisible(true);
+               return dialog.getWasProvided();
+       }
+
+       public void setAlwaysPrompt(Boolean alwaysPrompt) {
+               this.alwaysPrompt = alwaysPrompt;
+       }
+
+       protected static class PasswordDialog extends JDialog implements
+                       ActionListener {
+               private static final long serialVersionUID = 3399155607980846207L;
+
+               private static final String OK = "ok";
+
+               private JPasswordField password = new JPasswordField("", 10);
+
+               private JButton okButton;
+               private JButton cancelButton;
+
+               private Boolean wasProvided = false;
+
+               public PasswordDialog(String title) {
+                       setTitle(title);
+                       setModal(true);
+                       setLocationRelativeTo(null);
+                       setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+
+                       JPanel p1 = new JPanel(new GridLayout(1, 2, 3, 3));
+                       p1.add(new JLabel("Password"));
+                       password.setActionCommand(OK);
+                       password.addActionListener(this);
+                       p1.add(password);
+                       add("Center", p1);
+
+                       Panel p2 = new Panel();
+                       okButton = addButton(p2, "OK");
+                       okButton.setActionCommand(OK);
+                       cancelButton = addButton(p2, "Cancel");
+                       add("South", p2);
+                       setSize(240, 120);
+
+                       pack();
+               }
+
+               /** To be overridden */
+               protected void useCredentials(char[] password) {
+                       // does nothing
+               }
+
+               private JButton addButton(Container c, String name) {
+                       JButton button = new JButton(name);
+                       button.addActionListener(this);
+                       c.add(button);
+                       return button;
+               }
+
+               public final void actionPerformed(ActionEvent evt) {
+                       Object source = evt.getSource();
+                       if (source == okButton || evt.getActionCommand().equals(OK)) {
+                               char[] p = password.getPassword();
+                               useCredentials(p);
+                               wasProvided = true;
+                               Arrays.fill(p, '0');
+                               cleanUp();
+                       } else if (source == cancelButton)
+                               cleanUp();
+               }
+
+               private void cleanUp() {
+                       password.setText("");
+                       dispose();
+               }
+
+               public Boolean getWasProvided() {
+                       return wasProvided;
+               }
+
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/jaas.cfg b/legacy/org.argeo.slc.support/src/org/argeo/slc/jsch/jaas.cfg
new file mode 100644 (file)
index 0000000..21176b9
--- /dev/null
@@ -0,0 +1,5 @@
+SINGLE_USER {
+    com.sun.security.auth.module.Krb5LoginModule optional
+     principal="${user.name}"
+     useTicketCache=true;
+};
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/jcr/JcrRepositoryBackup.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/jcr/JcrRepositoryBackup.java
new file mode 100644 (file)
index 0000000..977bf87
--- /dev/null
@@ -0,0 +1,222 @@
+package org.argeo.slc.lib.jcr;
+
+import java.util.UUID;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.FileSelectInfo;
+import org.apache.commons.vfs2.FileSelector;
+import org.apache.commons.vfs2.FileSystemException;
+import org.apache.commons.vfs2.FileSystemManager;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.api.NodeUtils;
+import org.argeo.slc.SlcException;
+
+/** Backups a JCR repository */
+public class JcrRepositoryBackup implements Runnable {
+       private final static Log log = LogFactory.getLog(JcrRepositoryBackup.class);
+
+       private String sourceRepo;
+       private String sourceDatastore;
+       private String targetFile;
+
+       private String sourceWksp;
+
+       private String sourceUsername;
+       private char[] sourcePassword;
+
+       private RepositoryFactory repositoryFactory;
+       private FileSystemManager fileSystemManager;
+
+       public void run() {
+               Session sourceDefaultSession = null;
+               try {
+                       long begin = System.currentTimeMillis();
+
+                       FileObject archiveRoot = fileSystemManager.resolveFile(targetFile);
+                       archiveRoot.createFolder();
+
+                       String datastoreFolderName = "datastore";
+                       if (hasDatastore())
+                               backupDataStore(archiveRoot.resolveFile(datastoreFolderName));
+
+                       Repository sourceRepository = NodeUtils.getRepositoryByUri(
+                                       repositoryFactory, sourceRepo);
+                       Credentials sourceCredentials = null;
+                       if (sourceUsername != null)
+                               sourceCredentials = new SimpleCredentials(sourceUsername,
+                                               sourcePassword);
+
+                       sourceDefaultSession = sourceRepository.login(sourceCredentials);
+                       for (String sourceWorkspaceName : sourceDefaultSession
+                                       .getWorkspace().getAccessibleWorkspaceNames()) {
+                               if (Thread.interrupted()) {
+                                       log.error("Workspace backup interrupted");
+                                       Thread.currentThread().interrupt();
+                                       return;
+                               }
+
+                               if (sourceWksp != null && !sourceWksp.trim().equals("")
+                                               && !sourceWorkspaceName.equals(sourceWksp))
+                                       continue;
+                               Session sourceSession = null;
+                               JarOutputStream out = null;
+                               FileObject workspaceBackup = null;
+                               try {
+                                       Manifest manifest = new Manifest();
+                                       manifest.getMainAttributes().put(
+                                                       Attributes.Name.MANIFEST_VERSION, "1.0");
+                                       manifest.getMainAttributes().putValue("Backup-UUID",
+                                                       UUID.randomUUID().toString());
+                                       manifest.getMainAttributes().putValue("Backup-Timestamp",
+                                                       Long.toString(System.currentTimeMillis()));
+                                       manifest.getMainAttributes().putValue(
+                                                       "Backup-JCR-Workspace", sourceWorkspaceName);
+                                       workspaceBackup = fileSystemManager.resolveFile(targetFile
+                                                       + "/" + sourceWorkspaceName + ".jar");
+
+                                       out = new JarOutputStream(workspaceBackup.getContent()
+                                                       .getOutputStream(), manifest);
+                                       sourceSession = sourceRepository.login(sourceCredentials,
+                                                       sourceWorkspaceName);
+                                       backupWorkspace(sourceSession, out);
+                               } finally {
+                                       JcrUtils.logoutQuietly(sourceSession);
+                                       IOUtils.closeQuietly(out);
+                                       if (workspaceBackup != null)
+                                               workspaceBackup.close();
+                               }
+                       }
+
+                       // in case some binaries have been added during the backup
+                       if (hasDatastore())
+                               backupDataStore(archiveRoot.resolveFile(datastoreFolderName));
+
+                       long duration = (System.currentTimeMillis() - begin) / 1000;// s
+                       log.info("Backed-up " + sourceRepo + " in " + (duration / 60)
+                                       + "min " + (duration % 60) + "s");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot backup " + sourceRepo, e);
+               } finally {
+                       JcrUtils.logoutQuietly(sourceDefaultSession);
+               }
+       }
+
+       protected Boolean hasDatastore() {
+               return sourceDatastore != null && !sourceDatastore.trim().equals("");
+       }
+
+       protected void backupWorkspace(Session sourceSession, JarOutputStream out) {
+               try {
+                       if (log.isTraceEnabled())
+                               log.trace("Backup " + sourceSession.getWorkspace().getName()
+                                               + "...");
+                       Boolean skipBinaries = hasDatastore();
+                       for (NodeIterator it = sourceSession.getRootNode().getNodes(); it
+                                       .hasNext();) {
+                               if (Thread.interrupted()) {
+                                       log.error("Node backup interrupted");
+                                       Thread.currentThread().interrupt();
+                                       return;
+                               }
+                               Node node = it.nextNode();
+                               JarEntry entry = new JarEntry(node.getPath());
+                               out.putNextEntry(entry);
+                               sourceSession.exportSystemView(node.getPath(), out,
+                                               skipBinaries, false);
+                               out.flush();
+                               out.closeEntry();
+                       }
+                       if (log.isDebugEnabled())
+                               log.debug("Backed up " + sourceSession.getWorkspace().getName());
+               } catch (Exception e) {
+                       throw new SlcException("Cannot backup "
+                                       + sourceSession.getWorkspace().getName(), e);
+               }
+       }
+
+       protected void backupDataStore(final FileObject targetDatastore) {
+               try {
+                       targetDatastore.createFolder();
+                       final FileObject sourceDataStore = fileSystemManager
+                                       .resolveFile(sourceDatastore);
+                       if (log.isDebugEnabled())
+                               log.debug("Backup " + sourceDatastore);
+                       targetDatastore.copyFrom(sourceDataStore, new FileSelector() {
+                               public boolean traverseDescendents(FileSelectInfo fileInfo)
+                                               throws Exception {
+                                       return true;
+                               }
+
+                               public boolean includeFile(FileSelectInfo fileInfo)
+                                               throws Exception {
+                                       String relativeName = fileInfo
+                                                       .getFile()
+                                                       .getName()
+                                                       .getPath()
+                                                       .substring(
+                                                                       sourceDataStore.getName().getPath()
+                                                                                       .length());
+                                       FileObject target = targetDatastore
+                                                       .resolveFile(relativeName);
+                                       if (target.exists()) {
+                                               return false;
+                                       } else {
+                                               return true;
+                                       }
+                               }
+                       });
+                       if (log.isDebugEnabled())
+                               log.debug("Backed-up " + sourceDatastore);
+               } catch (FileSystemException e) {
+                       throw new SlcException("Cannot backup datastore", e);
+               }
+       }
+
+       public void setSourceRepo(String sourceRepo) {
+               this.sourceRepo = sourceRepo;
+       }
+
+       public void setSourceWksp(String sourceWksp) {
+               this.sourceWksp = sourceWksp;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setSourceUsername(String sourceUsername) {
+               this.sourceUsername = sourceUsername;
+       }
+
+       public void setSourcePassword(char[] sourcePassword) {
+               this.sourcePassword = sourcePassword;
+       }
+
+       public void setFileSystemManager(FileSystemManager fileSystemManager) {
+               this.fileSystemManager = fileSystemManager;
+       }
+
+       public void setTargetFile(String targetFile) {
+               this.targetFile = targetFile;
+       }
+
+       public void setSourceDatastore(String sourceDatastore) {
+               this.sourceDatastore = sourceDatastore;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRedhatDeploymentData.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRedhatDeploymentData.java
new file mode 100644 (file)
index 0000000..e93b99b
--- /dev/null
@@ -0,0 +1,54 @@
+package org.argeo.slc.lib.linux;
+
+import org.argeo.slc.core.deploy.MultiResourceSet;
+import org.argeo.slc.core.deploy.ResourceSet;
+
+public class DefaultRedhatDeploymentData implements RedhatDeploymentData {
+       private ResourceSet configurationFiles;
+       private String runlevelsScript;
+       private String permissionsScript;
+
+       private RedhatDeploymentData parent;
+
+       public ResourceSet getConfigurationFiles() {
+               if (parent != null && parent.getConfigurationFiles() != null) {
+                       MultiResourceSet mrs = new MultiResourceSet();
+                       mrs.getResourceSets().add(parent.getConfigurationFiles());
+                       mrs.getResourceSets().add(configurationFiles);
+                       return mrs;
+               } else {
+                       return configurationFiles;
+               }
+       }
+
+       public String getRunlevelsScript() {
+               if (parent != null && parent.getRunlevelsScript() != null)
+                       return parent.getRunlevelsScript() + "\n" + runlevelsScript;
+               else
+                       return runlevelsScript;
+       }
+
+       public String getPermissionsScript() {
+               if (parent != null && parent.getPermissionsScript() != null)
+                       return parent.getPermissionsScript() + "\n" + permissionsScript;
+               else
+                       return permissionsScript;
+       }
+
+       public void setRunlevelsScript(String runlevelsScript) {
+               this.runlevelsScript = runlevelsScript;
+       }
+
+       public void setConfigurationFiles(ResourceSet configurationFiles) {
+               this.configurationFiles = configurationFiles;
+       }
+
+       public void setPermissionsScript(String permissionsScript) {
+               this.permissionsScript = permissionsScript;
+       }
+
+       public void setParent(RedhatDeploymentData parentDeploymentData) {
+               this.parent = parentDeploymentData;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRpmDistribution.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DefaultRpmDistribution.java
new file mode 100644 (file)
index 0000000..5722bc1
--- /dev/null
@@ -0,0 +1,21 @@
+package org.argeo.slc.lib.linux;
+
+import java.util.List;
+
+public class DefaultRpmDistribution implements RpmDistribution {
+       private List<String> additionalPackages;
+
+       public String getDistributionId() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public List<String> getAdditionalPackages() {
+               return additionalPackages;
+       }
+
+       public void setAdditionalPackages(List<String> additionalPackages) {
+               this.additionalPackages = additionalPackages;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DeployLxcContainer.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/DeployLxcContainer.java
new file mode 100644 (file)
index 0000000..3325dc0
--- /dev/null
@@ -0,0 +1,84 @@
+package org.argeo.slc.lib.linux;
+
+import java.io.File;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.tasks.SystemCall;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/** Deploy and initialize an LXC container. */
+public class DeployLxcContainer implements Runnable {
+
+       private String chroot;
+
+       private Resource hostScript = new ClassPathResource(
+                       "/org/argeo/slc/lib/linux/lxc-init-host.sh", getClass()
+                                       .getClassLoader());
+       private Resource guestScript = new ClassPathResource(
+                       "/org/argeo/slc/lib/linux/lxc-init-guest.sh", getClass()
+                                       .getClassLoader());;
+
+       // private CallbackHandler callbackHandler;
+
+       private Integer ram = 1024;
+       private Integer vcpu = 2;
+
+       @Override
+       public void run() {
+               if (chroot == null || chroot.trim().equals(""))
+                       throw new SlcException("A chroot directory must be defined");
+
+               File chrootDir = new File(chroot);
+               chrootDir.mkdirs();
+
+               ScriptCall hostCall = new ScriptCall(hostScript);
+               hostCall.setLogCommand(true);
+               hostCall.arg(chroot);
+               // hostCall.getEnvironmentVariables().put("CHROOT", chroot);
+               // hostCall.setSudo("");
+               // hostCall.setCallbackHandler(callbackHandler);
+               hostCall.run();
+
+               ScriptCall guestCall = new ScriptCall(guestScript);
+               guestCall.setLogCommand(true);
+               // guestCall.setSudo("");
+               // guestCall.setCallbackHandler(callbackHandler);
+               guestCall.setChroot(chroot);
+               guestCall.run();
+
+               SystemCall virtInstall = new SystemCall(
+                               "virt-install --connect lxc:/// --name " + chrootDir.getName()
+                                               + " --ram " + ram + " --vcpu " + vcpu
+                                               + " --filesystem " + chrootDir.getAbsolutePath()
+                                               + ",/ --noautoconsole");
+               virtInstall.setLogCommand(true);
+               // virtInstall.setSudo("");
+               virtInstall.run();
+       }
+
+       public void setChroot(String chroot) {
+               this.chroot = chroot;
+       }
+
+       public void setHostScript(Resource hostScript) {
+               this.hostScript = hostScript;
+       }
+
+       public void setGuestScript(Resource guestScript) {
+               this.guestScript = guestScript;
+       }
+
+       // public void setCallbackHandler(CallbackHandler callbackHandler) {
+       // this.callbackHandler = callbackHandler;
+       // }
+
+       public void setRam(Integer ram) {
+               this.ram = ram;
+       }
+
+       public void setVcpu(Integer vcpu) {
+               this.vcpu = vcpu;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatDeploymentData.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatDeploymentData.java
new file mode 100644 (file)
index 0000000..39592b7
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.lib.linux;
+
+import org.argeo.slc.core.deploy.ResourceSet;
+import org.argeo.slc.deploy.DeploymentData;
+
+public interface RedhatDeploymentData extends DeploymentData {
+       public ResourceSet getConfigurationFiles();
+
+       public String getRunlevelsScript();
+
+       public String getPermissionsScript();
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatHostManager.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RedhatHostManager.java
new file mode 100644 (file)
index 0000000..8b1c5e5
--- /dev/null
@@ -0,0 +1,78 @@
+package org.argeo.slc.lib.linux;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.deploy.LocalFilesDeployment;
+import org.argeo.slc.core.deploy.ResourceSet;
+import org.argeo.slc.core.execution.tasks.SystemCall;
+import org.argeo.slc.jsch.RemoteExec;
+import org.argeo.slc.jsch.SshFilesDeployment;
+import org.argeo.slc.jsch.SshTarget;
+
+public class RedhatHostManager {
+
+       private SimpleLinuxHost host;
+
+       // SSH
+       private Boolean useSsh = true;
+       private SshTarget sshTarget = null;
+
+       public void installPackages() {
+               StringBuffer cmd = new StringBuffer("yum --nogpgcheck -y install");
+               for (String pkg : ((RpmDistribution) host.getDistribution())
+                               .getAdditionalPackages()) {
+                       cmd.append(' ').append(pkg);
+               }
+               executeCommand(cmd.toString());
+
+               RedhatDeploymentData rdd = (RedhatDeploymentData) host
+                               .getDeploymentData();
+               executeCommand(rdd.getRunlevelsScript());
+       }
+
+       public void deployConfig() {
+               RedhatDeploymentData rdd = (RedhatDeploymentData) host
+                               .getDeploymentData();
+               deploy(rdd.getConfigurationFiles());
+               executeCommand(rdd.getPermissionsScript());
+       }
+
+       // GENERIC?
+       protected void deploy(ResourceSet resourceSet) {
+               if (useSsh)
+                       new SshFilesDeployment(getSshTarget(), resourceSet).run();
+               else
+                       new LocalFilesDeployment(resourceSet).run();
+
+       }
+
+       protected void executeCommand(String command) {
+               if (command == null)
+                       return;
+
+               if (useSsh) {
+                       RemoteExec rExec = new RemoteExec(getSshTarget(), command);
+                       rExec.setFailOnBadExitStatus(false);
+                       rExec.run();
+               } else
+                       new SystemCall(command).run();
+       }
+
+       protected SshTarget getSshTarget() {
+               if (sshTarget == null)
+                       throw new SlcException("No SSH target defined");
+               return sshTarget;
+       }
+
+       public void setHost(SimpleLinuxHost host) {
+               this.host = host;
+       }
+
+       public void setUseSsh(Boolean useSsh) {
+               this.useSsh = useSsh;
+       }
+
+       public void setSshTarget(SshTarget sshTarget) {
+               this.sshTarget = sshTarget;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RpmDistribution.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/RpmDistribution.java
new file mode 100644 (file)
index 0000000..66e7969
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.lib.linux;
+
+import java.util.List;
+
+import org.argeo.slc.build.Distribution;
+
+public interface RpmDistribution extends Distribution {
+       public List<String> getAdditionalPackages();
+
+       public void setAdditionalPackages(List<String> additionalPackages);
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/ScriptCall.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/ScriptCall.java
new file mode 100644 (file)
index 0000000..755fa0c
--- /dev/null
@@ -0,0 +1,104 @@
+package org.argeo.slc.lib.linux;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.tasks.SystemCall;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
+
+/** Call to the interpreter of a script language. */
+public class ScriptCall extends SystemCall implements InitializingBean {
+       private Resource script;
+       private List<Object> scriptArgs = new ArrayList<Object>();
+
+       private Boolean localScriptCopy = false;
+
+       /** For use in Spring. */
+       public ScriptCall() {
+               super();
+       }
+
+       /** For use in code ({@link #init()} is called). */
+       public ScriptCall(Resource script) {
+               this.script = script;
+               init();
+       }
+
+       public void init() {
+               initInterpreter();
+               for (Object obj : scriptArgs) {
+                       arg(obj.toString());
+               }
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               init();
+       }
+
+       protected void initInterpreter() {
+               String ext = FilenameUtils.getExtension(script.getFilename());
+
+               if (localScriptCopy) {
+                       File scriptFile = copyScript();
+                       if ("sh".equals(ext))
+                               arg("/bin/sh").arg(scriptFile.getAbsolutePath());
+                       else if ("pl".equals(ext))
+                               arg("/usr/bin/perl").arg(scriptFile.getAbsolutePath());
+                       else if ("py".equals(ext))
+                               arg("/usr/bin/python").arg(scriptFile.getAbsolutePath());
+                       else
+                               throw new SlcException(
+                                               "Cannot initialize script intepreter for " + script);
+               } else {
+                       setStdInFile(script);
+                       if ("sh".equals(ext))
+                               arg("/bin/sh").arg("-s");
+                       else if ("pl".equals(ext))
+                               arg("/usr/bin/perl").arg("/dev/stdin");
+                       else if ("py".equals(ext))
+                               arg("/usr/bin/python").arg("-");
+                       else
+                               throw new SlcException(
+                                               "Cannot initialize script intepreter for " + script);
+               }
+       }
+
+       private File copyScript() {
+               InputStream in = null;
+               OutputStream out = null;
+               try {
+                       File scriptFile = File.createTempFile("script", ".sh");
+                       scriptFile.deleteOnExit();
+                       in = script.getInputStream();
+                       out = new FileOutputStream(scriptFile);
+                       IOUtils.copy(in, out);
+                       return scriptFile;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot copy " + script, e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+                       IOUtils.closeQuietly(out);
+               }
+       }
+
+       public void setScript(Resource script) {
+               this.script = script;
+       }
+
+       public void setScriptArgs(List<Object> scriptArgs) {
+               this.scriptArgs = scriptArgs;
+       }
+
+       public void setLocalScriptCopy(Boolean localScriptCopy) {
+               this.localScriptCopy = localScriptCopy;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/SimpleLinuxHost.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/SimpleLinuxHost.java
new file mode 100644 (file)
index 0000000..d51497a
--- /dev/null
@@ -0,0 +1,42 @@
+package org.argeo.slc.lib.linux;
+
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.deploy.DeployedSystem;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.TargetData;
+
+public class SimpleLinuxHost implements DeployedSystem {
+       private DeploymentData deploymentData;
+       private Distribution distribution;
+       private TargetData targetData;
+
+       public String getDeployedSystemId() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public DeploymentData getDeploymentData() {
+               return deploymentData;
+       }
+
+       public void setDeploymentData(DeploymentData deploymentData) {
+               this.deploymentData = deploymentData;
+       }
+
+       public Distribution getDistribution() {
+               return distribution;
+       }
+
+       public void setDistribution(Distribution distribution) {
+               this.distribution = distribution;
+       }
+
+       public TargetData getTargetData() {
+               return targetData;
+       }
+
+       public void setTargetData(TargetData targetData) {
+               this.targetData = targetData;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-guest.sh b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-guest.sh
new file mode 100644 (file)
index 0000000..11ecc4e
--- /dev/null
@@ -0,0 +1,29 @@
+echo demo | passwd root --stdin
+
+#Fix root login on console
+echo "pts/0" >>/etc/securetty
+sed -i s/"session    required     pam_selinux.so close"/"#session    required     pam_selinux.so close"/g /etc/pam.d/login
+sed -i s/"session    required     pam_selinux.so open"/"#session    required     pam_selinux.so open"/g /etc/pam.d/login
+sed -i s/"session    required     pam_loginuid.so"/"#session    required     pam_loginuid.so"/g /etc/pam.d/login
+
+#Configuring basic networking
+cat > /etc/sysconfig/network << EOF
+NETWORKING=yes
+HOSTNAME=demo
+EOF
+cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
+DEVICE=eth0
+BOOTPROTO=dhcp
+ONBOOT=yes
+EOF
+
+#Enabling sshd
+chkconfig sshd on
+
+# Fixing root login for sshd
+sed -i s/"session    required     pam_selinux.so close"/"#session    required     pam_selinux.so close"/g /etc/pam.d/sshd
+sed -i s/"session    required     pam_loginuid.so"/"#session    required     pam_loginuid.so"/g /etc/pam.d/sshd
+sed -i s/"session    required     pam_selinux.so open env_params"/"#session    required     pam_selinux.so open env_params"/g /etc/pam.d/sshd
+
+# Leaving the chroot'ed filesystem
+exit
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-host.sh b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/lxc-init-host.sh
new file mode 100644 (file)
index 0000000..9e0d75d
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+CHROOT=$1
+echo Init LXC container $CHROOT
+
+mkdir $CHROOT/etc/yum.repos.d/ -p  
+cat /etc/yum.repos.d/CentOS-Base.repo |sed s/'$releasever'/6/g > $CHROOT/etc/yum.repos.d/CentOS-Base.repo
+yum groupinstall core --installroot=$CHROOT --nogpgcheck -y
+yum install plymouth libselinux-python --installroot=$CHROOT --nogpgcheck -y
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/redhat.xml b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/redhat.xml
new file mode 100644 (file)
index 0000000..8379b8a
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+\r
+    Copyright (C) 2007-2012 Argeo GmbH\r
+\r
+    Licensed under the Apache License, Version 2.0 (the "License");\r
+    you may not use this file except in compliance with the License.\r
+    You may obtain a copy of the License at\r
+\r
+            http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+    Unless required by applicable law or agreed to in writing, software\r
+    distributed under the License is distributed on an "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+    See the License for the specific language governing permissions and\r
+    limitations under the License.\r
+\r
+-->\r
+<!-- Copyright (C) 2007-2012 Mathieu Baudier Licensed under the Apache License, \r
+       Version 2.0 (the "License"); you may not use this file except in compliance \r
+       with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 \r
+       Unless required by applicable law or agreed to in writing, software distributed \r
+       under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES \r
+       OR CONDITIONS OF ANY KIND, either express or implied. See the License for \r
+       the specific language governing permissions and limitations under the License. -->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
+       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
+       xsi:schemaLocation="\r
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
+       http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-1.2.xsd">\r
+\r
+       <bean id="hostManager" class="org.argeo.slc.lib.linux.RedhatHostManager">\r
+               <property name="sshTarget" ref="sshTarget" />\r
+               <property name="host" ref="host" />\r
+       </bean>\r
+\r
+       <!-- Execution Flows -->\r
+       <bean flow:as-flow="deployConfig" class="org.argeo.slc.core.execution.tasks.MethodCall"\r
+               p:target-ref="hostManager" p:method="deployConfig" />\r
+\r
+       <bean flow:as-flow="system/reboot" p:command="shutdown -r now"\r
+               p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec" />\r
+\r
+       <bean flow:as-flow="system/shutdown" p:command="shutdown -h now"\r
+               p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec" />\r
+\r
+       <bean flow:as-flow="system/packages/install" class="org.argeo.slc.core.execution.tasks.MethodCall"\r
+               p:target-ref="hostManager" p:method="installPackages" />\r
+\r
+       <bean flow:as-flow="system/packages/update" p:sshTarget-ref="sshTarget"\r
+               class="org.argeo.slc.jsch.RemoteExec">\r
+               <property name="systemCall">\r
+                       <bean class="org.argeo.slc.core.execution.tasks.SystemCall">\r
+                               <property name="cmd" value="yum -y update" />\r
+                       </bean>\r
+               </property>\r
+       </bean>\r
+\r
+       <bean flow:as-flow="system/security/firewall" p:script="osgibundle:/scripts/firewall.sh"\r
+               p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec" />\r
+\r
+       <flow:flow name="system/security/authconfig">\r
+               <flow:spec>\r
+                       <flow:primitive name="ldapserver" />\r
+                       <flow:primitive name="ldapbasedn" />\r
+               </flow:spec>\r
+               <bean p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec">\r
+                       <flow:variable />\r
+                       <property name="systemCall">\r
+                               <bean class="org.argeo.slc.core.execution.tasks.SystemCall">\r
+                                       <property name="command">\r
+                                               <list>\r
+                                                       <value>authconfig</value>\r
+                                                       <value>--enableldap</value>\r
+                                                       <value>--enableldapauth</value>\r
+                                                       <value>--enablecache</value>\r
+                                                       <value>--enablemkhomedir</value>\r
+                                                       <value>--ldapserver=@{ldapserver}</value>\r
+                                                       <value>--ldapbasedn=@{ldapbasedn}</value>\r
+                                                       <value>--passalgo=sha256</value>\r
+                                                       <value>--updateall</value>\r
+                                               </list>\r
+                                       </property>\r
+                               </bean>\r
+                       </property>\r
+               </bean>\r
+       </flow:flow>\r
+\r
+</beans>
\ No newline at end of file
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/BuildInMock.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/BuildInMock.java
new file mode 100644 (file)
index 0000000..44c4e0c
--- /dev/null
@@ -0,0 +1,198 @@
+package org.argeo.slc.lib.linux.rpmfactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.exec.Executor;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.tasks.SystemCall;
+
+/** Rebuild an SRPM in mock. (Historical) Replaces the build-mock.sh script. */
+public class BuildInMock implements Runnable {
+       private final static Log log = LogFactory.getLog(BuildInMock.class);
+
+       /** Mock flavour provided by the EPEL repository */
+       public final static String EPEL = "EPEL";
+       /** Mock flavour provided by CentOS until v5 */
+       public final static String CENTOS = "CENTOS";
+
+       public final static String NOARCH = "noarch";
+
+       private String mockVar = "/var/lib/mock";
+
+       private String mockFlavour = EPEL;
+       private String mockConfig = null;
+
+       private String repository;
+       private String release = null;
+       private String level = null;
+       private String arch = NOARCH;
+
+       private String rpmPackage = null;
+
+       private Boolean mkdirs = true;
+
+       private RpmBuildEnvironment buildEnvironment;
+       private Executor executor;
+
+       private String debuginfoDirName = "debuginfo";
+
+       public void run() {
+               // TODO check if caller is in mock group
+
+               String cfgId = repository + "-" + release + "-" + arch;
+               String cfg = mockConfig != null ? mockConfig : "slc/" + cfgId;
+
+               // prepare mock call
+               SystemCall mock = new SystemCall();
+               if (arch != null)
+                       mock.arg("setarch").arg(arch);
+               mock.arg("mock");
+               if (mockFlavour.equals(EPEL))
+                       mock.arg("-v");
+               else if (mockFlavour.equals(CENTOS))
+                       mock.arg("--debug");
+               if (arch != null)
+                       mock.arg("--arch=" + arch);
+               mock.arg("-r").arg(cfg);
+
+               mock.arg("--scm-enable");
+               mock.arg("--scm-option").arg("package=" + rpmPackage);
+
+               mock.setLogCommand(true);
+
+               // mock command execution
+               mock.setExecutor(executor);
+               mock.run();
+
+               // File repoDir = new File(buildEnvironment.getStagingBase() + "/"
+               // + repository + "/" + level + "/" + release);
+               File repoDir = new File(buildEnvironment.getStagingBase() + "/"
+                               + repository + "-" + release + "-staging");
+               File srpmDir = new File(repoDir, "SRPMS");
+               if (mkdirs)
+                       srpmDir.mkdirs();
+               File archDir = null;
+               File debuginfoDir = null;
+               if (!arch.equals(NOARCH)) {
+                       archDir = new File(repoDir, arch);
+                       debuginfoDir = new File(archDir, debuginfoDirName);
+                       debuginfoDir.mkdirs();
+               }
+
+               // copy RPMs
+               Set<File> reposToRecreate = new HashSet<File>();
+               File resultDir = new File(mockVar + "/" + cfgId + "/result");
+               rpms: for (File file : resultDir.listFiles()) {
+                       if (file.isDirectory())
+                               continue rpms;
+
+                       File[] targetDirs;
+                       if (file.getName().contains(".src.rpm"))
+                               targetDirs = new File[] { srpmDir };
+                       else if (file.getName().contains("-debuginfo-"))
+                               targetDirs = new File[] { debuginfoDir };
+                       else if (!arch.equals(NOARCH)
+                                       && file.getName().contains("." + arch + ".rpm"))
+                               targetDirs = new File[] { archDir };
+                       else if (file.getName().contains(".noarch.rpm")) {
+                               List<File> dirs = new ArrayList<File>();
+                               for (String arch : buildEnvironment.getArchs())
+                                       dirs.add(new File(repoDir, arch));
+                               targetDirs = dirs.toArray(new File[dirs.size()]);
+                       } else if (file.getName().contains(".rpm"))
+                               throw new SlcException("Don't know where to copy " + file);
+                       else {
+                               if (log.isTraceEnabled())
+                                       log.trace("Skip " + file);
+                               continue rpms;
+                       }
+
+                       reposToRecreate.addAll(Arrays.asList(targetDirs));
+                       copyToDirs(file, targetDirs);
+               }
+
+               // recreate changed repos
+               for (File repoToRecreate : reposToRecreate) {
+                       SystemCall createrepo = new SystemCall();
+                       createrepo.arg("createrepo");
+                       // sqllite db
+                       createrepo.arg("-d");
+                       // debuginfo
+                       if (!repoToRecreate.getName().equals(debuginfoDirName))
+                               createrepo.arg("-x").arg(debuginfoDirName + "/*");
+                       // quiet
+                       createrepo.arg("-q");
+                       createrepo.arg(repoToRecreate.getAbsolutePath());
+
+                       createrepo.setExecutor(executor);
+                       createrepo.run();
+                       log.info("Updated repo " + repoToRecreate);
+               }
+       }
+
+       protected void copyToDirs(File file, File[] dirs) {
+               for (File dir : dirs) {
+                       try {
+                               FileUtils.copyFileToDirectory(file, dir);
+                               if (log.isDebugEnabled())
+                                       log.debug(file + " => " + dir);
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot copy " + file + " to " + dir, e);
+                       }
+               }
+       }
+
+       public void setMockFlavour(String mockFlavour) {
+               this.mockFlavour = mockFlavour;
+       }
+
+       public void setMockConfig(String mockConfig) {
+               this.mockConfig = mockConfig;
+       }
+
+       public void setRepository(String repo) {
+               this.repository = repo;
+       }
+
+       public void setRelease(String release) {
+               this.release = release;
+       }
+
+       public void setLevel(String level) {
+               this.level = level;
+       }
+
+       public void setArch(String arch) {
+               this.arch = arch;
+       }
+
+       public void setRpmPackage(String rpmPackage) {
+               this.rpmPackage = rpmPackage;
+       }
+
+       public void setMockVar(String mockVar) {
+               this.mockVar = mockVar;
+       }
+
+       public void setMkdirs(Boolean mkdirs) {
+               this.mkdirs = mkdirs;
+       }
+
+       public void setBuildEnvironment(RpmBuildEnvironment buildEnvironment) {
+               this.buildEnvironment = buildEnvironment;
+       }
+
+       public void setExecutor(Executor executor) {
+               this.executor = executor;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/CreateSrpm.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/CreateSrpm.java
new file mode 100644 (file)
index 0000000..04680df
--- /dev/null
@@ -0,0 +1,211 @@
+package org.argeo.slc.lib.linux.rpmfactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.exec.Executor;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.tasks.SystemCall;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+
+/** Generates an SRPM from a spec file */
+public class CreateSrpm implements Runnable {
+       private final static Log log = LogFactory.getLog(CreateSrpm.class);
+
+       private File topdir;
+
+       /** Directory where to cache downloaded distributions. */
+       private File distributionCache;
+
+       private Resource specFile;
+
+       private RpmBuildEnvironment rpmBuildEnvironment;
+
+       private Boolean overwriteSources = false;
+
+       private File srpmFile;
+
+       private Executor executor;
+
+       public void run() {
+               File sourcesDir = new File(topdir, "SOURCES");
+               sourcesDir.mkdirs();
+               File specsDir = new File(topdir, "SPECS");
+               File srpmsDir = new File(topdir, "SRPMS");
+
+               try {
+                       // Parse spec file and copy required resources
+                       RpmSpecFile spec = new RpmSpecFile(specFile);
+                       copyToSources(spec, sourcesDir);
+
+                       // Copy spec file
+                       File targetFile = new File(specsDir, specFile.getFilename())
+                                       .getCanonicalFile();
+                       copyResourceToFile(specFile, targetFile);
+
+                       // Generate rpmbuild config files
+                       rpmBuildEnvironment.writeRpmbuildConfigFiles(topdir);
+
+                       // Build SRPM
+                       srpmsDir.mkdirs();
+                       SystemCall packageSrpm = new SystemCall();
+                       packageSrpm.arg("rpmbuild");
+                       packageSrpm.arg("-bs").arg("--nodeps");
+                       packageSrpm.arg("--rcfile=rpmrc");
+                       packageSrpm.arg("--macros=" + RpmBuildEnvironment.defaultMacroFiles
+                                       + ":rpmmacros");
+                       // buildSrpm.arg("-D", "_topdir " + topdir.getCanonicalPath() + "");
+                       packageSrpm.arg("SPECS/" + specFile.getFilename());
+                       packageSrpm.setExecDir(topdir.getCanonicalPath());
+                       packageSrpm.setLogCommand(true);
+
+                       // Execute
+                       packageSrpm.setExecutor(executor);
+                       String answer = packageSrpm.function();
+
+                       // Extract generated SRPM path
+                       // TODO: make it safer
+                       String srpmPath = answer.split(":")[1].trim();
+                       srpmFile = new File(srpmPath);
+               } catch (IOException e) {
+                       throw new SlcException("Cannot generate SRPM from " + specFile, e);
+               }
+
+       }
+
+       protected void copyToSources(RpmSpecFile spec, File sourcesDir) {
+               try {
+                       List<Resource> toCopyToSources = new ArrayList<Resource>();
+                       List<Resource> toDownload = new ArrayList<Resource>();
+                       for (String file : spec.getSources().values()) {
+                               try {
+                                       Resource res;
+                                       try {
+                                               res = specFile.createRelative("../SOURCES/" + file);
+                                               if (!res.exists())
+                                                       res = new UrlResource(file);
+
+                                       } catch (Exception e) {
+                                               res = new UrlResource(file);
+                                               toDownload.add(res);
+                                       }
+                                       toCopyToSources.add(res);
+                               } catch (Exception e) {
+                                       log.error("Cannot interpret " + file, e);
+                               }
+                       }
+                       for (String file : spec.getPatches().values()) {
+                               try {
+                                       Resource res;
+                                       try {
+                                               res = specFile.createRelative("../SOURCES/" + file);
+                                               if (!res.exists()) {
+                                                       res = new UrlResource(file);
+                                               }
+                                       } catch (Exception e) {
+                                               res = new UrlResource(file);
+                                               toDownload.add(res);
+                                       }
+                                       toCopyToSources.add(res);
+                               } catch (Exception e) {
+                                       log.error("Cannot interpret " + file, e);
+                               }
+                       }
+
+                       // FIXME: we may have missed some files here
+                       for (Resource res : toCopyToSources) {
+                               File targetDir;
+                               if (distributionCache != null && toDownload.contains(res)) {
+                                       if (!distributionCache.exists())
+                                               distributionCache.mkdirs();
+                                       targetDir = distributionCache;
+                                       if (log.isDebugEnabled())
+                                               log.debug("Cache " + res + " in " + targetDir);
+                               } else
+                                       targetDir = sourcesDir;
+                               File targetFile = new File(targetDir, res.getFilename())
+                                               .getCanonicalFile();
+                               if (!targetFile.exists() || overwriteSources)
+                                       copyResourceToFile(res, targetFile);
+                               if (!targetDir.equals(sourcesDir)) {
+                                       File fileInSourcesDir = new File(sourcesDir,
+                                                       targetFile.getName());
+                                       if (!fileInSourcesDir.exists()
+                                                       || !(fileInSourcesDir.length() == targetFile
+                                                                       .length()))
+                                               FileUtils.copyFile(targetFile, fileInSourcesDir);
+                               }
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot copy to " + sourcesDir, e);
+               }
+       }
+
+       private static void copyResourceToFile(Resource res, File targetFile) {
+               try {
+                       if (targetFile.equals(res.getFile())) {
+                               if (log.isDebugEnabled())
+                                       log.debug("Target identical to source, skipping... "
+                                                       + targetFile + " <=> " + res);
+                               return;
+                       }
+               } catch (IOException e1) {
+                       // silent
+               }
+
+               OutputStream out = null;
+               InputStream in = null;
+               try {
+                       out = FileUtils.openOutputStream(targetFile);
+                       in = res.getInputStream();
+                       IOUtils.copy(in, out);
+                       if (log.isDebugEnabled())
+                               log.debug("Copied " + targetFile + " from " + res);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot copy " + res + " to " + targetFile,
+                                       e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+                       IOUtils.closeQuietly(out);
+               }
+
+       }
+
+       public void setSpecFile(Resource specFile) {
+               this.specFile = specFile;
+       }
+
+       public void setTopdir(File topdir) {
+               this.topdir = topdir;
+       }
+
+       public void setOverwriteSources(Boolean overwriteSources) {
+               this.overwriteSources = overwriteSources;
+       }
+
+       public File getSrpmFile() {
+               return srpmFile;
+       }
+
+       public void setRpmBuildEnvironment(RpmBuildEnvironment rpmBuildEnvironment) {
+               this.rpmBuildEnvironment = rpmBuildEnvironment;
+       }
+
+       public void setDistributionCache(File distributionCache) {
+               this.distributionCache = distributionCache;
+       }
+
+       public void setExecutor(Executor executor) {
+               this.executor = executor;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/ImportSrpm.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/ImportSrpm.java
new file mode 100644 (file)
index 0000000..e005608
--- /dev/null
@@ -0,0 +1,62 @@
+package org.argeo.slc.lib.linux.rpmfactory;
+
+import java.io.File;
+
+import org.argeo.slc.core.execution.tasks.SystemCall;
+
+/** Install an SRPM into a working copy */
+public class ImportSrpm implements Runnable {
+       private File baseDir;
+       private File srpmFile;
+       private RpmBuildEnvironment rpmBuildEnvironment;
+
+       public void run() {
+               SystemCall rpmQuery = new SystemCall(
+                               "rpm --queryformat '%{NAME}\n' -qp " + srpmFile);
+               String packageName = rpmQuery.function();
+
+               File topdir = new File(baseDir, packageName);
+
+               // prepare SVN
+               // TODO: do it with SVNKit
+               topdir.mkdirs();
+               new SystemCall("svn add " + topdir).run();
+               new SystemCall("svn propset svn:ignore rpm*\nBUILD\nSRPMS\nRPMS " + topdir).run();
+               File sourcesDir = new File(topdir, "SOURCES");
+               sourcesDir.mkdirs();
+               new SystemCall("svn add " + sourcesDir).run();
+               new SystemCall("svn propset svn:ignore *gz\n*bz2\n*.zip\n*.jar " + sourcesDir).run();
+               File specsDir = new File(topdir, "SPECS");
+               specsDir.mkdirs();
+               new SystemCall("svn add " + specsDir).run();
+
+               // Write rpm config files
+               File rpmmacroFile = new File(topdir, "rpmmacros");
+               File rpmrcFile = new File(topdir, "rpmrc");
+               rpmBuildEnvironment.writeRpmbuildConfigFiles(topdir, rpmmacroFile,
+                               rpmrcFile);
+
+               // Install SRPM
+               SystemCall installSrpm = new SystemCall();
+               installSrpm.arg("rpm");
+               installSrpm.arg("-Uvh");
+               installSrpm.arg("--rcfile=" + rpmrcFile.getAbsolutePath());
+               installSrpm.arg(srpmFile.getAbsolutePath());
+               installSrpm.setExecDir(topdir.getAbsolutePath());
+               installSrpm.setLogCommand(true);
+               installSrpm.run();
+       }
+
+       public void setBaseDir(File basedir) {
+               this.baseDir = basedir;
+       }
+
+       public void setSrpmFile(File srpmFile) {
+               this.srpmFile = srpmFile;
+       }
+
+       public void setRpmBuildEnvironment(RpmBuildEnvironment rpmBuildEnvironment) {
+               this.rpmBuildEnvironment = rpmBuildEnvironment;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmBuildEnvironment.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmBuildEnvironment.java
new file mode 100644 (file)
index 0000000..17a1f27
--- /dev/null
@@ -0,0 +1,84 @@
+package org.argeo.slc.lib.linux.rpmfactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.FileUtils;
+import org.argeo.slc.SlcException;
+
+/**
+ * Defines a build environment. This information is typically used by other
+ * components performing the various actions related to RPM build.
+ */
+public class RpmBuildEnvironment {
+       static String defaultMacroFiles = "/usr/lib/rpm/macros:/usr/lib/rpm/ia32e-linux/macros:/usr/lib/rpm/redhat/macros:/etc/rpm/macros.*:/etc/rpm/macros:/etc/rpm/ia32e-linux/macros:~/.rpmmacros";
+
+       private Map<String, String> rpmmacros = new HashMap<String, String>();
+
+       private List<String> archs = new ArrayList<String>();
+
+       private String stagingBase = "/mnt/slc/repos/rpm";
+
+       /** Write (topdir)/rpmmacros and (topdir)/rpmrc */
+       public void writeRpmbuildConfigFiles(File topdir) {
+               writeRpmbuildConfigFiles(topdir, new File(topdir, "rpmmacros"),
+                               new File(topdir, "rpmrc"));
+       }
+
+       public void writeRpmbuildConfigFiles(File topdir, File rpmmacroFile,
+                       File rpmrcFile) {
+               try {
+                       List<String> macroLines = new ArrayList<String>();
+                       macroLines.add("%_topdir " + topdir.getCanonicalPath());
+                       for (String macroKey : rpmmacros.keySet()) {
+                               macroLines.add(macroKey + " " + rpmmacros.get(macroKey));
+                       }
+                       FileUtils.writeLines(rpmmacroFile, macroLines);
+
+                       List<String> rpmrcLines = new ArrayList<String>();
+                       rpmrcLines.add("include: /usr/lib/rpm/rpmrc");
+                       rpmrcLines.add("macrofiles: " + defaultMacroFiles + ":"
+                                       + rpmmacroFile.getCanonicalPath());
+                       FileUtils.writeLines(rpmrcFile, rpmrcLines);
+               } catch (IOException e) {
+                       throw new SlcException("Cannot write rpmbuild config files", e);
+               }
+
+       }
+
+       public Map<String, String> getRpmmacros() {
+               return rpmmacros;
+       }
+
+       public void setRpmmacros(Map<String, String> rpmmacros) {
+               this.rpmmacros = rpmmacros;
+       }
+
+       public String getDefaultMacroFiles() {
+               return defaultMacroFiles;
+       }
+
+       public void setDefaultMacroFiles(String defaultMacroFiles) {
+               this.defaultMacroFiles = defaultMacroFiles;
+       }
+
+       public void setArchs(List<String> archs) {
+               this.archs = archs;
+       }
+
+       public List<String> getArchs() {
+               return archs;
+       }
+
+       public String getStagingBase() {
+               return stagingBase;
+       }
+
+       public void setStagingBase(String stagingBase) {
+               this.stagingBase = stagingBase;
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmSpecFile.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/linux/rpmfactory/RpmSpecFile.java
new file mode 100644 (file)
index 0000000..899603a
--- /dev/null
@@ -0,0 +1,113 @@
+package org.argeo.slc.lib.linux.rpmfactory;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.core.io.Resource;
+
+public class RpmSpecFile {
+       private Resource specFile;
+
+       private String name;
+       private String version;
+       private String release;
+       private Map<String, String> sources = new HashMap<String, String>();
+       private Map<String, String> patches = new HashMap<String, String>();
+
+       public RpmSpecFile(Resource specFile) {
+               this.specFile = specFile;
+               parseSpecFile();
+       }
+
+       public void init() {
+               parseSpecFile();
+       }
+
+       @SuppressWarnings("unchecked")
+       protected void parseSpecFile() {
+               try {
+                       List<String> lines = (List<String>) IOUtils.readLines(specFile
+                                       .getInputStream());
+
+                       lines: for (String line : lines) {
+                               int indexSemiColon = line.indexOf(':');
+                               if (indexSemiColon <= 0)
+                                       continue lines;
+                               String directive = line.substring(0, indexSemiColon).trim();
+                               String value = line.substring(indexSemiColon + 1).trim();
+                               if ("name".equals(directive.toLowerCase()))
+                                       name = value;
+                               else if ("version".equals(directive.toLowerCase()))
+                                       version = value;
+                               else if ("release".equals(directive.toLowerCase()))
+                                       release = value;
+                               else if (directive.toLowerCase().startsWith("source"))
+                                       sources.put(directive, interpret(value));
+                               else if (directive.toLowerCase().startsWith("patch"))
+                                       patches.put(directive, interpret(value));
+                       }
+
+               } catch (IOException e) {
+                       throw new RuntimeException("Cannot parse spec file " + specFile, e);
+               }
+       }
+
+       protected String interpret(String value) {
+               StringBuffer buf = new StringBuffer(value.length());
+               StringBuffer currKey = null;
+               boolean mayBeKey = false;
+               chars: for (char c : value.toCharArray()) {
+                       if (c == '%')
+                               mayBeKey = true;
+                       else if (c == '{') {
+                               if (mayBeKey)
+                                       currKey = new StringBuffer();
+                       } else if (c == '}') {
+                               if (currKey == null)
+                                       continue chars;
+                               String key = currKey.toString();
+                               if ("name".equals(key.toLowerCase()))
+                                       buf.append(name);
+                               else if ("version".equals(key.toLowerCase()))
+                                       buf.append(version);
+                               else
+                                       buf.append("%{").append(key).append('}');
+                               currKey = null;
+                       } else {
+                               if (currKey != null)
+                                       currKey.append(c);
+                               else
+                                       buf.append(c);
+                       }
+               }
+               return buf.toString();
+       }
+
+       public Resource getSpecFile() {
+               return specFile;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public String getVersion() {
+               return version;
+       }
+
+       public String getRelease() {
+               return release;
+       }
+
+       public Map<String, String> getSources() {
+               return sources;
+       }
+
+       public Map<String, String> getPatches() {
+               return patches;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxMachine.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxMachine.java
new file mode 100644 (file)
index 0000000..2b561b6
--- /dev/null
@@ -0,0 +1,54 @@
+package org.argeo.slc.lib.vbox;
+
+import org.argeo.slc.UnsupportedException;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.deploy.DeployedSystem;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.TargetData;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.InitializingBean;
+
+public class VBoxMachine implements DeployedSystem, BeanNameAware,
+               InitializingBean {
+       private String deployedSystemId = null;
+       private String name;
+       private String beanName;
+
+       public String getDeployedSystemId() {
+               return deployedSystemId;
+       }
+
+       public DeploymentData getDeploymentData() {
+               throw new UnsupportedException();
+       }
+
+       public Distribution getDistribution() {
+               throw new UnsupportedException();
+       }
+
+       public TargetData getTargetData() {
+               throw new UnsupportedException();
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public void setDeployedSystemId(String deployedSystemId) {
+               this.deployedSystemId = deployedSystemId;
+       }
+
+       public void setBeanName(String beanName) {
+               this.beanName = name;
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               if (name == null)
+                       name = beanName;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxManager.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxManager.java
new file mode 100644 (file)
index 0000000..9992d77
--- /dev/null
@@ -0,0 +1,148 @@
+package org.argeo.slc.lib.vbox;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.tasks.SystemCall;
+import org.springframework.core.io.Resource;
+
+public class VBoxManager {
+       private final static Log log = LogFactory.getLog(VBoxManager.class);
+
+       private VBoxMachine vm;
+       private String executable = "VBoxManage";
+
+       private List<VBoxNat> nats = new ArrayList<VBoxNat>();
+
+       public void importOvf(Resource ovfDefinition) {
+               try {
+                       List<Object> cmd = new ArrayList<Object>();
+                       cmd.add(executable);
+                       cmd.add("import");
+                       cmd.add(ovfDefinition.getFile().getCanonicalPath());
+                       cmd.add("--vsys 0 --vmname <name>");
+                       cmd.add("0");
+                       cmd.add("--vmname");
+                       cmd.add(vm.getName());
+                       new SystemCall(cmd).run();
+               } catch (IOException e) {
+                       throw new SlcException("Cannot import OVF appliance "
+                                       + ovfDefinition, e);
+               }
+       }
+
+       public void startVm() {
+               startVm("gui");
+       }
+
+       public void startVmHeadless() {
+               startVm("vrdp");
+       }
+
+       public void startVm(String type) {
+               List<Object> cmd = new ArrayList<Object>();
+               cmd.add(executable);
+               cmd.add("startvm");
+               cmd.add(vm.getName());
+               cmd.add("--type");
+               cmd.add(type);
+               new SystemCall(cmd).run();
+       }
+
+       public void applyNats() {
+               StringBuffer script = new StringBuffer("");
+               for (VBoxNat vBoxNat : nats) {
+                       for (String id : vBoxNat.getMappings().keySet()) {
+                               VBoxPortMapping mapping = vBoxNat.getMappings().get(id);
+
+                               // Try to delete rule first
+                               try {
+                                       StringBuffer delCmd = new StringBuffer(
+                                                       "VBoxManage modifyvm");
+                                       delCmd.append(" \"").append(vm.getName()).append("\"");
+                                       delCmd.append(" --natpf").append(vBoxNat.getDevice())
+                                                       .append(" ");
+                                       delCmd.append(" delete ");
+                                       delCmd.append("\"").append(id).append("\"");
+                                       new SystemCall(delCmd.toString()).run();
+                                       script.append(delCmd).append("\n");
+                               } catch (Exception e) {
+                                       // silent
+                               }
+
+                               StringBuffer cmd = new StringBuffer("VBoxManage modifyvm");
+                               cmd.append(" \"").append(vm.getName()).append("\"");
+                               cmd.append(" --natpf").append(vBoxNat.getDevice()).append(" ");
+                               cmd.append("\"");
+                               cmd.append(id).append(",");
+                               cmd.append(mapping.getProtocol()).append(",");
+                               cmd.append(",");
+                               cmd.append(mapping.getHostPort()).append(",");
+                               cmd.append(vBoxNat.getGuestIp()).append(",");
+                               cmd.append(mapping.getGuestPort());
+                               cmd.append("\"");
+
+                               new SystemCall(cmd.toString()).run();
+                               script.append(cmd).append("\n");
+
+                               // Older VirtualBox
+                               // new SystemCall(createNatCommand(id, vBoxNat.getDevice(),
+                               // "Protocol", mapping.getProtocol(), script)).run();
+                               // script.append('\n');
+                               // new SystemCall(createNatCommand(id, vBoxNat.getDevice(),
+                               // "GuestPort", mapping.getGuest(), script)).run();
+                               // script.append('\n');
+                               // new SystemCall(createNatCommand(id, vBoxNat.getDevice(),
+                               // "HostPort", mapping.getHost(), script)).run();
+                               // script.append('\n');
+                               // script.append('\n');
+                       }
+                       script.append('\n');
+               }
+
+               if (log.isDebugEnabled())
+                       log.debug("Port setting script:\n" + script);
+       }
+
+       protected List<Object> createNatCommand(String id, String device,
+                       String cfgKey, String value, StringBuffer script) {
+               List<Object> cmd = new ArrayList<Object>();
+               cmd.add(executable);
+               cmd.add("setextradata");
+               cmd.add(vm.getName());
+               cmd.add("VBoxInternal/Devices/" + device + "/0/LUN#0/Config/" + id
+                               + "/" + cfgKey);
+               cmd.add(value);
+
+               for (Object arg : cmd) {
+                       script.append(arg).append(' ');
+               }
+
+               return cmd;
+       }
+
+       public String getExecutable() {
+               return executable;
+       }
+
+       public void setExecutable(String executable) {
+               this.executable = executable;
+       }
+
+       public List<VBoxNat> getNats() {
+               return nats;
+       }
+
+       public void setNats(List<VBoxNat> boxNats) {
+               nats = boxNats;
+       }
+
+       public void setVm(VBoxMachine vm) {
+               this.vm = vm;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxNat.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxNat.java
new file mode 100644 (file)
index 0000000..2661009
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.slc.lib.vbox;
+
+import java.util.Map;
+
+/** The NAT mapping table */
+public class VBoxNat {
+       private String device = "1";
+       private String guestIp = "";
+       private Map<String, VBoxPortMapping> mappings;
+
+       public String getDevice() {
+               return device;
+       }
+
+       public void setDevice(String device) {
+               this.device = device;
+       }
+
+       public Map<String, VBoxPortMapping> getMappings() {
+               return mappings;
+       }
+
+       public void setMappings(Map<String, VBoxPortMapping> mappings) {
+               this.mappings = mappings;
+       }
+
+       public String getGuestIp() {
+               return guestIp;
+       }
+
+       public void setGuestIp(String guestIp) {
+               this.guestIp = guestIp;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxPortMapping.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/lib/vbox/VBoxPortMapping.java
new file mode 100644 (file)
index 0000000..64ec866
--- /dev/null
@@ -0,0 +1,33 @@
+package org.argeo.slc.lib.vbox;
+
+/** The mapping of one port. */
+public class VBoxPortMapping {
+       private String protocol = "TCP";
+       private String guestPort;
+       private String hostPort;
+
+       public String getProtocol() {
+               return protocol;
+       }
+
+       public void setProtocol(String type) {
+               this.protocol = type;
+       }
+
+       public String getGuestPort() {
+               return guestPort;
+       }
+
+       public void setGuestPort(String guestPort) {
+               this.guestPort = guestPort;
+       }
+
+       public String getHostPort() {
+               return hostPort;
+       }
+
+       public void setHostPort(String hostPort) {
+               this.hostPort = hostPort;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/log4j/SlcExecutionAppender.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/log4j/SlcExecutionAppender.java
new file mode 100644 (file)
index 0000000..2a9ea5f
--- /dev/null
@@ -0,0 +1,142 @@
+package org.argeo.slc.log4j;
+
+import java.util.Date;
+import java.util.concurrent.BlockingQueue;
+
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.argeo.slc.execution.ExecutionStep;
+import org.argeo.slc.runtime.ExecutionThread;
+import org.argeo.slc.runtime.ProcessThreadGroup;
+
+/** Not meant to be used directly in standard log4j config */
+public class SlcExecutionAppender extends AppenderSkeleton {
+
+       private Boolean disabled = false;
+
+       private String level = null;
+
+       private Level log4jLevel = null;
+
+       /** Marker to prevent stack overflow */
+       private ThreadLocal<Boolean> dispatching = new ThreadLocal<Boolean>() {
+
+               @Override
+               protected Boolean initialValue() {
+                       return false;
+               }
+       };
+
+       // private Layout layout = null;
+       // private String pattern = "%m - %c%n";
+       private Boolean onlyExecutionThread = false;
+
+       public void init() {
+               // if (layout != null)
+               // setLayout(layout);
+               // else
+               // setLayout(new PatternLayout(pattern));
+               Logger.getRootLogger().addAppender(this);
+       }
+
+       @Override
+       protected void append(LoggingEvent event) {
+               if (disabled)
+                       return;
+
+               if (dispatching.get())
+                       return;
+
+               if (level != null && !level.trim().equals("")) {
+                       if (log4jLevel == null || !log4jLevel.toString().equals(level))
+                               try {
+                                       log4jLevel = Level.toLevel(level);
+                               } catch (Exception e) {
+                                       System.err.println("Log4j level could not be set for level '" + level + "', resetting it to null.");
+                                       e.printStackTrace();
+                                       level = null;
+                               }
+
+                       if (log4jLevel != null && !event.getLevel().isGreaterOrEqual(log4jLevel)) {
+                               return;
+                       }
+               }
+
+               // Check whether we are within an executing process
+               Thread currentThread = Thread.currentThread();
+               if (currentThread.getThreadGroup() instanceof ProcessThreadGroup) {
+                       if (onlyExecutionThread && !(currentThread instanceof ExecutionThread))
+                               return;
+
+                       final String type;
+                       if (event.getLevel().equals(Level.ERROR) || event.getLevel().equals(Level.FATAL))
+                               type = ExecutionStep.ERROR;
+                       else if (event.getLevel().equals(Level.WARN))
+                               type = ExecutionStep.WARNING;
+                       else if (event.getLevel().equals(Level.INFO))
+                               type = ExecutionStep.INFO;
+                       else if (event.getLevel().equals(Level.DEBUG))
+                               type = ExecutionStep.DEBUG;
+                       else if (event.getLevel().equals(Level.TRACE))
+                               type = ExecutionStep.TRACE;
+                       else
+                               type = ExecutionStep.INFO;
+
+                       ExecutionStep step = new ExecutionStep(event.getLoggerName(), new Date(event.getTimeStamp()), type,
+                                       event.getMessage().toString());
+
+                       try {
+                               dispatching.set(true);
+                               BlockingQueue<ExecutionStep> steps = ((ProcessThreadGroup) currentThread.getThreadGroup()).getSteps();
+                               if (steps.remainingCapacity() == 0) {
+                                       stdOut("WARNING: execution steps queue is full, skipping step: " + step);
+                                       // FIXME understand why it block indefinitely: the queue
+                                       // should be emptied by the logging thread
+                               } else {
+                                       steps.add(step);
+                               }
+                       } finally {
+                               dispatching.set(false);
+                       }
+               }
+       }
+
+       public void destroy() throws Exception {
+               Logger.getRootLogger().removeAppender(this);
+       }
+
+       public void close() {
+       }
+
+       public boolean requiresLayout() {
+               return false;
+       }
+
+       // public void setLayout(Layout layout) {
+       // this.layout = layout;
+       // }
+
+       /** For development purpose, since using regular logging is not easy here */
+       static void stdOut(Object obj) {
+               System.out.println(obj);
+       }
+
+       // public void setPattern(String pattern) {
+       // this.pattern = pattern;
+       // }
+
+       public void setOnlyExecutionThread(Boolean onlyExecutionThread) {
+               this.onlyExecutionThread = onlyExecutionThread;
+       }
+
+       public void setDisabled(Boolean disabled) {
+               this.disabled = disabled;
+       }
+
+       public void setLevel(String level) {
+               this.level = level;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/mail/SendMail.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/mail/SendMail.java
new file mode 100644 (file)
index 0000000..db4ab45
--- /dev/null
@@ -0,0 +1,140 @@
+package org.argeo.slc.mail;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.execution.tasks.SystemCall;
+
+/** Sends a mail via JavaMail, local mail command or Google Mail. */
+public class SendMail implements Runnable {
+       // See:
+       // http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailUsage
+       // http://java.sun.com/products/javamail/FAQ.html#gmail
+
+       private final static Log log = LogFactory.getLog(SendMail.class);
+
+       private String host;
+       private String from;
+       private String to;
+       private String subject;
+       private String text;
+       private String username;
+       private String password;
+       private Map<String, String> javaMailProperties = new HashMap<String, String>();
+
+       public void run() {
+               if ("local".equals(host))
+                       sendWithMailCommand();
+               else if ("smtp.gmail.com".equals(host))
+                       sendWithGMail();
+               else
+                       sendWithJavaMail();
+       }
+
+       protected void sendWithMailCommand() {
+               SystemCall mail = new SystemCall("mail");
+               mail.arg("-s", subject).arg(to);
+               mail.run();
+               if (log.isDebugEnabled())
+                       log.debug("Sent mail to " + to + " with OS mail command");
+       }
+
+       protected void sendWithJavaMail() {
+               try {
+                       // Get system properties
+                       Properties props = System.getProperties();
+
+                       // Setup mail server
+                       props.put("mail.smtp.host", host);
+
+                       for (String key : javaMailProperties.keySet())
+                               props.put(key, javaMailProperties.get(key));
+
+                       // Get session
+                       Session session = Session.getDefaultInstance(props, null);
+
+                       // Define message
+                       MimeMessage message = new MimeMessage(session);
+                       buildJavaMailMessage(message);
+
+                       // Send message
+                       Transport.send(message);
+                       if (log.isDebugEnabled())
+                               log.debug("Sent mail to " + to + " with JavaMail");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot send message.", e);
+               }
+       }
+
+       protected void sendWithGMail() {
+               try {
+                       Properties props = new Properties();
+                       props.put("mail.smtps.auth", "true");
+                       props.put("mail.smtps.host", host);
+                       Session session = Session.getDefaultInstance(props, null);
+                       MimeMessage message = new MimeMessage(session);
+                       buildJavaMailMessage(message);
+                       Transport t = session.getTransport("smtps");
+                       try {
+                               t.connect(host, username, password);
+                               t.sendMessage(message, message.getAllRecipients());
+                       } finally {
+                               t.close();
+                       }
+                       if (log.isDebugEnabled())
+                               log.debug("Sent mail to " + to + " with Google Mail");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot send message.", e);
+               }
+       }
+
+       protected void buildJavaMailMessage(Message message) throws Exception {
+               message.setFrom(new InternetAddress(from));
+               message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
+               message.setSubject(subject);
+               message.setText(text);
+       }
+
+       public void setHost(String host) {
+               this.host = host;
+       }
+
+       public void setFrom(String from) {
+               this.from = from;
+       }
+
+       public void setTo(String to) {
+               this.to = to;
+       }
+
+       public void setSubject(String subject) {
+               this.subject = subject;
+       }
+
+       public void setText(String text) {
+               this.text = text;
+       }
+
+       public void setJavaMailProperties(Map<String, String> javaMailProperties) {
+               this.javaMailProperties = javaMailProperties;
+       }
+
+       public void setUsername(String username) {
+               this.username = username;
+       }
+
+       public void setPassword(String password) {
+               this.password = password;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationDeployment.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationDeployment.java
new file mode 100644 (file)
index 0000000..804f280
--- /dev/null
@@ -0,0 +1,68 @@
+package org.argeo.slc.support.deploy;
+
+import java.io.File;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.deploy.DeployEnvironment;
+import org.argeo.slc.deploy.DeployedSystem;
+import org.argeo.slc.deploy.Deployment;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.TargetData;
+
+public class HttpdApplicationDeployment implements Deployment {
+       private static final Log log = LogFactory
+                       .getLog(HttpdApplicationDeployment.class);
+
+       private HttpdApplicationTargetData targetData;
+       private DeploymentData deploymentData;
+       private SimpleHttpdApplication deployedSystem;
+       private Distribution distribution;
+
+       private DeployEnvironment deployEnvironment;
+
+       public void run() {
+               try {
+                       deployEnvironment.unpackTo(distribution, targetData
+                                       .getTargetRootLocation(), null);
+
+                       // FIXME: make it generic
+                       String deployDataPath = targetData.getTargetRootLocation()
+                                       .getCanonicalPath();
+
+                       deployEnvironment.unpackTo(deploymentData,
+                                       new File(deployDataPath), null);
+                       deployedSystem = new SimpleHttpdApplication();
+                       deployedSystem.setTargetData(targetData);
+
+                       log.info("Deployed " + distribution + " to " + targetData);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot deploy " + distribution + " to "
+                                       + targetData, e);
+               }
+
+       }
+
+       public void setTargetData(TargetData targetData) {
+               this.targetData = (HttpdApplicationTargetData) targetData;
+       }
+
+       public void setDeploymentData(DeploymentData deploymentData) {
+               this.deploymentData = deploymentData;
+       }
+
+       public DeployedSystem getDeployedSystem() {
+               return deployedSystem;
+       }
+
+       public void setDistribution(Distribution distribution) {
+               this.distribution = distribution;
+       }
+
+       public void setDeployEnvironment(DeployEnvironment deployEnvironment) {
+               this.deployEnvironment = deployEnvironment;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationTargetData.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdApplicationTargetData.java
new file mode 100644 (file)
index 0000000..7b052ec
--- /dev/null
@@ -0,0 +1,65 @@
+package org.argeo.slc.support.deploy;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.deploy.TargetData;
+
+public class HttpdApplicationTargetData implements TargetData {
+       private HttpdServer webServer;
+       private String relativePath;
+       private String targetRootPath;
+
+       public HttpdServer getWebServer() {
+               return webServer;
+       }
+
+       public void setWebServer(HttpdServer webServer) {
+               this.webServer = webServer;
+       }
+
+       public String getRelativePath() {
+               return relativePath;
+       }
+
+       /**
+        * If targetRootLocation not set, used to build the targetRootLocation,
+        * relative to the webserver base.
+        */
+       public void setRelativePath(String relativePath) {
+               this.relativePath = relativePath;
+       }
+
+       public String getTargetRootPath() {
+               return targetRootPath;
+       }
+
+       public void setTargetRootPath(String targetRootPath) {
+               this.targetRootPath = targetRootPath;
+       }
+
+       public URL getTargetBaseUrl() {
+               try {
+                       URL wsUrl = getWebServer().getBaseUrl();
+                       // TODO: use URI
+                       return new URL(wsUrl, wsUrl.getFile() + '/' + relativePath);
+               } catch (MalformedURLException e) {
+                       throw new SlcException("Cannot get base url for " + relativePath, e);
+               }
+       }
+
+       public File getTargetRootLocation() {
+               if (targetRootPath != null && !targetRootPath.equals("")) {
+                       return new File(targetRootPath);
+               } else {
+                       HttpdServerTargetData targetData = (HttpdServerTargetData) getWebServer()
+                                       .getTargetData();
+                       String path = targetData.getServerRoot() + File.separator
+                                       + getRelativePath();
+                       return new File(path);
+               }
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServer.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServer.java
new file mode 100644 (file)
index 0000000..5fa4e9b
--- /dev/null
@@ -0,0 +1,50 @@
+package org.argeo.slc.support.deploy;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.TargetData;
+
+public class HttpdServer implements WebServer {
+       private HttpdServerTargetData targetData;
+       private HttpdServerDeploymentData deploymentData;
+
+       public URL getBaseUrl() {
+               try {
+                       return new URL("http://localhost:" + targetData.getPort());
+               } catch (IOException e) {
+                       throw new SlcException("Cannot get url for Httpd server "
+                                       + getDeployedSystemId(), e);
+               }
+       }
+
+       public String getDeployedSystemId() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public Distribution getDistribution() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public DeploymentData getDeploymentData() {
+               return deploymentData;
+       }
+
+       public TargetData getTargetData() {
+               return targetData;
+       }
+
+       public void setTargetData(TargetData targetData) {
+               this.targetData = (HttpdServerTargetData)targetData;
+       }
+
+       public void setDeploymentData(DeploymentData deploymentData) {
+               this.deploymentData = (HttpdServerDeploymentData)deploymentData;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeployment.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeployment.java
new file mode 100644 (file)
index 0000000..785510f
--- /dev/null
@@ -0,0 +1,34 @@
+package org.argeo.slc.support.deploy;
+
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.deploy.DeployedSystem;
+import org.argeo.slc.deploy.Deployment;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.TargetData;
+
+public class HttpdServerDeployment implements Deployment {
+//     private HttpdServerTargetData targetData;
+
+       public void run() {
+               // TODO Auto-generated method stub
+
+       }
+
+       public DeployedSystem getDeployedSystem() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public void setDeploymentData(DeploymentData deploymentData) {
+               // TODO Auto-generated method stub
+
+       }
+
+       public void setDistribution(Distribution distribution) {
+       }
+
+       public void setTargetData(TargetData targetData) {
+//             this.targetData = (HttpdServerTargetData) targetData;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeploymentData.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerDeploymentData.java
new file mode 100644 (file)
index 0000000..668ee39
--- /dev/null
@@ -0,0 +1,16 @@
+package org.argeo.slc.support.deploy;
+
+import org.argeo.slc.deploy.DeploymentData;
+
+public class HttpdServerDeploymentData implements DeploymentData {
+       private String configFile;
+
+       public String getConfigFile() {
+               return configFile;
+       }
+
+       public void setConfigFile(String configFile) {
+               this.configFile = configFile;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerManager.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerManager.java
new file mode 100644 (file)
index 0000000..20b7859
--- /dev/null
@@ -0,0 +1,81 @@
+package org.argeo.slc.support.deploy;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.deploy.DeployedSystemManager;
+
+public class HttpdServerManager implements DeployedSystemManager<HttpdServer> {
+       private final static Log log = LogFactory.getLog(HttpdServerManager.class);
+
+       private HttpdServer httpdServer;
+
+       public void start() {
+               runProcessAsync(createCommandLine("start"));
+               log.info("Started httpd server with root "
+                               + getHttpdServerTargetData().getServerRoot());
+       }
+
+       public void stop() {
+               runProcessAsync(createCommandLine("stop"));
+               log.info("Stopped httpd server with root "
+                               + getHttpdServerTargetData().getServerRoot());
+       }
+
+       protected String[] createCommandLine(String action) {
+               String httpdPath = getHttpdServerTargetData().getExecutables()
+                               .getExecutablePath("httpd");
+               String[] cmd = { httpdPath, "-d",
+                               getHttpdServerTargetData().getServerRoot(), "-f",
+                               getHttpdServerDeploymentData().getConfigFile(), "-k", action };
+               if (log.isDebugEnabled())
+                       log.debug("Command line: " + Arrays.asList(cmd));
+               return cmd;
+       }
+
+       protected static void runProcessAsync(String... command) {
+               ProcessBuilder procBuilder = new ProcessBuilder(command);
+               procBuilder.redirectErrorStream(true);
+               try {
+                       Process proc = procBuilder.start();
+                       final InputStream in = proc.getInputStream();
+                       Thread logThread = new Thread() {
+
+                               @Override
+                               public void run() {
+                                       BufferedReader reader = new BufferedReader(
+                                                       new InputStreamReader(in));
+                                       String line = null;
+                                       try {
+                                               while ((line = reader.readLine()) != null)
+                                                       log.info(line);
+                                       } catch (IOException e) {
+                                               log.error("Failed to read stdout", e);
+                                       }
+                               }
+                       };
+
+                       logThread.start();
+               } catch (IOException e) {
+                       throw new SlcException("Could not run command", e);
+               }
+       }
+
+       public void setDeployedSystem(HttpdServer httpdServer) {
+               this.httpdServer = httpdServer;
+       }
+
+       protected HttpdServerDeploymentData getHttpdServerDeploymentData() {
+               return (HttpdServerDeploymentData) httpdServer.getDeploymentData();
+       }
+
+       protected HttpdServerTargetData getHttpdServerTargetData() {
+               return (HttpdServerTargetData) httpdServer.getTargetData();
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerTargetData.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/HttpdServerTargetData.java
new file mode 100644 (file)
index 0000000..e4f28ca
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.slc.support.deploy;
+
+import org.argeo.slc.deploy.InstalledExecutables;
+import org.argeo.slc.deploy.TargetData;
+
+public class HttpdServerTargetData implements TargetData {
+       private String serverRoot;
+       private Integer port;
+       private InstalledExecutables executables;
+
+       public String getServerRoot() {
+               return serverRoot;
+       }
+
+       public void setServerRoot(String serverRoot) {
+               this.serverRoot = serverRoot;
+       }
+
+       public Integer getPort() {
+               return port;
+       }
+
+       public void setPort(Integer port) {
+               this.port = port;
+       }
+
+       public InstalledExecutables getExecutables() {
+               return executables;
+       }
+
+       public void setExecutables(InstalledExecutables executables) {
+               this.executables = executables;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/SimpleHttpdApplication.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/SimpleHttpdApplication.java
new file mode 100644 (file)
index 0000000..b5157f6
--- /dev/null
@@ -0,0 +1,47 @@
+package org.argeo.slc.support.deploy;
+
+import java.io.File;
+import java.net.URL;
+
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.deploy.DeploymentData;
+
+public class SimpleHttpdApplication implements WebApplication {
+       private HttpdApplicationTargetData targetData;
+       private Distribution distribution;
+
+       public void setDistribution(Distribution distribution) {
+               this.distribution = distribution;
+       }
+
+       public URL getBaseUrl() {
+               return targetData.getTargetBaseUrl();
+       }
+
+       public File getRootLocation() {
+               return targetData.getTargetRootLocation();
+       }
+
+       public String getDeployedSystemId() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public HttpdApplicationTargetData getTargetData() {
+               return targetData;
+       }
+
+       public void setTargetData(HttpdApplicationTargetData targetData) {
+               this.targetData = targetData;
+       }
+
+       public Distribution getDistribution() {
+               return distribution;
+       }
+
+       public DeploymentData getDeploymentData() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebApplication.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebApplication.java
new file mode 100644 (file)
index 0000000..1d82754
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.support.deploy;
+
+import java.io.File;
+import java.net.URL;
+
+import org.argeo.slc.deploy.DeployedSystem;
+
+public interface WebApplication extends DeployedSystem {
+       public URL getBaseUrl();
+
+       public File getRootLocation();
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebServer.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/WebServer.java
new file mode 100644 (file)
index 0000000..afce096
--- /dev/null
@@ -0,0 +1,9 @@
+package org.argeo.slc.support.deploy;
+
+import java.net.URL;
+
+import org.argeo.slc.deploy.DeployedSystem;
+
+public interface WebServer extends DeployedSystem {
+       public URL getBaseUrl();
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/DbModel.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/DbModel.java
new file mode 100644 (file)
index 0000000..6140d7b
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.support.deploy.db;
+
+import java.sql.Connection;
+
+public interface DbModel {
+       public void createSchema(Connection connection);
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/JdbcAware.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/JdbcAware.java
new file mode 100644 (file)
index 0000000..0d4de5e
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.support.deploy.db;
+
+import javax.sql.DataSource;
+
+public interface JdbcAware {
+       public DataSource getDataSource();
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/SimpleJdbcDatabase.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/support/deploy/db/SimpleJdbcDatabase.java
new file mode 100644 (file)
index 0000000..4f15209
--- /dev/null
@@ -0,0 +1,39 @@
+package org.argeo.slc.support.deploy.db;
+
+import javax.sql.DataSource;
+
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.deploy.DeployedSystem;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.TargetData;
+
+public class SimpleJdbcDatabase implements DeployedSystem, JdbcAware {
+       private DataSource dataSource;
+
+       public String getDeployedSystemId() {
+               return dataSource.toString();
+       }
+
+       public DataSource getDataSource() {
+               return dataSource;
+       }
+
+       public void setDataSource(DataSource dataSource) {
+               this.dataSource = dataSource;
+       }
+
+       @Override
+       public Distribution getDistribution() {
+               throw new UnsupportedOperationException();
+       }
+
+       @Override
+       public DeploymentData getDeploymentData() {
+               throw new UnsupportedOperationException();
+       }
+
+       @Override
+       public TargetData getTargetData() {
+               throw new UnsupportedOperationException();
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResource.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResource.java
new file mode 100644 (file)
index 0000000..7c0c7e9
--- /dev/null
@@ -0,0 +1,96 @@
+package org.argeo.slc.vfs;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.commons.io.IOExceptionWithCause;
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.FileSystemException;
+import org.apache.commons.vfs2.NameScope;
+import org.argeo.slc.SlcException;
+import org.springframework.core.io.Resource;
+
+public class VfsResource implements Resource {
+       private FileObject fileObject;
+
+       public VfsResource(FileObject fileObject) {
+               this.fileObject = fileObject;
+       }
+
+       public Resource createRelative(String relativePath) throws IOException {
+               return new VfsResource(fileObject.resolveFile(relativePath,
+                               NameScope.DESCENDENT_OR_SELF));
+       }
+
+       public boolean exists() {
+               try {
+                       return fileObject.exists();
+               } catch (FileSystemException e) {
+                       throw new SlcException("Cannot find out whether " + fileObject
+                                       + " exists", e);
+               }
+       }
+
+       public String getDescription() {
+               return "VFS resource " + fileObject;
+       }
+
+       public File getFile() throws IOException {
+               throw new IOException("Cannot access " + getDescription()
+                               + " as a local file");
+               // TODO: access local files
+               // if(fileObject instanceof LocalFile){
+               // ((LocalFile)fileObject).
+               // }
+               // return null;
+       }
+
+       public String getFilename() {
+               return fileObject.getName().getBaseName();
+       }
+
+       public URI getURI() throws IOException {
+               try {
+                       return new URI(fileObject.getName().getURI());
+               } catch (URISyntaxException e) {
+                       throw new IOExceptionWithCause(e);
+               }
+       }
+
+       public URL getURL() throws IOException {
+               return fileObject.getURL();
+       }
+
+       public boolean isOpen() {
+               return fileObject.isContentOpen();
+       }
+
+       public boolean isReadable() {
+               try {
+                       return fileObject.isReadable();
+               } catch (FileSystemException e) {
+                       throw new SlcException("Cannot find out whether " + fileObject
+                                       + " is readable", e);
+               }
+       }
+
+       public long lastModified() throws IOException {
+               return fileObject.getContent().getLastModifiedTime();
+       }
+
+       public InputStream getInputStream() throws IOException {
+               return fileObject.getContent().getInputStream();
+       }
+
+       public FileObject getFileObject() {
+               return fileObject;
+       }
+
+       public long contentLength(){
+               return -1;
+       }
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceFactory.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceFactory.java
new file mode 100644 (file)
index 0000000..ac92adf
--- /dev/null
@@ -0,0 +1,36 @@
+package org.argeo.slc.vfs;
+
+import org.apache.commons.vfs2.CacheStrategy;
+import org.apache.commons.vfs2.FileSystemManager;
+import org.apache.commons.vfs2.impl.StandardFileSystemManager;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
+
+public class VfsResourceFactory implements FactoryBean, InitializingBean {
+       private String url;
+       private FileSystemManager fileSystemManager;
+
+       public Object getObject() throws Exception {
+               return new VfsResource(fileSystemManager.resolveFile(url));
+       }
+
+       public Class<?> getObjectType() {
+               return Resource.class;
+       }
+
+       public boolean isSingleton() {
+               return false;
+       }
+
+       public void afterPropertiesSet() throws Exception {
+               if (fileSystemManager == null) {
+                       fileSystemManager = new StandardFileSystemManager();
+                       ((StandardFileSystemManager) fileSystemManager)
+                                       .setCacheStrategy(CacheStrategy.ON_RESOLVE);
+                       ((StandardFileSystemManager) fileSystemManager).init();
+               }
+
+       }
+
+}
diff --git a/legacy/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceSet.java b/legacy/org.argeo.slc.support/src/org/argeo/slc/vfs/VfsResourceSet.java
new file mode 100644 (file)
index 0000000..a56b431
--- /dev/null
@@ -0,0 +1,54 @@
+package org.argeo.slc.vfs;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.FileSystemException;
+import org.apache.commons.vfs2.FileSystemManager;
+import org.apache.commons.vfs2.VFS;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.core.deploy.ResourceSet;
+import org.springframework.core.io.Resource;
+
+public class VfsResourceSet implements ResourceSet {
+       private String base;
+
+       public Map<String, Resource> listResources() {
+               try {
+                       FileSystemManager fileSystemManager = VFS.getManager();
+                       FileObject fileObject = fileSystemManager.resolveFile(base);
+                       Map<String, Resource> map = new HashMap<String, Resource>();
+                       addToMap(map, "", fileObject);
+
+                       // TODO: add filters
+                       return map;
+               } catch (FileSystemException e) {
+                       throw new SlcException("Cannot list VFS resources from " + base, e);
+               }
+       }
+
+       /** recursive */
+       protected void addToMap(Map<String, Resource> map, String parentPath,
+                       FileObject fileObject) {
+               try {
+                       String newParentPath = parentPath
+                                       + fileObject.getName().getBaseName() + '/';
+                       if (fileObject.getType().hasChildren()) {
+                               for (FileObject child : fileObject.getChildren()) {
+                                       addToMap(map, newParentPath, child);
+                               }
+                       } else {
+                               map.put(parentPath + fileObject.getName().getBaseName(),
+                                               new VfsResource(fileObject));
+                       }
+               } catch (FileSystemException e) {
+                       throw new SlcException("Cannot add children from " + parentPath, e);
+               }
+       }
+
+       public void setBase(String base) {
+               this.base = base;
+       }
+
+}
index 0248ccb8e975be404c60a7452f81a7521b26974e..9ed41422e3889ffa694c91bacd53ef55235b781c 100644 (file)
@@ -1,25 +1,48 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
-               <groupId>org.argeo.maven</groupId>
-               <artifactId>argeo-osgi-parent</artifactId>
-               <version>2.1.4-SNAPSHOT</version>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>2.3-SNAPSHOT</version>
        </parent>
-       <groupId>org.argeo.slc</groupId>
        <artifactId>legacy</artifactId>
        <version>2.3-SNAPSHOT</version>
        <packaging>pom</packaging>
        <name>SLC Legacy Argeo Software</name>
        <properties>
-               <version.argeo-tp>2.1.27</version.argeo-tp>
-               <version.argeo-tp-extras>2.1.13</version.argeo-tp-extras>
-               <version.argeo-commons>2.3-SNAPSHOT</version.argeo-commons>
-
                <argeo.rpm.stagingRepository>/srv/rpmfactory/legacy/argeo-osgi-2/argeo</argeo.rpm.stagingRepository>
        </properties>
        <modules>
+               <!-- Legacy UI -->
                <module>org.argeo.legacy.fake.java8</module>
                <module>argeo-commons</module>
+
+               <!-- Legacy Runtime -->
+               <module>org.argeo.slc.spring</module>
+               <module>org.argeo.slc.support</module>
+               <module>org.argeo.slc.launcher</module>
+
+               <!-- Legacy Modules -->
+               <module>org.argeo.slc.agent</module>
+               <module>org.argeo.slc.agent.jcr</module>
+               <module>org.argeo.slc.server.repo</module>
+
+               <!-- Legacy UI -->
+               <module>org.argeo.slc.client.ui</module>
+               <module>org.argeo.slc.client.ui.dist</module>
+               <module>org.argeo.slc.client.rap</module>
+
+               <!-- To be imported by Spring-based modules -->
+               <module>lib</module>
+
+               <!-- Spring-based modules demo -->
+               <module>org.argeo.slc.demo.ant</module>
+               <module>org.argeo.slc.demo.basic</module>
+               <module>org.argeo.slc.demo.minimal</module>
+
+               <module>dep</module>
        </modules>
        <dependencies>
                <dependency>
diff --git a/lib/.gitignore b/lib/.gitignore
deleted file mode 100644 (file)
index b83d222..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/lib/cnf/maven.bnd b/lib/cnf/maven.bnd
deleted file mode 100644 (file)
index 4bd5c0c..0000000
+++ /dev/null
@@ -1 +0,0 @@
--include: ../../cnf/maven.bnd
\ No newline at end of file
diff --git a/lib/pom.xml b/lib/pom.xml
deleted file mode 100644 (file)
index 9e04232..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.slc</groupId>
-               <artifactId>argeo-slc</artifactId>
-               <version>2.3-SNAPSHOT</version>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>lib</artifactId>
-       <packaging>pom</packaging>
-       <name>SLC Standard Libs</name>
-       <description>SLC execution modules for generic tasks, to be used as parent pom</description>
-       <properties>
-               <additionalImports.slc-lib>
-                       com.jcraft.jsch;resolution:=optional,
-                       org.apache.commons.exec;resolution:=optional,
-               </additionalImports.slc-lib>
-       </properties>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.felix</groupId>
-                               <artifactId>maven-bundle-plugin</artifactId>
-                               <configuration>
-                                       <instructions>
-                                               <SLC-ExecutionModule>default</SLC-ExecutionModule>
-                                               <!-- Minimal imports + some optional convenience imports -->
-                                               <Import-Package>
-                                                       org.argeo.security.jackrabbit;resolution:="optional",
-                                                       org.springframework.cglib.proxy;resolution:="optional",
-                                                       org.springframework.cglib.core;resolution:="optional",
-                                                       org.springframework.cglib.reflect;resolution:="optional",
-                                                       org.aopalliance.aop;resolution:="optional",
-                                                       org.argeo.slc.runtime,
-                                                       org.argeo.slc.core.execution;resolution:="optional",
-                                                       org.argeo.slc.core.execution.tasks;resolution:="optional",
-                                                       org.argeo.slc.execution,
-                                                       org.argeo.slc.osgi;resolution:="optional",
-                                                       org.argeo.slc.test,
-                                                       org.springframework.aop;resolution:="optional",
-                                                       org.springframework.aop.framework;resolution:="optional",
-                                                       org.springframework.aop.scope;resolution:="optional",
-                                                       org.springframework.beans.factory.config;resolution:="optional",
-                                                       org.springframework.core.io;resolution:="optional",
-                                                       ${additionalImports.slc-lib},
-                                                       *
-                                               </Import-Package>
-                                       </instructions>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
-       <dependencies>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.dep.minimal</artifactId>
-                       <version>2.3-SNAPSHOT</version>
-                       <type>pom</type>
-               </dependency>
-       </dependencies>
-</project>
diff --git a/org.argeo.slc.api/.classpath b/org.argeo.slc.api/.classpath
new file mode 100644 (file)
index 0000000..bc86c42
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" output="target/classes" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.argeo.slc.api/.gitignore b/org.argeo.slc.api/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/org.argeo.slc.api/.project b/org.argeo.slc.api/.project
new file mode 100644 (file)
index 0000000..301fef6
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.api</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.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.argeo.slc.api/META-INF/.gitignore b/org.argeo.slc.api/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/org.argeo.slc.api/bnd.bnd b/org.argeo.slc.api/bnd.bnd
new file mode 100644 (file)
index 0000000..c3bac59
--- /dev/null
@@ -0,0 +1,4 @@
+Require-Capability: cms.datamodel;filter:="(name=ldap)",\
+ cms.datamodel;filter:="(name=argeo)"
+
+Provide-Capability: cms.datamodel;name=slc;cnd=/org/argeo/slc/slc.cnd
diff --git a/org.argeo.slc.api/build.properties b/org.argeo.slc.api/build.properties
new file mode 100644 (file)
index 0000000..07891d9
--- /dev/null
@@ -0,0 +1,2 @@
+bin.includes = META-INF/,.\r
+source..=src/\r
diff --git a/org.argeo.slc.api/pom.xml b/org.argeo.slc.api/pom.xml
new file mode 100644 (file)
index 0000000..f943ccc
--- /dev/null
@@ -0,0 +1,13 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.api</artifactId>
+       <name>SLC API</name>
+</project>
\ No newline at end of file
diff --git a/org.argeo.slc.api/src/org/argeo/slc/BasicNameVersion.java b/org.argeo.slc.api/src/org/argeo/slc/BasicNameVersion.java
new file mode 100644 (file)
index 0000000..61ed5eb
--- /dev/null
@@ -0,0 +1,33 @@
+package org.argeo.slc;
+
+import java.io.Serializable;
+
+/** @deprecated use {@link DefaultNameVersion} instead. */
+@Deprecated
+public class BasicNameVersion extends DefaultNameVersion implements
+               Serializable {
+       private static final long serialVersionUID = -5127304279136195127L;
+
+       public BasicNameVersion() {
+       }
+
+       /** Interprets string in OSGi-like format my.module.name;version=0.0.0 */
+       public BasicNameVersion(String nameVersion) {
+               int index = nameVersion.indexOf(";version=");
+               if (index < 0) {
+                       setName(nameVersion);
+                       setVersion(null);
+               } else {
+                       setName(nameVersion.substring(0, index));
+                       setVersion(nameVersion.substring(index + ";version=".length()));
+               }
+       }
+
+       public BasicNameVersion(String name, String version) {
+               super(name, version);
+       }
+
+       public BasicNameVersion(NameVersion nameVersion) {
+               super(nameVersion);
+       }
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java b/org.argeo.slc.api/src/org/argeo/slc/CategoryNameVersion.java
new file mode 100644 (file)
index 0000000..b335996
--- /dev/null
@@ -0,0 +1,25 @@
+package org.argeo.slc;
+
+/**
+ * Adds a dimension to {@link NameVersion} by adding an arbitrary category (e.g.
+ * Maven groupId, yum repository ID, etc.)
+ */
+public interface CategoryNameVersion extends NameVersion {
+       /** The category of the component. */
+       String getCategory();
+
+       static CategoryNameVersion parseCategoryNameVersion(String str) {
+               if (str == null || "".equals(str.trim()))
+                       throw new IllegalArgumentException("At least one character required.");
+               String[] arr = str.trim().split(":");
+               if (arr.length > 3)
+                       throw new IllegalArgumentException(str + " does not respect the [category]:[name]:[version] pattern");
+               DefaultCategoryNameVersion res = new DefaultCategoryNameVersion();
+               res.setCategory(arr[0]);
+               if (arr.length > 1)
+                       res.setName(arr[1]);
+               if (arr.length > 2)
+                       res.setVersion(arr[2]);
+               return res;
+       }
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/Condition.java b/org.argeo.slc.api/src/org/argeo/slc/Condition.java
new file mode 100644 (file)
index 0000000..f476961
--- /dev/null
@@ -0,0 +1,11 @@
+package org.argeo.slc;
+
+/** Binary check on an arbitrary object. */
+public interface Condition<T> {
+       /**
+        * Checks the condition.
+        * 
+        * @return true, if the condition is verified, false if not.
+        */
+       public Boolean check(T obj);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/DefaultCategoryNameVersion.java b/org.argeo.slc.api/src/org/argeo/slc/DefaultCategoryNameVersion.java
new file mode 100644 (file)
index 0000000..6506599
--- /dev/null
@@ -0,0 +1,34 @@
+package org.argeo.slc;
+
+/** Canonical implementation of {@link CategoryNameVersion} */
+public class DefaultCategoryNameVersion extends DefaultNameVersion implements CategoryNameVersion {
+       private String category;
+
+       public DefaultCategoryNameVersion() {
+       }
+
+       public DefaultCategoryNameVersion(String category, String name, String version) {
+               super(name, version);
+               this.category = category;
+       }
+
+       public DefaultCategoryNameVersion(String category, NameVersion nameVersion) {
+               super(nameVersion);
+               this.category = category;
+       }
+
+       @Override
+       public String getCategory() {
+               return category;
+       }
+
+       public void setCategory(String category) {
+               this.category = category;
+       }
+
+       @Override
+       public String toString() {
+               return category + ":" + super.toString();
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/DefaultNameVersion.java b/org.argeo.slc.api/src/org/argeo/slc/DefaultNameVersion.java
new file mode 100644 (file)
index 0000000..61cc66e
--- /dev/null
@@ -0,0 +1,77 @@
+package org.argeo.slc;
+
+
+/** Canonical implementation of {@link NameVersion} */
+public class DefaultNameVersion implements NameVersion,
+               Comparable<NameVersion> {
+       private String name;
+       private String version;
+
+       public DefaultNameVersion() {
+       }
+
+       /** Interprets string in OSGi-like format my.module.name;version=0.0.0 */
+       public DefaultNameVersion(String nameVersion) {
+               int index = nameVersion.indexOf(";version=");
+               if (index < 0) {
+                       setName(nameVersion);
+                       setVersion(null);
+               } else {
+                       setName(nameVersion.substring(0, index));
+                       setVersion(nameVersion.substring(index + ";version=".length()));
+               }
+       }
+
+       public DefaultNameVersion(String name, String version) {
+               this.name = name;
+               this.version = version;
+       }
+
+       public DefaultNameVersion(NameVersion nameVersion) {
+               this.name = nameVersion.getName();
+               this.version = nameVersion.getVersion();
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getVersion() {
+               return version;
+       }
+
+       public void setVersion(String version) {
+               this.version = version;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (obj instanceof NameVersion) {
+                       NameVersion nameVersion = (NameVersion) obj;
+                       return name.equals(nameVersion.getName())
+                                       && version.equals(nameVersion.getVersion());
+               } else
+                       return false;
+       }
+
+       @Override
+       public int hashCode() {
+               return name.hashCode();
+       }
+
+       @Override
+       public String toString() {
+               return name + ":" + version;
+       }
+
+       public int compareTo(NameVersion o) {
+               if (o.getName().equals(name))
+                       return version.compareTo(o.getVersion());
+               else
+                       return name.compareTo(o.getName());
+       }
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/ModuleSet.java b/org.argeo.slc.api/src/org/argeo/slc/ModuleSet.java
new file mode 100644 (file)
index 0000000..fd125a2
--- /dev/null
@@ -0,0 +1,8 @@
+package org.argeo.slc;
+
+import java.util.Iterator;
+
+/** A set of {@link NameVersion}. */
+public interface ModuleSet {
+       Iterator<? extends NameVersion> nameVersions();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/NameVersion.java b/org.argeo.slc.api/src/org/argeo/slc/NameVersion.java
new file mode 100644 (file)
index 0000000..1906049
--- /dev/null
@@ -0,0 +1,13 @@
+package org.argeo.slc;
+
+/**
+ * Abstraction of a name / version pair, typically used as coordinates for a
+ * software module either deployed or packaged as an archive.
+ */
+public interface NameVersion {
+       /** The name of the component. */
+       public String getName();
+
+       /** The version of the component. */
+       public String getVersion();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java b/org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java
new file mode 100644 (file)
index 0000000..7da9708
--- /dev/null
@@ -0,0 +1,10 @@
+package org.argeo.slc;
+
+/** Constants useful across all SLC components */
+public interface SlcConstants {
+       /** Read-write role. */
+       public final static String ROLE_SLC = "cn=org.argeo.slc.user,ou=roles,ou=node";
+
+       /** Read only unlogged user */
+       public final static String USER_ANONYMOUS = "anonymous";
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/SlcException.java b/org.argeo.slc.api/src/org/argeo/slc/SlcException.java
new file mode 100644 (file)
index 0000000..d2e5e2b
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.slc;
+
+/** Basis for all SLC exceptions. This is an unchecked exception. */
+public class SlcException extends RuntimeException {
+       private static final long serialVersionUID = 6373738619304106445L;
+
+       /** Constructor. */
+       public SlcException(String message) {
+               super(message);
+       }
+
+       /** Constructor. */
+       public SlcException(String message, Throwable e) {
+               super(message, e);
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/SlcNames.java b/org.argeo.slc.api/src/org/argeo/slc/SlcNames.java
new file mode 100644 (file)
index 0000000..557d479
--- /dev/null
@@ -0,0 +1,113 @@
+package org.argeo.slc;
+
+/** JCR names used by SLC */
+public interface SlcNames {
+       public final static String SLC_ = "slc:";
+
+       /*
+        * GENERAL
+        */
+       public final static String SLC_UUID = "slc:uuid";
+       public final static String SLC_STATUS = "slc:status";
+       // generic name for result parts of a given test result (slc:testResult)
+       // note that corresponding nodes can be retrieved using
+       // myTestResultNode.getNodes(SLC_RESULT_PART+"*") method
+       public final static String SLC_RESULT_PART = "slc:resultPart";
+       // Fixed name of the child node of a slc:testResult of type
+       // slc:check that aggregate status of all result parts of a given test
+       // result
+       public final static String SLC_AGGREGATED_STATUS = "slc:aggregatedStatus";
+
+       public final static String SLC_TYPE = "slc:type";
+       public final static String SLC_NAME = "slc:name";
+       public final static String SLC_VERSION = "slc:version";
+       public final static String SLC_CATEGORY = "slc:category";
+       public final static String SLC_VALUE = "slc:value";
+       public final static String SLC_ADDRESS = "slc:address";
+       public final static String SLC_METADATA = "slc:metadata";
+
+       public final static String SLC_TIMESTAMP = "slc:timestamp";
+       public final static String SLC_STARTED = "slc:started";
+       public final static String SLC_COMPLETED = "slc:completed";
+
+       public final static String SLC_VM = "slc:vm";
+       /*
+        * SLC RUNTIME
+        */
+       // execution
+       public final static String SLC_SPEC = "slc:spec";
+       public final static String SLC_EXECUTION_SPECS = "slc:executionSpecs";
+       public final static String SLC_FLOW = "slc:flow";
+       public final static String SLC_LOG = "slc:log";
+       public final static String SLC_AGENTS = "slc:agents";
+
+       // spec attribute
+       public final static String SLC_IS_IMMUTABLE = "slc:isImmutable";
+       public final static String SLC_IS_CONSTANT = "slc:isConstant";
+       public final static String SLC_IS_HIDDEN = "slc:isHidden";
+
+       // base directories
+       public final static String SLC_SYSTEM = "slc:system";
+       public final static String SLC_RESULTS = "slc:results";
+       public final static String SLC_MY_RESULTS = "slc:myResults";
+       public final static String SLC_PROCESSES = "slc:processes";
+
+       // result
+       public final static String SLC_SUCCESS = "slc:success";
+       public final static String SLC_MESSAGE = "slc:message";
+       public final static String SLC_TAG = "slc:tag";
+       public final static String SLC_ERROR_MESSAGE = "slc:errorMessage";
+       public final static String SLC_TEST_CASE = "slc:testCase";
+       public final static String SLC_TEST_CASE_TYPE = "slc:testCaseType";
+
+       // diff result
+       public final static String SLC_SUMMARY = "slc:summary";
+       public final static String SLC_ISSUES = "slc:issues";
+
+       /*
+        * SLC REPO
+        */
+       // shared
+       public final static String SLC_URL = "slc:url";
+       public final static String SLC_OPTIONAL = "slc:optional";
+       public final static String SLC_AS_STRING = "slc:asString";
+
+       // origin
+       public final static String SLC_ORIGIN = "slc:origin";
+       public final static String SLC_PROXY = "slc:proxy";
+
+       // slc:artifact
+       public final static String SLC_ARTIFACT_ID = "slc:artifactId";
+       public final static String SLC_GROUP_ID = "slc:groupId";
+       public final static String SLC_GROUP_BASE_ID = "slc:groupBaseId";
+       public final static String SLC_ARTIFACT_VERSION = "slc:artifactVersion";
+       public final static String SLC_ARTIFACT_EXTENSION = "slc:artifactExtension";
+       public final static String SLC_ARTIFACT_CLASSIFIER = "slc:artifactClassifier";
+
+       // slc:jarArtifact
+       public final static String SLC_MANIFEST = "slc:manifest";
+
+       // shared OSGi
+       public final static String SLC_SYMBOLIC_NAME = "slc:symbolic-name";
+       public final static String SLC_BUNDLE_VERSION = "slc:bundle-version";
+
+       // slc:osgiBaseVersion
+       public final static String SLC_MAJOR = "slc:major";
+       public final static String SLC_MINOR = "slc:minor";
+       public final static String SLC_MICRO = "slc:micro";
+       // slc:osgiVersion
+       public final static String SLC_QUALIFIER = "slc:qualifier";
+
+       // slc:exportedPackage
+       public final static String SLC_USES = "slc:uses";
+
+       // slc:modularDistribution
+       public final static String SLC_MODULES = "slc:modules";
+
+       // RPM
+       // slc:rpm
+       public final static String SLC_RPM_VERSION = "slc:rpmVersion";
+       public final static String SLC_RPM_RELEASE = "slc:rpmRelease";
+       public final static String SLC_RPM_ARCH = "slc:rpmArch";
+       public final static String SLC_RPM_ARCHIVE_SIZE = "slc:rpmArchiveSize";
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/SlcTypes.java b/org.argeo.slc.api/src/org/argeo/slc/SlcTypes.java
new file mode 100644 (file)
index 0000000..e0b86e6
--- /dev/null
@@ -0,0 +1,68 @@
+package org.argeo.slc;
+
+/** JCR node types used by SLC */
+public interface SlcTypes {
+
+       public final static String SLC_NAME_VERSION = "slc:nameVersion";
+       public final static String SLC_CATEGORIZED_NAME_VERSION = "slc:categorizedNameVersion";
+
+       public final static String SLC_AGENT_FACTORY = "slc:agentFactory";
+       public final static String SLC_AGENT = "slc:agent";
+       public final static String SLC_MODULE = "slc:module";
+       public final static String SLC_EXECUTION_MODULE = "slc:executionModule";
+       public final static String SLC_EXECUTION_SPEC = "slc:executionSpec";
+       public final static String SLC_EXECUTION_FLOW = "slc:executionFlow";
+       public final static String SLC_PROCESS = "slc:process";
+       public final static String SLC_REALIZED_FLOW = "slc:realizedFlow";
+
+       public final static String SLC_EXECUTION_SPEC_ATTRIBUTE = "slc:executionSpecAttribute";
+       public final static String SLC_PRIMITIVE_SPEC_ATTRIBUTE = "slc:primitiveSpecAttribute";
+       public final static String SLC_REF_SPEC_ATTRIBUTE = "slc:refSpecAttribute";
+
+       public final static String SLC_TEST_RESULT = "slc:testResult";
+       public final static String SLC_CHECK = "slc:check";
+       public final static String SLC_PROPERTY = "slc:property";
+       public final static String SLC_DIFF_RESULT = "slc:diffResult";
+
+       // Node types used for user defined and managed result UI tree
+       public final static String SLC_MY_RESULT_ROOT_FOLDER = "slc:myResultRootFolder";
+       public final static String SLC_RESULT_FOLDER = "slc:resultFolder";
+
+       // Log levels
+       public final static String SLC_LOG_ENTRY = "slc:logEntry";
+       public final static String SLC_LOG_TRACE = "slc:logTrace";
+       public final static String SLC_LOG_DEBUG = "slc:logDebug";
+       public final static String SLC_LOG_INFO = "slc:logInfo";
+       public final static String SLC_LOG_WARNING = "slc:logWarning";
+       public final static String SLC_LOG_ERROR = "slc:logError";
+
+       /*
+        * REPO
+        */
+       public final static String SLC_ARTIFACT = "slc:artifact";
+       public final static String SLC_ARTIFACT_VERSION_BASE = "slc:artifactVersion";
+       public final static String SLC_ARTIFACT_BASE = "slc:artifactBase";
+       public final static String SLC_GROUP_BASE = "slc:groupBase";
+       public final static String SLC_JAR_FILE = "slc:jarFile";
+       public final static String SLC_BUNDLE_ARTIFACT = "slc:bundleArtifact";
+       public final static String SLC_OSGI_VERSION = "slc:osgiVersion";
+       public final static String SLC_JAVA_PACKAGE = "slc:javaPackage";
+       public final static String SLC_EXPORTED_PACKAGE = "slc:exportedPackage";
+       public final static String SLC_IMPORTED_PACKAGE = "slc:importedPackage";
+       public final static String SLC_DYNAMIC_IMPORTED_PACKAGE = "slc:dynamicImportedPackage";
+       public final static String SLC_REQUIRED_BUNDLE = "slc:requiredBundle";
+       public final static String SLC_FRAGMENT_HOST = "slc:fragmentHost";
+
+       // Distribution management
+       // public final static String SLC_CATEGORY = "slc:category";
+       public final static String SLC_MODULAR_DISTRIBUTION_BASE = "slc:modularDistributionBase";
+       public final static String SLC_MODULAR_DISTRIBUTION = "slc:modularDistribution";
+       public final static String SLC_MODULE_COORDINATES = "slc:moduleCoordinates";
+
+       // origin
+       public final static String SLC_KNOWN_ORIGIN = "slc:knownOrigin";
+       public final static String SLC_PROXIED = "slc:proxied";
+
+       // rpm
+       public final static String SLC_RPM = "slc:rpm";
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/StreamReadable.java b/org.argeo.slc.api/src/org/argeo/slc/StreamReadable.java
new file mode 100644 (file)
index 0000000..f1bef22
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc;
+
+import java.io.InputStream;
+
+public interface StreamReadable {
+       public InputStream getInputStream();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/UnsupportedException.java b/org.argeo.slc.api/src/org/argeo/slc/UnsupportedException.java
new file mode 100644 (file)
index 0000000..aa050e3
--- /dev/null
@@ -0,0 +1,54 @@
+package org.argeo.slc;
+
+/** Exception for unsupported features or actions. */
+public class UnsupportedException extends SlcException {
+       static final long serialVersionUID = 1l;
+
+       /** Action not supported. */
+       public UnsupportedException() {
+               this("Action not supported");
+       }
+
+       /** Constructor with a message. */
+       public UnsupportedException(String message) {
+               super(message);
+       }
+
+       /**
+        * Constructor generating a message.
+        * 
+        * @param nature
+        *            the nature of the unsupported object
+        * @param obj
+        *            the object itself (its class name will be used in message)
+        */
+       public UnsupportedException(String nature, Object obj) {
+               super("Unsupported " + nature + ": "
+                               + (obj != null ? obj.getClass() : "[object is null]"));
+       }
+
+       /**
+        * Constructor generating a message.
+        * 
+        * @param nature
+        *            the nature of the unsupported object
+        * @param clss
+        *            the class itself (will be used in message)
+        */
+       public UnsupportedException(String nature, Class<?> clss) {
+               super("Unsupported " + nature + ": " + clss);
+       }
+
+       /**
+        * Constructor generating a message.
+        * 
+        * @param nature
+        *            the nature of the unsupported object
+        * @param value
+        *            the problematic value itself
+        */
+       public UnsupportedException(String nature, String value) {
+               super("Unsupported " + nature + ": " + value);
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/attachment/Attachment.java b/org.argeo.slc.api/src/org/argeo/slc/attachment/Attachment.java
new file mode 100644 (file)
index 0000000..6573251
--- /dev/null
@@ -0,0 +1,11 @@
+package org.argeo.slc.attachment;
+
+public interface Attachment {
+       public String getUuid();
+
+       public void setUuid(String uuid);
+
+       public String getName();
+
+       public String getContentType();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsEnabled.java b/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsEnabled.java
new file mode 100644 (file)
index 0000000..0b44e5b
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.attachment;
+
+public interface AttachmentsEnabled {
+       public void addAttachment(Attachment attachment);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsStorage.java b/org.argeo.slc.api/src/org/argeo/slc/attachment/AttachmentsStorage.java
new file mode 100644 (file)
index 0000000..48cd0e6
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.attachment;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public interface AttachmentsStorage {
+       public void retrieveAttachment(Attachment attachment,
+                       OutputStream outputStream);
+
+       /** Does NOT close the provided input stream. */
+       public void storeAttachment(Attachment attachment, InputStream inputStream);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/build/Distribution.java b/org.argeo.slc.api/src/org/argeo/slc/build/Distribution.java
new file mode 100644 (file)
index 0000000..b438a8f
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.build;\r
+\r
+/** A packaged software component */\r
+public interface Distribution {\r
+       public String getDistributionId();\r
+\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/build/License.java b/org.argeo.slc.api/src/org/argeo/slc/build/License.java
new file mode 100644 (file)
index 0000000..d115f45
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.build;
+
+/** A software license */
+public interface License {
+       public String getName();
+
+       public String getUri();
+
+       public String getLink();
+
+       public String getText();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/build/ModularDistribution.java b/org.argeo.slc.api/src/org/argeo/slc/build/ModularDistribution.java
new file mode 100644 (file)
index 0000000..3c7f625
--- /dev/null
@@ -0,0 +1,19 @@
+package org.argeo.slc.build;
+
+import org.argeo.slc.ModuleSet;
+import org.argeo.slc.NameVersion;
+
+/**
+ * A distribution of modules, that is components that can be identified by a
+ * name / version couple.
+ * 
+ * @see NameVersion
+ */
+public interface ModularDistribution extends Distribution, NameVersion,
+               ModuleSet {
+       public Distribution getModuleDistribution(String moduleName,
+                       String moduleVersion);
+
+       /** A descriptor such as P2, OBR or yum metadata. */
+       public Object getModulesDescriptor(String descriptorType);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/build/package.html b/org.argeo.slc.api/src/org/argeo/slc/build/package.html
new file mode 100644 (file)
index 0000000..5da2052
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+SLC Build: building of software systems.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployEnvironment.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployEnvironment.java
new file mode 100644 (file)
index 0000000..dd47369
--- /dev/null
@@ -0,0 +1,9 @@
+package org.argeo.slc.deploy;
+
+import java.io.File;
+import java.util.Map;
+
+public interface DeployEnvironment {
+       public void unpackTo(Object packg, File targetLocation,
+                       Map<String, String> filter);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystem.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystem.java
new file mode 100644 (file)
index 0000000..be28154
--- /dev/null
@@ -0,0 +1,18 @@
+package org.argeo.slc.deploy;\r
+\r
+import org.argeo.slc.build.Distribution;\r
+\r
+/** An instance of a software system. */\r
+public interface DeployedSystem extends TargetData {\r
+       /** Unique ID for this system instance. */\r
+       public String getDeployedSystemId();\r
+\r
+       /** Underlying packages */\r
+       public Distribution getDistribution();\r
+\r
+       /** Data required to initialize the instance (e.g. DB dump, etc.). */\r
+       public DeploymentData getDeploymentData();\r
+\r
+       /** Resources required by the system (ports, disk location, etc.) */\r
+       public TargetData getTargetData();\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystemManager.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/DeployedSystemManager.java
new file mode 100644 (file)
index 0000000..411bcb6
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.deploy;
+
+public interface DeployedSystemManager<T extends DeployedSystem> {
+       public void setDeployedSystem(T deployedSystem);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/Deployment.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/Deployment.java
new file mode 100644 (file)
index 0000000..74be42a
--- /dev/null
@@ -0,0 +1,13 @@
+package org.argeo.slc.deploy;\r
+\r
+import org.argeo.slc.build.Distribution;\r
+\r
+public interface Deployment extends Runnable{\r
+       public DeployedSystem getDeployedSystem();\r
+\r
+       public void setTargetData(TargetData targetData);\r
+\r
+       public void setDeploymentData(DeploymentData deploymentData);\r
+\r
+       public void setDistribution(Distribution distribution);\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/DeploymentData.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/DeploymentData.java
new file mode 100644 (file)
index 0000000..18e63f8
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.deploy;\r
+\r
+public interface DeploymentData {\r
+\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/DynamicRuntime.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/DynamicRuntime.java
new file mode 100644 (file)
index 0000000..ed29ce2
--- /dev/null
@@ -0,0 +1,18 @@
+package org.argeo.slc.deploy;
+
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.build.Distribution;
+
+public interface DynamicRuntime<M extends Module> extends
+               ModularDeployedSystem<M> {
+       public void shutdown();
+
+       public M installModule(Distribution distribution);
+
+       public void uninstallModule(NameVersion nameVersion);
+
+       public void updateModule(NameVersion nameVersion);
+
+       public void startModule(NameVersion nameVersion);
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/InstalledExecutables.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/InstalledExecutables.java
new file mode 100644 (file)
index 0000000..2d65a71
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.deploy;
+
+public interface InstalledExecutables extends DeployedSystem {
+       public String getExecutablePath(String key);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/ModularDeployedSystem.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/ModularDeployedSystem.java
new file mode 100644 (file)
index 0000000..18fd4fe
--- /dev/null
@@ -0,0 +1,8 @@
+package org.argeo.slc.deploy;
+
+import java.util.List;
+
+public interface ModularDeployedSystem<M extends Module> extends DeployedSystem {
+       /** List the underlying deployed modules (in real time) */
+       public List<M> listModules();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/Module.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/Module.java
new file mode 100644 (file)
index 0000000..10973c9
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.deploy;
+
+import org.argeo.slc.NameVersion;
+
+/**
+ * Represents a deployed module of a broader deployed system. A module is
+ * uniquely identifiable via a name / version.
+ */
+public interface Module extends DeployedSystem, NameVersion {
+       /** A serializable stateless description of the module */
+       public ModuleDescriptor getModuleDescriptor();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/ModuleDescriptor.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/ModuleDescriptor.java
new file mode 100644 (file)
index 0000000..f1d6642
--- /dev/null
@@ -0,0 +1,59 @@
+package org.argeo.slc.deploy;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.argeo.slc.DefaultNameVersion;
+
+/** The description of a versioned module. */
+public class ModuleDescriptor extends DefaultNameVersion implements Serializable {
+       private static final long serialVersionUID = 4310820315478645419L;
+       private String title;
+       private String description;
+       private Map<String, String> metadata = new HashMap<String, String>();
+       private Boolean started = false;
+
+       public String getTitle() {
+               return title;
+       }
+
+       public void setTitle(String title) {
+               this.title = title;
+       }
+
+       public String getDescription() {
+               return description;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       /** @deprecated use {@link #getTitle()} instead */
+       public String getLabel() {
+               return title;
+       }
+
+       /** @deprecated use {@link #setTitle(String)} instead */
+       public void setLabel(String label) {
+               this.title = label;
+       }
+
+       public Map<String, String> getMetadata() {
+               return metadata;
+       }
+
+       public void setMetadata(Map<String, String> metadata) {
+               this.metadata = metadata;
+       }
+
+       public Boolean getStarted() {
+               return started;
+       }
+
+       public void setStarted(Boolean started) {
+               this.started = started;
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/ModulesManager.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/ModulesManager.java
new file mode 100644 (file)
index 0000000..1288592
--- /dev/null
@@ -0,0 +1,26 @@
+package org.argeo.slc.deploy;
+
+import java.util.List;
+
+import org.argeo.slc.NameVersion;
+
+/** Provides access to deployed modules */
+public interface ModulesManager {
+       /** @return a full fledged module descriptor. */
+       public ModuleDescriptor getModuleDescriptor(String moduleName,
+                       String version);
+
+       /**
+        * @return a list of minimal module descriptors of the deployed modules
+        */
+       public List<ModuleDescriptor> listModules();
+
+       /** Synchronously upgrades the module referenced by this name version */
+       public void upgrade(NameVersion nameVersion);
+
+       /** Starts the module */
+       public void start(NameVersion nameVersion);
+
+       /** Stops the module */
+       public void stop(NameVersion nameVersion);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/TargetData.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/TargetData.java
new file mode 100644 (file)
index 0000000..f1c7e7d
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.deploy;\r
+\r
+public interface TargetData {\r
+\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/VersioningDriver.java b/org.argeo.slc.api/src/org/argeo/slc/deploy/VersioningDriver.java
new file mode 100644 (file)
index 0000000..dba5797
--- /dev/null
@@ -0,0 +1,33 @@
+package org.argeo.slc.deploy;\r
+\r
+import java.io.File;\r
+import java.io.OutputStream;\r
+import java.util.List;\r
+\r
+/** Abstracts common versioning operations */\r
+public interface VersioningDriver {\r
+       public void getFileFromRepository(String repositoryBaseUrl,\r
+                       String location, OutputStream out);\r
+\r
+       public List<String> getChangedPaths(File repositoryRoot, Long revision);\r
+\r
+       public String getRepositoryRoot(String repositoryUrl);\r
+\r
+       public String getRelativePath(String repositoryUrl);\r
+\r
+       public void updateToHead(File fileOrDir);\r
+\r
+       public void importFileOrDir(String repositoryUrl, File fileOrDir);\r
+\r
+       /**\r
+        * Checks out or update this versioned directory\r
+        * \r
+        * @return true if the content has changed, false otherwise\r
+        */\r
+       public Boolean checkout(String repositoryUrl, File destDir,\r
+                       Boolean recursive);\r
+\r
+       public void createRepository(String filePath);\r
+\r
+       public void commit(File fileOrDir, String commitMessage);\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/deploy/package.html b/org.argeo.slc.api/src/org/argeo/slc/deploy/package.html
new file mode 100644 (file)
index 0000000..f3a4c5b
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+SLC Deploy: deployment of software systems.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractExecutionValue.java b/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractExecutionValue.java
new file mode 100644 (file)
index 0000000..7f63626
--- /dev/null
@@ -0,0 +1,8 @@
+package org.argeo.slc.execution;
+
+import java.io.Serializable;
+
+/** Value to be used by an execution */
+public abstract class AbstractExecutionValue implements Serializable {
+       private static final long serialVersionUID = 1558444746120706961L;
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractSpecAttribute.java b/org.argeo.slc.api/src/org/argeo/slc/execution/AbstractSpecAttribute.java
new file mode 100644 (file)
index 0000000..d720db6
--- /dev/null
@@ -0,0 +1,73 @@
+package org.argeo.slc.execution;
+
+import java.io.Serializable;
+
+/** Canonical implementation of the execution spec attribute booleans. */
+public abstract class AbstractSpecAttribute implements ExecutionSpecAttribute,
+               Serializable {
+       private static final long serialVersionUID = 6494963738891709440L;
+       private Boolean isImmutable = false;
+       private Boolean isConstant = false;
+       private Boolean isHidden = false;
+
+       private String description;
+
+       /** Has to be set at instantiation */
+       public Boolean getIsImmutable() {
+               return isImmutable;
+       }
+
+       public void setIsImmutable(Boolean isImmutable) {
+               this.isImmutable = isImmutable;
+       }
+
+       /** Cannot be overridden at runtime */
+       public Boolean getIsConstant() {
+               return isConstant;
+       }
+
+       public void setIsConstant(Boolean isConstant) {
+               this.isConstant = isConstant;
+       }
+
+       /** Should not be shown to the end user */
+       public Boolean getIsHidden() {
+               return isHidden;
+       }
+
+       public void setIsHidden(Boolean isHidden) {
+               this.isHidden = isHidden;
+       }
+
+       /*
+        * DEPRECATED
+        */
+       /** @deprecated use {@link #getIsImmutable()} instead */
+       public Boolean getIsParameter() {
+               return isImmutable;
+       }
+
+       /** @deprecated use {@link #getIsConstant()} instead */
+       public Boolean getIsFrozen() {
+               return isConstant;
+       }
+
+       /** @deprecated use {@link #setIsImmutable(Boolean)} instead */
+       public void setIsParameter(Boolean isParameter) {
+               this.isImmutable = isParameter;
+       }
+
+       /** @deprecated use {@link #setIsConstant(Boolean)} instead */
+       public void setIsFrozen(Boolean isFrozen) {
+               this.isConstant = isFrozen;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       public String getDescription() {
+               return description;
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionContext.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionContext.java
new file mode 100644 (file)
index 0000000..46c448f
--- /dev/null
@@ -0,0 +1,20 @@
+package org.argeo.slc.execution;\r
+\r
+/** Variables or references attached to an execution (typically thread bounded).*/\r
+public interface ExecutionContext {\r
+       public final static String VAR_EXECUTION_CONTEXT_ID = "slcVar.executionContext.id";\r
+       public final static String VAR_EXECUTION_CONTEXT_CREATION_DATE = "slcVar.executionContext.creationDate";\r
+       public final static String VAR_FLOW_ID = "slcVar.flow.id";\r
+       public final static String VAR_FLOW_NAME = "slcVar.flow.name";\r
+\r
+       public String getUuid();\r
+\r
+       /** @return the variable value, or <code>null</code> if not found. */\r
+       public Object getVariable(String key);\r
+\r
+       public void setVariable(String key, Object value);\r
+       \r
+       public void beforeFlow(ExecutionFlow executionFlow);\r
+       \r
+       public void afterFlow(ExecutionFlow executionFlow);\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlow.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlow.java
new file mode 100644 (file)
index 0000000..7dd3a74
--- /dev/null
@@ -0,0 +1,33 @@
+package org.argeo.slc.execution;
+
+import java.util.Iterator;
+
+/** Abstraction of an execution that can be identified and configured. */
+public interface ExecutionFlow extends Runnable {
+       /** Retrieve an immutable parameter */
+       public Object getParameter(String key);
+
+       /** Whether this immutable parameter is set */
+       public Boolean isSetAsParameter(String key);
+
+       /** The specifications of the execution flow. */
+       public ExecutionSpec getExecutionSpec();
+
+       /**
+        * List sub-runnables that would be executed if run() method would be
+        * called.
+        */
+       public Iterator<Runnable> runnables();
+
+       /**
+        * If there is one and only one runnable wrapped return it, throw an
+        * exception otherwise.
+        */
+       public Runnable getRunnable();
+
+       /**
+        * The name of this execution flow. Can contains '/' which will be
+        * interpreted by UIs as a hierarchy;
+        */
+       public String getName();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptor.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptor.java
new file mode 100644 (file)
index 0000000..d38bb85
--- /dev/null
@@ -0,0 +1,119 @@
+package org.argeo.slc.execution;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 
+ * Implements both archetype and implementation of a given process.
+ * 
+ * At specification time, <code>executionSpec</code> represents the spec of the
+ * parameters accepted by the process, with, among others: type, default value
+ * and, optionally, possible values for each parameter. Thus ExecutionSpec might
+ * be a huge object. Note that when marshalling only a reference to a specific
+ * ExecutionSpec is stored in the XML to optimize performance and avoid
+ * redundancy between various ExecutionFlowDesciptor that might have the same
+ * ExecutionSpec.
+ * 
+ * At runtime, we build a RealizedFlow which references an
+ * ExecutionFlowDescriptor. As it happens AFTER marshalling / unmarshalling
+ * process, the ExecutionSpec is null but we manage to retrieve the
+ * ExecutionSpec and store it in the RealizedFlow, whereas set values of the
+ * parameters are stored in the <code>values</code> map.
+ * 
+ * Generally, values object are either a <code>PrimitiveAccessor</code> or a
+ * <code>RefValue</code> but can be other objects.
+ */
+public class ExecutionFlowDescriptor implements Serializable, Cloneable {
+       private static final long serialVersionUID = 7101944857038041216L;
+       private String name;
+       private String description;
+       private String path;
+       private Map<String, Object> values;
+       private ExecutionSpec executionSpec;
+
+       public ExecutionFlowDescriptor() {
+       }
+
+       public ExecutionFlowDescriptor(String name, String description,
+                       Map<String, Object> values, ExecutionSpec executionSpec) {
+               this.name = name;
+               this.values = values;
+               this.executionSpec = executionSpec;
+       }
+
+       /** The referenced {@link ExecutionSpec} is NOT cloned. */
+       @Override
+       protected Object clone() throws CloneNotSupportedException {
+               return new ExecutionFlowDescriptor(name, description,
+                               new HashMap<String, Object>(values), executionSpec);
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * @deprecated will be removed in SLC 2.x, the path should be the part of
+        *             the name with '/'
+        */
+       public String getPath() {
+               return path;
+       }
+
+       /**
+        * @deprecated will be removed in SLC 2.0, the path should be the part of
+        *             the name with '/'
+        */
+       public void setPath(String path) {
+               this.path = path;
+       }
+
+       public Map<String, Object> getValues() {
+               return values;
+       }
+
+       public ExecutionSpec getExecutionSpec() {
+               return executionSpec;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public void setValues(Map<String, Object> values) {
+               this.values = values;
+       }
+
+       public void setExecutionSpec(ExecutionSpec executionSpec) {
+               this.executionSpec = executionSpec;
+       }
+
+       public String getDescription() {
+               return description;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (obj instanceof ExecutionFlowDescriptor)
+                       return name.equals(((ExecutionFlowDescriptor) obj).getName());
+               return false;
+       }
+
+       @Override
+       public int hashCode() {
+               return name.hashCode();
+       }
+
+       @Override
+       public String toString() {
+               return (path != null && !path.trim().equals("") ? path + "/" : "")
+                               + name;
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptorConverter.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionFlowDescriptorConverter.java
new file mode 100644 (file)
index 0000000..13ff638
--- /dev/null
@@ -0,0 +1,18 @@
+package org.argeo.slc.execution;
+
+import java.util.Map;
+
+/**
+ * Maps back and forth between {@link ExecutionFlowDescriptor} and
+ * {@link ExecutionFlow}
+ */
+public interface ExecutionFlowDescriptorConverter {
+       public Map<String, Object> convertValues(
+                       ExecutionFlowDescriptor executionFlowDescriptor);
+
+       public void addFlowsToDescriptor(ExecutionModuleDescriptor md,
+                       Map<String, ExecutionFlow> executionFlows);
+
+       public ExecutionFlowDescriptor getExecutionFlowDescriptor(
+                       ExecutionFlow executionFlow);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModule.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModule.java
new file mode 100644 (file)
index 0000000..11021f6
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.execution;
+
+@Deprecated
+public interface ExecutionModule {
+/*     public String getName();
+
+       public String getVersion();
+       
+       public ExecutionModuleDescriptor getDescriptor();
+
+       public void execute(ExecutionFlowDescriptor descriptor);*/
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModuleDescriptor.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModuleDescriptor.java
new file mode 100644 (file)
index 0000000..cad6efb
--- /dev/null
@@ -0,0 +1,64 @@
+package org.argeo.slc.execution;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.deploy.ModuleDescriptor;
+
+/** Describes the information required to launch a flow */
+public class ExecutionModuleDescriptor extends ModuleDescriptor {
+       /** Metadata header identifying an SLC execution module */
+       public final static String SLC_EXECUTION_MODULE = "SLC-ExecutionModule";
+
+       private static final long serialVersionUID = -2394473464513029512L;
+       private List<ExecutionSpec> executionSpecs = new ArrayList<ExecutionSpec>();
+       private List<ExecutionFlowDescriptor> executionFlows = new ArrayList<ExecutionFlowDescriptor>();
+
+       public List<ExecutionSpec> getExecutionSpecs() {
+               return executionSpecs;
+       }
+
+       public List<ExecutionFlowDescriptor> getExecutionFlows() {
+               return executionFlows;
+       }
+
+       /**
+        * Returns a new {@link ExecutionModuleDescriptor} that can be used to build
+        * a {@link RealizedFlow}.
+        */
+       public ExecutionFlowDescriptor cloneFlowDescriptor(String name) {
+               ExecutionFlowDescriptor res = null;
+               for (ExecutionFlowDescriptor efd : executionFlows) {
+                       if (efd.getName().equals(name)
+                                       || ("/" + efd.getName()).equals(name)) {
+                               try {
+                                       res = (ExecutionFlowDescriptor) efd.clone();
+                               } catch (CloneNotSupportedException e) {
+                                       throw new SlcException("Cannot clone " + efd, e);
+                               }
+                       }
+               }
+               if (res == null)
+                       throw new SlcException("Flow " + name + " not found.");
+               return res;
+       }
+
+       public RealizedFlow asRealizedFlow(String flow, Map<String, Object> values) {
+               RealizedFlow realizedFlow = new RealizedFlow();
+               realizedFlow.setFlowDescriptor(cloneFlowDescriptor(flow));
+               realizedFlow.setModuleName(getName());
+               realizedFlow.setModuleVersion(getVersion());
+               realizedFlow.getFlowDescriptor().getValues().putAll(values);
+               return realizedFlow;
+       }
+
+       public void setExecutionSpecs(List<ExecutionSpec> executionSpecs) {
+               this.executionSpecs = executionSpecs;
+       }
+
+       public void setExecutionFlows(List<ExecutionFlowDescriptor> executionFlows) {
+               this.executionFlows = executionFlows;
+       }
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesListener.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesListener.java
new file mode 100644 (file)
index 0000000..aa0b16d
--- /dev/null
@@ -0,0 +1,16 @@
+package org.argeo.slc.execution;
+
+import org.argeo.slc.deploy.ModuleDescriptor;
+
+/** Listen to events on execution modules. */
+public interface ExecutionModulesListener {
+       public void executionModuleAdded(ModuleDescriptor moduleDescriptor);
+
+       public void executionModuleRemoved(ModuleDescriptor moduleDescriptor);
+
+       public void executionFlowAdded(ModuleDescriptor moduleDescriptor,
+                       ExecutionFlowDescriptor executionFlowDescriptor);
+
+       public void executionFlowRemoved(ModuleDescriptor moduleDescriptor,
+                       ExecutionFlowDescriptor executionFlowDescriptor);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesManager.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionModulesManager.java
new file mode 100644 (file)
index 0000000..1cedd12
--- /dev/null
@@ -0,0 +1,49 @@
+package org.argeo.slc.execution;
+
+import java.util.List;
+
+import org.argeo.slc.deploy.ModulesManager;
+
+/** Provides access to the execution modules */
+public interface ExecutionModulesManager extends ModulesManager {
+       /** Used to filter event notified to an execution notifier. */
+       public static String SLC_PROCESS_ID = "slc.process.id";
+
+       /** Unique launch module */
+       public static String UNIQUE_LAUNCH_MODULE_PROPERTY = "slc.launch.module";
+
+       /** Unique launch flow */
+       public static String UNIQUE_LAUNCH_FLOW_PROPERTY = "slc.launch.flow";
+
+       /** @return a full fledged module descriptor. */
+       public ExecutionModuleDescriptor getExecutionModuleDescriptor(
+                       String moduleName, String version);
+
+       /**
+        * @return a list of minimal execution module descriptors (only the module
+        *         meta data, not the flows)
+        */
+       public List<ExecutionModuleDescriptor> listExecutionModules();
+
+       /** Synchronously finds and executes an {@link ExecutionFlow}. */
+       public void execute(RealizedFlow realizedFlow);
+
+       // /** Notify of a status update status of the {@link ExecutionProcess} */
+//      public void dispatchUpdateStatus(ExecutionProcess process,
+//      String oldStatus, String newStatus);
+       //
+       // /** Notify that a step was added in an {@link ExecutionProcess} */
+       // public void dispatchAddSteps(ExecutionProcess process,
+       // List<ExecutionStep> steps);
+       //
+       // /**
+       // * Register a notifier which will be notified based on the provided
+       // * properties.
+       // */
+       // public void registerProcessNotifier(ExecutionProcessNotifier notifier,
+       // Map<String, String> properties);
+       //
+       // /** Unregisters a notifier */
+       // public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
+       // Map<String, String> properties);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionProcess.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionProcess.java
new file mode 100644 (file)
index 0000000..d894e1c
--- /dev/null
@@ -0,0 +1,52 @@
+package org.argeo.slc.execution;
+
+import java.util.List;
+
+/**
+ * A process is the functional representation of a combination of executions.
+ * While an execution is the actual java code running, a process exists before,
+ * during and after the execution actually took place, providing an entry point
+ * for the definition of executions, their monitoring (e.g. logging) and
+ * tracking. A process can be distributed or parallelized. <br/>
+ * NEW => INITIALIZED => SCHEDULED => RUNNING<br/>
+ * RUNNING => {COMPLETED | ERROR | KILLED}<br/>
+ * {COMPLETED | ERROR | KILLED} => PURGED<br/>
+ * UNKOWN : this is a bug if this status occurs<br/>
+ */
+public interface ExecutionProcess {
+       /** The process is not yet usable. */
+       public final static String NEW = "NEW";
+       /** The process is usable but not yet scheduled to run. */
+       public final static String INITIALIZED = "INITIALIZED";
+       /** The process is usable and scheduled to run, but not yet running. */
+       public final static String SCHEDULED = "SCHEDULED";
+       /** The process is currently running. */
+       public final static String RUNNING = "RUNNING";
+       /** The process has properly completed. */
+       public final static String COMPLETED = "COMPLETED";
+       /** The process failed because of an unexpected error. */
+       public final static String ERROR = "ERROR";
+       /** The process was killed explicitly or through a crash. */
+       public final static String KILLED = "KILLED";
+       /** The status cannot be retrieved (probably because of unexpected errors). */
+       public final static String UNKOWN = "UNKOWN";
+
+       /**
+        * Only a reference to the process has been kept, all monitoring data such
+        * as logs have been purged.
+        */
+       public final static String PURGED = "PURGED";
+
+       /** The UUID of this process. */
+       public String getUuid();
+
+       /** The current status of this process. */
+       public String getStatus();
+
+       /** Sets the current status of this process */
+       public void setStatus(String status);
+
+       public void addSteps(List<ExecutionStep> steps);
+
+       public List<RealizedFlow> getRealizedFlows();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionResources.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionResources.java
new file mode 100644 (file)
index 0000000..9ddbca9
--- /dev/null
@@ -0,0 +1,31 @@
+package org.argeo.slc.execution;
+
+import java.io.File;
+import java.nio.file.Path;
+
+/** Provides write access to resources during execution */
+public interface ExecutionResources {
+       /** The base directory where this execution can write */
+       public File getWritableBaseDir();
+
+       /** Allocates a local file in the writable area and return it as a resource. */
+       public Path getWritableResource(String relativePath);
+
+       /**
+        * Allocates a local file in the writable area and return it as a fully
+        * qualified OS path.
+        */
+       public String getWritableOsPath(String relativePath);
+
+       /**
+        * Allocates a local file in the writable area and return it as a {@link File}.
+        */
+       public File getWritableOsFile(String relativePath);
+
+       /**
+        * Returns the resource as a file path. If the resource is not writable it is
+        * copied as a file in the writable area and the path to this local file is
+        * returned.
+        */
+       public String getAsOsPath(Path resource, Boolean overwrite);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpec.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpec.java
new file mode 100644 (file)
index 0000000..0037b6d
--- /dev/null
@@ -0,0 +1,29 @@
+package org.argeo.slc.execution;
+
+import java.util.Map;
+
+/**
+ * The class implementing this interface defines the map of attributes that are
+ * necessary for the corresponding ExecutionFlow.
+ */
+public interface ExecutionSpec {
+       /**
+        * The name for an internal spec (for backward compatibility where a
+        * non-null name is expected)
+        */
+       public final static String INTERNAL_NAME = "__SLC_EXECUTION_SPEC_INTERNAL";
+
+       /**
+        * The name identifying the execution spec within its application context.
+        * Can be null. An execution spec can be referenced only if its name is not
+        * null or different from {@link #INTERNAL_NAME}
+        */
+       public String getName();
+
+       /** An optional description. Can be null. */
+       public String getDescription();
+
+       /** The attributes managed by this execution spec */
+       public Map<String, ExecutionSpecAttribute> getAttributes();
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpecAttribute.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionSpecAttribute.java
new file mode 100644 (file)
index 0000000..39f87d9
--- /dev/null
@@ -0,0 +1,53 @@
+package org.argeo.slc.execution;
+
+/**
+ * Possible attribute of an execution flow.
+ * 
+ * There are mainly two implementations :<br>
+ * + Primitive attributes (no predefined choice, the end user must compute a
+ * String, a Float, an Integer...)<br>
+ * + RefSpecAttribute which enable two things<br>
+ * ++ a reference to another object of the application context<br>
+ * ++ the display of some choices among which the end user can choose.<br>
+ * 
+ * @see org.argeo.slc.core.execution.PrimitiveSpecAttribute
+ * @see org.argeo.slc.core.execution.RefSpecAttribute
+ * @see org.argeo.slc.core.execution.PrimitiveUtils : this class offers some
+ *      helper, among others to cast the various type of primitive attribute.
+ */
+public interface ExecutionSpecAttribute {
+       /**
+        * Whether this attribute has to be set at instantiation of the flow and
+        * cannot be modified afterwards. If the attribute is not immutable (that
+        * is, this method returns false), it can be set at execution time.
+        */
+       public Boolean getIsImmutable();
+
+       /**
+        * Whether this attribute must be explicitly set and cannot be modified.
+        * This attribute is then basically a constant within a given application
+        * context. {@link #getValue()} cannot return null if the attribute is a
+        * constant.
+        */
+       public Boolean getIsConstant();
+
+       /** Whether this attribute will be hidden to end users. */
+       public Boolean getIsHidden();
+
+       /**
+        * The default value for this attribute. Can be null, except if
+        * {@link #getIsFrozen()} is <code>true</code>, in which case it represents
+        * the constant value of this attribute.
+        */
+       public Object getValue();
+
+       /** Description of this attribute, can be null */
+       public String getDescription();
+
+       /** @deprecated use {@link #getIsImmutable()} instead */
+       public Boolean getIsParameter();
+
+       /** @deprecated use {@link #getIsConstant()} instead */
+       public Boolean getIsFrozen();
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStack.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStack.java
new file mode 100644 (file)
index 0000000..0a15e33
--- /dev/null
@@ -0,0 +1,23 @@
+package org.argeo.slc.execution;
+
+/** Deal with nested level of executions using different variables. */
+public interface ExecutionStack {
+       /**
+        * @param name
+        * @return null if no object is found
+        */
+       public Object findScopedObject(String name);
+
+       public void addScopedObject(String name, Object obj);
+
+       public void enterFlow(ExecutionFlow executionFlow);
+
+       /** @return internal stack level UUID. */
+       public String getCurrentStackLevelUuid();
+
+       public Integer getStackSize();
+
+       public void leaveFlow(ExecutionFlow executionFlow);
+
+       Object findLocalVariable(String key);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStackLevel.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStackLevel.java
new file mode 100644 (file)
index 0000000..790404b
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.execution;
+
+import java.util.Map;
+
+public interface ExecutionStackLevel {
+       public ExecutionFlow getExecutionFlow();
+
+       public Map<String, Object> getScopedObjects();
+
+       public String getUuid();
+
+       public Map<String, Object> getLocalVariables();
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStep.java b/org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStep.java
new file mode 100644 (file)
index 0000000..47c6918
--- /dev/null
@@ -0,0 +1,96 @@
+package org.argeo.slc.execution;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+\r
+/**\r
+ * An atomic step to be notified in during an {@link ExecutionProcess}. Can be a\r
+ * log or the start/end of a phase, etc.\r
+ */\r
+public class ExecutionStep implements Serializable {\r
+       private static final long serialVersionUID = 798640526532912161L;\r
+\r
+       public final static String PHASE_START = "PHASE_START";\r
+       public final static String PHASE_END = "PHASE_END";\r
+       public final static String ERROR = "ERROR";\r
+       public final static String WARNING = "WARNING";\r
+       public final static String INFO = "INFO";\r
+       public final static String DEBUG = "DEBUG";\r
+       public final static String TRACE = "TRACE";\r
+\r
+       /** @deprecated */\r
+       public final static String START = "START";\r
+       /** @deprecated */\r
+       public final static String END = "END";\r
+\r
+       // TODO make the fields final and private when we don't need POJO support\r
+       // anymore (that\r
+       // is when SlcExecutionStep is removed)\r
+       protected String type;\r
+       protected String thread;\r
+       protected Date timestamp;\r
+       protected String log;\r
+\r
+       private String location;\r
+\r
+       /** Empty constructor */\r
+       public ExecutionStep() {\r
+               Thread currentThread = Thread.currentThread();\r
+               thread = currentThread.getName();\r
+       }\r
+\r
+       /** Creates a step at the current date */\r
+       public ExecutionStep(String location, String type, String log) {\r
+               this(location, new Date(), type, log);\r
+       }\r
+\r
+       /** Creates a step of the given type. */\r
+       public ExecutionStep(String location, Date timestamp, String type,\r
+                       String log) {\r
+               this(location, timestamp, type, log, Thread.currentThread().getName());\r
+       }\r
+\r
+       public ExecutionStep(String location, Date timestamp, String type,\r
+                       String log, String thread) {\r
+               this.location = location;\r
+               this.type = type;\r
+               this.timestamp = timestamp;\r
+               this.thread = thread;\r
+               this.log = addLog(log);\r
+       }\r
+\r
+       public String getType() {\r
+               return type;\r
+       }\r
+\r
+       public Date getTimestamp() {\r
+               return timestamp;\r
+       }\r
+\r
+       public String getThread() {\r
+               return thread;\r
+       }\r
+\r
+       /**\r
+        * Return the string that should be stored in the log field. Can be null if\r
+        * another mechanism is used to store log lines.\r
+        */\r
+       protected String addLog(String log) {\r
+               return log;\r
+       }\r
+\r
+       public String getLog() {\r
+               return log;\r
+       }\r
+\r
+       @Override\r
+       public String toString() {\r
+               return "Execution step, thread=" + thread + ", type=" + type;\r
+       }\r
+\r
+       /** Typically the logging category */\r
+       public String getLocation() {\r
+               return location;\r
+       }\r
+\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/FlowConfigurationException.java b/org.argeo.slc.api/src/org/argeo/slc/execution/FlowConfigurationException.java
new file mode 100644 (file)
index 0000000..d476483
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.execution;
+
+import org.argeo.slc.SlcException;
+
+/** The stack trace of such exceptions does not need to be displayed */
+public class FlowConfigurationException extends SlcException {
+       private static final long serialVersionUID = 8456260596346797321L;
+
+       public FlowConfigurationException(String message) {
+               super(message);
+       }
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/RealizedFlow.java b/org.argeo.slc.api/src/org/argeo/slc/execution/RealizedFlow.java
new file mode 100644 (file)
index 0000000..c1290a9
--- /dev/null
@@ -0,0 +1,71 @@
+package org.argeo.slc.execution;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+
+/** A fully configured execution flow, ready to be executed. */
+public class RealizedFlow implements Serializable {
+       private static final long serialVersionUID = 1L;
+
+       private String moduleName;
+       private String moduleVersion;
+       private ExecutionFlowDescriptor flowDescriptor;
+
+       public String getModuleName() {
+               return moduleName;
+       }
+
+       public void setModuleName(String moduleName) {
+               this.moduleName = moduleName;
+       }
+
+       public NameVersion getModuleNameVersion() {
+               return new DefaultNameVersion(getModuleName(), getModuleVersion());
+       }
+
+       public String getModuleVersion() {
+               return moduleVersion;
+       }
+
+       public void setModuleVersion(String moduleVersion) {
+               this.moduleVersion = moduleVersion;
+       }
+
+       public ExecutionFlowDescriptor getFlowDescriptor() {
+               return flowDescriptor;
+       }
+
+       public void setFlowDescriptor(ExecutionFlowDescriptor flowDescriptor) {
+               this.flowDescriptor = flowDescriptor;
+       }
+
+       /** Create a simple realized flow */
+       public static RealizedFlow create(String module, String version,
+                       String flowName, Map<String, String> args) {
+               final RealizedFlow realizedFlow = new RealizedFlow();
+               realizedFlow.setModuleName(module);
+               // TODO deal with version
+               if (version == null)
+                       version = "0.0.0";
+               realizedFlow.setModuleVersion(version);
+               ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
+               efd.setName(flowName);
+
+               // arguments
+               if (args != null && args.size() > 0) {
+                       Map<String, Object> values = new HashMap<String, Object>();
+                       for (String key : args.keySet()) {
+                               String value = args.get(key);
+                               values.put(key, value);
+                       }
+                       efd.setValues(values);
+               }
+
+               realizedFlow.setFlowDescriptor(efd);
+               return realizedFlow;
+       }
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/RefSpecAttribute.java b/org.argeo.slc.api/src/org/argeo/slc/execution/RefSpecAttribute.java
new file mode 100644 (file)
index 0000000..b9bded0
--- /dev/null
@@ -0,0 +1,62 @@
+package org.argeo.slc.execution;
+
+import java.util.List;
+
+/** A spec attribute whose value is a reference to a full fledged object. */
+public class RefSpecAttribute extends AbstractSpecAttribute implements
+               Cloneable {
+       private static final long serialVersionUID = -3427797452955753574L;
+       private transient Class<?> targetClass = String.class;
+       /** Read only. */
+       private String targetClassName;
+       private transient Object value = null;
+
+       /** List to be chosen from */
+       private List<RefValueChoice> choices = null;
+
+       public Object getValue() {
+               return value;
+       }
+
+       public void setValue(Object value) {
+               this.value = value;
+       }
+
+       /** Default is {@link String} */
+       public Class<?> getTargetClass() {
+               return targetClass;
+       }
+
+       public void setTargetClass(Class<?> targetClass) {
+               this.targetClass = targetClass;
+               this.targetClassName = targetClass.getName();
+       }
+
+       public String getTargetClassName() {
+               return targetClassName;
+       }
+
+       /** @return can be null */
+       public List<RefValueChoice> getChoices() {
+               return choices;
+       }
+
+       public void setChoices(List<RefValueChoice> choices) {
+               this.choices = choices;
+       }
+
+       @Override
+       protected Object clone() throws CloneNotSupportedException {
+               RefSpecAttribute rsa = new RefSpecAttribute();
+               rsa.setTargetClass(targetClass);
+               rsa.setChoices(choices);
+               return rsa;
+       }
+
+       @Override
+       public String toString() {
+               return "Ref spec attribute [" + targetClass + "]"
+                               + (value != null ? "=" + value : "");
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/RefValue.java b/org.argeo.slc.api/src/org/argeo/slc/execution/RefValue.java
new file mode 100644 (file)
index 0000000..02be2a6
--- /dev/null
@@ -0,0 +1,38 @@
+package org.argeo.slc.execution;
+
+/** Reference value to be used by an execution */
+public class RefValue extends AbstractExecutionValue {
+       private static final long serialVersionUID = -8951231456757181687L;
+       private String ref;
+       private String type;
+
+       public RefValue() {
+       }
+
+       public RefValue(String ref) {
+               super();
+               this.ref = ref;
+       }
+
+       public String getRef() {
+               return ref;
+       }
+
+       public void setRef(String ref) {
+               this.ref = ref;
+       }
+
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               this.type = type;
+       }
+
+       @Override
+       public String toString() {
+               return "Ref Value [" + type + "=" + ref + "]";
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/RefValueChoice.java b/org.argeo.slc.api/src/org/argeo/slc/execution/RefValueChoice.java
new file mode 100644 (file)
index 0000000..c4c403e
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.slc.execution;
+
+import java.io.Serializable;
+
+/** A choice of ref value to be shown to the end user. */
+public class RefValueChoice implements Serializable {
+       private static final long serialVersionUID = -1133645722307507774L;
+       private String name;
+       private String description;
+
+       public RefValueChoice() {
+       }
+
+       public RefValueChoice(String name, String description) {
+               this.name = name;
+               this.description = description;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getDescription() {
+               return description;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgent.java b/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgent.java
new file mode 100644 (file)
index 0000000..039724f
--- /dev/null
@@ -0,0 +1,51 @@
+package org.argeo.slc.execution;
+
+import java.net.URI;
+import java.util.List;
+
+/**
+ * A local agent can run SLC processes. It is responsible for creating their
+ * threads and integrating them with various UIs. It typically wraps
+ * {@link ExecutionModulesManager} which is used to run flows synchronously at a
+ * lower level.
+ */
+public interface SlcAgent {
+       /** Agent unique identifier */
+       public String getAgentUuid();
+
+       /** Execute / take part to this process */
+       public void process(ExecutionProcess process);
+
+       /**
+        * Asynchronously processes the flows defined as URIs, or interpret a single
+        * UUID URN as a scheduled or template process.
+        * 
+        * @return the UUID of the process launched.
+        */
+       public String process(List<URI> uris);
+
+       /** Kills this process */
+       public void kill(String processUuid);
+
+       /**
+        * Wait for this process to finish. returns immediately if it does not
+        * exist.
+        * 
+        * @param millis
+        *            can be null
+        */
+       public void waitFor(String processUuid, Long millis);
+
+       /**
+        * Describe all the flows provided by this execution module. Typically
+        * called in order to build a realized flow.
+        */
+       public ExecutionModuleDescriptor getExecutionModuleDescriptor(
+                       String moduleName, String version);
+
+       /** List all execution modules which can be processed by this agent. */
+       public List<ExecutionModuleDescriptor> listExecutionModuleDescriptors();
+
+       /** @return true if still alive. */
+       public boolean ping();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgentCli.java b/org.argeo.slc.api/src/org/argeo/slc/execution/SlcAgentCli.java
new file mode 100644 (file)
index 0000000..497d110
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.execution;
+
+/**
+ * Interpret a command line and run it in the underlying agent, with the proper
+ * authentication.
+ */
+public interface SlcAgentCli {
+       /**
+        * Synchronously executes.
+        * 
+        * @return the UUID of the process
+        */
+       public String process(String[] args);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/package.html b/org.argeo.slc.api/src/org/argeo/slc/package.html
new file mode 100644 (file)
index 0000000..db808c8
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+Common classes of teh SLC framework.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveAccessor.java b/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveAccessor.java
new file mode 100644 (file)
index 0000000..b3f87ba
--- /dev/null
@@ -0,0 +1,22 @@
+package org.argeo.slc.primitive;
+
+/** Abstraction of access to primitive values */
+public interface PrimitiveAccessor {
+       public final static String TYPE_STRING = "string";
+       /**
+        * As of Argeo 1, passwords are NOT stored encrypted, just hidden in the UI,
+        * but stored in plain text in JCR. Use keyring instead.
+        */
+       public final static String TYPE_PASSWORD = "password";
+       public final static String TYPE_INTEGER = "integer";
+       public final static String TYPE_LONG = "long";
+       public final static String TYPE_FLOAT = "float";
+       public final static String TYPE_DOUBLE = "double";
+       public final static String TYPE_BOOLEAN = "boolean";
+
+       public String getType();
+
+       public Object getValue();
+
+       public void setValue(Object value);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java b/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java
new file mode 100644 (file)
index 0000000..cc3ee67
--- /dev/null
@@ -0,0 +1,51 @@
+package org.argeo.slc.primitive;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.AbstractSpecAttribute;
+
+/**
+ * A spec attribute wrapping a primitive value.
+ * 
+ * @see PrimitiveAccessor
+ */
+public class PrimitiveSpecAttribute extends AbstractSpecAttribute implements
+               PrimitiveAccessor {
+       private static final long serialVersionUID = -566676381839825483L;
+       private String type = "string";
+       private Object value = null;
+
+       public PrimitiveSpecAttribute() {
+       }
+
+       public PrimitiveSpecAttribute(String type, Object value) {
+               this.type = type;
+               this.value = value;
+       }
+
+       public Object getValue() {
+               return value;
+       }
+
+       public void setValue(Object value) {
+               this.value = value;
+       }
+
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               // check whether type is recognized.
+               if (PrimitiveUtils.typeAsClass(type) == null)
+                       throw new SlcException("Unrecognized type " + type);
+               this.type = type;
+
+       }
+
+       @Override
+       public String toString() {
+               return "Primitive spec attribute [" + type + "]"
+                               + (value != null ? "=" + value : "");
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveUtils.java b/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveUtils.java
new file mode 100644 (file)
index 0000000..679e808
--- /dev/null
@@ -0,0 +1,95 @@
+package org.argeo.slc.primitive;
+
+/** Converts to and from primitive types. */
+public class PrimitiveUtils {
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_STRING} instead
+        */
+       public final static String TYPE_STRING = PrimitiveAccessor.TYPE_STRING;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_INTEGER} instead
+        */
+       public final static String TYPE_INTEGER = PrimitiveAccessor.TYPE_INTEGER;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_LONG} instead
+        */
+       public final static String TYPE_LONG = PrimitiveAccessor.TYPE_LONG;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_FLOAT} instead
+        */
+       public final static String TYPE_FLOAT = PrimitiveAccessor.TYPE_FLOAT;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_DOUBLE} instead
+        */
+       public final static String TYPE_DOUBLE = PrimitiveAccessor.TYPE_DOUBLE;
+       /**
+        * @deprecated Use {@link PrimitiveAccessor#TYPE_BOOLEAN} instead
+        */
+       public final static String TYPE_BOOLEAN = PrimitiveAccessor.TYPE_BOOLEAN;
+
+       private PrimitiveUtils() {
+
+       }
+
+       /** @return the class or null if the provided type is not a primitive */
+       public static Class<?> typeAsClass(String type) {
+               if (PrimitiveAccessor.TYPE_STRING.equals(type))
+                       return String.class;
+               else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type))
+                       return char[].class;
+               else if (PrimitiveAccessor.TYPE_INTEGER.equals(type))
+                       return Integer.class;
+               else if (PrimitiveAccessor.TYPE_LONG.equals(type))
+                       return Long.class;
+               else if (PrimitiveAccessor.TYPE_FLOAT.equals(type))
+                       return Float.class;
+               else if (PrimitiveAccessor.TYPE_DOUBLE.equals(type))
+                       return Double.class;
+               else if (PrimitiveAccessor.TYPE_BOOLEAN.equals(type))
+                       return Boolean.class;
+               else
+                       return null;
+       }
+
+       /** @return the type or null if the provided class is not a primitive */
+       public static String classAsType(Class<?> clss) {
+               if (String.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_STRING;
+               else if (char[].class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_PASSWORD;
+               else if (Integer.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_INTEGER;
+               else if (Long.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_LONG;
+               else if (Float.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_FLOAT;
+               else if (Double.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_DOUBLE;
+               else if (Boolean.class.isAssignableFrom(clss))
+                       return PrimitiveAccessor.TYPE_BOOLEAN;
+               else
+                       return null;
+       }
+
+       /** Parse string as an object. Passwords are returned as String.*/
+       public static Object convert(String type, String str) {
+               if (PrimitiveAccessor.TYPE_STRING.equals(type)) {
+                       return str;
+               } else if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) {
+                       return str;
+               } else if (PrimitiveAccessor.TYPE_INTEGER.equals(type)) {
+                       return (Integer.parseInt(str));
+               } else if (PrimitiveAccessor.TYPE_LONG.equals(type)) {
+                       return (Long.parseLong(str));
+               } else if (PrimitiveAccessor.TYPE_FLOAT.equals(type)) {
+                       return (Float.parseFloat(str));
+               } else if (PrimitiveAccessor.TYPE_DOUBLE.equals(type)) {
+                       return (Double.parseDouble(str));
+               } else if (PrimitiveAccessor.TYPE_BOOLEAN.equals(type)) {
+                       return (Boolean.parseBoolean(str));
+               } else {
+                       return str;
+               }
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveValue.java b/org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveValue.java
new file mode 100644 (file)
index 0000000..0c2bf23
--- /dev/null
@@ -0,0 +1,39 @@
+package org.argeo.slc.primitive;
+
+import org.argeo.slc.execution.AbstractExecutionValue;
+
+/** Primitive value to be used by an execution. */
+public class PrimitiveValue extends AbstractExecutionValue implements
+               PrimitiveAccessor {
+       private static final long serialVersionUID = 533414290998374166L;
+
+       private String type;
+
+       private Object value;
+
+       public PrimitiveValue() {
+       }
+
+       public PrimitiveValue(String type, Object value) {
+               super();
+               this.type = type;
+               this.value = value;
+       }
+
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               this.type = type;
+       }
+
+       public Object getValue() {
+               return value;
+       }
+
+       public void setValue(Object value) {
+               this.value = value;
+       }
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/slc.cnd b/org.argeo.slc.api/src/org/argeo/slc/slc.cnd
new file mode 100644 (file)
index 0000000..ed4a160
--- /dev/null
@@ -0,0 +1,294 @@
+<slc = 'http://www.argeo.org/ns/slc'>
+
+// COMMON
+[slc:nameVersion] > nt:base
+mixin
+- slc:name (STRING) m
+- slc:version (STRING) m
+
+[slc:categorizedNameVersion] > slc:nameVersion
+mixin
+// define as mandatory?
+- slc:category (STRING)
+
+// AGENT
+[slc:agentFactory] > nt:unstructured, mix:title
++ * (slc:agent)
+
+[slc:agent] > nt:unstructured, mix:title
++ * (slc:module)
+
+[slc:module] > slc:nameVersion, mix:title
+mixin
+
+[slc:activableModule] > slc:module
+mixin
+
+[slc:executionModule] > slc:activableModule
+mixin
+
+[slc:executionSpec] > nt:unstructured, mix:referenceable, mix:title
+- slc:name (STRING) m
++ * (slc:executionSpecAttribute) *
+
+[slc:executionSpecAttribute] > nt:base
+mixin abstract
+- slc:isImmutable (BOOLEAN) 
+- slc:isConstant (BOOLEAN) 
+- slc:isHidden (BOOLEAN) 
+
+[slc:primitiveSpecAttribute] > slc:executionSpecAttribute
+mixin
+- slc:type (STRING) 
+- slc:value (UNDEFINED)
+
+[slc:refSpecAttribute] > slc:executionSpecAttribute
+orderable
+mixin
+// typically a class name
+- slc:type (STRING)
+- slc:value (UNDEFINED)
++ * (mix:title)
+
+[slc:executionFlow] > nt:unstructured, mix:title
+- slc:name (STRING) ! m
+// if the execution spec is a referenceable node
+- slc:spec (REFERENCE)
+// if the execution spec is internal (without name)
++ * (slc:executionSpecAttribute) *
+
+// PROCESS
+[slc:process] > nt:unstructured, mix:created, mix:lastModified
+orderable
+- slc:uuid (STRING) ! m
+- slc:status (STRING) m
++ slc:flow (slc:realizedFlow)
++ slc:log
+
+// The first part of the relative path is the thread name, rest is location
+[slc:logEntry] > nt:unstructured
+abstract
+- slc:message (STRING) !
+- slc:timestamp (STRING)
+
+// Log levels are set via types.
+// Querying one level also queries the higher levels thanks to the inheritance
+// e.g. 'select * from [slc:logWarn]' also returns errors 
+[slc:logTrace] > slc:logEntry
+
+[slc:logDebug] > slc:logTrace
+
+[slc:logInfo] > slc:logDebug
+
+[slc:logWarning] > slc:logInfo
+
+[slc:logError] > slc:logWarning
+
+[slc:realizedFlow] > nt:base
+orderable
+mixin
+// the name of the flow
+// - slc:flow (STRING)
+// the name of the execution spec
+// - slc:spec (STRING)
+- slc:started (DATE)
+- slc:completed (DATE)
+//- slc:status (STRING)
++ slc:address (nt:address)
++ slc:flow (slc:realizedFlow) *
+// the realized execution spec attributes
++ * (slc:executionSpecAttribute) *
+
+// RESULT
+[slc:testResult] > nt:unstructured, mix:created, mix:lastModified
+- slc:uuid (STRING) ! m
+- slc:testCase (STRING)
+- slc:completed (DATE)
+// Helper to keep a centralize place to have testResultStatus
+// when adding more than one result part to a given testResult 
++ slc:aggregatedStatus (slc:check)
+// DEPRECATED - FOR COMPATIBILITY - DO NOT USE
++ slc:testStatus (slc:check)
+
+[slc:diffResult] > slc:testResult
++ slc:summary
++ slc:issues
+
+[slc:resultFolder] > nt:unstructured
++ slc:folderStatus (slc:check)
++ * (slc:resultFolder) *
++ * (slc:testResult) *
+
+// base node for user defined and managed result tree
+// simplify UI management
+[slc:myResultRootFolder] > nt:unstructured
++ * (slc:resultFolder) *
++ * (slc:testResult) *
+
+[slc:check] > nt:unstructured
+// true for PASSED, false for FAILED or ERROR
+- slc:success (BOOLEAN) ! m
+- slc:message (STRING)
+// ERROR if set, the check could not be performed because of an unexpected exception
+- slc:errorMessage (STRING)
+// to ease transition with legacy approach
++ * (slc:property) *
+
+[slc:property] > nt:unstructured
+- slc:name (STRING) ! m
+- slc:value (STRING) m
+
+//
+// DISTRIBUTION
+//
+
+// AETHER
+[slc:artifact] > mix:referenceable, mix:created, mix:lastModified
+mixin
+- slc:artifactId (STRING) m
+- slc:groupId (STRING) m
+- slc:artifactVersion (STRING) m
+- slc:artifactExtension (STRING) m
+- slc:artifactClassifier (STRING) ='' m a
+
+[slc:artifactVersion] > mix:referenceable, mix:created, mix:lastModified, mix:title
+mixin
+- slc:artifactId (STRING) m
+- slc:groupId (STRING) m
+- slc:artifactVersion (STRING) m
+
+[slc:artifactBase] > mix:referenceable, mix:created, mix:lastModified
+mixin
+- slc:artifactId (STRING) m
+- slc:groupId (STRING) m
+
+[slc:groupBase] > mix:referenceable, mix:created, mix:lastModified
+mixin
+// it is possible to have groupBase being artifact base (e.g. org.argeo.commons.basic)
+// so using groupId would conflict 
+- slc:groupBaseId (STRING) m
+
+[slc:modularDistributionBase]
+mixin
+
+[slc:modularDistribution] 
+mixin
++ slc:modules (nt:unstructured) m
+
+[slc:moduleCoordinates] > nt:unstructured
+- slc:category (STRING)
+- slc:name (STRING)
+- slc:version (STRING)
+
+// ORIGINS
+[slc:knownOrigin] > nt:base
+mixin
++ slc:origin (nt:address)
+
+[slc:proxied] > nt:address
+- slc:proxy (REFERENCE)
+
+// JAVA
+[slc:jarFile] > mix:referenceable
+mixin
+- 'slc:manifest' (BINARY) m
+- 'slc:Manifest-Version' (STRING)
+- 'slc:Signature-Version' (STRING)
+- 'slc:Class-Path'  (STRING)
+- 'slc:Main-Class' (STRING)
+- 'slc:Extension-Name' (STRING)
+- 'slc:Implementation-Version' (STRING)
+- 'slc:Implementation-Vendor' (STRING)
+- 'slc:Implementation-Vendor-Id' (STRING)
+- 'slc:Implementation-URL' (STRING)
+- 'slc:Specification-Title' (STRING)
+- 'slc:Specification-Version' (STRING)
+- 'slc:Specification-Vendor' (STRING)
+- 'slc:Sealed' (STRING)
+
+// OSGi
+// see http://www.osgi.org/Specifications/Reference
+
+[slc:javaPackage] > mix:referenceable
+- slc:name (STRING) primary m
+
+[slc:osgiBaseVersion] > mix:referenceable
+- slc:asString (STRING) primary m
+- slc:major (LONG) m
+- slc:minor (LONG) m
+- slc:micro (LONG) m
+
+[slc:osgiVersion] > slc:osgiBaseVersion
+- slc:qualifier (STRING)
+
+[slc:exportedPackage] > slc:javaPackage
++ slc:uses (slc:javaPackage) multiple
++ slc:version (slc:osgiVersion)
+
+[slc:importedPackage] > slc:javaPackage
+- slc:version (STRING) ='0.0.0' m a
+- slc:optional (BOOLEAN) ='false' m a
+
+[slc:dynamicImportedPackage] > slc:javaPackage
+- slc:version (STRING) ='0.0.0' m a
+- slc:optional (BOOLEAN) ='false' m a
+
+[slc:requiredBundle] > mix:referenceable
+- 'slc:symbolic-name' (STRING) primary m
+- 'slc:bundle-version' (STRING) ='0.0.0' m a
+- slc:optional (BOOLEAN) ='false' m a
+
+[slc:fragmentHost] > mix:referenceable
+- 'slc:symbolic-name' (STRING) m
+- 'slc:bundle-version' (STRING) ='0.0.0' m a
+
+[slc:bundleNativeCode] > mix:referenceable
+- slc:path (STRING) primary m
+- slc:osname (STRING)
+- slc:processor (STRING)
+
+// see http://www.osgi.org/Specifications/ReferenceHeaders
+[slc:bundle] > mix:referenceable
+mixin
+- 'slc:symbolic-name' (STRING) primary m
+- 'slc:bundle-version' (STRING) m
+- 'slc:Bundle-SymbolicName' (STRING) m
+- 'slc:Bundle-Name' (STRING)
+- 'slc:Bundle-Description' (STRING)
+- 'slc:Bundle-ManifestVersion' (STRING)
+- 'slc:Bundle-Category' (STRING)
+- 'slc:Bundle-ActivationPolicy' (STRING)
+- 'slc:Bundle-Copyright' (STRING)
+- 'slc:Bundle-Vendor' (STRING)
+- 'slc:Bundle-License' (STRING)
+- 'slc:Bundle-DocURL' (STRING)
+- 'slc:Bundle-ContactAddress' (STRING)
+- 'slc:Bundle-Activator' (STRING)
+- 'slc:Bundle-UpdateLocation' (STRING)
+- 'slc:Bundle-Localization' (STRING)
+- 'slc:Bundle-ClassPath' (STRING) *
+// see http://wiki.eclipse.org/EE  < 'OSGi/Minimum-1.0','OSGi/Minimum-1.1','CDC-1.0/Foundation-1.0','CDC-1.1/Foundation-1.1','JRE-1.1','J2SE-1.2','J2SE-1.3','J2SE-1.4','J2SE-1.5','JavaSE-1.6','JavaSE-1.7'
+- 'slc:Bundle-RequiredExecutionEnvironment' (STRING) *
++ 'slc:Bundle-Version' (slc:osgiVersion) m
++ 'slc:Fragment-Host' (slc:fragmentHost)
++ 'slc:Import-Package' (slc:importedPackage) multiple
++ 'slc:Export-Package' (slc:exportedPackage) multiple
++ 'slc:Require-Bundle' (slc:requiredBundle) multiple
++ 'slc:Bundle-NativeCode' (slc:bundleNativeCode) multiple
++ 'slc:DynamicImport-Package' (slc:dynamicImportedPackage) multiple
+
+[slc:bundleArtifact] > slc:artifact,slc:jarFile,slc:bundle
+mixin
+
+// RPM
+[slc:rpm] > mix:referenceable, mix:created, mix:lastModified, mix:title
+mixin
+- slc:name (STRING)
+- slc:version (STRING)
+- slc:rpmVersion (STRING)
+- slc:rpmRelease (STRING)
+- slc:rpmArch (STRING)
+- slc:rpmArchiveSize (STRING)
+// TYPO - TO BE REMOVED
+- slc:rpmArchivaeSize (STRING)
+
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/ExecutableTestRun.java b/org.argeo.slc.api/src/org/argeo/slc/test/ExecutableTestRun.java
new file mode 100644 (file)
index 0000000..f18196a
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.test;\r
+\r
+\r
+/** A test run that can be executed */\r
+public interface ExecutableTestRun extends TestRun, Runnable {\r
+\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/IncompatibleTestDataException.java b/org.argeo.slc.api/src/org/argeo/slc/test/IncompatibleTestDataException.java
new file mode 100644 (file)
index 0000000..de5d900
--- /dev/null
@@ -0,0 +1,24 @@
+package org.argeo.slc.test;\r
+\r
+import org.argeo.slc.SlcException;\r
+\r
+/**\r
+ * Exception to throw when a test definition cannot interpret the provided test\r
+ * data.\r
+ */\r
+public class IncompatibleTestDataException extends SlcException {\r
+       static final long serialVersionUID = 1l;\r
+\r
+       public IncompatibleTestDataException(TestData testData,\r
+                       TestDefinition testDefinition) {\r
+               super("TestData " + testData.getClass()\r
+                               + " is not compatible with TestDefinition "\r
+                               + testDefinition.getClass());\r
+       }\r
+\r
+       public IncompatibleTestDataException(TestRun testRun) {\r
+               super("TestData " + ((TestData) testRun.getTestData()).getClass()\r
+                               + " is not compatible with TestDefinition "\r
+                               + ((TestDefinition) testRun.getTestDefinition()).getClass());\r
+       }\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/TestData.java b/org.argeo.slc.api/src/org/argeo/slc/test/TestData.java
new file mode 100644 (file)
index 0000000..47973ad
--- /dev/null
@@ -0,0 +1,9 @@
+package org.argeo.slc.test;\r
+\r
+/**\r
+ * Any data required by a test in order to run: configuration, expected,\r
+ * reached, etc.\r
+ */\r
+public interface TestData {\r
+\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/TestDataProvider.java b/org.argeo.slc.api/src/org/argeo/slc/test/TestDataProvider.java
new file mode 100644 (file)
index 0000000..754a3df
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.test;\r
+\r
+public interface TestDataProvider {\r
+       public <T extends TestData> T getTestData(Class<T> clss, String key);\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/TestDefinition.java b/org.argeo.slc.api/src/org/argeo/slc/test/TestDefinition.java
new file mode 100644 (file)
index 0000000..c7bfeac
--- /dev/null
@@ -0,0 +1,10 @@
+package org.argeo.slc.test;\r
+\r
+/**\r
+ * The programmatic definition of a test, which will be associated with\r
+ * transient objects within a test run.\r
+ */\r
+public interface TestDefinition extends TestStatus {\r
+       /** Performs the test. */\r
+       public void execute(TestRun testRun);\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/TestResult.java b/org.argeo.slc.api/src/org/argeo/slc/test/TestResult.java
new file mode 100644 (file)
index 0000000..767b286
--- /dev/null
@@ -0,0 +1,27 @@
+package org.argeo.slc.test;
+
+import java.util.Date;
+import java.util.Map;
+
+/** The result of a test */
+public interface TestResult extends TestStatus, TestRunAware {
+       public String getUuid();
+
+       /** Adds a part of the result. */
+       public void addResultPart(TestResultPart part);
+
+       /**
+        * Marks that the collection of test results is completed and free the
+        * related resources (also closing listeners).
+        */
+       public void close();
+
+       /**
+        * The date when this test result was closed. Can be null, which means the
+        * result is not closed.
+        */
+       public Date getCloseDate();
+
+       /** Additional arbitrary meta data */
+       public Map<String, String> getAttributes();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/TestResultListener.java b/org.argeo.slc.api/src/org/argeo/slc/test/TestResultListener.java
new file mode 100644 (file)
index 0000000..c2ad8ed
--- /dev/null
@@ -0,0 +1,10 @@
+package org.argeo.slc.test;
+
+/** Listener to the operations on a test result. */
+public interface TestResultListener<T extends TestResult> {
+       /** Notified when a part was added to a test result. */
+       public void resultPartAdded(T testResult, TestResultPart testResultPart);
+
+       /** Stops listening and release the related resources. */
+       public void close(T testResult);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/TestResultPart.java b/org.argeo.slc.api/src/org/argeo/slc/test/TestResultPart.java
new file mode 100644 (file)
index 0000000..ec984f9
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.slc.test;
+
+/**
+ * Part of a test result.
+ * 
+ * @see TestResult
+ */
+public interface TestResultPart {
+       /** The status, as defined in {@link TestStatus}. */
+       public Integer getStatus();
+
+       /** The related message. */
+       public String getMessage();
+
+       /** The underlying <code>Exception</code>. Can be null. */
+       public String getExceptionMessage();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/TestRun.java b/org.argeo.slc.api/src/org/argeo/slc/test/TestRun.java
new file mode 100644 (file)
index 0000000..a3e8aeb
--- /dev/null
@@ -0,0 +1,21 @@
+package org.argeo.slc.test;
+
+import org.argeo.slc.deploy.DeployedSystem;
+
+/** The actual run of a test */
+public interface TestRun {
+       /** Gets UUID */
+       public String getUuid();
+
+       /** Gets the related test definition. */
+       public <T extends TestDefinition> T getTestDefinition();
+
+       /** Gets the related test data */
+       public <T extends TestData> T getTestData();
+
+       /** Gets the related deployed system. */
+       public <T extends DeployedSystem> T getDeployedSystem();
+
+       /** Gets the related result where to record results. */
+       public <T extends TestResult> T getTestResult();
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/TestRunAware.java b/org.argeo.slc.api/src/org/argeo/slc/test/TestRunAware.java
new file mode 100644 (file)
index 0000000..5458559
--- /dev/null
@@ -0,0 +1,8 @@
+package org.argeo.slc.test;
+
+/** Allows a test run to notify other objects. */
+public interface TestRunAware {
+       /** Notifies the current test run. */
+       public void notifyTestRun(TestRun testRun);
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/TestStatus.java b/org.argeo.slc.api/src/org/argeo/slc/test/TestStatus.java
new file mode 100644 (file)
index 0000000..a5e10d3
--- /dev/null
@@ -0,0 +1,31 @@
+package org.argeo.slc.test;
+
+/**
+ * Simple statuses. Ordering of the flags can be relied upon in aggregation: if
+ * one element is failed, the aggregation is failed. Is one element is in ERROR,
+ * the aggregation is in ERROR.
+ * <p>
+ * <ul>
+ * <li>{@link #PASSED}: the test succeeded</li>
+ * <li>{@link #FAILED}: the test could run, but did not reach the expected
+ * result</li>
+ * <li>{@link #ERROR}: an error during the test run prevented to get a
+ * significant information on the tested system.</li>
+ * </ul>
+ * </p>
+ */
+public interface TestStatus {
+       /** The flag for a passed test: 0 */
+       public final static Integer PASSED = 0;
+       /** The flag for a failed test: 1 */
+       public final static Integer FAILED = 1;
+       /**
+        * The flag for a test which could not properly run because of an error
+        * (there is no feedback on the behavior of the tested component): 2
+        */
+       public final static Integer ERROR = 2;
+       public final static String STATUSSTR_PASSED = "PASSED";
+       public final static String STATUSSTR_FAILED = "FAILED";
+       public final static String STATUSSTR_ERROR = "ERROR";
+
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/WritableTestRun.java b/org.argeo.slc.api/src/org/argeo/slc/test/WritableTestRun.java
new file mode 100644 (file)
index 0000000..1a2ab23
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.test;
+
+import org.argeo.slc.deploy.DeployedSystem;
+
+/** Test run whose various components can be externally set. */
+public interface WritableTestRun extends ExecutableTestRun {
+       public void setDeployedSystem(DeployedSystem deployedSystem);
+
+       public void setTestData(TestData testData);
+
+       public void setTestDefinition(TestDefinition testDefinition);
+
+       public void setTestResult(TestResult testResult);
+}
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/context/ContextAware.java b/org.argeo.slc.api/src/org/argeo/slc/test/context/ContextAware.java
new file mode 100644 (file)
index 0000000..d2cd86f
--- /dev/null
@@ -0,0 +1,22 @@
+package org.argeo.slc.test.context;\r
+\r
+import java.util.Map;\r
+\r
+/** Access to an SLC test context that is, maps of reached and expected values. */\r
+public interface ContextAware {\r
+       public final static String DEFAULT_SKIP_FLAG = "!";\r
+       public final static String DEFAULT_ANY_FLAG = "*";\r
+\r
+       /** Retrieves reached values. */\r
+       public Map<String, Object> getValues();\r
+\r
+       /** Set reached values. */\r
+       public void setValues(Map<String, Object> values);\r
+\r
+       /** Retrieves expected values. */\r
+       public Map<String, Object> getExpectedValues();\r
+\r
+       public String getContextSkipFlag();\r
+\r
+       public String getContextAnyFlag();\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/context/ParentContextAware.java b/org.argeo.slc.api/src/org/argeo/slc/test/context/ParentContextAware.java
new file mode 100644 (file)
index 0000000..b4044f7
--- /dev/null
@@ -0,0 +1,9 @@
+package org.argeo.slc.test.context;\r
+\r
+import java.util.Collection;\r
+\r
+public interface ParentContextAware extends ContextAware {\r
+       public Collection<ContextAware> getChildContexts();\r
+\r
+       public void addChildContext(ContextAware contextAware);\r
+}\r
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/context/package.html b/org.argeo.slc.api/src/org/argeo/slc/test/context/package.html
new file mode 100644 (file)
index 0000000..cd08d63
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+Context variables to be passed between parts of tests.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/org.argeo.slc.api/src/org/argeo/slc/test/package.html b/org.argeo.slc.api/src/org/argeo/slc/test/package.html
new file mode 100644 (file)
index 0000000..c70d2d1
--- /dev/null
@@ -0,0 +1,6 @@
+<html>\r
+<head></head>\r
+<body>\r
+SLC Test: test of software systems.\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/org.argeo.slc.factory/.classpath b/org.argeo.slc.factory/.classpath
new file mode 100644 (file)
index 0000000..bc86c42
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" output="target/classes" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.argeo.slc.factory/.gitignore b/org.argeo.slc.factory/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/org.argeo.slc.factory/.project b/org.argeo.slc.factory/.project
new file mode 100644 (file)
index 0000000..948356f
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.factory</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.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.argeo.slc.factory/META-INF/.gitignore b/org.argeo.slc.factory/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/org.argeo.slc.factory/bnd.bnd b/org.argeo.slc.factory/bnd.bnd
new file mode 100644 (file)
index 0000000..35c4c44
--- /dev/null
@@ -0,0 +1,5 @@
+Import-Package: javax.jcr.nodetype,\
+org.argeo.slc.repo,\
+org.osgi.*;version=0.0.0,\
+*
+                                                       
\ No newline at end of file
diff --git a/org.argeo.slc.factory/pom.xml b/org.argeo.slc.factory/pom.xml
new file mode 100644 (file)
index 0000000..dadb1c7
--- /dev/null
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.factory</artifactId>
+       <name>SLC Factory</name>
+       <dependencies>
+               <!-- SLC -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.runtime</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.repo</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmFactory.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmFactory.java
new file mode 100644 (file)
index 0000000..0223a20
--- /dev/null
@@ -0,0 +1,62 @@
+package org.argeo.slc.rpmfactory;
+
+import java.io.File;
+import java.util.List;
+
+import javax.jcr.Node;
+
+/**
+ * Defines a build environment. This information is typically used by other
+ * components performing the various actions related to RPM build.
+ */
+public interface RpmFactory {
+       //
+       // DIRECT ACTIONS ON JCR REPOSITORY
+       //
+       public void indexWorkspace(String workspace);
+
+       public Node newDistribution(String distributionId);
+
+       //
+       // CONFIG FILES GENERATION
+       //
+       /** Creates a mock config file. */
+       public File getMockConfigFile(String arch, String branch);
+
+       /** Creates a yum config file. */
+       public File getYumRepoFile(String arch);
+
+       //
+       // WORKSPACES
+       //
+       public String getStagingWorkspace();
+
+       /**
+        * @return the name of the testing workspace, or null if and only if the
+        *         testing workspace was not enabled.
+        */
+       public String getTestingWorkspace();
+
+       public String getStableWorkspace();
+
+       public File getWorkspaceDir(String workspace);
+
+       //
+       // ARCH DEPENDENT INFOS
+       //
+       public List<String> getArchs();
+
+       public String getMockConfig(String arch);
+
+       public String getIdWithArch(String arch);
+
+       public File getResultDir(String arch);
+
+       //
+       // DEPLOYMENT
+       //
+       public String getGitBaseUrl();
+
+       public Boolean isDeveloperInstance();
+
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmProxyService.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmProxyService.java
new file mode 100644 (file)
index 0000000..40002a8
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.rpmfactory;
+
+import org.argeo.jcr.proxy.ResourceProxy;
+
+/** Marker interface (useful for OSGi services references), may be extended later */
+public interface RpmProxyService extends ResourceProxy {
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmRepository.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/RpmRepository.java
new file mode 100644 (file)
index 0000000..24d7c72
--- /dev/null
@@ -0,0 +1,9 @@
+package org.argeo.slc.rpmfactory;
+
+/** A YUM compatible repository of RPM packages. */
+public interface RpmRepository {
+       public String getId();
+
+       public String getUrl();
+
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/AbstractRpmRepository.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/AbstractRpmRepository.java
new file mode 100644 (file)
index 0000000..19418b6
--- /dev/null
@@ -0,0 +1,28 @@
+package org.argeo.slc.rpmfactory.core;
+
+import org.argeo.slc.rpmfactory.RpmRepository;
+
+/** Common method to RPM repositories. */
+public abstract class AbstractRpmRepository implements RpmRepository {
+       private String id;
+       private String url;
+
+       @Override
+       public String getId() {
+               return id;
+       }
+
+       @Override
+       public String getUrl() {
+               return url;
+       }
+
+       public void setId(String id) {
+               this.id = id;
+       }
+
+       public void setUrl(String url) {
+               this.url = url;
+       }
+
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/BuildInMock.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/BuildInMock.java
new file mode 100644 (file)
index 0000000..a69e39f
--- /dev/null
@@ -0,0 +1,191 @@
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.exec.Executor;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.runtime.tasks.SystemCall;
+
+/** Build an RPM in mock. */
+public class BuildInMock implements Runnable {
+       private final static Log log = LogFactory.getLog(BuildInMock.class);
+       private final static String NOARCH = "noarch";
+
+       private String rpmPackage = null;
+       private String branch = null;
+       private String arch = NOARCH;
+
+       private RpmFactory rpmFactory;
+       private Executor executor;
+
+       private String debuginfoDirName = "debuginfo";
+       private String mockExecutable = "/usr/bin/mock";
+
+       private List<String> preBuildCommands = new ArrayList<String>();
+
+       public void run() {
+               if (!rpmFactory.isDeveloperInstance()) {
+                       // clean/init
+                       SystemCall mockClean = createBaseMockCall();
+                       mockClean.arg("--init");
+                       mockClean.run();
+               }
+
+               // pre build commands
+               for (String preBuildCmd : preBuildCommands) {
+                       SystemCall mockClean = createBaseMockCall();
+                       mockClean.arg("--chroot").arg(preBuildCmd);
+                       mockClean.run();
+               }
+
+               // actual build
+               SystemCall mockBuild = createBaseMockCall();
+               mockBuild.arg("--scm-enable");
+               mockBuild.arg("--scm-option").arg("package=" + rpmPackage);
+               mockBuild.arg("--no-clean");
+               //
+               //
+               mockBuild.run();
+               //
+
+               // copy RPMs to target directories
+               File stagingDir = rpmFactory.getWorkspaceDir(rpmFactory
+                               .getStagingWorkspace());
+               File srpmDir = new File(stagingDir, "SRPMS");
+               srpmDir.mkdirs();
+               File archDir = null;
+               File debuginfoDir = null;
+               if (!arch.equals(NOARCH)) {
+                       archDir = new File(stagingDir, arch);
+                       debuginfoDir = new File(archDir, debuginfoDirName);
+                       debuginfoDir.mkdirs();
+               }
+
+               Set<File> reposToRecreate = new HashSet<File>();
+               File resultDir = rpmFactory.getResultDir(arch);
+               if (resultDir.exists())
+                       rpms: for (File file : resultDir.listFiles()) {
+                               if (file.isDirectory())
+                                       continue rpms;
+
+                               File[] targetDirs;
+                               if (file.getName().contains(".src.rpm"))
+                                       targetDirs = new File[] { srpmDir };
+                               else if (file.getName().contains("-debuginfo-"))
+                                       targetDirs = new File[] { debuginfoDir };
+                               else if (!arch.equals(NOARCH)
+                                               && file.getName().contains("." + arch + ".rpm"))
+                                       targetDirs = new File[] { archDir };
+                               else if (file.getName().contains(".noarch.rpm")) {
+                                       List<File> dirs = new ArrayList<File>();
+                                       for (String arch : rpmFactory.getArchs())
+                                               dirs.add(new File(stagingDir, arch));
+                                       targetDirs = dirs.toArray(new File[dirs.size()]);
+                               } else if (file.getName().contains(".rpm"))
+                                       throw new SlcException("Don't know where to copy " + file);
+                               else {
+                                       if (log.isTraceEnabled())
+                                               log.trace("Skip " + file);
+                                       continue rpms;
+                               }
+
+                               reposToRecreate.addAll(Arrays.asList(targetDirs));
+                               copyToDirs(file, targetDirs);
+                       }
+
+               // recreate changed repos
+               for (File repoToRecreate : reposToRecreate) {
+                       SystemCall createrepo = new SystemCall();
+                       createrepo.arg("createrepo");
+                       // sqllite db
+                       createrepo.arg("-d");
+                       // debuginfo
+                       if (!repoToRecreate.getName().equals(debuginfoDirName))
+                               createrepo.arg("-x").arg(debuginfoDirName + "/*");
+                       // quiet
+                       createrepo.arg("-q");
+                       createrepo.arg(repoToRecreate.getAbsolutePath());
+
+                       createrepo.setExecutor(executor);
+                       createrepo.run();
+                       log.info("Updated repo " + repoToRecreate);
+               }
+
+               // index staging workspace
+               rpmFactory.indexWorkspace(rpmFactory.getStagingWorkspace());
+       }
+
+       /** Creates a mock call with all the common options such as config file etc. */
+       protected SystemCall createBaseMockCall() {
+               String mockCfg = rpmFactory.getMockConfig(arch);
+               File mockConfigFile = rpmFactory.getMockConfigFile(arch, branch);
+
+               // prepare mock call
+               SystemCall mock = new SystemCall();
+
+               if (arch != null)
+                       mock.arg("setarch").arg(arch);
+               mock.arg(mockExecutable);
+               mock.arg("-v");
+               mock.arg("--configdir=" + mockConfigFile.getAbsoluteFile().getParent());
+               if (arch != null)
+                       mock.arg("--arch=" + arch);
+               mock.arg("-r").arg(mockCfg);
+
+               mock.setLogCommand(true);
+               mock.setExecutor(executor);
+
+               return mock;
+       }
+
+       protected void copyToDirs(File file, File[] dirs) {
+               for (File dir : dirs) {
+                       try {
+                               FileUtils.copyFileToDirectory(file, dir);
+                               if (log.isDebugEnabled())
+                                       log.debug(file + " => " + dir);
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot copy " + file + " to " + dir, e);
+                       }
+               }
+       }
+
+       public void setArch(String arch) {
+               this.arch = arch;
+       }
+
+       public void setRpmPackage(String rpmPackage) {
+               this.rpmPackage = rpmPackage;
+       }
+
+       public void setBranch(String branch) {
+               this.branch = branch;
+       }
+
+       public void setRpmFactory(RpmFactory env) {
+               this.rpmFactory = env;
+       }
+
+       public void setExecutor(Executor executor) {
+               this.executor = executor;
+       }
+
+       public void setMockExecutable(String mockExecutable) {
+               this.mockExecutable = mockExecutable;
+       }
+
+       public void setPreBuildCommands(List<String> preBuildCommands) {
+               this.preBuildCommands = preBuildCommands;
+       }
+
+}
\ No newline at end of file
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/CreateRpmDistribution.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/CreateRpmDistribution.java
new file mode 100644 (file)
index 0000000..6f60b3d
--- /dev/null
@@ -0,0 +1,142 @@
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.StringTokenizer;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.runtime.tasks.SystemCall;
+
+/**
+ * Gather RPMs from various sources (local builds or third party) into a
+ * consistent distributable set (typically to be used to generate an ISO).
+ */
+public class CreateRpmDistribution implements Runnable {
+       private final static Log log = LogFactory
+                       .getLog(CreateRpmDistribution.class);
+
+       private RpmFactory rpmFactory;
+       private RpmDistribution rpmDistribution;
+
+       private String arch = "x86_64";
+
+       private String repoqueryExecutable = "/usr/bin/repoquery";
+
+       @Override
+       public void run() {
+               Session session = null;
+               // Reader reader = null;
+               try {
+                       Node baseFolder = rpmFactory.newDistribution(rpmDistribution
+                                       .getId());
+                       session = baseFolder.getSession();
+                       Node targetFolder = baseFolder.addNode(arch, NodeType.NT_FOLDER);
+
+                       SystemCall repoquery = new SystemCall();
+                       repoquery.arg(repoqueryExecutable);
+
+                       File yumConfigFile = rpmFactory.getYumRepoFile(arch);
+                       repoquery.arg("-c", yumConfigFile.getAbsolutePath());
+                       repoquery.arg("--requires");
+                       repoquery.arg("--resolve");
+                       repoquery.arg("--location");
+                       repoquery.arg("--archlist=" + arch);
+
+                       for (String rpmPackage : rpmDistribution.getPackages())
+                               repoquery.arg(rpmPackage);
+
+                       if (log.isDebugEnabled())
+                               log.debug("Command:\n" + repoquery.asCommand());
+
+                       String output = repoquery.function();
+
+                       if (log.isDebugEnabled())
+                               log.debug(output + "\n");
+                       // reader = new StringReader(output);
+                       StringTokenizer lines = new StringTokenizer(output, "\n");
+                       // List<String> dependencies = IOUtils.readLines(reader);
+                       dependencies: while (lines.hasMoreTokens()) {
+                               String urlStr = lines.nextToken();
+                               InputStream in = null;
+                               try {
+                                       URL url = new URL(urlStr);
+                                       String fileName = FilenameUtils.getName(url.getFile());
+                                       String[] tokens = fileName.split("-");
+                                       if (tokens.length < 3)
+                                               continue dependencies;
+                                       StringBuilder buf = new StringBuilder();
+                                       for (int i = 0; i < tokens.length - 2; i++) {
+                                               if (i != 0)
+                                                       buf.append('-');
+                                               buf.append(tokens[i]);
+
+                                       }
+                                       String packageName = buf.toString();
+                                       for (RpmPackageSet excluded : rpmDistribution
+                                                       .getExcludedPackages()) {
+                                               if (excluded.contains(packageName)) {
+                                                       if (log.isDebugEnabled())
+                                                               log.debug("Skipped " + packageName);
+                                                       continue dependencies;// skip
+                                               }
+                                       }
+                                       in = url.openStream();
+                                       JcrUtils.copyStreamAsFile(targetFolder, fileName, in);
+                                       targetFolder.getSession().save();
+                                       if (log.isDebugEnabled())
+                                               log.debug("Copied  " + packageName);
+                               } catch (Exception e) {
+                                       log.error("Cannot copy " + urlStr, e);
+                               } finally {
+                                       IOUtils.closeQuietly(in);
+                               }
+                       }
+
+                       // createrepo
+                       File workspaceDir = rpmFactory.getWorkspaceDir(rpmDistribution
+                                       .getId());
+                       SystemCall createrepo = new SystemCall();
+                       createrepo.arg("createrepo");
+                       createrepo.arg("-q");
+                       createrepo.arg("-d");
+                       File archDir = new File(workspaceDir.getPath()
+                                       + targetFolder.getPath());
+                       createrepo.arg(archDir.getAbsolutePath());
+                       createrepo.run();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot generate distribution "
+                                       + rpmDistribution.getId(), e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+                       // IOUtils.closeQuietly(reader);
+               }
+       }
+
+       public void setRpmDistribution(RpmDistribution rpmDistribution) {
+               this.rpmDistribution = rpmDistribution;
+       }
+
+       public void setRpmFactory(RpmFactory rpmFactory) {
+               this.rpmFactory = rpmFactory;
+       }
+
+       public void setArch(String arch) {
+               this.arch = arch;
+       }
+
+       public void setRepoqueryExecutable(String yumdownloaderExecutable) {
+               this.repoqueryExecutable = yumdownloaderExecutable;
+       }
+
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ReleaseStaging.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ReleaseStaging.java
new file mode 100644 (file)
index 0000000..dcdbc9c
--- /dev/null
@@ -0,0 +1,109 @@
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.exec.Executor;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.runtime.tasks.SystemCall;
+
+/** Releases the content of staging to a public repository. */
+public class ReleaseStaging implements Runnable {
+       private final static Log log = LogFactory.getLog(ReleaseStaging.class);
+
+       private RpmFactory rpmFactory;
+       private Executor executor;
+
+       private String debuginfoDirName = "debuginfo";
+
+       @Override
+       public void run() {
+               String sourceWorkspace = rpmFactory.getStagingWorkspace();
+               File sourceRepoDir = rpmFactory.getWorkspaceDir(sourceWorkspace);
+               String targetWorkspace = rpmFactory.getTestingWorkspace() != null ? rpmFactory
+                               .getTestingWorkspace() : rpmFactory.getStableWorkspace();
+               File targetRepoDir = rpmFactory.getWorkspaceDir(targetWorkspace);
+               List<File> reposToRecreate = new ArrayList<File>();
+
+               stagingChildren: for (File dir : sourceRepoDir.listFiles()) {
+                       if (!dir.isDirectory())
+                               continue stagingChildren;
+                       if (dir.getName().equals("lost+found"))
+                               continue stagingChildren;
+
+                       File targetDir = new File(targetRepoDir, dir.getName());
+                       try {
+                               FileUtils.copyDirectory(dir, targetDir);
+                               if (log.isDebugEnabled())
+                                       log.debug(dir + " => " + targetDir);
+                       } catch (IOException e) {
+                               throw new SlcException(sourceRepoDir
+                                               + " could not be copied properly, check it manually."
+                                               + " Metadata have NOT been updated.", e);
+                       }
+
+                       reposToRecreate.add(dir);
+                       reposToRecreate.add(targetDir);
+                       File debugInfoDir = new File(dir, debuginfoDirName);
+                       if (debugInfoDir.exists())
+                               reposToRecreate.add(debugInfoDir);
+                       File targetDebugInfoDir = new File(targetDir, debuginfoDirName);
+                       if (targetDebugInfoDir.exists())
+                               reposToRecreate.add(targetDebugInfoDir);
+
+               }
+
+               // clear staging
+               for (File dir : sourceRepoDir.listFiles()) {
+                       try {
+                               if (dir.getName().equals("lost+found"))
+                                       continue;
+                               if (dir.isDirectory())
+                                       FileUtils.deleteDirectory(dir);
+                       } catch (IOException e) {
+                               log.error("Could not delete " + dir + ". " + e);
+                       }
+               }
+
+               // recreate changed repos
+               for (File repoToRecreate : reposToRecreate) {
+                       repoToRecreate.mkdirs();
+                       SystemCall createrepo = new SystemCall();
+                       createrepo.arg("createrepo");
+                       // sqllite db
+                       createrepo.arg("-d");
+                       // debuginfo
+                       if (!repoToRecreate.getName().equals(debuginfoDirName))
+                               createrepo.arg("-x").arg(debuginfoDirName + "/*");
+                       // quiet
+                       createrepo.arg("-q");
+                       createrepo.arg(repoToRecreate.getAbsolutePath());
+
+                       createrepo.setExecutor(executor);
+                       createrepo.run();
+                       log.info("Updated repo " + repoToRecreate);
+               }
+
+               rpmFactory.indexWorkspace(sourceWorkspace);
+               rpmFactory.indexWorkspace(targetWorkspace);
+       }
+
+       public void setRpmFactory(RpmFactory rpmFactory) {
+               this.rpmFactory = rpmFactory;
+       }
+
+       public void setExecutor(Executor executor) {
+               this.executor = executor;
+       }
+
+       public void setDebuginfoDirName(String debuginfoDirName) {
+               this.debuginfoDirName = debuginfoDirName;
+       }
+
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmDistribution.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmDistribution.java
new file mode 100644 (file)
index 0000000..0df31c6
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.slc.rpmfactory.core;
+
+import java.util.List;
+
+/** A consistent distributable set of RPM. */
+public class RpmDistribution {
+       private String id;
+       private List<String> packages;
+       private List<RpmPackageSet> excludedPackages;
+
+       public List<String> getPackages() {
+               return packages;
+       }
+
+       public void setPackages(List<String> packages) {
+               this.packages = packages;
+       }
+
+       public String getId() {
+               return id;
+       }
+
+       public void setId(String id) {
+               this.id = id;
+       }
+
+       public List<RpmPackageSet> getExcludedPackages() {
+               return excludedPackages;
+       }
+
+       public void setExcludedPackages(List<RpmPackageSet> excludedPackages) {
+               this.excludedPackages = excludedPackages;
+       }
+
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmFactoryImpl.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmFactoryImpl.java
new file mode 100644 (file)
index 0000000..5e1a627
--- /dev/null
@@ -0,0 +1,458 @@
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.NodeIndexerVisitor;
+import org.argeo.slc.repo.RpmIndexer;
+import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.rpmfactory.RpmRepository;
+import org.argeo.slc.runtime.tasks.SystemCall;
+
+/**
+ * Defines a build environment. This information is typically used by other
+ * components performing the various actions related to RPM build.
+ */
+public class RpmFactoryImpl implements RpmFactory {
+       private Log log = LogFactory.getLog(RpmFactoryImpl.class);
+
+       private Repository rpmRepository;
+       private Repository distRepository;
+
+       private String id;
+       private List<RpmRepository> repositories = new ArrayList<RpmRepository>();
+       private List<String> archs = new ArrayList<String>();
+
+       private String rpmBase = "/mnt/slc/repos/rpm";
+       private String distBase = "/mnt/slc/repos/dist";
+       private String mockVar = "/var/lib/mock";
+       private String mockEtc = "/etc/mock";
+
+       private DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmm");
+
+       private String gitWorkspace = "git";
+
+       private String localUrlBase = "http://localhost:7070/";
+       /** If not null or empty, this is a developer instance. */
+       private String gitDevBaseUrl = null;
+
+       private Boolean withTestingRepository = false;
+
+       private String yumConfigMainSection = "cachedir=/var/cache/yum\n"
+                       + "debuglevel=1\n" + "reposdir=/dev/null\n"
+                       + "logfile=/var/log/yum.log\n" + "retries=20\n" + "obsoletes=1\n"
+                       + "gpgcheck=0\n" + "assumeyes=1\n" + "syslog_ident=mock\n"
+                       + "syslog_device=\n" + "http_caching=none\n";
+
+       private String defaultMacroFiles = "/usr/lib/rpm/macros:"
+                       + "/usr/lib/rpm/ia32e-linux/macros:"
+                       + "/usr/lib/rpm/redhat/macros:" + "/etc/rpm/macros.*:"
+                       + "/etc/rpm/macros:" + "/etc/rpm/ia32e-linux/macros:"
+                       + "~/.rpmmacros";
+       private Map<String, String> rpmmacros = new HashMap<String, String>();
+
+       // set by init
+       private String proxiedReposBase;
+       private String managedReposBase;
+
+       private String stagingWorkspace;
+       private String testingWorkspace;
+       private String stableWorkspace;
+
+       private File rpmFactoryBaseDir;
+       private File mockConfDir;
+       private File yumConfDir;
+
+       public void init() {
+               // local URL bases
+               proxiedReposBase = localUrlBase + "repo/rpm/";
+               managedReposBase = localUrlBase + "data/public/rpm/";
+
+               // local directories
+               rpmFactoryBaseDir.mkdirs();
+               mockConfDir = new File(rpmFactoryBaseDir.getPath() + "/conf/mock");
+               mockConfDir.mkdirs();
+               yumConfDir = new File(rpmFactoryBaseDir.getPath() + "/conf/yum");
+               yumConfDir.mkdirs();
+
+               // managed repositories
+               stagingWorkspace = id + "-staging";
+               if (withTestingRepository)
+                       testingWorkspace = id + "-testing";
+               stableWorkspace = id;
+
+               initDistWorkspace(stableWorkspace);
+               initGitWorkspace();
+               initRpmWorkspace(stagingWorkspace);
+               if (withTestingRepository)
+                       initRpmWorkspace(testingWorkspace);
+               initRpmWorkspace(stableWorkspace);
+       }
+
+       protected void initRpmWorkspace(String workspace) {
+               Session session = null;
+               try {
+                       session = JcrUtils.loginOrCreateWorkspace(rpmRepository, workspace);
+                       JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+                                       "jcr:all");
+
+                       for (String arch : archs) {
+                               Node archFolder = JcrUtils.mkfolders(session, "/" + arch);
+                               session.save();
+                               File workspaceDir = getWorkspaceDir(workspace);
+                               try {
+                                       if (!archFolder.hasNode("repodata")) {
+                                               // touch a file in order to make sure this is properly
+                                               // mounted.
+                                               File touch = new File(workspaceDir, ".touch");
+                                               touch.createNewFile();
+                                               touch.delete();
+
+                                               SystemCall createrepo = new SystemCall();
+                                               createrepo.arg("createrepo");
+                                               createrepo.arg("-q");
+                                               File archDir = new File(workspaceDir, arch);
+                                               createrepo.arg(archDir.getAbsolutePath());
+                                               createrepo.run();
+                                       }
+                               } catch (IOException e) {
+                                       log.error(workspaceDir + " not properly mounted.", e);
+                               }
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot initialize workspace " + workspace,
+                                       e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       /** Caller must logout the underlying session. */
+       public Node newDistribution(String distributionId) {
+               Session session = null;
+               try {
+                       session = JcrUtils.loginOrCreateWorkspace(rpmRepository,
+                                       distributionId);
+                       JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+                                       "jcr:all");
+
+                       Calendar now = new GregorianCalendar();
+                       String folderName = dateFormat.format(now.getTime());
+                       return JcrUtils.mkfolders(session, "/" + folderName);
+               } catch (Exception e) {
+                       JcrUtils.logoutQuietly(session);
+                       throw new SlcException("Cannot initialize distribution workspace "
+                                       + distributionId, e);
+               }
+       }
+
+       protected void initGitWorkspace() {
+               Session session = null;
+               try {
+                       session = JcrUtils.loginOrCreateWorkspace(rpmRepository,
+                                       gitWorkspace);
+                       JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+                                       "jcr:all");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot initialize workspace "
+                                       + gitWorkspace, e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       protected void initDistWorkspace(String workspace) {
+               Session session = null;
+               try {
+                       session = JcrUtils
+                                       .loginOrCreateWorkspace(distRepository, workspace);
+                       JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot initialize workspace " + workspace,
+                                       e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       public void destroy() {
+
+       }
+
+       public String generateMockConfigFile(String arch, String branch) {
+               StringBuffer buf = new StringBuffer();
+
+               buf.append("config_opts['root'] = '" + getIdWithArch(arch) + "'\n");
+               buf.append("config_opts['target_arch'] = '" + arch + "'\n");
+               buf.append("config_opts['legal_host_arches'] = ('" + arch + "',)\n");
+               buf.append("config_opts['chroot_setup_cmd'] = 'groupinstall buildsys-build'\n");
+               // buf.append("config_opts['dist'] = 'el6'\n");
+               buf.append("config_opts['plugin_conf']['yum_cache_enable'] = False\n");
+
+               buf.append("config_opts['scm'] = False\n");
+               buf.append("config_opts['scm_opts']['method'] = 'git'\n");
+               buf.append("config_opts['scm_opts']['spec'] = 'SCM_PKG.spec'\n");
+               buf.append("config_opts['scm_opts']['ext_src_dir'] = '"
+                               + getSourcesDir().getAbsolutePath() + "'\n");
+               buf.append("config_opts['scm_opts']['git_timestamps'] = True\n");
+
+               // development
+               if (gitDevBaseUrl != null && !gitDevBaseUrl.trim().equals(""))
+                       buf.append("config_opts['scm_opts']['git_get'] = 'git clone "
+                                       + (branch != null ? "-b " + branch : "") + " "
+                                       + gitDevBaseUrl + "/SCM_PKG SCM_PKG'\n");
+               else
+                       buf.append("config_opts['scm_opts']['git_get'] = 'git clone "
+                                       + (branch != null ? "-b " + branch : "") + " "
+                                       + getGitBaseUrl() + "/SCM_PKG.git SCM_PKG'\n");
+
+               buf.append("\nconfig_opts['yum.conf'] = \"\"\"\n");
+               buf.append(generateYumConfigFile(arch)).append('\n');
+               buf.append("\"\"\"\n");
+               return buf.toString();
+       }
+
+       public String generateYumConfigFile(String arch) {
+               StringBuffer buf = new StringBuffer();
+               buf.append("[main]\n");
+               buf.append(yumConfigMainSection).append('\n');
+
+               for (RpmRepository repository : repositories) {
+                       buf.append('[').append(repository.getId()).append("]\n");
+                       buf.append("name=").append(repository.getId()).append('\n');
+                       if (repository instanceof ThirdPartyRpmRepository) {
+                               buf.append("#baseurl=").append(repository.getUrl())
+                                               .append(arch).append('/').append("\n");
+                               buf.append("baseurl=").append(proxiedReposBase)
+                                               .append(repository.getId()).append('/').append(arch)
+                                               .append('/').append("\n");
+                               if (((ThirdPartyRpmRepository) repository).getYumConf() != null)
+                                       buf.append(
+                                                       ((ThirdPartyRpmRepository) repository).getYumConf()
+                                                                       .trim()).append('\n');
+                       }
+               }
+
+               // managed repos
+               addManagedRepository(buf, stagingWorkspace, arch);
+               if (withTestingRepository)
+                       addManagedRepository(buf, testingWorkspace, arch);
+               addManagedRepository(buf, stableWorkspace, arch);
+               return buf.toString();
+       }
+
+       protected void addManagedRepository(StringBuffer buf, String workspace,
+                       String arch) {
+               buf.append('[').append(workspace).append("]\n");
+               buf.append("baseurl=").append(managedReposBase).append(workspace)
+                               .append('/').append(arch).append('/').append("\n");
+               buf.append("gpgcheck=0").append("\n");
+       }
+
+       /** Creates a mock config file. */
+       public File getMockConfigFile(String arch, String branch) {
+               File mockSiteDefaultsFile = new File(mockConfDir, "site-defaults.cfg");
+               File mockLoggingFile = new File(mockConfDir, "logging.ini");
+               File mockConfigFile = new File(mockConfDir, getIdWithArch(arch)
+                               + ".cfg");
+               try {
+                       if (!mockSiteDefaultsFile.exists())
+                               mockSiteDefaultsFile.createNewFile();
+                       if (!mockLoggingFile.exists())
+                               FileUtils.copyFile(new File(mockEtc + "/logging.ini"),
+                                               mockLoggingFile);
+
+                       FileUtils.writeStringToFile(mockConfigFile,
+                                       generateMockConfigFile(arch, branch));
+                       return mockConfigFile;
+               } catch (IOException e) {
+                       throw new SlcException("Cannot write mock config file to "
+                                       + mockConfigFile, e);
+               }
+       }
+
+       /** Creates a yum config file. */
+       public File getYumRepoFile(String arch) {
+               File yumConfigFile = new File(yumConfDir, getIdWithArch(arch) + ".repo");
+               try {
+                       FileUtils.writeStringToFile(yumConfigFile,
+                                       generateYumConfigFile(arch));
+                       return yumConfigFile;
+               } catch (IOException e) {
+                       throw new SlcException("Cannot write yum config file to "
+                                       + yumConfigFile, e);
+               }
+       }
+
+       public File getResultDir(String arch) {
+               return new File(mockVar + "/" + getIdWithArch(arch) + "/result");
+       }
+
+       public File getWorkspaceDir(String workspace) {
+               return new File(rpmBase + "/" + workspace);
+       }
+
+       public File getSourcesDir() {
+               return new File(distBase + "/" + stableWorkspace);
+       }
+
+       public String getMockConfig(String arch) {
+               return getIdWithArch(arch);
+       }
+
+       public String getIdWithArch(String arch) {
+               return id + "-" + arch;
+       }
+
+       public String getGitBaseUrl() {
+               return managedReposBase + gitWorkspace;
+       }
+
+       public void indexWorkspace(String workspace) {
+               Session session = null;
+               try {
+                       session = rpmRepository.login(workspace);
+                       session.getRootNode().accept(
+                                       new NodeIndexerVisitor(new RpmIndexer()));
+                       if (log.isDebugEnabled())
+                               log.debug("Indexed workspace " + workspace);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot index workspace " + workspace, e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       public Boolean isDeveloperInstance() {
+               return gitDevBaseUrl != null;
+       }
+
+       /** Write (topdir)/rpmmacros and (topdir)/rpmrc */
+       public void writeRpmbuildConfigFiles(File topdir) {
+               writeRpmbuildConfigFiles(topdir, new File(topdir, "rpmmacros"),
+                               new File(topdir, "rpmrc"));
+       }
+
+       public void writeRpmbuildConfigFiles(File topdir, File rpmmacroFile,
+                       File rpmrcFile) {
+               try {
+                       List<String> macroLines = new ArrayList<String>();
+                       macroLines.add("%_topdir " + topdir.getCanonicalPath());
+                       for (String macroKey : rpmmacros.keySet()) {
+                               macroLines.add(macroKey + " " + rpmmacros.get(macroKey));
+                       }
+                       FileUtils.writeLines(rpmmacroFile, macroLines);
+
+                       List<String> rpmrcLines = new ArrayList<String>();
+                       rpmrcLines.add("include: /usr/lib/rpm/rpmrc");
+                       rpmrcLines.add("macrofiles: " + defaultMacroFiles + ":"
+                                       + rpmmacroFile.getCanonicalPath());
+                       FileUtils.writeLines(rpmrcFile, rpmrcLines);
+               } catch (IOException e) {
+                       throw new SlcException("Cannot write rpmbuild config files", e);
+               }
+
+       }
+
+       public Map<String, String> getRpmmacros() {
+               return rpmmacros;
+       }
+
+       public void setRpmmacros(Map<String, String> rpmmacros) {
+               this.rpmmacros = rpmmacros;
+       }
+
+       public String getDefaultMacroFiles() {
+               return defaultMacroFiles;
+       }
+
+       public void setDefaultMacroFiles(String defaultMacroFiles) {
+               this.defaultMacroFiles = defaultMacroFiles;
+       }
+
+       public void setArchs(List<String> archs) {
+               this.archs = archs;
+       }
+
+       public List<String> getArchs() {
+               return archs;
+       }
+
+       public void setRpmBase(String stagingBase) {
+               this.rpmBase = stagingBase;
+       }
+
+       public void setId(String id) {
+               this.id = id;
+       }
+
+       public void setMockVar(String mockVar) {
+               this.mockVar = mockVar;
+       }
+
+       public void setRpmRepository(Repository rpmRepository) {
+               this.rpmRepository = rpmRepository;
+       }
+
+       public void setDistRepository(Repository distRepository) {
+               this.distRepository = distRepository;
+       }
+
+       public void setLocalUrlBase(String localUrlBase) {
+               this.localUrlBase = localUrlBase;
+       }
+
+       public void setYumConfigMainSection(String yumConfigMainSection) {
+               this.yumConfigMainSection = yumConfigMainSection;
+       }
+
+       public void setRepositories(List<RpmRepository> repositories) {
+               this.repositories = repositories;
+       }
+
+       public void setRpmFactoryBaseDir(File rpmFactoryBaseDir) {
+               this.rpmFactoryBaseDir = rpmFactoryBaseDir;
+       }
+
+       public String getStagingWorkspace() {
+               return stagingWorkspace;
+       }
+
+       public String getTestingWorkspace() {
+               return testingWorkspace;
+       }
+
+       public String getStableWorkspace() {
+               return stableWorkspace;
+       }
+
+       public void setWithTestingRepository(Boolean withTestingRepository) {
+               this.withTestingRepository = withTestingRepository;
+       }
+
+       public void setGitDevBaseUrl(String gitBaseUrl) {
+               this.gitDevBaseUrl = gitBaseUrl;
+       }
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmPackageSet.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmPackageSet.java
new file mode 100644 (file)
index 0000000..1693413
--- /dev/null
@@ -0,0 +1,6 @@
+package org.argeo.slc.rpmfactory.core;
+
+/** Set of RPM packages */
+public interface RpmPackageSet {
+       public Boolean contains(String rpmPackage);
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java
new file mode 100644 (file)
index 0000000..d067dfa
--- /dev/null
@@ -0,0 +1,142 @@
+package org.argeo.slc.rpmfactory.core;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.security.AccessControlException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.ArgeoNames;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.proxy.AbstractUrlProxy;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.rpmfactory.RpmProxyService;
+import org.argeo.slc.rpmfactory.RpmRepository;
+
+/** Synchronises the node repository with remote Maven repositories */
+public class RpmProxyServiceImpl extends AbstractUrlProxy implements
+               RpmProxyService, ArgeoNames, SlcNames {
+       private final static Log log = LogFactory.getLog(RpmProxyServiceImpl.class);
+
+       private Set<RpmRepository> defaultRepositories = new HashSet<RpmRepository>();
+
+       @Override
+       protected void beforeInitSessionSave(Session session)
+                       throws RepositoryException {
+               JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+               try {
+                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+                                       "jcr:all");
+               } catch (AccessControlException e) {
+                       if (log.isTraceEnabled())
+                               log.trace("Cannot give jcr:all privileges to "+SlcConstants.ROLE_SLC);
+               }
+
+               JcrUtils.mkdirsSafe(session, RepoConstants.PROXIED_REPOSITORIES);
+       }
+
+       /**
+        * Retrieve and add this file to the repository
+        */
+       @Override
+       protected Node retrieve(Session session, String path) {
+               StringBuilder relativePathBuilder = new StringBuilder();
+               String repoId = extractRepoId(path, relativePathBuilder);
+               // remove starting '/'
+               String relativePath = relativePathBuilder.toString().substring(1);
+
+               RpmRepository sourceRepo = null;
+               for (Iterator<RpmRepository> reposIt = defaultRepositories.iterator(); reposIt
+                               .hasNext();) {
+                       RpmRepository rpmRepo = reposIt.next();
+                       if (rpmRepo.getId().equals(repoId)) {
+                               sourceRepo = rpmRepo;
+                               break;
+                       }
+               }
+
+               if (sourceRepo == null)
+                       throw new SlcException("No RPM repository found for " + path);
+
+               try {
+                       String baseUrl = sourceRepo.getUrl();
+                       String remoteUrl = baseUrl + relativePath;
+                       Node node = proxyUrl(session, remoteUrl, path);
+                       if (node != null) {
+                               registerSource(sourceRepo, node, remoteUrl);
+                               if (log.isDebugEnabled())
+                                       log.debug("Imported " + remoteUrl + " to " + node);
+                               return node;
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot proxy " + path, e);
+               }
+               JcrUtils.discardQuietly(session);
+               throw new SlcException("No proxy found for " + path);
+       }
+
+       protected void registerSource(RpmRepository sourceRepo, Node node,
+                       String remoteUrl) throws RepositoryException {
+               node.addMixin(SlcTypes.SLC_KNOWN_ORIGIN);
+               Node origin;
+               if (!node.hasNode(SLC_ORIGIN))
+                       origin = node.addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
+               else
+                       origin = node.getNode(SLC_ORIGIN);
+
+               // proxied repository
+               Node proxiedRepository;
+               String proxiedRepositoryPath = RepoConstants.PROXIED_REPOSITORIES + '/'
+                               + sourceRepo.getId();
+               Session session = node.getSession();
+               if (session.itemExists(proxiedRepositoryPath)) {
+                       proxiedRepository = session.getNode(proxiedRepositoryPath);
+               } else {
+                       proxiedRepository = session.getNode(
+                                       RepoConstants.PROXIED_REPOSITORIES).addNode(
+                                       sourceRepo.getId());
+                       proxiedRepository.addMixin(NodeType.MIX_REFERENCEABLE);
+                       JcrUtils.urlToAddressProperties(proxiedRepository,
+                                       sourceRepo.getUrl());
+                       proxiedRepository.setProperty(SLC_URL, sourceRepo.getUrl());
+               }
+
+               origin.setProperty(SLC_PROXY, proxiedRepository);
+               JcrUtils.urlToAddressProperties(origin, remoteUrl);
+       }
+
+       /** Returns the first token of the path */
+       protected String extractRepoId(String path, StringBuilder relativePath) {
+               StringBuilder workspace = new StringBuilder();
+               StringBuilder buf = workspace;
+               for (int i = 1; i < path.length(); i++) {
+                       char c = path.charAt(i);
+                       if (c == '/') {
+                               buf = relativePath;
+                       }
+                       buf.append(c);
+               }
+               return workspace.toString();
+       }
+
+       @Override
+       protected Boolean shouldUpdate(Session clientSession, String nodePath) {
+               // if (nodePath.contains("/repodata/"))
+               // return true;
+               return super.shouldUpdate(clientSession, nodePath);
+       }
+
+       public void setDefaultRepositories(Set<RpmRepository> defaultRepositories) {
+               this.defaultRepositories = defaultRepositories;
+       }
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmSpecFile.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmSpecFile.java
new file mode 100644 (file)
index 0000000..c9132f9
--- /dev/null
@@ -0,0 +1,110 @@
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class RpmSpecFile {
+       private Path specFile;
+
+       private String name;
+       private String version;
+       private String release;
+       private Map<String, String> sources = new HashMap<String, String>();
+       private Map<String, String> patches = new HashMap<String, String>();
+
+       public RpmSpecFile(Path specFile) {
+               this.specFile = specFile;
+               parseSpecFile();
+       }
+
+       public void init() {
+               parseSpecFile();
+       }
+
+       protected void parseSpecFile() {
+               try {
+                       List<String> lines = (List<String>) Files.readAllLines(specFile);
+
+                       lines: for (String line : lines) {
+                               int indexSemiColon = line.indexOf(':');
+                               if (indexSemiColon <= 0)
+                                       continue lines;
+                               String directive = line.substring(0, indexSemiColon).trim();
+                               String value = line.substring(indexSemiColon + 1).trim();
+                               if ("name".equals(directive.toLowerCase()))
+                                       name = value;
+                               else if ("version".equals(directive.toLowerCase()))
+                                       version = value;
+                               else if ("release".equals(directive.toLowerCase()))
+                                       release = value;
+                               else if (directive.toLowerCase().startsWith("source"))
+                                       sources.put(directive, interpret(value));
+                               else if (directive.toLowerCase().startsWith("patch"))
+                                       patches.put(directive, interpret(value));
+                       }
+
+               } catch (IOException e) {
+                       throw new RuntimeException("Cannot parse spec file " + specFile, e);
+               }
+       }
+
+       protected String interpret(String value) {
+               StringBuffer buf = new StringBuffer(value.length());
+               StringBuffer currKey = null;
+               boolean mayBeKey = false;
+               chars: for (char c : value.toCharArray()) {
+                       if (c == '%')
+                               mayBeKey = true;
+                       else if (c == '{') {
+                               if (mayBeKey)
+                                       currKey = new StringBuffer();
+                       } else if (c == '}') {
+                               if (currKey == null)
+                                       continue chars;
+                               String key = currKey.toString();
+                               if ("name".equals(key.toLowerCase()))
+                                       buf.append(name);
+                               else if ("version".equals(key.toLowerCase()))
+                                       buf.append(version);
+                               else
+                                       buf.append("%{").append(key).append('}');
+                               currKey = null;
+                       } else {
+                               if (currKey != null)
+                                       currKey.append(c);
+                               else
+                                       buf.append(c);
+                       }
+               }
+               return buf.toString();
+       }
+
+       public Path getSpecFile() {
+               return specFile;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public String getVersion() {
+               return version;
+       }
+
+       public String getRelease() {
+               return release;
+       }
+
+       public Map<String, String> getSources() {
+               return sources;
+       }
+
+       public Map<String, String> getPatches() {
+               return patches;
+       }
+
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/StagingRpmRepository.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/StagingRpmRepository.java
new file mode 100644 (file)
index 0000000..58977f4
--- /dev/null
@@ -0,0 +1,6 @@
+package org.argeo.slc.rpmfactory.core;
+
+/** Local build repository, used only for builds. */
+public class StagingRpmRepository extends AbstractRpmRepository {
+
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ThirdPartyRpmRepository.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/ThirdPartyRpmRepository.java
new file mode 100644 (file)
index 0000000..2902530
--- /dev/null
@@ -0,0 +1,18 @@
+package org.argeo.slc.rpmfactory.core;
+
+/**
+ * A repository of third party RPMs used for the build. RPM used by the builds
+ * will be cached within the system.
+ */
+public class ThirdPartyRpmRepository extends AbstractRpmRepository {
+       private String yumConf;
+
+       public String getYumConf() {
+               return yumConf;
+       }
+
+       public void setYumConf(String yumConf) {
+               this.yumConf = yumConf;
+       }
+
+}
diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/YumListParser.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/YumListParser.java
new file mode 100644 (file)
index 0000000..ee89aa3
--- /dev/null
@@ -0,0 +1,94 @@
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.LineIterator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+
+/**
+ * Reads the output of a 'yum list all' command and interpret the list of
+ * packages.
+ */
+public class YumListParser implements RpmPackageSet {
+       private final static Log log = LogFactory.getLog(YumListParser.class);
+
+       private Set<String> installed = new TreeSet<String>();
+       /** Not installed but available */
+       private Set<String> installable = new TreeSet<String>();
+
+       private Path yumListOutput;
+
+       public void init() {
+               if (yumListOutput != null) {
+                       try (InputStream in = Files.newInputStream(yumListOutput)) {
+                               load(in);
+                               if (log.isDebugEnabled())
+                                       log.debug(installed.size() + " installed, " + installable.size() + " installable, from "
+                                                       + yumListOutput);
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot initialize yum list parser", e);
+                       }
+               }
+       }
+
+       public Boolean contains(String packageName) {
+               if (installed.contains(packageName))
+                       return true;
+               else
+                       return installable.contains(packageName);
+       }
+
+       protected void load(InputStream in) throws IOException {
+               Boolean readingInstalled = false;
+               Boolean readingAvailable = false;
+               LineIterator it = IOUtils.lineIterator(in, "UTF-8");
+               while (it.hasNext()) {
+                       String line = it.nextLine();
+                       if (line.trim().equals("Installed Packages")) {
+                               readingInstalled = true;
+                       } else if (line.trim().equals("Available Packages")) {
+                               readingAvailable = true;
+                               readingInstalled = false;
+                       } else if (readingAvailable) {
+                               if (Character.isLetterOrDigit(line.charAt(0))) {
+                                       installable.add(extractRpmName(line));
+                               }
+                       } else if (readingInstalled) {
+                               if (Character.isLetterOrDigit(line.charAt(0))) {
+                                       installed.add(extractRpmName(line));
+                               }
+                       }
+               }
+       }
+
+       protected String extractRpmName(String line) {
+               StringTokenizer st = new StringTokenizer(line, " \t");
+               String packageName = st.nextToken();
+               // consider the arch as an extension
+               return FilenameUtils.getBaseName(packageName);
+               // return packageName.split("\\.")[0];
+       }
+
+       public Set<String> getInstalled() {
+               return installed;
+       }
+
+       public Set<String> getInstallable() {
+               return installable;
+       }
+
+       public void setYumListOutput(Path yumListOutput) {
+               this.yumListOutput = yumListOutput;
+       }
+
+}
diff --git a/org.argeo.slc.jcr/.classpath b/org.argeo.slc.jcr/.classpath
new file mode 100644 (file)
index 0000000..e801ebf
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.argeo.slc.jcr/.gitignore b/org.argeo.slc.jcr/.gitignore
new file mode 100644 (file)
index 0000000..09e3bc9
--- /dev/null
@@ -0,0 +1,2 @@
+/bin/
+/target/
diff --git a/org.argeo.slc.jcr/.project b/org.argeo.slc.jcr/.project
new file mode 100644 (file)
index 0000000..a4cd874
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.jcr</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/org.argeo.slc.jcr/META-INF/.gitignore b/org.argeo.slc.jcr/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/org.argeo.slc.jcr/bnd.bnd b/org.argeo.slc.jcr/bnd.bnd
new file mode 100644 (file)
index 0000000..28c2b84
--- /dev/null
@@ -0,0 +1,3 @@
+Import-Package: javax.jcr.nodetype,\
+javax.jcr.security,\
+*
\ No newline at end of file
diff --git a/org.argeo.slc.jcr/build.properties b/org.argeo.slc.jcr/build.properties
new file mode 100644 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/org.argeo.slc.jcr/pom.xml b/org.argeo.slc.jcr/pom.xml
new file mode 100644 (file)
index 0000000..0212f04
--- /dev/null
@@ -0,0 +1,47 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.jcr</artifactId>
+       <name>SLC JCR implementations</name>
+       <dependencies>
+               <!-- SLC -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.api</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.runtime</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.enterprise</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.api</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.cms</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.jcr</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrMetadataWriter.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrMetadataWriter.java
new file mode 100644 (file)
index 0000000..e2d1b10
--- /dev/null
@@ -0,0 +1,65 @@
+package org.argeo.slc.jcr;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+
+/**
+ * Writes arbitrary metadata into a child node of a given node (or the node
+ * itself if metadata node name is set to null)
+ */
+public class JcrMetadataWriter implements Runnable {
+       private final static Log log = LogFactory.getLog(JcrMetadataWriter.class);
+
+       private Node baseNode;
+       private String metadataNodeName = SlcNames.SLC_METADATA;
+
+       private Map<String, String> metadata = new HashMap<String, String>();
+
+       public void run() {
+               try {
+                       Node metadataNode;
+                       if (metadataNodeName != null)
+                               metadataNode = baseNode.hasNode(metadataNodeName) ? baseNode
+                                               .getNode(metadataNodeName) : baseNode
+                                               .addNode(metadataNodeName);
+                       else
+                               metadataNode = baseNode;
+
+                       for (String key : metadata.keySet())
+                               metadataNode.setProperty(key, metadata.get(key));
+
+                       baseNode.getSession().save();
+
+                       if (log.isDebugEnabled())
+                               log.debug("Wrote " + metadata.size() + " metadata entries to "
+                                               + metadataNode);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot write metadata to " + baseNode, e);
+               } finally {
+                       JcrUtils.discardUnderlyingSessionQuietly(baseNode);
+               }
+
+       }
+
+       public void setBaseNode(Node baseNode) {
+               this.baseNode = baseNode;
+       }
+
+       public void setMetadataNodeName(String metadataNodeName) {
+               this.metadataNodeName = metadataNodeName;
+       }
+
+       public void setMetadata(Map<String, String> metadata) {
+               this.metadata = metadata;
+       }
+
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrTestResult.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/JcrTestResult.java
new file mode 100644 (file)
index 0000000..e2d0607
--- /dev/null
@@ -0,0 +1,276 @@
+package org.argeo.slc.jcr;
+
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.attachment.Attachment;
+import org.argeo.slc.attachment.AttachmentsEnabled;
+import org.argeo.slc.test.TestResult;
+import org.argeo.slc.test.TestResultPart;
+import org.argeo.slc.test.TestRun;
+import org.argeo.slc.test.TestStatus;
+
+/**
+ * {@link TestResult} wrapping a JCR node of type
+ * {@link SlcTypes#SLC_TEST_RESULT}.
+ */
+public class JcrTestResult implements TestResult, SlcNames, AttachmentsEnabled {
+       private final static Log log = LogFactory.getLog(JcrTestResult.class);
+
+       /** Should only be set for an already existing result. */
+       private String uuid;
+       private Repository repository;
+       private Session session;
+       /**
+        * For testing purposes, best practice is to not set them explicitely but
+        * via other mechanisms such as JAAS or SPring Security.
+        */
+       private Credentials credentials = null;
+       private String resultType = SlcTypes.SLC_TEST_RESULT;
+
+       /** cached for performance purposes */
+       private String nodeIdentifier = null;
+
+       private Map<String, String> attributes = new HashMap<String, String>();
+
+       public void init() {
+               try {
+                       session = repository.login(credentials);
+                       if (uuid == null) {
+                               // create new result
+                               uuid = UUID.randomUUID().toString();
+                               String path = SlcJcrUtils.createResultPath(session, uuid);
+                               Node resultNode = JcrUtils.mkdirs(session, path, resultType);
+                               resultNode.setProperty(SLC_UUID, uuid);
+                               for (String attr : attributes.keySet()) {
+                                       String property = attr;
+                                       // compatibility with legacy applications
+                                       if ("testCase".equals(attr))
+                                               property = SLC_TEST_CASE;
+                                       else if ("testCaseType".equals(attr))
+                                               property = SLC_TEST_CASE_TYPE;
+                                       resultNode.setProperty(property, attributes.get(attr));
+                               }
+                               session.save();
+                               if (log.isDebugEnabled())
+                                       log.debug("Created test result " + uuid);
+                       }
+               } catch (Exception e) {
+                       JcrUtils.discardQuietly(session);
+                       throw new SlcException("Cannot initialize JCR result", e);
+               }
+       }
+
+       public void destroy() {
+               JcrUtils.logoutQuietly(session);
+               if (log.isTraceEnabled())
+                       log.trace("Logged out session for result " + uuid);
+       }
+
+       public Node getNode() {
+               try {
+                       Node resultNode;
+                       if (nodeIdentifier != null) {
+                               return session.getNodeByIdentifier(nodeIdentifier);
+                       } else {
+                               QueryManager qm = session.getWorkspace().getQueryManager();
+                               Query q = qm.createQuery("select * from ["
+                                               + SlcTypes.SLC_TEST_RESULT + "] where [slc:uuid]='"
+                                               + uuid + "'", Query.JCR_SQL2);
+                               resultNode = JcrUtils.querySingleNode(q);
+                               if (resultNode != null)
+                                       nodeIdentifier = resultNode.getIdentifier();
+                       }
+                       return resultNode;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot get result node", e);
+               }
+       }
+
+       public void notifyTestRun(TestRun testRun) {
+               // TODO store meta data about the test running
+               // if (log.isDebugEnabled())
+               // log.debug("Running test "
+               // + testRun.getTestDefinition().getClass().getName() + "...");
+       }
+
+       public void addResultPart(TestResultPart testResultPart) {
+               Node node = getNode();
+
+               try {
+                       // error : revert all unsaved changes on the resultNode to be sure
+                       // it is in a consistant state
+                       if (testResultPart.getExceptionMessage() != null)
+                               JcrUtils.discardQuietly(node.getSession());
+                       node.getSession().save();
+
+                       // add the new result part, retrieving status information
+                       Node resultPartNode = node.addNode(SlcNames.SLC_RESULT_PART,
+                                       SlcTypes.SLC_CHECK);
+                       resultPartNode.setProperty(SLC_SUCCESS, testResultPart.getStatus()
+                                       .equals(TestStatus.PASSED));
+                       if (testResultPart.getMessage() != null)
+                               resultPartNode.setProperty(SLC_MESSAGE,
+                                               testResultPart.getMessage());
+                       if (testResultPart.getStatus().equals(TestStatus.ERROR)) {
+                               resultPartNode.setProperty(SLC_ERROR_MESSAGE,
+                                               (testResultPart.getExceptionMessage() == null) ? ""
+                                                               : testResultPart.getExceptionMessage());
+                       }
+
+                       // helper update aggregate status node
+                       Node mainStatus;
+                       if (!node.hasNode(SLC_AGGREGATED_STATUS)) {
+
+                               mainStatus = node.addNode(SLC_AGGREGATED_STATUS,
+                                               SlcTypes.SLC_CHECK);
+                               mainStatus.setProperty(SLC_SUCCESS,
+                                               resultPartNode.getProperty(SLC_SUCCESS).getBoolean());
+                               if (resultPartNode.hasProperty(SLC_MESSAGE))
+                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_MESSAGE).getString());
+                               if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE))
+                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
+                       } else {
+                               mainStatus = node.getNode(SLC_AGGREGATED_STATUS);
+                               if (mainStatus.hasProperty(SLC_ERROR_MESSAGE)) {
+                                       // main status already in error we do nothing
+                               } else if (resultPartNode.hasProperty(SLC_ERROR_MESSAGE)) {
+                                       // main status was not in error and new result part is in
+                                       // error; we update main status
+                                       mainStatus.setProperty(SLC_SUCCESS, false);
+                                       mainStatus.setProperty(SLC_ERROR_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_ERROR_MESSAGE).getString());
+                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
+                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                               .getProperty(SLC_MESSAGE).getString());
+                                       else
+                                               // remove old message to remain consistent
+                                               mainStatus.setProperty(SLC_MESSAGE, "");
+                               } else if (!mainStatus.getProperty(SLC_SUCCESS).getBoolean()) {
+                                       // main status was already failed and new result part is not
+                                       // in error, we do nothing
+                               } else if (!resultPartNode.getProperty(SLC_SUCCESS)
+                                               .getBoolean()) {
+                                       // new resultPart that is failed
+                                       mainStatus.setProperty(SLC_SUCCESS, false);
+                                       if (resultPartNode.hasProperty(SLC_MESSAGE))
+                                               mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                               .getProperty(SLC_MESSAGE).getString());
+                                       else
+                                               // remove old message to remain consistent
+                                               mainStatus.setProperty(SLC_MESSAGE, "");
+                               } else if (resultPartNode.hasProperty(SLC_MESSAGE)
+                                               && (!mainStatus.hasProperty(SLC_MESSAGE) || (""
+                                                               .equals(mainStatus.getProperty(SLC_MESSAGE)
+                                                                               .getString().trim())))) {
+                                       mainStatus.setProperty(SLC_MESSAGE, resultPartNode
+                                                       .getProperty(SLC_MESSAGE).getString());
+                               }
+                       }
+                       JcrUtils.updateLastModified(node);
+                       node.getSession().save();
+               } catch (Exception e) {
+                       JcrUtils.discardUnderlyingSessionQuietly(node);
+                       throw new SlcException("Cannot add ResultPart to node " + node, e);
+               }
+       }
+
+       public String getUuid() {
+               Node node = getNode();
+               try {
+                       return node.getProperty(SLC_UUID).getString();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot get UUID from " + node, e);
+               }
+       }
+
+       /** JCR session is NOT logged out */
+       public void close() {
+               Node node = getNode();
+               try {
+                       if (node.hasNode(SLC_COMPLETED))
+                               return;
+                       node.setProperty(SLC_COMPLETED, new GregorianCalendar());
+                       JcrUtils.updateLastModified(node);
+                       node.getSession().save();
+               } catch (Exception e) {
+                       JcrUtils.discardUnderlyingSessionQuietly(node);
+                       throw new SlcException("Cannot get close date from " + node, e);
+               }
+       }
+
+       public Date getCloseDate() {
+               Node node = getNode();
+               try {
+                       if (!node.hasNode(SLC_COMPLETED))
+                               return null;
+                       return node.getProperty(SLC_COMPLETED).getDate().getTime();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot get close date from " + node, e);
+               }
+       }
+
+       public Map<String, String> getAttributes() {
+               Node node = getNode();
+               try {
+                       Map<String, String> map = new HashMap<String, String>();
+                       PropertyIterator pit = node.getProperties();
+                       while (pit.hasNext()) {
+                               Property p = pit.nextProperty();
+                               if (!p.isMultiple())
+                                       map.put(p.getName(), p.getValue().getString());
+                       }
+                       return map;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot get close date from " + node, e);
+               }
+       }
+
+       public void addAttachment(Attachment attachment) {
+               // TODO implement it
+       }
+
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setResultType(String resultType) {
+               this.resultType = resultType;
+       }
+
+       public void setAttributes(Map<String, String> attributes) {
+               if (uuid != null)
+                       throw new SlcException(
+                                       "Attributes cannot be set on an already initialized test result."
+                                                       + " Update the related JCR node directly instead.");
+               this.attributes = attributes;
+       }
+
+       public void setCredentials(Credentials credentials) {
+               this.credentials = credentials;
+       }
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrConstants.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrConstants.java
new file mode 100644 (file)
index 0000000..19e6430
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.jcr;
+
+import org.argeo.slc.SlcNames;
+
+/** JCR related constants used across SLC */
+public interface SlcJcrConstants {
+       public final static String PROPERTY_PATH = "argeo.slc.jcr.path";
+
+       public final static String SLC_BASE_PATH = "/" + SlcNames.SLC_SYSTEM;
+       public final static String AGENTS_BASE_PATH = SLC_BASE_PATH + "/"
+                       + SlcNames.SLC_AGENTS;
+       public final static String VM_AGENT_FACTORY_PATH = AGENTS_BASE_PATH + "/"
+                       + SlcNames.SLC_VM;
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrResultUtils.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrResultUtils.java
new file mode 100644 (file)
index 0000000..c7717db
--- /dev/null
@@ -0,0 +1,153 @@
+package org.argeo.slc.jcr;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.api.NodeUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+
+/**
+ * Utilities around the SLC JCR Result model. Note that it relies on fixed base
+ * paths (convention over configuration) for optimization purposes.
+ */
+public class SlcJcrResultUtils {
+
+       /**
+        * Returns the path to the current slc:result node
+        */
+       public static String getSlcResultsBasePath(Session session) {
+               try {
+                       Node userHome = NodeUtils.getUserHome(session);
+                       if (userHome == null)
+                               throw new SlcException("No user home available for "
+                                               + session.getUserID());
+                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
+                                       + SlcNames.SLC_RESULTS;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while getting Slc Results Base Path.", re);
+               }
+       }
+
+       /**
+        * Returns the base node to store SlcResults. If it does not exists, it is
+        * created. If a node already exists at the given path with the wrong type,
+        * it throws an exception.
+        * 
+        * @param session
+        * @return
+        */
+       public static Node getSlcResultsParentNode(Session session) {
+               try {
+                       String absPath = getSlcResultsBasePath(session);
+                       if (session.nodeExists(absPath)) {
+                               Node currNode = session.getNode(absPath);
+                               if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
+                                       return currNode;
+                               else
+                                       throw new SlcException(
+                                                       "A node already exists at this path : " + absPath
+                                                                       + " that has the wrong type. ");
+                       } else {
+                               Node slcResParNode = JcrUtils.mkdirs(session, absPath);
+                               slcResParNode.setPrimaryType(NodeType.NT_UNSTRUCTURED);
+                               session.save();
+                               return slcResParNode;
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while creating slcResult root parent node.",
+                                       re);
+               }
+       }
+
+       /**
+        * Returns the path to the current Result UI specific node, depending the
+        * current user
+        */
+       public static String getMyResultsBasePath(Session session) {
+               try {
+                       Node userHome = NodeUtils.getUserHome(session);
+                       if (userHome == null)
+                               throw new SlcException("No user home available for "
+                                               + session.getUserID());
+                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
+                                       + SlcNames.SLC_MY_RESULTS;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while getting Slc Results Base Path.", re);
+               }
+       }
+
+       /**
+        * Creates a new node with type SlcTypes.SLC_MY_RESULT_ROOT_FOLDER at the
+        * given absolute path. If a node already exists at the given path, returns
+        * that node if it has the correct type and throws an exception otherwise.
+        * 
+        * @param session
+        * @return
+        */
+       public static Node getMyResultParentNode(Session session) {
+               try {
+                       String absPath = getMyResultsBasePath(session);
+                       if (session.nodeExists(absPath)) {
+                               Node currNode = session.getNode(absPath);
+                               if (currNode.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
+                                       return currNode;
+                               else
+                                       throw new SlcException(
+                                                       "A node already exists at this path : " + absPath
+                                                                       + " that has the wrong type. ");
+                       } else {
+                               Node myResParNode = JcrUtils.mkdirs(session, absPath);
+                               myResParNode.setPrimaryType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER);
+                               session.save();
+                               return myResParNode;
+                       }
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while creating user MyResult base node.",
+                                       re);
+               }
+       }
+
+       /**
+        * Creates a new node with type SlcTypes.SLC_RESULT_FOLDER at the given
+        * absolute path. If a node already exists at the given path, returns that
+        * node if it has the correct type and throws an exception otherwise.
+        * 
+        * @param session
+        * @param absPath
+        * @return
+        */
+       public static synchronized Node createResultFolderNode(Session session,
+                       String absPath) {
+               try {
+                       if (session.nodeExists(absPath)) {
+                               // Sanity check
+                               Node currNode = session.getNode(absPath);
+                               if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER))
+                                       return currNode;
+                               else
+                                       throw new SlcException(
+                                                       "A node already exists at this path : " + absPath
+                                                                       + " that has the wrong type. ");
+                       }
+                       Node rfNode = JcrUtils.mkdirs(session, absPath);
+                       rfNode.setPrimaryType(SlcTypes.SLC_RESULT_FOLDER);
+                       Node statusNode = rfNode.addNode(SlcNames.SLC_AGGREGATED_STATUS,
+                                       SlcTypes.SLC_CHECK);
+                       statusNode.setProperty(SlcNames.SLC_SUCCESS, true);
+                       session.save();
+                       return rfNode;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while creating Result Folder node.", re);
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrUtils.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/SlcJcrUtils.java
new file mode 100644 (file)
index 0000000..c91a94c
--- /dev/null
@@ -0,0 +1,253 @@
+package org.argeo.slc.jcr;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.argeo.api.NodeUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.deploy.ModuleDescriptor;
+import org.argeo.slc.primitive.PrimitiveAccessor;
+import org.argeo.slc.primitive.PrimitiveUtils;
+import org.argeo.slc.test.TestStatus;
+
+/**
+ * Utilities around the SLC JCR model. Note that it relies on fixed base paths
+ * (convention over configuration) for optimization purposes.
+ */
+public class SlcJcrUtils implements SlcNames {
+       public final static Integer AGENT_FACTORY_DEPTH = 3;
+
+       /** Extracts the path of a flow relative to its execution module */
+       public static String flowRelativePath(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               StringBuffer buf = new StringBuffer(fullFlowPath.length());
+               for (int i = AGENT_FACTORY_DEPTH + 3; i < tokens.length; i++) {
+                       buf.append('/').append(tokens[i]);
+               }
+               return buf.toString();
+       }
+
+       /** Extracts the path to the related execution module */
+       public static String modulePath(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               StringBuffer buf = new StringBuffer(fullFlowPath.length());
+               for (int i = 0; i < AGENT_FACTORY_DEPTH + 3; i++) {
+                       if (!tokens[i].equals(""))
+                               buf.append('/').append(tokens[i]);
+               }
+               return buf.toString();
+       }
+
+       /** Extracts the module name from a flow path */
+       public static String moduleName(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               String moduleName = tokens[AGENT_FACTORY_DEPTH + 2];
+               moduleName = moduleName.substring(0, moduleName.indexOf('_'));
+               return moduleName;
+       }
+
+       /** Extracts the module name and version from a flow path */
+       public static NameVersion moduleNameVersion(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               String module = tokens[AGENT_FACTORY_DEPTH + 2];
+               String moduleName = module.substring(0, module.indexOf('_'));
+               String moduleVersion = module.substring(module.indexOf('_') + 1);
+               return new DefaultNameVersion(moduleName, moduleVersion);
+       }
+
+       /** Module node name based on module name and version */
+       public static String getModuleNodeName(ModuleDescriptor moduleDescriptor) {
+               return moduleDescriptor.getName() + "_" + moduleDescriptor.getVersion();
+       }
+
+       /** Extracts the agent factory of a flow */
+       public static String flowAgentFactoryPath(String fullFlowPath) {
+               String[] tokens = fullFlowPath.split("/");
+               StringBuffer buf = new StringBuffer(fullFlowPath.length());
+               // first token is always empty
+               for (int i = 1; i < AGENT_FACTORY_DEPTH + 1; i++) {
+                       buf.append('/').append(tokens[i]);
+               }
+               return buf.toString();
+       }
+
+       /** Create a new execution process path based on the current time */
+       public static String createExecutionProcessPath(Session session, String uuid) {
+               Calendar now = new GregorianCalendar();
+               return getSlcProcessesBasePath(session) + '/'
+                               + JcrUtils.dateAsPath(now, true) + uuid;
+       }
+
+       /** Get the base for the user processi. */
+       public static String getSlcProcessesBasePath(Session session) {
+               try {
+                       Node userHome = NodeUtils.getUserHome(session);
+                       if (userHome == null)
+                               throw new SlcException("No user home available for "
+                                               + session.getUserID());
+                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
+                                       + SlcNames.SLC_PROCESSES;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while getting Slc Results Base Path.", re);
+               }
+       }
+
+       /**
+        * Create a new execution result path in the user home based on the current
+        * time
+        */
+       public static String createResultPath(Session session, String uuid)
+                       throws RepositoryException {
+               Calendar now = new GregorianCalendar();
+               StringBuffer absPath = new StringBuffer(
+                               SlcJcrResultUtils.getSlcResultsBasePath(session) + '/');
+               // Remove hours and add title property to the result process path on
+               // request of O. Capillon
+               // return getSlcProcessesBasePath(session) + '/'
+               // + JcrUtils.dateAsPath(now, true) + uuid;
+               String relPath = JcrUtils.dateAsPath(now, false);
+               List<String> names = JcrUtils.tokenize(relPath);
+               for (String name : names) {
+                       absPath.append(name + "/");
+                       Node node = JcrUtils.mkdirs(session, absPath.toString());
+                       try {
+                               node.addMixin(NodeType.MIX_TITLE);
+                               node.setProperty(Property.JCR_TITLE, name.substring(1));
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "unable to create execution process path", e);
+                       }
+               }
+               return absPath.toString() + uuid;
+       }
+
+       /**
+        * Set the value of the primitive accessor as a JCR property. Does nothing
+        * if the value is null.
+        */
+       public static void setPrimitiveAsProperty(Node node, String propertyName,
+                       PrimitiveAccessor primitiveAccessor) {
+               String type = primitiveAccessor.getType();
+               Object value = primitiveAccessor.getValue();
+               setPrimitiveAsProperty(node, propertyName, type, value);
+       }
+
+       /** Map a primitive value to JCR property value. */
+       public static void setPrimitiveAsProperty(Node node, String propertyName,
+                       String type, Object value) {
+               if (value == null)
+                       return;
+               if (value instanceof CharSequence)
+                       value = PrimitiveUtils.convert(type,
+                                       ((CharSequence) value).toString());
+               if (value instanceof char[])
+                       value = new String((char[]) value);
+
+               try {
+                       if (type.equals(PrimitiveAccessor.TYPE_STRING))
+                               node.setProperty(propertyName, value.toString());
+                       else if (type.equals(PrimitiveAccessor.TYPE_PASSWORD))
+                               node.setProperty(propertyName, value.toString());
+                       else if (type.equals(PrimitiveAccessor.TYPE_INTEGER))
+                               node.setProperty(propertyName, (long) ((Integer) value));
+                       else if (type.equals(PrimitiveAccessor.TYPE_LONG))
+                               node.setProperty(propertyName, ((Long) value));
+                       else if (type.equals(PrimitiveAccessor.TYPE_FLOAT))
+                               node.setProperty(propertyName, (double) ((Float) value));
+                       else if (type.equals(PrimitiveAccessor.TYPE_DOUBLE))
+                               node.setProperty(propertyName, ((Double) value));
+                       else if (type.equals(PrimitiveAccessor.TYPE_BOOLEAN))
+                               node.setProperty(propertyName, ((Boolean) value));
+                       else
+                               throw new SlcException("Unsupported type " + type);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot set primitive of " + type
+                                       + " as property " + propertyName + " on " + node, e);
+               }
+       }
+
+       /** Aggregates the {@link TestStatus} of this sub-tree. */
+       public static Integer aggregateTestStatus(Node node) {
+               try {
+                       Integer status = TestStatus.PASSED;
+                       if (node.isNodeType(SlcTypes.SLC_CHECK))
+                               if (node.getProperty(SLC_SUCCESS).getBoolean())
+                                       status = TestStatus.PASSED;
+                               else if (node.hasProperty(SLC_ERROR_MESSAGE))
+                                       status = TestStatus.ERROR;
+                               else
+                                       status = TestStatus.FAILED;
+
+                       NodeIterator it = node.getNodes();
+                       while (it.hasNext()) {
+                               Node curr = it.nextNode();
+
+                               // Manually skip aggregated status
+                               if (!SlcNames.SLC_AGGREGATED_STATUS.equals(curr.getName())) {
+                                       Integer childStatus = aggregateTestStatus(curr);
+                                       if (childStatus > status)
+                                               status = childStatus;
+                               }
+                       }
+                       return status;
+               } catch (Exception e) {
+                       throw new SlcException("Could not aggregate test status from "
+                                       + node, e);
+               }
+       }
+
+       /**
+        * Aggregates the {@link TestStatus} of this sub-tree.
+        * 
+        * @return the same {@link StringBuffer}, for convenience (typically calling
+        *         toString() on it)
+        */
+       public static StringBuffer aggregateTestMessages(Node node,
+                       StringBuffer messages) {
+               try {
+                       if (node.isNodeType(SlcTypes.SLC_CHECK)) {
+                               if (node.hasProperty(SLC_MESSAGE)) {
+                                       if (messages.length() > 0)
+                                               messages.append('\n');
+                                       messages.append(node.getProperty(SLC_MESSAGE).getString());
+                               }
+                               if (node.hasProperty(SLC_ERROR_MESSAGE)) {
+                                       if (messages.length() > 0)
+                                               messages.append('\n');
+                                       messages.append(node.getProperty(SLC_ERROR_MESSAGE)
+                                                       .getString());
+                               }
+                       }
+                       NodeIterator it = node.getNodes();
+                       while (it.hasNext()) {
+                               Node child = it.nextNode();
+                               // Manually skip aggregated status
+                               if (!SlcNames.SLC_AGGREGATED_STATUS.equals(child.getName())) {
+                                       aggregateTestMessages(child, messages);
+                               }
+                       }
+                       return messages;
+               } catch (Exception e) {
+                       throw new SlcException("Could not aggregate test messages from "
+                                       + node, e);
+               }
+       }
+
+       /** Prevents instantiation */
+       private SlcJcrUtils() {
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrAgent.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrAgent.java
new file mode 100644 (file)
index 0000000..7f776d1
--- /dev/null
@@ -0,0 +1,116 @@
+package org.argeo.slc.jcr.execution;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.UUID;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.security.Privilege;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.runtime.DefaultAgent;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.jcr.SlcJcrConstants;
+import org.argeo.slc.runtime.ProcessThread;
+
+/** SLC VM agent synchronizing with a JCR repository. */
+public class JcrAgent extends DefaultAgent implements SlcNames {
+       // final static String ROLE_REMOTE = "ROLE_REMOTE";
+       final static String NODE_REPO_URI = "argeo.node.repo.uri";
+
+       private Repository repository;
+
+       private String agentNodeName = "default";
+
+       /*
+        * LIFECYCLE
+        */
+       protected String initAgentUuid() {
+               Session session = null;
+               try {
+                       session = repository.login();
+
+                       String agentFactoryPath = getAgentFactoryPath();
+                       Node vmAgentFactoryNode = JcrUtils.mkdirsSafe(session, agentFactoryPath, SlcTypes.SLC_AGENT_FACTORY);
+                       JcrUtils.addPrivilege(session, SlcJcrConstants.SLC_BASE_PATH, SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
+                       if (!vmAgentFactoryNode.hasNode(agentNodeName)) {
+                               String uuid = UUID.randomUUID().toString();
+                               Node agentNode = vmAgentFactoryNode.addNode(agentNodeName, SlcTypes.SLC_AGENT);
+                               agentNode.setProperty(SLC_UUID, uuid);
+                       }
+                       session.save();
+                       return vmAgentFactoryNode.getNode(agentNodeName).getProperty(SLC_UUID).getString();
+               } catch (RepositoryException e) {
+                       JcrUtils.discardQuietly(session);
+                       throw new SlcException("Cannot find JCR agent UUID", e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       @Override
+       public void destroy() {
+               super.destroy();
+       }
+
+       /*
+        * SLC AGENT
+        */
+       @Override
+       protected ProcessThread createProcessThread(ThreadGroup processesThreadGroup,
+                       ExecutionModulesManager modulesManager, ExecutionProcess process) {
+               if (process instanceof JcrExecutionProcess)
+                       return new JcrProcessThread(processesThreadGroup, modulesManager, (JcrExecutionProcess) process);
+               else
+                       return super.createProcessThread(processesThreadGroup, modulesManager, process);
+       }
+
+       /*
+        * UTILITIES
+        */
+       public String getNodePath() {
+               return getAgentFactoryPath() + '/' + getAgentNodeName();
+       }
+
+       public String getAgentFactoryPath() {
+               try {
+                       Boolean isRemote = System.getProperty(NODE_REPO_URI) != null;
+                       String agentFactoryPath;
+                       if (isRemote) {
+                               InetAddress localhost = InetAddress.getLocalHost();
+                               agentFactoryPath = SlcJcrConstants.AGENTS_BASE_PATH + "/" + localhost.getCanonicalHostName();
+
+                               if (agentFactoryPath.equals(SlcJcrConstants.VM_AGENT_FACTORY_PATH))
+                                       throw new SlcException("Unsupported hostname " + localhost.getCanonicalHostName());
+                       } else {// local
+                               agentFactoryPath = SlcJcrConstants.VM_AGENT_FACTORY_PATH;
+                       }
+                       return agentFactoryPath;
+               } catch (UnknownHostException e) {
+                       throw new SlcException("Cannot find agent factory base path", e);
+               }
+       }
+
+       /*
+        * BEAN
+        */
+       public String getAgentNodeName() {
+               return agentNodeName;
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setAgentNodeName(String agentNodeName) {
+               this.agentNodeName = agentNodeName;
+       }
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java
new file mode 100644 (file)
index 0000000..2804b22
--- /dev/null
@@ -0,0 +1,401 @@
+package org.argeo.slc.jcr.execution;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.deploy.ModuleDescriptor;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionModuleDescriptor;
+import org.argeo.slc.execution.ExecutionModulesListener;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.execution.ExecutionSpec;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValueChoice;
+import org.argeo.slc.jcr.SlcJcrUtils;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveValue;
+
+/**
+ * Synchronizes the local execution runtime with a JCR repository. For the time
+ * being the state is completely reset from one start to another.
+ */
+public class JcrExecutionModulesListener implements ExecutionModulesListener,
+               SlcNames {
+       private final static String SLC_EXECUTION_MODULES_PROPERTY = "slc.executionModules";
+
+       private final static Log log = LogFactory
+                       .getLog(JcrExecutionModulesListener.class);
+       private JcrAgent agent;
+
+       private ExecutionModulesManager modulesManager;
+
+       private Repository repository;
+       /**
+        * We don't use a thread bound session because many different threads will
+        * call this critical component and we don't want to login each time. We
+        * therefore rather protect access to this session via synchronized.
+        */
+       private Session session;
+
+       /*
+        * LIFECYCLE
+        */
+       public void init() {
+               try {
+                       session = repository.login();
+                       clearAgent();
+                       if (modulesManager != null) {
+                               Node agentNode = session.getNode(agent.getNodePath());
+
+                               List<ModuleDescriptor> moduleDescriptors = modulesManager
+                                               .listModules();
+
+                               // scan SLC-ExecutionModule metadata
+                               for (ModuleDescriptor md : moduleDescriptors) {
+                                       if (md.getMetadata().containsKey(
+                                                       ExecutionModuleDescriptor.SLC_EXECUTION_MODULE)) {
+                                               String moduleNodeName = SlcJcrUtils
+                                                               .getModuleNodeName(md);
+                                               Node moduleNode = agentNode.hasNode(moduleNodeName) ? agentNode
+                                                               .getNode(moduleNodeName) : agentNode
+                                                               .addNode(moduleNodeName);
+                                               moduleNode.addMixin(SlcTypes.SLC_EXECUTION_MODULE);
+                                               moduleNode.setProperty(SLC_NAME, md.getName());
+                                               moduleNode.setProperty(SLC_VERSION, md.getVersion());
+                                               moduleNode.setProperty(Property.JCR_TITLE,
+                                                               md.getTitle());
+                                               moduleNode.setProperty(Property.JCR_DESCRIPTION,
+                                                               md.getDescription());
+                                               moduleNode.setProperty(SLC_STARTED, md.getStarted());
+                                       }
+                               }
+
+                               // scan execution modules property
+                               String executionModules = System
+                                               .getProperty(SLC_EXECUTION_MODULES_PROPERTY);
+                               if (executionModules != null) {
+                                       for (String executionModule : executionModules.split(",")) {
+                                               allModules: for (ModuleDescriptor md : moduleDescriptors) {
+                                                       String moduleNodeName = SlcJcrUtils
+                                                                       .getModuleNodeName(md);
+                                                       if (md.getName().equals(executionModule)) {
+                                                               Node moduleNode = agentNode
+                                                                               .hasNode(moduleNodeName) ? agentNode
+                                                                               .getNode(moduleNodeName) : agentNode
+                                                                               .addNode(moduleNodeName);
+                                                               moduleNode
+                                                                               .addMixin(SlcTypes.SLC_EXECUTION_MODULE);
+                                                               moduleNode.setProperty(SLC_NAME, md.getName());
+                                                               moduleNode.setProperty(SLC_VERSION,
+                                                                               md.getVersion());
+                                                               moduleNode.setProperty(Property.JCR_TITLE,
+                                                                               md.getTitle());
+                                                               moduleNode.setProperty(
+                                                                               Property.JCR_DESCRIPTION,
+                                                                               md.getDescription());
+                                                               moduleNode.setProperty(SLC_STARTED,
+                                                                               md.getStarted());
+                                                               break allModules;
+                                                       }
+                                               }
+                                       }
+
+                                       // save if needed
+                                       if (session.hasPendingChanges())
+                                               session.save();
+                               }
+                       }
+               } catch (RepositoryException e) {
+                       JcrUtils.discardQuietly(session);
+                       JcrUtils.logoutQuietly(session);
+                       throw new SlcException("Cannot initialize modules", e);
+               }
+       }
+
+       public void destroy() {
+               clearAgent();
+               JcrUtils.logoutQuietly(session);
+       }
+
+       protected synchronized void clearAgent() {
+               try {
+                       Node agentNode = session.getNode(agent.getNodePath());
+                       for (NodeIterator nit = agentNode.getNodes(); nit.hasNext();)
+                               nit.nextNode().remove();
+                       session.save();
+               } catch (RepositoryException e) {
+                       JcrUtils.discardQuietly(session);
+                       throw new SlcException("Cannot clear agent " + agent, e);
+               }
+       }
+
+       /*
+        * EXECUTION MODULES LISTENER
+        */
+
+       public synchronized void executionModuleAdded(
+                       ModuleDescriptor moduleDescriptor) {
+               syncExecutionModule(moduleDescriptor);
+       }
+
+       protected void syncExecutionModule(ModuleDescriptor moduleDescriptor) {
+               try {
+                       Node agentNode = session.getNode(agent.getNodePath());
+                       String moduleNodeName = SlcJcrUtils
+                                       .getModuleNodeName(moduleDescriptor);
+                       Node moduleNode = agentNode.hasNode(moduleNodeName) ? agentNode
+                                       .getNode(moduleNodeName) : agentNode
+                                       .addNode(moduleNodeName);
+                       moduleNode.addMixin(SlcTypes.SLC_EXECUTION_MODULE);
+                       moduleNode.setProperty(SLC_NAME, moduleDescriptor.getName());
+                       moduleNode.setProperty(SLC_VERSION, moduleDescriptor.getVersion());
+                       moduleNode.setProperty(Property.JCR_TITLE,
+                                       moduleDescriptor.getTitle());
+                       moduleNode.setProperty(Property.JCR_DESCRIPTION,
+                                       moduleDescriptor.getDescription());
+                       moduleNode.setProperty(SLC_STARTED, moduleDescriptor.getStarted());
+                       session.save();
+               } catch (RepositoryException e) {
+                       JcrUtils.discardQuietly(session);
+                       throw new SlcException("Cannot sync module " + moduleDescriptor, e);
+               }
+       }
+
+       public synchronized void executionModuleRemoved(
+                       ModuleDescriptor moduleDescriptor) {
+               try {
+                       String moduleName = SlcJcrUtils.getModuleNodeName(moduleDescriptor);
+                       Node agentNode = session.getNode(agent.getNodePath());
+                       if (agentNode.hasNode(moduleName)) {
+                               Node moduleNode = agentNode.getNode(moduleName);
+                               for (NodeIterator nit = moduleNode.getNodes(); nit.hasNext();) {
+                                       nit.nextNode().remove();
+                               }
+                               moduleNode.setProperty(SLC_STARTED, false);
+                       }
+                       session.save();
+               } catch (RepositoryException e) {
+                       JcrUtils.discardQuietly(session);
+                       throw new SlcException("Cannot remove module " + moduleDescriptor,
+                                       e);
+               }
+       }
+
+       public synchronized void executionFlowAdded(ModuleDescriptor module,
+                       ExecutionFlowDescriptor efd) {
+               try {
+                       Node agentNode = session.getNode(agent.getNodePath());
+                       Node moduleNode = agentNode.getNode(SlcJcrUtils
+                                       .getModuleNodeName(module));
+                       String relativePath = getExecutionFlowRelativePath(efd);
+                       @SuppressWarnings("unused")
+                       Node flowNode = null;
+                       if (!moduleNode.hasNode(relativePath)) {
+                               flowNode = createExecutionFlowNode(moduleNode, relativePath,
+                                               efd);
+                               session.save();
+                       } else {
+                               flowNode = moduleNode.getNode(relativePath);
+                       }
+
+                       if (log.isTraceEnabled())
+                               log.trace("Flow " + efd + " added to JCR");
+               } catch (RepositoryException e) {
+                       JcrUtils.discardQuietly(session);
+                       throw new SlcException("Cannot add flow " + efd + " from module "
+                                       + module, e);
+               }
+
+       }
+
+       protected Node createExecutionFlowNode(Node moduleNode,
+                       String relativePath, ExecutionFlowDescriptor efd)
+                       throws RepositoryException {
+               Node flowNode = null;
+               List<String> pathTokens = Arrays.asList(relativePath.split("/"));
+
+               Iterator<String> names = pathTokens.iterator();
+               // create intermediary paths
+               Node currNode = moduleNode;
+               while (names.hasNext()) {
+                       String name = names.next();
+                       if (currNode.hasNode(name))
+                               currNode = currNode.getNode(name);
+                       else {
+                               if (names.hasNext())
+                                       currNode = currNode.addNode(name);
+                               else
+                                       flowNode = currNode.addNode(name,
+                                                       SlcTypes.SLC_EXECUTION_FLOW);
+                       }
+               }
+
+               // name, description
+               flowNode.setProperty(SLC_NAME, efd.getName());
+               String endName = pathTokens.get(pathTokens.size() - 1);
+               flowNode.setProperty(Property.JCR_TITLE, endName);
+               if (efd.getDescription() != null
+                               && !efd.getDescription().trim().equals("")) {
+                       flowNode.setProperty(Property.JCR_DESCRIPTION, efd.getDescription());
+               } else {
+                       flowNode.setProperty(Property.JCR_DESCRIPTION, endName);
+               }
+
+               // execution spec
+               ExecutionSpec executionSpec = efd.getExecutionSpec();
+               String esName = executionSpec.getName();
+               if (esName == null || esName.equals(ExecutionSpec.INTERNAL_NAME)
+                               || esName.contains("#")/* automatically generated bean name */) {
+                       // internal spec node
+                       mapExecutionSpec(flowNode, executionSpec);
+               } else {
+                       // reference spec node
+                       Node executionSpecsNode = moduleNode.hasNode(SLC_EXECUTION_SPECS) ? moduleNode
+                                       .getNode(SLC_EXECUTION_SPECS) : moduleNode
+                                       .addNode(SLC_EXECUTION_SPECS);
+                       Node executionSpecNode = executionSpecsNode.addNode(esName,
+                                       SlcTypes.SLC_EXECUTION_SPEC);
+                       executionSpecNode.setProperty(SLC_NAME, esName);
+                       executionSpecNode.setProperty(Property.JCR_TITLE, esName);
+                       if (executionSpec.getDescription() != null
+                                       && !executionSpec.getDescription().trim().equals(""))
+                               executionSpecNode.setProperty(Property.JCR_DESCRIPTION,
+                                               executionSpec.getDescription());
+                       mapExecutionSpec(executionSpecNode, executionSpec);
+                       flowNode.setProperty(SLC_SPEC, executionSpecNode);
+               }
+
+               // flow values
+               for (String attr : efd.getValues().keySet()) {
+                       ExecutionSpecAttribute esa = executionSpec.getAttributes()
+                                       .get(attr);
+                       if (esa instanceof PrimitiveSpecAttribute) {
+                               PrimitiveSpecAttribute psa = (PrimitiveSpecAttribute) esa;
+                               // if spec reference there will be no node at this stage
+                               Node valueNode = JcrUtils.getOrAdd(flowNode, attr);
+                               valueNode.setProperty(SLC_TYPE, psa.getType());
+                               SlcJcrUtils.setPrimitiveAsProperty(valueNode, SLC_VALUE,
+                                               (PrimitiveValue) efd.getValues().get(attr));
+                       }
+               }
+
+               return flowNode;
+       }
+
+       /**
+        * Base can be either an execution spec node, or an execution flow node (in
+        * case the execution spec is internal)
+        */
+       protected void mapExecutionSpec(Node baseNode, ExecutionSpec executionSpec)
+                       throws RepositoryException {
+               for (String attrName : executionSpec.getAttributes().keySet()) {
+                       ExecutionSpecAttribute esa = executionSpec.getAttributes().get(
+                                       attrName);
+                       Node attrNode = baseNode.addNode(attrName);
+                       // booleans
+                       attrNode.addMixin(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE);
+                       attrNode.setProperty(SLC_IS_IMMUTABLE, esa.getIsImmutable());
+                       attrNode.setProperty(SLC_IS_CONSTANT, esa.getIsConstant());
+                       attrNode.setProperty(SLC_IS_HIDDEN, esa.getIsHidden());
+
+                       if (esa instanceof PrimitiveSpecAttribute) {
+                               attrNode.addMixin(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE);
+                               PrimitiveSpecAttribute psa = (PrimitiveSpecAttribute) esa;
+                               SlcJcrUtils.setPrimitiveAsProperty(attrNode, SLC_VALUE, psa);
+                               attrNode.setProperty(SLC_TYPE, psa.getType());
+                       } else if (esa instanceof RefSpecAttribute) {
+                               attrNode.addMixin(SlcTypes.SLC_REF_SPEC_ATTRIBUTE);
+                               RefSpecAttribute rsa = (RefSpecAttribute) esa;
+                               attrNode.setProperty(SLC_TYPE, rsa.getTargetClassName());
+                               Object value = rsa.getValue();
+                               if (rsa.getChoices() != null) {
+                                       Integer index = null;
+                                       int count = 0;
+                                       for (RefValueChoice choice : rsa.getChoices()) {
+                                               String name = choice.getName();
+                                               if (value != null && name.equals(value.toString()))
+                                                       index = count;
+                                               Node choiceNode = attrNode.addNode(choice.getName());
+                                               choiceNode.addMixin(NodeType.MIX_TITLE);
+                                               choiceNode.setProperty(Property.JCR_TITLE,
+                                                               choice.getName());
+                                               if (choice.getDescription() != null
+                                                               && !choice.getDescription().trim().equals(""))
+                                                       choiceNode.setProperty(Property.JCR_DESCRIPTION,
+                                                                       choice.getDescription());
+                                               count++;
+                                       }
+
+                                       if (index != null)
+                                               attrNode.setProperty(SLC_VALUE, index);
+                               }
+                       }
+               }
+       }
+
+       public synchronized void executionFlowRemoved(ModuleDescriptor module,
+                       ExecutionFlowDescriptor executionFlow) {
+               try {
+                       Node agentNode = session.getNode(agent.getNodePath());
+                       Node moduleNode = agentNode.getNode(SlcJcrUtils
+                                       .getModuleNodeName(module));
+                       String relativePath = getExecutionFlowRelativePath(executionFlow);
+                       if (moduleNode.hasNode(relativePath))
+                               moduleNode.getNode(relativePath).remove();
+                       agentNode.getSession().save();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot remove flow " + executionFlow
+                                       + " from module " + module, e);
+               }
+       }
+
+       /*
+        * UTILITIES
+        */
+       /** @return the relative path, never starts with '/' */
+       @SuppressWarnings("deprecation")
+       protected String getExecutionFlowRelativePath(
+                       ExecutionFlowDescriptor executionFlow) {
+               String relativePath = executionFlow.getPath() == null ? executionFlow
+                               .getName() : executionFlow.getPath() + '/'
+                               + executionFlow.getName();
+               // we assume that it is more than one char long
+               if (relativePath.charAt(0) == '/')
+                       relativePath = relativePath.substring(1);
+               // FIXME quick hack to avoid duplicate '/'
+               relativePath = relativePath.replaceAll("//", "/");
+               return relativePath;
+       }
+
+       /*
+        * BEAN
+        */
+       public void setAgent(JcrAgent agent) {
+               this.agent = agent;
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setModulesManager(ExecutionModulesManager modulesManager) {
+               this.modulesManager = modulesManager;
+       }
+
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionProcess.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrExecutionProcess.java
new file mode 100644 (file)
index 0000000..9d00459
--- /dev/null
@@ -0,0 +1,179 @@
+package org.argeo.slc.jcr.execution;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.ExecutionStep;
+import org.argeo.slc.execution.RealizedFlow;
+import org.argeo.slc.jcr.SlcJcrUtils;
+import org.argeo.slc.runtime.ProcessThread;
+
+/** Execution process implementation based on a JCR node. */
+public class JcrExecutionProcess implements ExecutionProcess, SlcNames {
+       private final static Log log = LogFactory.getLog(JcrExecutionProcess.class);
+       private final Node node;
+
+       private Long nextLogLine = 1l;
+
+       public JcrExecutionProcess(Node node) {
+               this.node = node;
+       }
+
+       public synchronized String getUuid() {
+               try {
+                       return node.getProperty(SLC_UUID).getString();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot get uuid for " + node, e);
+               }
+       }
+
+       public synchronized String getStatus() {
+               try {
+                       return node.getProperty(SLC_STATUS).getString();
+               } catch (RepositoryException e) {
+                       log.error("Cannot get status: " + e);
+                       // we should re-throw exception because this information can
+                       // probably used for monitoring in case there are already unexpected
+                       // exceptions
+                       return UNKOWN;
+               }
+       }
+
+       public synchronized void setStatus(String status) {
+               try {
+                       node.setProperty(SLC_STATUS, status);
+                       // last modified properties needs to be manually updated
+                       // see https://issues.apache.org/jira/browse/JCR-2233
+                       JcrUtils.updateLastModified(node);
+                       node.getSession().save();
+               } catch (RepositoryException e) {
+                       JcrUtils.discardUnderlyingSessionQuietly(node);
+                       // we should re-throw exception because this information can
+                       // probably used for monitoring in case there are already unexpected
+                       // exceptions
+                       log.error("Cannot set status " + status + ": " + e);
+               }
+       }
+
+       /**
+        * Synchronized in order to make sure that there is no concurrent
+        * modification of {@link #nextLogLine}.
+        */
+       public synchronized void addSteps(List<ExecutionStep> steps) {
+               try {
+                       steps: for (ExecutionStep step : steps) {
+                               String type;
+                               if (step.getType().equals(ExecutionStep.TRACE))
+                                       type = SlcTypes.SLC_LOG_TRACE;
+                               else if (step.getType().equals(ExecutionStep.DEBUG))
+                                       type = SlcTypes.SLC_LOG_DEBUG;
+                               else if (step.getType().equals(ExecutionStep.INFO))
+                                       type = SlcTypes.SLC_LOG_INFO;
+                               else if (step.getType().equals(ExecutionStep.WARNING))
+                                       type = SlcTypes.SLC_LOG_WARNING;
+                               else if (step.getType().equals(ExecutionStep.ERROR))
+                                       type = SlcTypes.SLC_LOG_ERROR;
+                               else
+                                       // skip
+                                       continue steps;
+
+                               String relPath = SLC_LOG + '/'
+                                               + step.getThread().replace('/', '_') + '/'
+                                               + step.getLocation().replace('.', '/');
+                               String path = node.getPath() + '/' + relPath;
+                               // clean special character
+                               // TODO factorize in JcrUtils
+                               path = path.replace('@', '_');
+
+                               Node location = JcrUtils.mkdirs(node.getSession(), path);
+                               Node logEntry = location.addNode(Long.toString(nextLogLine),
+                                               type);
+                               logEntry.setProperty(SLC_MESSAGE, step.getLog());
+                               Calendar calendar = new GregorianCalendar();
+                               calendar.setTime(step.getTimestamp());
+                               logEntry.setProperty(SLC_TIMESTAMP, calendar);
+
+                               // System.out.println("Logged " + logEntry.getPath());
+
+                               nextLogLine++;
+                       }
+
+                       // last modified properties needs to be manually updated
+                       // see https://issues.apache.org/jira/browse/JCR-2233
+                       JcrUtils.updateLastModified(node);
+
+                       node.getSession().save();
+               } catch (Exception e) {
+                       JcrUtils.discardUnderlyingSessionQuietly(node);
+                       e.printStackTrace();
+               }
+       }
+
+       // public Node getNode() {
+       // return node;
+       // }
+
+       public List<RealizedFlow> getRealizedFlows() {
+               try {
+                       List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();
+                       Node rootRealizedFlowNode = node.getNode(SLC_FLOW);
+                       // we just manage one level for the time being
+                       NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW);
+                       while (nit.hasNext()) {
+                               Node realizedFlowNode = nit.nextNode();
+
+                               if (realizedFlowNode.hasNode(SLC_ADDRESS)) {
+                                       String flowPath = realizedFlowNode.getNode(SLC_ADDRESS)
+                                                       .getProperty(Property.JCR_PATH).getString();
+                                       NameVersion moduleNameVersion = SlcJcrUtils
+                                                       .moduleNameVersion(flowPath);
+                                       ((ProcessThread) Thread.currentThread())
+                                                       .getExecutionModulesManager().start(
+                                                                       moduleNameVersion);
+                               }
+
+                               RealizedFlow realizedFlow = new JcrRealizedFlow(
+                                               realizedFlowNode);
+                               if (realizedFlow != null)
+                                       realizedFlows.add(realizedFlow);
+                       }
+                       return realizedFlows;
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot get realized flows", e);
+               }
+       }
+
+       public String getNodePath() {
+               try {
+                       return node.getPath();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot get process node path for " + node,
+                                       e);
+               }
+       }
+
+       public Repository getRepository() {
+               try {
+                       return node.getSession().getRepository();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot get process JCR repository for "
+                                       + node, e);
+               }
+       }
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java
new file mode 100644 (file)
index 0000000..bef375a
--- /dev/null
@@ -0,0 +1,73 @@
+package org.argeo.slc.jcr.execution;
+
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.api.NodeConstants;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.RealizedFlow;
+import org.argeo.slc.runtime.ProcessThread;
+
+/** Where the actual execution takes place */
+public class JcrProcessThread extends ProcessThread implements SlcNames {
+
+       public JcrProcessThread(ThreadGroup processesThreadGroup, ExecutionModulesManager executionModulesManager,
+                       JcrExecutionProcess process) {
+               super(processesThreadGroup, executionModulesManager, process);
+       }
+
+       /** Overridden in order to set progress status on realized flow nodes. */
+       @Override
+       protected void process() throws InterruptedException {
+               Session session = null;
+               if (getProcess() instanceof JcrExecutionProcess)
+                       try {
+                               session = ((JcrExecutionProcess) getProcess()).getRepository().login(NodeConstants.HOME_WORKSPACE);
+
+                               List<RealizedFlow> realizedFlows = getProcess().getRealizedFlows();
+                               for (RealizedFlow realizedFlow : realizedFlows) {
+                                       Node realizedFlowNode = session.getNode(((JcrRealizedFlow) realizedFlow).getPath());
+                                       setFlowStatus(realizedFlowNode, ExecutionProcess.RUNNING);
+
+                                       try {
+                                               //
+                                               // EXECUTE THE FLOW
+                                               //
+                                               execute(realizedFlow, true);
+
+                                               setFlowStatus(realizedFlowNode, ExecutionProcess.COMPLETED);
+                                       } catch (RepositoryException e) {
+                                               throw e;
+                                       } catch (InterruptedException e) {
+                                               setFlowStatus(realizedFlowNode, ExecutionProcess.KILLED);
+                                               throw e;
+                                       } catch (RuntimeException e) {
+                                               setFlowStatus(realizedFlowNode, ExecutionProcess.ERROR);
+                                               throw e;
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot process " + getJcrExecutionProcess().getNodePath(), e);
+                       } finally {
+                               JcrUtils.logoutQuietly(session);
+                       }
+               else
+                       super.process();
+       }
+
+       protected void setFlowStatus(Node realizedFlowNode, String status) throws RepositoryException {
+               realizedFlowNode.setProperty(SLC_STATUS, status);
+               realizedFlowNode.getSession().save();
+       }
+
+       protected JcrExecutionProcess getJcrExecutionProcess() {
+               return (JcrExecutionProcess) getProcess();
+       }
+}
diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java
new file mode 100644 (file)
index 0000000..b7444d4
--- /dev/null
@@ -0,0 +1,133 @@
+package org.argeo.slc.jcr.execution;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RealizedFlow;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.jcr.SlcJcrUtils;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveUtils;
+import org.argeo.slc.runtime.DefaultExecutionSpec;
+
+public class JcrRealizedFlow extends RealizedFlow implements SlcNames {
+       private static final long serialVersionUID = -3709453850260712001L;
+       private String path;
+
+       public JcrRealizedFlow(Node node) {
+               try {
+                       this.path = node.getPath();
+                       loadFromNode(node);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot initialize from " + node, e);
+               }
+       }
+
+       protected void loadFromNode(Node realizedFlowNode) throws RepositoryException {
+               if (realizedFlowNode.hasNode(SLC_ADDRESS)) {
+                       String flowPath = realizedFlowNode.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString();
+                       // TODO: convert to local path if remote
+                       // FIXME start related module
+                       Session agentSession = realizedFlowNode.getSession().getRepository().login();
+                       try {
+                               Node flowNode = agentSession.getNode(flowPath);
+                               String flowName = flowNode.getProperty(SLC_NAME).getString();
+                               String description = null;
+                               if (flowNode.hasProperty(Property.JCR_DESCRIPTION))
+                                       description = flowNode.getProperty(Property.JCR_DESCRIPTION).getString();
+
+                               Node executionModuleNode = flowNode.getSession().getNode(SlcJcrUtils.modulePath(flowPath));
+                               String executionModuleName = executionModuleNode.getProperty(SLC_NAME).getString();
+                               String executionModuleVersion = executionModuleNode.getProperty(SLC_VERSION).getString();
+
+                               RealizedFlow realizedFlow = this;
+                               realizedFlow.setModuleName(executionModuleName);
+                               realizedFlow.setModuleVersion(executionModuleVersion);
+
+                               // retrieve execution spec
+                               DefaultExecutionSpec executionSpec = new DefaultExecutionSpec();
+                               Map<String, ExecutionSpecAttribute> attrs = readExecutionSpecAttributes(realizedFlowNode);
+                               executionSpec.setAttributes(attrs);
+
+                               // set execution spec name
+                               if (flowNode.hasProperty(SlcNames.SLC_SPEC)) {
+                                       Node executionSpecNode = flowNode.getProperty(SLC_SPEC).getNode();
+                                       executionSpec.setName(executionSpecNode.getProperty(SLC_NAME).getString());
+                               }
+
+                               // explicitly retrieve values
+                               Map<String, Object> values = new HashMap<String, Object>();
+                               for (String attrName : attrs.keySet()) {
+                                       ExecutionSpecAttribute attr = attrs.get(attrName);
+                                       Object value = attr.getValue();
+                                       values.put(attrName, value);
+                               }
+
+                               ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(flowName, description, values, executionSpec);
+                               realizedFlow.setFlowDescriptor(efd);
+
+                       } finally {
+                               JcrUtils.logoutQuietly(agentSession);
+                       }
+               } else {
+                       throw new SlcException("Unsupported realized flow " + realizedFlowNode);
+               }
+       }
+
+       protected Map<String, ExecutionSpecAttribute> readExecutionSpecAttributes(Node node) {
+               try {
+                       Map<String, ExecutionSpecAttribute> attrs = new HashMap<String, ExecutionSpecAttribute>();
+                       for (NodeIterator nit = node.getNodes(); nit.hasNext();) {
+                               Node specAttrNode = nit.nextNode();
+                               if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
+                                       String type = specAttrNode.getProperty(SLC_TYPE).getString();
+                                       Object value = null;
+                                       if (specAttrNode.hasProperty(SLC_VALUE)) {
+                                               String valueStr = specAttrNode.getProperty(SLC_VALUE).getString();
+                                               value = PrimitiveUtils.convert(type, valueStr);
+                                       }
+                                       PrimitiveSpecAttribute specAttr = new PrimitiveSpecAttribute(type, value);
+                                       attrs.put(specAttrNode.getName(), specAttr);
+                               } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
+                                       if (!specAttrNode.hasProperty(SLC_VALUE)) {
+                                               continue;
+                                       }
+                                       Integer value = (int) specAttrNode.getProperty(SLC_VALUE).getLong();
+                                       RefSpecAttribute specAttr = new RefSpecAttribute();
+                                       NodeIterator children = specAttrNode.getNodes();
+                                       int index = 0;
+                                       String id = null;
+                                       while (children.hasNext()) {
+                                               Node child = children.nextNode();
+                                               if (index == value)
+                                                       id = child.getName();
+                                               index++;
+                                       }
+                                       specAttr.setValue(id);
+                                       attrs.put(specAttrNode.getName(), specAttr);
+                               }
+                               // throw new SlcException("Unsupported spec attribute "
+                               // + specAttrNode);
+                       }
+                       return attrs;
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot read spec attributes from " + node, e);
+               }
+       }
+
+       public String getPath() {
+               return path;
+       }
+}
diff --git a/org.argeo.slc.repo/.classpath b/org.argeo.slc.repo/.classpath
new file mode 100644 (file)
index 0000000..70b08e8
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" output="target/classes" path="src"/>
+       <classpathentry kind="src" path="ext/test"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.argeo.slc.repo/.gitignore b/org.argeo.slc.repo/.gitignore
new file mode 100644 (file)
index 0000000..0f63015
--- /dev/null
@@ -0,0 +1,2 @@
+/target/
+/bin/
diff --git a/org.argeo.slc.repo/.project b/org.argeo.slc.repo/.project
new file mode 100644 (file)
index 0000000..26f4658
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.repo</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.jdt.core.javanature</nature>
+               <nature>org.eclipse.pde.PluginNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.argeo.slc.repo/META-INF/.gitignore b/org.argeo.slc.repo/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/org.argeo.slc.repo/bnd.bnd b/org.argeo.slc.repo/bnd.bnd
new file mode 100644 (file)
index 0000000..07af6b4
--- /dev/null
@@ -0,0 +1,16 @@
+Import-Package: org.w3c.dom.*,\
+org.xml.sax.*,\
+javax.xml.transform.*,\
+javax.xml.parsers.*,\
+javax.jcr.nodetype,\
+org.eclipse.aether.*;version=1.0.1,\
+org.osgi.*;version=0.0.0,\
+*
+
+Private-Package: org.eclipse.aether.*
+
+Require-Capability: cms.datamodel; filter:="(name=slc)"
+Provide-Capability: cms.datamodel; name=java,\
+ cms.datamodel; name=dist,\
+ cms.datamodel; name=docs,\
+ cms.datamodel; name=rpm
diff --git a/org.argeo.slc.repo/build.properties b/org.argeo.slc.repo/build.properties
new file mode 100644 (file)
index 0000000..31b02d2
--- /dev/null
@@ -0,0 +1 @@
+additional.bundles = org.junit
diff --git a/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/AetherUtilsTest.java b/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/AetherUtilsTest.java
new file mode 100644 (file)
index 0000000..21563fe
--- /dev/null
@@ -0,0 +1,54 @@
+package org.argeo.slc.repo.internal;
+
+
+import junit.framework.TestCase;
+
+import org.argeo.slc.repo.maven.AetherUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+public class AetherUtilsTest extends TestCase {
+       public void testConvertPathToArtifact() throws Exception {
+               checkPathConversion("my.group.id:my-artifactId:pom:1.2.3",
+                               "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3.pom");
+               checkPathConversion("my.group.id:my-artifactId:pom:1.2.3-SNAPSHOT",
+                               "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT.pom");
+               checkPathConversion("my.group.id:my-artifactId:pom:myClassifier:1.2.3",
+                               "/my/group/id/my-artifactId/1.2.3/my-artifactId-1.2.3-myClassifier.pom");
+               checkPathConversion(
+                               "my.group.id:my-artifactId:pom:myClassifier:1.2.3-SNAPSHOT",
+                               "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-1.2.3-SNAPSHOT-myClassifier.pom");
+               checkPathConversion(
+                               "my.group.id:my-artifactId:pom:myClassifier:20110828.223836-2",
+                               "/my/group/id/my-artifactId/1.2.3-SNAPSHOT/my-artifactId-20110828.223836-2-myClassifier.pom");
+       }
+
+       public void testConvertPathToArtifactRealLife() throws Exception {
+               checkPathConversion(
+                               "org.apache.maven.plugins:maven-antrun-plugin:pom:1.1",
+                               "org/apache/maven/plugins/maven-antrun-plugin/1.1/maven-antrun-plugin-1.1.pom");
+               checkPathConversion(
+                               "org.apache.maven.plugins:maven-plugin-parent:pom:2.0.1",
+                               "org/apache/maven/plugins/maven-plugin-parent/2.0.1/maven-plugin-parent-2.0.1.pom");
+               checkPathConversion(
+                               "org.apache.avalon.framework:avalon-framework-impl:pom:4.3.1",
+                               "org/apache/avalon/framework/avalon-framework-impl/4.3.1/avalon-framework-impl-4.3.1.pom");
+               checkPathConversion(
+                               "org.apache.maven.shared:maven-dependency-tree:pom:1.2",
+                               "org/apache/maven/shared/maven-dependency-tree/1.2/maven-dependency-tree-1.2.pom");
+               checkPathConversion(
+                               "org.argeo.maven.plugins:maven-argeo-osgi-plugin:pom:1.0.33",
+                               "org/argeo/maven/plugins/maven-argeo-osgi-plugin/1.0.33/maven-argeo-osgi-plugin-1.0.33.pom");
+               checkPathConversion(
+                               "org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1",
+                               "org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom");
+       }
+
+       protected void checkPathConversion(String expectedArtifact, String path) {
+               Artifact artifact = AetherUtils.convertPathToArtifact(path, null);
+               if (expectedArtifact == null)
+                       assertNull(artifact);
+               else
+                       assertEquals(new DefaultArtifact(expectedArtifact), artifact);
+       }
+}
diff --git a/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/pom.xml b/org.argeo.slc.repo/ext/test/org/argeo/slc/repo/internal/pom.xml
new file mode 100644 (file)
index 0000000..b12659b
--- /dev/null
@@ -0,0 +1,209 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.commons</groupId>
+               <artifactId>argeo-commons</artifactId>
+               <version>2.1.70-SNAPSHOT</version>
+       </parent>
+       <groupId>org.argeo.slc</groupId>
+       <artifactId>argeo-slc</artifactId>
+       <packaging>pom</packaging>
+       <name>Argeo SLC</name>
+       <version>2.1.10-SNAPSHOT</version>
+       <properties>
+               <developmentCycle.slc>2.1</developmentCycle.slc>
+               <developmentCycle.startDate>2015-02-12</developmentCycle.startDate>
+               <version.argeo-rcp>2.1.15</version.argeo-rcp>
+               <version.slc>2.1.10-SNAPSHOT</version.slc>
+               <version.equinox>3.11.1.v20160708-1632</version.equinox>
+               <!-- Embedded Maven -->
+               <version.maven>3.2.5</version.maven>
+       </properties>
+       <modules>
+               <!-- Runtime -->
+               <module>org.argeo.slc.api</module>
+               <module>org.argeo.slc.core</module>
+               <module>org.argeo.slc.unit</module>
+               <module>org.argeo.slc.support</module>
+               <module>org.argeo.slc.support.maven</module>
+               <module>org.argeo.slc.repo</module>
+               <module>org.argeo.slc.factory</module>
+               <module>org.argeo.slc.launcher</module>
+
+               <!-- Modules -->
+               <module>org.argeo.slc.agent</module>
+               <module>org.argeo.slc.agent.jcr</module>
+               <module>org.argeo.slc.server.repo</module>
+
+               <!-- UI -->
+               <module>org.argeo.slc.client.ui</module>
+               <module>org.argeo.slc.client.ui.dist</module>
+               <module>org.argeo.slc.client.rap</module>
+               <!-- <module>org.argeo.slc.client.rcp</module> -->
+
+               <module>lib</module>
+               <module>dep</module>
+               <module>dist</module>
+               <module>demo</module>
+       </modules>
+       <url>http://projects.argeo.org/slc/</url>
+       <scm>
+               <connection>scm:git:http://git.argeo.org/apache2/argeo-slc.git</connection>
+               <url>http://git.argeo.org/?p=apache2/argeo-slc.git;a=summary</url>
+               <developerConnection>scm:git:https://code.argeo.org/git/apache2/argeo-slc.git</developerConnection>
+               <tag>HEAD</tag>
+       </scm>
+       <inceptionYear>2007</inceptionYear>
+       <licenses>
+               <license>
+                       <name>Apache 2</name>
+                       <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+                       <distribution>repo</distribution>
+                       <comments><![CDATA[
+SLC (Software Life Cycle) framework
+                          
+Copyright (C) 2007-2012 Argeo GmbH
+
+Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+]]>
+                       </comments>
+               </license>
+       </licenses>
+       <developers>
+               <developer>
+                       <id>mbaudier</id>
+                       <name>Mathieu Baudier</name>
+                       <email><![CDATA[http://mailhide.recaptcha.net/d?k=01EM7GpnvY3k8woQ2tnnZLUA==&c=crsNpHjhOBDPswHG6HD_gXaqymhC69wmBf7wlagcSHw=]]></email>
+                       <organization>Argeo</organization>
+                       <organizationUrl>http://www.argeo.org</organizationUrl>
+                       <roles>
+                               <role>architect</role>
+                               <role>developer</role>
+                               <role>QA</role>
+                       </roles>
+               </developer>
+               <developer>
+                       <id>ocapillo</id>
+                       <name>Olivier Capillon</name>
+                       <email><![CDATA[http://mailhide.recaptcha.net/d?k=01EM7GpnvY3k8woQ2tnnZLUA==&c=BYw8i94WiejnvegUKJoCZQQr0h-mYlKCNKZVe_3WPIA=]]></email>
+                       <organization>Argeo</organization>
+                       <organizationUrl>http://www.argeo.org</organizationUrl>
+                       <roles>
+                               <role>developer</role>
+                       </roles>
+               </developer>
+               <developer>
+                       <id>bsinou</id>
+                       <name>Bruno Sinou</name>
+                       <email><![CDATA[http://www.google.com/recaptcha/mailhide/d?k=01SZoYvDnJzcw0KOR7M7u6Qg==&c=SVgEjXA_Uu9ZrNzLES92w1ght6puLFiVpoNUddCfSU8=]]></email>
+                       <organization>Argeo</organization>
+                       <organizationUrl>http://www.argeo.org</organizationUrl>
+                       <roles>
+                               <role>developer</role>
+                       </roles>
+               </developer>
+       </developers>
+       <build>
+               <plugins>
+                       <plugin>
+                               <artifactId>maven-site-plugin</artifactId>
+                               <inherited>false</inherited>
+                               <configuration>
+                                       <skip>false</skip>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <artifactId>maven-javadoc-plugin</artifactId>
+                               <configuration>
+                                       <skip>true</skip>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       <repositories>
+               <repository>
+                       <id>argeo</id>
+                       <url>http://forge.argeo.org/data/java/argeo-2.1/</url>
+                       <releases>
+                               <enabled>true</enabled>
+                               <updatePolicy>daily</updatePolicy>
+                               <checksumPolicy>warn</checksumPolicy>
+                       </releases>
+               </repository>
+               <repository>
+                       <id>argeo-rcp</id>
+                       <url>http://forge.argeo.org/data/java/argeo-rcp-2.1</url>
+                       <releases>
+                               <enabled>true</enabled>
+                               <updatePolicy>daily</updatePolicy>
+                               <checksumPolicy>warn</checksumPolicy>
+                       </releases>
+               </repository>
+
+               <!-- Disable Maven default repository -->
+               <repository>
+                       <id>central</id>
+                       <url>http://repo1.maven.org/maven2</url>
+                       <releases>
+                               <enabled>false</enabled>
+                       </releases>
+                       <snapshots>
+                               <enabled>false</enabled>
+                       </snapshots>
+               </repository>
+       </repositories>
+       <profiles>
+               <profile>
+                       <id>localrepo</id>
+                       <repositories>
+                               <repository>
+                                       <id>argeo-tp</id>
+                                       <url>http://localhost:7070/data/java/argeo-${developmentCycle.argeo-commons}</url>
+                                       <releases>
+                                               <enabled>true</enabled>
+                                               <updatePolicy>daily</updatePolicy>
+                                               <checksumPolicy>warn</checksumPolicy>
+                                       </releases>
+                               </repository>
+                               <!-- <repository> -->
+                               <!-- <id>argeo-tp-extras</id> -->
+                               <!-- <url>http://localhost:7080/data/java/argeo-tp-extras-2.1</url> -->
+                               <!-- <releases> -->
+                               <!-- <enabled>true</enabled> -->
+                               <!-- <updatePolicy>daily</updatePolicy> -->
+                               <!-- <checksumPolicy>warn</checksumPolicy> -->
+                               <!-- </releases> -->
+                               <!-- </repository> -->
+                               <repository>
+                                       <id>argeo-commons</id>
+                                       <url>http://localhost:7070/data/java/argeo-${developmentCycle.argeo-commons}</url>
+                                       <releases>
+                                               <enabled>true</enabled>
+                                               <updatePolicy>daily</updatePolicy>
+                                               <checksumPolicy>warn</checksumPolicy>
+                                       </releases>
+                               </repository>
+                       </repositories>
+                       <distributionManagement>
+                               <repository>
+                                       <id>staging</id>
+                                       <url>dav:http://localhost:7070/data/java/argeo-slc-${developmentCycle.slc}</url>
+                               </repository>
+                               <site>
+                                       <id>staging</id>
+                                       <url>dav:http://localhost:7070/data/docs/argeo-slc-${developmentCycle.slc}</url>
+                               </site>
+                       </distributionManagement>
+               </profile>
+       </profiles>
+</project>
diff --git a/org.argeo.slc.repo/pom.xml b/org.argeo.slc.repo/pom.xml
new file mode 100644 (file)
index 0000000..200b116
--- /dev/null
@@ -0,0 +1,37 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.repo</artifactId>
+       <name>SLC Repo</name>
+       <dependencies>
+               <!-- SLC API -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.api</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.jcr</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.cms</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+
+               <!-- BND -->
+               <dependency>
+                       <groupId>org.argeo.tp.sdk</groupId>
+                       <artifactId>biz.aQute.bndlib</artifactId>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/ArgeoOsgiDistribution.java
new file mode 100644 (file)
index 0000000..4b8878a
--- /dev/null
@@ -0,0 +1,11 @@
+package org.argeo.slc.repo;
+
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.build.ModularDistribution;
+
+/** Aether compatible OSGi distribution */
+public interface ArgeoOsgiDistribution extends Distribution,
+               CategoryNameVersion, ModularDistribution {
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactDistribution.java
new file mode 100644 (file)
index 0000000..bc496f1
--- /dev/null
@@ -0,0 +1,63 @@
+package org.argeo.slc.repo;
+
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.build.Distribution;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+/** A {@link Distribution} based on an Aether {@link Artifact} */
+public class ArtifactDistribution implements Distribution,
+               CategoryNameVersion {
+       private final Artifact artifact;
+
+       public ArtifactDistribution(Artifact artifact) {
+               this.artifact = artifact;
+       }
+
+       public ArtifactDistribution(String coords) {
+               this(new DefaultArtifact(coords));
+       }
+
+       /** Aether coordinates of the underlying artifact. */
+       public String getDistributionId() {
+               return artifact.toString();
+       }
+
+       public Artifact getArtifact() {
+               return artifact;
+       }
+
+       public String getName() {
+               return getArtifact().getArtifactId();
+       }
+
+       public String getVersion() {
+               return getArtifact().getVersion();
+       }
+
+       public String getCategory() {
+               return getArtifact().getGroupId();
+       }
+
+       @Override
+       public int hashCode() {
+               return artifact.hashCode();
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (obj instanceof CategoryNameVersion) {
+                       CategoryNameVersion cnv = (CategoryNameVersion) obj;
+                       return getCategory().equals(cnv.getCategory())
+                                       && getName().equals(cnv.getName())
+                                       && getVersion().equals(cnv.getVersion());
+               } else
+                       return artifact.equals(obj);
+       }
+
+       @Override
+       public String toString() {
+               return getDistributionId();
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactIndexer.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/ArtifactIndexer.java
new file mode 100644 (file)
index 0000000..037a7be
--- /dev/null
@@ -0,0 +1,256 @@
+package org.argeo.slc.repo;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.maven.AetherUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.osgi.framework.Constants;
+
+/**
+ * Add {@link Artifact} properties to a {@link Node}. Does nothing if the node
+ * name doesn't start with the artifact id (in order to skip Maven metadata XML
+ * files and other non artifact files).
+ */
+public class ArtifactIndexer implements NodeIndexer, SlcNames {
+       private Log log = LogFactory.getLog(ArtifactIndexer.class);
+       private Boolean force = false;
+
+       public Boolean support(String path) {
+               String relativePath = getRelativePath(path);
+               if (relativePath == null)
+                       return false;
+               Artifact artifact = null;
+               try {
+                       artifact = AetherUtils.convertPathToArtifact(relativePath, null);
+               } catch (Exception e) {
+                       if (log.isTraceEnabled())
+                               log.trace("Malformed path " + path + ", skipping silently", e);
+               }
+               return artifact != null;
+       }
+
+       public void index(Node fileNode) {
+               Artifact artifact = null;
+               try {
+                       if (!support(fileNode.getPath()))
+                               return;
+
+                       // Already indexed
+                       if (!force && fileNode.isNodeType(SlcTypes.SLC_ARTIFACT))
+                               return;
+
+                       if (!fileNode.isNodeType(NodeType.NT_FILE))
+                               return;
+
+                       String relativePath = getRelativePath(fileNode.getPath());
+                       if (relativePath == null)
+                               return;
+                       artifact = AetherUtils.convertPathToArtifact(relativePath, null);
+                       // support() guarantees that artifact won't be null, no NPE check
+                       fileNode.addMixin(SlcTypes.SLC_ARTIFACT);
+                       fileNode.setProperty(SlcNames.SLC_ARTIFACT_ID,
+                                       artifact.getArtifactId());
+                       fileNode.setProperty(SlcNames.SLC_GROUP_ID, artifact.getGroupId());
+                       fileNode.setProperty(SlcNames.SLC_ARTIFACT_VERSION,
+                                       artifact.getVersion());
+                       fileNode.setProperty(SlcNames.SLC_ARTIFACT_EXTENSION,
+                                       artifact.getExtension());
+                       // can be null but ok for JCR API
+                       fileNode.setProperty(SlcNames.SLC_ARTIFACT_CLASSIFIER,
+                                       artifact.getClassifier());
+                       JcrUtils.updateLastModified(fileNode);
+
+                       // make sure there are checksums
+                       String shaNodeName = fileNode.getName() + ".sha1";
+                       if (!fileNode.getParent().hasNode(shaNodeName)) {
+                               String sha = JcrUtils.checksumFile(fileNode, "SHA-1");
+                               JcrUtils.copyBytesAsFile(fileNode.getParent(), shaNodeName,
+                                               sha.getBytes());
+                       }
+                       String md5NodeName = fileNode.getName() + ".md5";
+                       if (!fileNode.getParent().hasNode(md5NodeName)) {
+                               String md5 = JcrUtils.checksumFile(fileNode, "MD5");
+                               JcrUtils.copyBytesAsFile(fileNode.getParent(), md5NodeName,
+                                               md5.getBytes());
+                       }
+
+                       // Create a default pom if none already exist
+                       String fileNodeName = fileNode.getName();
+                       String pomName = null;
+                       if (fileNodeName.endsWith(".jar"))
+                               pomName = fileNodeName.substring(0, fileNodeName.length()
+                                               - ".jar".length())
+                                               + ".pom";
+
+                       if (pomName != null && !fileNode.getParent().hasNode(pomName)) {
+                               String pom = generatePomForBundle(fileNode);
+                               Node pomNode = JcrUtils.copyBytesAsFile(fileNode.getParent(),
+                                               pomName, pom.getBytes());
+                               // corresponding check sums
+                               String sha = JcrUtils.checksumFile(pomNode, "SHA-1");
+                               JcrUtils.copyBytesAsFile(fileNode.getParent(), pomName
+                                               + ".sha1", sha.getBytes());
+                               String md5 = JcrUtils.checksumFile(fileNode, "MD5");
+                               JcrUtils.copyBytesAsFile(fileNode.getParent(),
+                                               pomName + ".md5", md5.getBytes());
+                       }
+
+                       // set higher levels
+                       Node artifactVersionBase = fileNode.getParent();
+                       if (!artifactVersionBase
+                                       .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+                               artifactVersionBase
+                                               .addMixin(SlcTypes.SLC_ARTIFACT_VERSION_BASE);
+                               artifactVersionBase.setProperty(SlcNames.SLC_ARTIFACT_VERSION,
+                                               artifact.getBaseVersion());
+                               artifactVersionBase.setProperty(SlcNames.SLC_ARTIFACT_ID,
+                                               artifact.getArtifactId());
+                               artifactVersionBase.setProperty(SlcNames.SLC_GROUP_ID,
+                                               artifact.getGroupId());
+                       }
+                       JcrUtils.updateLastModified(artifactVersionBase);
+
+                       // pom
+                       if (artifact.getExtension().equals("pom")) {
+                               // TODO read to make it a distribution
+                       }
+
+                       Node artifactBase = artifactVersionBase.getParent();
+                       if (!artifactBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
+                               artifactBase.addMixin(SlcTypes.SLC_ARTIFACT_BASE);
+                               artifactBase.setProperty(SlcNames.SLC_ARTIFACT_ID,
+                                               artifact.getArtifactId());
+                               artifactBase.setProperty(SlcNames.SLC_GROUP_ID,
+                                               artifact.getGroupId());
+                       }
+                       JcrUtils.updateLastModified(artifactBase);
+
+                       Node groupBase = artifactBase.getParent();
+                       if (!groupBase.isNodeType(SlcTypes.SLC_GROUP_BASE)) {
+                               // if (groupBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
+                               // log.warn("Group base " + groupBase.getPath()
+                               // + " is also artifact base");
+                               // }
+                               groupBase.addMixin(SlcTypes.SLC_GROUP_BASE);
+                               groupBase.setProperty(SlcNames.SLC_GROUP_BASE_ID,
+                                               artifact.getGroupId());
+                       }
+                       JcrUtils.updateLastModifiedAndParents(groupBase,
+                                       RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH);
+
+                       if (log.isTraceEnabled())
+                               log.trace("Indexed artifact " + artifact + " on " + fileNode);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot index artifact " + artifact
+                                       + " metadata on node " + fileNode, e);
+               }
+       }
+
+       private String getRelativePath(String nodePath) {
+               String basePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
+               if (!nodePath.startsWith(basePath))
+                       return null;
+               String relativePath = nodePath.substring(basePath.length());
+               return relativePath;
+       }
+
+       public void setForce(Boolean force) {
+               this.force = force;
+       }
+
+       private String generatePomForBundle(Node n) throws RepositoryException {
+               StringBuffer p = new StringBuffer();
+               p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+               p.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
+               p.append("<modelVersion>4.0.0</modelVersion>");
+
+               // Categorized name version
+               p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
+                               .append("</groupId>\n");
+               p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
+                               .append("</artifactId>\n");
+               p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
+                               .append("</version>\n");
+               // TODO make it more generic
+               p.append("<packaging>jar</packaging>\n");
+               if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
+                       p.append("<name>")
+                                       .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
+                                       .append("</name>\n");
+               if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
+                       p.append("<description>")
+                                       .append(JcrUtils
+                                                       .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
+                                       .append("</description>\n");
+
+               // Dependencies in case of a distribution
+               if (n.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION)) {
+                       p.append(getDependenciesSnippet(n.getNode(SlcNames.SLC_MODULES)
+                                       .getNodes()));
+                       p.append(getDependencyManagementSnippet(n.getNode(
+                                       SlcNames.SLC_MODULES).getNodes()));
+               }
+               p.append("</project>\n");
+               return p.toString();
+       }
+
+       private String getDependenciesSnippet(NodeIterator nit)
+                       throws RepositoryException {
+               StringBuilder b = new StringBuilder();
+               b.append("<dependencies>\n");
+               while (nit.hasNext()) {
+                       Node currModule = nit.nextNode();
+                       if (currModule.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
+                               b.append(getDependencySnippet(
+                                               currModule.getProperty(SlcNames.SLC_CATEGORY)
+                                                               .getString(),
+                                               currModule.getProperty(SlcNames.SLC_NAME).getString(),
+                                               null));
+                       }
+               }
+               b.append("</dependencies>\n");
+               return b.toString();
+       }
+
+       private String getDependencyManagementSnippet(NodeIterator nit)
+                       throws RepositoryException {
+               StringBuilder b = new StringBuilder();
+               b.append("<dependencyManagement>\n");
+               b.append("<dependencies>\n");
+               while (nit.hasNext()) {
+                       Node currModule = nit.nextNode();
+                       if (currModule.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
+                               b.append(getDependencySnippet(
+                                               currModule.getProperty(SlcNames.SLC_CATEGORY)
+                                                               .getString(),
+                                               currModule.getProperty(SlcNames.SLC_NAME).getString(),
+                                               currModule.getProperty(SlcNames.SLC_VERSION)
+                                                               .getString()));
+                       }
+               }
+               b.append("</dependencies>\n");
+               b.append("</dependencyManagement>\n");
+               return b.toString();
+       }
+
+       private String getDependencySnippet(String category, String name,
+                       String version) {
+               StringBuilder b = new StringBuilder();
+               b.append("<dependency>\n");
+               b.append("\t<groupId>").append(category).append("</groupId>\n");
+               b.append("\t<artifactId>").append(name).append("</artifactId>\n");
+               if (version != null)
+                       b.append("\t<version>").append(version).append("</version>\n");
+               b.append("</dependency>\n");
+               return b.toString();
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/FreeLicense.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/FreeLicense.java
new file mode 100644 (file)
index 0000000..1b83666
--- /dev/null
@@ -0,0 +1,166 @@
+package org.argeo.slc.repo;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.build.License;
+
+/** A free software license */
+public abstract class FreeLicense implements License {
+       final static String RESOURCES = "/org/argeo/slc/repo/license/";
+
+       /** GNU */
+       public final static FreeLicense GPL_v3 = new FreeLicense(
+                       "GNU General Public License, version 3.0",
+                       "http://www.gnu.org/licenses/gpl-3.0.txt",
+                       "http://www.gnu.org/licenses/", RESOURCES + "gpl-3.0.txt") {
+       };
+
+       public final static FreeLicense GPL_v2 = new FreeLicense(
+                       "GNU General Public License, version 2.0",
+                       "http://www.gnu.org/licenses/gpl-2.0.txt",
+                       "http://www.gnu.org/licenses/", RESOURCES + "gpl-2.0.txt") {
+       };
+       public final static FreeLicense GPL = GPL_v3;
+
+       public final static FreeLicense LGPL_v3 = new FreeLicense(
+                       "GNU Lesser General Public License, version 3.0",
+                       "http://www.gnu.org/licenses/lgpl-3.0.txt",
+                       "http://www.gnu.org/licenses/", RESOURCES + "lgpl-3.0.txt") {
+       };
+
+       public final static FreeLicense LGPL_v2 = new FreeLicense(
+                       "GNU Lesser General Public License, version 2.1",
+                       "http://www.gnu.org/licenses/lgpl-2.1.txt",
+                       "http://www.gnu.org/licenses/", RESOURCES + "lgpl-2.1.txt") {
+       };
+       public final static FreeLicense LGPL = LGPL_v3;
+
+       /** Apache */
+       public final static FreeLicense APACHE_v2 = new FreeLicense(
+                       "Apache License, Version 2.0",
+                       "http://www.apache.org/licenses/LICENSE-2.0.txt",
+                       "http://www.apache.org/licenses/", RESOURCES + "apache-2.0.txt") {
+       };
+       public final static FreeLicense APACHE = APACHE_v2;
+
+       /** Eclipse */
+       public final static FreeLicense EPL_v1 = new FreeLicense(
+                       "Eclipse Public License, Version 1.0",
+                       "http://www.eclipse.org/legal/epl-v10.html",
+                       "http://www.eclipse.org/legal/eplfaq.php", RESOURCES
+                                       + "epl-1.0.txt") {
+       };
+       public final static FreeLicense EPL = EPL_v1;
+
+       /** Miscellaneous */
+       public final static FreeLicense MIT = new FreeLicense("The MIT License",
+                       "http://opensource.org/licenses/MIT", null, RESOURCES + "mit.txt") {
+       };
+
+       public final static FreeLicense BSD_NEW = new FreeLicense(
+                       "The BSD 3-Clause License",
+                       "http://opensource.org/licenses/BSD-3-Clause", null, RESOURCES
+                                       + "bsd-3-clause.txt") {
+       };
+
+       public final static FreeLicense BSD = BSD_NEW;
+
+       public final static FreeLicense CDDL_v1 = new FreeLicense(
+                       "Common Development and Distribution License",
+                       "http://opensource.org/licenses/CDDL-1.0", null, RESOURCES
+                                       + "cddl-1.0.txt") {
+       };
+       public final static FreeLicense CDDL = CDDL_v1;
+
+       /** Public domain corner case */
+       public final static License PUBLIC_DOMAIN = new License() {
+
+               public String getUri() {
+                       return "http://creativecommons.org/about/pdm";
+               }
+
+               public String getText() {
+                       return "This work is free of known copyright restrictions.";
+               }
+
+               public String getName() {
+                       return "Public Domain License";
+               }
+
+               public String getLink() {
+                       return "http://wiki.creativecommons.org/PDM_FAQ";
+               }
+       };
+
+       private final String name, uri, link, resource;
+
+       public FreeLicense(String name, String uri) {
+               this(name, uri, null, null);
+       }
+
+       public FreeLicense(String name, String uri, String link) {
+               this(name, uri, link, null);
+       }
+
+       public FreeLicense(String name, String uri, String link, String resource) {
+               if (uri == null)
+                       throw new SlcException("URI cannot be null");
+               this.name = name;
+               this.uri = uri;
+               this.link = link;
+               this.resource = resource;
+               getText();
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public String getUri() {
+               return uri;
+       }
+
+       public String getLink() {
+               return link;
+       }
+
+       @Override
+       public String getText() {
+               InputStream in = null;
+               URL url = null;
+               try {
+                       if (resource != null)
+                               url = getClass().getClassLoader().getResource(resource);
+                       else
+                               url = new URL(uri);
+                       in = url.openStream();
+                       String text = IOUtils.toString(in);
+                       return text;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot retrieve license " + name + " from "
+                                       + url, e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+               }
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (!(obj instanceof License))
+                       return false;
+               return ((License) obj).getUri().equals(getUri());
+       }
+
+       @Override
+       public int hashCode() {
+               return getUri().hashCode();
+       }
+
+       @Override
+       public String toString() {
+               return name + " (" + uri + ")";
+       }
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/JarFileIndexer.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/JarFileIndexer.java
new file mode 100644 (file)
index 0000000..95fa918
--- /dev/null
@@ -0,0 +1,483 @@
+package org.argeo.slc.repo;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+import java.util.jar.Attributes;
+import java.util.jar.Attributes.Name;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+
+/**
+ * Indexes jar file, currently supports standard J2SE and OSGi metadata (both
+ * from MANIFEST)
+ */
+public class JarFileIndexer implements NodeIndexer, SlcNames {
+       private final static Log log = LogFactory.getLog(JarFileIndexer.class);
+       private Boolean force = false;
+
+       public Boolean support(String path) {
+               return FilenameUtils.getExtension(path).equals("jar");
+       }
+
+       public void index(Node fileNode) {
+               Binary fileBinary = null;
+               JarInputStream jarIn = null;
+               ByteArrayOutputStream bo = null;
+               ByteArrayInputStream bi = null;
+               Binary manifestBinary = null;
+               try {
+                       if (!support(fileNode.getPath()))
+                               return;
+
+                       // Already indexed
+                       if (!force && fileNode.isNodeType(SlcTypes.SLC_JAR_FILE))
+                               return;
+
+                       if (!fileNode.isNodeType(NodeType.NT_FILE))
+                               return;
+
+                       Session jcrSession = fileNode.getSession();
+                       Node contentNode = fileNode.getNode(Node.JCR_CONTENT);
+                       fileBinary = contentNode.getProperty(Property.JCR_DATA).getBinary();
+
+                       jarIn = new JarInputStream(fileBinary.getStream());
+                       Manifest manifest = jarIn.getManifest();
+                       if (manifest == null) {
+                               log.error(fileNode + " has no MANIFEST");
+                               return;
+                       }
+
+                       bo = new ByteArrayOutputStream();
+                       manifest.write(bo);
+                       byte[] newManifest = bo.toByteArray();
+                       if (fileNode.hasProperty(SLC_MANIFEST)) {
+                               byte[] storedManifest = JcrUtils.getBinaryAsBytes(fileNode
+                                               .getProperty(SLC_MANIFEST));
+                               if (Arrays.equals(newManifest, storedManifest)) {
+                                       if (log.isTraceEnabled())
+                                               log.trace("Manifest not changed, doing nothing "
+                                                               + fileNode);
+                                       return;
+                               }
+                       }
+
+                       bi = new ByteArrayInputStream(newManifest);
+                       manifestBinary = jcrSession.getValueFactory().createBinary(bi);
+
+                       // standard jar file
+                       fileNode.addMixin(SlcTypes.SLC_JAR_FILE);
+
+                       fileNode.setProperty(SlcNames.SLC_MANIFEST, manifestBinary);
+                       Attributes attrs = manifest.getMainAttributes();
+
+                       getI18nValues(fileBinary, attrs);
+
+                       // standard J2SE MANIFEST attributes
+                       addAttr(Attributes.Name.MANIFEST_VERSION, fileNode, attrs);
+                       addAttr(Attributes.Name.SIGNATURE_VERSION, fileNode, attrs);
+                       addAttr(Attributes.Name.CLASS_PATH, fileNode, attrs);
+                       addAttr(Attributes.Name.MAIN_CLASS, fileNode, attrs);
+                       addAttr(Attributes.Name.EXTENSION_NAME, fileNode, attrs);
+                       addAttr(Attributes.Name.IMPLEMENTATION_VERSION, fileNode, attrs);
+                       addAttr(Attributes.Name.IMPLEMENTATION_VENDOR, fileNode, attrs);
+                       addAttr(Attributes.Name.IMPLEMENTATION_VENDOR_ID, fileNode, attrs);
+                       addAttr(Attributes.Name.SPECIFICATION_TITLE, fileNode, attrs);
+                       addAttr(Attributes.Name.SPECIFICATION_VERSION, fileNode, attrs);
+                       addAttr(Attributes.Name.SPECIFICATION_VENDOR, fileNode, attrs);
+                       addAttr(Attributes.Name.SEALED, fileNode, attrs);
+
+                       // OSGi
+                       if (attrs.containsKey(new Name(Constants.BUNDLE_SYMBOLICNAME))) {
+                               addOsgiMetadata(fileNode, attrs);
+                               if (log.isTraceEnabled())
+                                       log.trace("Indexed OSGi bundle " + fileNode);
+                       } else {
+                               if (log.isTraceEnabled())
+                                       log.trace("Indexed JAR file " + fileNode);
+                       }
+
+                       JcrUtils.updateLastModified(fileNode);
+
+               } catch (Exception e) {
+                       throw new SlcException("Cannot index jar " + fileNode, e);
+               } finally {
+                       IOUtils.closeQuietly(bi);
+                       IOUtils.closeQuietly(bo);
+                       IOUtils.closeQuietly(jarIn);
+                       JcrUtils.closeQuietly(manifestBinary);
+                       JcrUtils.closeQuietly(fileBinary);
+               }
+
+       }
+
+       private void getI18nValues(Binary fileBinary, Attributes attrs)
+                       throws IOException {
+               JarInputStream jarIn = null;
+               try {
+                       jarIn = new JarInputStream(fileBinary.getStream());
+                       String bundleLocalization = null;
+
+                       String blKey = Constants.BUNDLE_LOCALIZATION; // "Bundle-Localization";
+                       Name blkName = new Name(blKey);
+
+                       browse: for (Object obj : attrs.keySet()) {
+                               String value = attrs.getValue((Attributes.Name) obj);
+                               if (value.startsWith("%")) {
+                                       if (attrs.containsKey(blkName)) {
+                                               bundleLocalization = attrs.getValue(blkName);
+                                               break browse;
+                                       }
+                               }
+                       }
+
+                       JarEntry jarEntry = null;
+                       byte[] propBytes = null;
+                       ByteArrayOutputStream baos = null;
+                       browse: if (bundleLocalization != null) {
+                               JarEntry entry = jarIn.getNextJarEntry();
+                               while (entry != null) {
+                                       if (entry.getName().equals(
+                                                       bundleLocalization + ".properties")) {
+                                               jarEntry = entry;
+
+                                               // if(je.getSize() != -1){
+                                               // propBytes = new byte[(int)je.getSize()];
+                                               // int len = (int) je.getSize();
+                                               // int offset = 0;
+                                               // while (offset != len)
+                                               // offset += jarIn.read(propBytes, offset, len -
+                                               // offset);
+                                               // } else {
+                                               baos = new ByteArrayOutputStream();
+                                               while (true) {
+                                                       int qwe = jarIn.read();
+                                                       if (qwe == -1)
+                                                               break;
+                                                       baos.write(qwe);
+                                               }
+                                               propBytes = baos.toByteArray();
+                                               break browse;
+                                       }
+                                       entry = jarIn.getNextJarEntry();
+                               }
+                       }
+
+                       if (jarEntry != null) {
+                               Properties prop = new Properties();
+                               InputStream is = new ByteArrayInputStream(propBytes);
+                               prop.load(is);
+
+                               for (Object obj : attrs.keySet()) {
+                                       String value = attrs.getValue((Attributes.Name) obj);
+                                       if (value.startsWith("%")) {
+                                               String newVal = prop.getProperty(value.substring(1));
+                                               if (newVal != null)
+                                                       attrs.put(obj, newVal);
+                                       }
+                               }
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException(
+                                       "Error while reading the jar binary content " + fileBinary,
+                                       e);
+               } catch (IOException ioe) {
+                       throw new SlcException("unable to get internationalized values",
+                                       ioe);
+               } finally {
+                       IOUtils.closeQuietly(jarIn);
+               }
+       }
+
+       protected void addOsgiMetadata(Node fileNode, Attributes attrs)
+                       throws RepositoryException {
+
+               // TODO remove this ?
+               // Compulsory for the time being, because bundle artifact extends
+               // artifact
+               if (!fileNode.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                       ArtifactIndexer indexer = new ArtifactIndexer();
+                       indexer.index(fileNode);
+               }
+
+               fileNode.addMixin(SlcTypes.SLC_BUNDLE_ARTIFACT);
+
+               // symbolic name
+               String symbolicName = attrs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+               // make sure there is no directive
+               symbolicName = symbolicName.split(";")[0];
+               fileNode.setProperty(SlcNames.SLC_SYMBOLIC_NAME, symbolicName);
+
+               // direct mapping
+               addAttr(Constants.BUNDLE_SYMBOLICNAME, fileNode, attrs);
+               addAttr(Constants.BUNDLE_NAME, fileNode, attrs);
+               addAttr(Constants.BUNDLE_DESCRIPTION, fileNode, attrs);
+               addAttr(Constants.BUNDLE_MANIFESTVERSION, fileNode, attrs);
+               addAttr(Constants.BUNDLE_CATEGORY, fileNode, attrs);
+               addAttr(Constants.BUNDLE_ACTIVATIONPOLICY, fileNode, attrs);
+               addAttr(Constants.BUNDLE_COPYRIGHT, fileNode, attrs);
+               addAttr(Constants.BUNDLE_VENDOR, fileNode, attrs);
+               addAttr("Bundle-License", fileNode, attrs);
+               addAttr(Constants.BUNDLE_DOCURL, fileNode, attrs);
+               addAttr(Constants.BUNDLE_CONTACTADDRESS, fileNode, attrs);
+               addAttr(Constants.BUNDLE_ACTIVATOR, fileNode, attrs);
+               addAttr(Constants.BUNDLE_UPDATELOCATION, fileNode, attrs);
+               addAttr(Constants.BUNDLE_LOCALIZATION, fileNode, attrs);
+
+               // required execution environment
+               if (attrs.containsKey(new Name(
+                               Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)))
+                       fileNode.setProperty(SlcNames.SLC_
+                                       + Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, attrs
+                                       .getValue(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)
+                                       .split(","));
+
+               // bundle classpath
+               if (attrs.containsKey(new Name(Constants.BUNDLE_CLASSPATH)))
+                       fileNode.setProperty(SlcNames.SLC_ + Constants.BUNDLE_CLASSPATH,
+                                       attrs.getValue(Constants.BUNDLE_CLASSPATH).split(","));
+
+               // version
+               Version version = new Version(attrs.getValue(Constants.BUNDLE_VERSION));
+               fileNode.setProperty(SlcNames.SLC_BUNDLE_VERSION, version.toString());
+               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.BUNDLE_VERSION);
+               Node bundleVersionNode = fileNode.addNode(SlcNames.SLC_
+                               + Constants.BUNDLE_VERSION, SlcTypes.SLC_OSGI_VERSION);
+               mapOsgiVersion(version, bundleVersionNode);
+
+               // fragment
+               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.FRAGMENT_HOST);
+               if (attrs.containsKey(new Name(Constants.FRAGMENT_HOST))) {
+                       String fragmentHost = attrs.getValue(Constants.FRAGMENT_HOST);
+                       String[] tokens = fragmentHost.split(";");
+                       Node node = fileNode.addNode(SlcNames.SLC_
+                                       + Constants.FRAGMENT_HOST, SlcTypes.SLC_FRAGMENT_HOST);
+                       node.setProperty(SlcNames.SLC_SYMBOLIC_NAME, tokens[0]);
+                       for (int i = 1; i < tokens.length; i++) {
+                               if (tokens[i].startsWith(Constants.BUNDLE_VERSION_ATTRIBUTE)) {
+                                       node.setProperty(SlcNames.SLC_BUNDLE_VERSION,
+                                                       attributeValue(tokens[i]));
+                               }
+                       }
+               }
+
+               // imported packages
+               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.IMPORT_PACKAGE);
+               if (attrs.containsKey(new Name(Constants.IMPORT_PACKAGE))) {
+                       String importPackages = attrs.getValue(Constants.IMPORT_PACKAGE);
+                       List<String> packages = parseCommaSeparated(importPackages);
+                       for (String pkg : packages) {
+                               String[] tokens = pkg.split(";");
+                               Node node = fileNode.addNode(SlcNames.SLC_
+                                               + Constants.IMPORT_PACKAGE,
+                                               SlcTypes.SLC_IMPORTED_PACKAGE);
+                               node.setProperty(SlcNames.SLC_NAME, tokens[0]);
+                               for (int i = 1; i < tokens.length; i++) {
+                                       if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
+                                               node.setProperty(SlcNames.SLC_VERSION,
+                                                               attributeValue(tokens[i]));
+                                       } else if (tokens[i]
+                                                       .startsWith(Constants.RESOLUTION_DIRECTIVE)) {
+                                               node.setProperty(
+                                                               SlcNames.SLC_OPTIONAL,
+                                                               directiveValue(tokens[i]).equals(
+                                                                               Constants.RESOLUTION_OPTIONAL));
+                                       }
+                               }
+                       }
+               }
+
+               // dynamic import package
+               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.DYNAMICIMPORT_PACKAGE);
+               if (attrs.containsKey(new Name(Constants.DYNAMICIMPORT_PACKAGE))) {
+                       String importPackages = attrs
+                                       .getValue(Constants.DYNAMICIMPORT_PACKAGE);
+                       List<String> packages = parseCommaSeparated(importPackages);
+                       for (String pkg : packages) {
+                               String[] tokens = pkg.split(";");
+                               Node node = fileNode.addNode(SlcNames.SLC_
+                                               + Constants.DYNAMICIMPORT_PACKAGE,
+                                               SlcTypes.SLC_DYNAMIC_IMPORTED_PACKAGE);
+                               node.setProperty(SlcNames.SLC_NAME, tokens[0]);
+                               for (int i = 1; i < tokens.length; i++) {
+                                       if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
+                                               node.setProperty(SlcNames.SLC_VERSION,
+                                                               attributeValue(tokens[i]));
+                                       }
+                               }
+                       }
+               }
+
+               // exported packages
+               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.EXPORT_PACKAGE);
+               if (attrs.containsKey(new Name(Constants.EXPORT_PACKAGE))) {
+                       String exportPackages = attrs.getValue(Constants.EXPORT_PACKAGE);
+                       List<String> packages = parseCommaSeparated(exportPackages);
+                       for (String pkg : packages) {
+                               String[] tokens = pkg.split(";");
+                               Node node = fileNode.addNode(SlcNames.SLC_
+                                               + Constants.EXPORT_PACKAGE,
+                                               SlcTypes.SLC_EXPORTED_PACKAGE);
+                               node.setProperty(SlcNames.SLC_NAME, tokens[0]);
+                               // TODO: are these cleans really necessary?
+                               cleanSubNodes(node, SlcNames.SLC_USES);
+                               cleanSubNodes(node, SlcNames.SLC_VERSION);
+                               for (int i = 1; i < tokens.length; i++) {
+                                       if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
+                                               String versionStr = attributeValue(tokens[i]);
+                                               Node versionNode = node.addNode(SlcNames.SLC_VERSION,
+                                                               SlcTypes.SLC_OSGI_VERSION);
+                                               mapOsgiVersion(new Version(versionStr), versionNode);
+                                       } else if (tokens[i].startsWith(Constants.USES_DIRECTIVE)) {
+                                               String usedPackages = directiveValue(tokens[i]);
+                                               // log.debug("uses='" + usedPackages + "'");
+                                               for (String usedPackage : usedPackages.split(",")) {
+                                                       // log.debug("usedPackage='" +
+                                                       // usedPackage +
+                                                       // "'");
+                                                       Node usesNode = node.addNode(SlcNames.SLC_USES,
+                                                                       SlcTypes.SLC_JAVA_PACKAGE);
+                                                       usesNode.setProperty(SlcNames.SLC_NAME, usedPackage);
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               // required bundle
+               cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.REQUIRE_BUNDLE);
+               if (attrs.containsKey(new Name(Constants.REQUIRE_BUNDLE))) {
+                       String requireBundle = attrs.getValue(Constants.REQUIRE_BUNDLE);
+                       List<String> bundles = parseCommaSeparated(requireBundle);
+                       for (String bundle : bundles) {
+                               String[] tokens = bundle.split(";");
+                               Node node = fileNode.addNode(SlcNames.SLC_
+                                               + Constants.REQUIRE_BUNDLE,
+                                               SlcTypes.SLC_REQUIRED_BUNDLE);
+                               node.setProperty(SlcNames.SLC_SYMBOLIC_NAME, tokens[0]);
+                               for (int i = 1; i < tokens.length; i++) {
+                                       if (tokens[i]
+                                                       .startsWith(Constants.BUNDLE_VERSION_ATTRIBUTE)) {
+                                               node.setProperty(SlcNames.SLC_BUNDLE_VERSION,
+                                                               attributeValue(tokens[i]));
+                                       } else if (tokens[i]
+                                                       .startsWith(Constants.RESOLUTION_DIRECTIVE)) {
+                                               node.setProperty(
+                                                               SlcNames.SLC_OPTIONAL,
+                                                               directiveValue(tokens[i]).equals(
+                                                                               Constants.RESOLUTION_OPTIONAL));
+                                       }
+                               }
+                       }
+               }
+
+       }
+
+       private void addAttr(String key, Node node, Attributes attrs)
+                       throws RepositoryException {
+               addAttr(new Name(key), node, attrs);
+       }
+
+       private void addAttr(Name key, Node node, Attributes attrs)
+                       throws RepositoryException {
+               if (attrs.containsKey(key)) {
+                       String value = attrs.getValue(key);
+                       node.setProperty(SlcNames.SLC_ + key, value);
+               }
+       }
+
+       private void cleanSubNodes(Node node, String name)
+                       throws RepositoryException {
+               if (node.hasNode(name)) {
+                       NodeIterator nit = node.getNodes(name);
+                       while (nit.hasNext())
+                               nit.nextNode().remove();
+               }
+       }
+
+       private String attributeValue(String str) {
+               return extractValue(str, "=");
+       }
+
+       private String directiveValue(String str) {
+               return extractValue(str, ":=");
+       }
+
+       private String extractValue(String str, String eq) {
+               String[] tokens = str.split(eq);
+               // String key = tokens[0];
+               String value = tokens[1].trim();
+               // TODO: optimize?
+               if (value.startsWith("\""))
+                       value = value.substring(1);
+               if (value.endsWith("\""))
+                       value = value.substring(0, value.length() - 1);
+               return value;
+       }
+
+       /** Parse package list with nested directive with ',' */
+       private List<String> parseCommaSeparated(String str) {
+               List<String> res = new ArrayList<String>();
+               StringBuffer curr = new StringBuffer("");
+               boolean in = false;
+               for (char c : str.toCharArray()) {
+                       if (c == ',') {
+                               if (!in) {// new package
+                                       res.add(curr.toString());
+                                       curr = new StringBuffer("");
+                               } else {// a ',' within " "
+                                       curr.append(c);
+                               }
+                       } else if (c == '\"') {
+                               in = !in;
+                               curr.append(c);
+                       } else {
+                               curr.append(c);
+                       }
+               }
+               res.add(curr.toString());
+               // log.debug(res);
+               return res;
+       }
+
+       protected void mapOsgiVersion(Version version, Node versionNode)
+                       throws RepositoryException {
+               versionNode.setProperty(SlcNames.SLC_AS_STRING, version.toString());
+               versionNode.setProperty(SlcNames.SLC_MAJOR, version.getMajor());
+               versionNode.setProperty(SlcNames.SLC_MINOR, version.getMinor());
+               versionNode.setProperty(SlcNames.SLC_MICRO, version.getMicro());
+               if (!version.getQualifier().equals(""))
+                       versionNode.setProperty(SlcNames.SLC_QUALIFIER,
+                                       version.getQualifier());
+       }
+
+       public void setForce(Boolean force) {
+               this.force = force;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/JavaRepoManager.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/JavaRepoManager.java
new file mode 100644 (file)
index 0000000..4d7c3ef
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.repo;
+
+/** Java-specific operations */
+public interface JavaRepoManager {
+       public void createWorkspace(String workspaceName);
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/MavenProxyService.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/MavenProxyService.java
new file mode 100644 (file)
index 0000000..81261fe
--- /dev/null
@@ -0,0 +1,7 @@
+package org.argeo.slc.repo;
+
+import org.argeo.jcr.proxy.ResourceProxy;
+
+/** Marker interface (useful for OSGi servcies references), maybe extended later */
+public interface MavenProxyService extends ResourceProxy {
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionFactory.java
new file mode 100644 (file)
index 0000000..19627d8
--- /dev/null
@@ -0,0 +1,519 @@
+package org.argeo.slc.repo;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.osgi.framework.Constants;
+
+/**
+ * Creates a jar bundle from an ArgeoOsgiDistribution. This jar is then
+ * persisted and indexed in a java repository using the OSGI Factory.
+ * 
+ * It does the following <list>
+ * <li>Creates a Manifest</li>
+ * <li>Creates files indexes (csv, feature.xml ...)</li>
+ * <li>Populate the corresponding jar</li>
+ * <li>Save it in the repository</li>
+ * <li>Index the node and creates corresponding sha1 and md5 files</li> </list>
+ * 
+ */
+public class ModularDistributionFactory implements Runnable {
+
+       private OsgiFactory osgiFactory;
+       private Session javaSession;
+       private ArgeoOsgiDistribution osgiDistribution;
+       private String modularDistributionSeparator = ",";
+       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
+       private String artifactType = "jar";
+
+       // Constants
+       private final static String CSV_FILE_NAME = "modularDistribution.csv";
+       private final DateFormat snapshotTimestamp = new SimpleDateFormat("YYYYMMddhhmm");
+
+       // private final static String FEATURE_FILE_NAME = "feature.xml";
+       // private static int BUFFER_SIZE = 10240;
+
+       /** Convenience constructor with minimal configuration */
+       public ModularDistributionFactory(OsgiFactory osgiFactory, ArgeoOsgiDistribution osgiDistribution) {
+               this.osgiFactory = osgiFactory;
+               this.osgiDistribution = osgiDistribution;
+       }
+
+       @Override
+       public void run() {
+               byte[] distFile = null;
+               try {
+                       javaSession = osgiFactory.openJavaSession();
+
+                       if (artifactType == "jar")
+                               distFile = generateJarFile();
+                       else if (artifactType == "pom")
+                               distFile = generatePomFile();
+                       else
+                               throw new SlcException("Unimplemented distribution artifact type: " + artifactType + " for "
+                                               + osgiDistribution.toString());
+
+                       // Save in java repository
+                       Artifact osgiArtifact = new DefaultArtifact(osgiDistribution.getCategory(), osgiDistribution.getName(),
+                                       artifactType, osgiDistribution.getVersion());
+
+                       Node distNode = RepoUtils.copyBytesAsArtifact(javaSession.getNode(artifactBasePath), osgiArtifact,
+                                       distFile);
+
+                       // index
+                       osgiFactory.indexNode(distNode);
+
+                       // We use a specific session. Save before closing
+                       javaSession.save();
+               } catch (RepositoryException e) {
+                       throw new SlcException(
+                                       "JCR error while persisting modular distribution in JCR " + osgiDistribution.toString(), e);
+               } finally {
+                       JcrUtils.logoutQuietly(javaSession);
+               }
+       }
+
+       private byte[] generateJarFile() {
+               ByteArrayOutputStream byteOut = null;
+               JarOutputStream jarOut = null;
+               try {
+                       byteOut = new ByteArrayOutputStream();
+                       jarOut = new JarOutputStream(byteOut, createManifest());
+                       // Create various indexes
+                       addToJar(createCsvDescriptor(), CSV_FILE_NAME, jarOut);
+                       jarOut.close();
+                       return byteOut.toByteArray();
+               } catch (IOException e) {
+                       throw new SlcException("IO error while generating modular distribution " + osgiDistribution.toString(), e);
+               } finally {
+                       IOUtils.closeQuietly(byteOut);
+                       IOUtils.closeQuietly(jarOut);
+               }
+       }
+
+       // private void indexDistribution(Node distNode) throws RepositoryException
+       // {
+       // distNode.addMixin(SlcTypes.SLC_MODULAR_DISTRIBUTION);
+       // distNode.addMixin(SlcTypes.SLC_CATEGORIZED_NAME_VERSION);
+       // distNode.setProperty(SlcNames.SLC_CATEGORY,
+       // osgiDistribution.getCategory());
+       // distNode.setProperty(SlcNames.SLC_NAME, osgiDistribution.getName());
+       // distNode.setProperty(SlcNames.SLC_VERSION,
+       // osgiDistribution.getVersion());
+       //
+       // if (distNode.hasNode(SlcNames.SLC_MODULES))
+       // distNode.getNode(SlcNames.SLC_MODULES).remove();
+       // Node modules = distNode.addNode(SlcNames.SLC_MODULES,
+       // NodeType.NT_UNSTRUCTURED);
+       //
+       // for (Iterator<? extends NameVersion> it = osgiDistribution
+       // .nameVersions(); it.hasNext();)
+       // addModule(modules, it.next());
+       // }
+
+       private Manifest createManifest() {
+               Manifest manifest = new Manifest();
+
+               // TODO make this configurable
+               manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+//             addManifestAttribute(manifest, Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-1.8");
+               addManifestAttribute(manifest, Constants.BUNDLE_VENDOR, "Argeo");
+               addManifestAttribute(manifest, Constants.BUNDLE_MANIFESTVERSION, "2");
+//             addManifestAttribute(manifest, "Bundle-License", "http://www.apache.org/licenses/LICENSE-2.0.txt");
+
+               // TODO define a user friendly name
+               addManifestAttribute(manifest, Constants.BUNDLE_NAME, osgiDistribution.getName());
+
+               // Categorized name version
+               addManifestAttribute(manifest, RepoConstants.SLC_CATEGORY_ID, osgiDistribution.getCategory());
+               addManifestAttribute(manifest, Constants.BUNDLE_SYMBOLICNAME, osgiDistribution.getName());
+               String version = osgiDistribution.getVersion();
+               if (version.endsWith("-SNAPSHOT")) {
+                       version = version.substring(0, version.length() - "-SNAPSHOT".length());
+                       version = version + ".SNAPSHOT-r" + snapshotTimestamp.format(new Date());
+               }
+               addManifestAttribute(manifest, Constants.BUNDLE_VERSION, version);
+
+               return manifest;
+       }
+
+       private void addManifestAttribute(Manifest manifest, String name, String value) {
+               manifest.getMainAttributes().put(new Attributes.Name(name), value);
+       }
+
+       private byte[] createCsvDescriptor() {
+               Writer writer = null;
+               try {
+                       // FIXME remove use of tmp file.
+                       File tmpFile = File.createTempFile("modularDistribution", "csv");
+                       tmpFile.deleteOnExit();
+                       writer = new FileWriter(tmpFile);
+                       // Populate the file
+                       for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();)
+                               writer.write(getCsvLine(it.next()));
+                       writer.flush();
+                       return FileUtils.readFileToByteArray(tmpFile);
+               } catch (Exception e) {
+                       throw new SlcException("unable to create csv distribution file for " + osgiDistribution.toString(), e);
+               } finally {
+                       IOUtils.closeQuietly(writer);
+               }
+       }
+
+       @SuppressWarnings("unused")
+       private byte[] createFeatureDescriptor() {
+               // Directly retrieved from Argeo maven plugin
+               // Does not work due to the lack of org.codehaus.plexus/plexus-archiver
+               // third party dependency
+
+               throw new SlcException("Unimplemented method");
+
+               // // protected void writeFeatureDescriptor() throws
+               // MojoExecutionException {
+               // File featureDesc = File.createTempFile("feature", "xml");
+               // featureDesc.deleteOnExit();
+               //
+               // Writer writer = null;
+               // try {
+               // writer = new FileWriter(featureDesc);
+               // PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
+               // xmlWriter.startElement("feature");
+               // xmlWriter.addAttribute("id", project.getArtifactId());
+               // xmlWriter.addAttribute("label", project.getName());
+               //
+               // // Version
+               // String projectVersion = project.getVersion();
+               // int indexSnapshot = projectVersion.indexOf("-SNAPSHOT");
+               // if (indexSnapshot > -1)
+               // projectVersion = projectVersion.substring(0, indexSnapshot);
+               // projectVersion = projectVersion + ".qualifier";
+               //
+               // // project.
+               // xmlWriter.addAttribute("version", projectVersion);
+               //
+               // Organization organization = project.getOrganization();
+               // if (organization != null && organization.getName() != null)
+               // xmlWriter.addAttribute("provider-name", organization.getName());
+               //
+               // if (project.getDescription() != null || project.getUrl() != null) {
+               // xmlWriter.startElement("description");
+               // if (project.getUrl() != null)
+               // xmlWriter.addAttribute("url", project.getUrl());
+               // if (project.getDescription() != null)
+               // xmlWriter.writeText(project.getDescription());
+               // xmlWriter.endElement();// description
+               // }
+               //
+               // if (feature != null && feature.getCopyright() != null
+               // || (organization != null && organization.getUrl() != null)) {
+               // xmlWriter.startElement("copyright");
+               // if (organization != null && organization.getUrl() != null)
+               // xmlWriter.addAttribute("url", organization.getUrl());
+               // if (feature.getCopyright() != null)
+               // xmlWriter.writeText(feature.getCopyright());
+               // xmlWriter.endElement();// copyright
+               // }
+               //
+               // if (feature != null && feature.getUpdateSite() != null) {
+               // xmlWriter.startElement("url");
+               // xmlWriter.startElement("update");
+               // xmlWriter.addAttribute("url", feature.getUpdateSite());
+               // xmlWriter.endElement();// update
+               // xmlWriter.endElement();// url
+               // }
+               //
+               // List licenses = project.getLicenses();
+               // if (licenses.size() > 0) {
+               // // take the first one
+               // License license = (License) licenses.get(0);
+               // xmlWriter.startElement("license");
+               //
+               // if (license.getUrl() != null)
+               // xmlWriter.addAttribute("url", license.getUrl());
+               // if (license.getComments() != null)
+               // xmlWriter.writeText(license.getComments());
+               // else if (license.getName() != null)
+               // xmlWriter.writeText(license.getName());
+               // xmlWriter.endElement();// license
+               // }
+               //
+               // // deploymentRepository.pathOf(null);
+               // if (jarDirectory == null) {
+               // Set dependencies = mavenDependencyManager
+               // .getTransitiveProjectDependencies(project, remoteRepos,
+               // local);
+               // // // protected void writeFeatureDescriptor() throws
+               // MojoExecutionException {
+               // File featureDesc = File.createTempFile("feature", "xml");
+               // featureDesc.deleteOnExit();
+               //
+               // Writer writer = null;
+               // try {
+               // writer = new FileWriter(featureDesc);
+               // PrettyPrintXMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
+               // xmlWriter.startElement("feature");
+               // xmlWriter.addAttribute("id", project.getArtifactId());
+               // xmlWriter.addAttribute("label", project.getName());
+               //
+               // // Version
+               // String projectVersion = project.getVersion();
+               // int indexSnapshot = projectVersion.indexOf("-SNAPSHOT");
+               // if (indexSnapshot > -1)
+               // projectVersion = projectVersion.substring(0, indexSnapshot);
+               // projectVersion = projectVersion + ".qualifier";
+               //
+               // // project.
+               // xmlWriter.addAttribute("version", projectVersion);
+               //
+               // Organization organization = project.getOrganization();
+               // if (organization != null && organization.getName() != null)
+               // xmlWriter.addAttribute("provider-name", organization.getName());
+               //
+               // if (project.getDescription() != null || project.getUrl() != null) {
+               // xmlWriter.startElement("description");
+               // if (project.getUrl() != null)
+               // xmlWriter.addAttribute("url", project.getUrl());
+               // if (project.getDescription() != null)
+               // xmlWriter.writeText(project.getDescription());
+               // xmlWriter.endElement();// description
+               // }
+               //
+               // if (feature != null && feature.getCopyright() != null
+               // || (organization != null && organization.getUrl() != null)) {
+               // xmlWriter.startElement("copyright");
+               // if (organization != null && organization.getUrl() != null)
+               // xmlWriter.addAttribute("url", organization.getUrl());
+               // if (feature.getCopyright() != null)
+               // xmlWriter.writeText(feature.getCopyright());
+               // xmlWriter.endElement();// copyright
+               // }
+               //
+               // if (feature != null && feature.getUpdateSite() != null) {
+               // xmlWriter.startElement("url");
+               // xmlWriter.startElement("update");
+               // xmlWriter.addAttribute("url", feature.getUpdateSite());
+               // xmlWriter.endElement();// update
+               // xmlWriter.endElement();// url
+               // }
+               //
+               // List licenses = project.getLicenses();
+               // if (licenses.size() > 0) {
+               // // take the first one
+               // License license = (License) licenses.get(0);
+               // xmlWriter.startElement("license");
+               //
+               // if (license.getUrl() != null)
+               // xmlWriter.addAttribute("url", license.getUrl());
+               // if (license.getComments() != null)
+               // xmlWriter.writeText(license.getComments());
+               // else if (license.getName() != null)
+               // xmlWriter.writeText(license.getName());
+               // xmlWriter.endElement();// license
+               // }
+               //
+               // // deploymentRepository.pathOf(null);
+               // if (jarDirectory == null) {
+               // Set dependencies = mavenDependencyManager
+               // .getTransitiveProjectDependencies(project, remoteRepos,
+               // local);
+               // for (Iterator it = dependencies.iterator(); it.hasNext();) {
+               // Artifact artifact = (Artifact) it.next();
+               // writeFeaturePlugin(xmlWriter, artifact.getFile());
+               // }
+               // } else {
+               // // TODO: filter jars
+               // File[] jars = jarDirectory.listFiles();
+               // if (jars == null)
+               // throw new MojoExecutionException("No jar found in "
+               // + jarDirectory);
+               // for (int i = 0; i < jars.length; i++) {
+               // writeFeaturePlugin(xmlWriter, jars[i]);
+               // }
+               // }
+               //
+               // xmlWriter.endElement();// feature
+               //
+               // if (getLog().isDebugEnabled())
+               // getLog().debug("Wrote Eclipse feature descriptor.");
+               // } catch (Exception e) {
+               // throw new MojoExecutionException("Cannot write feature descriptor",
+               // e);
+               // } finally {
+               // IOUtil.close(writer);
+               // }for (Iterator it = dependencies.iterator(); it.hasNext();) {
+               // Artifact artifact = (Artifact) it.next();
+               // writeFeaturePlugin(xmlWriter, artifact.getFile());
+               // }
+               // } else {
+               // // TODO: filter jars
+               // File[] jars = jarDirectory.listFiles();
+               // if (jars == null)
+               // throw new MojoExecutionException("No jar found in "
+               // + jarDirectory);
+               // for (int i = 0; i < jars.length; i++) {
+               // writeFeaturePlugin(xmlWriter, jars[i]);
+               // }
+               // }
+               //
+               // xmlWriter.endElement();// feature
+               //
+               // if (getLog().isDebugEnabled())
+               // getLog().debug("Wrote Eclipse feature descriptor.");
+               // } catch (Exception e) {
+               // throw new MojoExecutionException("Cannot write feature descriptor",
+               // e);
+               // } finally {
+               // IOUtil.close(writer);
+               // }
+       }
+
+       /** Create an Aether like distribution artifact */
+       private byte[] generatePomFile() {
+               StringBuilder b = new StringBuilder();
+               // XML header
+               b.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+               b.append(
+                               "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
+               b.append("<modelVersion>4.0.0</modelVersion>");
+
+               // Artifact
+               b.append("<groupId>").append(osgiDistribution.getCategory()).append("</groupId>\n");
+               b.append("<artifactId>").append(osgiDistribution.getName()).append("</artifactId>\n");
+               b.append("<version>").append(osgiDistribution.getVersion()).append("</version>\n");
+               b.append("<packaging>pom</packaging>\n");
+               // p.append("<name>").append("Bundle Name").append("</name>\n");
+               // p.append("<description>").append("Bundle
+               // Description").append("</description>\n");
+
+               // Dependencies
+               b.append("<dependencies>\n");
+               for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();) {
+                       NameVersion nameVersion = it.next();
+                       if (!(nameVersion instanceof CategoryNameVersion))
+                               throw new SlcException("Unsupported type " + nameVersion.getClass());
+                       CategoryNameVersion nv = (CategoryNameVersion) nameVersion;
+                       b.append(getDependencySnippet(nv, false));
+               }
+               b.append("</dependencies>\n");
+
+               // Dependency management
+               b.append("<dependencyManagement>\n");
+               b.append("<dependencies>\n");
+
+               for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();)
+                       b.append(getDependencySnippet((CategoryNameVersion) it.next(), true));
+               b.append("</dependencies>\n");
+               b.append("</dependencyManagement>\n");
+
+               b.append("</project>\n");
+               return b.toString().getBytes();
+       }
+
+       private String getDependencySnippet(CategoryNameVersion cnv, boolean includeVersion) { // , String type, String
+                                                                                                                                                                                               // scope
+               StringBuilder b = new StringBuilder();
+               b.append("<dependency>\n");
+               b.append("\t<groupId>").append(cnv.getCategory()).append("</groupId>\n");
+               b.append("\t<artifactId>").append(cnv.getName()).append("</artifactId>\n");
+               if (includeVersion)
+                       b.append("\t<version>").append(cnv.getVersion()).append("</version>\n");
+               // if (type!= null)
+               // p.append("\t<type>").append(type).append("</type>\n");
+               // if (type!= null)
+               // p.append("\t<scope>").append(scope).append("</scope>\n");
+               b.append("</dependency>\n");
+               return b.toString();
+       }
+
+       // Helpers
+       private void addToJar(byte[] content, String name, JarOutputStream target) throws IOException {
+               ByteArrayInputStream in = null;
+               try {
+                       target.putNextEntry(new JarEntry(name));
+                       in = new ByteArrayInputStream(content);
+                       byte[] buffer = new byte[1024];
+                       while (true) {
+                               int count = in.read(buffer);
+                               if (count == -1)
+                                       break;
+                               target.write(buffer, 0, count);
+                       }
+                       target.closeEntry();
+               } finally {
+                       IOUtils.closeQuietly(in);
+               }
+       }
+
+       private String getCsvLine(NameVersion nameVersion) throws RepositoryException {
+               if (!(nameVersion instanceof CategoryNameVersion))
+                       throw new SlcException("Unsupported type " + nameVersion.getClass());
+               CategoryNameVersion cnv = (CategoryNameVersion) nameVersion;
+               StringBuilder builder = new StringBuilder();
+
+               builder.append(cnv.getName());
+               builder.append(modularDistributionSeparator);
+               builder.append(nameVersion.getVersion());
+               builder.append(modularDistributionSeparator);
+               builder.append(cnv.getCategory().replace('.', '/'));
+               // MavenConventionsUtils.groupPath("", cnv.getCategory());
+               builder.append('/');
+               builder.append(cnv.getName());
+               builder.append('/');
+               builder.append(cnv.getVersion());
+               builder.append('/');
+               builder.append(cnv.getName());
+               builder.append('-');
+               builder.append(cnv.getVersion());
+               builder.append('.');
+               // TODO make this dynamic
+               builder.append("jar");
+               builder.append("\n");
+
+               return builder.toString();
+       }
+
+       /** Enable dependency injection */
+       public void setOsgiFactory(OsgiFactory osgiFactory) {
+               this.osgiFactory = osgiFactory;
+       }
+
+       public void setOsgiDistribution(ArgeoOsgiDistribution osgiDistribution) {
+               this.osgiDistribution = osgiDistribution;
+       }
+
+       public void setModularDistributionSeparator(String modularDistributionSeparator) {
+               this.modularDistributionSeparator = modularDistributionSeparator;
+       }
+
+       public void setArtifactBasePath(String artifactBasePath) {
+               this.artifactBasePath = artifactBasePath;
+       }
+
+       public void setArtifactType(String artifactType) {
+               this.artifactType = artifactType;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/ModularDistributionIndexer.java
new file mode 100644 (file)
index 0000000..77e8f84
--- /dev/null
@@ -0,0 +1,214 @@
+package org.argeo.slc.repo;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.DefaultCategoryNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.repo.maven.AetherUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.osgi.framework.Constants;
+
+/**
+ * Create or update JCR meta-data for an SLC Modular Distribution
+ * 
+ * Currently, following types are managed: <list>
+ * <li>* .jar: dependency artifacts with csv index</li>
+ * <li>@Deprecated : .pom: artifact (binaries) that indexes a group, the .pom
+ * file contains a tag "dependencyManagement" that list all modules</li> </list>
+ */
+public class ModularDistributionIndexer implements NodeIndexer, SlcNames {
+       private final static Log log = LogFactory.getLog(ModularDistributionIndexer.class);
+
+       // Constants for csv indexing
+       private final static String INDEX_FILE_NAME = "modularDistribution.csv";
+       private String separator = ",";
+
+       private Manifest manifest;
+
+       public Boolean support(String path) {
+               if (FilenameUtils.getExtension(path).equals("jar"))
+                       return true;
+               return false;
+       }
+
+       public void index(Node fileNode) {
+               Binary fileBinary = null;
+               try {
+                       String fileNodePath = fileNode.getPath();
+                       if (!support(fileNodePath))
+                               return;
+
+                       if (!fileNode.isNodeType(NodeType.NT_FILE))
+                               return;
+
+                       Node contentNode = fileNode.getNode(Node.JCR_CONTENT);
+                       fileBinary = contentNode.getProperty(Property.JCR_DATA).getBinary();
+
+                       MyModularDistribution currDist = null;
+                       if (FilenameUtils.getExtension(fileNode.getPath()).equals("jar"))
+                               currDist = listModulesFromCsvIndex(fileNode, fileBinary);
+
+                       if (fileNode.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION) || currDist == null
+                                       || !currDist.nameVersions().hasNext())
+                               return; // already indexed or no modules found
+                       else {
+                               fileNode.addMixin(SlcTypes.SLC_MODULAR_DISTRIBUTION);
+                               fileNode.addMixin(SlcTypes.SLC_CATEGORIZED_NAME_VERSION);
+                               if (currDist.getCategory() != null)
+                                       fileNode.setProperty(SLC_CATEGORY, currDist.getCategory());
+                               fileNode.setProperty(SLC_NAME, currDist.getName());
+                               fileNode.setProperty(SLC_VERSION, currDist.getVersion());
+                               indexDistribution(currDist, fileNode);
+                       }
+
+                       if (log.isTraceEnabled())
+                               log.trace("Indexed " + fileNode + " as modular distribution");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot list dependencies from " + fileNode, e);
+               } finally {
+                       JcrUtils.closeQuietly(fileBinary);
+               }
+       }
+
+       private void indexDistribution(ArgeoOsgiDistribution osgiDist, Node distNode) throws RepositoryException {
+               distNode.addMixin(SlcTypes.SLC_MODULAR_DISTRIBUTION);
+               distNode.addMixin(SlcTypes.SLC_CATEGORIZED_NAME_VERSION);
+               distNode.setProperty(SlcNames.SLC_CATEGORY, osgiDist.getCategory());
+               distNode.setProperty(SlcNames.SLC_NAME, osgiDist.getName());
+               distNode.setProperty(SlcNames.SLC_VERSION, osgiDist.getVersion());
+               if (distNode.hasNode(SLC_MODULES))
+                       distNode.getNode(SLC_MODULES).remove();
+               Node modules = distNode.addNode(SLC_MODULES, NodeType.NT_UNSTRUCTURED);
+
+               for (Iterator<? extends NameVersion> it = osgiDist.nameVersions(); it.hasNext();)
+                       addModule(modules, it.next());
+       }
+
+       // Helpers
+       private Node addModule(Node modules, NameVersion nameVersion) throws RepositoryException {
+               CategoryNameVersion cnv = (CategoryNameVersion) nameVersion;
+               Node moduleCoord = null;
+               moduleCoord = modules.addNode(cnv.getName(), SlcTypes.SLC_MODULE_COORDINATES);
+               moduleCoord.setProperty(SlcNames.SLC_CATEGORY, cnv.getCategory());
+               moduleCoord.setProperty(SlcNames.SLC_NAME, cnv.getName());
+               moduleCoord.setProperty(SlcNames.SLC_VERSION, cnv.getVersion());
+               return moduleCoord;
+       }
+
+       private MyModularDistribution listModulesFromCsvIndex(Node fileNode, Binary fileBinary) {
+               JarInputStream jarIn = null;
+               BufferedReader reader = null;
+               try {
+                       jarIn = new JarInputStream(fileBinary.getStream());
+
+                       List<CategoryNameVersion> modules = new ArrayList<CategoryNameVersion>();
+
+                       // meta data
+                       manifest = jarIn.getManifest();
+                       if (manifest == null) {
+                               log.error(fileNode + " has no MANIFEST");
+                               return null;
+                       }
+                       String category = manifest.getMainAttributes().getValue(RepoConstants.SLC_CATEGORY_ID);
+                       String name = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+                       String version = manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
+
+                       Artifact distribution = new DefaultArtifact(category, name, "jar", version);
+                       // Retrieve the index file
+                       JarEntry indexEntry;
+                       while ((indexEntry = jarIn.getNextJarEntry()) != null) {
+                               String entryName = indexEntry.getName();
+                               if (entryName.equals(INDEX_FILE_NAME)) {
+                                       break;
+                               }
+                               try {
+                                       jarIn.closeEntry();
+                               } catch (SecurityException se) {
+                                       log.error("Invalid signature file digest " + "for Manifest main attributes: " + entryName
+                                                       + " while looking for an index in bundle " + name);
+                               }
+                       }
+                       if (indexEntry == null)
+                               return null; // Not a modular definition
+
+                       if (category == null) {
+                               log.warn("Modular definition found but no " + RepoConstants.SLC_CATEGORY_ID + " in " + fileNode);
+                       }
+
+                       // Process the index
+                       reader = new BufferedReader(new InputStreamReader(jarIn));
+                       String line = null;
+                       while ((line = reader.readLine()) != null) {
+                               StringTokenizer st = new StringTokenizer(line, separator);
+                               st.nextToken(); // moduleName
+                               st.nextToken(); // moduleVersion
+                               String relativeUrl = st.nextToken();
+                               Artifact currModule = AetherUtils.convertPathToArtifact(relativeUrl, null);
+                               modules.add(new DefaultCategoryNameVersion(currModule.getGroupId(), currModule.getArtifactId(),
+                                               currModule.getVersion()));
+                       }
+                       return new MyModularDistribution(distribution, modules);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot list artifacts", e);
+               } finally {
+                       IOUtils.closeQuietly(jarIn);
+                       IOUtils.closeQuietly(reader);
+               }
+       }
+
+       /**
+        * A consistent and versioned OSGi distribution, which can be built and tested.
+        */
+       private class MyModularDistribution extends ArtifactDistribution implements ArgeoOsgiDistribution {
+
+               private List<CategoryNameVersion> modules;
+
+               public MyModularDistribution(Artifact artifact, List<CategoryNameVersion> modules) {
+                       super(artifact);
+                       this.modules = modules;
+               }
+
+               public Iterator<CategoryNameVersion> nameVersions() {
+                       return modules.iterator();
+               }
+
+               // Modular distribution interface methods. Not yet used.
+               public Distribution getModuleDistribution(String moduleName, String moduleVersion) {
+                       return null;
+               }
+
+               public Object getModulesDescriptor(String descriptorType) {
+                       return null;
+               }
+       }
+
+       /** Separator used to parse the tabular file, default is "," */
+       public void setSeparator(String modulesUrlSeparator) {
+               this.separator = modulesUrlSeparator;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexer.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexer.java
new file mode 100644 (file)
index 0000000..374ad85
--- /dev/null
@@ -0,0 +1,29 @@
+package org.argeo.slc.repo;
+
+import javax.jcr.Node;
+import javax.jcr.observation.EventListener;
+
+/**
+ * Adds metadata to an existing node, ideally via observation after it has been
+ * added. There is a similar concept in ModeShape with which this abstraction
+ * may be merged in the future.
+ */
+public interface NodeIndexer {
+       /**
+        * Whether the node at this path will be supported. This is typically use in
+        * an {@link EventListener} before the node is loaded, and would apply on
+        * information contained in the path / file name: file extension, base path,
+        * etc. If the node needs to be loaded, the recommended approach is to
+        * return <code>true</code> here and wait for index to be called, possibly
+        * returning without processing if the node should not be indexed. While
+        * not strictly a requirement, this avoids to open sessions in the indexer,
+        * centralizing such tasks in the caller.
+        */
+       public Boolean support(String path);
+
+       /**
+        * Adds the metadata. This is the responsibility of the caller to save the
+        * underlying session.
+        */
+       public void index(Node node);
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexerVisitor.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/NodeIndexerVisitor.java
new file mode 100644 (file)
index 0000000..c0f90d1
--- /dev/null
@@ -0,0 +1,48 @@
+package org.argeo.slc.repo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.ItemVisitor;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+/**
+ * Recursively visit a sub tree and apply the list of node indexer on supported
+ * nodes.
+ */
+public class NodeIndexerVisitor implements ItemVisitor {
+       /** order may be important */
+       private List<NodeIndexer> nodeIndexers = new ArrayList<NodeIndexer>();
+
+       public NodeIndexerVisitor() {
+       }
+
+       /** Convenience constructor */
+       public NodeIndexerVisitor(NodeIndexer nodeIndexer) {
+               nodeIndexers.add(nodeIndexer);
+       }
+
+       public NodeIndexerVisitor(List<NodeIndexer> nodeIndexers) {
+               this.nodeIndexers = nodeIndexers;
+       }
+
+       public void visit(Node node) throws RepositoryException {
+               for (NodeIndexer nodeIndexer : nodeIndexers)
+                       if (nodeIndexer.support(node.getPath()))
+                               nodeIndexer.index(node);
+
+               for (NodeIterator it = node.getNodes(); it.hasNext();)
+                       visit(it.nextNode());
+       }
+
+       public void visit(Property property) throws RepositoryException {
+       }
+
+       public void setNodeIndexers(List<NodeIndexer> nodeIndexers) {
+               this.nodeIndexers = nodeIndexers;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiBundlesProvider.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiBundlesProvider.java
new file mode 100644 (file)
index 0000000..de5f03c
--- /dev/null
@@ -0,0 +1,12 @@
+package org.argeo.slc.repo;
+
+import java.util.List;
+
+/**
+ * Provides OSGi bundles either by linking to them, by wrapping existing
+ * archives or by building them.
+ */
+public interface OsgiBundlesProvider {
+       /** The provided bundles in the order they will be retrieved/wrapped/built. */
+       public List<ArtifactDistribution> provides();
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiFactory.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/OsgiFactory.java
new file mode 100644 (file)
index 0000000..8178493
--- /dev/null
@@ -0,0 +1,28 @@
+package org.argeo.slc.repo;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/** OSGi Factory */
+public interface OsgiFactory {
+       public Session openJavaSession() throws RepositoryException;
+
+       public Session openDistSession() throws RepositoryException;
+
+       public void indexNode(Node node);
+
+       /**
+        * Provide access to a third party archive in the 'dist' repository,
+        * downloading it if it is not available.
+        */
+       public Node getDist(Session distSession, String uri)
+                       throws RepositoryException;
+
+       /**
+        * Provide access to a cached maven ardifact identified by its coordinates
+        * the 'dist' repository, downloading it if it is not available.
+        */
+       public Node getMaven(Session distSession, String coords)
+                       throws RepositoryException;
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/PdeSourcesIndexer.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/PdeSourcesIndexer.java
new file mode 100644 (file)
index 0000000..0ce3ba9
--- /dev/null
@@ -0,0 +1,109 @@
+package org.argeo.slc.repo;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.maven.AetherUtils;
+import org.argeo.slc.repo.maven.MavenConventionsUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+/**
+ * Creates pde sources from a source {@link Artifact} with name
+ * "...-sources.jar"
+ */
+public class PdeSourcesIndexer implements NodeIndexer {
+       private Log log = LogFactory.getLog(PdeSourcesIndexer.class);
+
+       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
+
+       // private ArtifactIndexer artifactIndexer;
+       // private JarFileIndexer jarFileIndexer;
+
+       // public PdeSourcesIndexer(){
+       // // ArtifactIndexer artifactIndexer,
+       // // JarFileIndexer jarFileIndexer) {
+       // // this.artifactIndexer = artifactIndexer;
+       // // this.jarFileIndexer = jarFileIndexer;
+       // }
+
+       public Boolean support(String path) {
+               // TODO implement clean management of same name siblings
+               String name = FilenameUtils.getBaseName(path);
+               // int lastInd = name.lastIndexOf("[");
+               // if (lastInd != -1)
+               // name = name.substring(0, lastInd);
+               return name.endsWith("-sources") && FilenameUtils.getExtension(path).equals("jar");
+       }
+
+       public void index(Node sourcesNode) {
+               try {
+                       if (!support(sourcesNode.getPath()))
+                               return;
+
+                       packageSourcesAsPdeSource(sourcesNode);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot generate pde sources for node " + sourcesNode, e);
+               }
+       }
+
+       protected void packageSourcesAsPdeSource(Node sourcesNode) {
+               Binary origBinary = null;
+               Binary osgiBinary = null;
+               try {
+                       Session session = sourcesNode.getSession();
+                       Artifact sourcesArtifact = AetherUtils.convertPathToArtifact(sourcesNode.getPath(), null);
+
+                       // read name version from manifest
+                       Artifact osgiArtifact = new DefaultArtifact(sourcesArtifact.getGroupId(), sourcesArtifact.getArtifactId(),
+                                       sourcesArtifact.getExtension(), sourcesArtifact.getVersion());
+                       String osgiPath = MavenConventionsUtils.artifactPath(artifactBasePath, osgiArtifact);
+                       osgiBinary = session.getNode(osgiPath).getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary();
+
+                       NameVersion nameVersion = RepoUtils.readNameVersion(osgiBinary.getStream());
+                       if (nameVersion == null) {
+                               log.warn("Cannot package PDE sources for " + osgiPath + " as it is probably not an OSGi bundle");
+                               return;
+                       }
+
+                       // create PDe sources artifact
+                       Artifact pdeSourceArtifact = new DefaultArtifact(sourcesArtifact.getGroupId(),
+                                       sourcesArtifact.getArtifactId() + ".source", sourcesArtifact.getExtension(),
+                                       sourcesArtifact.getVersion());
+                       String targetSourceParentPath = MavenConventionsUtils.artifactParentPath(artifactBasePath,
+                                       pdeSourceArtifact);
+                       String targetSourceFileName = MavenConventionsUtils.artifactFileName(pdeSourceArtifact);
+                       // String targetSourceJarPath = targetSourceParentPath + '/'
+                       // + targetSourceFileName;
+
+                       Node targetSourceParentNode = JcrUtils.mkfolders(session, targetSourceParentPath);
+                       origBinary = sourcesNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary();
+                       byte[] targetJarBytes = RepoUtils.packageAsPdeSource(origBinary.getStream(), nameVersion);
+                       JcrUtils.copyBytesAsFile(targetSourceParentNode, targetSourceFileName, targetJarBytes);
+
+                       // reindex
+                       // Automagically done via the various listeners or manually
+                       // triggered.
+                       // Node targetSourceJarNode = session.getNode(targetSourceJarPath);
+                       // artifactIndexer.index(targetSourceJarNode);
+                       // jarFileIndexer.index(targetSourceJarNode);
+                       if (log.isTraceEnabled())
+                               log.trace("Created pde source artifact " + pdeSourceArtifact + " from " + sourcesNode);
+
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot add PDE sources for " + sourcesNode, e);
+               } finally {
+                       JcrUtils.closeQuietly(origBinary);
+                       JcrUtils.closeQuietly(osgiBinary);
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java
new file mode 100644 (file)
index 0000000..0645664
--- /dev/null
@@ -0,0 +1,27 @@
+package org.argeo.slc.repo;
+
+import org.argeo.api.NodeConstants;
+
+/** SLC repository constants */
+public interface RepoConstants {
+       String DEFAULT_JAVA_REPOSITORY_ALIAS = "java";
+       String DEFAULT_JAVA_REPOSITORY_LABEL = "Internal Java Repository";
+
+
+       String DEFAULT_ARTIFACTS_BASE_PATH = "/";
+       String REPO_BASEPATH = "/slc:repo";
+       String PROXIED_REPOSITORIES = REPO_BASEPATH + "/slc:sources";
+       String DISTRIBUTIONS_BASE_PATH = REPO_BASEPATH + "/slc:distributions";
+       String REPOSITORIES_BASE_PATH = REPO_BASEPATH + "/slc:repositories";
+       String DIST_DOWNLOAD_BASEPATH = "/download";
+
+       String BINARIES_ARTIFACT_ID = "binaries";
+       String SOURCES_ARTIFACT_ID = "sources";
+       String SDK_ARTIFACT_ID = "sdk";
+
+       // TODO might exists somewhere else
+       String SLC_CATEGORY_ID = "SLC-Category";
+
+       // TODO find a more generic way
+       String DEFAULT_DEFAULT_WORKSPACE = NodeConstants.SYS_WORKSPACE;
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoService.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoService.java
new file mode 100644 (file)
index 0000000..9b9bc66
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.repo;
+
+import javax.jcr.Session;
+
+/** Start factorisation of the session management using a manager service */
+public interface RepoService {
+
+       /**
+        * Returns a corresponding session given the current context. Caller must
+        * close the session once it has been used
+        */
+       public Session getRemoteSession(String repoNodePath, String uri,
+                       String workspaceName);
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java
new file mode 100644 (file)
index 0000000..2eb532e
--- /dev/null
@@ -0,0 +1,590 @@
+package org.argeo.slc.repo;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+import javax.jcr.Binary;
+import javax.jcr.Credentials;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.api.NodeUtils;
+import org.argeo.slc.SlcException;
+import org.xml.sax.SAXException;
+
+/**
+ * Synchronise workspaces from a remote software repository to the local
+ * repository (Synchronisation in the other direction does not work).
+ * 
+ * Workspaces are retrieved by name given a map that links the source with a
+ * target name. If a target workspace does not exist, it is created. Otherwise
+ * we copy the content of the source workspace into the target one.
+ */
+public class RepoSync implements Runnable {
+       private final static Log log = LogFactory.getLog(RepoSync.class);
+
+       // Centralizes definition of workspaces that must be ignored by the sync.
+       private final static List<String> IGNORED_WKSP_LIST = Arrays.asList("security", "localrepo");
+
+       private final Calendar zero;
+       private Session sourceDefaultSession = null;
+       private Session targetDefaultSession = null;
+
+       private Repository sourceRepository;
+       private Credentials sourceCredentials;
+       private Repository targetRepository;
+       private Credentials targetCredentials;
+
+       // if Repository and Credentials objects are not explicitly set
+       private String sourceRepoUri;
+       private String sourceUsername;
+       private char[] sourcePassword;
+       private String targetRepoUri;
+       private String targetUsername;
+       private char[] targetPassword;
+
+       private RepositoryFactory repositoryFactory;
+
+       private JcrMonitor monitor;
+       private Map<String, String> workspaceMap;
+
+       // TODO fix monitor
+       private Boolean filesOnly = false;
+
+       public RepoSync() {
+               zero = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
+               zero.setTimeInMillis(0);
+       }
+
+       /**
+        * 
+        * Shortcut to instantiate a RepoSync with already known repositories and
+        * credentials.
+        * 
+        * @param sourceRepository
+        * @param sourceCredentials
+        * @param targetRepository
+        * @param targetCredentials
+        */
+       public RepoSync(Repository sourceRepository, Credentials sourceCredentials, Repository targetRepository,
+                       Credentials targetCredentials) {
+               this();
+               this.sourceRepository = sourceRepository;
+               this.sourceCredentials = sourceCredentials;
+               this.targetRepository = targetRepository;
+               this.targetCredentials = targetCredentials;
+       }
+
+       public void run() {
+               try {
+                       long begin = System.currentTimeMillis();
+
+                       // Setup
+                       if (sourceRepository == null)
+                               sourceRepository = NodeUtils.getRepositoryByUri(repositoryFactory, sourceRepoUri);
+                       if (sourceCredentials == null && sourceUsername != null)
+                               sourceCredentials = new SimpleCredentials(sourceUsername, sourcePassword);
+                       // FIXME make it more generic
+                       sourceDefaultSession = sourceRepository.login(sourceCredentials, RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
+
+                       if (targetRepository == null)
+                               targetRepository = NodeUtils.getRepositoryByUri(repositoryFactory, targetRepoUri);
+                       if (targetCredentials == null && targetUsername != null)
+                               targetCredentials = new SimpleCredentials(targetUsername, targetPassword);
+                       targetDefaultSession = targetRepository.login(targetCredentials);
+
+                       Map<String, Exception> errors = new HashMap<String, Exception>();
+                       for (String sourceWorkspaceName : sourceDefaultSession.getWorkspace().getAccessibleWorkspaceNames()) {
+                               if (monitor != null && monitor.isCanceled())
+                                       break;
+
+                               if (workspaceMap != null && !workspaceMap.containsKey(sourceWorkspaceName))
+                                       continue;
+                               if (IGNORED_WKSP_LIST.contains(sourceWorkspaceName))
+                                       continue;
+
+                               Session sourceSession = null;
+                               Session targetSession = null;
+                               String targetWorkspaceName = workspaceMap.get(sourceWorkspaceName);
+                               try {
+                                       try {
+                                               targetSession = targetRepository.login(targetCredentials, targetWorkspaceName);
+                                       } catch (NoSuchWorkspaceException e) {
+                                               targetDefaultSession.getWorkspace().createWorkspace(targetWorkspaceName);
+                                               targetSession = targetRepository.login(targetCredentials, targetWorkspaceName);
+                                       }
+                                       sourceSession = sourceRepository.login(sourceCredentials, sourceWorkspaceName);
+                                       syncWorkspace(sourceSession, targetSession);
+                               } catch (Exception e) {
+                                       errors.put("Could not sync workspace " + sourceWorkspaceName, e);
+                                       if (log.isErrorEnabled())
+                                               e.printStackTrace();
+
+                               } finally {
+                                       JcrUtils.logoutQuietly(sourceSession);
+                                       JcrUtils.logoutQuietly(targetSession);
+                               }
+                       }
+
+                       if (monitor != null && monitor.isCanceled())
+                               log.info("Sync has been canceled by user");
+
+                       long duration = (System.currentTimeMillis() - begin) / 1000;// s
+                       log.info("Sync " + sourceRepoUri + " to " + targetRepoUri + " in " + (duration / 60)
+
+                                       + "min " + (duration % 60) + "s");
+
+                       if (errors.size() > 0) {
+                               throw new SlcException("Sync failed " + errors);
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot sync " + sourceRepoUri + " to " + targetRepoUri, e);
+               } finally {
+                       JcrUtils.logoutQuietly(sourceDefaultSession);
+                       JcrUtils.logoutQuietly(targetDefaultSession);
+               }
+       }
+
+       private long getNodesNumber(Session session) {
+               if (IGNORED_WKSP_LIST.contains(session.getWorkspace().getName()))
+                       return 0l;
+               try {
+                       Query countQuery = session.getWorkspace().getQueryManager().createQuery(
+                                       "select file from [" + (true ? NodeType.NT_FILE : NodeType.NT_BASE) + "] as file", Query.JCR_SQL2);
+
+                       QueryResult result = countQuery.execute();
+                       Long expectedCount = result.getNodes().getSize();
+                       return expectedCount;
+               } catch (RepositoryException e) {
+                       throw new SlcException("Unexpected error while computing " + "the size of the fetch for workspace "
+                                       + session.getWorkspace().getName(), e);
+               }
+       }
+
+       protected void syncWorkspace(Session sourceSession, Session targetSession) {
+               if (monitor != null) {
+                       monitor.beginTask("Computing fetch size...", -1);
+                       Long totalAmount = getNodesNumber(sourceSession);
+                       monitor.beginTask("Fetch", totalAmount.intValue());
+               }
+
+               try {
+                       String msg = "Synchronizing workspace: " + sourceSession.getWorkspace().getName();
+                       if (monitor != null)
+                               monitor.setTaskName(msg);
+                       if (log.isDebugEnabled())
+                               log.debug(msg);
+
+                       for (NodeIterator it = sourceSession.getRootNode().getNodes(); it.hasNext();) {
+                               Node node = it.nextNode();
+                               if (node.getName().contains(":"))
+                                       continue;
+                               if (node.getName().equals("download"))
+                                       continue;
+                               if (!node.isNodeType(NodeType.NT_HIERARCHY_NODE))
+                                       continue;
+                               syncNode(node, targetSession);
+                       }
+                       // if (filesOnly) {
+                       // JcrUtils.copyFiles(sourceSession.getRootNode(), targetSession.getRootNode(),
+                       // true, monitor);
+                       // } else {
+                       // for (NodeIterator it = sourceSession.getRootNode().getNodes(); it.hasNext();)
+                       // {
+                       // Node node = it.nextNode();
+                       // if (node.getName().equals("jcr:system"))
+                       // continue;
+                       // syncNode(node, targetSession);
+                       // }
+                       // }
+                       if (log.isDebugEnabled())
+                               log.debug("Synced " + sourceSession.getWorkspace().getName());
+               } catch (Exception e) {
+                       e.printStackTrace();
+                       throw new SlcException("Cannot sync " + sourceSession.getWorkspace().getName() + " to "
+                                       + targetSession.getWorkspace().getName(), e);
+               }
+       }
+
+       /** factorizes monitor management */
+       private void updateMonitor(String msg) {
+               updateMonitor(msg, false);
+       }
+
+       protected void syncNode(Node sourceNode, Session targetSession) throws RepositoryException, SAXException {
+               if (filesOnly) {
+                       Node targetNode;
+                       if (targetSession.itemExists(sourceNode.getPath()))
+                               targetNode = targetSession.getNode(sourceNode.getPath());
+                       else
+                               targetNode = JcrUtils.mkdirs(targetSession, sourceNode.getPath(), NodeType.NT_FOLDER);
+                       JcrUtils.copyFiles(sourceNode, targetNode, true, monitor, true);
+                       return;
+               }
+               // Boolean singleLevel = singleLevel(sourceNode);
+               try {
+                       if (monitor != null && monitor.isCanceled()) {
+                               updateMonitor("Fetched has been canceled, " + "process is terminating");
+                               return;
+                       }
+
+                       Node targetParentNode = targetSession.getNode(sourceNode.getParent().getPath());
+                       Node targetNode;
+                       if (monitor != null && sourceNode.isNodeType(NodeType.NT_HIERARCHY_NODE))
+                               monitor.subTask("Process " + sourceNode.getPath());
+
+                       final Boolean isNew;
+                       if (!targetSession.itemExists(sourceNode.getPath())) {
+                               isNew = true;
+                               targetNode = targetParentNode.addNode(sourceNode.getName(), sourceNode.getPrimaryNodeType().getName());
+                       } else {
+                               isNew = false;
+                               targetNode = targetSession.getNode(sourceNode.getPath());
+                               if (!targetNode.getPrimaryNodeType().getName().equals(sourceNode.getPrimaryNodeType().getName()))
+                                       targetNode.setPrimaryType(sourceNode.getPrimaryNodeType().getName());
+                       }
+
+                       // export
+                       // sourceNode.getSession().exportSystemView(sourceNode.getPath(),
+                       // contentHandler, false, singleLevel);
+
+                       // if (singleLevel) {
+                       // if (targetSession.hasPendingChanges()) {
+                       // // updateMonitor(
+                       // // (isNew ? "Added " : "Updated ") + targetNode.getPath(),
+                       // // true);
+                       // if (doSave)
+                       // targetSession.save();
+                       // } else {
+                       // // updateMonitor("Checked " + targetNode.getPath(), false);
+                       // }
+                       // }
+
+                       // mixin and properties
+                       for (NodeType nt : sourceNode.getMixinNodeTypes()) {
+                               if (!targetNode.isNodeType(nt.getName()) && targetNode.canAddMixin(nt.getName()))
+                                       targetNode.addMixin(nt.getName());
+                       }
+                       copyProperties(sourceNode, targetNode);
+
+                       // next level
+                       NodeIterator ni = sourceNode.getNodes();
+                       while (ni != null && ni.hasNext()) {
+                               Node sourceChild = ni.nextNode();
+                               syncNode(sourceChild, targetSession);
+                       }
+
+                       copyTimestamps(sourceNode, targetNode);
+
+                       if (sourceNode.isNodeType(NodeType.NT_HIERARCHY_NODE)) {
+                               if (targetSession.hasPendingChanges()) {
+                                       if (sourceNode.isNodeType(NodeType.NT_FILE))
+                                               updateMonitor((isNew ? "Added " : "Updated ") + targetNode.getPath(), true);
+                                       // if (doSave)
+                                       targetSession.save();
+                               } else {
+                                       if (sourceNode.isNodeType(NodeType.NT_FILE))
+                                               updateMonitor("Checked " + targetNode.getPath(), false);
+                               }
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot sync source node " + sourceNode, e);
+               }
+       }
+
+       private void copyTimestamps(Node sourceNode, Node targetNode) throws RepositoryException {
+               if (sourceNode.getDefinition().isProtected())
+                       return;
+               if (targetNode.getDefinition().isProtected())
+                       return;
+               copyTimestamp(sourceNode, targetNode, Property.JCR_CREATED);
+               copyTimestamp(sourceNode, targetNode, Property.JCR_CREATED_BY);
+               copyTimestamp(sourceNode, targetNode, Property.JCR_LAST_MODIFIED);
+               copyTimestamp(sourceNode, targetNode, Property.JCR_LAST_MODIFIED_BY);
+       }
+
+       private void copyTimestamp(Node sourceNode, Node targetNode, String property) throws RepositoryException {
+               if (sourceNode.hasProperty(property)) {
+                       Property p = sourceNode.getProperty(property);
+                       if (p.getDefinition().isProtected())
+                               return;
+                       if (targetNode.hasProperty(property)
+                                       && targetNode.getProperty(property).getValue().equals(sourceNode.getProperty(property).getValue()))
+                               return;
+                       targetNode.setProperty(property, sourceNode.getProperty(property).getValue());
+               }
+       }
+
+       private void copyProperties(Node sourceNode, Node targetNode) throws RepositoryException {
+               properties: for (PropertyIterator pi = sourceNode.getProperties(); pi.hasNext();) {
+                       Property p = pi.nextProperty();
+                       if (p.getDefinition().isProtected())
+                               continue properties;
+                       if (p.getName().equals(Property.JCR_CREATED) || p.getName().equals(Property.JCR_CREATED_BY)
+                                       || p.getName().equals(Property.JCR_LAST_MODIFIED)
+                                       || p.getName().equals(Property.JCR_LAST_MODIFIED_BY))
+                               continue properties;
+
+                       if (p.getType() == PropertyType.BINARY) {
+                               copyBinary(p, targetNode);
+                       } else {
+
+                               if (p.isMultiple()) {
+                                       if (!targetNode.hasProperty(p.getName())
+                                                       || !Arrays.equals(targetNode.getProperty(p.getName()).getValues(), p.getValues()))
+                                               targetNode.setProperty(p.getName(), p.getValues());
+                               } else {
+                                       if (!targetNode.hasProperty(p.getName())
+                                                       || !targetNode.getProperty(p.getName()).getValue().equals(p.getValue()))
+                                               targetNode.setProperty(p.getName(), p.getValue());
+                               }
+                       }
+               }
+       }
+
+       private static void copyBinary(Property p, Node targetNode) throws RepositoryException {
+               InputStream in = null;
+               Binary sourceBinary = null;
+               Binary targetBinary = null;
+               try {
+                       sourceBinary = p.getBinary();
+                       if (targetNode.hasProperty(p.getName()))
+                               targetBinary = targetNode.getProperty(p.getName()).getBinary();
+
+                       // optim FIXME make it more configurable
+                       if (targetBinary != null)
+                               if (sourceBinary.getSize() == targetBinary.getSize()) {
+                                       if (log.isTraceEnabled())
+                                               log.trace("Skipped " + p.getPath());
+                                       return;
+                               }
+
+                       in = sourceBinary.getStream();
+                       targetBinary = targetNode.getSession().getValueFactory().createBinary(in);
+                       targetNode.setProperty(p.getName(), targetBinary);
+               } catch (Exception e) {
+                       throw new SlcException("Could not transfer " + p, e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+                       JcrUtils.closeQuietly(sourceBinary);
+                       JcrUtils.closeQuietly(targetBinary);
+               }
+       }
+
+       /** factorizes monitor management */
+       private void updateMonitor(String msg, Boolean doLog) {
+               if (doLog && log.isDebugEnabled())
+                       log.debug(msg);
+               if (monitor != null) {
+                       monitor.worked(1);
+                       monitor.subTask(msg);
+               }
+       }
+
+       // private void syncNode_old(Node sourceNode, Node targetParentNode)
+       // throws RepositoryException, SAXException {
+       //
+       // // enable cancelation of the current fetch process
+       // // fxme insure the repository stays in a stable state
+       // if (monitor != null && monitor.isCanceled()) {
+       // updateMonitor("Fetched has been canceled, "
+       // + "process is terminating");
+       // return;
+       // }
+       //
+       // Boolean noRecurse = singleLevel(sourceNode);
+       // Calendar sourceLastModified = null;
+       // if (sourceNode.isNodeType(NodeType.MIX_LAST_MODIFIED)) {
+       // sourceLastModified = sourceNode.getProperty(
+       // Property.JCR_LAST_MODIFIED).getDate();
+       // }
+       //
+       // if (sourceNode.getDefinition().isProtected())
+       // log.warn(sourceNode + " is protected.");
+       //
+       // if (!targetParentNode.hasNode(sourceNode.getName())) {
+       // String msg = "Adding " + sourceNode.getPath();
+       // updateMonitor(msg);
+       // if (log.isDebugEnabled())
+       // log.debug(msg);
+       // ContentHandler contentHandler = targetParentNode
+       // .getSession()
+       // .getWorkspace()
+       // .getImportContentHandler(targetParentNode.getPath(),
+       // ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+       // sourceNode.getSession().exportSystemView(sourceNode.getPath(),
+       // contentHandler, false, noRecurse);
+       // } else {
+       // Node targetNode = targetParentNode.getNode(sourceNode.getName());
+       // if (sourceLastModified != null) {
+       // Calendar targetLastModified = null;
+       // if (targetNode.isNodeType(NodeType.MIX_LAST_MODIFIED)) {
+       // targetLastModified = targetNode.getProperty(
+       // Property.JCR_LAST_MODIFIED).getDate();
+       // }
+       //
+       // if (targetLastModified == null
+       // || targetLastModified.before(sourceLastModified)) {
+       // String msg = "Updating " + targetNode.getPath();
+       // updateMonitor(msg);
+       // if (log.isDebugEnabled())
+       // log.debug(msg);
+       // ContentHandler contentHandler = targetParentNode
+       // .getSession()
+       // .getWorkspace()
+       // .getImportContentHandler(
+       // targetParentNode.getPath(),
+       // ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
+       // sourceNode.getSession().exportSystemView(
+       // sourceNode.getPath(), contentHandler, false,
+       // noRecurse);
+       // } else {
+       // String msg = "Skipped up to date " + targetNode.getPath();
+       // updateMonitor(msg);
+       // if (log.isDebugEnabled())
+       // log.debug(msg);
+       // return;
+       // }
+       // }
+       // }
+       //
+       // if (noRecurse) {
+       // // recurse
+       // Node targetNode = targetParentNode.getNode(sourceNode.getName());
+       // if (sourceLastModified != null) {
+       // Calendar zero = new GregorianCalendar();
+       // zero.setTimeInMillis(0);
+       // targetNode.setProperty(Property.JCR_LAST_MODIFIED, zero);
+       // targetNode.getSession().save();
+       // }
+       //
+       // for (NodeIterator it = sourceNode.getNodes(); it.hasNext();) {
+       // syncNode_old(it.nextNode(), targetNode);
+       // }
+       //
+       // if (sourceLastModified != null) {
+       // targetNode.setProperty(Property.JCR_LAST_MODIFIED,
+       // sourceLastModified);
+       // targetNode.getSession().save();
+       // }
+       // }
+       // }
+
+       protected Boolean singleLevel(Node sourceNode) throws RepositoryException {
+               if (sourceNode.isNodeType(NodeType.NT_FILE))
+                       return false;
+               return true;
+       }
+
+       /**
+        * Synchronises only one workspace, retrieved by name without changing its name.
+        */
+       public void setSourceWksp(String sourceWksp) {
+               if (sourceWksp != null && !sourceWksp.trim().equals("")) {
+                       Map<String, String> map = new HashMap<String, String>();
+                       map.put(sourceWksp, sourceWksp);
+                       setWkspMap(map);
+               }
+       }
+
+       /**
+        * Synchronises a map of workspaces that will be retrieved by name. If the
+        * target name is not defined (eg null or an empty string) for a given source
+        * workspace, we use the source name as target name.
+        */
+       public void setWkspMap(Map<String, String> workspaceMap) {
+               // clean the list to ease later use
+               this.workspaceMap = new HashMap<String, String>();
+               if (workspaceMap != null) {
+                       workspaceNames: for (String srcName : workspaceMap.keySet()) {
+                               String targetName = workspaceMap.get(srcName);
+
+                               // Sanity check
+                               if (srcName.trim().equals(""))
+                                       continue workspaceNames;
+                               if (targetName == null || "".equals(targetName.trim()))
+                                       targetName = srcName;
+                               this.workspaceMap.put(srcName, targetName);
+                       }
+               }
+               // clean the map to ease later use
+               if (this.workspaceMap.size() == 0)
+                       this.workspaceMap = null;
+       }
+
+       public void setMonitor(JcrMonitor monitor) {
+               this.monitor = monitor;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setSourceRepoUri(String sourceRepoUri) {
+               this.sourceRepoUri = sourceRepoUri;
+       }
+
+       public void setSourceUsername(String sourceUsername) {
+               this.sourceUsername = sourceUsername;
+       }
+
+       public void setSourcePassword(char[] sourcePassword) {
+               this.sourcePassword = sourcePassword;
+       }
+
+       public void setTargetRepoUri(String targetRepoUri) {
+               this.targetRepoUri = targetRepoUri;
+       }
+
+       public void setTargetUsername(String targetUsername) {
+               this.targetUsername = targetUsername;
+       }
+
+       public void setTargetPassword(char[] targetPassword) {
+               this.targetPassword = targetPassword;
+       }
+
+       public void setSourceRepository(Repository sourceRepository) {
+               this.sourceRepository = sourceRepository;
+       }
+
+       public void setSourceCredentials(Credentials sourceCredentials) {
+               this.sourceCredentials = sourceCredentials;
+       }
+
+       public void setTargetRepository(Repository targetRepository) {
+               this.targetRepository = targetRepository;
+       }
+
+       public void setTargetCredentials(Credentials targetCredentials) {
+               this.targetCredentials = targetCredentials;
+       }
+
+       public void setFilesOnly(Boolean filesOnly) {
+               this.filesOnly = filesOnly;
+       }
+
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoUtils.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoUtils.java
new file mode 100644 (file)
index 0000000..a6dc5d9
--- /dev/null
@@ -0,0 +1,635 @@
+package org.argeo.slc.repo;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipInputStream;
+
+import javax.jcr.Credentials;
+import javax.jcr.GuestCredentials;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.ArgeoNames;
+import org.argeo.cms.ArgeoTypes;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.api.NodeUtils;
+import org.argeo.api.security.Keyring;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.maven.ArtifactIdComparator;
+import org.argeo.slc.repo.maven.MavenConventionsUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.osgi.framework.Constants;
+
+/** Utilities around repo */
+public class RepoUtils implements ArgeoNames, SlcNames {
+       private final static Log log = LogFactory.getLog(RepoUtils.class);
+
+       /** Packages a regular sources jar as PDE source. */
+       public static void packagesAsPdeSource(File sourceFile,
+                       NameVersion nameVersion, OutputStream out) throws IOException {
+               if (isAlreadyPdeSource(sourceFile)) {
+                       FileInputStream in = new FileInputStream(sourceFile);
+                       IOUtils.copy(in, out);
+                       IOUtils.closeQuietly(in);
+               } else {
+                       String sourceSymbolicName = nameVersion.getName() + ".source";
+
+                       Manifest sourceManifest = null;
+                       sourceManifest = new Manifest();
+                       sourceManifest.getMainAttributes().put(
+                                       Attributes.Name.MANIFEST_VERSION, "1.0");
+                       sourceManifest.getMainAttributes().putValue("Bundle-SymbolicName",
+                                       sourceSymbolicName);
+                       sourceManifest.getMainAttributes().putValue("Bundle-Version",
+                                       nameVersion.getVersion());
+                       sourceManifest.getMainAttributes().putValue(
+                                       "Eclipse-SourceBundle",
+                                       nameVersion.getName() + ";version="
+                                                       + nameVersion.getVersion());
+                       copyJar(sourceFile, out, sourceManifest);
+               }
+       }
+
+       public static byte[] packageAsPdeSource(InputStream sourceJar,
+                       NameVersion nameVersion) {
+               String sourceSymbolicName = nameVersion.getName() + ".source";
+
+               Manifest sourceManifest = null;
+               sourceManifest = new Manifest();
+               sourceManifest.getMainAttributes().put(
+                               Attributes.Name.MANIFEST_VERSION, "1.0");
+               sourceManifest.getMainAttributes().putValue("Bundle-SymbolicName",
+                               sourceSymbolicName);
+               sourceManifest.getMainAttributes().putValue("Bundle-Version",
+                               nameVersion.getVersion());
+               sourceManifest.getMainAttributes().putValue("Eclipse-SourceBundle",
+                               nameVersion.getName() + ";version=" + nameVersion.getVersion());
+
+               return modifyManifest(sourceJar, sourceManifest);
+       }
+
+       /**
+        * Check whether the file as already been packaged as PDE source, in order
+        * not to mess with Jar signing
+        */
+       private static boolean isAlreadyPdeSource(File sourceFile) {
+               JarInputStream jarInputStream = null;
+
+               try {
+                       jarInputStream = new JarInputStream(new FileInputStream(sourceFile));
+
+                       Manifest manifest = jarInputStream.getManifest();
+                       Iterator<?> it = manifest.getMainAttributes().keySet().iterator();
+                       boolean res = false;
+                       // containsKey() does not work, iterating...
+                       while (it.hasNext())
+                               if (it.next().toString().equals("Eclipse-SourceBundle")) {
+                                       res = true;
+                                       break;
+                               }
+                       // boolean res = manifest.getMainAttributes().get(
+                       // "Eclipse-SourceBundle") != null;
+                       if (res)
+                               log.info(sourceFile + " is already a PDE source");
+                       return res;
+               } catch (Exception e) {
+                       // probably not a jar, skipping
+                       if (log.isDebugEnabled())
+                               log.debug("Skipping " + sourceFile + " because of "
+                                               + e.getMessage());
+                       return false;
+               } finally {
+                       IOUtils.closeQuietly(jarInputStream);
+               }
+       }
+
+       /**
+        * Copy a jar, replacing its manifest with the provided one
+        * 
+        * @param manifest
+        *            can be null
+        */
+       private static void copyJar(File source, OutputStream out, Manifest manifest)
+                       throws IOException {
+               JarFile sourceJar = null;
+               JarOutputStream output = null;
+               try {
+                       output = manifest != null ? new JarOutputStream(out, manifest)
+                                       : new JarOutputStream(out);
+                       sourceJar = new JarFile(source);
+
+                       entries: for (Enumeration<?> entries = sourceJar.entries(); entries
+                                       .hasMoreElements();) {
+                               JarEntry entry = (JarEntry) entries.nextElement();
+                               if (manifest != null
+                                               && entry.getName().equals("META-INF/MANIFEST.MF"))
+                                       continue entries;
+
+                               InputStream entryStream = sourceJar.getInputStream(entry);
+                               JarEntry newEntry = new JarEntry(entry.getName());
+                               // newEntry.setMethod(JarEntry.DEFLATED);
+                               output.putNextEntry(newEntry);
+                               IOUtils.copy(entryStream, output);
+                       }
+               } finally {
+                       IOUtils.closeQuietly(output);
+                       try {
+                               if (sourceJar != null)
+                                       sourceJar.close();
+                       } catch (IOException e) {
+                               // silent
+                       }
+               }
+       }
+
+       /** Copy a jar changing onlythe manifest */
+       public static void copyJar(InputStream in, OutputStream out,
+                       Manifest manifest) {
+               JarInputStream jarIn = null;
+               JarOutputStream jarOut = null;
+               try {
+                       jarIn = new JarInputStream(in);
+                       jarOut = new JarOutputStream(out, manifest);
+                       JarEntry jarEntry = null;
+                       while ((jarEntry = jarIn.getNextJarEntry()) != null) {
+                               if (!jarEntry.getName().equals("META-INF/MANIFEST.MF")) {
+                                       JarEntry newJarEntry = new JarEntry(jarEntry.getName());
+                                       jarOut.putNextEntry(newJarEntry);
+                                       IOUtils.copy(jarIn, jarOut);
+                                       jarIn.closeEntry();
+                                       jarOut.closeEntry();
+                               }
+                       }
+               } catch (IOException e) {
+                       throw new SlcException("Could not copy jar with MANIFEST "
+                                       + manifest.getMainAttributes(), e);
+               } finally {
+                       if (!(in instanceof ZipInputStream))
+                               IOUtils.closeQuietly(jarIn);
+                       IOUtils.closeQuietly(jarOut);
+               }
+       }
+
+       /** Reads a jar file, modify its manifest */
+       public static byte[] modifyManifest(InputStream in, Manifest manifest) {
+               ByteArrayOutputStream out = new ByteArrayOutputStream(200 * 1024);
+               try {
+                       copyJar(in, out, manifest);
+                       return out.toByteArray();
+               } finally {
+                       IOUtils.closeQuietly(out);
+               }
+       }
+
+       /** Read the OSGi {@link NameVersion} */
+       public static NameVersion readNameVersion(Artifact artifact) {
+               File artifactFile = artifact.getFile();
+               if (artifact.getExtension().equals("pom")) {
+                       // hack to process jars which weirdly appear as POMs
+                       File jarFile = new File(artifactFile.getParentFile(),
+                                       FilenameUtils.getBaseName(artifactFile.getPath()) + ".jar");
+                       if (jarFile.exists()) {
+                               log.warn("Use " + jarFile + " instead of " + artifactFile
+                                               + " for " + artifact);
+                               artifactFile = jarFile;
+                       }
+               }
+               return readNameVersion(artifactFile);
+       }
+
+       /** Read the OSGi {@link NameVersion} */
+       public static NameVersion readNameVersion(File artifactFile) {
+               try {
+                       return readNameVersion(new FileInputStream(artifactFile));
+               } catch (Exception e) {
+                       // probably not a jar, skipping
+                       if (log.isDebugEnabled()) {
+                               log.debug("Skipping " + artifactFile + " because of " + e);
+                               // e.printStackTrace();
+                       }
+               }
+               return null;
+       }
+
+       /** Read the OSGi {@link NameVersion} */
+       public static NameVersion readNameVersion(InputStream in) {
+               JarInputStream jarInputStream = null;
+               try {
+                       jarInputStream = new JarInputStream(in);
+                       return readNameVersion(jarInputStream.getManifest());
+               } catch (Exception e) {
+                       // probably not a jar, skipping
+                       if (log.isDebugEnabled()) {
+                               log.debug("Skipping because of " + e);
+                       }
+               } finally {
+                       IOUtils.closeQuietly(jarInputStream);
+               }
+               return null;
+       }
+
+       /** Read the OSGi {@link NameVersion} */
+       public static NameVersion readNameVersion(Manifest manifest) {
+               DefaultNameVersion nameVersion = new DefaultNameVersion();
+               nameVersion.setName(manifest.getMainAttributes().getValue(
+                               Constants.BUNDLE_SYMBOLICNAME));
+
+               // Skip additional specs such as
+               // ; singleton:=true
+               if (nameVersion.getName().indexOf(';') > -1) {
+                       nameVersion
+                                       .setName(new StringTokenizer(nameVersion.getName(), " ;")
+                                                       .nextToken());
+               }
+
+               nameVersion.setVersion(manifest.getMainAttributes().getValue(
+                               Constants.BUNDLE_VERSION));
+
+               return nameVersion;
+       }
+
+       /*
+        * DATA MODEL
+        */
+       /** The artifact described by this node */
+       public static Artifact asArtifact(Node node) throws RepositoryException {
+               if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+                       // FIXME update data model to store packaging at this level
+                       String extension = "jar";
+                       return new DefaultArtifact(node.getProperty(SLC_GROUP_ID)
+                                       .getString(),
+                                       node.getProperty(SLC_ARTIFACT_ID).getString(), extension,
+                                       node.getProperty(SLC_ARTIFACT_VERSION).getString());
+               } else if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
+                       return new DefaultArtifact(node.getProperty(SLC_GROUP_ID)
+                                       .getString(),
+                                       node.getProperty(SLC_ARTIFACT_ID).getString(), node
+                                                       .getProperty(SLC_ARTIFACT_CLASSIFIER).getString(),
+                                       node.getProperty(SLC_ARTIFACT_EXTENSION).getString(), node
+                                                       .getProperty(SLC_ARTIFACT_VERSION).getString());
+               } else if (node.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
+                       return new DefaultArtifact(node.getProperty(SLC_CATEGORY)
+                                       .getString(), node.getProperty(SLC_NAME).getString(),
+                                       "jar", node.getProperty(SLC_VERSION).getString());
+               } else {
+                       throw new SlcException("Unsupported node type for " + node);
+               }
+       }
+
+       /**
+        * The path to the PDE source related to this artifact (or artifact version
+        * base). There may or there may not be a node at this location (the
+        * returned path will typically be used to test whether PDE sources are
+        * attached to this artifact).
+        */
+       public static String relatedPdeSourcePath(String artifactBasePath,
+                       Node artifactNode) throws RepositoryException {
+               Artifact artifact = asArtifact(artifactNode);
+               Artifact pdeSourceArtifact = new DefaultArtifact(artifact.getGroupId(),
+                               artifact.getArtifactId() + ".source", artifact.getExtension(),
+                               artifact.getVersion());
+               return MavenConventionsUtils.artifactPath(artifactBasePath,
+                               pdeSourceArtifact);
+       }
+
+       /**
+        * Copy this bytes array as an artifact, relative to the root of the
+        * repository (typically the workspace root node)
+        */
+       public static Node copyBytesAsArtifact(Node artifactsBase,
+                       Artifact artifact, byte[] bytes) throws RepositoryException {
+               String parentPath = MavenConventionsUtils.artifactParentPath(
+                               artifactsBase.getPath(), artifact);
+               Node folderNode = JcrUtils.mkfolders(artifactsBase.getSession(),
+                               parentPath);
+               return JcrUtils.copyBytesAsFile(folderNode,
+                               MavenConventionsUtils.artifactFileName(artifact), bytes);
+       }
+
+       private RepoUtils() {
+       }
+
+       /** If a source return the base bundle name, does not change otherwise */
+       public static String extractBundleNameFromSourceName(String sourceBundleName) {
+               if (sourceBundleName.endsWith(".source"))
+                       return sourceBundleName.substring(0, sourceBundleName.length()
+                                       - ".source".length());
+               else
+                       return sourceBundleName;
+       }
+
+       /*
+        * SOFTWARE REPOSITORIES
+        */
+
+       /** Retrieve repository based on information in the repo node */
+       public static Repository getRepository(RepositoryFactory repositoryFactory,
+                       Keyring keyring, Node repoNode) {
+               try {
+                       Repository repository;
+                       if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
+                               String uri = repoNode.getProperty(ARGEO_URI).getString();
+                               if (uri.startsWith("http")) {// http, https
+                                       repository = NodeUtils.getRepositoryByUri(
+                                                       repositoryFactory, uri);
+                               } else if (uri.startsWith("vm:")) {// alias
+                                       repository = NodeUtils.getRepositoryByUri(
+                                                       repositoryFactory, uri);
+                               } else {
+                                       throw new SlcException("Unsupported repository uri " + uri);
+                               }
+                               return repository;
+                       } else {
+                               throw new SlcException("Unsupported node type " + repoNode);
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot connect to repository " + repoNode,
+                                       e);
+               }
+       }
+
+       /**
+        * Reads credentials from node, using keyring if there is a password. Can
+        * return null if no credentials needed (local repo) at all, but returns
+        * {@link GuestCredentials} if user id is 'anonymous' .
+        */
+       public static Credentials getRepositoryCredentials(Keyring keyring,
+                       Node repoNode) {
+               try {
+                       if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
+                               if (!repoNode.hasProperty(ARGEO_USER_ID))
+                                       return null;
+
+                               String userId = repoNode.getProperty(ARGEO_USER_ID).getString();
+                               if (userId.equals("anonymous"))// FIXME hardcoded userId
+                                       return new GuestCredentials();
+                               char[] password = keyring.getAsChars(repoNode.getPath() + '/'
+                                               + ARGEO_PASSWORD);
+                               Credentials credentials = new SimpleCredentials(userId,
+                                               password);
+                               return credentials;
+                       } else {
+                               throw new SlcException("Unsupported node type " + repoNode);
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot connect to repository " + repoNode,
+                                       e);
+               }
+       }
+
+       /**
+        * Shortcut to retrieve a session given variable information: Handle the
+        * case where we only have an URI of the repository, that we want to connect
+        * as anonymous or the case of a identified connection to a local or remote
+        * repository.
+        * 
+        * Callers must close the session once it has been used
+        */
+       public static Session getRemoteSession(RepositoryFactory repositoryFactory,
+                       Keyring keyring, Node repoNode, String uri, String workspaceName) {
+               try {
+                       if (repoNode == null && uri == null)
+                               throw new SlcException(
+                                               "At least one of repoNode and uri must be defined");
+                       Repository currRepo = null;
+                       Credentials credentials = null;
+                       // Anonymous URI only workspace
+                       if (repoNode == null)
+                               // Anonymous
+                               currRepo = NodeUtils.getRepositoryByUri(repositoryFactory, uri);
+                       else {
+                               currRepo = RepoUtils.getRepository(repositoryFactory, keyring,
+                                               repoNode);
+                               credentials = RepoUtils.getRepositoryCredentials(keyring,
+                                               repoNode);
+                       }
+                       return currRepo.login(credentials, workspaceName);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot connect to workspace "
+                                       + workspaceName + " of repository " + repoNode
+                                       + " with URI " + uri, e);
+               }
+       }
+
+       /**
+        * Shortcut to retrieve a session on a remote Jrc Repository from
+        * information stored in a local argeo node or from an URI: Handle the case
+        * where we only have an URI of the repository, that we want to connect as
+        * anonymous or the case of a identified connection to a local or remote
+        * repository.
+        * 
+        * Callers must close the session once it has been used
+        */
+       public static Session getRemoteSession(RepositoryFactory repositoryFactory,
+                       Keyring keyring, Repository localRepository, String repoNodePath,
+                       String uri, String workspaceName) {
+               Session localSession = null;
+               Node repoNode = null;
+               try {
+                       localSession = localRepository.login();
+                       if (repoNodePath != null && localSession.nodeExists(repoNodePath))
+                               repoNode = localSession.getNode(repoNodePath);
+
+                       return RepoUtils.getRemoteSession(repositoryFactory, keyring,
+                                       repoNode, uri, workspaceName);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot log to workspace " + workspaceName
+                                       + " for repo defined in " + repoNodePath, e);
+               } finally {
+                       JcrUtils.logoutQuietly(localSession);
+               }
+       }
+
+       /**
+        * Write group indexes: 'binaries' lists all bundles and their versions,
+        * 'sources' list their sources, and 'sdk' aggregates both.
+        */
+       public static void writeGroupIndexes(Session session,
+                       String artifactBasePath, String groupId, String version,
+                       Set<Artifact> binaries, Set<Artifact> sources) {
+               try {
+                       Set<Artifact> indexes = new TreeSet<Artifact>(
+                                       new ArtifactIdComparator());
+                       Artifact binariesArtifact = writeIndex(session, artifactBasePath,
+                                       groupId, RepoConstants.BINARIES_ARTIFACT_ID, version,
+                                       binaries);
+                       indexes.add(binariesArtifact);
+                       if (sources != null) {
+                               Artifact sourcesArtifact = writeIndex(session,
+                                               artifactBasePath, groupId,
+                                               RepoConstants.SOURCES_ARTIFACT_ID, version, sources);
+                               indexes.add(sourcesArtifact);
+                       }
+                       // sdk
+                       writeIndex(session, artifactBasePath, groupId,
+                                       RepoConstants.SDK_ARTIFACT_ID, version, indexes);
+                       session.save();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot write indexes for group " + groupId,
+                                       e);
+               }
+       }
+
+       /** Write a group index. */
+       private static Artifact writeIndex(Session session,
+                       String artifactBasePath, String groupId, String artifactId,
+                       String version, Set<Artifact> artifacts) throws RepositoryException {
+               Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
+                               version);
+               String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
+                               artifacts, null);
+               Node node = RepoUtils.copyBytesAsArtifact(
+                               session.getNode(artifactBasePath), artifact, pom.getBytes());
+               addMavenChecksums(node);
+               return artifact;
+       }
+
+       /** Add files containing the SHA-1 and MD5 checksums. */
+       public static void addMavenChecksums(Node node) throws RepositoryException {
+               // TODO optimize
+               String sha = JcrUtils.checksumFile(node, "SHA-1");
+               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
+                               sha.getBytes());
+               String md5 = JcrUtils.checksumFile(node, "MD5");
+               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
+                               md5.getBytes());
+       }
+
+       /**
+        * Custom copy since the one in commons does not fit the needs when copying
+        * a workspace completely.
+        */
+       public static void copy(Node fromNode, Node toNode) {
+               copy(fromNode, toNode, null);
+       }
+
+       public static void copy(Node fromNode, Node toNode, JcrMonitor monitor) {
+               try {
+                       String fromPath = fromNode.getPath();
+                       if (monitor != null)
+                               monitor.subTask("copying node :" + fromPath);
+                       if (log.isDebugEnabled())
+                               log.debug("copy node :" + fromPath);
+
+                       // FIXME : small hack to enable specific workspace copy
+                       if (fromNode.isNodeType("rep:ACL")
+                                       || fromNode.isNodeType("rep:system")) {
+                               if (log.isTraceEnabled())
+                                       log.trace("node " + fromNode + " skipped");
+                               return;
+                       }
+
+                       // add mixins
+                       for (NodeType mixinType : fromNode.getMixinNodeTypes()) {
+                               toNode.addMixin(mixinType.getName());
+                       }
+
+                       // Double check
+                       for (NodeType mixinType : toNode.getMixinNodeTypes()) {
+                               if (log.isDebugEnabled())
+                                       log.debug(mixinType.getName());
+                       }
+
+                       // process properties
+                       PropertyIterator pit = fromNode.getProperties();
+                       properties: while (pit.hasNext()) {
+                               Property fromProperty = pit.nextProperty();
+                               String propName = fromProperty.getName();
+                               try {
+                                       String propertyName = fromProperty.getName();
+                                       if (toNode.hasProperty(propertyName)
+                                                       && toNode.getProperty(propertyName).getDefinition()
+                                                                       .isProtected())
+                                               continue properties;
+
+                                       if (fromProperty.getDefinition().isProtected())
+                                               continue properties;
+
+                                       if (propertyName.equals("jcr:created")
+                                                       || propertyName.equals("jcr:createdBy")
+                                                       || propertyName.equals("jcr:lastModified")
+                                                       || propertyName.equals("jcr:lastModifiedBy"))
+                                               continue properties;
+
+                                       if (fromProperty.isMultiple()) {
+                                               toNode.setProperty(propertyName,
+                                                               fromProperty.getValues());
+                                       } else {
+                                               toNode.setProperty(propertyName,
+                                                               fromProperty.getValue());
+                                       }
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot property " + propName, e);
+                               }
+                       }
+
+                       // recursively process children nodes
+                       NodeIterator nit = fromNode.getNodes();
+                       while (nit.hasNext()) {
+                               Node fromChild = nit.nextNode();
+                               Integer index = fromChild.getIndex();
+                               String nodeRelPath = fromChild.getName() + "[" + index + "]";
+                               Node toChild;
+                               if (toNode.hasNode(nodeRelPath))
+                                       toChild = toNode.getNode(nodeRelPath);
+                               else
+                                       toChild = toNode.addNode(fromChild.getName(), fromChild
+                                                       .getPrimaryNodeType().getName());
+                               copy(fromChild, toChild);
+                       }
+
+                       // update jcr:lastModified and jcr:lastModifiedBy in toNode in
+                       // case
+                       // they existed
+                       if (!toNode.getDefinition().isProtected()
+                                       && toNode.isNodeType(NodeType.MIX_LAST_MODIFIED))
+                               JcrUtils.updateLastModified(toNode);
+
+                       // Workaround to reduce session size: artifact is a saveable
+                       // unity
+                       if (toNode.isNodeType(SlcTypes.SLC_ARTIFACT))
+                               toNode.getSession().save();
+
+                       if (monitor != null)
+                               monitor.worked(1);
+
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot copy " + fromNode + " to " + toNode,
+                                       e);
+               }
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmIndexer.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmIndexer.java
new file mode 100644 (file)
index 0000000..fadac82
--- /dev/null
@@ -0,0 +1,116 @@
+package org.argeo.slc.repo;
+
+import static org.redline_rpm.header.Header.HeaderTag.HEADERIMMUTABLE;
+import static org.redline_rpm.header.Signature.SignatureTag.SIGNATURES;
+
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.io.FilenameUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.redline_rpm.ChannelWrapper.Key;
+import org.redline_rpm.ReadableChannelWrapper;
+import org.redline_rpm.header.AbstractHeader;
+import org.redline_rpm.header.Format;
+import org.redline_rpm.header.Header;
+
+/** Indexes an RPM file. */
+public class RpmIndexer implements NodeIndexer, SlcNames {
+       private Boolean force = false;
+
+       @Override
+       public Boolean support(String path) {
+               return FilenameUtils.getExtension(path).equals("rpm");
+       }
+
+       @Override
+       public void index(Node node) {
+               try {
+                       if (!support(node.getPath()))
+                               return;
+
+                       // Already indexed
+                       if (!force && node.isNodeType(SlcTypes.SLC_RPM))
+                               return;
+
+                       if (!node.isNodeType(NodeType.NT_FILE))
+                               return;
+
+                       InputStream in = node.getNode(Node.JCR_CONTENT)
+                                       .getProperty(Property.JCR_DATA).getBinary().getStream();
+                       ReadableChannelWrapper channel = new ReadableChannelWrapper(
+                                       Channels.newChannel(in));
+                       Format format = readRpmInfo(channel);
+
+                       node.addMixin(SlcTypes.SLC_RPM);
+                       node.setProperty(SLC_NAME, readTag(format, Header.HeaderTag.NAME));
+                       String rpmVersion = readTag(format, Header.HeaderTag.VERSION);
+                       String rpmRelease = readTag(format, Header.HeaderTag.RELEASE);
+                       node.setProperty(SLC_RPM_VERSION, rpmVersion);
+                       node.setProperty(SLC_RPM_RELEASE, rpmRelease);
+                       node.setProperty(SLC_VERSION, rpmVersion + "-" + rpmRelease);
+
+                       String arch = readTag(format, Header.HeaderTag.ARCH);
+                       if (arch != null)
+                               node.setProperty(SLC_RPM_ARCH, arch);
+
+                       String archiveSize = readTag(format, Header.HeaderTag.ARCHIVESIZE);
+                       if (archiveSize != null)
+                               node.setProperty(SLC_RPM_ARCHIVE_SIZE,
+                                               Long.parseLong(archiveSize));
+
+                       node.getSession().save();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot index " + node, e);
+               }
+
+       }
+
+       @SuppressWarnings("unused")
+       public Format readRpmInfo(ReadableChannelWrapper channel) throws Exception {
+               Format format = new Format();
+
+               Key<Integer> lead = channel.start();
+               format.getLead().read(channel);
+               // System.out.println( "Lead ended at '" + in.finish( lead) + "'.");
+
+               Key<Integer> signature = channel.start();
+               int count = format.getSignature().read(channel);
+               int expected = ByteBuffer
+                               .wrap((byte[]) format.getSignature().getEntry(SIGNATURES)
+                                               .getValues(), 8, 4).getInt()
+                               / -16;
+               // System.out.println( "Signature ended at '" + in.finish( signature) +
+               // "' and contained '" + count + "' headers (expected '" + expected +
+               // "').");
+
+               Key<Integer> header = channel.start();
+               count = format.getHeader().read(channel);
+               expected = ByteBuffer.wrap(
+                               (byte[]) format.getHeader().getEntry(HEADERIMMUTABLE)
+                                               .getValues(), 8, 4).getInt()
+                               / -16;
+               // System.out.println( "Header ended at '" + in.finish( header) +
+               // " and contained '" + count + "' headers (expected '" + expected +
+               // "').");
+
+               return format;
+       }
+
+       private String readTag(Format format, Header.HeaderTag tag) {
+               AbstractHeader.Entry<?> entry = format.getHeader().getEntry(tag);
+               if (entry == null)
+                       return null;
+               if (entry.getValues() == null)
+                       return null;
+               Object[] values = (Object[]) entry.getValues();
+               return values[0].toString().trim();
+       }
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmRepoManager.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/RpmRepoManager.java
new file mode 100644 (file)
index 0000000..7535468
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.repo;
+
+public interface RpmRepoManager {
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/SlcRepoManager.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/SlcRepoManager.java
new file mode 100644 (file)
index 0000000..a0ba8e0
--- /dev/null
@@ -0,0 +1,10 @@
+package org.argeo.slc.repo;
+
+/** Coordinator of the various type of repository (Java, RPM, etc.) */
+public interface SlcRepoManager {
+       /** @return null if Java not supported. */
+       public JavaRepoManager getJavaRepoManager();
+
+       /** @return null if RPM not supported. */
+       public RpmRepoManager getRpmRepoManager();
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/core/AbstractJcrRepoManager.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/core/AbstractJcrRepoManager.java
new file mode 100644 (file)
index 0000000..4bdda83
--- /dev/null
@@ -0,0 +1,106 @@
+package org.argeo.slc.repo.core;
+
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.NodeIndexer;
+
+/** Generic operations on a JCR-based repo. */
+abstract class AbstractJcrRepoManager {
+       private final static Log log = LogFactory
+                       .getLog(AbstractJcrRepoManager.class);
+       private String securityWorkspace = "security";
+
+       private Repository jcrRepository;
+       private Session adminSession;
+       private List<NodeIndexer> nodeIndexers;
+
+       // registries
+       private Map<String, Session> workspaceSessions = new TreeMap<String, Session>();
+       private Map<String, WorkspaceIndexer> workspaceIndexers = new TreeMap<String, WorkspaceIndexer>();
+
+       public void init() {
+               try {
+                       adminSession = jcrRepository.login();
+                       String[] workspaceNames = adminSession.getWorkspace()
+                                       .getAccessibleWorkspaceNames();
+                       for (String workspaceName : workspaceNames) {
+                               if (workspaceName.equals(securityWorkspace))
+                                       continue;
+                               if (workspaceName.equals(adminSession.getWorkspace().getName()))
+                                       continue;
+                               workspaceInit(workspaceName);
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot initialize repo manager", e);
+               }
+       }
+
+       public void destroy() {
+               for (String key : workspaceIndexers.keySet()) {
+                       workspaceIndexers.get(key).close();
+               }
+
+               for (String key : workspaceSessions.keySet()) {
+                       JcrUtils.logoutQuietly(workspaceSessions.get(key));
+               }
+               JcrUtils.logoutQuietly(adminSession);
+       }
+
+       public void createWorkspace(String workspaceName) {
+               try {
+                       try {
+                               jcrRepository.login(workspaceName);
+                               throw new SlcException("Workspace " + workspaceName
+                                               + " exists already.");
+                       } catch (NoSuchWorkspaceException e) {
+                               // try to create workspace
+                               adminSession.getWorkspace().createWorkspace(workspaceName);
+                               workspaceInit(workspaceName);
+                       }
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot create workspace " + workspaceName,
+                                       e);
+               }
+       }
+
+       protected void workspaceInit(String workspaceName) {
+               Session workspaceAdminSession = null;
+               try {
+                       workspaceAdminSession = jcrRepository.login(workspaceName);
+                       workspaceSessions.put(workspaceName, adminSession);
+                       JcrUtils.addPrivilege(workspaceAdminSession, "/",
+                                       SlcConstants.ROLE_SLC, "jcr:all");
+                       WorkspaceIndexer workspaceIndexer = new WorkspaceIndexer(
+                                       workspaceAdminSession, nodeIndexers);
+                       workspaceIndexers.put(workspaceName, workspaceIndexer);
+               } catch (RepositoryException e) {
+                       log.error("Cannot initialize workspace " + workspaceName, e);
+               } finally {
+                       JcrUtils.logoutQuietly(workspaceAdminSession);
+               }
+       }
+
+       public void setJcrRepository(Repository jcrRepository) {
+               this.jcrRepository = jcrRepository;
+       }
+
+       public void setNodeIndexers(List<NodeIndexer> nodeIndexers) {
+               this.nodeIndexers = nodeIndexers;
+       }
+
+       public void setSecurityWorkspace(String securityWorkspace) {
+               this.securityWorkspace = securityWorkspace;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/core/JavaRepoManagerImpl.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/core/JavaRepoManagerImpl.java
new file mode 100644 (file)
index 0000000..dfd0c8a
--- /dev/null
@@ -0,0 +1,8 @@
+package org.argeo.slc.repo.core;
+
+import org.argeo.slc.repo.JavaRepoManager;
+
+/** Java-specific operations */
+public class JavaRepoManagerImpl extends AbstractJcrRepoManager implements
+               JavaRepoManager {
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RepoServiceImpl.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RepoServiceImpl.java
new file mode 100644 (file)
index 0000000..bca40cb
--- /dev/null
@@ -0,0 +1,43 @@
+package org.argeo.slc.repo.core;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.api.security.Keyring;
+import org.argeo.slc.repo.RepoService;
+import org.argeo.slc.repo.RepoUtils;
+
+/**
+ * Work in Progress - enhance this. First implementation of a service that
+ * centralizes session management in an argeo SLC context, repositories are
+ * either defined using an URI and a workspace name in a anonymous context or
+ * using connection information that are store in a corresponding node in the
+ * local repository home
+ */
+public class RepoServiceImpl implements RepoService {
+
+       /* DEPENDENCY INJECTION */
+       private Repository nodeRepository;
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+
+       public Session getRemoteSession(String repoNodePath, String uri,
+                       String workspaceName) {
+               return RepoUtils.getRemoteSession(repositoryFactory, keyring,
+                               nodeRepository, repoNodePath, uri, workspaceName);
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RpmRepoManagerImpl.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/core/RpmRepoManagerImpl.java
new file mode 100644 (file)
index 0000000..6e83523
--- /dev/null
@@ -0,0 +1,8 @@
+package org.argeo.slc.repo.core;
+
+import org.argeo.slc.repo.RpmRepoManager;
+
+/** RPM-specific operations */
+public class RpmRepoManagerImpl extends AbstractJcrRepoManager implements
+               RpmRepoManager {
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/core/SlcRepoManagerImpl.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/core/SlcRepoManagerImpl.java
new file mode 100644 (file)
index 0000000..bce6f03
--- /dev/null
@@ -0,0 +1,38 @@
+package org.argeo.slc.repo.core;
+
+import org.argeo.slc.repo.JavaRepoManager;
+import org.argeo.slc.repo.RpmRepoManager;
+import org.argeo.slc.repo.SlcRepoManager;
+
+/** Coordinator of the various repositories. */
+public class SlcRepoManagerImpl implements SlcRepoManager {
+       private JavaRepoManager javaRepoManager;
+       private RpmRepoManager rpmRepoManager;
+
+       public void init() {
+
+       }
+
+       public void destroy() {
+
+       }
+
+       @Override
+       public JavaRepoManager getJavaRepoManager() {
+               return javaRepoManager;
+       }
+
+       public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
+               this.javaRepoManager = javaRepoManager;
+       }
+
+       @Override
+       public RpmRepoManager getRpmRepoManager() {
+               return rpmRepoManager;
+       }
+
+       public void setRpmRepoManager(RpmRepoManager rpmRepoManager) {
+               this.rpmRepoManager = rpmRepoManager;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/core/WorkspaceIndexer.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/core/WorkspaceIndexer.java
new file mode 100644 (file)
index 0000000..d0233c3
--- /dev/null
@@ -0,0 +1,82 @@
+package org.argeo.slc.repo.core;
+
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.NodeIndexer;
+
+/** Maintains the metadata of a workspace, using listeners */
+public class WorkspaceIndexer {
+       private final static Log log = LogFactory.getLog(WorkspaceIndexer.class);
+
+       private final Session adminSession;
+       private IndexingListener artifactListener;
+       /** order may be important */
+       private final List<NodeIndexer> nodeIndexers;
+
+       public WorkspaceIndexer(Session adminSession, List<NodeIndexer> nodeIndexers) {
+               this.adminSession = adminSession;
+               this.nodeIndexers = nodeIndexers;
+               try {
+                       artifactListener = new IndexingListener();
+                       adminSession
+                                       .getWorkspace()
+                                       .getObservationManager()
+                                       .addEventListener(artifactListener, Event.NODE_ADDED, "/",
+                                                       true, null, null, true);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot initialize repository backend", e);
+               }
+       }
+
+       public void close() {
+               try {
+                       adminSession.getWorkspace().getObservationManager()
+                                       .removeEventListener(artifactListener);
+               } catch (RepositoryException e) {
+                       log.error("Cannot close workspace indexer "
+                                       + adminSession.getWorkspace().getName(), e);
+               }
+       }
+
+       class IndexingListener implements EventListener {
+
+               public void onEvent(EventIterator events) {
+                       while (events.hasNext()) {
+                               Event event = events.nextEvent();
+                               try {
+                                       String newNodePath = event.getPath();
+                                       Node newNode = null;
+                                       for (NodeIndexer nodeIndexer : nodeIndexers) {
+                                               try {
+                                                       if (nodeIndexer.support(newNodePath)) {
+                                                               if (newNode == null)
+                                                                       newNode = adminSession.getNode(newNodePath);
+                                                               nodeIndexer.index(newNode);
+                                                       }
+                                               } catch (RuntimeException e) {
+                                                       e.printStackTrace();
+                                                       throw e;
+                                               }
+                                       }
+                                       if (newNode != null)
+                                               adminSession.save();
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot process event " + event, e);
+                               } finally {
+                                       JcrUtils.discardQuietly(adminSession);
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/AntPathMatcher.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/AntPathMatcher.java
new file mode 100644 (file)
index 0000000..20becbc
--- /dev/null
@@ -0,0 +1,424 @@
+/*\r
+ * Copyright 2002-2007 the original author or authors.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.argeo.slc.repo.internal.springutil;\r
+\r
+/**\r
+ * PathMatcher implementation for Ant-style path patterns. Examples are provided\r
+ * below.\r
+ *\r
+ * <p>\r
+ * Part of this mapping code has been kindly borrowed from\r
+ * <a href="http://ant.apache.org">Apache Ant</a>.\r
+ *\r
+ * <p>\r
+ * The mapping matches URLs using the following rules:<br>\r
+ * <ul>\r
+ * <li>? matches one character</li>\r
+ * <li>* matches zero or more characters</li>\r
+ * <li>** matches zero or more 'directories' in a path</li>\r
+ * </ul>\r
+ *\r
+ * <p>\r
+ * Some examples:<br>\r
+ * <ul>\r
+ * <li><code>com/t?st.jsp</code> - matches <code>com/test.jsp</code> but also\r
+ * <code>com/tast.jsp</code> or <code>com/txst.jsp</code></li>\r
+ * <li><code>com/*.jsp</code> - matches all <code>.jsp</code> files in the\r
+ * <code>com</code> directory</li>\r
+ * <li><code>com/&#42;&#42;/test.jsp</code> - matches all <code>test.jsp</code>\r
+ * files underneath the <code>com</code> path</li>\r
+ * <li><code>org/springframework/&#42;&#42;/*.jsp</code> - matches all\r
+ * <code>.jsp</code> files underneath the <code>org/springframework</code>\r
+ * path</li>\r
+ * <li><code>org/&#42;&#42;/servlet/bla.jsp</code> - matches\r
+ * <code>org/springframework/servlet/bla.jsp</code> but also\r
+ * <code>org/springframework/testing/servlet/bla.jsp</code> and\r
+ * <code>org/servlet/bla.jsp</code></li>\r
+ * </ul>\r
+ *\r
+ * @author Alef Arendsen\r
+ * @author Juergen Hoeller\r
+ * @author Rob Harrop\r
+ * @since 16.07.2003\r
+ */\r
+public class AntPathMatcher implements PathMatcher {\r
+\r
+       /** Default path separator: "/" */\r
+       public static final String DEFAULT_PATH_SEPARATOR = "/";\r
+\r
+       private String pathSeparator = DEFAULT_PATH_SEPARATOR;\r
+\r
+       /**\r
+        * Set the path separator to use for pattern parsing. Default is "/", as in Ant.\r
+        */\r
+       public void setPathSeparator(String pathSeparator) {\r
+               this.pathSeparator = (pathSeparator != null ? pathSeparator : DEFAULT_PATH_SEPARATOR);\r
+       }\r
+\r
+       public boolean isPattern(String path) {\r
+               return (path.indexOf('*') != -1 || path.indexOf('?') != -1);\r
+       }\r
+\r
+       public boolean match(String pattern, String path) {\r
+               return doMatch(pattern, path, true);\r
+       }\r
+\r
+       public boolean matchStart(String pattern, String path) {\r
+               return doMatch(pattern, path, false);\r
+       }\r
+\r
+       /**\r
+        * Actually match the given <code>path</code> against the given\r
+        * <code>pattern</code>.\r
+        * \r
+        * @param pattern   the pattern to match against\r
+        * @param path      the path String to test\r
+        * @param fullMatch whether a full pattern match is required (else a pattern\r
+        *                  match as far as the given base path goes is sufficient)\r
+        * @return <code>true</code> if the supplied <code>path</code> matched,\r
+        *         <code>false</code> if it didn't\r
+        */\r
+       protected boolean doMatch(String pattern, String path, boolean fullMatch) {\r
+               if (path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {\r
+                       return false;\r
+               }\r
+\r
+//             String[] pattDirs = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator);\r
+//             String[] pathDirs = StringUtils.tokenizeToStringArray(path, this.pathSeparator);\r
+               // mbaudier - 2020-03-13 : Use standard Java call:\r
+               String[] pattDirs = pattern.split(this.pathSeparator);\r
+               String[] pathDirs = path.split(this.pathSeparator);\r
+\r
+               int pattIdxStart = 0;\r
+               int pattIdxEnd = pattDirs.length - 1;\r
+               int pathIdxStart = 0;\r
+               int pathIdxEnd = pathDirs.length - 1;\r
+\r
+               // Match all elements up to the first **\r
+               while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {\r
+                       String patDir = pattDirs[pattIdxStart];\r
+                       if ("**".equals(patDir)) {\r
+                               break;\r
+                       }\r
+                       if (!matchStrings(patDir, pathDirs[pathIdxStart])) {\r
+                               return false;\r
+                       }\r
+                       pattIdxStart++;\r
+                       pathIdxStart++;\r
+               }\r
+\r
+               if (pathIdxStart > pathIdxEnd) {\r
+                       // Path is exhausted, only match if rest of pattern is * or **'s\r
+                       if (pattIdxStart > pattIdxEnd) {\r
+                               return (pattern.endsWith(this.pathSeparator) ? path.endsWith(this.pathSeparator)\r
+                                               : !path.endsWith(this.pathSeparator));\r
+                       }\r
+                       if (!fullMatch) {\r
+                               return true;\r
+                       }\r
+                       if (pattIdxStart == pattIdxEnd && pattDirs[pattIdxStart].equals("*") && path.endsWith(this.pathSeparator)) {\r
+                               return true;\r
+                       }\r
+                       for (int i = pattIdxStart; i <= pattIdxEnd; i++) {\r
+                               if (!pattDirs[i].equals("**")) {\r
+                                       return false;\r
+                               }\r
+                       }\r
+                       return true;\r
+               } else if (pattIdxStart > pattIdxEnd) {\r
+                       // String not exhausted, but pattern is. Failure.\r
+                       return false;\r
+               } else if (!fullMatch && "**".equals(pattDirs[pattIdxStart])) {\r
+                       // Path start definitely matches due to "**" part in pattern.\r
+                       return true;\r
+               }\r
+\r
+               // up to last '**'\r
+               while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {\r
+                       String patDir = pattDirs[pattIdxEnd];\r
+                       if (patDir.equals("**")) {\r
+                               break;\r
+                       }\r
+                       if (!matchStrings(patDir, pathDirs[pathIdxEnd])) {\r
+                               return false;\r
+                       }\r
+                       pattIdxEnd--;\r
+                       pathIdxEnd--;\r
+               }\r
+               if (pathIdxStart > pathIdxEnd) {\r
+                       // String is exhausted\r
+                       for (int i = pattIdxStart; i <= pattIdxEnd; i++) {\r
+                               if (!pattDirs[i].equals("**")) {\r
+                                       return false;\r
+                               }\r
+                       }\r
+                       return true;\r
+               }\r
+\r
+               while (pattIdxStart != pattIdxEnd && pathIdxStart <= pathIdxEnd) {\r
+                       int patIdxTmp = -1;\r
+                       for (int i = pattIdxStart + 1; i <= pattIdxEnd; i++) {\r
+                               if (pattDirs[i].equals("**")) {\r
+                                       patIdxTmp = i;\r
+                                       break;\r
+                               }\r
+                       }\r
+                       if (patIdxTmp == pattIdxStart + 1) {\r
+                               // '**/**' situation, so skip one\r
+                               pattIdxStart++;\r
+                               continue;\r
+                       }\r
+                       // Find the pattern between padIdxStart & padIdxTmp in str between\r
+                       // strIdxStart & strIdxEnd\r
+                       int patLength = (patIdxTmp - pattIdxStart - 1);\r
+                       int strLength = (pathIdxEnd - pathIdxStart + 1);\r
+                       int foundIdx = -1;\r
+\r
+                       strLoop: for (int i = 0; i <= strLength - patLength; i++) {\r
+                               for (int j = 0; j < patLength; j++) {\r
+                                       String subPat = (String) pattDirs[pattIdxStart + j + 1];\r
+                                       String subStr = (String) pathDirs[pathIdxStart + i + j];\r
+                                       if (!matchStrings(subPat, subStr)) {\r
+                                               continue strLoop;\r
+                                       }\r
+                               }\r
+                               foundIdx = pathIdxStart + i;\r
+                               break;\r
+                       }\r
+\r
+                       if (foundIdx == -1) {\r
+                               return false;\r
+                       }\r
+\r
+                       pattIdxStart = patIdxTmp;\r
+                       pathIdxStart = foundIdx + patLength;\r
+               }\r
+\r
+               for (int i = pattIdxStart; i <= pattIdxEnd; i++) {\r
+                       if (!pattDirs[i].equals("**")) {\r
+                               return false;\r
+                       }\r
+               }\r
+\r
+               return true;\r
+       }\r
+\r
+       /**\r
+        * Tests whether or not a string matches against a pattern. The pattern may\r
+        * contain two special characters:<br>\r
+        * '*' means zero or more characters<br>\r
+        * '?' means one and only one character\r
+        * \r
+        * @param pattern pattern to match against. Must not be <code>null</code>.\r
+        * @param str     string which must be matched against the pattern. Must not be\r
+        *                <code>null</code>.\r
+        * @return <code>true</code> if the string matches against the pattern, or\r
+        *         <code>false</code> otherwise.\r
+        */\r
+       private boolean matchStrings(String pattern, String str) {\r
+               char[] patArr = pattern.toCharArray();\r
+               char[] strArr = str.toCharArray();\r
+               int patIdxStart = 0;\r
+               int patIdxEnd = patArr.length - 1;\r
+               int strIdxStart = 0;\r
+               int strIdxEnd = strArr.length - 1;\r
+               char ch;\r
+\r
+               boolean containsStar = false;\r
+               for (int i = 0; i < patArr.length; i++) {\r
+                       if (patArr[i] == '*') {\r
+                               containsStar = true;\r
+                               break;\r
+                       }\r
+               }\r
+\r
+               if (!containsStar) {\r
+                       // No '*'s, so we make a shortcut\r
+                       if (patIdxEnd != strIdxEnd) {\r
+                               return false; // Pattern and string do not have the same size\r
+                       }\r
+                       for (int i = 0; i <= patIdxEnd; i++) {\r
+                               ch = patArr[i];\r
+                               if (ch != '?') {\r
+                                       if (ch != strArr[i]) {\r
+                                               return false;// Character mismatch\r
+                                       }\r
+                               }\r
+                       }\r
+                       return true; // String matches against pattern\r
+               }\r
+\r
+               if (patIdxEnd == 0) {\r
+                       return true; // Pattern contains only '*', which matches anything\r
+               }\r
+\r
+               // Process characters before first star\r
+               while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) {\r
+                       if (ch != '?') {\r
+                               if (ch != strArr[strIdxStart]) {\r
+                                       return false;// Character mismatch\r
+                               }\r
+                       }\r
+                       patIdxStart++;\r
+                       strIdxStart++;\r
+               }\r
+               if (strIdxStart > strIdxEnd) {\r
+                       // All characters in the string are used. Check if only '*'s are\r
+                       // left in the pattern. If so, we succeeded. Otherwise failure.\r
+                       for (int i = patIdxStart; i <= patIdxEnd; i++) {\r
+                               if (patArr[i] != '*') {\r
+                                       return false;\r
+                               }\r
+                       }\r
+                       return true;\r
+               }\r
+\r
+               // Process characters after last star\r
+               while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) {\r
+                       if (ch != '?') {\r
+                               if (ch != strArr[strIdxEnd]) {\r
+                                       return false;// Character mismatch\r
+                               }\r
+                       }\r
+                       patIdxEnd--;\r
+                       strIdxEnd--;\r
+               }\r
+               if (strIdxStart > strIdxEnd) {\r
+                       // All characters in the string are used. Check if only '*'s are\r
+                       // left in the pattern. If so, we succeeded. Otherwise failure.\r
+                       for (int i = patIdxStart; i <= patIdxEnd; i++) {\r
+                               if (patArr[i] != '*') {\r
+                                       return false;\r
+                               }\r
+                       }\r
+                       return true;\r
+               }\r
+\r
+               // process pattern between stars. padIdxStart and patIdxEnd point\r
+               // always to a '*'.\r
+               while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {\r
+                       int patIdxTmp = -1;\r
+                       for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {\r
+                               if (patArr[i] == '*') {\r
+                                       patIdxTmp = i;\r
+                                       break;\r
+                               }\r
+                       }\r
+                       if (patIdxTmp == patIdxStart + 1) {\r
+                               // Two stars next to each other, skip the first one.\r
+                               patIdxStart++;\r
+                               continue;\r
+                       }\r
+                       // Find the pattern between padIdxStart & padIdxTmp in str between\r
+                       // strIdxStart & strIdxEnd\r
+                       int patLength = (patIdxTmp - patIdxStart - 1);\r
+                       int strLength = (strIdxEnd - strIdxStart + 1);\r
+                       int foundIdx = -1;\r
+                       strLoop: for (int i = 0; i <= strLength - patLength; i++) {\r
+                               for (int j = 0; j < patLength; j++) {\r
+                                       ch = patArr[patIdxStart + j + 1];\r
+                                       if (ch != '?') {\r
+                                               if (ch != strArr[strIdxStart + i + j]) {\r
+                                                       continue strLoop;\r
+                                               }\r
+                                       }\r
+                               }\r
+\r
+                               foundIdx = strIdxStart + i;\r
+                               break;\r
+                       }\r
+\r
+                       if (foundIdx == -1) {\r
+                               return false;\r
+                       }\r
+\r
+                       patIdxStart = patIdxTmp;\r
+                       strIdxStart = foundIdx + patLength;\r
+               }\r
+\r
+               // All characters in the string are used. Check if only '*'s are left\r
+               // in the pattern. If so, we succeeded. Otherwise failure.\r
+               for (int i = patIdxStart; i <= patIdxEnd; i++) {\r
+                       if (patArr[i] != '*') {\r
+                               return false;\r
+                       }\r
+               }\r
+\r
+               return true;\r
+       }\r
+\r
+       /**\r
+        * Given a pattern and a full path, determine the pattern-mapped part.\r
+        * <p>\r
+        * For example:\r
+        * <ul>\r
+        * <li>'<code>/docs/cvs/commit.html</code>' and\r
+        * '<code>/docs/cvs/commit.html</code> to ''</li>\r
+        * <li>'<code>/docs/*</code>' and '<code>/docs/cvs/commit</code> to\r
+        * '<code>cvs/commit</code>'</li>\r
+        * <li>'<code>/docs/cvs/*.html</code>' and '<code>/docs/cvs/commit.html</code>\r
+        * to '<code>commit.html</code>'</li>\r
+        * <li>'<code>/docs/**</code>' and '<code>/docs/cvs/commit</code> to\r
+        * '<code>cvs/commit</code>'</li>\r
+        * <li>'<code>/docs/**\/*.html</code>' and '<code>/docs/cvs/commit.html</code>\r
+        * to '<code>cvs/commit.html</code>'</li>\r
+        * <li>'<code>/*.html</code>' and '<code>/docs/cvs/commit.html</code> to\r
+        * '<code>docs/cvs/commit.html</code>'</li>\r
+        * <li>'<code>*.html</code>' and '<code>/docs/cvs/commit.html</code> to\r
+        * '<code>/docs/cvs/commit.html</code>'</li>\r
+        * <li>'<code>*</code>' and '<code>/docs/cvs/commit.html</code> to\r
+        * '<code>/docs/cvs/commit.html</code>'</li>\r
+        * </ul>\r
+        * <p>\r
+        * Assumes that {@link #match} returns <code>true</code> for\r
+        * '<code>pattern</code>' and '<code>path</code>', but does <strong>not</strong>\r
+        * enforce this.\r
+        */\r
+       public String extractPathWithinPattern(String pattern, String path) {\r
+//             String[] patternParts = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator);\r
+//             String[] pathParts = StringUtils.tokenizeToStringArray(path, this.pathSeparator);\r
+               // mbaudier - 2020-03-13 : Use standard Java call:\r
+               String[] patternParts = pattern.split(this.pathSeparator);\r
+               String[] pathParts = path.split(this.pathSeparator);\r
+\r
+               StringBuffer buffer = new StringBuffer();\r
+\r
+               // Add any path parts that have a wildcarded pattern part.\r
+               int puts = 0;\r
+               for (int i = 0; i < patternParts.length; i++) {\r
+                       String patternPart = patternParts[i];\r
+                       if ((patternPart.indexOf('*') > -1 || patternPart.indexOf('?') > -1) && pathParts.length >= i + 1) {\r
+                               if (puts > 0 || (i == 0 && !pattern.startsWith(this.pathSeparator))) {\r
+                                       buffer.append(this.pathSeparator);\r
+                               }\r
+                               buffer.append(pathParts[i]);\r
+                               puts++;\r
+                       }\r
+               }\r
+\r
+               // Append any trailing path parts.\r
+               for (int i = patternParts.length; i < pathParts.length; i++) {\r
+                       if (puts > 0 || i > 0) {\r
+                               buffer.append(this.pathSeparator);\r
+                       }\r
+                       buffer.append(pathParts[i]);\r
+               }\r
+\r
+               return buffer.toString();\r
+       }\r
+\r
+}\r
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/PathMatcher.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/internal/springutil/PathMatcher.java
new file mode 100644 (file)
index 0000000..9fc1f22
--- /dev/null
@@ -0,0 +1,91 @@
+/*\r
+ * Copyright 2002-2007 the original author or authors.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.argeo.slc.repo.internal.springutil;\r
+\r
+/**\r
+ * Strategy interface for <code>String</code>-based path matching.\r
+ * \r
+ * <p>Used by <code>org.springframework.core.io.support.PathMatchingResourcePatternResolver</code>,\r
+ * {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping},\r
+ * {@link org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver},\r
+ * and {@link org.springframework.web.servlet.mvc.WebContentInterceptor}.\r
+ *\r
+ * <p>The default implementation is {@link AntPathMatcher}, supporting the\r
+ * Ant-style pattern syntax.\r
+ *\r
+ * @author Juergen Hoeller\r
+ * @since 1.2\r
+ * @see AntPathMatcher\r
+ */\r
+public interface PathMatcher {\r
+\r
+       /**\r
+        * Does the given <code>path</code> represent a pattern that can be matched\r
+        * by an implementation of this interface?\r
+        * <p>If the return value is <code>false</code>, then the {@link #match}\r
+        * method does not have to be used because direct equality comparisons\r
+        * on the static path Strings will lead to the same result.\r
+        * @param path the path String to check\r
+        * @return <code>true</code> if the given <code>path</code> represents a pattern\r
+        */\r
+       boolean isPattern(String path);\r
+\r
+       /**\r
+        * Match the given <code>path</code> against the given <code>pattern</code>,\r
+        * according to this PathMatcher's matching strategy.\r
+        * @param pattern the pattern to match against\r
+        * @param path the path String to test\r
+        * @return <code>true</code> if the supplied <code>path</code> matched,\r
+        * <code>false</code> if it didn't\r
+        */\r
+       boolean match(String pattern, String path);\r
+\r
+       /**\r
+        * Match the given <code>path</code> against the corresponding part of the given\r
+        * <code>pattern</code>, according to this PathMatcher's matching strategy.\r
+        * <p>Determines whether the pattern at least matches as far as the given base\r
+        * path goes, assuming that a full path may then match as well.\r
+        * @param pattern the pattern to match against\r
+        * @param path the path String to test\r
+        * @return <code>true</code> if the supplied <code>path</code> matched,\r
+        * <code>false</code> if it didn't\r
+        */\r
+       boolean matchStart(String pattern, String path);\r
+\r
+       /**\r
+        * Given a pattern and a full path, determine the pattern-mapped part.\r
+        * <p>This method is supposed to find out which part of the path is matched\r
+        * dynamically through an actual pattern, that is, it strips off a statically\r
+        * defined leading path from the given full path, returning only the actually\r
+        * pattern-matched part of the path.\r
+        * <p>For example: For "myroot/*.html" as pattern and "myroot/myfile.html"\r
+        * as full path, this method should return "myfile.html". The detailed\r
+        * determination rules are specified to this PathMatcher's matching strategy.\r
+        * <p>A simple implementation may return the given full path as-is in case\r
+        * of an actual pattern, and the empty String in case of the pattern not\r
+        * containing any dynamic parts (i.e. the <code>pattern</code> parameter being\r
+        * a static path that wouldn't qualify as an actual {@link #isPattern pattern}).\r
+        * A sophisticated implementation will differentiate between the static parts\r
+        * and the dynamic parts of the given path pattern.\r
+        * @param pattern the path pattern\r
+        * @param path the full path to introspect\r
+        * @return the pattern-mapped part of the given <code>path</code>\r
+        * (never <code>null</code>)\r
+        */\r
+       String extractPathWithinPattern(String pattern, String path);\r
+\r
+}\r
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/license/apache-2.0.txt b/org.argeo.slc.repo/src/org/argeo/slc/repo/license/apache-2.0.txt
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/license/bsd-3-clause.txt b/org.argeo.slc.repo/src/org/argeo/slc/repo/license/bsd-3-clause.txt
new file mode 100644 (file)
index 0000000..ed0116e
--- /dev/null
@@ -0,0 +1,12 @@
+Copyright (c) <YEAR>, <OWNER>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/license/cddl-1.0.txt b/org.argeo.slc.repo/src/org/argeo/slc/repo/license/cddl-1.0.txt
new file mode 100644 (file)
index 0000000..9dc4442
--- /dev/null
@@ -0,0 +1,93 @@
+ COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 1.
+
+Definitions.
+
+1.1. Contributor means each individual or entity that creates or contributes to the creation of Modifications.
+
+1.2. Contributor Version means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
+
+1.3. Covered Software means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
+
+1.4. Executable means the Covered Software in any form other than Source Code.
+
+1.5. Initial Developer means the individual or entity that first makes Original Software available under this License.
+
+1.6. Larger Work means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
+
+1.7. License means this document.
+
+1.8. Licensable means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
+
+1.9. Modifications means the Source Code and Executable form of any of the following: A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications; B. Any new file that contains any part of the Original Software or previous Modification; or C. Any new file that is contributed or otherwise made available under the terms of this License.
+
+1.10. Original Software means the Source Code and Executable form of computer software code that is originally released under this License.
+
+1.11. Patent Claims means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
+
+1.12. Source Code means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
+
+1.13. You (or Your) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, You includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, control means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
+
+2. License Grants.
+
+ 2.1. The Initial Developer Grant. Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
+
+(b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof);
+
+ (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License;
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
+
+2.2. Contributor Grant. Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
+
+(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
+
+(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
+
+(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
+
+3. Distribution Obligations.
+
+3.1. Availability of Source Code. Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
+
+3.2. Modifications. The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
+
+3.3. Required Notices. You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
+
+3.4. Application of Additional Terms. You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
+
+3.5. Distribution of Executable Versions. You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipients rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
+
+3.6. Larger Works. You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
+
+4. Versions of the License.
+
+4.1. New Versions. Sun Microsystems, Inc. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
+
+4.2. Effect of New Versions. You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
+
+4.3. Modified Versions. When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
+
+5. DISCLAIMER OF WARRANTY. COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN AS IS BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+6. TERMINATION.
+
+6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
+
+6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as Participant) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
+
+6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
+
+7. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTYS NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+8. U.S. GOVERNMENT END USERS. The Covered Software is a commercial item, as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of commercial computer software (as that term is defined at 48 C.F.R.  252.227-7014(a)(1)) and commercial computer software documentation as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
+
+9. MISCELLANEOUS. This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdictions conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
+
+10. RESPONSIBILITY FOR CLAIMS. As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
+
+NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California. 
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/license/epl-1.0.txt b/org.argeo.slc.repo/src/org/argeo/slc/repo/license/epl-1.0.txt
new file mode 100644 (file)
index 0000000..795c0c3
--- /dev/null
@@ -0,0 +1,73 @@
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+    a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+    b) in the case of each subsequent Contributor:
+    i) changes to the Program, and
+    ii) additions to the Program; 
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+    a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+    b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+    c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+    d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+    a) it complies with the terms and conditions of this Agreement; and
+    b) its license agreement:
+    i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+    ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+    iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+    iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. 
+
+When the Program is made available in source code form:
+
+    a) it must be made available under this Agreement; and
+    b) a copy of this Agreement must be included with each copy of the Program. 
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-2.0.txt b/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-2.0.txt
new file mode 100644 (file)
index 0000000..d159169
--- /dev/null
@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-3.0.txt b/org.argeo.slc.repo/src/org/argeo/slc/repo/license/gpl-3.0.txt
new file mode 100644 (file)
index 0000000..94a9ed0
--- /dev/null
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-2.1.txt b/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-2.1.txt
new file mode 100644 (file)
index 0000000..4362b49
--- /dev/null
@@ -0,0 +1,502 @@
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+                  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-3.0.txt b/org.argeo.slc.repo/src/org/argeo/slc/repo/license/lgpl-3.0.txt
new file mode 100644 (file)
index 0000000..65c5ca8
--- /dev/null
@@ -0,0 +1,165 @@
+                   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/license/mit.txt b/org.argeo.slc.repo/src/org/argeo/slc/repo/license/mit.txt
new file mode 100644 (file)
index 0000000..e14c371
--- /dev/null
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/AetherUtils.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/AetherUtils.java
new file mode 100644 (file)
index 0000000..e9360f9
--- /dev/null
@@ -0,0 +1,162 @@
+package org.argeo.slc.repo.maven;
+
+import java.util.regex.Pattern;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.graph.DependencyNode;
+
+/** Utilities related to Aether */
+public class AetherUtils {
+       public final static String SNAPSHOT = "SNAPSHOT";
+       // hacked from aether
+       public static final Pattern SNAPSHOT_TIMESTAMP = Pattern
+                       .compile("^(.*-)?([0-9]{8}.[0-9]{6}-[0-9]+)$");
+
+       private final static Log log = LogFactory.getLog(AetherUtils.class);
+
+       /** Logs a dependency node and its transitive dependencies as a tree. */
+       public static void logDependencyNode(int depth,
+                       DependencyNode dependencyNode) {
+               if (!log.isDebugEnabled())
+                       return;
+
+               StringBuffer prefix = new StringBuffer(depth * 2 + 2);
+               // prefix.append("|-");
+               for (int i = 0; i < depth * 2; i++) {
+                       prefix.append(' ');
+               }
+               Artifact artifact = dependencyNode.getDependency().getArtifact();
+               log.debug(prefix + "|-> " + artifact.getArtifactId() + " ["
+                               + artifact.getVersion() + "]"
+                               + (dependencyNode.getDependency().isOptional() ? " ?" : ""));
+               for (DependencyNode child : dependencyNode.getChildren()) {
+                       logDependencyNode(depth + 1, child);
+               }
+       }
+
+       /**
+        * Converts a path (relative to a repository root) to an {@link Artifact}.
+        * 
+        * @param path
+        *            the relative path
+        * @param type
+        *            the layout type, currently ignored because only the 'default'
+        *            Maven 2 layout is currently supported:
+        *            /my/group/id/artifactId/
+        *            version/artifactId-version[-classifier].extension
+        * @return the related artifact or null if the file is not an artifact
+        *         (Maven medata data XML files, check sums, etc.)
+        */
+       public static Artifact convertPathToArtifact(String path, String type) {
+               // TODO rewrite it with regexp (unit tests first!)
+
+               // normalize
+               if (path.startsWith("/"))
+                       path = path.substring(1);
+
+               // parse group id
+               String[] tokensSlash = path.split("/");
+               if (tokensSlash.length < 4)
+                       return null;
+               StringBuffer groupId = new StringBuffer(path.length());
+               for (int i = 0; i < tokensSlash.length - 3; i++) {
+                       if (i != 0)
+                               groupId.append('.');
+                       groupId.append(tokensSlash[i]);
+               }
+               String artifactId = tokensSlash[tokensSlash.length - 3];
+               String baseVersion = tokensSlash[tokensSlash.length - 2];
+               String fileName = tokensSlash[tokensSlash.length - 1];
+
+               if (!fileName.startsWith(artifactId))
+                       return null;
+               // FIXME make it configurable? (via an argument?)
+               if (FilenameUtils.isExtension(fileName, new String[] { "sha1", "md5" }))
+                       return null;
+
+               String extension = FilenameUtils.getExtension(fileName);
+               String baseName = FilenameUtils.getBaseName(fileName);
+
+               // check since we assume hereafter
+               if (!baseName.startsWith(artifactId))
+                       throw new SlcException("Base name '" + baseName
+                                       + " does not start with artifact id '" + artifactId
+                                       + "' in " + path);
+
+               boolean isSnapshot = baseVersion.endsWith("-" + SNAPSHOT);
+               String baseBaseVersion = isSnapshot ? baseVersion.substring(0,
+                               baseVersion.length() - SNAPSHOT.length() - 1) : baseVersion;
+               int artifactAndBaseBaseVersionLength = artifactId.length() + 1
+                               + baseBaseVersion.length() + 1;
+               String classifier = null;
+               if (baseName.length() > artifactAndBaseBaseVersionLength) {
+                       String dashRest = baseName
+                                       .substring(artifactAndBaseBaseVersionLength);
+                       String[] dashes = dashRest.split("-");
+
+                       if (isSnapshot) {
+                               if (dashes[0].equals(SNAPSHOT)) {
+                                       if (dashRest.length() > SNAPSHOT.length() + 1)
+                                               classifier = dashRest.substring(SNAPSHOT.length() + 1);
+
+                               } else {
+                                       if (dashes.length > 2)// assume no '-' in classifier
+                                               classifier = dashes[2];
+                               }
+                       } else {
+                               if (dashes.length > 0)
+                                       classifier = dashes[0];
+                       }
+               }
+
+               // classifier
+               // String classifier = null;
+               // int firstDash = baseName.indexOf('-');
+               // int classifierDash = baseName.lastIndexOf('-');
+               // if (classifierDash > 0 && classifierDash != firstDash) {
+               // classifier = baseName.substring(classifierDash + 1);
+               // }
+               // if (isSnapshot && classifier != null) {
+               // if (classifier.equals(SNAPSHOT))
+               // classifier = null;
+               // else
+               // try {
+               // Long.parseLong(classifier); // build number
+               // // if not failed this is a timestamped version
+               // classifier = null;
+               // } catch (NumberFormatException e) {
+               // // silent
+               // }
+               // }
+
+               // version
+               String version = baseName.substring(artifactId.length() + 1);
+               if (classifier != null)
+                       version = version.substring(0,
+                                       version.length() - classifier.length() - 1);
+
+               // consistency checks
+               if (!isSnapshot && !version.equals(baseVersion))
+                       throw new SlcException("Base version '" + baseVersion
+                                       + "' and version '" + version + "' not in line in " + path);
+               if (!isSnapshot && isSnapshotVersion(version))
+                       throw new SlcException("SNAPSHOT base version '" + baseVersion
+                                       + "' and version '" + version + "' not in line in " + path);
+
+               DefaultArtifact artifact = new DefaultArtifact(groupId.toString(),
+                               artifactId, classifier, extension, version);
+               return artifact;
+       }
+
+       /** Hacked from aether */
+       public static boolean isSnapshotVersion(String version) {
+               return version.endsWith(SNAPSHOT)
+                               || SNAPSHOT_TIMESTAMP.matcher(version).matches();
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ArtifactIdComparator.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ArtifactIdComparator.java
new file mode 100644 (file)
index 0000000..7aef78d
--- /dev/null
@@ -0,0 +1,20 @@
+package org.argeo.slc.repo.maven;
+
+import java.util.Comparator;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * Compare two artifacts, for use in {@link TreeSet} / {@link TreeMap}, consider
+ * artifactId first THEN groupId
+ */
+public class ArtifactIdComparator implements Comparator<Artifact> {
+       public int compare(Artifact o1, Artifact o2) {
+               if (o1.getArtifactId().equals(o2.getArtifactId()))
+                       return o1.getGroupId().compareTo(o2.getGroupId());
+               return o1.getArtifactId().compareTo(o2.getArtifactId());
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ConvertPoms_01_03.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/ConvertPoms_01_03.java
new file mode 100644 (file)
index 0000000..d46375e
--- /dev/null
@@ -0,0 +1,211 @@
+package org.argeo.slc.repo.maven;
+
+import java.io.File;
+import java.util.HashMap;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/** Recursively migrate all the POMs to Argeo Distribution v1.3 */
+public class ConvertPoms_01_03 implements Runnable {
+       final String SPRING_SOURCE_PREFIX = "com.springsource";
+
+       private HashMap<String, String> artifactMapping = new HashMap<String, String>();
+
+       private File rootDir;
+
+       public ConvertPoms_01_03(String rootDirPath) {
+               this(new File(rootDirPath));
+       }
+
+       public ConvertPoms_01_03(File rootDir) {
+               this.rootDir = rootDir;
+
+               artifactMapping.put("org.argeo.dep.jacob", "com.jacob");
+               artifactMapping.put("org.argeo.dep.jacob.win32.x86",
+                               "com.jacob.win32.x86");
+               artifactMapping.put("org.argeo.dep.osgi.activemq",
+                               "org.apache.activemq");
+               artifactMapping.put("org.argeo.dep.osgi.activemq.optional",
+                               "org.apache.activemq.optional");
+               artifactMapping.put("org.argeo.dep.osgi.activemq.xmpp",
+                               "org.apache.activemq.xmpp");
+               artifactMapping.put("org.argeo.dep.osgi.aether", "org.eclipse.aether");
+               artifactMapping.put("org.argeo.dep.osgi.boilerpipe",
+                               "de.l3s.boilerpipe");
+               artifactMapping.put("org.argeo.dep.osgi.commons.cli",
+                               "org.apache.commons.cli");
+               artifactMapping.put("org.argeo.dep.osgi.commons.exec",
+                               "org.apache.commons.exec");
+               artifactMapping.put("org.argeo.dep.osgi.directory.shared.asn.codec",
+                               "org.apache.directory.shared.asn.codec");
+               artifactMapping.put("org.argeo.dep.osgi.drewnoakes.metadata_extractor",
+                               "com.drewnoakes.metadata_extractor");
+               artifactMapping.put("org.argeo.dep.osgi.geoapi", "org.opengis");
+               artifactMapping.put("org.argeo.dep.osgi.geotools", "org.geotools");
+               artifactMapping.put("org.argeo.dep.osgi.google.collections",
+                               "com.google.collections");
+               artifactMapping.put("org.argeo.dep.osgi.hibernatespatial",
+                               "org.hibernatespatial");
+               artifactMapping.put("org.argeo.dep.osgi.jackrabbit",
+                               "org.apache.jackrabbit");
+               artifactMapping.put("org.argeo.dep.osgi.jai.imageio",
+                               "com.sun.media.jai.imageio");
+               artifactMapping.put("org.argeo.dep.osgi.java3d", "javax.vecmath");
+               artifactMapping.put("org.argeo.dep.osgi.jcr", "javax.jcr");
+               artifactMapping.put("org.argeo.dep.osgi.jsr275", "javax.measure");
+               artifactMapping.put("org.argeo.dep.osgi.jts", "com.vividsolutions.jts");
+               artifactMapping.put("org.argeo.dep.osgi.mina.filter.ssl",
+                               "org.apache.mina.filter.ssl");
+               artifactMapping.put("org.argeo.dep.osgi.modeshape", "org.modeshape");
+               artifactMapping.put("org.argeo.dep.osgi.netcdf",
+                               "edu.ucar.unidata.netcdf");
+               artifactMapping.put("org.argeo.dep.osgi.pdfbox", "org.apache.pdfbox");
+               artifactMapping.put("org.argeo.dep.osgi.poi", "org.apache.poi");
+               artifactMapping.put("org.argeo.dep.osgi.postgis.jdbc",
+                               "org.postgis.jdbc");
+               artifactMapping.put("org.argeo.dep.osgi.springframework.ldap",
+                               "org.springframework.ldap");
+               artifactMapping.put("org.argeo.dep.osgi.tagsoup",
+                               "org.ccil.cowan.tagsoup");
+               artifactMapping.put("org.argeo.dep.osgi.tika", "org.apache.tika");
+       }
+
+       public void run() {
+               traverse(rootDir);
+       }
+
+       protected void traverse(File dir) {
+               for (File file : dir.listFiles()) {
+                       String fileName = file.getName();
+                       if (file.isDirectory() && !skipDirName(fileName)) {
+                               traverse(file);
+                       } else if (fileName.equals("pom.xml")) {
+                               processPom(file);
+                       }
+               }
+       }
+
+       protected Boolean skipDirName(String fileName) {
+               return fileName.equals(".svn") || fileName.equals("target")
+                               || fileName.equals("META-INF") || fileName.equals("src");
+       }
+
+       protected void processPom(File pomFile) {
+               try {
+                       Boolean wasChanged = false;
+                       DocumentBuilderFactory dbFactory = DocumentBuilderFactory
+                                       .newInstance();
+                       DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+                       Document doc = dBuilder.parse(pomFile);
+                       doc.getDocumentElement().normalize();
+
+                       Element dependenciesElement = null;
+                       NodeList rootChildren = doc.getDocumentElement().getChildNodes();
+                       for (int temp = 0; temp < rootChildren.getLength(); temp++) {
+                               Node n = rootChildren.item(temp);
+                               if (n.getNodeName().equals("dependencies"))
+                                       dependenciesElement = (Element) n;
+                       }
+
+                       if (dependenciesElement != null) {
+                               stdOut("\n## " + pomFile);
+                               NodeList dependencyElements = dependenciesElement
+                                               .getElementsByTagName("dependency");
+
+                               for (int temp = 0; temp < dependencyElements.getLength(); temp++) {
+                                       Element eElement = (Element) dependencyElements.item(temp);
+                                       String groupId = getTagValue(eElement, "groupId");
+                                       String artifactId = getTagValue(eElement, "artifactId");
+                                       // stdOut(groupId + ":" + artifactId);
+
+                                       String newGroupId = null;
+                                       String newArtifactId = null;
+                                       if (groupId.startsWith("org.argeo.dep")) {
+                                               newGroupId = "org.argeo.tp";
+                                       } else if (!(groupId.startsWith("org.argeo")
+                                                       || groupId.startsWith("com.capco")
+                                                       || groupId.startsWith("com.agfa") || groupId
+                                                       .startsWith("org.ibboost"))) {
+                                               newGroupId = "org.argeo.tp";
+                                       }
+
+                                       if (artifactMapping.containsKey(artifactId)) {
+                                               newArtifactId = artifactMapping.get(artifactId);
+                                       } else if (artifactId.startsWith(SPRING_SOURCE_PREFIX)
+                                                       && !artifactId.equals(SPRING_SOURCE_PREFIX
+                                                                       + ".json")) {
+                                               newArtifactId = artifactId
+                                                               .substring(SPRING_SOURCE_PREFIX.length() + 1);
+                                       }
+
+                                       // modify
+                                       if (newGroupId != null || newArtifactId != null) {
+                                               if (newGroupId == null)
+                                                       newGroupId = groupId;
+                                               if (newArtifactId == null)
+                                                       newArtifactId = artifactId;
+                                               stdOut(groupId + ":" + artifactId + " => " + newGroupId
+                                                               + ":" + newArtifactId);
+                                               setTagValue(eElement, "groupId", newGroupId);
+                                               setTagValue(eElement, "artifactId", newArtifactId);
+                                               wasChanged = true;
+                                       }
+                               }
+                       }
+
+                       if (wasChanged) {
+                               // pomFile.renameTo(new File(pomFile.getParentFile(),
+                               // "pom-old.xml"));
+                               // save in place
+                               Source source = new DOMSource(doc);
+                               Result result = new StreamResult(pomFile);
+                               Transformer xformer = TransformerFactory.newInstance()
+                                               .newTransformer();
+                               xformer.transform(source, result);
+                       }
+               } catch (Exception e) {
+                       throw new RuntimeException("Cannot process " + pomFile, e);
+               }
+
+       }
+
+       private String getTagValue(Element eElement, String sTag) {
+               NodeList nList = eElement.getElementsByTagName(sTag);
+               if (nList.getLength() > 0) {
+                       NodeList nlList = nList.item(0).getChildNodes();
+                       Node nValue = (Node) nlList.item(0);
+                       return nValue.getNodeValue();
+               } else
+                       return null;
+       }
+
+       private void setTagValue(Element eElement, String sTag, String value) {
+               NodeList nList = eElement.getElementsByTagName(sTag);
+               if (nList.getLength() > 0) {
+                       NodeList nlList = nList.item(0).getChildNodes();
+                       Node nValue = (Node) nlList.item(0);
+                       nValue.setNodeValue(value);
+               }
+       }
+
+       public static void stdOut(Object obj) {
+               System.out.println(obj);
+       }
+
+       public static void main(String argv[]) {
+               new ConvertPoms_01_03(argv[0]).run();
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/GenerateBinaries.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/GenerateBinaries.java
new file mode 100644 (file)
index 0000000..3ccc164
--- /dev/null
@@ -0,0 +1,568 @@
+package org.argeo.slc.repo.maven;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.ArtifactIndexer;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.osgi.framework.Version;
+
+/**
+ * Generates binaries-, sources- and sdk-version.pom artifacts for a given
+ * group.
+ */
+public class GenerateBinaries implements Runnable, SlcNames {
+       private final static Log log = LogFactory.getLog(GenerateBinaries.class);
+
+       // Connection info
+       private Repository repository;
+       private Credentials credentials;
+       private String workspace;
+
+       // Business info
+       private String groupId;
+       private String parentPomCoordinates;
+       private String version = null;
+
+       // Constants
+       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
+       private List<String> excludedSuffixes = new ArrayList<String>();
+
+       // Indexes
+       private Set<Artifact> binaries = new TreeSet<Artifact>(
+                       new ArtifactIdComparator());
+       private Set<Artifact> sources = new TreeSet<Artifact>(
+                       new ArtifactIdComparator());
+
+       // local cache
+       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
+       private Node allArtifactsHighestVersion;
+
+       public void run() {
+               Session session = null;
+               try {
+                       session = repository.login(credentials, workspace);
+                       Node groupNode = session.getNode(MavenConventionsUtils.groupPath(
+                                       artifactBasePath, groupId));
+                       internalPreProcessing(groupNode, null);
+                       internalProcessing(groupNode, null);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot normalize group " + groupId + " in "
+                                       + workspace, e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       /**
+        * Generates binaries-, sources- and sdk-version.pom artifacts for the given
+        * version (or the highest of all children version if none is precised).
+        * 
+        * By default, it includes each latest version of all artifact of this
+        * group.
+        * 
+        * The 3 generated artifacts are then marked as modular distributions and
+        * indexed.
+        */
+       public static void processGroupNode(Node groupNode, String version,
+                       JcrMonitor monitor) throws RepositoryException {
+               // TODO set artifactsBase based on group node
+               GenerateBinaries gb = new GenerateBinaries();
+               String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
+                               .getString();
+               gb.setGroupId(groupId);
+               gb.setVersion(version);
+               // TODO use already done pre-processing
+               gb.internalPreProcessing(groupNode, monitor);
+               gb.internalProcessing(groupNode, monitor);
+       }
+
+       /** Only builds local indexes. Does not change anything in the local Session */
+       public static GenerateBinaries preProcessGroupNode(Node groupNode,
+                       JcrMonitor monitor) throws RepositoryException {
+               // TODO set artifactsBase based on group node
+               GenerateBinaries gb = new GenerateBinaries();
+               String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
+                               .getString();
+               gb.setGroupId(groupId);
+               // gb.setVersion(version);
+               // gb.setOverridePoms(overridePoms);
+               gb.internalPreProcessing(groupNode, monitor);
+               return gb;
+       }
+
+       // exposes indexes. to display results of the pre-processing phase.
+       public Set<Artifact> getBinaries() {
+               return binaries;
+       }
+
+       public Artifact getHighestArtifactVersion() throws RepositoryException {
+               return allArtifactsHighestVersion == null ? null : RepoUtils
+                               .asArtifact(allArtifactsHighestVersion);
+       }
+
+       // //////////////////////////////////////
+       // INTERNAL METHODS
+
+       /**
+        * Browse all children of a Node considered as a folder that follows Aether
+        * conventions i.e that has Aether's artifact base as children.
+        * 
+        * Each of such child contains a set of Aether artifact versions. This
+        * methods build the binaries {@code Set<Artifact>} and other indexes. It
+        * does not impact the
+        */
+       protected void internalPreProcessing(Node groupNode, JcrMonitor monitor)
+                       throws RepositoryException {
+               if (monitor != null)
+                       monitor.subTask("Pre processing group " + groupId);
+
+               // Process all direct children nodes,
+               // gathering latest versions of each artifact
+               allArtifactsHighestVersion = null;
+
+               aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases
+                               .hasNext();) {
+                       Node aBase = aBases.nextNode();
+                       if (aBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
+                               Node highestAVersion = getArtifactLatestVersion(aBase);
+                               if (highestAVersion == null)
+                                       continue aBases;
+                               else {
+                                       // retrieve relevant child node
+                                       // Information is stored on the NT_FILE child node.
+                                       for (NodeIterator files = highestAVersion.getNodes(); files
+                                                       .hasNext();) {
+                                               Node file = files.nextNode();
+                                               if (file.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
+                                                       if (log.isDebugEnabled())
+                                                               log.debug("Pre-Processing " + file.getName());
+                                                       preProcessBundleArtifact(file);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               // if (log.isDebugEnabled()) {
+               // int bundleCount = symbolicNamesToNodes.size();
+               // log.debug("" + bundleCount + " bundles have been indexed for "
+               // + groupId);
+               // }
+       }
+
+       /** Does the real job : writes JCR META-DATA and generates binaries */
+       protected void internalProcessing(Node groupNode, JcrMonitor monitor)
+                       throws RepositoryException {
+               if (monitor != null)
+                       monitor.subTask("Processing group " + groupId);
+
+               Session session = groupNode.getSession();
+
+               // if version not set or empty, use the highest version
+               // useful when indexing a product maven repository where
+               // all artifacts have the same version for a given release
+               // => the version can then be left empty
+               if (version == null || version.trim().equals(""))
+                       if (allArtifactsHighestVersion != null)
+                               version = allArtifactsHighestVersion.getProperty(
+                                               SLC_ARTIFACT_VERSION).getString();
+                       else
+                               throw new SlcException("Group version " + version
+                                               + " is empty.");
+
+               // int bundleCount = symbolicNamesToNodes.size();
+               // int count = 1;
+               // for (Node bundleNode : symbolicNamesToNodes.values()) {
+               // if (log.isDebugEnabled())
+               // log.debug("Processing " + bundleNode.getName() + " ( " + count
+               // + "/" + bundleCount + " )");
+               //
+               // // processBundleArtifact(bundleNode);
+               // // bundleNode.getSession().save();
+               // count++;
+               // }
+
+               // indexes
+               Set<Artifact> indexes = new TreeSet<Artifact>(
+                               new ArtifactIdComparator());
+
+               Artifact indexArtifact;
+               indexArtifact = writeIndex(session, RepoConstants.BINARIES_ARTIFACT_ID,
+                               binaries);
+               indexes.add(indexArtifact);
+
+               indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID,
+                               sources);
+               indexes.add(indexArtifact);
+
+               // sdk
+               writeIndex(session, RepoConstants.SDK_ARTIFACT_ID, indexes);
+
+               if (monitor != null)
+                       monitor.worked(1);
+       }
+
+       protected void preProcessBundleArtifact(Node bundleNode)
+                       throws RepositoryException {
+
+               String symbolicName = JcrUtils.get(bundleNode, SLC_SYMBOLIC_NAME);
+               // Sanity check.
+               if (symbolicName == null)
+                       log.warn("Symbolic name is null for bundle " + bundleNode);
+
+               // Manage source bundles
+               if (symbolicName.endsWith(".source")) {
+                       // TODO make a shared node with classifier 'sources'?
+                       String bundleName = RepoUtils
+                                       .extractBundleNameFromSourceName(symbolicName);
+                       for (String excludedSuffix : excludedSuffixes) {
+                               if (bundleName.endsWith(excludedSuffix))
+                                       return;// skip adding to sources
+                       }
+                       sources.add(RepoUtils.asArtifact(bundleNode));
+                       return;
+               }
+
+               // // Build indexes
+               // NodeIterator exportPackages = bundleNode.getNodes(SLC_
+               // + Constants.EXPORT_PACKAGE);
+               // while (exportPackages.hasNext()) {
+               // Node exportPackage = exportPackages.nextNode();
+               // String pkg = JcrUtils.get(exportPackage, SLC_NAME);
+               // packagesToSymbolicNames.put(pkg, symbolicName);
+               // }
+               //
+               // symbolicNamesToNodes.put(symbolicName, bundleNode);
+               // for (String excludedSuffix : excludedSuffixes) {
+               // if (symbolicName.endsWith(excludedSuffix))
+               // return;// skip adding to binaries
+               // }
+
+               binaries.add(RepoUtils.asArtifact(bundleNode));
+
+               // Extra check. to remove
+               if (bundleNode.getSession().hasPendingChanges())
+                       throw new SlcException("Pending changes in the session, "
+                                       + "this should not be true here.");
+       }
+
+       // protected void processBundleArtifact(Node bundleNode)
+       // throws RepositoryException {
+       // Node artifactFolder = bundleNode.getParent();
+       // String baseName = FilenameUtils.getBaseName(bundleNode.getName());
+       //
+       // // pom
+       // String pomName = baseName + ".pom";
+       // if (artifactFolder.hasNode(pomName) && !overridePoms)
+       // return;// skip
+       //
+       // String pom = generatePomForBundle(bundleNode);
+       // Node pomNode = JcrUtils.copyBytesAsFile(artifactFolder, pomName,
+       // pom.getBytes());
+       // // checksum
+       // String bundleSha = JcrUtils.checksumFile(bundleNode, "SHA-1");
+       // JcrUtils.copyBytesAsFile(artifactFolder,
+       // bundleNode.getName() + ".sha1", bundleSha.getBytes());
+       // String pomSha = JcrUtils.checksumFile(pomNode, "SHA-1");
+       // JcrUtils.copyBytesAsFile(artifactFolder, pomNode.getName() + ".sha1",
+       // pomSha.getBytes());
+       // }
+
+       // ////////////////////
+       // LOCAL WRITERS
+       //
+
+       private Artifact writeIndex(Session session, String artifactId,
+                       Set<Artifact> artifacts) throws RepositoryException {
+               Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
+                               version);
+               Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(
+                               parentPomCoordinates) : null;
+               String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
+                               artifacts, parentArtifact);
+               Node node = RepoUtils.copyBytesAsArtifact(
+                               session.getNode(artifactBasePath), artifact, pom.getBytes());
+               artifactIndexer.index(node);
+
+               // TODO factorize
+               String pomSha = JcrUtils.checksumFile(node, "SHA-1");
+               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
+                               pomSha.getBytes());
+               String pomMd5 = JcrUtils.checksumFile(node, "MD5");
+               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
+                               pomMd5.getBytes());
+               session.save();
+               return artifact;
+       }
+
+       // Helpers
+       private Node getArtifactLatestVersion(Node artifactBase) {
+               try {
+                       Node highestAVersion = null;
+                       for (NodeIterator aVersions = artifactBase.getNodes(); aVersions
+                                       .hasNext();) {
+                               Node aVersion = aVersions.nextNode();
+                               if (aVersion.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+                                       if (highestAVersion == null) {
+                                               highestAVersion = aVersion;
+                                               if (allArtifactsHighestVersion == null)
+                                                       allArtifactsHighestVersion = aVersion;
+                                               // Correctly handle following arrival order:
+                                               // Name1 - V1, name2 - V3
+                                               else {
+                                                       Version cachedHighestVersion = extractOsgiVersion(allArtifactsHighestVersion);
+                                                       Version currVersion = extractOsgiVersion(aVersion);
+                                                       if (currVersion.compareTo(cachedHighestVersion) > 0)
+                                                               allArtifactsHighestVersion = aVersion;
+                                               }
+                                       } else {
+                                               Version currVersion = extractOsgiVersion(aVersion);
+                                               Version currentHighestVersion = extractOsgiVersion(highestAVersion);
+                                               if (currVersion.compareTo(currentHighestVersion) > 0) {
+                                                       highestAVersion = aVersion;
+                                               }
+                                               if (currVersion
+                                                               .compareTo(extractOsgiVersion(allArtifactsHighestVersion)) > 0) {
+                                                       allArtifactsHighestVersion = aVersion;
+                                               }
+                                       }
+
+                               }
+                       }
+                       return highestAVersion;
+               } catch (RepositoryException re) {
+                       throw new SlcException("Unable to get latest version for node "
+                                       + artifactBase, re);
+               }
+       }
+
+       private Version extractOsgiVersion(Node artifactVersion)
+                       throws RepositoryException {
+               String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION)
+                               .getString();
+               String cleanVersion = rawVersion.replace("-SNAPSHOT", ".SNAPSHOT");
+               Version osgiVersion = null;
+               // log invalid version value to enable tracking them
+               try {
+                       osgiVersion = new Version(cleanVersion);
+               } catch (IllegalArgumentException e) {
+                       log.error("Version string " + cleanVersion + " is invalid ");
+                       String twickedVersion = twickInvalidVersion(cleanVersion);
+                       osgiVersion = new Version(twickedVersion);
+                       log.error("Using " + twickedVersion + " instead");
+                       // throw e;
+               }
+               return osgiVersion;
+       }
+
+       private String twickInvalidVersion(String tmpVersion) {
+               String[] tokens = tmpVersion.split("\\.");
+               if (tokens.length == 3 && tokens[2].lastIndexOf("-") > 0) {
+                       String newSuffix = tokens[2].replaceFirst("-", ".");
+                       tmpVersion = tmpVersion.replaceFirst(tokens[2], newSuffix);
+               } else if (tokens.length > 4) {
+                       // FIXME manually remove other "."
+                       StringTokenizer st = new StringTokenizer(tmpVersion, ".", true);
+                       StringBuilder builder = new StringBuilder();
+                       // Major
+                       builder.append(st.nextToken()).append(st.nextToken());
+                       // Minor
+                       builder.append(st.nextToken()).append(st.nextToken());
+                       // Micro
+                       builder.append(st.nextToken()).append(st.nextToken());
+                       // Qualifier
+                       builder.append(st.nextToken());
+                       while (st.hasMoreTokens()) {
+                               // consume delimiter
+                               st.nextToken();
+                               if (st.hasMoreTokens())
+                                       builder.append("-").append(st.nextToken());
+                       }
+                       tmpVersion = builder.toString();
+               }
+               return tmpVersion;
+       }
+
+       // private String generatePomForBundle(Node n) throws RepositoryException {
+       // String ownSymbolicName = JcrUtils.get(n, SLC_SYMBOLIC_NAME);
+       //
+       // StringBuffer p = new StringBuffer();
+       //
+       // // XML header
+       // p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+       // p.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
+       // p.append("<modelVersion>4.0.0</modelVersion>");
+       //
+       // // Artifact
+       // p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
+       // .append("</groupId>\n");
+       // p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
+       // .append("</artifactId>\n");
+       // p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
+       // .append("</version>\n");
+       // p.append("<packaging>pom</packaging>\n");
+       // if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
+       // p.append("<name>")
+       // .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
+       // .append("</name>\n");
+       // if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
+       // p.append("<description>")
+       // .append(JcrUtils
+       // .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
+       // .append("</description>\n");
+       //
+       // // Dependencies
+       // Set<String> dependenciesSymbolicNames = new TreeSet<String>();
+       // Set<String> optionalSymbolicNames = new TreeSet<String>();
+       // NodeIterator importPackages = n.getNodes(SLC_
+       // + Constants.IMPORT_PACKAGE);
+       // while (importPackages.hasNext()) {
+       // Node importPackage = importPackages.nextNode();
+       // String pkg = JcrUtils.get(importPackage, SLC_NAME);
+       // if (packagesToSymbolicNames.containsKey(pkg)) {
+       // String dependencySymbolicName = packagesToSymbolicNames
+       // .get(pkg);
+       // if (JcrUtils.check(importPackage, SLC_OPTIONAL))
+       // optionalSymbolicNames.add(dependencySymbolicName);
+       // else
+       // dependenciesSymbolicNames.add(dependencySymbolicName);
+       // } else {
+       // if (!JcrUtils.check(importPackage, SLC_OPTIONAL)
+       // && !systemPackages.contains(pkg))
+       // log.warn("No bundle found for pkg " + pkg);
+       // }
+       // }
+       //
+       // if (n.hasNode(SLC_ + Constants.FRAGMENT_HOST)) {
+       // String fragmentHost = JcrUtils.get(
+       // n.getNode(SLC_ + Constants.FRAGMENT_HOST),
+       // SLC_SYMBOLIC_NAME);
+       // dependenciesSymbolicNames.add(fragmentHost);
+       // }
+       //
+       // // TODO require bundles
+       //
+       // List<Node> dependencyNodes = new ArrayList<Node>();
+       // for (String depSymbName : dependenciesSymbolicNames) {
+       // if (depSymbName.equals(ownSymbolicName))
+       // continue;// skip self
+       //
+       // if (symbolicNamesToNodes.containsKey(depSymbName))
+       // dependencyNodes.add(symbolicNamesToNodes.get(depSymbName));
+       // else
+       // log.warn("Could not find node for " + depSymbName);
+       // }
+       // List<Node> optionalDependencyNodes = new ArrayList<Node>();
+       // for (String depSymbName : optionalSymbolicNames) {
+       // if (symbolicNamesToNodes.containsKey(depSymbName))
+       // optionalDependencyNodes.add(symbolicNamesToNodes
+       // .get(depSymbName));
+       // else
+       // log.warn("Could not find node for " + depSymbName);
+       // }
+       //
+       // p.append("<dependencies>\n");
+       // for (Node dependencyNode : dependencyNodes) {
+       // p.append("<dependency>\n");
+       // p.append("\t<groupId>")
+       // .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
+       // .append("</groupId>\n");
+       // p.append("\t<artifactId>")
+       // .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
+       // .append("</artifactId>\n");
+       // p.append("</dependency>\n");
+       // }
+       //
+       // if (optionalDependencyNodes.size() > 0)
+       // p.append("<!-- OPTIONAL -->\n");
+       // for (Node dependencyNode : optionalDependencyNodes) {
+       // p.append("<dependency>\n");
+       // p.append("\t<groupId>")
+       // .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
+       // .append("</groupId>\n");
+       // p.append("\t<artifactId>")
+       // .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
+       // .append("</artifactId>\n");
+       // p.append("\t<optional>true</optional>\n");
+       // p.append("</dependency>\n");
+       // }
+       // p.append("</dependencies>\n");
+       //
+       // // Dependency management
+       // p.append("<dependencyManagement>\n");
+       // p.append("<dependencies>\n");
+       // p.append("<dependency>\n");
+       // p.append("\t<groupId>").append(groupId).append("</groupId>\n");
+       // p.append("\t<artifactId>")
+       // .append(ownSymbolicName.endsWith(".source") ?
+       // RepoConstants.SOURCES_ARTIFACT_ID
+       // : RepoConstants.BINARIES_ARTIFACT_ID)
+       // .append("</artifactId>\n");
+       // p.append("\t<version>").append(version).append("</version>\n");
+       // p.append("\t<type>pom</type>\n");
+       // p.append("\t<scope>import</scope>\n");
+       // p.append("</dependency>\n");
+       // p.append("</dependencies>\n");
+       // p.append("</dependencyManagement>\n");
+       //
+       // p.append("</project>\n");
+       // return p.toString();
+       // }
+
+       /* SETTERS */
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setCredentials(Credentials credentials) {
+               this.credentials = credentials;
+       }
+
+       public void setWorkspace(String workspace) {
+               this.workspace = workspace;
+       }
+
+       public void setGroupId(String groupId) {
+               this.groupId = groupId;
+       }
+
+       public void setParentPomCoordinates(String parentPomCoordinates) {
+               this.parentPomCoordinates = parentPomCoordinates;
+       }
+
+       public void setArtifactBasePath(String artifactBasePath) {
+               this.artifactBasePath = artifactBasePath;
+       }
+
+       public void setVersion(String version) {
+               this.version = version;
+       }
+
+       public void setExcludedSuffixes(List<String> excludedSuffixes) {
+               this.excludedSuffixes = excludedSuffixes;
+       }
+
+       public void setArtifactIndexer(ArtifactIndexer artifactIndexer) {
+               this.artifactIndexer = artifactIndexer;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/IndexDistribution.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/IndexDistribution.java
new file mode 100644 (file)
index 0000000..1d013f5
--- /dev/null
@@ -0,0 +1,130 @@
+package org.argeo.slc.repo.maven;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.RepoConstants;
+import org.eclipse.aether.artifact.Artifact;
+
+/** Create a distribution node from a set of artifacts */
+public class IndexDistribution implements Runnable {
+       private final static Log log = LogFactory.getLog(IndexDistribution.class);
+       private Repository repository;
+       private String workspace;
+
+       private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
+       private String distributionsBasePath = RepoConstants.DISTRIBUTIONS_BASE_PATH;
+       private String distributionName;
+
+       public void run() {
+               // TODO populate
+               Set<Artifact> artifacts = new HashSet<Artifact>();
+
+               // sync
+               Session session = null;
+               try {
+                       session = repository.login(workspace);
+                       syncDistribution(session, artifacts);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot import distribution", e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       protected void syncDistribution(Session jcrSession, Set<Artifact> artifacts) {
+               Long begin = System.currentTimeMillis();
+               try {
+                       JcrUtils.mkdirs(jcrSession, distributionsBasePath + '/'
+                                       + distributionName);
+                       artifacts: for (Artifact artifact : artifacts) {
+                               File file = artifact.getFile();
+                               if (file == null) {
+                                       file = MavenConventionsUtils.artifactToFile(artifact);
+                                       if (!file.exists()) {
+                                               log.warn("Generated file " + file + " for " + artifact
+                                                               + " does not exist");
+                                               continue artifacts;
+                                       }
+                               }
+
+                               try {
+                                       String parentPath = artifactBasePath
+                                                       + (artifactBasePath.endsWith("/") ? "" : "/")
+                                                       + artifactParentPath(artifact);
+                                       Node parentNode = jcrSession.getNode(parentPath);
+                                       Node fileNode = parentNode.getNode(file.getName());
+
+                                       if (fileNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME)) {
+                                               String distPath = bundleDistributionPath(fileNode);
+                                               if (!jcrSession.itemExists(distPath)
+                                                               && fileNode
+                                                                               .isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT))
+                                                       jcrSession.getWorkspace().clone(
+                                                                       jcrSession.getWorkspace().getName(),
+                                                                       fileNode.getPath(), distPath, false);
+                                               if (log.isDebugEnabled())
+                                                       log.debug("Indexed " + fileNode);
+                                       }
+                               } catch (Exception e) {
+                                       log.error("Could not index " + artifact, e);
+                                       jcrSession.refresh(false);
+                                       throw e;
+                               }
+                       }
+
+                       Long duration = (System.currentTimeMillis() - begin) / 1000;
+                       if (log.isDebugEnabled())
+                               log.debug("Indexed distribution in " + duration + "s");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot synchronize distribution", e);
+               }
+       }
+
+       private String artifactParentPath(Artifact artifact) {
+               return artifact.getGroupId().replace('.', '/') + '/'
+                               + artifact.getArtifactId() + '/' + artifact.getVersion();
+       }
+
+       private String bundleDistributionPath(Node fileNode) {
+               try {
+                       return distributionsBasePath
+                                       + '/'
+                                       + distributionName
+                                       + '/'
+                                       + fileNode.getProperty(SlcNames.SLC_SYMBOLIC_NAME)
+                                                       .getString()
+                                       + '_'
+                                       + fileNode.getProperty(SlcNames.SLC_BUNDLE_VERSION)
+                                                       .getString();
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot create distribution path for "
+                                       + fileNode, e);
+               }
+       }
+
+       public void setDistributionName(String distributionName) {
+               this.distributionName = distributionName;
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setWorkspace(String workspace) {
+               this.workspace = workspace;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java
new file mode 100644 (file)
index 0000000..9487e4d
--- /dev/null
@@ -0,0 +1,204 @@
+package org.argeo.slc.repo.maven;
+
+import java.io.File;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * Static utilities around Maven which are NOT using the Maven APIs (conventions
+ * based).
+ */
+public class MavenConventionsUtils {
+       private final static Log log = LogFactory.getLog(MavenConventionsUtils.class);
+
+       /**
+        * Path to the file identified by this artifact <b>without</b> using Maven
+        * APIs (convention based). Default location of repository
+        * (~/.m2/repository) is used here.
+        * 
+        * @see MavenConventionsUtils#artifactToFile(String, Artifact)
+        */
+       public static File artifactToFile(Artifact artifact) {
+               return artifactToFile(System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository",
+                               artifact);
+       }
+
+       /**
+        * Path to the file identified by this artifact <b>without</b> using Maven
+        * APIs (convention based).
+        * 
+        * @param repositoryPath
+        *            path to the related local repository location
+        * @param artifact
+        *            the artifact
+        */
+       public static File artifactToFile(String repositoryPath, Artifact artifact) {
+               return new File(repositoryPath + File.separator + artifact.getGroupId().replace('.', File.separatorChar)
+                               + File.separator + artifact.getArtifactId() + File.separator + artifact.getVersion() + File.separator
+                               + artifactFileName(artifact)).getAbsoluteFile();
+       }
+
+       /** The file name of this artifact when stored */
+       public static String artifactFileName(Artifact artifact) {
+               return artifact.getArtifactId() + '-' + artifact.getVersion()
+                               + (artifact.getClassifier().equals("") ? "" : '-' + artifact.getClassifier()) + '.'
+                               + artifact.getExtension();
+       }
+
+       /** Absolute path to the file */
+       public static String artifactPath(String artifactBasePath, Artifact artifact) {
+               return artifactParentPath(artifactBasePath, artifact) + '/' + artifactFileName(artifact);
+       }
+
+       /** Absolute path to the file */
+       public static String artifactUrl(String repoUrl, Artifact artifact) {
+               if (repoUrl.endsWith("/"))
+                       return repoUrl + artifactPath("/", artifact).substring(1);
+               else
+                       return repoUrl + artifactPath("/", artifact);
+       }
+
+       /** Absolute path to the directories where the files will be stored */
+       public static String artifactParentPath(String artifactBasePath, Artifact artifact) {
+               return artifactBasePath + (artifactBasePath.endsWith("/") ? "" : "/") + artifactParentPath(artifact);
+       }
+
+       /** Absolute path to the directory of this group */
+       public static String groupPath(String artifactBasePath, String groupId) {
+               return artifactBasePath + (artifactBasePath.endsWith("/") ? "" : "/") + groupId.replace('.', '/');
+       }
+
+       /** Relative path to the directories where the files will be stored */
+       public static String artifactParentPath(Artifact artifact) {
+               return artifact.getGroupId().replace('.', '/') + '/' + artifact.getArtifactId() + '/'
+                               + artifact.getBaseVersion();
+       }
+
+       public static String artifactsAsDependencyPom(Artifact pomArtifact, Set<Artifact> artifacts, Artifact parent) {
+               StringBuffer p = new StringBuffer();
+
+               // XML header
+               p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+               p.append(
+                               "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
+               p.append("<modelVersion>4.0.0</modelVersion>\n");
+
+               // Artifact
+               if (parent != null) {
+                       p.append("<parent>\n");
+                       p.append("<groupId>").append(parent.getGroupId()).append("</groupId>\n");
+                       p.append("<artifactId>").append(parent.getArtifactId()).append("</artifactId>\n");
+                       p.append("<version>").append(parent.getVersion()).append("</version>\n");
+                       p.append("</parent>\n");
+               }
+               p.append("<groupId>").append(pomArtifact.getGroupId()).append("</groupId>\n");
+               p.append("<artifactId>").append(pomArtifact.getArtifactId()).append("</artifactId>\n");
+               p.append("<version>").append(pomArtifact.getVersion()).append("</version>\n");
+               p.append("<packaging>pom</packaging>\n");
+
+               // Dependencies
+               p.append("<dependencies>\n");
+               for (Artifact a : artifacts) {
+                       p.append("\t<dependency>");
+                       p.append("<artifactId>").append(a.getArtifactId()).append("</artifactId>");
+                       p.append("<groupId>").append(a.getGroupId()).append("</groupId>");
+                       if (!a.getExtension().equals("jar"))
+                               p.append("<type>").append(a.getExtension()).append("</type>");
+                       p.append("</dependency>\n");
+               }
+               p.append("</dependencies>\n");
+
+               // Dependency management
+               p.append("<dependencyManagement>\n");
+               p.append("<dependencies>\n");
+               for (Artifact a : artifacts) {
+                       p.append("\t<dependency>");
+                       p.append("<artifactId>").append(a.getArtifactId()).append("</artifactId>");
+                       p.append("<version>").append(a.getVersion()).append("</version>");
+                       p.append("<groupId>").append(a.getGroupId()).append("</groupId>");
+                       if (a.getExtension().equals("pom")) {
+                               p.append("<type>").append(a.getExtension()).append("</type>");
+                               p.append("<scope>import</scope>");
+                       }
+                       p.append("</dependency>\n");
+               }
+               p.append("</dependencies>\n");
+               p.append("</dependencyManagement>\n");
+
+               // Repositories
+               // p.append("<repositories>\n");
+               // p.append("<repository><id>argeo</id><url>http://maven.argeo.org/argeo</url></repository>\n");
+               // p.append("</repositories>\n");
+
+               p.append("</project>\n");
+               return p.toString();
+       }
+
+//     /**
+//      * Directly parses Maven POM XML format in order to find all artifacts
+//      * references under the dependency and dependencyManagement tags. This is
+//      * meant to migrate existing pom registering a lot of artifacts, not to
+//      * replace Maven resolving.
+//      */
+//     public static void gatherPomDependencies(AetherTemplate aetherTemplate, Set<Artifact> artifacts,
+//                     Artifact pomArtifact) {
+//             if (log.isDebugEnabled())
+//                     log.debug("Gather dependencies for " + pomArtifact);
+//
+//             try {
+//                     File file = aetherTemplate.getResolvedFile(pomArtifact);
+//                     DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+//                     Document doc = documentBuilder.parse(file);
+//
+//                     // properties
+//                     Properties props = new Properties();
+//                     props.setProperty("project.version", pomArtifact.getBaseVersion());
+//                     NodeList properties = doc.getElementsByTagName("properties");
+//                     if (properties.getLength() > 0) {
+//                             NodeList propertiesElems = properties.item(0).getChildNodes();
+//                             for (int i = 0; i < propertiesElems.getLength(); i++) {
+//                                     if (propertiesElems.item(i) instanceof Element) {
+//                                             Element property = (Element) propertiesElems.item(i);
+//                                             props.put(property.getNodeName(), property.getTextContent());
+//                                     }
+//                             }
+//                     }
+//
+//                     // dependencies (direct and dependencyManagement)
+//                     NodeList dependencies = doc.getElementsByTagName("dependency");
+//                     for (int i = 0; i < dependencies.getLength(); i++) {
+//                             Element dependency = (Element) dependencies.item(i);
+//                             String groupId = dependency.getElementsByTagName("groupId").item(0).getTextContent().trim();
+//                             String artifactId = dependency.getElementsByTagName("artifactId").item(0).getTextContent().trim();
+//                             String version = dependency.getElementsByTagName("version").item(0).getTextContent().trim();
+//                             if (version.startsWith("${")) {
+//                                     String versionKey = version.substring(0, version.length() - 1).substring(2);
+//                                     if (!props.containsKey(versionKey))
+//                                             throw new SlcException("Cannot interpret version " + version);
+//                                     version = props.getProperty(versionKey);
+//                             }
+//                             NodeList scopes = dependency.getElementsByTagName("scope");
+//                             if (scopes.getLength() > 0 && scopes.item(0).getTextContent().equals("import")) {
+//                                     // recurse
+//                                     gatherPomDependencies(aetherTemplate, artifacts,
+//                                                     new DefaultArtifact(groupId, artifactId, "pom", version));
+//                             } else {
+//                                     // TODO: deal with scope?
+//                                     // TODO: deal with type
+//                                     String type = "jar";
+//                                     Artifact artifact = new DefaultArtifact(groupId, artifactId, type, version);
+//                                     artifacts.add(artifact);
+//                             }
+//                     }
+//             } catch (Exception e) {
+//                     throw new SlcException("Cannot process " + pomArtifact, e);
+//             }
+//     }
+
+       /** Prevent instantiation */
+       private MavenConventionsUtils() {
+       }
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenProxyServiceImpl.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenProxyServiceImpl.java
new file mode 100644 (file)
index 0000000..9a88534
--- /dev/null
@@ -0,0 +1,113 @@
+package org.argeo.slc.repo.maven;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.security.AccessControlException;
+import javax.jcr.security.Privilege;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.ArgeoNames;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.proxy.AbstractUrlProxy;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.MavenProxyService;
+import org.argeo.slc.repo.RepoConstants;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/** Synchronises the node repository with remote Maven repositories */
+public class MavenProxyServiceImpl extends AbstractUrlProxy implements
+               MavenProxyService, ArgeoNames, SlcNames {
+       private final static Log log = LogFactory
+                       .getLog(MavenProxyServiceImpl.class);
+
+       private List<RemoteRepository> defaultRepositories = new ArrayList<RemoteRepository>();
+
+       /** Initialises the artifacts area. */
+       @Override
+       protected void beforeInitSessionSave(Session session)
+                       throws RepositoryException {
+               JcrUtils.addPrivilege(session, "/", SlcConstants.USER_ANONYMOUS, Privilege.JCR_READ);
+               try {
+                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+                                       Privilege.JCR_ALL);
+               } catch (AccessControlException e) {
+                       if (log.isTraceEnabled())
+                               log.trace("Cannot give jcr:all privileges to "
+                                               + SlcConstants.ROLE_SLC);
+               }
+
+               JcrUtils.mkdirsSafe(session, RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH);
+               Node proxiedRepositories = JcrUtils.mkdirsSafe(session,
+                               RepoConstants.PROXIED_REPOSITORIES);
+               for (RemoteRepository repository : defaultRepositories) {
+                       if (!proxiedRepositories.hasNode(repository.getId())) {
+                               Node proxiedRepository = proxiedRepositories.addNode(repository
+                                               .getId());
+                               proxiedRepository.addMixin(NodeType.MIX_REFERENCEABLE);
+                               JcrUtils.urlToAddressProperties(proxiedRepository,
+                                               repository.getUrl());
+                               // proxiedRepository.setProperty(SLC_URL, repository.getUrl());
+                               proxiedRepository.setProperty(SLC_TYPE,
+                                               repository.getContentType());
+                       }
+               }
+       }
+
+       /**
+        * Retrieve and add this file to the repository
+        */
+       @Override
+       protected Node retrieve(Session session, String path) {
+               try {
+                       if (session.hasPendingChanges())
+                               throw new SlcException("Session has pending changed");
+                       Node node = null;
+                       for (Node proxiedRepository : getBaseUrls(session)) {
+                               String baseUrl = JcrUtils
+                                               .urlFromAddressProperties(proxiedRepository);
+                               node = proxyUrl(session, baseUrl, path);
+                               if (node != null) {
+                                       node.addMixin(SlcTypes.SLC_KNOWN_ORIGIN);
+                                       Node origin = node
+                                                       .addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
+                                       origin.setProperty(SLC_PROXY, proxiedRepository);
+                                       JcrUtils.urlToAddressProperties(origin, baseUrl + path);
+                                       if (log.isDebugEnabled())
+                                               log.debug("Imported " + baseUrl + path + " to " + node);
+                                       return node;
+                               }
+                       }
+                       if (log.isDebugEnabled())
+                               log.warn("No proxy found for " + path);
+                       return null;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot proxy " + path, e);
+               }
+       }
+
+       protected synchronized List<Node> getBaseUrls(Session session)
+                       throws RepositoryException {
+               List<Node> baseUrls = new ArrayList<Node>();
+               for (NodeIterator nit = session.getNode(
+                               RepoConstants.PROXIED_REPOSITORIES).getNodes(); nit.hasNext();) {
+                       Node proxiedRepository = nit.nextNode();
+                       baseUrls.add(proxiedRepository);
+               }
+               return baseUrls;
+       }
+
+       public void setDefaultRepositories(
+                       List<RemoteRepository> defaultRepositories) {
+               this.defaultRepositories = defaultRepositories;
+       }
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/Migration_01_03.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/Migration_01_03.java
new file mode 100644 (file)
index 0000000..a7f7d16
--- /dev/null
@@ -0,0 +1,409 @@
+package org.argeo.slc.repo.maven;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.Attributes.Name;
+import java.util.jar.Manifest;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Ordering;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.ArtifactIndexer;
+import org.argeo.slc.repo.JarFileIndexer;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.slc.repo.osgi.OsgiProfile;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.osgi.framework.Constants;
+
+/**
+ * Migrate the distribution from 1.2 to 1.4 by cleaning naming and dependencies.
+ * The dependency to the SpringSource Enterprise Bundle repository is removed as
+ * well as their naming conventions. All third party are move to org.argeo.tp
+ * group IDs. Maven dependency for Eclipse artifacts don't use version ranges
+ * anymore. Verison constraints on javax.* packages are removed (since they lead
+ * to "use package conflicts" when Eclipse and Spring Security are used
+ * together).
+ */
+public class Migration_01_03 implements Runnable, SlcNames {
+       final String SPRING_SOURCE_PREFIX = "com.springsource";
+       private final static Log log = LogFactory.getLog(Migration_01_03.class);
+
+       private Repository repository;
+       private String sourceWorkspace;
+       private String targetWorkspace;
+
+       private List<String> excludedBundles = new ArrayList<String>();
+       private Map<String, String> symbolicNamesMapping = new HashMap<String, String>();
+
+       private Session origSession;
+       private Session targetSession;
+
+       private List<String> systemPackages = OsgiProfile.PROFILE_JAVA_SE_1_6
+                       .getSystemPackages();
+
+       private String artifactBasePath = "/";
+
+       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
+       private JarFileIndexer jarFileIndexer = new JarFileIndexer();
+
+       public void init() throws RepositoryException {
+               origSession = JcrUtils.loginOrCreateWorkspace(repository,
+                               sourceWorkspace);
+               targetSession = JcrUtils.loginOrCreateWorkspace(repository,
+                               targetWorkspace);
+
+               // works only in OSGi!!
+               // systemPackages = Arrays.asList(System.getProperty(
+               // "org.osgi.framework.system.packages").split(","));
+       }
+
+       public void destroy() {
+               JcrUtils.logoutQuietly(origSession);
+               JcrUtils.logoutQuietly(targetSession);
+       }
+
+       public void run() {
+
+               try {
+                       // clear target
+                       NodeIterator nit = targetSession.getNode(artifactBasePath)
+                                       .getNodes();
+                       while (nit.hasNext()) {
+                               Node node = nit.nextNode();
+                               if (node.isNodeType(NodeType.NT_FOLDER)
+                                               || node.isNodeType(NodeType.NT_UNSTRUCTURED)) {
+                                       node.remove();
+                                       node.getSession().save();
+                                       if (log.isDebugEnabled())
+                                               log.debug("Cleared " + node);
+                               }
+                       }
+
+                       NodeIterator origArtifacts = listArtifactVersions(origSession);
+                       // process
+                       while (origArtifacts.hasNext()) {
+                               Node origArtifactNode = origArtifacts.nextNode();
+                               if (log.isTraceEnabled())
+                                       log.trace(origArtifactNode);
+
+                               processOrigArtifactVersion(origArtifactNode);
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot perform v1.3 migration from "
+                                       + sourceWorkspace + " to " + targetWorkspace, e);
+               } finally {
+                       JcrUtils.discardQuietly(targetSession);
+               }
+       }
+
+       protected void processOrigArtifactVersion(Node origArtifactNode)
+                       throws RepositoryException, IOException {
+               Artifact origArtifact = RepoUtils.asArtifact(origArtifactNode);
+
+               // skip eclipse artifacts
+               if ((origArtifact.getGroupId().startsWith("org.eclipse") && !(origArtifact
+                               .getArtifactId().equals("org.eclipse.osgi")
+                               || origArtifact.getArtifactId().equals(
+                                               "org.eclipse.osgi.source") || origArtifact
+                               .getArtifactId().startsWith("org.eclipse.rwt.widgets.upload")))
+                               || origArtifact.getArtifactId().startsWith("com.ibm.icu")) {
+                       if (log.isDebugEnabled())
+                               log.debug("Skip " + origArtifact);
+                       return;
+               }
+
+               // skip SpringSource ActiveMQ
+               if (origArtifact.getArtifactId().startsWith(
+                               "com.springsource.org.apache.activemq"))
+                       return;
+
+               String origJarNodeName = MavenConventionsUtils
+                               .artifactFileName(origArtifact);
+               if (!origArtifactNode.hasNode(origJarNodeName))
+                       throw new SlcException("Cannot find jar node for "
+                                       + origArtifactNode);
+               Node origJarNode = origArtifactNode.getNode(origJarNodeName);
+
+               // read MANIFEST
+               Binary manifestBinary = origJarNode.getProperty(SLC_MANIFEST)
+                               .getBinary();
+               Manifest origManifest = new Manifest(manifestBinary.getStream());
+               JcrUtils.closeQuietly(manifestBinary);
+
+               Boolean manifestModified = false;
+               Manifest targetManifest = new Manifest(origManifest);
+
+               // transform symbolic name
+               String origSymbolicName = origManifest.getMainAttributes().getValue(
+                               Constants.BUNDLE_SYMBOLICNAME);
+               final String targetSymbolicName;
+               if (symbolicNamesMapping.containsKey(origSymbolicName)) {
+                       targetSymbolicName = symbolicNamesMapping.get(origSymbolicName);
+               } else if (origSymbolicName.startsWith(SPRING_SOURCE_PREFIX)
+                               && !origSymbolicName.equals(SPRING_SOURCE_PREFIX + ".json")) {
+                       targetSymbolicName = origSymbolicName
+                                       .substring(SPRING_SOURCE_PREFIX.length() + 1);
+               } else {
+                       targetSymbolicName = origSymbolicName;
+               }
+
+               if (!targetSymbolicName.equals(origSymbolicName)) {
+                       targetManifest.getMainAttributes().putValue(
+                                       Constants.BUNDLE_SYMBOLICNAME, targetSymbolicName);
+                       manifestModified = true;
+                       if (log.isDebugEnabled())
+                               log.debug(Constants.BUNDLE_SYMBOLICNAME + " to "
+                                               + targetSymbolicName + " \t\tfrom " + origSymbolicName);
+               }
+
+               // skip excluded bundles
+               if (excludedBundles.contains(targetSymbolicName))
+                       return;
+
+               // check fragment host
+               if (origManifest.getMainAttributes().containsKey(
+                               new Name(Constants.FRAGMENT_HOST))) {
+                       String origFragmentHost = origManifest.getMainAttributes()
+                                       .getValue(Constants.FRAGMENT_HOST);
+                       String targetFragmentHost;
+                       if (symbolicNamesMapping.containsKey(origFragmentHost)) {
+                               targetFragmentHost = symbolicNamesMapping.get(origFragmentHost);
+                       } else if (origFragmentHost.startsWith(SPRING_SOURCE_PREFIX)
+                                       && !origFragmentHost.equals(SPRING_SOURCE_PREFIX + ".json")) {
+                               targetFragmentHost = origFragmentHost
+                                               .substring(SPRING_SOURCE_PREFIX.length() + 1);
+                       } else if (origFragmentHost
+                                       .equals("org.argeo.dep.jacob;bundle-version=\"[1.14.3,1.14.4)\"")) {
+                               // this one for those who think I cannot be pragmatic - mbaudier
+                               targetFragmentHost = "com.jacob;bundle-version=\"[1.14.3,1.14.4)\"";
+                       } else {
+                               targetFragmentHost = origFragmentHost;
+                       }
+
+                       if (!targetFragmentHost.equals(origFragmentHost)) {
+                               targetManifest.getMainAttributes().putValue(
+                                               Constants.FRAGMENT_HOST, targetFragmentHost);
+                               manifestModified = true;
+                               if (log.isDebugEnabled())
+                                       log.debug(Constants.FRAGMENT_HOST + " to "
+                                                       + targetFragmentHost + " from " + origFragmentHost);
+                       }
+               }
+
+               // we assume there is no Require-Bundle in com.springsource.* bundles
+
+               // javax with versions
+               StringBuffer targetImportPackages = new StringBuffer("");
+               NodeIterator origImportPackages = origJarNode.getNodes(SLC_
+                               + Constants.IMPORT_PACKAGE);
+               Boolean importPackagesModified = false;
+               while (origImportPackages.hasNext()) {
+                       Node importPackage = origImportPackages.nextNode();
+                       String pkg = importPackage.getProperty(SLC_NAME).getString();
+                       targetImportPackages.append(pkg);
+                       if (importPackage.hasProperty(SLC_VERSION)) {
+                               String sourceVersion = importPackage.getProperty(SLC_VERSION)
+                                               .getString();
+                               String targetVersion = sourceVersion;
+                               if (systemPackages.contains(pkg)) {
+                                       if (!(sourceVersion.trim().equals("0") || sourceVersion
+                                                       .trim().equals("0.0.0"))) {
+                                               targetVersion = null;
+                                               importPackagesModified = true;
+                                               if (log.isDebugEnabled())
+                                                       log.debug(origSymbolicName
+                                                                       + ": Nullify version of " + pkg + " from "
+                                                                       + sourceVersion);
+                                       }
+                               }
+                               if (targetVersion != null)
+                                       targetImportPackages.append(";version=\"")
+                                                       .append(targetVersion).append("\"");
+                       }
+                       if (importPackage.hasProperty(SLC_OPTIONAL)) {
+                               Boolean optional = importPackage.getProperty(SLC_OPTIONAL)
+                                               .getBoolean();
+                               if (optional)
+                                       targetImportPackages.append(";resolution:=\"optional\"");
+
+                       }
+                       if (origImportPackages.hasNext())
+                               targetImportPackages.append(",");
+               }
+
+               if (importPackagesModified) {
+                       targetManifest.getMainAttributes().putValue(
+                                       Constants.IMPORT_PACKAGE, targetImportPackages.toString());
+                       manifestModified = true;
+               }
+
+               if (!manifestModified && log.isTraceEnabled()) {
+                       log.trace("MANIFEST of " + origSymbolicName + " was not modified");
+               }
+
+               // target coordinates
+               final String targetGroupId;
+               if (origArtifact.getArtifactId().startsWith(
+                               "org.eclipse.rwt.widgets.upload"))
+                       targetGroupId = "org.argeo.tp.rap";
+               else if (origArtifact.getArtifactId().startsWith("org.polymap"))
+                       targetGroupId = "org.argeo.tp.rap";
+               else if (origArtifact.getGroupId().startsWith("org.eclipse")
+                               && !origArtifact.getArtifactId().equals("org.eclipse.osgi"))
+                       throw new SlcException(origArtifact + " should have been excluded");// targetGroupId
+                                                                                                                                                               // =
+                                                                                                                                                               // "org.argeo.tp.eclipse";
+               else
+                       targetGroupId = "org.argeo.tp";
+
+               String targetArtifactId = targetSymbolicName.split(";")[0];
+               Artifact targetArtifact = new DefaultArtifact(targetGroupId,
+                               targetArtifactId, "jar", origArtifact.getVersion());
+               String targetParentPath = MavenConventionsUtils.artifactParentPath(
+                               artifactBasePath, targetArtifact);
+               String targetFileName = MavenConventionsUtils
+                               .artifactFileName(targetArtifact);
+               String targetJarPath = targetParentPath + '/' + targetFileName;
+
+               // copy
+               Node targetParentNode = JcrUtils.mkfolders(targetSession,
+                               targetParentPath);
+               targetSession.save();
+               if (manifestModified) {
+                       Binary origBinary = origJarNode.getNode(Node.JCR_CONTENT)
+                                       .getProperty(Property.JCR_DATA).getBinary();
+                       byte[] targetJarBytes = RepoUtils.modifyManifest(
+                                       origBinary.getStream(), targetManifest);
+                       JcrUtils.copyBytesAsFile(targetParentNode, targetFileName,
+                                       targetJarBytes);
+                       JcrUtils.closeQuietly(origBinary);
+               } else {// just copy
+                       targetSession.getWorkspace().copy(sourceWorkspace,
+                                       origJarNode.getPath(), targetJarPath);
+               }
+               targetSession.save();
+
+               // reindex
+               Node targetJarNode = targetSession.getNode(targetJarPath);
+               artifactIndexer.index(targetJarNode);
+               jarFileIndexer.index(targetJarNode);
+
+               targetSession.save();
+
+               // sources
+               Artifact origSourceArtifact = new DefaultArtifact(
+                               origArtifact.getGroupId(), origArtifact.getArtifactId()
+                                               + ".source", "jar", origArtifact.getVersion());
+               String origSourcePath = MavenConventionsUtils.artifactPath(
+                               artifactBasePath, origSourceArtifact);
+               if (origSession.itemExists(origSourcePath)) {
+                       Node origSourceJarNode = origSession.getNode(origSourcePath);
+
+                       Artifact targetSourceArtifact = new DefaultArtifact(targetGroupId,
+                                       targetArtifactId + ".source", "jar",
+                                       origArtifact.getVersion());
+                       String targetSourceParentPath = MavenConventionsUtils
+                                       .artifactParentPath(artifactBasePath, targetSourceArtifact);
+                       String targetSourceFileName = MavenConventionsUtils
+                                       .artifactFileName(targetSourceArtifact);
+                       String targetSourceJarPath = targetSourceParentPath + '/'
+                                       + targetSourceFileName;
+
+                       Node targetSourceParentNode = JcrUtils.mkfolders(targetSession,
+                                       targetSourceParentPath);
+                       targetSession.save();
+
+                       if (!targetSymbolicName.equals(origSymbolicName)) {
+                               Binary origBinary = origSourceJarNode.getNode(Node.JCR_CONTENT)
+                                               .getProperty(Property.JCR_DATA).getBinary();
+                               NameVersion targetNameVersion = RepoUtils
+                                               .readNameVersion(targetManifest);
+                               byte[] targetJarBytes = RepoUtils.packageAsPdeSource(
+                                               origBinary.getStream(), targetNameVersion);
+                               JcrUtils.copyBytesAsFile(targetSourceParentNode,
+                                               targetSourceFileName, targetJarBytes);
+                               JcrUtils.closeQuietly(origBinary);
+                       } else {// just copy
+                               targetSession.getWorkspace().copy(sourceWorkspace,
+                                               origSourceJarNode.getPath(), targetSourceJarPath);
+                       }
+                       targetSession.save();
+
+                       // reindex
+                       Node targetSourceJarNode = targetSession
+                                       .getNode(targetSourceJarPath);
+                       artifactIndexer.index(targetSourceJarNode);
+                       jarFileIndexer.index(targetSourceJarNode);
+
+                       targetSession.save();
+               }
+       }
+
+       /*
+        * UTILITIES
+        */
+
+       static NodeIterator listArtifactVersions(Session session)
+                       throws RepositoryException {
+               QueryManager queryManager = session.getWorkspace().getQueryManager();
+               QueryObjectModelFactory factory = queryManager.getQOMFactory();
+
+               final String artifactVersionsSelector = "artifactVersions";
+               Selector source = factory.selector(SlcTypes.SLC_ARTIFACT_VERSION_BASE,
+                               artifactVersionsSelector);
+
+               Ordering orderByArtifactId = factory.ascending(factory.propertyValue(
+                               artifactVersionsSelector, SlcNames.SLC_ARTIFACT_ID));
+               Ordering[] orderings = { orderByArtifactId };
+
+               QueryObjectModel query = factory.createQuery(source, null, orderings,
+                               null);
+
+               QueryResult result = query.execute();
+               return result.getNodes();
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setSourceWorkspace(String sourceWorkspace) {
+               this.sourceWorkspace = sourceWorkspace;
+       }
+
+       public void setTargetWorkspace(String targetWorkspace) {
+               this.targetWorkspace = targetWorkspace;
+       }
+
+       public void setExcludedBundles(List<String> excludedBundles) {
+               this.excludedBundles = excludedBundles;
+       }
+
+       public void setSymbolicNamesMapping(Map<String, String> symbolicNamesMapping) {
+               this.symbolicNamesMapping = symbolicNamesMapping;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveSourcesProvider.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveSourcesProvider.java
new file mode 100644 (file)
index 0000000..ab52c70
--- /dev/null
@@ -0,0 +1,91 @@
+package org.argeo.slc.repo.osgi;
+
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.jar.JarEntry;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.OsgiFactory;
+
+public class ArchiveSourcesProvider implements SourcesProvider {
+       private final static Log log = LogFactory
+                       .getLog(ArchiveSourcesProvider.class);
+
+       private OsgiFactory osgiFactory;
+       private String uri;
+       private String base = "";
+
+       @Override
+       public void writeSources(List<String> packages, ZipOutputStream zout) {
+               Session distSession = null;
+               ZipInputStream zin = null;
+               try {
+                       distSession = osgiFactory.openDistSession();
+
+                       if (log.isDebugEnabled())
+                               log.debug("Wrapping " + uri);
+
+                       Node distNode = osgiFactory.getDist(distSession, uri);
+                       zin = new ZipInputStream(distNode.getNode(Node.JCR_CONTENT)
+                                       .getProperty(Property.JCR_DATA).getBinary().getStream());
+
+                       // prepare
+                       Set<String> directories = new TreeSet<String>();
+                       for (String pkg : packages)
+                               if (!pkg.equals("META-INF"))
+                                       directories.add(base + pkg.replace('.', '/') + '/');
+
+                       ZipEntry zentry = null;
+                       entries: while ((zentry = zin.getNextEntry()) != null) {
+                               String name = zentry.getName();
+                               if (!name.startsWith(base))
+                                       continue entries;
+
+                               String dirPath = FilenameUtils.getPath(name);
+                               if (name.equals(dirPath))// directory
+                                       continue entries;
+
+                               if (directories.contains(dirPath)) {
+                                       String path = name.substring(base.length());
+                                       zout.putNextEntry(new JarEntry(path));
+                                       IOUtils.copy(zin, zout);
+                                       zin.closeEntry();
+                                       zout.closeEntry();
+                                       continue entries;
+                               }
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot retrieve sources from " + uri, e);
+               } finally {
+                       IOUtils.closeQuietly(zin);
+                       JcrUtils.logoutQuietly(distSession);
+               }
+
+       }
+
+       public void setOsgiFactory(OsgiFactory osgiFactory) {
+               this.osgiFactory = osgiFactory;
+       }
+
+       public void setUri(String uri) {
+               this.uri = uri;
+       }
+
+       public void setBase(String base) {
+               this.base = base;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapper.java
new file mode 100644 (file)
index 0000000..2a3e5b0
--- /dev/null
@@ -0,0 +1,433 @@
+package org.argeo.slc.repo.osgi;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.jar.JarInputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.ModuleSet;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.build.License;
+import org.argeo.slc.repo.OsgiFactory;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.slc.repo.internal.springutil.AntPathMatcher;
+import org.argeo.slc.repo.internal.springutil.PathMatcher;
+import org.argeo.slc.repo.maven.ArtifactIdComparator;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+import aQute.bnd.osgi.Jar;
+
+/**
+ * Download a software distribution and generates the related OSGi bundles from
+ * the jars, or import them directly if they are already OSGi bundles and don't
+ * need further modification.
+ */
+public class ArchiveWrapper implements Runnable, ModuleSet, Distribution {
+       private final static Log log = LogFactory.getLog(ArchiveWrapper.class);
+
+       private OsgiFactory osgiFactory;
+       private String version;
+       private License license;
+
+       private String uri;
+
+       /** Jars to wrap as OSGi bundles */
+       private Map<String, BndWrapper> wrappers = new HashMap<String, BndWrapper>();
+
+       private SourcesProvider sourcesProvider;
+
+       // pattern of OSGi bundles to import
+       private PathMatcher pathMatcher = new AntPathMatcher();
+       private Map<String, String> includes = new HashMap<String, String>();
+       private List<String> excludes = new ArrayList<String>();
+
+       private Boolean mavenGroupIndexes = false;
+
+       public void init() {
+               for (BndWrapper wrapper : wrappers.values()) {
+                       wrapper.setFactory(this);
+                       if (version != null && wrapper.getVersion() == null)
+                               wrapper.setVersion(version);
+                       if (license != null && wrapper.getLicense() == null)
+                               wrapper.setLicense(license);
+               }
+       }
+
+       public void destroy() {
+
+       }
+
+       public String getDistributionId() {
+               return uri;
+       }
+
+       public String getVersion() {
+               return version;
+       }
+
+       public License getLicense() {
+               return license;
+       }
+
+       public String getUri() {
+               return uri;
+       }
+
+       public Iterator<? extends NameVersion> nameVersions() {
+               if (wrappers.size() > 0)
+                       return wrappers.values().iterator();
+               else
+                       return osgiNameVersions();
+       }
+
+       @SuppressWarnings("resource")
+       protected Iterator<? extends NameVersion> osgiNameVersions() {
+               List<CategoryNameVersion> nvs = new ArrayList<CategoryNameVersion>();
+
+               Session distSession = null;
+               ZipInputStream zin = null;
+               try {
+                       distSession = osgiFactory.openDistSession();
+
+                       Node distNode = osgiFactory.getDist(distSession, uri);
+                       zin = new ZipInputStream(
+                                       distNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream());
+
+                       ZipEntry zentry = null;
+                       entries: while ((zentry = zin.getNextEntry()) != null) {
+                               String name = zentry.getName();
+                               if (log.isTraceEnabled())
+                                       log.trace("Zip entry " + name);
+                               for (String exclude : excludes)
+                                       if (pathMatcher.match(exclude, name))
+                                               continue entries;
+
+                               for (String include : includes.keySet()) {
+                                       if (pathMatcher.match(include, name)) {
+                                               String groupId = includes.get(include);
+                                               JarInputStream jis = new JarInputStream(zin);
+                                               if (jis.getManifest() == null) {
+                                                       log.warn("No MANIFEST in entry " + name + ", skipping...");
+                                                       continue entries;
+                                               }
+                                               NameVersion nv = RepoUtils.readNameVersion(jis.getManifest());
+                                               if (nv != null) {
+                                                       if (nv.getName().endsWith(".source"))
+                                                               continue entries;
+                                                       CategoryNameVersion cnv = new ArchiveWrapperCNV(groupId, nv.getName(), nv.getVersion(),
+                                                                       this);
+                                                       nvs.add(cnv);
+                                                       // no need to process further includes
+                                                       continue entries;
+                                               }
+                                       }
+                               }
+                       }
+                       return nvs.iterator();
+               } catch (Exception e) {
+                       throw new SlcException("Cannot wrap distribution " + uri, e);
+               } finally {
+                       IOUtils.closeQuietly(zin);
+                       JcrUtils.logoutQuietly(distSession);
+               }
+       }
+
+       public void run() {
+               if (mavenGroupIndexes && (version == null))
+                       throw new SlcException("'mavenGroupIndexes' requires 'version' to be set");
+
+               Map<String, Set<Artifact>> binaries = new HashMap<String, Set<Artifact>>();
+               Map<String, Set<Artifact>> sources = new HashMap<String, Set<Artifact>>();
+
+               Session distSession = null;
+               Session javaSession = null;
+               ZipInputStream zin = null;
+               try {
+                       javaSession = osgiFactory.openJavaSession();
+                       distSession = osgiFactory.openDistSession();
+
+                       if (log.isDebugEnabled())
+                               log.debug("Wrapping " + uri);
+                       boolean nothingWasDone = true;
+
+                       Node distNode = osgiFactory.getDist(distSession, uri);
+                       zin = new ZipInputStream(
+                                       distNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream());
+
+                       ZipEntry zentry = null;
+                       entries: while ((zentry = zin.getNextEntry()) != null) {
+                               String name = zentry.getName();
+
+                               // sources autodetect
+                               String baseName = FilenameUtils.getBaseName(name);
+                               if (baseName.endsWith("-sources")) {
+                                       String bundle = baseName.substring(0, baseName.length() - "-sources".length());
+                                       // log.debug(name + "," + baseName + ", " + bundle);
+                                       String bundlePath = FilenameUtils.getPath(name) + bundle + ".jar";
+                                       if (wrappers.containsKey(bundlePath)) {
+                                               BndWrapper wrapper = wrappers.get(bundlePath);
+                                               NameVersion bundleNv = new DefaultNameVersion(wrapper.getName(), wrapper.getVersion());
+                                               byte[] pdeSource = RepoUtils.packageAsPdeSource(zin, bundleNv);
+                                               Artifact sourcesArtifact = new DefaultArtifact(wrapper.getCategory(),
+                                                               wrapper.getName() + ".source", "jar", wrapper.getVersion());
+                                               Node pdeSourceNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), sourcesArtifact,
+                                                               pdeSource);
+                                               osgiFactory.indexNode(pdeSourceNode);
+                                               pdeSourceNode.getSession().save();
+                                               if (log.isDebugEnabled())
+                                                       log.debug("Added sources " + sourcesArtifact + " for bundle " + wrapper.getArtifact()
+                                                                       + "from " + name + " in binary archive.");
+                                       }
+
+                               }
+                               // else if (baseName.endsWith(".source")) {
+                               // }
+
+                               // binaries
+                               if (wrappers.containsKey(name)) {
+                                       BndWrapper wrapper = (BndWrapper) wrappers.get(name);
+                                       // we must copy since the stream is closed by BND
+                                       byte[] origJarBytes = IOUtils.toByteArray(zin);
+                                       Artifact artifact = wrapZipEntry(javaSession, zentry, origJarBytes, wrapper);
+                                       nothingWasDone = false;
+                                       addArtifactToIndex(binaries, wrapper.getGroupId(), artifact);
+                               } else {
+                                       for (String wrapperKey : wrappers.keySet())
+                                               if (pathMatcher.match(wrapperKey, name)) {
+                                                       // first matched is taken
+                                                       BndWrapper wrapper = (BndWrapper) wrappers.get(wrapperKey);
+                                                       // we must copy since the stream is closed by BND
+                                                       byte[] origJarBytes = IOUtils.toByteArray(zin);
+                                                       Artifact artifact = wrapZipEntry(javaSession, zentry, origJarBytes, wrapper);
+                                                       nothingWasDone = false;
+                                                       addArtifactToIndex(binaries, wrapper.getGroupId(), artifact);
+                                                       continue entries;
+                                               } else {
+                                                       if (log.isTraceEnabled())
+                                                               log.trace(name + " not matched by " + wrapperKey);
+                                               }
+
+                                       for (String exclude : excludes)
+                                               if (pathMatcher.match(exclude, name))
+                                                       continue entries;
+
+                                       for (String include : includes.keySet()) {
+                                               if (pathMatcher.match(include, name)) {
+                                                       String groupId = includes.get(include);
+                                                       byte[] origJarBytes = IOUtils.toByteArray(zin);
+                                                       Artifact artifact = importZipEntry(javaSession, zentry, origJarBytes, groupId);
+                                                       if (artifact == null) {
+                                                               log.warn("Skipped non identified " + zentry);
+                                                               continue entries;
+                                                       }
+                                                       nothingWasDone = false;
+                                                       if (artifact.getArtifactId().endsWith(".source"))
+                                                               addArtifactToIndex(sources, groupId, artifact);
+                                                       else
+                                                               addArtifactToIndex(binaries, groupId, artifact);
+                                                       // no need to process this entry further
+                                                       continue entries;
+                                               }
+                                       }
+                               }
+                       }
+
+                       // indexes
+                       if (mavenGroupIndexes && version != null) {
+                               for (String groupId : binaries.keySet()) {
+                                       RepoUtils.writeGroupIndexes(javaSession, "/", groupId, version, binaries.get(groupId),
+                                                       sources.containsKey(groupId) ? sources.get(groupId) : null);
+                               }
+                       }
+
+                       if (nothingWasDone) {
+                               log.error("Nothing was done when wrapping " + uri + ". THE DISTRIBUTION IS INCONSISTENT.");
+                               // throw new SlcException("Nothing was done");
+                               // TODO Fail if not all wrappers matched
+                       }
+
+               } catch (Exception e) {
+                       throw new SlcException("Cannot wrap distribution " + uri, e);
+               } finally {
+                       IOUtils.closeQuietly(zin);
+                       JcrUtils.logoutQuietly(distSession);
+                       JcrUtils.logoutQuietly(javaSession);
+               }
+       }
+
+       protected Artifact wrapZipEntry(Session javaSession, ZipEntry zentry, byte[] origJarBytes, BndWrapper wrapper)
+                       throws RepositoryException {
+               ByteArrayOutputStream out = null;
+               ByteArrayInputStream in = null;
+               Node newJarNode;
+               Jar jar = null;
+               try {
+                       out = new ByteArrayOutputStream((int) zentry.getSize());
+                       in = new ByteArrayInputStream(origJarBytes);
+                       wrapper.wrapJar(in, out);
+
+                       Artifact artifact = wrapper.getArtifact();
+                       newJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), artifact, out.toByteArray());
+                       osgiFactory.indexNode(newJarNode);
+                       newJarNode.getSession().save();
+                       if (log.isDebugEnabled())
+                               log.debug("Wrapped jar " + zentry.getName() + " to " + newJarNode.getPath());
+
+                       if (sourcesProvider != null)
+                               addSource(javaSession, artifact, out.toByteArray());
+
+                       return artifact;
+               } finally {
+                       IOUtils.closeQuietly(in);
+                       IOUtils.closeQuietly(out);
+                       if (jar != null)
+                               jar.close();
+               }
+       }
+
+       protected void addSource(Session javaSession, Artifact artifact, byte[] binaryJarBytes) {
+               InputStream in = null;
+               ByteArrayOutputStream out = null;
+               Jar jar = null;
+               try {
+                       in = new ByteArrayInputStream(binaryJarBytes);
+                       jar = new Jar(null, in);
+                       List<String> packages = jar.getPackages();
+
+                       out = new ByteArrayOutputStream();
+                       sourcesProvider.writeSources(packages, new ZipOutputStream(out));
+
+                       IOUtils.closeQuietly(in);
+                       in = new ByteArrayInputStream(out.toByteArray());
+                       byte[] sourcesJar = RepoUtils.packageAsPdeSource(in,
+                                       new DefaultNameVersion(artifact.getArtifactId(), artifact.getVersion()));
+                       Artifact sourcesArtifact = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId() + ".source",
+                                       "jar", artifact.getVersion());
+                       Node sourcesJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), sourcesArtifact, sourcesJar);
+                       sourcesJarNode.getSession().save();
+
+                       if (log.isDebugEnabled())
+                               log.debug("Added sources " + sourcesArtifact + " for bundle " + artifact + "from source provider "
+                                               + sourcesProvider);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot get sources for " + artifact, e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+                       IOUtils.closeQuietly(out);
+                       if (jar != null)
+                               jar.close();
+               }
+       }
+
+       protected Artifact importZipEntry(Session javaSession, ZipEntry zentry, byte[] binaryJarBytes, String groupId)
+                       throws RepositoryException {
+               ByteArrayInputStream in = null;
+               Node newJarNode;
+               try {
+                       in = new ByteArrayInputStream(binaryJarBytes);
+                       NameVersion nameVersion = RepoUtils.readNameVersion(in);
+                       if (nameVersion == null) {
+                               log.warn("Cannot identify " + zentry.getName());
+                               return null;
+                       }
+                       Artifact artifact = new DefaultArtifact(groupId, nameVersion.getName(), "jar", nameVersion.getVersion());
+                       newJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), artifact, binaryJarBytes);
+                       osgiFactory.indexNode(newJarNode);
+                       newJarNode.getSession().save();
+                       if (log.isDebugEnabled()) {
+                               log.debug(zentry.getName() + " => " + artifact);
+                       }
+
+                       if (sourcesProvider != null)
+                               addSource(javaSession, artifact, binaryJarBytes);
+
+                       return artifact;
+               } finally {
+                       IOUtils.closeQuietly(in);
+               }
+       }
+
+       private void addArtifactToIndex(Map<String, Set<Artifact>> index, String groupId, Artifact artifact) {
+               if (!index.containsKey(groupId))
+                       index.put(groupId, new TreeSet<Artifact>(new ArtifactIdComparator()));
+               index.get(groupId).add(artifact);
+       }
+
+       public void setUri(String uri) {
+               this.uri = uri;
+       }
+
+       public void setWrappers(Map<String, BndWrapper> wrappers) {
+               this.wrappers = wrappers;
+       }
+
+       public void setOsgiFactory(OsgiFactory osgiFactory) {
+               this.osgiFactory = osgiFactory;
+       }
+
+       public void setVersion(String version) {
+               this.version = version;
+       }
+
+       public void setLicense(License license) {
+               this.license = license;
+       }
+
+       public void setPathMatcher(PathMatcher pathMatcher) {
+               this.pathMatcher = pathMatcher;
+       }
+
+       public void setIncludes(Map<String, String> includes) {
+               this.includes = includes;
+       }
+
+       public void setExcludes(List<String> excludes) {
+               this.excludes = excludes;
+       }
+
+       public void setMavenGroupIndexes(Boolean mavenGroupIndexes) {
+               this.mavenGroupIndexes = mavenGroupIndexes;
+       }
+
+       public void setSourcesProvider(SourcesProvider sourcesProvider) {
+               this.sourcesProvider = sourcesProvider;
+       }
+
+       public Map<String, BndWrapper> getWrappers() {
+               return wrappers;
+       }
+
+       public Map<String, String> getIncludes() {
+               return includes;
+       }
+
+       public List<String> getExcludes() {
+               return excludes;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapperCNV.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArchiveWrapperCNV.java
new file mode 100644 (file)
index 0000000..910d581
--- /dev/null
@@ -0,0 +1,25 @@
+package org.argeo.slc.repo.osgi;
+
+import org.argeo.slc.DefaultCategoryNameVersion;
+
+/** A module within an archive. */
+public class ArchiveWrapperCNV extends DefaultCategoryNameVersion implements Runnable {
+       /** Build runnable */
+       private ArchiveWrapper build;
+
+       public ArchiveWrapperCNV(String category, String name, String version, ArchiveWrapper build) {
+               super(category, name, version);
+               this.build = build;
+       }
+
+       @Override
+       public void run() {
+               if (build != null)
+                       build.run();
+       }
+
+       public ArchiveWrapper getBuild() {
+               return build;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ArgeoOsgiDistributionImpl.java
new file mode 100644 (file)
index 0000000..7e4a32e
--- /dev/null
@@ -0,0 +1,220 @@
+package org.argeo.slc.repo.osgi;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.ModuleSet;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.repo.ArgeoOsgiDistribution;
+import org.argeo.slc.repo.ArtifactDistribution;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.osgi.framework.Constants;
+
+/**
+ * A consistent and versioned OSGi distribution, which can be built and tested.
+ */
+public class ArgeoOsgiDistributionImpl extends ArtifactDistribution implements ArgeoOsgiDistribution {
+       private final static Log log = LogFactory.getLog(ArgeoOsgiDistributionImpl.class);
+
+       private List<Object> modules = new ArrayList<Object>();
+
+       public ArgeoOsgiDistributionImpl(String coords) {
+               super(coords);
+       }
+
+       public void init() {
+               if (log.isDebugEnabled())
+                       log.debug(describe());
+//             migrateTov2(Paths.get(System.getProperty("user.home"), "dev/git/gpl/argeo-tp/argeo-tp"));
+       }
+
+       public void destroy() {
+
+       }
+
+       public String describe() {
+               SortedSet<String> sort = new TreeSet<String>();
+               Iterator<? extends NameVersion> nvIt = nameVersions();
+               while (nvIt.hasNext()) {
+                       NameVersion nv = nvIt.next();
+                       String str = nv.toString();
+                       if (nv instanceof MavenWrapper)
+                               str = str + "\t(Maven)";
+                       else if (nv instanceof UriWrapper)
+                               str = str + "\t(URI)";
+                       else if (nv instanceof ArchiveWrapperCNV)
+                               str = str + "\t(OSGi from archive)";
+                       else if (nv instanceof BndWrapper)
+                               str = str + "\t(Plain BND from archive)";
+                       else
+                               str = str + "\t(UNKNOWN??)";
+                       sort.add(str);
+               }
+
+               StringBuffer buf = new StringBuffer("## DISTRIBUTION " + toString() + " ##\n");
+               for (String str : sort) {
+                       buf.append(str).append('\n');
+               }
+               return buf.toString();
+       }
+
+       public void migrateTov2(Path baseDir) {
+               Set<ArchiveWrapper> archiveWrappers = new HashSet<>();
+               Iterator<? extends NameVersion> nvIt = nameVersions();
+               while (nvIt.hasNext()) {
+                       NameVersion nv = nvIt.next();
+                       try {
+                               if (nv instanceof CategoryNameVersion) {
+                                       CategoryNameVersion cnv = (CategoryNameVersion) nv;
+                                       // TODO add branch?
+                                       Path categoryBase = baseDir.resolve(cnv.getCategory());
+                                       Files.createDirectories(categoryBase);
+                                       if (cnv instanceof BndWrapper) {
+                                               BndWrapper bw = (BndWrapper) cnv;
+                                               Path bndPath = categoryBase.resolve(cnv.getName() + ".bnd");
+                                               Map<String, String> props = new TreeMap<>();
+                                               for (Map.Entry<Object, Object> entry : ((BndWrapper) cnv).getBndProperties().entrySet()) {
+                                                       props.put(entry.getKey().toString(), entry.getValue().toString());
+                                               }
+                                               props.put(Constants.BUNDLE_SYMBOLICNAME, cnv.getName());
+                                               props.put(Constants.BUNDLE_VERSION, cnv.getVersion());
+                                               if (bw.getLicense() != null)
+                                                       props.put(Constants.BUNDLE_LICENSE, bw.getLicense().toString());
+                                               else
+                                                       log.warn("No license for " + cnv);
+                                               if (bw.getDoNotModify()) {
+                                                       props.put("SLC-Source-Original", "true");
+                                               }
+                                               // props.put("SLC-Category", cnv.getCategory());
+
+                                               if (cnv instanceof MavenWrapper) {
+                                                       MavenWrapper mw = (MavenWrapper) cnv;
+                                                       String sourceCoords = mw.getSourceCoords();
+                                                       props.put("SLC-Source-M2", sourceCoords);
+                                                       Artifact mavenCnv = new DefaultArtifact(sourceCoords);
+                                                       if (mavenCnv.getArtifactId().equals(cnv.getName()))
+                                                               props.remove(Constants.BUNDLE_SYMBOLICNAME);
+                                                       if (mavenCnv.getVersion().equals(cnv.getVersion()))
+                                                               props.remove(Constants.BUNDLE_VERSION);
+                                               } else if (cnv instanceof UriWrapper) {
+                                                       UriWrapper mw = (UriWrapper) cnv;
+                                                       props.put("SLC-Source-URI", mw.getEffectiveUri());
+                                                       if (mw.getUri() == null && mw.getBaseUri() != null) {
+                                                               log.warn("Base URI for " + cnv);
+                                                               props.put("SLC-Source-BaseURI", mw.getBaseUri());
+                                                               props.put("SLC-Source-VersionSeparator", mw.getVersionSeparator());
+                                                       }
+                                               } else {
+                                                       log.warn("Unidentified BND wrapper " + cnv);
+                                               }
+
+                                               // write BND file
+                                               try (Writer writer = Files.newBufferedWriter(bndPath)) {
+                                                       // writer.write("# " + cnv + "\n");
+                                                       props: for (String key : props.keySet()) {
+                                                               String value = props.get(key);
+                                                               if (Constants.EXPORT_PACKAGE.equals(key) && "*".equals(value.trim()))
+                                                                       continue props;
+
+                                                               writer.write(key + ": " + value + '\n');
+                                                       }
+                                                       if (log.isTraceEnabled())
+                                                               log.trace("Wrote " + bndPath);
+                                               }
+                                       } else if (cnv instanceof ArchiveWrapperCNV) {
+                                               ArchiveWrapperCNV onv = (ArchiveWrapperCNV) cnv;
+                                               ArchiveWrapper aw = onv.getBuild();
+                                               archiveWrappers.add(aw);
+                                               // TODO specify and implement archive wrapper support
+                                       } else {
+                                               log.warn("Unsupported wrapper " + cnv.getClass() + " for " + cnv);
+                                       }
+
+                               } else {
+                                       log.error("Category required for " + nv + ", skipping...");
+                               }
+                       } catch (IOException e) {
+                               log.error("Could not process " + nv, e);
+                       }
+               }
+               if (log.isDebugEnabled()) {
+                       for (ArchiveWrapper aw : archiveWrappers) {
+                               log.debug("Archive wrapper " + aw.getUri() + ":");
+                               log.debug(" includes: " + aw.getIncludes());
+                               log.debug(" excludes: " + aw.getExcludes());
+                               log.debug(" beans   : " + aw.getWrappers());
+                       }
+               }
+
+       }
+
+       public Iterator<NameVersion> nameVersions() {
+               List<NameVersion> nameVersions = new ArrayList<NameVersion>();
+               for (Object module : modules) {
+                       // extract runnable from execution flow
+                       if (module instanceof ExecutionFlow) {
+                               for (Iterator<Runnable> it = ((ExecutionFlow) module).runnables(); it.hasNext();) {
+                                       processModule(nameVersions, it.next());
+                               }
+                       } else {
+                               processModule(nameVersions, module);
+                       }
+               }
+               return nameVersions.iterator();
+       }
+
+       private void processModule(List<NameVersion> nameVersions, Object module) {
+               if (module instanceof ModuleSet)
+                       addNameVersions(nameVersions, (ModuleSet) module);
+               else if (module instanceof NameVersion) {
+                       NameVersion nv = (NameVersion) module;
+                       addNameVersion(nameVersions, nv);
+               } else
+                       log.warn("Ignored " + module);
+       }
+
+       private void addNameVersions(List<NameVersion> nameVersions, ModuleSet moduleSet) {
+               Iterator<? extends NameVersion> it = moduleSet.nameVersions();
+               while (it.hasNext()) {
+                       NameVersion nv = it.next();
+                       addNameVersion(nameVersions, nv);
+               }
+       }
+
+       protected void addNameVersion(List<NameVersion> nameVersions, NameVersion nv) {
+               if (!nameVersions.contains(nv)) {
+                       nameVersions.add(nv);
+               }
+       }
+
+       // Modular distribution interface methods. Not yet used.
+       public Distribution getModuleDistribution(String moduleName, String moduleVersion) {
+               throw new UnsupportedOperationException();
+       }
+
+       public Object getModulesDescriptor(String descriptorType) {
+               throw new UnsupportedOperationException();
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setModules(List<Object> modules) {
+               this.modules = modules;
+       }
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/BndWrapper.java
new file mode 100644 (file)
index 0000000..ddb569b
--- /dev/null
@@ -0,0 +1,222 @@
+package org.argeo.slc.repo.osgi;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Properties;
+import java.util.jar.Manifest;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.build.License;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.osgi.framework.Version;
+
+import aQute.bnd.osgi.Builder;
+import aQute.bnd.osgi.Constants;
+import aQute.bnd.osgi.Jar;
+
+/** Utilities around the BND library, which manipulates OSGi metadata. */
+public class BndWrapper implements Constants, CategoryNameVersion, Distribution {
+       private final static Log log = LogFactory.getLog(BndWrapper.class);
+
+       private String groupId;
+       private String name;
+       private Properties bndProperties = new Properties();
+
+       private String version;
+       private License license;
+
+       private Boolean doNotModify = false;
+
+       private Runnable factory = null;
+
+       public void wrapJar(InputStream in, OutputStream out) {
+               Builder b = new Builder();
+               Jar jar = null;
+               try {
+                       byte[] jarBytes = IOUtils.toByteArray(in);
+
+                       jar = new Jar(name, new ByteArrayInputStream(jarBytes));
+                       Manifest sourceManifest = jar.getManifest();
+
+                       Version versionToUse;
+                       if (sourceManifest != null) {
+                               // Symbolic name
+                               String sourceSymbolicName = sourceManifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
+                               if (sourceSymbolicName != null && !sourceSymbolicName.equals(name))
+                                       log.info("The new symbolic name (" + name
+                                                       + ") is not consistant with the wrapped bundle symbolic name (" + sourceSymbolicName + ")");
+
+                               // Version
+                               String sourceVersion = sourceManifest.getMainAttributes().getValue(BUNDLE_VERSION);
+                               if (getVersion() == null && sourceVersion == null) {
+                                       throw new SlcException("A bundle version must be defined.");
+                               } else if (getVersion() == null && sourceVersion != null) {
+                                       versionToUse = new Version(sourceVersion);
+                                       version = sourceVersion; // set wrapper version
+                               } else if (getVersion() != null && sourceVersion == null) {
+                                       versionToUse = new Version(getVersion());
+                               } else {// both set
+                                       versionToUse = new Version(getVersion());
+                                       Version sv = new Version(sourceVersion);
+                                       if (versionToUse.getMajor() != sv.getMajor() || versionToUse.getMinor() != sv.getMinor()
+                                                       || versionToUse.getMicro() != sv.getMicro()) {
+                                               log.warn("The new version (" + versionToUse
+                                                               + ") is not consistant with the wrapped bundle version (" + sv + ")");
+                                       }
+                               }
+                       } else {
+                               versionToUse = new Version(getVersion());
+                       }
+
+                       if (doNotModify) {
+                               IOUtils.write(jarBytes, out);
+                               // jar.write(out);
+                       } else {
+
+                               Properties properties = new Properties();
+                               properties.putAll(bndProperties);
+                               properties.setProperty(BUNDLE_SYMBOLICNAME, name);
+                               properties.setProperty(BUNDLE_VERSION, versionToUse.toString());
+
+                               // License
+                               if (license != null) {
+                                       StringBuilder sb = new StringBuilder(license.getUri());
+                                       if (license.getName() != null)
+                                               sb.append(';').append("description=").append(license.getName());
+                                       if (license.getLink() != null)
+                                               sb.append(';').append("link=").append(license.getLink());
+                                       properties.setProperty(BUNDLE_LICENSE, sb.toString());
+                                       // TODO add LICENSE.TXT
+                               } else {
+                                       log.warn("No license set for " + toString());
+                               }
+
+                               // b.addIncluded(jarFile);
+                               b.addClasspath(jar);
+
+                               if (log.isDebugEnabled())
+                                       log.debug(properties);
+                               b.setProperties(properties);
+
+                               Jar newJar = b.build();
+                               newJar.write(out);
+                               newJar.close();
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot wrap jar", e);
+               } finally {
+                       try {
+                               b.close();
+                               if (jar != null)
+                                       jar.close();
+                       } catch (Exception e) {
+                               // silent
+                       }
+               }
+
+       }
+
+       public Runnable getFactory() {
+               return factory;
+       }
+
+       public void setFactory(Runnable factory) {
+               if (this.factory != null)
+                       throw new SlcException("Factory already set on " + name);
+               this.factory = factory;
+       }
+
+       public void setName(String bsn) {
+               this.name = bsn;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setVersion(String version) {
+               if (this.version != null)
+                       throw new SlcException("Version already set on " + name + " (" + this.version + ")");
+               this.version = version;
+       }
+
+       public String getVersion() {
+               return version;
+       }
+
+       public License getLicense() {
+               return license;
+       }
+
+       public void setLicense(License license) {
+               if (this.license != null)
+                       throw new SlcException("License already set on " + name);
+               this.license = license;
+       }
+
+       public Properties getBndProperties() {
+               return bndProperties;
+       }
+
+       public void setBndProperties(Properties bndProperties) {
+               this.bndProperties = bndProperties;
+       }
+
+       public String getGroupId() {
+               return groupId;
+       }
+
+       public String getCategory() {
+               return getGroupId();
+       }
+
+       public void setGroupId(String groupId) {
+               this.groupId = groupId;
+       }
+
+       public String getDistributionId() {
+               return getCategory() + ":" + getName() + ":" + getVersion();
+       }
+
+       public Artifact getArtifact() {
+               return new DefaultArtifact(groupId, name, "jar", getVersion());
+       }
+
+       @Override
+       public String toString() {
+               return getDistributionId();
+       }
+
+       @Override
+       public int hashCode() {
+               if (name != null)
+                       return name.hashCode();
+               return super.hashCode();
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (obj instanceof CategoryNameVersion) {
+                       CategoryNameVersion cnv = (CategoryNameVersion) obj;
+                       return getCategory().equals(cnv.getCategory()) && getName().equals(cnv.getName())
+                                       && getVersion().equals(cnv.getVersion());
+               } else
+                       return false;
+       }
+
+       public void setDoNotModify(Boolean doNotModify) {
+               this.doNotModify = doNotModify;
+       }
+
+       public Boolean getDoNotModify() {
+               return doNotModify;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ImportBundlesZip.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ImportBundlesZip.java
new file mode 100644 (file)
index 0000000..0518bbf
--- /dev/null
@@ -0,0 +1,149 @@
+package org.argeo.slc.repo.osgi;
+
+import java.io.ByteArrayInputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.ArtifactIndexer;
+import org.argeo.slc.repo.JarFileIndexer;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+/**
+ * Import all bundles in a zip file (typically an Eclipse distribution) into the
+ * workspace.
+ * 
+ * @deprecated Use {@link ArchiveWrapper} instead.
+ */
+@Deprecated
+public class ImportBundlesZip implements Runnable {
+       private final static Log log = LogFactory.getLog(ImportBundlesZip.class);
+       private Repository repository;
+       private String workspace;
+       private String groupId;
+       private String artifactBasePath = "/";
+
+       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
+       private JarFileIndexer jarFileIndexer = new JarFileIndexer();
+
+       private String zipFile;
+
+       private List<String> excludedBundles = new ArrayList<String>();
+
+       public void run() {
+               ZipInputStream zipIn = null;
+               JarInputStream jarIn = null;
+               Session session = null;
+               try {
+                       URL url = new URL(zipFile);
+                       session = repository.login(workspace);
+
+                       // clear
+                       // String groupPath = MavenConventionsUtils.groupPath(
+                       // artifactBasePath, groupId);
+                       // if (session.itemExists(groupPath)) {
+                       // session.getNode(groupPath).remove();
+                       // session.save();
+                       // if (log.isDebugEnabled())
+                       // log.debug("Cleared " + groupPath);
+                       // }
+
+                       zipIn = new ZipInputStream(url.openStream());
+                       ZipEntry zipEntry = null;
+                       entries: while ((zipEntry = zipIn.getNextEntry()) != null) {
+                               String entryName = zipEntry.getName();
+                               if (!entryName.endsWith(".jar")
+                                               || entryName.contains("feature"))
+                                       continue entries;// skip
+                               byte[] jarBytes = IOUtils.toByteArray(zipIn);
+                               zipIn.closeEntry();
+                               jarIn = new JarInputStream(new ByteArrayInputStream(jarBytes));
+                               Manifest manifest = jarIn.getManifest();
+                               IOUtils.closeQuietly(jarIn);
+                               if (manifest == null) {
+                                       log.warn(entryName + " has no MANIFEST");
+                                       continue entries;
+                               }
+                               NameVersion nv;
+                               try {
+                                       nv = RepoUtils.readNameVersion(manifest);
+                               } catch (Exception e) {
+                                       log.warn("Cannot read name version from " + entryName, e);
+                                       continue entries;
+                               }
+
+                               String bundleName = RepoUtils
+                                               .extractBundleNameFromSourceName(nv.getName());
+                               // skip excluded bundles and their sources
+                               if (excludedBundles.contains(bundleName))
+                                       continue entries;
+                               // for(String excludedBundle:excludedBundles){
+                               // if(bundleName.contains(excludedBundle))
+                               // continue entries;
+                               // }
+
+                               Artifact artifact = new DefaultArtifact(groupId, nv.getName(),
+                                               "jar", nv.getVersion());
+                               Node artifactNode = RepoUtils.copyBytesAsArtifact(
+                                               session.getNode(artifactBasePath), artifact, jarBytes);
+                               jarBytes = null;// superstition, in order to free memory
+
+                               // indexes
+                               artifactIndexer.index(artifactNode);
+                               jarFileIndexer.index(artifactNode);
+                               session.save();
+                               if (log.isDebugEnabled())
+                                       log.debug("Imported " + entryName + " to " + artifactNode);
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot import zip " + zipFile + " to "
+                                       + workspace, e);
+               } finally {
+                       IOUtils.closeQuietly(zipIn);
+                       IOUtils.closeQuietly(jarIn);
+                       JcrUtils.logoutQuietly(session);
+               }
+
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setWorkspace(String workspace) {
+               this.workspace = workspace;
+       }
+
+       public void setGroupId(String groupId) {
+               this.groupId = groupId;
+       }
+
+       public void setArtifactBasePath(String artifactBasePath) {
+               this.artifactBasePath = artifactBasePath;
+       }
+
+       public void setZipFile(String zipFile) {
+               this.zipFile = zipFile;
+       }
+
+       public void setExcludedBundles(List<String> excludedBundles) {
+               this.excludedBundles = excludedBundles;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.6.profile b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.6.profile
new file mode 100644 (file)
index 0000000..68e811f
--- /dev/null
@@ -0,0 +1,194 @@
+###############################################################################
+# Copyright (c) 2003, 2008 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
+###############################################################################
+org.osgi.framework.system.packages = \
+ javax.accessibility,\
+ javax.activation,\
+ javax.activity,\
+ javax.annotation,\
+ javax.annotation.processing,\
+ javax.crypto,\
+ javax.crypto.interfaces,\
+ javax.crypto.spec,\
+ javax.imageio,\
+ javax.imageio.event,\
+ javax.imageio.metadata,\
+ javax.imageio.plugins.bmp,\
+ javax.imageio.plugins.jpeg,\
+ javax.imageio.spi,\
+ javax.imageio.stream,\
+ javax.jws,\
+ javax.jws.soap,\
+ javax.lang.model,\
+ javax.lang.model.element,\
+ javax.lang.model.type,\
+ javax.lang.model.util,\
+ javax.management,\
+ javax.management.loading,\
+ javax.management.modelmbean,\
+ javax.management.monitor,\
+ javax.management.openmbean,\
+ javax.management.relation,\
+ javax.management.remote,\
+ javax.management.remote.rmi,\
+ javax.management.timer,\
+ javax.naming,\
+ javax.naming.directory,\
+ javax.naming.event,\
+ javax.naming.ldap,\
+ javax.naming.spi,\
+ javax.net,\
+ javax.net.ssl,\
+ javax.print,\
+ javax.print.attribute,\
+ javax.print.attribute.standard,\
+ javax.print.event,\
+ javax.rmi,\
+ javax.rmi.CORBA,\
+ javax.rmi.ssl,\
+ javax.script,\
+ javax.security.auth,\
+ javax.security.auth.callback,\
+ javax.security.auth.kerberos,\
+ javax.security.auth.login,\
+ javax.security.auth.spi,\
+ javax.security.auth.x500,\
+ javax.security.cert,\
+ javax.security.sasl,\
+ javax.sound.midi,\
+ javax.sound.midi.spi,\
+ javax.sound.sampled,\
+ javax.sound.sampled.spi,\
+ javax.sql,\
+ javax.sql.rowset,\
+ javax.sql.rowset.serial,\
+ javax.sql.rowset.spi,\
+ javax.swing,\
+ javax.swing.border,\
+ javax.swing.colorchooser,\
+ javax.swing.event,\
+ javax.swing.filechooser,\
+ javax.swing.plaf,\
+ javax.swing.plaf.basic,\
+ javax.swing.plaf.metal,\
+ javax.swing.plaf.multi,\
+ javax.swing.plaf.synth,\
+ javax.swing.table,\
+ javax.swing.text,\
+ javax.swing.text.html,\
+ javax.swing.text.html.parser,\
+ javax.swing.text.rtf,\
+ javax.swing.tree,\
+ javax.swing.undo,\
+ javax.tools,\
+ javax.transaction,\
+ javax.transaction.xa,\
+ javax.xml,\
+ javax.xml.bind,\
+ javax.xml.bind.annotation,\
+ javax.xml.bind.annotation.adapters,\
+ javax.xml.bind.attachment,\
+ javax.xml.bind.helpers,\
+ javax.xml.bind.util,\
+ javax.xml.crypto,\
+ javax.xml.crypto.dom,\
+ javax.xml.crypto.dsig,\
+ javax.xml.crypto.dsig.dom,\
+ javax.xml.crypto.dsig.keyinfo,\
+ javax.xml.crypto.dsig.spec,\
+ javax.xml.datatype,\
+ javax.xml.namespace,\
+ javax.xml.parsers,\
+ javax.xml.soap,\
+ javax.xml.stream,\
+ javax.xml.stream.events,\
+ javax.xml.stream.util,\
+ javax.xml.transform,\
+ javax.xml.transform.dom,\
+ javax.xml.transform.sax,\
+ javax.xml.transform.stax,\
+ javax.xml.transform.stream,\
+ javax.xml.validation,\
+ javax.xml.ws,\
+ javax.xml.ws.handler,\
+ javax.xml.ws.handler.soap,\
+ javax.xml.ws.http,\
+ javax.xml.ws.soap,\
+ javax.xml.ws.spi,\
+ javax.xml.ws.wsaddressing,\
+ javax.xml.xpath,\
+ org.ietf.jgss,\
+ org.omg.CORBA,\
+ org.omg.CORBA_2_3,\
+ org.omg.CORBA_2_3.portable,\
+ org.omg.CORBA.DynAnyPackage,\
+ org.omg.CORBA.ORBPackage,\
+ org.omg.CORBA.portable,\
+ org.omg.CORBA.TypeCodePackage,\
+ org.omg.CosNaming,\
+ org.omg.CosNaming.NamingContextExtPackage,\
+ org.omg.CosNaming.NamingContextPackage,\
+ org.omg.Dynamic,\
+ org.omg.DynamicAny,\
+ org.omg.DynamicAny.DynAnyFactoryPackage,\
+ org.omg.DynamicAny.DynAnyPackage,\
+ org.omg.IOP,\
+ org.omg.IOP.CodecFactoryPackage,\
+ org.omg.IOP.CodecPackage,\
+ org.omg.Messaging,\
+ org.omg.PortableInterceptor,\
+ org.omg.PortableInterceptor.ORBInitInfoPackage,\
+ org.omg.PortableServer,\
+ org.omg.PortableServer.CurrentPackage,\
+ org.omg.PortableServer.POAManagerPackage,\
+ org.omg.PortableServer.POAPackage,\
+ org.omg.PortableServer.portable,\
+ org.omg.PortableServer.ServantLocatorPackage,\
+ org.omg.SendingContext,\
+ org.omg.stub.java.rmi,\
+ org.w3c.dom,\
+ org.w3c.dom.bootstrap,\
+ org.w3c.dom.css,\
+ org.w3c.dom.events,\
+ org.w3c.dom.html,\
+ org.w3c.dom.ls,\
+ org.w3c.dom.ranges,\
+ org.w3c.dom.stylesheets,\
+ org.w3c.dom.traversal,\
+ org.w3c.dom.views,\
+ org.w3c.dom.xpath,\
+ org.xml.sax,\
+ org.xml.sax.ext,\
+ org.xml.sax.helpers
+org.osgi.framework.bootdelegation = \
+ javax.*,\
+ org.ietf.jgss,\
+ org.omg.*,\
+ org.w3c.*,\
+ org.xml.*,\
+ sun.*,\
+ com.sun.*
+org.osgi.framework.executionenvironment = \
+ OSGi/Minimum-1.0,\
+ OSGi/Minimum-1.1,\
+ OSGi/Minimum-1.2,\
+ JRE-1.1,\
+ J2SE-1.2,\
+ J2SE-1.3,\
+ J2SE-1.4,\
+ J2SE-1.5,\
+ JavaSE-1.6
+osgi.java.profile.name = JavaSE-1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.7.profile b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/JavaSE-1.7.profile
new file mode 100644 (file)
index 0000000..192b46e
--- /dev/null
@@ -0,0 +1,198 @@
+###############################################################################
+# Copyright (c) 2009, 2010 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
+###############################################################################
+org.osgi.framework.system.packages = \
+ javax.accessibility,\
+ javax.activation,\
+ javax.activity,\
+ javax.annotation,\
+ javax.annotation.processing,\
+ javax.crypto,\
+ javax.crypto.interfaces,\
+ javax.crypto.spec,\
+ javax.imageio,\
+ javax.imageio.event,\
+ javax.imageio.metadata,\
+ javax.imageio.plugins.bmp,\
+ javax.imageio.plugins.jpeg,\
+ javax.imageio.spi,\
+ javax.imageio.stream,\
+ javax.jws,\
+ javax.jws.soap,\
+ javax.lang.model,\
+ javax.lang.model.element,\
+ javax.lang.model.type,\
+ javax.lang.model.util,\
+ javax.management,\
+ javax.management.event,\
+ javax.management.loading,\
+ javax.management.modelmbean,\
+ javax.management.monitor,\
+ javax.management.namespace,\
+ javax.management.openmbean,\
+ javax.management.relation,\
+ javax.management.remote,\
+ javax.management.remote.rmi,\
+ javax.management.timer,\
+ javax.naming,\
+ javax.naming.directory,\
+ javax.naming.event,\
+ javax.naming.ldap,\
+ javax.naming.spi,\
+ javax.net,\
+ javax.net.ssl,\
+ javax.print,\
+ javax.print.attribute,\
+ javax.print.attribute.standard,\
+ javax.print.event,\
+ javax.rmi,\
+ javax.rmi.CORBA,\
+ javax.rmi.ssl,\
+ javax.script,\
+ javax.security.auth,\
+ javax.security.auth.callback,\
+ javax.security.auth.kerberos,\
+ javax.security.auth.login,\
+ javax.security.auth.spi,\
+ javax.security.auth.x500,\
+ javax.security.cert,\
+ javax.security.sasl,\
+ javax.sound.midi,\
+ javax.sound.midi.spi,\
+ javax.sound.sampled,\
+ javax.sound.sampled.spi,\
+ javax.sql,\
+ javax.sql.rowset,\
+ javax.sql.rowset.serial,\
+ javax.sql.rowset.spi,\
+ javax.swing,\
+ javax.swing.border,\
+ javax.swing.colorchooser,\
+ javax.swing.event,\
+ javax.swing.filechooser,\
+ javax.swing.plaf,\
+ javax.swing.plaf.basic,\
+ javax.swing.plaf.metal,\
+ javax.swing.plaf.multi,\
+ javax.swing.plaf.nimbus,\
+ javax.swing.plaf.synth,\
+ javax.swing.table,\
+ javax.swing.text,\
+ javax.swing.text.html,\
+ javax.swing.text.html.parser,\
+ javax.swing.text.rtf,\
+ javax.swing.tree,\
+ javax.swing.undo,\
+ javax.tools,\
+ javax.transaction,\
+ javax.transaction.xa,\
+ javax.xml,\
+ javax.xml.bind,\
+ javax.xml.bind.annotation,\
+ javax.xml.bind.annotation.adapters,\
+ javax.xml.bind.attachment,\
+ javax.xml.bind.helpers,\
+ javax.xml.bind.util,\
+ javax.xml.crypto,\
+ javax.xml.crypto.dom,\
+ javax.xml.crypto.dsig,\
+ javax.xml.crypto.dsig.dom,\
+ javax.xml.crypto.dsig.keyinfo,\
+ javax.xml.crypto.dsig.spec,\
+ javax.xml.datatype,\
+ javax.xml.namespace,\
+ javax.xml.parsers,\
+ javax.xml.soap,\
+ javax.xml.stream,\
+ javax.xml.stream.events,\
+ javax.xml.stream.util,\
+ javax.xml.transform,\
+ javax.xml.transform.dom,\
+ javax.xml.transform.sax,\
+ javax.xml.transform.stax,\
+ javax.xml.transform.stream,\
+ javax.xml.validation,\
+ javax.xml.ws,\
+ javax.xml.ws.handler,\
+ javax.xml.ws.handler.soap,\
+ javax.xml.ws.http,\
+ javax.xml.ws.soap,\
+ javax.xml.ws.spi,\
+ javax.xml.ws.wsaddressing,\
+ javax.xml.xpath,\
+ org.ietf.jgss,\
+ org.omg.CORBA,\
+ org.omg.CORBA_2_3,\
+ org.omg.CORBA_2_3.portable,\
+ org.omg.CORBA.DynAnyPackage,\
+ org.omg.CORBA.ORBPackage,\
+ org.omg.CORBA.portable,\
+ org.omg.CORBA.TypeCodePackage,\
+ org.omg.CosNaming,\
+ org.omg.CosNaming.NamingContextExtPackage,\
+ org.omg.CosNaming.NamingContextPackage,\
+ org.omg.Dynamic,\
+ org.omg.DynamicAny,\
+ org.omg.DynamicAny.DynAnyFactoryPackage,\
+ org.omg.DynamicAny.DynAnyPackage,\
+ org.omg.IOP,\
+ org.omg.IOP.CodecFactoryPackage,\
+ org.omg.IOP.CodecPackage,\
+ org.omg.Messaging,\
+ org.omg.PortableInterceptor,\
+ org.omg.PortableInterceptor.ORBInitInfoPackage,\
+ org.omg.PortableServer,\
+ org.omg.PortableServer.CurrentPackage,\
+ org.omg.PortableServer.POAManagerPackage,\
+ org.omg.PortableServer.POAPackage,\
+ org.omg.PortableServer.portable,\
+ org.omg.PortableServer.ServantLocatorPackage,\
+ org.omg.SendingContext,\
+ org.omg.stub.java.rmi,\
+ org.w3c.dom,\
+ org.w3c.dom.bootstrap,\
+ org.w3c.dom.css,\
+ org.w3c.dom.events,\
+ org.w3c.dom.html,\
+ org.w3c.dom.ls,\
+ org.w3c.dom.ranges,\
+ org.w3c.dom.stylesheets,\
+ org.w3c.dom.traversal,\
+ org.w3c.dom.views,\
+ org.w3c.dom.xpath,\
+ org.xml.sax,\
+ org.xml.sax.ext,\
+ org.xml.sax.helpers
+org.osgi.framework.bootdelegation = \
+ javax.*,\
+ org.ietf.jgss,\
+ org.omg.*,\
+ org.w3c.*,\
+ org.xml.*,\
+ sun.*,\
+ com.sun.*
+org.osgi.framework.executionenvironment = \
+ OSGi/Minimum-1.0,\
+ OSGi/Minimum-1.1,\
+ OSGi/Minimum-1.2,\
+ JRE-1.1,\
+ J2SE-1.2,\
+ J2SE-1.3,\
+ J2SE-1.4,\
+ J2SE-1.5,\
+ JavaSE-1.6,\
+ JavaSE-1.7
+osgi.java.profile.name = JavaSE-1.7
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/MavenWrapper.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/MavenWrapper.java
new file mode 100644 (file)
index 0000000..6ab2309
--- /dev/null
@@ -0,0 +1,123 @@
+package org.argeo.slc.repo.osgi;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.OsgiFactory;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+/**
+ * BND wrapper based on a Maven artifact available from one of the configured
+ * repositories.
+ */
+public class MavenWrapper extends BndWrapper implements Runnable {
+       private final static Log log = LogFactory.getLog(MavenWrapper.class);
+
+       private String sourceCoords;
+
+       private OsgiFactory osgiFactory;
+
+       private Boolean doNotModifySources = false;
+
+       public MavenWrapper() {
+               setFactory(this);
+       }
+
+       @Override
+       public String getVersion() {
+               String version = super.getVersion();
+               if (version != null)
+                       return version;
+               return new DefaultArtifact(sourceCoords).getVersion();
+       }
+
+       public void run() {
+               Session distSession = null;
+               Session javaSession = null;
+               InputStream in = null;
+               ByteArrayOutputStream out = null;
+               try {
+                       distSession = osgiFactory.openDistSession();
+                       javaSession = osgiFactory.openJavaSession();
+                       Node origArtifact;
+                       try {
+                               origArtifact = osgiFactory.getMaven(distSession, sourceCoords);
+                       } catch (Exception e1) {
+                               origArtifact = osgiFactory.getMaven(distSession, sourceCoords + ":" + getVersion());
+                       }
+
+                       in = origArtifact.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream();
+                       out = new ByteArrayOutputStream();
+                       wrapJar(in, out);
+                       Node newJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), getArtifact(),
+                                       out.toByteArray());
+                       osgiFactory.indexNode(newJarNode);
+                       newJarNode.getSession().save();
+
+                       if (log.isDebugEnabled())
+                               log.debug("Wrapped Maven " + sourceCoords + " to " + newJarNode.getPath());
+
+                       // sources
+                       Artifact sourcesArtifact = new SubArtifact(new DefaultArtifact(sourceCoords), "sources", null);
+                       Node sourcesArtifactNode;
+                       try {
+
+                               sourcesArtifactNode = osgiFactory.getMaven(distSession, sourcesArtifact.toString());
+                       } catch (SlcException e) {
+                               // no sources available
+                               return;
+                       }
+
+                       IOUtils.closeQuietly(in);
+                       in = sourcesArtifactNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream();
+                       byte[] pdeSource;
+                       if (doNotModifySources)
+                               pdeSource = IOUtils.toByteArray(in);
+                       else
+                               pdeSource = RepoUtils.packageAsPdeSource(in, new DefaultNameVersion(getName(), getVersion()));
+                       Node pdeSourceNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(),
+                                       new DefaultArtifact(getCategory(), getName() + ".source", "jar", getVersion()), pdeSource);
+                       osgiFactory.indexNode(pdeSourceNode);
+                       pdeSourceNode.getSession().save();
+
+                       if (log.isDebugEnabled())
+                               log.debug("Wrapped Maven " + sourcesArtifact + " to PDE sources " + pdeSourceNode.getPath());
+               } catch (Exception e) {
+                       throw new SlcException("Cannot wrap Maven " + sourceCoords, e);
+               } finally {
+                       JcrUtils.logoutQuietly(distSession);
+                       JcrUtils.logoutQuietly(javaSession);
+                       IOUtils.closeQuietly(in);
+                       IOUtils.closeQuietly(out);
+               }
+       }
+
+       public void setSourceCoords(String sourceCoords) {
+               this.sourceCoords = sourceCoords;
+       }
+
+       public String getSourceCoords() {
+               return sourceCoords;
+       }
+
+       public void setOsgiFactory(OsgiFactory osgiFactory) {
+               this.osgiFactory = osgiFactory;
+       }
+
+       public void setDoNotModifySources(Boolean doNotModifySources) {
+               this.doNotModifySources = doNotModifySources;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/NormalizeGroup.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/NormalizeGroup.java
new file mode 100644 (file)
index 0000000..7a25c4b
--- /dev/null
@@ -0,0 +1,492 @@
+package org.argeo.slc.repo.osgi;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.ArtifactIndexer;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.slc.repo.maven.ArtifactIdComparator;
+import org.argeo.slc.repo.maven.MavenConventionsUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+
+/**
+ * Make sure that all JCR metadata and Maven metadata are consistent for this
+ * group of OSGi bundles.
+ * 
+ * The job is now done via the various {@code NodeIndexer} of the
+ * WorkspaceManager. TODO import dependencies in the workspace.
+ */
+@Deprecated
+public class NormalizeGroup implements Runnable, SlcNames {
+       private final static Log log = LogFactory.getLog(NormalizeGroup.class);
+
+       private Repository repository;
+       private String workspace;
+       private String groupId;
+       private Boolean overridePoms = false;
+       private String artifactBasePath = "/";
+       private String version = null;
+       private String parentPomCoordinates;
+
+       private List<String> excludedSuffixes = new ArrayList<String>();
+
+       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
+       // private JarFileIndexer jarFileIndexer = new JarFileIndexer();
+
+       /** TODO make it more generic */
+       private List<String> systemPackages = OsgiProfile.PROFILE_JAVA_SE_1_6
+                       .getSystemPackages();
+
+       // indexes
+       private Map<String, String> packagesToSymbolicNames = new HashMap<String, String>();
+       private Map<String, Node> symbolicNamesToNodes = new HashMap<String, Node>();
+
+       private Set<Artifact> binaries = new TreeSet<Artifact>(
+                       new ArtifactIdComparator());
+       private Set<Artifact> sources = new TreeSet<Artifact>(
+                       new ArtifactIdComparator());
+
+       public void run() {
+               Session session = null;
+               try {
+                       session = repository.login(workspace);
+                       Node groupNode = session.getNode(MavenConventionsUtils.groupPath(
+                                       artifactBasePath, groupId));
+                       processGroupNode(groupNode, null);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot normalize group " + groupId + " in "
+                                       + workspace, e);
+               } finally {
+                       JcrUtils.logoutQuietly(session);
+               }
+       }
+
+       public static void processGroupNode(Node groupNode, String version,
+                       Boolean overridePoms, JcrMonitor monitor)
+                       throws RepositoryException {
+               // TODO set artifactsBase based on group node
+               NormalizeGroup ng = new NormalizeGroup();
+               String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
+                               .getString();
+               ng.setGroupId(groupId);
+               ng.setVersion(version);
+               ng.setOverridePoms(overridePoms);
+               ng.processGroupNode(groupNode, monitor);
+       }
+
+       protected void processGroupNode(Node groupNode, JcrMonitor monitor)
+                       throws RepositoryException {
+               if (monitor != null)
+                       monitor.subTask("Group " + groupId);
+               Node allArtifactsHighestVersion = null;
+               Session session = groupNode.getSession();
+               aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases
+                               .hasNext();) {
+                       Node aBase = aBases.nextNode();
+                       if (aBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
+                               Node highestAVersion = null;
+                               for (NodeIterator aVersions = aBase.getNodes(); aVersions
+                                               .hasNext();) {
+                                       Node aVersion = aVersions.nextNode();
+                                       if (aVersion.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+                                               if (highestAVersion == null) {
+                                                       highestAVersion = aVersion;
+                                                       if (allArtifactsHighestVersion == null)
+                                                               allArtifactsHighestVersion = aVersion;
+
+                                                       // BS will fail if artifacts arrive in this order
+                                                       // Name1 - V1, name2 - V3, V1 will remain the
+                                                       // allArtifactsHighestVersion
+                                                       // Fixed below
+                                                       else {
+                                                               Version currVersion = extractOsgiVersion(aVersion);
+                                                               Version highestVersion = extractOsgiVersion(allArtifactsHighestVersion);
+                                                               if (currVersion.compareTo(highestVersion) > 0)
+                                                                       allArtifactsHighestVersion = aVersion;
+                                                       }
+
+                                               } else {
+                                                       Version currVersion = extractOsgiVersion(aVersion);
+                                                       Version currentHighestVersion = extractOsgiVersion(highestAVersion);
+                                                       if (currVersion.compareTo(currentHighestVersion) > 0) {
+                                                               highestAVersion = aVersion;
+                                                       }
+                                                       if (currVersion
+                                                                       .compareTo(extractOsgiVersion(allArtifactsHighestVersion)) > 0) {
+                                                               allArtifactsHighestVersion = aVersion;
+                                                       }
+                                               }
+
+                                       }
+
+                               }
+                               if (highestAVersion == null)
+                                       continue aBases;
+                               for (NodeIterator files = highestAVersion.getNodes(); files
+                                               .hasNext();) {
+                                       Node file = files.nextNode();
+                                       if (file.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
+                                               preProcessBundleArtifact(file);
+                                               file.getSession().save();
+                                               if (log.isDebugEnabled())
+                                                       log.debug("Pre-processed " + file.getName());
+                                       }
+
+                               }
+                       }
+               }
+
+               // if version not set or empty, use the highest version
+               // useful when indexing a product maven repository where
+               // all artifacts have the same version for a given release
+               // => the version can then be left empty
+               if (version == null || version.trim().equals(""))
+                       if (allArtifactsHighestVersion != null)
+                               version = allArtifactsHighestVersion.getProperty(
+                                               SLC_ARTIFACT_VERSION).getString();
+                       else
+                               version = "0.0";
+               // throw new SlcException("Group version " + version
+               // + " is empty.");
+
+               int bundleCount = symbolicNamesToNodes.size();
+               if (log.isDebugEnabled())
+                       log.debug("Indexed " + bundleCount + " bundles");
+
+               int count = 1;
+               for (Node bundleNode : symbolicNamesToNodes.values()) {
+                       processBundleArtifact(bundleNode);
+                       bundleNode.getSession().save();
+                       if (log.isDebugEnabled())
+                               log.debug(count + "/" + bundleCount + " Processed "
+                                               + bundleNode.getName());
+                       count++;
+               }
+
+               // indexes
+               Set<Artifact> indexes = new TreeSet<Artifact>(
+                               new ArtifactIdComparator());
+               Artifact indexArtifact = writeIndex(session,
+                               RepoConstants.BINARIES_ARTIFACT_ID, binaries);
+               indexes.add(indexArtifact);
+               indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID,
+                               sources);
+               indexes.add(indexArtifact);
+               // sdk
+               writeIndex(session, RepoConstants.SDK_ARTIFACT_ID, indexes);
+               if (monitor != null)
+                       monitor.worked(1);
+       }
+
+       private Version extractOsgiVersion(Node artifactVersion)
+                       throws RepositoryException {
+               String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION)
+                               .getString();
+               String cleanVersion = rawVersion.replace("-SNAPSHOT", ".SNAPSHOT");
+               Version osgiVersion = null;
+               // log invalid version value to enable tracking them
+               try {
+                       osgiVersion = new Version(cleanVersion);
+               } catch (IllegalArgumentException e) {
+                       log.error("Version string " + cleanVersion + " is invalid ");
+                       String twickedVersion = twickInvalidVersion(cleanVersion);
+                       osgiVersion = new Version(twickedVersion);
+                       log.error("Using " + twickedVersion + " instead");
+                       // throw e;
+               }
+               return osgiVersion;
+       }
+
+       private String twickInvalidVersion(String tmpVersion) {
+               String[] tokens = tmpVersion.split("\\.");
+               if (tokens.length == 3 && tokens[2].lastIndexOf("-") > 0) {
+                       String newSuffix = tokens[2].replaceFirst("-", ".");
+                       tmpVersion = tmpVersion.replaceFirst(tokens[2], newSuffix);
+               } else if (tokens.length > 4) {
+                       // FIXME manually remove other "."
+                       StringTokenizer st = new StringTokenizer(tmpVersion, ".", true);
+                       StringBuilder builder = new StringBuilder();
+                       // Major
+                       builder.append(st.nextToken()).append(st.nextToken());
+                       // Minor
+                       builder.append(st.nextToken()).append(st.nextToken());
+                       // Micro
+                       builder.append(st.nextToken()).append(st.nextToken());
+                       // Qualifier
+                       builder.append(st.nextToken());
+                       while (st.hasMoreTokens()) {
+                               // consume delimiter
+                               st.nextToken();
+                               if (st.hasMoreTokens())
+                                       builder.append("-").append(st.nextToken());
+                       }
+                       tmpVersion = builder.toString();
+               }
+               return tmpVersion;
+       }
+
+       private Artifact writeIndex(Session session, String artifactId,
+                       Set<Artifact> artifacts) throws RepositoryException {
+               Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
+                               version);
+               Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(
+                               parentPomCoordinates) : null;
+               String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
+                               artifacts, parentArtifact);
+               Node node = RepoUtils.copyBytesAsArtifact(
+                               session.getNode(artifactBasePath), artifact, pom.getBytes());
+               artifactIndexer.index(node);
+
+               // TODO factorize
+               String pomSha = JcrUtils.checksumFile(node, "SHA-1");
+               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
+                               pomSha.getBytes());
+               String pomMd5 = JcrUtils.checksumFile(node, "MD5");
+               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
+                               pomMd5.getBytes());
+               session.save();
+               return artifact;
+       }
+
+       protected void preProcessBundleArtifact(Node bundleNode)
+                       throws RepositoryException {
+
+               String symbolicName = JcrUtils.get(bundleNode, SLC_SYMBOLIC_NAME);
+               if (symbolicName.endsWith(".source")) {
+                       // TODO make a shared node with classifier 'sources'?
+                       String bundleName = RepoUtils
+                                       .extractBundleNameFromSourceName(symbolicName);
+                       for (String excludedSuffix : excludedSuffixes) {
+                               if (bundleName.endsWith(excludedSuffix))
+                                       return;// skip adding to sources
+                       }
+                       sources.add(RepoUtils.asArtifact(bundleNode));
+                       return;
+               }
+
+               NodeIterator exportPackages = bundleNode.getNodes(SLC_
+                               + Constants.EXPORT_PACKAGE);
+               while (exportPackages.hasNext()) {
+                       Node exportPackage = exportPackages.nextNode();
+                       String pkg = JcrUtils.get(exportPackage, SLC_NAME);
+                       packagesToSymbolicNames.put(pkg, symbolicName);
+               }
+
+               symbolicNamesToNodes.put(symbolicName, bundleNode);
+               for (String excludedSuffix : excludedSuffixes) {
+                       if (symbolicName.endsWith(excludedSuffix))
+                               return;// skip adding to binaries
+               }
+               binaries.add(RepoUtils.asArtifact(bundleNode));
+
+               if (bundleNode.getSession().hasPendingChanges())
+                       bundleNode.getSession().save();
+       }
+
+       protected void processBundleArtifact(Node bundleNode)
+                       throws RepositoryException {
+               Node artifactFolder = bundleNode.getParent();
+               String baseName = FilenameUtils.getBaseName(bundleNode.getName());
+
+               // pom
+               String pomName = baseName + ".pom";
+               if (artifactFolder.hasNode(pomName) && !overridePoms)
+                       return;// skip
+
+               String pom = generatePomForBundle(bundleNode);
+               Node pomNode = JcrUtils.copyBytesAsFile(artifactFolder, pomName,
+                               pom.getBytes());
+               // checksum
+               String bundleSha = JcrUtils.checksumFile(bundleNode, "SHA-1");
+               JcrUtils.copyBytesAsFile(artifactFolder,
+                               bundleNode.getName() + ".sha1", bundleSha.getBytes());
+               String pomSha = JcrUtils.checksumFile(pomNode, "SHA-1");
+               JcrUtils.copyBytesAsFile(artifactFolder, pomNode.getName() + ".sha1",
+                               pomSha.getBytes());
+       }
+
+       private String generatePomForBundle(Node n) throws RepositoryException {
+               String ownSymbolicName = JcrUtils.get(n, SLC_SYMBOLIC_NAME);
+
+               StringBuffer p = new StringBuffer();
+
+               // XML header
+               p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+               p.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
+               p.append("<modelVersion>4.0.0</modelVersion>");
+
+               // Artifact
+               p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
+                               .append("</groupId>\n");
+               p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
+                               .append("</artifactId>\n");
+               p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
+                               .append("</version>\n");
+               p.append("<packaging>pom</packaging>\n");
+               if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
+                       p.append("<name>")
+                                       .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
+                                       .append("</name>\n");
+               if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
+                       p.append("<description>")
+                                       .append(JcrUtils
+                                                       .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
+                                       .append("</description>\n");
+
+               // Dependencies
+               Set<String> dependenciesSymbolicNames = new TreeSet<String>();
+               Set<String> optionalSymbolicNames = new TreeSet<String>();
+               NodeIterator importPackages = n.getNodes(SLC_
+                               + Constants.IMPORT_PACKAGE);
+               while (importPackages.hasNext()) {
+                       Node importPackage = importPackages.nextNode();
+                       String pkg = JcrUtils.get(importPackage, SLC_NAME);
+                       if (packagesToSymbolicNames.containsKey(pkg)) {
+                               String dependencySymbolicName = packagesToSymbolicNames
+                                               .get(pkg);
+                               if (JcrUtils.check(importPackage, SLC_OPTIONAL))
+                                       optionalSymbolicNames.add(dependencySymbolicName);
+                               else
+                                       dependenciesSymbolicNames.add(dependencySymbolicName);
+                       } else {
+                               if (!JcrUtils.check(importPackage, SLC_OPTIONAL)
+                                               && !systemPackages.contains(pkg))
+                                       log.warn("No bundle found for pkg " + pkg);
+                       }
+               }
+
+               if (n.hasNode(SLC_ + Constants.FRAGMENT_HOST)) {
+                       String fragmentHost = JcrUtils.get(
+                                       n.getNode(SLC_ + Constants.FRAGMENT_HOST),
+                                       SLC_SYMBOLIC_NAME);
+                       dependenciesSymbolicNames.add(fragmentHost);
+               }
+
+               // TODO require bundles
+
+               List<Node> dependencyNodes = new ArrayList<Node>();
+               for (String depSymbName : dependenciesSymbolicNames) {
+                       if (depSymbName.equals(ownSymbolicName))
+                               continue;// skip self
+
+                       if (symbolicNamesToNodes.containsKey(depSymbName))
+                               dependencyNodes.add(symbolicNamesToNodes.get(depSymbName));
+                       else
+                               log.warn("Could not find node for " + depSymbName);
+               }
+               List<Node> optionalDependencyNodes = new ArrayList<Node>();
+               for (String depSymbName : optionalSymbolicNames) {
+                       if (symbolicNamesToNodes.containsKey(depSymbName))
+                               optionalDependencyNodes.add(symbolicNamesToNodes
+                                               .get(depSymbName));
+                       else
+                               log.warn("Could not find node for " + depSymbName);
+               }
+
+               p.append("<dependencies>\n");
+               for (Node dependencyNode : dependencyNodes) {
+                       p.append("<dependency>\n");
+                       p.append("\t<groupId>")
+                                       .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
+                                       .append("</groupId>\n");
+                       p.append("\t<artifactId>")
+                                       .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
+                                       .append("</artifactId>\n");
+                       p.append("</dependency>\n");
+               }
+
+               if (optionalDependencyNodes.size() > 0)
+                       p.append("<!-- OPTIONAL -->\n");
+               for (Node dependencyNode : optionalDependencyNodes) {
+                       p.append("<dependency>\n");
+                       p.append("\t<groupId>")
+                                       .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
+                                       .append("</groupId>\n");
+                       p.append("\t<artifactId>")
+                                       .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
+                                       .append("</artifactId>\n");
+                       p.append("\t<optional>true</optional>\n");
+                       p.append("</dependency>\n");
+               }
+               p.append("</dependencies>\n");
+
+               // Dependency management
+               p.append("<dependencyManagement>\n");
+               p.append("<dependencies>\n");
+               p.append("<dependency>\n");
+               p.append("\t<groupId>").append(groupId).append("</groupId>\n");
+               p.append("\t<artifactId>")
+                               .append(ownSymbolicName.endsWith(".source") ? RepoConstants.SOURCES_ARTIFACT_ID
+                                               : RepoConstants.BINARIES_ARTIFACT_ID)
+                               .append("</artifactId>\n");
+               p.append("\t<version>").append(version).append("</version>\n");
+               p.append("\t<type>pom</type>\n");
+               p.append("\t<scope>import</scope>\n");
+               p.append("</dependency>\n");
+               p.append("</dependencies>\n");
+               p.append("</dependencyManagement>\n");
+
+               p.append("</project>\n");
+               return p.toString();
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+
+       public void setWorkspace(String workspace) {
+               this.workspace = workspace;
+       }
+
+       public void setGroupId(String groupId) {
+               this.groupId = groupId;
+       }
+
+       public void setParentPomCoordinates(String parentPomCoordinates) {
+               this.parentPomCoordinates = parentPomCoordinates;
+       }
+
+       public void setArtifactBasePath(String artifactBasePath) {
+               this.artifactBasePath = artifactBasePath;
+       }
+
+       public void setVersion(String version) {
+               this.version = version;
+       }
+
+       public void setExcludedSuffixes(List<String> excludedSuffixes) {
+               this.excludedSuffixes = excludedSuffixes;
+       }
+
+       public void setOverridePoms(Boolean overridePoms) {
+               this.overridePoms = overridePoms;
+       }
+
+       public void setArtifactIndexer(ArtifactIndexer artifactIndexer) {
+               this.artifactIndexer = artifactIndexer;
+       }
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ObrWrapper.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ObrWrapper.java
new file mode 100644 (file)
index 0000000..4ace647
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.repo.osgi;
+
+public class ObrWrapper {
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java
new file mode 100644 (file)
index 0000000..e372afd
--- /dev/null
@@ -0,0 +1,239 @@
+package org.argeo.slc.repo.osgi;
+
+import java.io.BufferedInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.security.Privilege;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.NodeIndexer;
+import org.argeo.slc.repo.OsgiFactory;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.repo.maven.MavenConventionsUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+/** Default implementation of {@link OsgiFactory}. */
+public class OsgiFactoryImpl implements OsgiFactory, SlcNames {
+       private final static Log log = LogFactory.getLog(OsgiFactoryImpl.class);
+
+       private String workspace;
+       private Repository distRepository;
+       private Repository javaRepository;
+
+       private List<NodeIndexer> nodeIndexers = new ArrayList<NodeIndexer>();
+
+       /** key is URI prefix, value list of base URLs */
+       private Map<String, List<String>> mirrors = new HashMap<String, List<String>>();
+
+       private List<String> mavenRepositories = new ArrayList<String>();
+       private String downloadBase = RepoConstants.DIST_DOWNLOAD_BASEPATH;
+       private String mavenProxyBase = downloadBase + "/maven";
+
+       public void init() {
+               if (workspace == null)
+                       throw new SlcException("A workspace must be specified");
+
+               // default Maven repo
+               if (mavenRepositories.size() == 0) {
+                       // mavenRepositories
+                       // .add("http://search.maven.org/remotecontent?filepath=");
+                       mavenRepositories.add("http://repo1.maven.org/maven2");
+               }
+
+               Session javaSession = null;
+               Session distSession = null;
+               try {
+                       // TODO rather user a JavaRepoManager that will also implicitely
+                       // manage the indexing of newly created nodes.
+                       javaSession = JcrUtils.loginOrCreateWorkspace(javaRepository, workspace);
+                       distSession = JcrUtils.loginOrCreateWorkspace(distRepository, workspace);
+
+                       // Privileges
+                       JcrUtils.addPrivilege(javaSession, "/", SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
+                       JcrUtils.addPrivilege(distSession, "/", SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot initialize OSGi Factory " + workspace, e);
+               } finally {
+                       JcrUtils.logoutQuietly(javaSession);
+                       JcrUtils.logoutQuietly(distSession);
+               }
+       }
+
+       public void destroy() {
+
+       }
+
+       public Session openJavaSession() throws RepositoryException {
+               return javaRepository.login(workspace);
+       }
+
+       public Session openDistSession() throws RepositoryException {
+               return distRepository.login(workspace);
+       }
+
+       public void indexNode(Node node) {
+               for (NodeIndexer nodeIndexer : nodeIndexers) {
+                       nodeIndexer.index(node);
+               }
+       }
+
+       public Node getMaven(Session distSession, String coords) throws RepositoryException {
+               Artifact artifact = new DefaultArtifact(coords);
+               String path = MavenConventionsUtils.artifactPath(mavenProxyBase, artifact);
+
+               // exists
+               if (distSession.itemExists(path))
+                       return distSession.getNode(path);
+
+               for (String mavenRepo : mavenRepositories) {
+                       String url = MavenConventionsUtils.artifactUrl(mavenRepo, artifact);
+                       try {
+                               Node node = loadUrlToPath(url, distSession, path);
+                               if (node != null) {
+                                       // checksums
+                                       try {
+                                               loadUrlToPath(url + ".md5", distSession, path + ".md5");
+                                       } catch (FileNotFoundException e) {
+                                               // silent
+                                       }
+                                       try {
+                                               loadUrlToPath(url + ".sha1", distSession, path + ".sha1");
+                                       } catch (FileNotFoundException e) {
+                                               // silent
+                                       }
+                                       return node;
+                               }
+                       } catch (FileNotFoundException e) {
+                               if (log.isDebugEnabled())
+                                       log.debug("Maven " + coords + " could not be downloaded from " + url);
+                       }
+               }
+               throw new SlcException("Could not download Maven " + coords);
+       }
+
+       public Node getDist(Session distSession, String uri) throws RepositoryException {
+               String distPath = downloadBase + '/' + JcrUtils.urlAsPath(uri);
+
+               // already retrieved
+               if (distSession.itemExists(distPath))
+                       return distSession.getNode(distPath);
+
+               // find mirror
+               List<String> urlBases = null;
+               String uriPrefix = null;
+               uriPrefixes: for (String uriPref : mirrors.keySet()) {
+                       if (uri.startsWith(uriPref)) {
+                               if (mirrors.get(uriPref).size() > 0) {
+                                       urlBases = mirrors.get(uriPref);
+                                       uriPrefix = uriPref;
+                                       break uriPrefixes;
+                               }
+                       }
+               }
+               if (urlBases == null)
+                       try {
+                               return loadUrlToPath(uri, distSession, distPath);
+                       } catch (FileNotFoundException e) {
+                               throw new SlcException("Cannot download " + uri, e);
+                       }
+
+               // try to download
+               for (String urlBase : urlBases) {
+                       String relativePath = uri.substring(uriPrefix.length());
+                       String url = urlBase + relativePath;
+                       try {
+                               return loadUrlToPath(url, distSession, distPath);
+                       } catch (FileNotFoundException e) {
+                               if (log.isDebugEnabled())
+                                       log.debug("Cannot download " + url + ", trying another mirror");
+                       }
+               }
+
+               throw new SlcException("Could not download " + uri);
+       }
+
+       /** Actually downloads a file to an internal location */
+       protected Node loadUrlToPath(String url, Session distSession, String path)
+                       throws RepositoryException, FileNotFoundException {
+               if (log.isDebugEnabled())
+                       log.debug("Downloading " + url + "...");
+
+               InputStream in = null;
+               URLConnection conn = null;
+               Node folderNode = JcrUtils.mkfolders(distSession, JcrUtils.parentPath(path));
+               try {
+                       URL u = new URL(url);
+                       conn = u.openConnection();
+                       conn.connect();
+                       in = new BufferedInputStream(conn.getInputStream());
+                       // byte[] arr = IOUtils.toByteArray(in);
+                       // Node fileNode = JcrUtils.copyBytesAsFile(folderNode,
+                       // JcrUtils.nodeNameFromPath(path), arr);
+                       Node fileNode = JcrUtils.copyStreamAsFile(folderNode, JcrUtils.nodeNameFromPath(path), in);
+                       fileNode.addMixin(SlcTypes.SLC_KNOWN_ORIGIN);
+                       Node origin = fileNode.addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
+                       JcrUtils.urlToAddressProperties(origin, url);
+                       distSession.save();
+                       return fileNode;
+               } catch (MalformedURLException e) {
+                       throw new SlcException("URL " + url + " not valid.", e);
+               } catch (FileNotFoundException e) {
+                       throw e;
+               } catch (IOException e) {
+                       throw new SlcException("Cannot load " + url + " to " + path, e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+               }
+
+       }
+
+       public void setWorkspace(String workspace) {
+               this.workspace = workspace;
+       }
+
+       public void setDistRepository(Repository distRepository) {
+               this.distRepository = distRepository;
+       }
+
+       public void setJavaRepository(Repository javaRepository) {
+               this.javaRepository = javaRepository;
+       }
+
+       public void setNodeIndexers(List<NodeIndexer> nodeIndexers) {
+               this.nodeIndexers = nodeIndexers;
+       }
+
+       public void setMirrors(Map<String, List<String>> mirrors) {
+               this.mirrors = mirrors;
+       }
+
+       public void setMavenRepositories(List<String> mavenRepositories) {
+               this.mavenRepositories = mavenRepositories;
+       }
+
+       public void setMavenProxyBase(String mavenProxyBase) {
+               this.mavenProxyBase = mavenProxyBase;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiProfile.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiProfile.java
new file mode 100644 (file)
index 0000000..b15ed5d
--- /dev/null
@@ -0,0 +1,55 @@
+package org.argeo.slc.repo.osgi;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.slc.SlcException;
+
+/**
+ * Wraps an OSGi profile, simplifying access to its values such as system
+ * packages, etc.
+ */
+public class OsgiProfile {
+       public final static String PROP_SYSTEM_PACKAGES = "org.osgi.framework.system.packages";
+
+       public final static OsgiProfile PROFILE_JAVA_SE_1_6 = new OsgiProfile(
+                       "JavaSE-1.6.profile");
+
+       private final URL url;
+       private final Properties properties;
+
+       public OsgiProfile(URL url) {
+               this.url = url;
+               properties = new Properties();
+               InputStream in = null;
+               try {
+                       properties.load(this.url.openStream());
+               } catch (Exception e) {
+                       throw new SlcException("Cannot initalize OSGi profile " + url, e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+               }
+       }
+
+       public OsgiProfile(String name) {
+               this(OsgiProfile.class.getClassLoader().getResource(
+                               '/'
+                                               + OsgiProfile.class.getPackage().getName()
+                                                               .replace('.', '/') + '/' + name));
+       }
+
+       public List<String> getSystemPackages() {
+               String[] splitted = properties.getProperty(PROP_SYSTEM_PACKAGES).split(
+                               ",");
+               List<String> res = new ArrayList<String>();
+               for (String pkg : splitted) {
+                       res.add(pkg.trim());
+               }
+               return Collections.unmodifiableList(res);
+       }
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/ProcessDistribution.java
new file mode 100644 (file)
index 0000000..7d5d779
--- /dev/null
@@ -0,0 +1,95 @@
+package org.argeo.slc.repo.osgi;
+
+import java.util.Iterator;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.ArgeoOsgiDistribution;
+import org.argeo.slc.repo.ModularDistributionFactory;
+import org.argeo.slc.repo.OsgiFactory;
+import org.argeo.slc.repo.maven.MavenConventionsUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+/** Executes the processes required so that all managed bundles are available. */
+public class ProcessDistribution implements Runnable {
+       private final static Log log = LogFactory.getLog(ProcessDistribution.class);
+
+       private ArgeoOsgiDistribution osgiDistribution;
+       private OsgiFactory osgiFactory;
+
+       public void run() {
+               Session javaSession = null;
+               try {
+                       javaSession = osgiFactory.openJavaSession();
+                       for (Iterator<? extends NameVersion> it = osgiDistribution
+                                       .nameVersions(); it.hasNext();)
+                               processNameVersion(javaSession, it.next());
+
+                       // Check sources
+                       for (Iterator<? extends NameVersion> it = osgiDistribution
+                                       .nameVersions(); it.hasNext();) {
+                               CategoryNameVersion nv = (CategoryNameVersion) it.next();
+                               Artifact artifact = new DefaultArtifact(nv.getCategory(),
+                                               nv.getName() + ".source", "jar", nv.getVersion());
+                               String path = MavenConventionsUtils.artifactPath("/", artifact);
+                               if (!javaSession.itemExists(path))
+                                       log.warn("No source available for " + nv);
+                       }
+
+                       // explicitly create the corresponding modular distribution as we
+                       // have here all necessary info.
+                       ModularDistributionFactory mdf = new ModularDistributionFactory(
+                                       osgiFactory, osgiDistribution);
+                       mdf.run();
+
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot process distribution "
+                                       + osgiDistribution, e);
+               } finally {
+                       JcrUtils.logoutQuietly(javaSession);
+               }
+       }
+
+       protected void processNameVersion(Session javaSession,
+                       NameVersion nameVersion) throws RepositoryException {
+               if (log.isTraceEnabled())
+                       log.trace("Check " + nameVersion + "...");
+               if (!(nameVersion instanceof CategoryNameVersion))
+                       throw new SlcException("Unsupported type " + nameVersion.getClass());
+               CategoryNameVersion nv = (CategoryNameVersion) nameVersion;
+               Artifact artifact = new DefaultArtifact(nv.getCategory(), nv.getName(),
+                               "jar", nv.getVersion());
+               String path = MavenConventionsUtils.artifactPath("/", artifact);
+               if (!javaSession.itemExists(path)) {
+                       if (nv instanceof BndWrapper) {
+                               if (log.isDebugEnabled())
+                                       log.debug("Run factory for   : " + nv + "...");
+                               ((BndWrapper) nv).getFactory().run();
+                       } else if (nv instanceof Runnable) {
+                               ((Runnable) nv).run();
+                       } else {
+                               log.warn("Skip unsupported   : " + nv);
+                       }
+               } else {
+                       if (log.isTraceEnabled())
+                               log.trace("Already available : " + nv);
+               }
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setOsgiDistribution(ArgeoOsgiDistribution osgiDistribution) {
+               this.osgiDistribution = osgiDistribution;
+       }
+
+       public void setOsgiFactory(OsgiFactory osgiFactory) {
+               this.osgiFactory = osgiFactory;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SourcesProvider.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SourcesProvider.java
new file mode 100644 (file)
index 0000000..a0a20f6
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.slc.repo.osgi;
+
+import java.util.List;
+import java.util.zip.ZipOutputStream;
+
+/** Provides access to Java sources */
+public interface SourcesProvider {
+       /**
+        * Writes sources into a ZIP (or a JAR), under the same sirectory structure.
+        * 
+        * @param packages
+        *            the packages to import
+        * @param out
+        *            the ZIP or JAR to write to
+        */
+       public void writeSources(List<String> packages, ZipOutputStream zout);
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SubArtifact.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/SubArtifact.java
new file mode 100644 (file)
index 0000000..9ce8455
--- /dev/null
@@ -0,0 +1,214 @@
+package org.argeo.slc.repo.osgi;
+
+import java.io.File;
+import java.util.Map;
+
+import org.eclipse.aether.artifact.AbstractArtifact;
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * An artifact whose identity is derived from another artifact. <em>Note:</em> Instances of this class are immutable and
+ * the exposed mutators return new objects rather than changing the current instance.
+ */
+final class SubArtifact
+    extends AbstractArtifact
+{
+
+    private final Artifact mainArtifact;
+
+    private final String classifier;
+
+    private final String extension;
+
+    private final File file;
+
+    private final Map<String, String> properties;
+
+    /**
+     * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
+     * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
+     * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
+     * used to refer to the GPG signature of an artifact.
+     * 
+     * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
+     * @param classifier The classifier for this artifact, may be {@code null} if none.
+     * @param extension The extension for this artifact, may be {@code null} if none.
+     */
+    public SubArtifact( Artifact mainArtifact, String classifier, String extension )
+    {
+        this( mainArtifact, classifier, extension, (File) null );
+    }
+
+    /**
+     * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
+     * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
+     * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
+     * used to refer to the GPG signature of an artifact.
+     * 
+     * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
+     * @param classifier The classifier for this artifact, may be {@code null} if none.
+     * @param extension The extension for this artifact, may be {@code null} if none.
+     * @param file The file for this artifact, may be {@code null} if unresolved.
+     */
+    public SubArtifact( Artifact mainArtifact, String classifier, String extension, File file )
+    {
+        this( mainArtifact, classifier, extension, null, file );
+    }
+
+    /**
+     * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
+     * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
+     * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
+     * used to refer to the GPG signature of an artifact.
+     * 
+     * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
+     * @param classifier The classifier for this artifact, may be {@code null} if none.
+     * @param extension The extension for this artifact, may be {@code null} if none.
+     * @param properties The properties of the artifact, may be {@code null}.
+     */
+    public SubArtifact( Artifact mainArtifact, String classifier, String extension, Map<String, String> properties )
+    {
+        this( mainArtifact, classifier, extension, properties, null );
+    }
+
+    /**
+     * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
+     * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
+     * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
+     * used to refer to the GPG signature of an artifact.
+     * 
+     * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
+     * @param classifier The classifier for this artifact, may be {@code null} if none.
+     * @param extension The extension for this artifact, may be {@code null} if none.
+     * @param properties The properties of the artifact, may be {@code null}.
+     * @param file The file for this artifact, may be {@code null} if unresolved.
+     */
+    public SubArtifact( Artifact mainArtifact, String classifier, String extension, Map<String, String> properties,
+                        File file )
+    {
+        if ( mainArtifact == null )
+        {
+            throw new IllegalArgumentException( "no artifact specified" );
+        }
+        this.mainArtifact = mainArtifact;
+        this.classifier = classifier;
+        this.extension = extension;
+        this.file = file;
+        this.properties = copyProperties( properties );
+    }
+
+    private SubArtifact( Artifact mainArtifact, String classifier, String extension, File file,
+                         Map<String, String> properties )
+    {
+        // NOTE: This constructor assumes immutability of the provided properties, for internal use only
+        this.mainArtifact = mainArtifact;
+        this.classifier = classifier;
+        this.extension = extension;
+        this.file = file;
+        this.properties = properties;
+    }
+
+    public String getGroupId()
+    {
+        return mainArtifact.getGroupId();
+    }
+
+    public String getArtifactId()
+    {
+        return mainArtifact.getArtifactId();
+    }
+
+    public String getVersion()
+    {
+        return mainArtifact.getVersion();
+    }
+
+    public String getBaseVersion()
+    {
+        return mainArtifact.getBaseVersion();
+    }
+
+    public boolean isSnapshot()
+    {
+        return mainArtifact.isSnapshot();
+    }
+
+    public String getClassifier()
+    {
+        return expand( classifier, mainArtifact.getClassifier() );
+    }
+
+    public String getExtension()
+    {
+        return expand( extension, mainArtifact.getExtension() );
+    }
+
+    public File getFile()
+    {
+        return file;
+    }
+
+    public Artifact setFile( File file )
+    {
+        if ( ( this.file == null ) ? file == null : this.file.equals( file ) )
+        {
+            return this;
+        }
+        return new SubArtifact( mainArtifact, classifier, extension, file, properties );
+    }
+
+    public Map<String, String> getProperties()
+    {
+        return properties;
+    }
+
+    public Artifact setProperties( Map<String, String> properties )
+    {
+        if ( this.properties.equals( properties ) || ( properties == null && this.properties.isEmpty() ) )
+        {
+            return this;
+        }
+        return new SubArtifact( mainArtifact, classifier, extension, properties, file );
+    }
+
+    private static String expand( String pattern, String replacement )
+    {
+        String result = "";
+        if ( pattern != null )
+        {
+            result = pattern.replace( "*", replacement );
+
+            if ( replacement.length() <= 0 )
+            {
+                if ( pattern.startsWith( "*" ) )
+                {
+                    int i = 0;
+                    for ( ; i < result.length(); i++ )
+                    {
+                        char c = result.charAt( i );
+                        if ( c != '-' && c != '.' )
+                        {
+                            break;
+                        }
+                    }
+                    result = result.substring( i );
+                }
+                if ( pattern.endsWith( "*" ) )
+                {
+                    int i = result.length() - 1;
+                    for ( ; i >= 0; i-- )
+                    {
+                        char c = result.charAt( i );
+                        if ( c != '-' && c != '.' )
+                        {
+                            break;
+                        }
+                    }
+                    result = result.substring( 0, i + 1 );
+                }
+            }
+        }
+        return result;
+    }
+
+}
\ No newline at end of file
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/UriWrapper.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/UriWrapper.java
new file mode 100644 (file)
index 0000000..262246f
--- /dev/null
@@ -0,0 +1,142 @@
+package org.argeo.slc.repo.osgi;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.List;
+import java.util.zip.ZipOutputStream;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.OsgiFactory;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+import aQute.bnd.osgi.Jar;
+
+public class UriWrapper extends BndWrapper implements Runnable {
+       private final static Log log = LogFactory.getLog(UriWrapper.class);
+
+       private String uri;
+       private String baseUri;
+       private String versionSeparator = "-";
+       private String extension = "jar";
+
+       private OsgiFactory osgiFactory;
+
+       private SourcesProvider sourcesProvider;
+
+       public UriWrapper() {
+               setFactory(this);
+       }
+
+       public void run() {
+               Session distSession = null;
+               Session javaSession = null;
+               InputStream in = null;
+               ByteArrayOutputStream out = null;
+               Jar jar = null;
+               try {
+                       distSession = osgiFactory.openDistSession();
+                       javaSession = osgiFactory.openJavaSession();
+                       String uri = getEffectiveUri();
+//                     if (uri == null) {
+//                             uri = baseUri + '/' + getName() + versionSeparator + getVersion() + "." + extension;
+//                     }
+                       Node sourceArtifact = osgiFactory.getDist(distSession, uri);
+
+                       // TODO factorize with Maven
+                       in = sourceArtifact.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream();
+                       out = new ByteArrayOutputStream();
+                       wrapJar(in, out);
+                       Node newJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), getArtifact(),
+                                       out.toByteArray());
+                       osgiFactory.indexNode(newJarNode);
+                       newJarNode.getSession().save();
+                       if (log.isDebugEnabled())
+                               log.debug("Wrapped " + uri + " to " + newJarNode.getPath());
+
+                       // sources
+                       if (sourcesProvider != null) {
+                               IOUtils.closeQuietly(in);
+                               in = new ByteArrayInputStream(out.toByteArray());
+                               jar = new Jar(null, in);
+                               List<String> packages = jar.getPackages();
+
+                               IOUtils.closeQuietly(out);
+                               out = new ByteArrayOutputStream();
+                               sourcesProvider.writeSources(packages, new ZipOutputStream(out));
+
+                               IOUtils.closeQuietly(in);
+                               in = new ByteArrayInputStream(out.toByteArray());
+                               byte[] sourcesJar = RepoUtils.packageAsPdeSource(in, new DefaultNameVersion(this));
+                               Artifact sourcesArtifact = new DefaultArtifact(getArtifact().getGroupId(),
+                                               getArtifact().getArtifactId() + ".source", "jar", getArtifact().getVersion());
+                               Node sourcesJarNode = RepoUtils.copyBytesAsArtifact(javaSession.getRootNode(), sourcesArtifact,
+                                               sourcesJar);
+                               sourcesJarNode.getSession().save();
+
+                               if (log.isDebugEnabled())
+                                       log.debug("Added sources " + sourcesArtifact + " for bundle " + getArtifact());
+                       }
+               } catch (Exception e) {
+                       throw new SlcException("Cannot wrap URI " + uri, e);
+               } finally {
+                       IOUtils.closeQuietly(in);
+                       IOUtils.closeQuietly(out);
+                       JcrUtils.logoutQuietly(distSession);
+                       JcrUtils.logoutQuietly(javaSession);
+                       if (jar != null)
+                               jar.close();
+               }
+       }
+
+       public void setUri(String sourceCoords) {
+               this.uri = sourceCoords;
+       }
+
+       public String getEffectiveUri() {
+               if (uri == null) {
+                       return baseUri + '/' + getName() + versionSeparator + getVersion() + "." + extension;
+               } else
+                       return uri;
+       }
+
+       public void setOsgiFactory(OsgiFactory osgiFactory) {
+               this.osgiFactory = osgiFactory;
+       }
+
+       public void setBaseUri(String baseUri) {
+               this.baseUri = baseUri;
+       }
+
+       public void setVersionSeparator(String versionSeparator) {
+               this.versionSeparator = versionSeparator;
+       }
+
+       public void setSourcesProvider(SourcesProvider sourcesProvider) {
+               this.sourcesProvider = sourcesProvider;
+       }
+
+       public String getUri() {
+               return uri;
+       }
+
+       public String getBaseUri() {
+               return baseUri;
+       }
+
+       public String getVersionSeparator() {
+               return versionSeparator;
+       }
+
+}
diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/repo.cnd b/org.argeo.slc.repo/src/org/argeo/slc/repo/repo.cnd
new file mode 100644 (file)
index 0000000..dacffbb
--- /dev/null
@@ -0,0 +1,164 @@
+<repo = 'http://www.argeo.org/ns/repo'>
+
+// Argeo Commons 1 node types
+[argeo:references] > nt:unstructured
+- * (REFERENCE) *
+
+// AETHER
+[slc:artifact] > mix:referenceable, mix:created, mix:lastModified
+mixin
+- slc:artifactId (STRING) m
+- slc:groupId (STRING) m
+- slc:artifactVersion (STRING) m
+- slc:artifactExtension (STRING) m
+- slc:artifactClassifier (STRING) ='' m a
+
+[slc:artifactVersion] > mix:referenceable, mix:created, mix:lastModified, mix:title
+mixin
+- slc:artifactId (STRING) m
+- slc:groupId (STRING) m
+- slc:artifactVersion (STRING) m
+
+[slc:artifactBase] > mix:referenceable, mix:created, mix:lastModified
+mixin
+- slc:artifactId (STRING) m
+- slc:groupId (STRING) m
+
+[slc:groupBase] > mix:referenceable, mix:created, mix:lastModified
+mixin
+// it is possible to have groupBase being artifact base (e.g. org.argeo.commons.basic)
+// so using groupId would conflict 
+- slc:groupBaseId (STRING) m
+
+// Mark a given group base as relevant to create modular distribution in the current workspace  
+// [slc:category]
+// mixin
+
+[slc:distribution] > slc:artifactVersion
+mixin
++ slc:artifactVersions (argeo:references) m
+
+
+[slc:modularDistributionBase]
+mixin
+
+// Question: Extend slc:categorizedNameVersion ? (not possible without migration)
+[slc:modularDistribution] 
+mixin
++ slc:modules (nt:unstructured) m
+
+[slc:moduleCoordinates] > nt:unstructured
+- slc:category (STRING)
+- slc:name (STRING)
+- slc:version (STRING)
+
+
+// ORIGINS
+[slc:knownOrigin] > nt:base
+mixin
++ slc:origin (nt:address)
+
+[slc:proxied] > nt:address
+- slc:proxy (REFERENCE)
+
+// JAVA
+[slc:jarFile] > mix:referenceable
+mixin
+- 'slc:manifest' (BINARY) m
+- 'slc:Manifest-Version' (STRING)
+- 'slc:Signature-Version' (STRING)
+- 'slc:Class-Path'  (STRING)
+- 'slc:Main-Class' (STRING)
+- 'slc:Extension-Name' (STRING)
+- 'slc:Implementation-Version' (STRING)
+- 'slc:Implementation-Vendor' (STRING)
+- 'slc:Implementation-Vendor-Id' (STRING)
+- 'slc:Implementation-URL' (STRING)
+- 'slc:Specification-Title' (STRING)
+- 'slc:Specification-Version' (STRING)
+- 'slc:Specification-Vendor' (STRING)
+- 'slc:Sealed' (STRING)
+
+// OSGi
+// see http://www.osgi.org/Specifications/Reference
+
+[slc:javaPackage] > mix:referenceable
+- slc:name (STRING) primary m
+
+[slc:osgiBaseVersion] > mix:referenceable
+- slc:asString (STRING) primary m
+- slc:major (LONG) m
+- slc:minor (LONG) m
+- slc:micro (LONG) m
+
+[slc:osgiVersion] > slc:osgiBaseVersion
+- slc:qualifier (STRING)
+
+[slc:exportedPackage] > slc:javaPackage
++ slc:uses (slc:javaPackage) multiple
++ slc:version (slc:osgiVersion)
+
+[slc:importedPackage] > slc:javaPackage
+- slc:version (STRING) ='0.0.0' m a
+- slc:optional (BOOLEAN) ='false' m a
+
+[slc:dynamicImportedPackage] > slc:javaPackage
+- slc:version (STRING) ='0.0.0' m a
+- slc:optional (BOOLEAN) ='false' m a
+
+[slc:requiredBundle] > mix:referenceable
+- 'slc:symbolic-name' (STRING) primary m
+- 'slc:bundle-version' (STRING) ='0.0.0' m a
+- slc:optional (BOOLEAN) ='false' m a
+
+[slc:fragmentHost] > mix:referenceable
+- 'slc:symbolic-name' (STRING) m
+- 'slc:bundle-version' (STRING) ='0.0.0' m a
+
+[slc:bundleNativeCode] > mix:referenceable
+- slc:path (STRING) primary m
+- slc:osname (STRING)
+- slc:processor (STRING)
+
+// see http://www.osgi.org/Specifications/ReferenceHeaders
+[slc:bundle] > mix:referenceable
+mixin
+- 'slc:symbolic-name' (STRING) primary m
+- 'slc:bundle-version' (STRING) m
+- 'slc:Bundle-SymbolicName' (STRING) m
+- 'slc:Bundle-Name' (STRING)
+- 'slc:Bundle-Description' (STRING)
+- 'slc:Bundle-ManifestVersion' (STRING)
+- 'slc:Bundle-Category' (STRING)
+- 'slc:Bundle-ActivationPolicy' (STRING)
+- 'slc:Bundle-Copyright' (STRING)
+- 'slc:Bundle-Vendor' (STRING)
+- 'slc:Bundle-License' (STRING)
+- 'slc:Bundle-DocURL' (STRING)
+- 'slc:Bundle-ContactAddress' (STRING)
+- 'slc:Bundle-Activator' (STRING)
+- 'slc:Bundle-UpdateLocation' (STRING)
+- 'slc:Bundle-Localization' (STRING)
+- 'slc:Bundle-ClassPath' (STRING) *
+// see http://wiki.eclipse.org/EE  < 'OSGi/Minimum-1.0','OSGi/Minimum-1.1','CDC-1.0/Foundation-1.0','CDC-1.1/Foundation-1.1','JRE-1.1','J2SE-1.2','J2SE-1.3','J2SE-1.4','J2SE-1.5','JavaSE-1.6','JavaSE-1.7'
+- 'slc:Bundle-RequiredExecutionEnvironment' (STRING) *
++ 'slc:Bundle-Version' (slc:osgiVersion) m
++ 'slc:Fragment-Host' (slc:fragmentHost)
++ 'slc:Import-Package' (slc:importedPackage) multiple
++ 'slc:Export-Package' (slc:exportedPackage) multiple
++ 'slc:Require-Bundle' (slc:requiredBundle) multiple
++ 'slc:Bundle-NativeCode' (slc:bundleNativeCode) multiple
++ 'slc:DynamicImport-Package' (slc:dynamicImportedPackage) multiple
+
+[slc:bundleArtifact] > slc:artifact,slc:jarFile,slc:bundle
+mixin
+
+// RPM
+[slc:rpm] > mix:referenceable, mix:created, mix:lastModified, mix:title
+mixin
+- slc:name (STRING)
+- slc:version (STRING)
+- slc:rpmVersion (STRING)
+- slc:rpmRelease (STRING)
+- slc:rpmArch (STRING)
+- slc:rpmArchivaeSize (STRING)
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java b/org.argeo.slc.repo/src/org/eclipse/aether/AbstractForwardingRepositorySystemSession.java
new file mode 100644 (file)
index 0000000..590ad28
--- /dev/null
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+import java.util.Map;
+
+import org.eclipse.aether.artifact.ArtifactTypeRegistry;
+import org.eclipse.aether.collection.DependencyGraphTransformer;
+import org.eclipse.aether.collection.DependencyManager;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.collection.DependencyTraverser;
+import org.eclipse.aether.collection.VersionFilter;
+import org.eclipse.aether.repository.AuthenticationSelector;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
+import org.eclipse.aether.repository.MirrorSelector;
+import org.eclipse.aether.repository.ProxySelector;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
+import org.eclipse.aether.resolution.ResolutionErrorPolicy;
+import org.eclipse.aether.transfer.TransferListener;
+
+/**
+ * A special repository system session to enable decorating or proxying another session. To do so, clients have to
+ * create a subclass and implement {@link #getSession()}.
+ */
+public abstract class AbstractForwardingRepositorySystemSession
+    implements RepositorySystemSession
+{
+
+    /**
+     * Creates a new forwarding session.
+     */
+    protected AbstractForwardingRepositorySystemSession()
+    {
+    }
+
+    /**
+     * Gets the repository system session to which this instance forwards calls. It's worth noting that this class does
+     * not save/cache the returned reference but queries this method before each forwarding. Hence, the session
+     * forwarded to may change over time or depending on the context (e.g. calling thread).
+     * 
+     * @return The repository system session to forward calls to, never {@code null}.
+     */
+    protected abstract RepositorySystemSession getSession();
+
+    public boolean isOffline()
+    {
+        return getSession().isOffline();
+    }
+
+    public boolean isIgnoreArtifactDescriptorRepositories()
+    {
+        return getSession().isIgnoreArtifactDescriptorRepositories();
+    }
+
+    public ResolutionErrorPolicy getResolutionErrorPolicy()
+    {
+        return getSession().getResolutionErrorPolicy();
+    }
+
+    public ArtifactDescriptorPolicy getArtifactDescriptorPolicy()
+    {
+        return getSession().getArtifactDescriptorPolicy();
+    }
+
+    public String getChecksumPolicy()
+    {
+        return getSession().getChecksumPolicy();
+    }
+
+    public String getUpdatePolicy()
+    {
+        return getSession().getUpdatePolicy();
+    }
+
+    public LocalRepository getLocalRepository()
+    {
+        return getSession().getLocalRepository();
+    }
+
+    public LocalRepositoryManager getLocalRepositoryManager()
+    {
+        return getSession().getLocalRepositoryManager();
+    }
+
+    public WorkspaceReader getWorkspaceReader()
+    {
+        return getSession().getWorkspaceReader();
+    }
+
+    public RepositoryListener getRepositoryListener()
+    {
+        return getSession().getRepositoryListener();
+    }
+
+    public TransferListener getTransferListener()
+    {
+        return getSession().getTransferListener();
+    }
+
+    public Map<String, String> getSystemProperties()
+    {
+        return getSession().getSystemProperties();
+    }
+
+    public Map<String, String> getUserProperties()
+    {
+        return getSession().getUserProperties();
+    }
+
+    public Map<String, Object> getConfigProperties()
+    {
+        return getSession().getConfigProperties();
+    }
+
+    public MirrorSelector getMirrorSelector()
+    {
+        return getSession().getMirrorSelector();
+    }
+
+    public ProxySelector getProxySelector()
+    {
+        return getSession().getProxySelector();
+    }
+
+    public AuthenticationSelector getAuthenticationSelector()
+    {
+        return getSession().getAuthenticationSelector();
+    }
+
+    public ArtifactTypeRegistry getArtifactTypeRegistry()
+    {
+        return getSession().getArtifactTypeRegistry();
+    }
+
+    public DependencyTraverser getDependencyTraverser()
+    {
+        return getSession().getDependencyTraverser();
+    }
+
+    public DependencyManager getDependencyManager()
+    {
+        return getSession().getDependencyManager();
+    }
+
+    public DependencySelector getDependencySelector()
+    {
+        return getSession().getDependencySelector();
+    }
+
+    public VersionFilter getVersionFilter()
+    {
+        return getSession().getVersionFilter();
+    }
+
+    public DependencyGraphTransformer getDependencyGraphTransformer()
+    {
+        return getSession().getDependencyGraphTransformer();
+    }
+
+    public SessionData getData()
+    {
+        return getSession().getData();
+    }
+
+    public RepositoryCache getCache()
+    {
+        return getSession().getCache();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/AbstractRepositoryListener.java b/org.argeo.slc.repo/src/org/eclipse/aether/AbstractRepositoryListener.java
new file mode 100644 (file)
index 0000000..eaaffc1
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+/**
+ * A skeleton implementation for custom repository listeners. The callback methods in this class do nothing.
+ */
+public abstract class AbstractRepositoryListener
+    implements RepositoryListener
+{
+
+    /**
+     * Enables subclassing.
+     */
+    protected AbstractRepositoryListener()
+    {
+    }
+
+    public void artifactDeployed( RepositoryEvent event )
+    {
+    }
+
+    public void artifactDeploying( RepositoryEvent event )
+    {
+    }
+
+    public void artifactDescriptorInvalid( RepositoryEvent event )
+    {
+    }
+
+    public void artifactDescriptorMissing( RepositoryEvent event )
+    {
+    }
+
+    public void artifactDownloaded( RepositoryEvent event )
+    {
+    }
+
+    public void artifactDownloading( RepositoryEvent event )
+    {
+    }
+
+    public void artifactInstalled( RepositoryEvent event )
+    {
+    }
+
+    public void artifactInstalling( RepositoryEvent event )
+    {
+    }
+
+    public void artifactResolved( RepositoryEvent event )
+    {
+    }
+
+    public void artifactResolving( RepositoryEvent event )
+    {
+    }
+
+    public void metadataDeployed( RepositoryEvent event )
+    {
+    }
+
+    public void metadataDeploying( RepositoryEvent event )
+    {
+    }
+
+    public void metadataDownloaded( RepositoryEvent event )
+    {
+    }
+
+    public void metadataDownloading( RepositoryEvent event )
+    {
+    }
+
+    public void metadataInstalled( RepositoryEvent event )
+    {
+    }
+
+    public void metadataInstalling( RepositoryEvent event )
+    {
+    }
+
+    public void metadataInvalid( RepositoryEvent event )
+    {
+    }
+
+    public void metadataResolved( RepositoryEvent event )
+    {
+    }
+
+    public void metadataResolving( RepositoryEvent event )
+    {
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/ConfigurationProperties.java b/org.argeo.slc.repo/src/org/eclipse/aether/ConfigurationProperties.java
new file mode 100644 (file)
index 0000000..3cbd59c
--- /dev/null
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+/**
+ * The keys and defaults for common configuration properties.
+ * 
+ * @see RepositorySystemSession#getConfigProperties()
+ */
+public final class ConfigurationProperties
+{
+
+    private static final String PREFIX_AETHER = "aether.";
+
+    private static final String PREFIX_CONNECTOR = PREFIX_AETHER + "connector.";
+
+    /**
+     * The prefix for properties that control the priority of pluggable extensions like transporters. For example, for
+     * an extension with the fully qualified class name "org.eclipse.MyExtensionFactory", the configuration properties
+     * "aether.priority.org.eclipse.MyExtensionFactory", "aether.priority.MyExtensionFactory" and
+     * "aether.priority.MyExtension" will be consulted for the priority, in that order (obviously, the last key is only
+     * tried if the class name ends with "Factory"). The corresponding value is a float and the special value
+     * {@link Float#NaN} or "NaN" (case-sensitive) can be used to disable the extension.
+     */
+    public static final String PREFIX_PRIORITY = PREFIX_AETHER + "priority.";
+
+    /**
+     * A flag indicating whether the priorities of pluggable extensions are implicitly given by their iteration order
+     * such that the first extension has the highest priority. If set, an extension's built-in priority as well as any
+     * corresponding {@code aether.priority.*} configuration properties are ignored when searching for a suitable
+     * implementation among the available extensions. This priority mode is meant for cases where the application will
+     * present/inject extensions in the desired search order.
+     * 
+     * @see #DEFAULT_IMPLICIT_PRIORITIES
+     */
+    public static final String IMPLICIT_PRIORITIES = PREFIX_PRIORITY + "implicit";
+
+    /**
+     * The default extension priority mode if {@link #IMPLICIT_PRIORITIES} isn't set.
+     */
+    public static final boolean DEFAULT_IMPLICIT_PRIORITIES = false;
+
+    /**
+     * A flag indicating whether interaction with the user is allowed.
+     * 
+     * @see #DEFAULT_INTERACTIVE
+     */
+    public static final String INTERACTIVE = PREFIX_AETHER + "interactive";
+
+    /**
+     * The default interactive mode if {@link #INTERACTIVE} isn't set.
+     */
+    public static final boolean DEFAULT_INTERACTIVE = false;
+
+    /**
+     * The user agent that repository connectors should report to servers.
+     * 
+     * @see #DEFAULT_USER_AGENT
+     */
+    public static final String USER_AGENT = PREFIX_CONNECTOR + "userAgent";
+
+    /**
+     * The default user agent to use if {@link #USER_AGENT} isn't set.
+     */
+    public static final String DEFAULT_USER_AGENT = "Aether";
+
+    /**
+     * The maximum amount of time (in milliseconds) to wait for a successful connection to a remote server. Non-positive
+     * values indicate no timeout.
+     * 
+     * @see #DEFAULT_CONNECT_TIMEOUT
+     */
+    public static final String CONNECT_TIMEOUT = PREFIX_CONNECTOR + "connectTimeout";
+
+    /**
+     * The default connect timeout to use if {@link #CONNECT_TIMEOUT} isn't set.
+     */
+    public static final int DEFAULT_CONNECT_TIMEOUT = 10 * 1000;
+
+    /**
+     * The maximum amount of time (in milliseconds) to wait for remaining data to arrive from a remote server. Note that
+     * this timeout does not restrict the overall duration of a request, it only restricts the duration of inactivity
+     * between consecutive data packets. Non-positive values indicate no timeout.
+     * 
+     * @see #DEFAULT_REQUEST_TIMEOUT
+     */
+    public static final String REQUEST_TIMEOUT = PREFIX_CONNECTOR + "requestTimeout";
+
+    /**
+     * The default request timeout to use if {@link #REQUEST_TIMEOUT} isn't set.
+     */
+    public static final int DEFAULT_REQUEST_TIMEOUT = 1800 * 1000;
+
+    /**
+     * The request headers to use for HTTP-based repository connectors. The headers are specified using a
+     * {@code Map<String, String>}, mapping a header name to its value. Besides this general key, clients may also
+     * specify headers for a specific remote repository by appending the suffix {@code .<repoId>} to this key when
+     * storing the headers map. The repository-specific headers map is supposed to be complete, i.e. is not merged with
+     * the general headers map.
+     */
+    public static final String HTTP_HEADERS = PREFIX_CONNECTOR + "http.headers";
+
+    /**
+     * The encoding/charset to use when exchanging credentials with HTTP servers. Besides this general key, clients may
+     * also specify the encoding for a specific remote repository by appending the suffix {@code .<repoId>} to this key
+     * when storing the charset name.
+     * 
+     * @see #DEFAULT_HTTP_CREDENTIAL_ENCODING
+     */
+    public static final String HTTP_CREDENTIAL_ENCODING = PREFIX_CONNECTOR + "http.credentialEncoding";
+
+    /**
+     * The default encoding/charset to use if {@link #HTTP_CREDENTIAL_ENCODING} isn't set.
+     */
+    public static final String DEFAULT_HTTP_CREDENTIAL_ENCODING = "ISO-8859-1";
+
+    /**
+     * An option indicating whether authentication configured for a HTTP repository should also be used with any host
+     * that the original server might redirect requests to. Unless enabled, credentials are only exchanged with the
+     * original host from the repository URL and not supplied to different hosts encountered during redirects. The
+     * option value can either be a boolean flag or a comma-separated list of host names denoting the whitelist of
+     * original hosts whose redirects can be trusted and should use the configured authentication no matter the
+     * destination host(s). Alternatively, the suffix {@code .<repoId>} can be appended to this configuration key to
+     * control the behavior for a specific repository id.
+     * 
+     * @see #DEFAULT_HTTP_REDIRECTED_AUTHENTICATION
+     * @since 1.1.0
+     */
+    public static final String HTTP_REDIRECTED_AUTHENTICATION = PREFIX_CONNECTOR + "http.redirectedAuthentication";
+
+    /**
+     * The default handling of authentication during HTTP redirects if {@link #HTTP_REDIRECTED_AUTHENTICATION} isn't
+     * set.
+     * 
+     * @since 1.1.0
+     */
+    public static final String DEFAULT_HTTP_REDIRECTED_AUTHENTICATION = "false";
+
+    /**
+     * A flag indicating whether checksums which are retrieved during checksum validation should be persisted in the
+     * local filesystem next to the file they provide the checksum for.
+     * 
+     * @see #DEFAULT_PERSISTED_CHECKSUMS
+     */
+    public static final String PERSISTED_CHECKSUMS = PREFIX_CONNECTOR + "persistedChecksums";
+
+    /**
+     * The default checksum persistence mode if {@link #PERSISTED_CHECKSUMS} isn't set.
+     */
+    public static final boolean DEFAULT_PERSISTED_CHECKSUMS = true;
+
+    private ConfigurationProperties()
+    {
+        // hide constructor
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositoryCache.java b/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositoryCache.java
new file mode 100644 (file)
index 0000000..12d2789
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * A simplistic repository cache backed by a thread-safe map. The simplistic nature of this cache makes it only suitable
+ * for use with short-lived repository system sessions where pruning of cache data is not required.
+ */
+public final class DefaultRepositoryCache
+    implements RepositoryCache
+{
+
+    private final Map<Object, Object> cache = new ConcurrentHashMap<Object, Object>( 256 );
+
+    public Object get( RepositorySystemSession session, Object key )
+    {
+        return cache.get( key );
+    }
+
+    public void put( RepositorySystemSession session, Object key, Object data )
+    {
+        if ( data != null )
+        {
+            cache.put( key, data );
+        }
+        else
+        {
+            cache.remove( key );
+        }
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositorySystemSession.java b/org.argeo.slc.repo/src/org/eclipse/aether/DefaultRepositorySystemSession.java
new file mode 100644 (file)
index 0000000..363ede6
--- /dev/null
@@ -0,0 +1,825 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.aether.artifact.ArtifactType;
+import org.eclipse.aether.artifact.ArtifactTypeRegistry;
+import org.eclipse.aether.collection.DependencyGraphTransformer;
+import org.eclipse.aether.collection.DependencyManager;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.collection.DependencyTraverser;
+import org.eclipse.aether.collection.VersionFilter;
+import org.eclipse.aether.repository.Authentication;
+import org.eclipse.aether.repository.AuthenticationSelector;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
+import org.eclipse.aether.repository.MirrorSelector;
+import org.eclipse.aether.repository.Proxy;
+import org.eclipse.aether.repository.ProxySelector;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.repository.RepositoryPolicy;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
+import org.eclipse.aether.resolution.ResolutionErrorPolicy;
+import org.eclipse.aether.transfer.TransferListener;
+
+/**
+ * A simple repository system session.
+ * <p>
+ * <strong>Note:</strong> This class is not thread-safe. It is assumed that the mutators get only called during an
+ * initialization phase and that the session itself is not changed once initialized and being used by the repository
+ * system. It is recommended to call {@link #setReadOnly()} once the session has been fully initialized to prevent
+ * accidental manipulation of it afterwards.
+ */
+public final class DefaultRepositorySystemSession
+    implements RepositorySystemSession
+{
+
+    private boolean readOnly;
+
+    private boolean offline;
+
+    private boolean ignoreArtifactDescriptorRepositories;
+
+    private ResolutionErrorPolicy resolutionErrorPolicy;
+
+    private ArtifactDescriptorPolicy artifactDescriptorPolicy;
+
+    private String checksumPolicy;
+
+    private String updatePolicy;
+
+    private LocalRepositoryManager localRepositoryManager;
+
+    private WorkspaceReader workspaceReader;
+
+    private RepositoryListener repositoryListener;
+
+    private TransferListener transferListener;
+
+    private Map<String, String> systemProperties;
+
+    private Map<String, String> systemPropertiesView;
+
+    private Map<String, String> userProperties;
+
+    private Map<String, String> userPropertiesView;
+
+    private Map<String, Object> configProperties;
+
+    private Map<String, Object> configPropertiesView;
+
+    private MirrorSelector mirrorSelector;
+
+    private ProxySelector proxySelector;
+
+    private AuthenticationSelector authenticationSelector;
+
+    private ArtifactTypeRegistry artifactTypeRegistry;
+
+    private DependencyTraverser dependencyTraverser;
+
+    private DependencyManager dependencyManager;
+
+    private DependencySelector dependencySelector;
+
+    private VersionFilter versionFilter;
+
+    private DependencyGraphTransformer dependencyGraphTransformer;
+
+    private SessionData data;
+
+    private RepositoryCache cache;
+
+    /**
+     * Creates an uninitialized session. <em>Note:</em> The new session is not ready to use, as a bare minimum,
+     * {@link #setLocalRepositoryManager(LocalRepositoryManager)} needs to be called but usually other settings also
+     * need to be customized to achieve meaningful behavior.
+     */
+    public DefaultRepositorySystemSession()
+    {
+        systemProperties = new HashMap<String, String>();
+        systemPropertiesView = Collections.unmodifiableMap( systemProperties );
+        userProperties = new HashMap<String, String>();
+        userPropertiesView = Collections.unmodifiableMap( userProperties );
+        configProperties = new HashMap<String, Object>();
+        configPropertiesView = Collections.unmodifiableMap( configProperties );
+        mirrorSelector = NullMirrorSelector.INSTANCE;
+        proxySelector = NullProxySelector.INSTANCE;
+        authenticationSelector = NullAuthenticationSelector.INSTANCE;
+        artifactTypeRegistry = NullArtifactTypeRegistry.INSTANCE;
+        data = new DefaultSessionData();
+    }
+
+    /**
+     * Creates a shallow copy of the specified session. Actually, the copy is not completely shallow, all maps holding
+     * system/user/config properties are copied as well. In other words, invoking any mutator on the new session itself
+     * has no effect on the original session. Other mutable objects like the session data and cache (if any) are not
+     * copied and will be shared with the original session unless reconfigured.
+     * 
+     * @param session The session to copy, must not be {@code null}.
+     */
+    public DefaultRepositorySystemSession( RepositorySystemSession session )
+    {
+        if ( session == null )
+        {
+            throw new IllegalArgumentException( "repository system session not specified" );
+        }
+
+        setOffline( session.isOffline() );
+        setIgnoreArtifactDescriptorRepositories( session.isIgnoreArtifactDescriptorRepositories() );
+        setResolutionErrorPolicy( session.getResolutionErrorPolicy() );
+        setArtifactDescriptorPolicy( session.getArtifactDescriptorPolicy() );
+        setChecksumPolicy( session.getChecksumPolicy() );
+        setUpdatePolicy( session.getUpdatePolicy() );
+        setLocalRepositoryManager( session.getLocalRepositoryManager() );
+        setWorkspaceReader( session.getWorkspaceReader() );
+        setRepositoryListener( session.getRepositoryListener() );
+        setTransferListener( session.getTransferListener() );
+        setSystemProperties( session.getSystemProperties() );
+        setUserProperties( session.getUserProperties() );
+        setConfigProperties( session.getConfigProperties() );
+        setMirrorSelector( session.getMirrorSelector() );
+        setProxySelector( session.getProxySelector() );
+        setAuthenticationSelector( session.getAuthenticationSelector() );
+        setArtifactTypeRegistry( session.getArtifactTypeRegistry() );
+        setDependencyTraverser( session.getDependencyTraverser() );
+        setDependencyManager( session.getDependencyManager() );
+        setDependencySelector( session.getDependencySelector() );
+        setVersionFilter( session.getVersionFilter() );
+        setDependencyGraphTransformer( session.getDependencyGraphTransformer() );
+        setData( session.getData() );
+        setCache( session.getCache() );
+    }
+
+    public boolean isOffline()
+    {
+        return offline;
+    }
+
+    /**
+     * Controls whether the repository system operates in offline mode and avoids/refuses any access to remote
+     * repositories.
+     * 
+     * @param offline {@code true} if the repository system is in offline mode, {@code false} otherwise.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setOffline( boolean offline )
+    {
+        failIfReadOnly();
+        this.offline = offline;
+        return this;
+    }
+
+    public boolean isIgnoreArtifactDescriptorRepositories()
+    {
+        return ignoreArtifactDescriptorRepositories;
+    }
+
+    /**
+     * Controls whether repositories declared in artifact descriptors should be ignored during transitive dependency
+     * collection. If enabled, only the repositories originally provided with the collect request will be considered.
+     * 
+     * @param ignoreArtifactDescriptorRepositories {@code true} to ignore additional repositories from artifact
+     *            descriptors, {@code false} to merge those with the originally specified repositories.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setIgnoreArtifactDescriptorRepositories( boolean ignoreArtifactDescriptorRepositories )
+    {
+        failIfReadOnly();
+        this.ignoreArtifactDescriptorRepositories = ignoreArtifactDescriptorRepositories;
+        return this;
+    }
+
+    public ResolutionErrorPolicy getResolutionErrorPolicy()
+    {
+        return resolutionErrorPolicy;
+    }
+
+    /**
+     * Sets the policy which controls whether resolutions errors from remote repositories should be cached.
+     * 
+     * @param resolutionErrorPolicy The resolution error policy for this session, may be {@code null} if resolution
+     *            errors should generally not be cached.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setResolutionErrorPolicy( ResolutionErrorPolicy resolutionErrorPolicy )
+    {
+        failIfReadOnly();
+        this.resolutionErrorPolicy = resolutionErrorPolicy;
+        return this;
+    }
+
+    public ArtifactDescriptorPolicy getArtifactDescriptorPolicy()
+    {
+        return artifactDescriptorPolicy;
+    }
+
+    /**
+     * Sets the policy which controls how errors related to reading artifact descriptors should be handled.
+     * 
+     * @param artifactDescriptorPolicy The descriptor error policy for this session, may be {@code null} if descriptor
+     *            errors should generally not be tolerated.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setArtifactDescriptorPolicy( ArtifactDescriptorPolicy artifactDescriptorPolicy )
+    {
+        failIfReadOnly();
+        this.artifactDescriptorPolicy = artifactDescriptorPolicy;
+        return this;
+    }
+
+    public String getChecksumPolicy()
+    {
+        return checksumPolicy;
+    }
+
+    /**
+     * Sets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
+     * repositories being used for resolution.
+     * 
+     * @param checksumPolicy The global checksum policy, may be {@code null}/empty to apply the per-repository policies.
+     * @return This session for chaining, never {@code null}.
+     * @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
+     * @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
+     * @see RepositoryPolicy#CHECKSUM_POLICY_WARN
+     */
+    public DefaultRepositorySystemSession setChecksumPolicy( String checksumPolicy )
+    {
+        failIfReadOnly();
+        this.checksumPolicy = checksumPolicy;
+        return this;
+    }
+
+    public String getUpdatePolicy()
+    {
+        return updatePolicy;
+    }
+
+    /**
+     * Sets the global update policy. If set, the global update policy overrides the update policies of the remote
+     * repositories being used for resolution.
+     * 
+     * @param updatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies.
+     * @return This session for chaining, never {@code null}.
+     * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
+     * @see RepositoryPolicy#UPDATE_POLICY_DAILY
+     * @see RepositoryPolicy#UPDATE_POLICY_NEVER
+     */
+    public DefaultRepositorySystemSession setUpdatePolicy( String updatePolicy )
+    {
+        failIfReadOnly();
+        this.updatePolicy = updatePolicy;
+        return this;
+    }
+
+    public LocalRepository getLocalRepository()
+    {
+        LocalRepositoryManager lrm = getLocalRepositoryManager();
+        return ( lrm != null ) ? lrm.getRepository() : null;
+    }
+
+    public LocalRepositoryManager getLocalRepositoryManager()
+    {
+        return localRepositoryManager;
+    }
+
+    /**
+     * Sets the local repository manager used during this session. <em>Note:</em> Eventually, a valid session must have
+     * a local repository manager set.
+     * 
+     * @param localRepositoryManager The local repository manager used during this session, may be {@code null}.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setLocalRepositoryManager( LocalRepositoryManager localRepositoryManager )
+    {
+        failIfReadOnly();
+        this.localRepositoryManager = localRepositoryManager;
+        return this;
+    }
+
+    public WorkspaceReader getWorkspaceReader()
+    {
+        return workspaceReader;
+    }
+
+    /**
+     * Sets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
+     * to resolve artifacts.
+     * 
+     * @param workspaceReader The workspace reader for this session, may be {@code null} if none.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setWorkspaceReader( WorkspaceReader workspaceReader )
+    {
+        failIfReadOnly();
+        this.workspaceReader = workspaceReader;
+        return this;
+    }
+
+    public RepositoryListener getRepositoryListener()
+    {
+        return repositoryListener;
+    }
+
+    /**
+     * Sets the listener being notified of actions in the repository system.
+     * 
+     * @param repositoryListener The repository listener, may be {@code null} if none.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setRepositoryListener( RepositoryListener repositoryListener )
+    {
+        failIfReadOnly();
+        this.repositoryListener = repositoryListener;
+        return this;
+    }
+
+    public TransferListener getTransferListener()
+    {
+        return transferListener;
+    }
+
+    /**
+     * Sets the listener being notified of uploads/downloads by the repository system.
+     * 
+     * @param transferListener The transfer listener, may be {@code null} if none.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setTransferListener( TransferListener transferListener )
+    {
+        failIfReadOnly();
+        this.transferListener = transferListener;
+        return this;
+    }
+
+    private <T> Map<String, T> copySafe( Map<?, ?> table, Class<T> valueType )
+    {
+        Map<String, T> map;
+        if ( table == null || table.isEmpty() )
+        {
+            map = new HashMap<String, T>();
+        }
+        else
+        {
+            map = new HashMap<String, T>( (int) ( table.size() / 0.75f ) + 1 );
+            for ( Map.Entry<?, ?> entry : table.entrySet() )
+            {
+                Object key = entry.getKey();
+                if ( key instanceof String )
+                {
+                    Object value = entry.getValue();
+                    if ( valueType.isInstance( value ) )
+                    {
+                        map.put( key.toString(), valueType.cast( value ) );
+                    }
+                }
+            }
+        }
+        return map;
+    }
+
+    public Map<String, String> getSystemProperties()
+    {
+        return systemPropertiesView;
+    }
+
+    /**
+     * Sets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
+     * collected from the runtime environment like {@link System#getProperties()} and environment variables.
+     * <p>
+     * <em>Note:</em> System properties are of type {@code Map<String, String>} and any key-value pair in the input map
+     * that doesn't match this type will be silently ignored.
+     * 
+     * @param systemProperties The system properties, may be {@code null} or empty if none.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setSystemProperties( Map<?, ?> systemProperties )
+    {
+        failIfReadOnly();
+        this.systemProperties = copySafe( systemProperties, String.class );
+        systemPropertiesView = Collections.unmodifiableMap( this.systemProperties );
+        return this;
+    }
+
+    /**
+     * Sets the specified system property.
+     * 
+     * @param key The property key, must not be {@code null}.
+     * @param value The property value, may be {@code null} to remove/unset the property.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setSystemProperty( String key, String value )
+    {
+        failIfReadOnly();
+        if ( value != null )
+        {
+            systemProperties.put( key, value );
+        }
+        else
+        {
+            systemProperties.remove( key );
+        }
+        return this;
+    }
+
+    public Map<String, String> getUserProperties()
+    {
+        return userPropertiesView;
+    }
+
+    /**
+     * Sets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
+     * system properties but are set on the discretion of the user and hence are considered of higher priority than
+     * system properties in case of conflicts.
+     * <p>
+     * <em>Note:</em> User properties are of type {@code Map<String, String>} and any key-value pair in the input map
+     * that doesn't match this type will be silently ignored.
+     * 
+     * @param userProperties The user properties, may be {@code null} or empty if none.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setUserProperties( Map<?, ?> userProperties )
+    {
+        failIfReadOnly();
+        this.userProperties = copySafe( userProperties, String.class );
+        userPropertiesView = Collections.unmodifiableMap( this.userProperties );
+        return this;
+    }
+
+    /**
+     * Sets the specified user property.
+     * 
+     * @param key The property key, must not be {@code null}.
+     * @param value The property value, may be {@code null} to remove/unset the property.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setUserProperty( String key, String value )
+    {
+        failIfReadOnly();
+        if ( value != null )
+        {
+            userProperties.put( key, value );
+        }
+        else
+        {
+            userProperties.remove( key );
+        }
+        return this;
+    }
+
+    public Map<String, Object> getConfigProperties()
+    {
+        return configPropertiesView;
+    }
+
+    /**
+     * Sets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
+     * connector-specific behavior, etc.).
+     * <p>
+     * <em>Note:</em> Configuration properties are of type {@code Map<String, Object>} and any key-value pair in the
+     * input map that doesn't match this type will be silently ignored.
+     * 
+     * @param configProperties The configuration properties, may be {@code null} or empty if none.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setConfigProperties( Map<?, ?> configProperties )
+    {
+        failIfReadOnly();
+        this.configProperties = copySafe( configProperties, Object.class );
+        configPropertiesView = Collections.unmodifiableMap( this.configProperties );
+        return this;
+    }
+
+    /**
+     * Sets the specified configuration property.
+     * 
+     * @param key The property key, must not be {@code null}.
+     * @param value The property value, may be {@code null} to remove/unset the property.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setConfigProperty( String key, Object value )
+    {
+        failIfReadOnly();
+        if ( value != null )
+        {
+            configProperties.put( key, value );
+        }
+        else
+        {
+            configProperties.remove( key );
+        }
+        return this;
+    }
+
+    public MirrorSelector getMirrorSelector()
+    {
+        return mirrorSelector;
+    }
+
+    /**
+     * Sets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
+     * not used for remote repositories which are passed as request parameters to the repository system, those
+     * repositories are supposed to denote the effective repositories.
+     * 
+     * @param mirrorSelector The mirror selector to use, may be {@code null}.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setMirrorSelector( MirrorSelector mirrorSelector )
+    {
+        failIfReadOnly();
+        this.mirrorSelector = mirrorSelector;
+        if ( this.mirrorSelector == null )
+        {
+            this.mirrorSelector = NullMirrorSelector.INSTANCE;
+        }
+        return this;
+    }
+
+    public ProxySelector getProxySelector()
+    {
+        return proxySelector;
+    }
+
+    /**
+     * Sets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
+     * not used for remote repositories which are passed as request parameters to the repository system, those
+     * repositories are supposed to have their proxy (if any) already set.
+     * 
+     * @param proxySelector The proxy selector to use, may be {@code null}.
+     * @return This session for chaining, never {@code null}.
+     * @see org.eclipse.aether.repository.RemoteRepository#getProxy()
+     */
+    public DefaultRepositorySystemSession setProxySelector( ProxySelector proxySelector )
+    {
+        failIfReadOnly();
+        this.proxySelector = proxySelector;
+        if ( this.proxySelector == null )
+        {
+            this.proxySelector = NullProxySelector.INSTANCE;
+        }
+        return this;
+    }
+
+    public AuthenticationSelector getAuthenticationSelector()
+    {
+        return authenticationSelector;
+    }
+
+    /**
+     * Sets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
+     * selector is not used for remote repositories which are passed as request parameters to the repository system,
+     * those repositories are supposed to have their authentication (if any) already set.
+     * 
+     * @param authenticationSelector The authentication selector to use, may be {@code null}.
+     * @return This session for chaining, never {@code null}.
+     * @see org.eclipse.aether.repository.RemoteRepository#getAuthentication()
+     */
+    public DefaultRepositorySystemSession setAuthenticationSelector( AuthenticationSelector authenticationSelector )
+    {
+        failIfReadOnly();
+        this.authenticationSelector = authenticationSelector;
+        if ( this.authenticationSelector == null )
+        {
+            this.authenticationSelector = NullAuthenticationSelector.INSTANCE;
+        }
+        return this;
+    }
+
+    public ArtifactTypeRegistry getArtifactTypeRegistry()
+    {
+        return artifactTypeRegistry;
+    }
+
+    /**
+     * Sets the registry of artifact types recognized by this session.
+     * 
+     * @param artifactTypeRegistry The artifact type registry, may be {@code null}.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setArtifactTypeRegistry( ArtifactTypeRegistry artifactTypeRegistry )
+    {
+        failIfReadOnly();
+        this.artifactTypeRegistry = artifactTypeRegistry;
+        if ( this.artifactTypeRegistry == null )
+        {
+            this.artifactTypeRegistry = NullArtifactTypeRegistry.INSTANCE;
+        }
+        return this;
+    }
+
+    public DependencyTraverser getDependencyTraverser()
+    {
+        return dependencyTraverser;
+    }
+
+    /**
+     * Sets the dependency traverser to use for building dependency graphs.
+     * 
+     * @param dependencyTraverser The dependency traverser to use for building dependency graphs, may be {@code null}.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setDependencyTraverser( DependencyTraverser dependencyTraverser )
+    {
+        failIfReadOnly();
+        this.dependencyTraverser = dependencyTraverser;
+        return this;
+    }
+
+    public DependencyManager getDependencyManager()
+    {
+        return dependencyManager;
+    }
+
+    /**
+     * Sets the dependency manager to use for building dependency graphs.
+     * 
+     * @param dependencyManager The dependency manager to use for building dependency graphs, may be {@code null}.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setDependencyManager( DependencyManager dependencyManager )
+    {
+        failIfReadOnly();
+        this.dependencyManager = dependencyManager;
+        return this;
+    }
+
+    public DependencySelector getDependencySelector()
+    {
+        return dependencySelector;
+    }
+
+    /**
+     * Sets the dependency selector to use for building dependency graphs.
+     * 
+     * @param dependencySelector The dependency selector to use for building dependency graphs, may be {@code null}.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setDependencySelector( DependencySelector dependencySelector )
+    {
+        failIfReadOnly();
+        this.dependencySelector = dependencySelector;
+        return this;
+    }
+
+    public VersionFilter getVersionFilter()
+    {
+        return versionFilter;
+    }
+
+    /**
+     * Sets the version filter to use for building dependency graphs.
+     * 
+     * @param versionFilter The version filter to use for building dependency graphs, may be {@code null} to not filter
+     *            versions.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setVersionFilter( VersionFilter versionFilter )
+    {
+        failIfReadOnly();
+        this.versionFilter = versionFilter;
+        return this;
+    }
+
+    public DependencyGraphTransformer getDependencyGraphTransformer()
+    {
+        return dependencyGraphTransformer;
+    }
+
+    /**
+     * Sets the dependency graph transformer to use for building dependency graphs.
+     * 
+     * @param dependencyGraphTransformer The dependency graph transformer to use for building dependency graphs, may be
+     *            {@code null}.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setDependencyGraphTransformer( DependencyGraphTransformer dependencyGraphTransformer )
+    {
+        failIfReadOnly();
+        this.dependencyGraphTransformer = dependencyGraphTransformer;
+        return this;
+    }
+
+    public SessionData getData()
+    {
+        return data;
+    }
+
+    /**
+     * Sets the custom data associated with this session.
+     * 
+     * @param data The session data, may be {@code null}.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setData( SessionData data )
+    {
+        failIfReadOnly();
+        this.data = data;
+        if ( this.data == null )
+        {
+            this.data = new DefaultSessionData();
+        }
+        return this;
+    }
+
+    public RepositoryCache getCache()
+    {
+        return cache;
+    }
+
+    /**
+     * Sets the cache the repository system may use to save data for future reuse during the session.
+     * 
+     * @param cache The repository cache, may be {@code null} if none.
+     * @return This session for chaining, never {@code null}.
+     */
+    public DefaultRepositorySystemSession setCache( RepositoryCache cache )
+    {
+        failIfReadOnly();
+        this.cache = cache;
+        return this;
+    }
+
+    /**
+     * Marks this session as read-only such that any future attempts to call its mutators will fail with an exception.
+     * Marking an already read-only session as read-only has no effect. The session's data and cache remain writable
+     * though.
+     */
+    public void setReadOnly()
+    {
+        readOnly = true;
+    }
+
+    private void failIfReadOnly()
+    {
+        if ( readOnly )
+        {
+            throw new IllegalStateException( "repository system session is read-only" );
+        }
+    }
+
+    static class NullProxySelector
+        implements ProxySelector
+    {
+
+        public static final ProxySelector INSTANCE = new NullProxySelector();
+
+        public Proxy getProxy( RemoteRepository repository )
+        {
+            return repository.getProxy();
+        }
+
+    }
+
+    static class NullMirrorSelector
+        implements MirrorSelector
+    {
+
+        public static final MirrorSelector INSTANCE = new NullMirrorSelector();
+
+        public RemoteRepository getMirror( RemoteRepository repository )
+        {
+            return null;
+        }
+
+    }
+
+    static class NullAuthenticationSelector
+        implements AuthenticationSelector
+    {
+
+        public static final AuthenticationSelector INSTANCE = new NullAuthenticationSelector();
+
+        public Authentication getAuthentication( RemoteRepository repository )
+        {
+            return repository.getAuthentication();
+        }
+
+    }
+
+    static final class NullArtifactTypeRegistry
+        implements ArtifactTypeRegistry
+    {
+
+        public static final ArtifactTypeRegistry INSTANCE = new NullArtifactTypeRegistry();
+
+        public ArtifactType get( String typeId )
+        {
+            return null;
+        }
+
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/DefaultSessionData.java b/org.argeo.slc.repo/src/org/eclipse/aether/DefaultSessionData.java
new file mode 100644 (file)
index 0000000..738cebc
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * A simple session data storage backed by a thread-safe map.
+ */
+public final class DefaultSessionData
+    implements SessionData
+{
+
+    private final ConcurrentMap<Object, Object> data;
+
+    public DefaultSessionData()
+    {
+        data = new ConcurrentHashMap<Object, Object>();
+    }
+
+    public void set( Object key, Object value )
+    {
+        if ( key == null )
+        {
+            throw new IllegalArgumentException( "key must not be null" );
+        }
+
+        if ( value != null )
+        {
+            data.put( key, value );
+        }
+        else
+        {
+            data.remove( key );
+        }
+    }
+
+    public boolean set( Object key, Object oldValue, Object newValue )
+    {
+        if ( key == null )
+        {
+            throw new IllegalArgumentException( "key must not be null" );
+        }
+
+        if ( newValue != null )
+        {
+            if ( oldValue == null )
+            {
+                return data.putIfAbsent( key, newValue ) == null;
+            }
+            return data.replace( key, oldValue, newValue );
+        }
+        else
+        {
+            if ( oldValue == null )
+            {
+                return !data.containsKey( key );
+            }
+            return data.remove( key, oldValue );
+        }
+    }
+
+    public Object get( Object key )
+    {
+        if ( key == null )
+        {
+            throw new IllegalArgumentException( "key must not be null" );
+        }
+
+        return data.get( key );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryCache.java b/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryCache.java
new file mode 100644 (file)
index 0000000..7363844
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+/**
+ * Caches auxiliary data used during repository access like already processed metadata. The data in the cache is meant
+ * for exclusive consumption by the repository system and is opaque to the cache implementation. <strong>Note:</strong>
+ * Actual cache implementations must be thread-safe.
+ * 
+ * @see RepositorySystemSession#getCache()
+ */
+public interface RepositoryCache
+{
+
+    /**
+     * Puts the specified data into the cache. It is entirely up to the cache implementation how long this data will be
+     * kept before being purged, i.e. callers must not make any assumptions about the lifetime of cached data.
+     * <p>
+     * <em>Warning:</em> The cache will directly save the provided reference. If the cached data is mutable, i.e. could
+     * be modified after being put into the cache, the caller is responsible for creating a copy of the original data
+     * and store the copy in the cache.
+     * 
+     * @param session The repository session during which the cache is accessed, must not be {@code null}.
+     * @param key The key to use for lookup of the data, must not be {@code null}.
+     * @param data The data to store in the cache, may be {@code null}.
+     */
+    void put( RepositorySystemSession session, Object key, Object data );
+
+    /**
+     * Gets the specified data from the cache.
+     * <p>
+     * <em>Warning:</em> The cache will directly return the saved reference. If the cached data is to be modified after
+     * its retrieval, the caller is responsible to create a copy of the returned data and use this instead of the cache
+     * record.
+     * 
+     * @param session The repository session during which the cache is accessed, must not be {@code null}.
+     * @param key The key to use for lookup of the data, must not be {@code null}.
+     * @return The requested data or {@code null} if none was present in the cache.
+     */
+    Object get( RepositorySystemSession session, Object key );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryEvent.java b/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryEvent.java
new file mode 100644 (file)
index 0000000..2abd800
--- /dev/null
@@ -0,0 +1,433 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.repository.ArtifactRepository;
+
+/**
+ * An event describing an action performed by the repository system. Note that events which indicate the end of an
+ * action like {@link EventType#ARTIFACT_RESOLVED} are generally fired in both the success and the failure case. Use
+ * {@link #getException()} to check whether an event denotes success or failure.
+ * 
+ * @see RepositoryListener
+ * @see RepositoryEvent.Builder
+ */
+public final class RepositoryEvent
+{
+
+    /**
+     * The type of the repository event.
+     */
+    public enum EventType
+    {
+
+        /**
+         * @see RepositoryListener#artifactDescriptorInvalid(RepositoryEvent)
+         */
+        ARTIFACT_DESCRIPTOR_INVALID,
+
+        /**
+         * @see RepositoryListener#artifactDescriptorMissing(RepositoryEvent)
+         */
+        ARTIFACT_DESCRIPTOR_MISSING,
+
+        /**
+         * @see RepositoryListener#metadataInvalid(RepositoryEvent)
+         */
+        METADATA_INVALID,
+
+        /**
+         * @see RepositoryListener#artifactResolving(RepositoryEvent)
+         */
+        ARTIFACT_RESOLVING,
+
+        /**
+         * @see RepositoryListener#artifactResolved(RepositoryEvent)
+         */
+        ARTIFACT_RESOLVED,
+
+        /**
+         * @see RepositoryListener#metadataResolving(RepositoryEvent)
+         */
+        METADATA_RESOLVING,
+
+        /**
+         * @see RepositoryListener#metadataResolved(RepositoryEvent)
+         */
+        METADATA_RESOLVED,
+
+        /**
+         * @see RepositoryListener#artifactDownloading(RepositoryEvent)
+         */
+        ARTIFACT_DOWNLOADING,
+
+        /**
+         * @see RepositoryListener#artifactDownloaded(RepositoryEvent)
+         */
+        ARTIFACT_DOWNLOADED,
+
+        /**
+         * @see RepositoryListener#metadataDownloading(RepositoryEvent)
+         */
+        METADATA_DOWNLOADING,
+
+        /**
+         * @see RepositoryListener#metadataDownloaded(RepositoryEvent)
+         */
+        METADATA_DOWNLOADED,
+
+        /**
+         * @see RepositoryListener#artifactInstalling(RepositoryEvent)
+         */
+        ARTIFACT_INSTALLING,
+
+        /**
+         * @see RepositoryListener#artifactInstalled(RepositoryEvent)
+         */
+        ARTIFACT_INSTALLED,
+
+        /**
+         * @see RepositoryListener#metadataInstalling(RepositoryEvent)
+         */
+        METADATA_INSTALLING,
+
+        /**
+         * @see RepositoryListener#metadataInstalled(RepositoryEvent)
+         */
+        METADATA_INSTALLED,
+
+        /**
+         * @see RepositoryListener#artifactDeploying(RepositoryEvent)
+         */
+        ARTIFACT_DEPLOYING,
+
+        /**
+         * @see RepositoryListener#artifactDeployed(RepositoryEvent)
+         */
+        ARTIFACT_DEPLOYED,
+
+        /**
+         * @see RepositoryListener#metadataDeploying(RepositoryEvent)
+         */
+        METADATA_DEPLOYING,
+
+        /**
+         * @see RepositoryListener#metadataDeployed(RepositoryEvent)
+         */
+        METADATA_DEPLOYED
+
+    }
+
+    private final EventType type;
+
+    private final RepositorySystemSession session;
+
+    private final Artifact artifact;
+
+    private final Metadata metadata;
+
+    private final ArtifactRepository repository;
+
+    private final File file;
+
+    private final List<Exception> exceptions;
+
+    private final RequestTrace trace;
+
+    RepositoryEvent( Builder builder )
+    {
+        type = builder.type;
+        session = builder.session;
+        artifact = builder.artifact;
+        metadata = builder.metadata;
+        repository = builder.repository;
+        file = builder.file;
+        exceptions = builder.exceptions;
+        trace = builder.trace;
+    }
+
+    /**
+     * Gets the type of the event.
+     * 
+     * @return The type of the event, never {@code null}.
+     */
+    public EventType getType()
+    {
+        return type;
+    }
+
+    /**
+     * Gets the repository system session during which the event occurred.
+     * 
+     * @return The repository system session during which the event occurred, never {@code null}.
+     */
+    public RepositorySystemSession getSession()
+    {
+        return session;
+    }
+
+    /**
+     * Gets the artifact involved in the event (if any).
+     * 
+     * @return The involved artifact or {@code null} if none.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Gets the metadata involved in the event (if any).
+     * 
+     * @return The involved metadata or {@code null} if none.
+     */
+    public Metadata getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Gets the file involved in the event (if any).
+     * 
+     * @return The involved file or {@code null} if none.
+     */
+    public File getFile()
+    {
+        return file;
+    }
+
+    /**
+     * Gets the repository involved in the event (if any).
+     * 
+     * @return The involved repository or {@code null} if none.
+     */
+    public ArtifactRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Gets the exception that caused the event (if any). As a rule of thumb, an event accompanied by an exception
+     * indicates a failure of the corresponding action. If multiple exceptions occurred, this method returns the first
+     * exception.
+     * 
+     * @return The exception or {@code null} if none.
+     */
+    public Exception getException()
+    {
+        return exceptions.isEmpty() ? null : exceptions.get( 0 );
+    }
+
+    /**
+     * Gets the exceptions that caused the event (if any). As a rule of thumb, an event accompanied by exceptions
+     * indicates a failure of the corresponding action.
+     * 
+     * @return The exceptions, never {@code null}.
+     */
+    public List<Exception> getExceptions()
+    {
+        return exceptions;
+    }
+
+    /**
+     * Gets the trace information about the request during which the event occurred.
+     * 
+     * @return The trace information or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder buffer = new StringBuilder( 256 );
+        buffer.append( getType() );
+        if ( getArtifact() != null )
+        {
+            buffer.append( " " ).append( getArtifact() );
+        }
+        if ( getMetadata() != null )
+        {
+            buffer.append( " " ).append( getMetadata() );
+        }
+        if ( getFile() != null )
+        {
+            buffer.append( " (" ).append( getFile() ).append( ")" );
+        }
+        if ( getRepository() != null )
+        {
+            buffer.append( " @ " ).append( getRepository() );
+        }
+        return buffer.toString();
+    }
+
+    /**
+     * A builder to create events.
+     */
+    public static final class Builder
+    {
+
+        EventType type;
+
+        RepositorySystemSession session;
+
+        Artifact artifact;
+
+        Metadata metadata;
+
+        ArtifactRepository repository;
+
+        File file;
+
+        List<Exception> exceptions = Collections.emptyList();
+
+        RequestTrace trace;
+
+        /**
+         * Creates a new event builder for the specified session and event type.
+         * 
+         * @param session The repository system session, must not be {@code null}.
+         * @param type The type of the event, must not be {@code null}.
+         */
+        public Builder( RepositorySystemSession session, EventType type )
+        {
+            if ( session == null )
+            {
+                throw new IllegalArgumentException( "session not specified" );
+            }
+            this.session = session;
+            if ( type == null )
+            {
+                throw new IllegalArgumentException( "event type not specified" );
+            }
+            this.type = type;
+        }
+
+        /**
+         * Sets the artifact involved in the event.
+         * 
+         * @param artifact The involved artifact, may be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setArtifact( Artifact artifact )
+        {
+            this.artifact = artifact;
+            return this;
+        }
+
+        /**
+         * Sets the metadata involved in the event.
+         * 
+         * @param metadata The involved metadata, may be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setMetadata( Metadata metadata )
+        {
+            this.metadata = metadata;
+            return this;
+        }
+
+        /**
+         * Sets the repository involved in the event.
+         * 
+         * @param repository The involved repository, may be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setRepository( ArtifactRepository repository )
+        {
+            this.repository = repository;
+            return this;
+        }
+
+        /**
+         * Sets the file involved in the event.
+         * 
+         * @param file The involved file, may be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setFile( File file )
+        {
+            this.file = file;
+            return this;
+        }
+
+        /**
+         * Sets the exception causing the event.
+         * 
+         * @param exception The exception causing the event, may be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setException( Exception exception )
+        {
+            if ( exception != null )
+            {
+                this.exceptions = Collections.singletonList( exception );
+            }
+            else
+            {
+                this.exceptions = Collections.emptyList();
+            }
+            return this;
+        }
+
+        /**
+         * Sets the exceptions causing the event.
+         * 
+         * @param exceptions The exceptions causing the event, may be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setExceptions( List<Exception> exceptions )
+        {
+            if ( exceptions != null )
+            {
+                this.exceptions = exceptions;
+            }
+            else
+            {
+                this.exceptions = Collections.emptyList();
+            }
+            return this;
+        }
+
+        /**
+         * Sets the trace information about the request during which the event occurred.
+         * 
+         * @param trace The trace information, may be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setTrace( RequestTrace trace )
+        {
+            this.trace = trace;
+            return this;
+        }
+
+        /**
+         * Builds a new event from the current values of this builder. The state of the builder itself remains
+         * unchanged.
+         * 
+         * @return The event, never {@code null}.
+         */
+        public RepositoryEvent build()
+        {
+            return new RepositoryEvent( this );
+        }
+
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryException.java b/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryException.java
new file mode 100644 (file)
index 0000000..35f0cfd
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+/**
+ * The base class for exceptions thrown by the repository system. <em>Note:</em> Unless otherwise noted, instances of
+ * this class and its subclasses will not persist fields carrying extended error information during serialization.
+ */
+public class RepositoryException
+    extends Exception
+{
+
+    /**
+     * Creates a new exception with the specified detail message.
+     * 
+     * @param message The detail message, may be {@code null}.
+     */
+    public RepositoryException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * Creates a new exception with the specified detail message and cause.
+     * 
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public RepositoryException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    /**
+     * @noreference This method is not intended to be used by clients.
+     * @param prefix A message prefix for the cause.
+     * @param cause The error cause.
+     * @return The error message for the cause.
+     */
+    protected static String getMessage( String prefix, Throwable cause )
+    {
+        String msg = "";
+        if ( cause != null )
+        {
+            msg = cause.getMessage();
+            if ( msg == null || msg.length() <= 0 )
+            {
+                msg = cause.getClass().getSimpleName();
+            }
+            msg = prefix + msg;
+        }
+        return msg;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryListener.java b/org.argeo.slc.repo/src/org/eclipse/aether/RepositoryListener.java
new file mode 100644 (file)
index 0000000..5f83923
--- /dev/null
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+/**
+ * A listener being notified of events from the repository system. In general, the system sends events upon termination
+ * of an operation like {@link #artifactResolved(RepositoryEvent)} regardless whether it succeeded or failed so
+ * listeners need to inspect the event details carefully. Also, the listener may be called from an arbitrary thread.
+ * <em>Note:</em> Implementors are strongly advised to inherit from {@link AbstractRepositoryListener} instead of
+ * directly implementing this interface.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getRepositoryListener()
+ * @see org.eclipse.aether.transfer.TransferListener
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface RepositoryListener
+{
+
+    /**
+     * Notifies the listener of a syntactically or semantically invalid artifact descriptor.
+     * {@link RepositoryEvent#getArtifact()} indicates the artifact whose descriptor is invalid and
+     * {@link RepositoryEvent#getExceptions()} carries the encountered errors. Depending on the session's
+     * {@link org.eclipse.aether.resolution.ArtifactDescriptorPolicy}, the underlying repository operation might abort
+     * with an exception or ignore the invalid descriptor.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactDescriptorInvalid( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of a missing artifact descriptor. {@link RepositoryEvent#getArtifact()} indicates the
+     * artifact whose descriptor is missing. Depending on the session's
+     * {@link org.eclipse.aether.resolution.ArtifactDescriptorPolicy}, the underlying repository operation might abort
+     * with an exception or ignore the missing descriptor.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactDescriptorMissing( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of syntactically or semantically invalid metadata. {@link RepositoryEvent#getMetadata()}
+     * indicates the invalid metadata and {@link RepositoryEvent#getExceptions()} carries the encountered errors. The
+     * underlying repository operation might still succeed, depending on whether the metadata in question is actually
+     * needed to carry out the resolution process.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void metadataInvalid( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of an artifact that is about to be resolved. {@link RepositoryEvent#getArtifact()} denotes
+     * the artifact in question. Unlike the {@link #artifactDownloading(RepositoryEvent)} event, this event is fired
+     * regardless whether the artifact already exists locally or not.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactResolving( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of an artifact whose resolution has been completed, either successfully or not.
+     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
+     * {@link RepositoryEvent#getExceptions()} indicates whether the resolution succeeded or failed. Unlike the
+     * {@link #artifactDownloaded(RepositoryEvent)} event, this event is fired regardless whether the artifact already
+     * exists locally or not.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactResolved( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of some metadata that is about to be resolved. {@link RepositoryEvent#getMetadata()}
+     * denotes the metadata in question. Unlike the {@link #metadataDownloading(RepositoryEvent)} event, this event is
+     * fired regardless whether the metadata already exists locally or not.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void metadataResolving( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of some metadata whose resolution has been completed, either successfully or not.
+     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
+     * {@link RepositoryEvent#getExceptions()} indicates whether the resolution succeeded or failed. Unlike the
+     * {@link #metadataDownloaded(RepositoryEvent)} event, this event is fired regardless whether the metadata already
+     * exists locally or not.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void metadataResolved( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of an artifact that is about to be downloaded from a remote repository.
+     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
+     * {@link RepositoryEvent#getRepository()} the source repository. Unlike the
+     * {@link #artifactResolving(RepositoryEvent)} event, this event is only fired when the artifact does not already
+     * exist locally.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactDownloading( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of an artifact whose download has been completed, either successfully or not.
+     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
+     * {@link RepositoryEvent#getExceptions()} indicates whether the download succeeded or failed. Unlike the
+     * {@link #artifactResolved(RepositoryEvent)} event, this event is only fired when the artifact does not already
+     * exist locally.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactDownloaded( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of some metadata that is about to be downloaded from a remote repository.
+     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
+     * {@link RepositoryEvent#getRepository()} the source repository. Unlike the
+     * {@link #metadataResolving(RepositoryEvent)} event, this event is only fired when the metadata does not already
+     * exist locally.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void metadataDownloading( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of some metadata whose download has been completed, either successfully or not.
+     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
+     * {@link RepositoryEvent#getExceptions()} indicates whether the download succeeded or failed. Unlike the
+     * {@link #metadataResolved(RepositoryEvent)} event, this event is only fired when the metadata does not already
+     * exist locally.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void metadataDownloaded( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of an artifact that is about to be installed to the local repository.
+     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactInstalling( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of an artifact whose installation to the local repository has been completed, either
+     * successfully or not. {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
+     * {@link RepositoryEvent#getExceptions()} indicates whether the installation succeeded or failed.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactInstalled( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of some metadata that is about to be installed to the local repository.
+     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void metadataInstalling( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of some metadata whose installation to the local repository has been completed, either
+     * successfully or not. {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
+     * {@link RepositoryEvent#getExceptions()} indicates whether the installation succeeded or failed.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void metadataInstalled( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of an artifact that is about to be uploaded to a remote repository.
+     * {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
+     * {@link RepositoryEvent#getRepository()} the destination repository.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactDeploying( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of an artifact whose upload to a remote repository has been completed, either successfully
+     * or not. {@link RepositoryEvent#getArtifact()} denotes the artifact in question and
+     * {@link RepositoryEvent#getExceptions()} indicates whether the upload succeeded or failed.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void artifactDeployed( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of some metadata that is about to be uploaded to a remote repository.
+     * {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
+     * {@link RepositoryEvent#getRepository()} the destination repository.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void metadataDeploying( RepositoryEvent event );
+
+    /**
+     * Notifies the listener of some metadata whose upload to a remote repository has been completed, either
+     * successfully or not. {@link RepositoryEvent#getMetadata()} denotes the metadata in question and
+     * {@link RepositoryEvent#getExceptions()} indicates whether the upload succeeded or failed.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void metadataDeployed( RepositoryEvent event );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystem.java b/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystem.java
new file mode 100644 (file)
index 0000000..debdb7d
--- /dev/null
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.collection.CollectResult;
+import org.eclipse.aether.collection.DependencyCollectionException;
+import org.eclipse.aether.deployment.DeployRequest;
+import org.eclipse.aether.deployment.DeployResult;
+import org.eclipse.aether.deployment.DeploymentException;
+import org.eclipse.aether.installation.InstallRequest;
+import org.eclipse.aether.installation.InstallResult;
+import org.eclipse.aether.installation.InstallationException;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactDescriptorException;
+import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
+import org.eclipse.aether.resolution.ArtifactDescriptorResult;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.resolution.DependencyRequest;
+import org.eclipse.aether.resolution.DependencyResolutionException;
+import org.eclipse.aether.resolution.DependencyResult;
+import org.eclipse.aether.resolution.MetadataRequest;
+import org.eclipse.aether.resolution.MetadataResult;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResolutionException;
+import org.eclipse.aether.resolution.VersionRangeResult;
+import org.eclipse.aether.resolution.VersionRequest;
+import org.eclipse.aether.resolution.VersionResolutionException;
+import org.eclipse.aether.resolution.VersionResult;
+
+/**
+ * The main entry point to the repository system and its functionality. Note that obtaining a concrete implementation of
+ * this interface (e.g. via dependency injection, service locator, etc.) is dependent on the application and its
+ * specific needs, please consult the online documentation for examples and directions on booting the system.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface RepositorySystem
+{
+
+    /**
+     * Expands a version range to a list of matching versions, in ascending order. For example, resolves "[3.8,4.0)" to
+     * "3.8", "3.8.1", "3.8.2". Note that the returned list of versions is only dependent on the configured repositories
+     * and their contents, the list is not processed by the {@link RepositorySystemSession#getVersionFilter() session's
+     * version filter}.
+     * <p>
+     * The supplied request may also refer to a single concrete version rather than a version range. In this case
+     * though, the result contains simply the (parsed) input version, regardless of the repositories and their contents.
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param request The version range request, must not be {@code null}.
+     * @return The version range result, never {@code null}.
+     * @throws VersionRangeResolutionException If the requested range could not be parsed. Note that an empty range does
+     *             not raise an exception.
+     * @see #newResolutionRepositories(RepositorySystemSession, List)
+     */
+    VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
+        throws VersionRangeResolutionException;
+
+    /**
+     * Resolves an artifact's meta version (if any) to a concrete version. For example, resolves "1.0-SNAPSHOT" to
+     * "1.0-20090208.132618-23".
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param request The version request, must not be {@code null}.
+     * @return The version result, never {@code null}.
+     * @throws VersionResolutionException If the metaversion could not be resolved.
+     * @see #newResolutionRepositories(RepositorySystemSession, List)
+     */
+    VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
+        throws VersionResolutionException;
+
+    /**
+     * Gets information about an artifact like its direct dependencies and potential relocations.
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param request The descriptor request, must not be {@code null}.
+     * @return The descriptor result, never {@code null}.
+     * @throws ArtifactDescriptorException If the artifact descriptor could not be read.
+     * @see RepositorySystemSession#getArtifactDescriptorPolicy()
+     * @see #newResolutionRepositories(RepositorySystemSession, List)
+     */
+    ArtifactDescriptorResult readArtifactDescriptor( RepositorySystemSession session, ArtifactDescriptorRequest request )
+        throws ArtifactDescriptorException;
+
+    /**
+     * Collects the transitive dependencies of an artifact and builds a dependency graph. Note that this operation is
+     * only concerned about determining the coordinates of the transitive dependencies. To also resolve the actual
+     * artifact files, use {@link #resolveDependencies(RepositorySystemSession, DependencyRequest)}.
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param request The collection request, must not be {@code null}.
+     * @return The collection result, never {@code null}.
+     * @throws DependencyCollectionException If the dependency tree could not be built.
+     * @see RepositorySystemSession#getDependencyTraverser()
+     * @see RepositorySystemSession#getDependencyManager()
+     * @see RepositorySystemSession#getDependencySelector()
+     * @see RepositorySystemSession#getVersionFilter()
+     * @see RepositorySystemSession#getDependencyGraphTransformer()
+     * @see #newResolutionRepositories(RepositorySystemSession, List)
+     */
+    CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request )
+        throws DependencyCollectionException;
+
+    /**
+     * Collects and resolves the transitive dependencies of an artifact. This operation is essentially a combination of
+     * {@link #collectDependencies(RepositorySystemSession, CollectRequest)} and
+     * {@link #resolveArtifacts(RepositorySystemSession, Collection)}.
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param request The dependency request, must not be {@code null}.
+     * @return The dependency result, never {@code null}.
+     * @throws DependencyResolutionException If the dependency tree could not be built or any dependency artifact could
+     *             not be resolved.
+     * @see #newResolutionRepositories(RepositorySystemSession, List)
+     */
+    DependencyResult resolveDependencies( RepositorySystemSession session, DependencyRequest request )
+        throws DependencyResolutionException;
+
+    /**
+     * Resolves the path for an artifact. The artifact will be downloaded to the local repository if necessary. An
+     * artifact that is already resolved will be skipped and is not re-resolved. In general, callers must not assume any
+     * relationship between an artifact's resolved filename and its coordinates. Note that this method assumes that any
+     * relocations have already been processed.
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param request The resolution request, must not be {@code null}.
+     * @return The resolution result, never {@code null}.
+     * @throws ArtifactResolutionException If the artifact could not be resolved.
+     * @see Artifact#getFile()
+     * @see #newResolutionRepositories(RepositorySystemSession, List)
+     */
+    ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request )
+        throws ArtifactResolutionException;
+
+    /**
+     * Resolves the paths for a collection of artifacts. Artifacts will be downloaded to the local repository if
+     * necessary. Artifacts that are already resolved will be skipped and are not re-resolved. In general, callers must
+     * not assume any relationship between an artifact's filename and its coordinates. Note that this method assumes
+     * that any relocations have already been processed.
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param requests The resolution requests, must not be {@code null}.
+     * @return The resolution results (in request order), never {@code null}.
+     * @throws ArtifactResolutionException If any artifact could not be resolved.
+     * @see Artifact#getFile()
+     * @see #newResolutionRepositories(RepositorySystemSession, List)
+     */
+    List<ArtifactResult> resolveArtifacts( RepositorySystemSession session,
+                                           Collection<? extends ArtifactRequest> requests )
+        throws ArtifactResolutionException;
+
+    /**
+     * Resolves the paths for a collection of metadata. Metadata will be downloaded to the local repository if
+     * necessary, e.g. because it hasn't been cached yet or the cache is deemed outdated.
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param requests The resolution requests, must not be {@code null}.
+     * @return The resolution results (in request order), never {@code null}.
+     * @see Metadata#getFile()
+     * @see #newResolutionRepositories(RepositorySystemSession, List)
+     */
+    List<MetadataResult> resolveMetadata( RepositorySystemSession session,
+                                          Collection<? extends MetadataRequest> requests );
+
+    /**
+     * Installs a collection of artifacts and their accompanying metadata to the local repository.
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param request The installation request, must not be {@code null}.
+     * @return The installation result, never {@code null}.
+     * @throws InstallationException If any artifact/metadata from the request could not be installed.
+     */
+    InstallResult install( RepositorySystemSession session, InstallRequest request )
+        throws InstallationException;
+
+    /**
+     * Uploads a collection of artifacts and their accompanying metadata to a remote repository.
+     * 
+     * @param session The repository session, must not be {@code null}.
+     * @param request The deployment request, must not be {@code null}.
+     * @return The deployment result, never {@code null}.
+     * @throws DeploymentException If any artifact/metadata from the request could not be deployed.
+     * @see #newDeploymentRepository(RepositorySystemSession, RemoteRepository)
+     */
+    DeployResult deploy( RepositorySystemSession session, DeployRequest request )
+        throws DeploymentException;
+
+    /**
+     * Creates a new manager for the specified local repository. If the specified local repository has no type, the
+     * default local repository type of the system will be used. <em>Note:</em> It is expected that this method
+     * invocation is one of the last steps of setting up a new session, in particular any configuration properties
+     * should have been set already.
+     * 
+     * @param session The repository system session from which to configure the manager, must not be {@code null}.
+     * @param localRepository The local repository to create a manager for, must not be {@code null}.
+     * @return The local repository manager, never {@code null}.
+     * @throws IllegalArgumentException If the specified repository type is not recognized or no base directory is
+     *             given.
+     */
+    LocalRepositoryManager newLocalRepositoryManager( RepositorySystemSession session, LocalRepository localRepository );
+
+    /**
+     * Creates a new synchronization context.
+     * 
+     * @param session The repository session during which the context will be used, must not be {@code null}.
+     * @param shared A flag indicating whether access to the artifacts/metadata associated with the new context can be
+     *            shared among concurrent readers or whether access needs to be exclusive to the calling thread.
+     * @return The synchronization context, never {@code null}.
+     */
+    SyncContext newSyncContext( RepositorySystemSession session, boolean shared );
+
+    /**
+     * Forms remote repositories suitable for artifact resolution by applying the session's authentication selector and
+     * similar network configuration to the given repository prototypes. As noted for
+     * {@link RepositorySystemSession#getAuthenticationSelector()} etc. the remote repositories passed to e.g.
+     * {@link #resolveArtifact(RepositorySystemSession, ArtifactRequest) resolveArtifact()} are used as is and expected
+     * to already carry any required authentication or proxy configuration. This method can be used to apply the
+     * authentication/proxy configuration from a session to a bare repository definition to obtain the complete
+     * repository definition for use in the resolution request.
+     * 
+     * @param session The repository system session from which to configure the repositories, must not be {@code null}.
+     * @param repositories The repository prototypes from which to derive the resolution repositories, must not be
+     *            {@code null} or contain {@code null} elements.
+     * @return The resolution repositories, never {@code null}. Note that there is generally no 1:1 relationship of the
+     *         obtained repositories to the original inputs due to mirror selection potentially aggregating multiple
+     *         repositories.
+     * @see #newDeploymentRepository(RepositorySystemSession, RemoteRepository)
+     */
+    List<RemoteRepository> newResolutionRepositories( RepositorySystemSession session,
+                                                      List<RemoteRepository> repositories );
+
+    /**
+     * Forms a remote repository suitable for artifact deployment by applying the session's authentication selector and
+     * similar network configuration to the given repository prototype. As noted for
+     * {@link RepositorySystemSession#getAuthenticationSelector()} etc. the remote repository passed to
+     * {@link #deploy(RepositorySystemSession, DeployRequest) deploy()} is used as is and expected to already carry any
+     * required authentication or proxy configuration. This method can be used to apply the authentication/proxy
+     * configuration from a session to a bare repository definition to obtain the complete repository definition for use
+     * in the deploy request.
+     * 
+     * @param session The repository system session from which to configure the repository, must not be {@code null}.
+     * @param repository The repository prototype from which to derive the deployment repository, must not be
+     *            {@code null}.
+     * @return The deployment repository, never {@code null}.
+     * @see #newResolutionRepositories(RepositorySystemSession, List)
+     */
+    RemoteRepository newDeploymentRepository( RepositorySystemSession session, RemoteRepository repository );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystemSession.java b/org.argeo.slc.repo/src/org/eclipse/aether/RepositorySystemSession.java
new file mode 100644 (file)
index 0000000..96f51c1
--- /dev/null
@@ -0,0 +1,254 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+import java.util.Map;
+
+import org.eclipse.aether.artifact.ArtifactTypeRegistry;
+import org.eclipse.aether.collection.DependencyGraphTransformer;
+import org.eclipse.aether.collection.DependencyManager;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.collection.DependencyTraverser;
+import org.eclipse.aether.collection.VersionFilter;
+import org.eclipse.aether.repository.AuthenticationSelector;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
+import org.eclipse.aether.repository.MirrorSelector;
+import org.eclipse.aether.repository.ProxySelector;
+import org.eclipse.aether.repository.RepositoryPolicy;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
+import org.eclipse.aether.resolution.ResolutionErrorPolicy;
+import org.eclipse.aether.transfer.TransferListener;
+
+/**
+ * Defines settings and components that control the repository system. Once initialized, the session object itself is
+ * supposed to be immutable and hence can safely be shared across an entire application and any concurrent threads
+ * reading it. Components that wish to tweak some aspects of an existing session should use the copy constructor of
+ * {@link DefaultRepositorySystemSession} and its mutators to derive a custom session.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface RepositorySystemSession
+{
+
+    /**
+     * Indicates whether the repository system operates in offline mode and avoids/refuses any access to remote
+     * repositories.
+     * 
+     * @return {@code true} if the repository system is in offline mode, {@code false} otherwise.
+     */
+    boolean isOffline();
+
+    /**
+     * Indicates whether repositories declared in artifact descriptors should be ignored during transitive dependency
+     * collection. If enabled, only the repositories originally provided with the collect request will be considered.
+     * 
+     * @return {@code true} if additional repositories from artifact descriptors are ignored, {@code false} to merge
+     *         those with the originally specified repositories.
+     */
+    boolean isIgnoreArtifactDescriptorRepositories();
+
+    /**
+     * Gets the policy which controls whether resolutions errors from remote repositories should be cached.
+     * 
+     * @return The resolution error policy for this session or {@code null} if resolution errors should generally not be
+     *         cached.
+     */
+    ResolutionErrorPolicy getResolutionErrorPolicy();
+
+    /**
+     * Gets the policy which controls how errors related to reading artifact descriptors should be handled.
+     * 
+     * @return The descriptor error policy for this session or {@code null} if descriptor errors should generally not be
+     *         tolerated.
+     */
+    ArtifactDescriptorPolicy getArtifactDescriptorPolicy();
+
+    /**
+     * Gets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
+     * repositories being used for resolution.
+     * 
+     * @return The global checksum policy or {@code null}/empty if not set and the per-repository policies apply.
+     * @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
+     * @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
+     * @see RepositoryPolicy#CHECKSUM_POLICY_WARN
+     */
+    String getChecksumPolicy();
+
+    /**
+     * Gets the global update policy. If set, the global update policy overrides the update policies of the remote
+     * repositories being used for resolution.
+     * 
+     * @return The global update policy or {@code null}/empty if not set and the per-repository policies apply.
+     * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
+     * @see RepositoryPolicy#UPDATE_POLICY_DAILY
+     * @see RepositoryPolicy#UPDATE_POLICY_NEVER
+     */
+    String getUpdatePolicy();
+
+    /**
+     * Gets the local repository used during this session. This is a convenience method for
+     * {@link LocalRepositoryManager#getRepository()}.
+     * 
+     * @return The local repository being during this session, never {@code null}.
+     */
+    LocalRepository getLocalRepository();
+
+    /**
+     * Gets the local repository manager used during this session.
+     * 
+     * @return The local repository manager used during this session, never {@code null}.
+     */
+    LocalRepositoryManager getLocalRepositoryManager();
+
+    /**
+     * Gets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
+     * to resolve artifacts.
+     * 
+     * @return The workspace reader for this session or {@code null} if none.
+     */
+    WorkspaceReader getWorkspaceReader();
+
+    /**
+     * Gets the listener being notified of actions in the repository system.
+     * 
+     * @return The repository listener or {@code null} if none.
+     */
+    RepositoryListener getRepositoryListener();
+
+    /**
+     * Gets the listener being notified of uploads/downloads by the repository system.
+     * 
+     * @return The transfer listener or {@code null} if none.
+     */
+    TransferListener getTransferListener();
+
+    /**
+     * Gets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
+     * collected from the runtime environment like {@link System#getProperties()} and environment variables.
+     * 
+     * @return The (read-only) system properties, never {@code null}.
+     */
+    Map<String, String> getSystemProperties();
+
+    /**
+     * Gets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
+     * system properties but are set on the discretion of the user and hence are considered of higher priority than
+     * system properties.
+     * 
+     * @return The (read-only) user properties, never {@code null}.
+     */
+    Map<String, String> getUserProperties();
+
+    /**
+     * Gets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
+     * connector-specific behavior, etc.)
+     * 
+     * @return The (read-only) configuration properties, never {@code null}.
+     * @see ConfigurationProperties
+     */
+    Map<String, Object> getConfigProperties();
+
+    /**
+     * Gets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
+     * not used for remote repositories which are passed as request parameters to the repository system, those
+     * repositories are supposed to denote the effective repositories.
+     * 
+     * @return The mirror selector to use, never {@code null}.
+     * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
+     */
+    MirrorSelector getMirrorSelector();
+
+    /**
+     * Gets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
+     * not used for remote repositories which are passed as request parameters to the repository system, those
+     * repositories are supposed to have their proxy (if any) already set.
+     * 
+     * @return The proxy selector to use, never {@code null}.
+     * @see org.eclipse.aether.repository.RemoteRepository#getProxy()
+     * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
+     */
+    ProxySelector getProxySelector();
+
+    /**
+     * Gets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
+     * selector is not used for remote repositories which are passed as request parameters to the repository system,
+     * those repositories are supposed to have their authentication (if any) already set.
+     * 
+     * @return The authentication selector to use, never {@code null}.
+     * @see org.eclipse.aether.repository.RemoteRepository#getAuthentication()
+     * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
+     */
+    AuthenticationSelector getAuthenticationSelector();
+
+    /**
+     * Gets the registry of artifact types recognized by this session, for instance when processing artifact
+     * descriptors.
+     * 
+     * @return The artifact type registry, never {@code null}.
+     */
+    ArtifactTypeRegistry getArtifactTypeRegistry();
+
+    /**
+     * Gets the dependency traverser to use for building dependency graphs.
+     * 
+     * @return The dependency traverser to use for building dependency graphs or {@code null} if dependencies are
+     *         unconditionally traversed.
+     */
+    DependencyTraverser getDependencyTraverser();
+
+    /**
+     * Gets the dependency manager to use for building dependency graphs.
+     * 
+     * @return The dependency manager to use for building dependency graphs or {@code null} if dependency management is
+     *         not performed.
+     */
+    DependencyManager getDependencyManager();
+
+    /**
+     * Gets the dependency selector to use for building dependency graphs.
+     * 
+     * @return The dependency selector to use for building dependency graphs or {@code null} if dependencies are
+     *         unconditionally included.
+     */
+    DependencySelector getDependencySelector();
+
+    /**
+     * Gets the version filter to use for building dependency graphs.
+     * 
+     * @return The version filter to use for building dependency graphs or {@code null} if versions aren't filtered.
+     */
+    VersionFilter getVersionFilter();
+
+    /**
+     * Gets the dependency graph transformer to use for building dependency graphs.
+     * 
+     * @return The dependency graph transformer to use for building dependency graphs or {@code null} if none.
+     */
+    DependencyGraphTransformer getDependencyGraphTransformer();
+
+    /**
+     * Gets the custom data associated with this session.
+     * 
+     * @return The session data, never {@code null}.
+     */
+    SessionData getData();
+
+    /**
+     * Gets the cache the repository system may use to save data for future reuse during the session.
+     * 
+     * @return The repository cache or {@code null} if none.
+     */
+    RepositoryCache getCache();
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/RequestTrace.java b/org.argeo.slc.repo/src/org/eclipse/aether/RequestTrace.java
new file mode 100644 (file)
index 0000000..c6afa8e
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+/**
+ * A trace of nested requests that are performed by the repository system. This trace information can be used to
+ * correlate repository events with higher level operations in the application code that eventually caused the events. A
+ * single trace can carry an arbitrary object as data which is meant to describe a request/operation that is currently
+ * executed. For call hierarchies within the repository system itself, this data will usually be the {@code *Request}
+ * object that is currently processed. When invoking methods on the repository system, client code may provide a request
+ * trace that has been prepopulated with whatever data is useful for the application to indicate its state for later
+ * evaluation when processing the repository events.
+ * 
+ * @see RepositoryEvent#getTrace()
+ */
+public class RequestTrace
+{
+
+    private final RequestTrace parent;
+
+    private final Object data;
+
+    /**
+     * Creates a child of the specified request trace. This method is basically a convenience that will invoke
+     * {@link RequestTrace#newChild(Object) parent.newChild()} when the specified parent trace is not {@code null} or
+     * otherwise instantiante a new root trace.
+     * 
+     * @param parent The parent request trace, may be {@code null}.
+     * @param data The data to associate with the child trace, may be {@code null}.
+     * @return The child trace, never {@code null}.
+     */
+    public static RequestTrace newChild( RequestTrace parent, Object data )
+    {
+        if ( parent == null )
+        {
+            return new RequestTrace( data );
+        }
+        return parent.newChild( data );
+    }
+
+    /**
+     * Creates a new root trace with the specified data.
+     * 
+     * @param data The data to associate with the trace, may be {@code null}.
+     */
+    public RequestTrace( Object data )
+    {
+        this( null, data );
+    }
+
+    /**
+     * Creates a new trace with the specified data and parent
+     * 
+     * @param parent The parent trace, may be {@code null} for a root trace.
+     * @param data The data to associate with the trace, may be {@code null}.
+     */
+    protected RequestTrace( RequestTrace parent, Object data )
+    {
+        this.parent = parent;
+        this.data = data;
+    }
+
+    /**
+     * Gets the data associated with this trace.
+     * 
+     * @return The data associated with this trace or {@code null} if none.
+     */
+    public final Object getData()
+    {
+        return data;
+    }
+
+    /**
+     * Gets the parent of this trace.
+     * 
+     * @return The parent of this trace or {@code null} if this is the root of the trace stack.
+     */
+    public final RequestTrace getParent()
+    {
+        return parent;
+    }
+
+    /**
+     * Creates a new child of this trace.
+     * 
+     * @param data The data to associate with the child, may be {@code null}.
+     * @return The child trace, never {@code null}.
+     */
+    public RequestTrace newChild( Object data )
+    {
+        return new RequestTrace( this, data );
+    }
+
+    @Override
+    public String toString()
+    {
+        return String.valueOf( getData() );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/SessionData.java b/org.argeo.slc.repo/src/org/eclipse/aether/SessionData.java
new file mode 100644 (file)
index 0000000..92930e7
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+/**
+ * A container for data that is specific to a repository system session. Both components within the repository system
+ * and clients of the system may use this storage to associate arbitrary data with a session.
+ * <p>
+ * Unlike a cache, this session data is not subject to purging. For this same reason, session data should also not be
+ * abused as a cache (i.e. for storing values that can be re-calculated) to avoid memory exhaustion.
+ * <p>
+ * <strong>Note:</strong> Actual implementations must be thread-safe.
+ * 
+ * @see RepositorySystemSession#getData()
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface SessionData
+{
+
+    /**
+     * Associates the specified session data with the given key.
+     * 
+     * @param key The key under which to store the session data, must not be {@code null}.
+     * @param value The data to associate with the key, may be {@code null} to remove the mapping.
+     */
+    void set( Object key, Object value );
+
+    /**
+     * Associates the specified session data with the given key if the key is currently mapped to the given value. This
+     * method provides an atomic compare-and-update of some key's value.
+     * 
+     * @param key The key under which to store the session data, must not be {@code null}.
+     * @param oldValue The expected data currently associated with the key, may be {@code null}.
+     * @param newValue The data to associate with the key, may be {@code null} to remove the mapping.
+     * @return {@code true} if the key mapping was successfully updated from the old value to the new value,
+     *         {@code false} if the current key mapping didn't match the expected value and was not updated.
+     */
+    boolean set( Object key, Object oldValue, Object newValue );
+
+    /**
+     * Gets the session data associated with the specified key.
+     * 
+     * @param key The key for which to retrieve the session data, must not be {@code null}.
+     * @return The session data associated with the key or {@code null} if none.
+     */
+    Object get( Object key );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/SyncContext.java b/org.argeo.slc.repo/src/org/eclipse/aether/SyncContext.java
new file mode 100644 (file)
index 0000000..a05d512
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether;
+
+import java.io.Closeable;
+import java.util.Collection;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.metadata.Metadata;
+
+/**
+ * A synchronization context used to coordinate concurrent access to artifacts or metadatas. The typical usage of a
+ * synchronization context looks like this:
+ * 
+ * <pre>
+ * SyncContext syncContext = repositorySystem.newSyncContext( ... );
+ * try {
+ *     syncContext.acquire( artifacts, metadatas );
+ *     // work with the artifacts and metadatas
+ * } finally {
+ *     syncContext.close();
+ * }
+ * </pre>
+ * 
+ * Within one thread, synchronization contexts may be nested which can naturally happen in a hierarchy of method calls.
+ * The nested synchronization contexts may also acquire overlapping sets of artifacts/metadatas as long as the following
+ * conditions are met. If the outer-most context holding a particular resource is exclusive, that resource can be
+ * reacquired in any nested context. If however the outer-most context is shared, the resource may only be reacquired by
+ * nested contexts if these are also shared.
+ * <p>
+ * A synchronization context is meant to be utilized by only one thread and as such is not thread-safe.
+ * <p>
+ * Note that the level of actual synchronization is subject to the implementation and might range from OS-wide to none.
+ * 
+ * @see RepositorySystem#newSyncContext(RepositorySystemSession, boolean)
+ */
+public interface SyncContext
+    extends Closeable
+{
+
+    /**
+     * Acquires synchronized access to the specified artifacts and metadatas. The invocation will potentially block
+     * until all requested resources can be acquired by the calling thread. Acquiring resources that are already
+     * acquired by this synchronization context has no effect. Please also see the class-level documentation for
+     * information regarding reentrancy. The method may be invoked multiple times on a synchronization context until all
+     * desired resources have been acquired.
+     * 
+     * @param artifacts The artifacts to acquire, may be {@code null} or empty if none.
+     * @param metadatas The metadatas to acquire, may be {@code null} or empty if none.
+     */
+    void acquire( Collection<? extends Artifact> artifacts, Collection<? extends Metadata> metadatas );
+
+    /**
+     * Releases all previously acquired artifacts/metadatas. If no resources have been acquired before or if this
+     * synchronization context has already been closed, this method does nothing.
+     */
+    void close();
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/artifact/AbstractArtifact.java b/org.argeo.slc.repo/src/org/eclipse/aether/artifact/AbstractArtifact.java
new file mode 100644 (file)
index 0000000..2944ff8
--- /dev/null
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.artifact;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A skeleton class for artifacts.
+ */
+public abstract class AbstractArtifact
+    implements Artifact
+{
+
+    private static final String SNAPSHOT = "SNAPSHOT";
+
+    private static final Pattern SNAPSHOT_TIMESTAMP = Pattern.compile( "^(.*-)?([0-9]{8}\\.[0-9]{6}-[0-9]+)$" );
+
+    public boolean isSnapshot()
+    {
+        return isSnapshot( getVersion() );
+    }
+
+    private static boolean isSnapshot( String version )
+    {
+        return version.endsWith( SNAPSHOT ) || SNAPSHOT_TIMESTAMP.matcher( version ).matches();
+    }
+
+    public String getBaseVersion()
+    {
+        return toBaseVersion( getVersion() );
+    }
+
+    private static String toBaseVersion( String version )
+    {
+        String baseVersion;
+
+        if ( version == null )
+        {
+            baseVersion = version;
+        }
+        else if ( version.startsWith( "[" ) || version.startsWith( "(" ) )
+        {
+            baseVersion = version;
+        }
+        else
+        {
+            Matcher m = SNAPSHOT_TIMESTAMP.matcher( version );
+            if ( m.matches() )
+            {
+                if ( m.group( 1 ) != null )
+                {
+                    baseVersion = m.group( 1 ) + SNAPSHOT;
+                }
+                else
+                {
+                    baseVersion = SNAPSHOT;
+                }
+            }
+            else
+            {
+                baseVersion = version;
+            }
+        }
+
+        return baseVersion;
+    }
+
+    /**
+     * Creates a new artifact with the specified coordinates, properties and file.
+     * 
+     * @param version The version of the artifact, may be {@code null}.
+     * @param properties The properties of the artifact, may be {@code null} if none. The method may assume immutability
+     *            of the supplied map, i.e. need not copy it.
+     * @param file The resolved file of the artifact, may be {@code null}.
+     * @return The new artifact instance, never {@code null}.
+     */
+    private Artifact newInstance( String version, Map<String, String> properties, File file )
+    {
+        return new DefaultArtifact( getGroupId(), getArtifactId(), getClassifier(), getExtension(), version, file,
+                                    properties );
+    }
+
+    public Artifact setVersion( String version )
+    {
+        String current = getVersion();
+        if ( current.equals( version ) || ( version == null && current.length() <= 0 ) )
+        {
+            return this;
+        }
+        return newInstance( version, getProperties(), getFile() );
+    }
+
+    public Artifact setFile( File file )
+    {
+        File current = getFile();
+        if ( ( current == null ) ? file == null : current.equals( file ) )
+        {
+            return this;
+        }
+        return newInstance( getVersion(), getProperties(), file );
+    }
+
+    public Artifact setProperties( Map<String, String> properties )
+    {
+        Map<String, String> current = getProperties();
+        if ( current.equals( properties ) || ( properties == null && current.isEmpty() ) )
+        {
+            return this;
+        }
+        return newInstance( getVersion(), copyProperties( properties ), getFile() );
+    }
+
+    public String getProperty( String key, String defaultValue )
+    {
+        String value = getProperties().get( key );
+        return ( value != null ) ? value : defaultValue;
+    }
+
+    /**
+     * Copies the specified artifact properties. This utility method should be used when creating new artifact instances
+     * with caller-supplied properties.
+     * 
+     * @param properties The properties to copy, may be {@code null}.
+     * @return The copied and read-only properties, never {@code null}.
+     */
+    protected static Map<String, String> copyProperties( Map<String, String> properties )
+    {
+        if ( properties != null && !properties.isEmpty() )
+        {
+            return Collections.unmodifiableMap( new HashMap<String, String>( properties ) );
+        }
+        else
+        {
+            return Collections.emptyMap();
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder buffer = new StringBuilder( 128 );
+        buffer.append( getGroupId() );
+        buffer.append( ':' ).append( getArtifactId() );
+        buffer.append( ':' ).append( getExtension() );
+        if ( getClassifier().length() > 0 )
+        {
+            buffer.append( ':' ).append( getClassifier() );
+        }
+        buffer.append( ':' ).append( getVersion() );
+        return buffer.toString();
+    }
+
+    /**
+     * Compares this artifact with the specified object.
+     * 
+     * @param obj The object to compare this artifact against, may be {@code null}.
+     * @return {@code true} if and only if the specified object is another {@link Artifact} with equal coordinates,
+     *         properties and file, {@code false} otherwise.
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+        else if ( !( obj instanceof Artifact ) )
+        {
+            return false;
+        }
+
+        Artifact that = (Artifact) obj;
+
+        return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() )
+            && getVersion().equals( that.getVersion() ) && getExtension().equals( that.getExtension() )
+            && getClassifier().equals( that.getClassifier() ) && eq( getFile(), that.getFile() )
+            && getProperties().equals( that.getProperties() );
+    }
+
+    private static <T> boolean eq( T s1, T s2 )
+    {
+        return s1 != null ? s1.equals( s2 ) : s2 == null;
+    }
+
+    /**
+     * Returns a hash code for this artifact.
+     * 
+     * @return A hash code for the artifact.
+     */
+    @Override
+    public int hashCode()
+    {
+        int hash = 17;
+        hash = hash * 31 + getGroupId().hashCode();
+        hash = hash * 31 + getArtifactId().hashCode();
+        hash = hash * 31 + getExtension().hashCode();
+        hash = hash * 31 + getClassifier().hashCode();
+        hash = hash * 31 + getVersion().hashCode();
+        hash = hash * 31 + hash( getFile() );
+        return hash;
+    }
+
+    private static int hash( Object obj )
+    {
+        return ( obj != null ) ? obj.hashCode() : 0;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/artifact/Artifact.java b/org.argeo.slc.repo/src/org/eclipse/aether/artifact/Artifact.java
new file mode 100644 (file)
index 0000000..5eef695
--- /dev/null
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.artifact;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ * A specific artifact. In a nutshell, an artifact has identifying coordinates and optionally a file that denotes its
+ * data. <em>Note:</em> Artifact instances are supposed to be immutable, e.g. any exposed mutator method returns a new
+ * artifact instance and leaves the original instance unchanged. <em>Note:</em> Implementors are strongly advised to
+ * inherit from {@link AbstractArtifact} instead of directly implementing this interface.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface Artifact
+{
+
+    /**
+     * Gets the group identifier of this artifact, for example "org.apache.maven".
+     * 
+     * @return The group identifier, never {@code null}.
+     */
+    String getGroupId();
+
+    /**
+     * Gets the artifact identifier of this artifact, for example "maven-model".
+     * 
+     * @return The artifact identifier, never {@code null}.
+     */
+    String getArtifactId();
+
+    /**
+     * Gets the version of this artifact, for example "1.0-20100529-1213". Note that in case of meta versions like
+     * "1.0-SNAPSHOT", the artifact's version depends on the state of the artifact. Artifacts that have been resolved or
+     * deployed will usually have the meta version expanded.
+     * 
+     * @return The version, never {@code null}.
+     */
+    String getVersion();
+
+    /**
+     * Sets the version of the artifact.
+     * 
+     * @param version The version of this artifact, may be {@code null} or empty.
+     * @return The new artifact, never {@code null}.
+     */
+    Artifact setVersion( String version );
+
+    /**
+     * Gets the base version of this artifact, for example "1.0-SNAPSHOT". In contrast to the {@link #getVersion()}, the
+     * base version will always refer to the unresolved meta version.
+     * 
+     * @return The base version, never {@code null}.
+     */
+    String getBaseVersion();
+
+    /**
+     * Determines whether this artifact uses a snapshot version.
+     * 
+     * @return {@code true} if the artifact is a snapshot, {@code false} otherwise.
+     */
+    boolean isSnapshot();
+
+    /**
+     * Gets the classifier of this artifact, for example "sources".
+     * 
+     * @return The classifier or an empty string if none, never {@code null}.
+     */
+    String getClassifier();
+
+    /**
+     * Gets the (file) extension of this artifact, for example "jar" or "tar.gz".
+     * 
+     * @return The file extension (without leading period), never {@code null}.
+     */
+    String getExtension();
+
+    /**
+     * Gets the file of this artifact. Note that only resolved artifacts have a file associated with them. In general,
+     * callers must not assume any relationship between an artifact's filename and its coordinates.
+     * 
+     * @return The file or {@code null} if the artifact isn't resolved.
+     */
+    File getFile();
+
+    /**
+     * Sets the file of the artifact.
+     * 
+     * @param file The file of the artifact, may be {@code null}
+     * @return The new artifact, never {@code null}.
+     */
+    Artifact setFile( File file );
+
+    /**
+     * Gets the specified property.
+     * 
+     * @param key The name of the property, must not be {@code null}.
+     * @param defaultValue The default value to return in case the property is not set, may be {@code null}.
+     * @return The requested property value or {@code null} if the property is not set and no default value was
+     *         provided.
+     * @see ArtifactProperties
+     */
+    String getProperty( String key, String defaultValue );
+
+    /**
+     * Gets the properties of this artifact. Clients may use these properties to associate non-persistent values with an
+     * artifact that help later processing when the artifact gets passed around within the application.
+     * 
+     * @return The (read-only) properties, never {@code null}.
+     * @see ArtifactProperties
+     */
+    Map<String, String> getProperties();
+
+    /**
+     * Sets the properties for the artifact. Note that these properties exist merely in memory and are not persisted
+     * when the artifact gets installed/deployed to a repository.
+     * 
+     * @param properties The properties for the artifact, may be {@code null}.
+     * @return The new artifact, never {@code null}.
+     * @see ArtifactProperties
+     */
+    Artifact setProperties( Map<String, String> properties );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactProperties.java b/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactProperties.java
new file mode 100644 (file)
index 0000000..7fbea04
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.artifact;
+
+/**
+ * The keys for common properties of artifacts.
+ * 
+ * @see Artifact#getProperties()
+ */
+public final class ArtifactProperties
+{
+
+    /**
+     * A high-level characterization of the artifact, e.g. "maven-plugin" or "test-jar".
+     * 
+     * @see ArtifactType#getId()
+     */
+    public static final String TYPE = "type";
+
+    /**
+     * The programming language this artifact is relevant for, e.g. "java" or "none".
+     */
+    public static final String LANGUAGE = "language";
+
+    /**
+     * The (expected) path to the artifact on the local filesystem. An artifact which has this property set is assumed
+     * to be not present in any regular repository and likewise has no artifact descriptor. Artifact resolution will
+     * verify the path and resolve the artifact if the path actually denotes an existing file. If the path isn't valid,
+     * resolution will fail and no attempts to search local/remote repositories are made.
+     */
+    public static final String LOCAL_PATH = "localPath";
+
+    /**
+     * A boolean flag indicating whether the artifact presents some kind of bundle that physically includes its
+     * dependencies, e.g. a fat WAR.
+     */
+    public static final String INCLUDES_DEPENDENCIES = "includesDependencies";
+
+    /**
+     * A boolean flag indicating whether the artifact is meant to be used for the compile/runtime/test build path of a
+     * consumer project.
+     */
+    public static final String CONSTITUTES_BUILD_PATH = "constitutesBuildPath";
+
+    /**
+     * The URL to a web page from which the artifact can be manually downloaded. This URL is not contacted by the
+     * repository system but serves as a pointer for the end user to assist in getting artifacts that are not published
+     * in a proper repository.
+     */
+    public static final String DOWNLOAD_URL = "downloadUrl";
+
+    private ArtifactProperties()
+    {
+        // hide constructor
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactType.java b/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactType.java
new file mode 100644 (file)
index 0000000..174c3c5
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.artifact;
+
+import java.util.Map;
+
+/**
+ * An artifact type describing artifact characteristics/properties that are common for certain artifacts. Artifact types
+ * are a means to simplify the description of an artifact by referring to an artifact type instead of specifying the
+ * various properties individually.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ * @see ArtifactTypeRegistry
+ * @see DefaultArtifact#DefaultArtifact(String, String, String, String, String, ArtifactType)
+ */
+public interface ArtifactType
+{
+
+    /**
+     * Gets the identifier of this type, e.g. "maven-plugin" or "test-jar".
+     * 
+     * @return The identifier of this type, never {@code null}.
+     * @see ArtifactProperties#TYPE
+     */
+    String getId();
+
+    /**
+     * Gets the file extension to use for artifacts of this type (unless explicitly overridden by the artifact).
+     * 
+     * @return The usual file extension, never {@code null}.
+     */
+    String getExtension();
+
+    /**
+     * Gets the classifier to use for artifacts of this type (unless explicitly overridden by the artifact).
+     * 
+     * @return The usual classifier or an empty string if none, never {@code null}.
+     */
+    String getClassifier();
+
+    /**
+     * Gets the properties to use for artifacts of this type (unless explicitly overridden by the artifact).
+     * 
+     * @return The (read-only) properties, never {@code null}.
+     * @see ArtifactProperties
+     */
+    Map<String, String> getProperties();
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactTypeRegistry.java b/org.argeo.slc.repo/src/org/eclipse/aether/artifact/ArtifactTypeRegistry.java
new file mode 100644 (file)
index 0000000..2addff1
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.artifact;
+
+/**
+ * A registry of known artifact types.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getArtifactTypeRegistry()
+ */
+public interface ArtifactTypeRegistry
+{
+
+    /**
+     * Gets the artifact type with the specified identifier.
+     * 
+     * @param typeId The identifier of the type, must not be {@code null}.
+     * @return The artifact type or {@code null} if no type with the requested identifier exists.
+     */
+    ArtifactType get( String typeId );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifact.java b/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifact.java
new file mode 100644 (file)
index 0000000..9971034
--- /dev/null
@@ -0,0 +1,276 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.artifact;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A simple artifact. <em>Note:</em> Instances of this class are immutable and the exposed mutators return new objects
+ * rather than changing the current instance.
+ */
+public final class DefaultArtifact
+    extends AbstractArtifact
+{
+
+    private final String groupId;
+
+    private final String artifactId;
+
+    private final String version;
+
+    private final String classifier;
+
+    private final String extension;
+
+    private final File file;
+
+    private final Map<String, String> properties;
+
+    /**
+     * Creates a new artifact with the specified coordinates. If not specified in the artifact coordinates, the
+     * artifact's extension defaults to {@code jar} and classifier to an empty string.
+     * 
+     * @param coords The artifact coordinates in the format
+     *            {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null}.
+     */
+    public DefaultArtifact( String coords )
+    {
+        this( coords, Collections.<String, String> emptyMap() );
+    }
+
+    /**
+     * Creates a new artifact with the specified coordinates and properties. If not specified in the artifact
+     * coordinates, the artifact's extension defaults to {@code jar} and classifier to an empty string.
+     * 
+     * @param coords The artifact coordinates in the format
+     *            {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null}.
+     * @param properties The artifact properties, may be {@code null}.
+     */
+    public DefaultArtifact( String coords, Map<String, String> properties )
+    {
+        Pattern p = Pattern.compile( "([^: ]+):([^: ]+)(:([^: ]*)(:([^: ]+))?)?:([^: ]+)" );
+        Matcher m = p.matcher( coords );
+        if ( !m.matches() )
+        {
+            throw new IllegalArgumentException( "Bad artifact coordinates " + coords
+                + ", expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>" );
+        }
+        groupId = m.group( 1 );
+        artifactId = m.group( 2 );
+        extension = get( m.group( 4 ), "jar" );
+        classifier = get( m.group( 6 ), "" );
+        version = m.group( 7 );
+        file = null;
+        this.properties = copyProperties( properties );
+    }
+
+    private static String get( String value, String defaultValue )
+    {
+        return ( value == null || value.length() <= 0 ) ? defaultValue : value;
+    }
+
+    /**
+     * Creates a new artifact with the specified coordinates and no classifier. Passing {@code null} for any of the
+     * coordinates is equivalent to specifying an empty string.
+     * 
+     * @param groupId The group identifier of the artifact, may be {@code null}.
+     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+     * @param extension The file extension of the artifact, may be {@code null}.
+     * @param version The version of the artifact, may be {@code null}.
+     */
+    public DefaultArtifact( String groupId, String artifactId, String extension, String version )
+    {
+        this( groupId, artifactId, "", extension, version );
+    }
+
+    /**
+     * Creates a new artifact with the specified coordinates. Passing {@code null} for any of the coordinates is
+     * equivalent to specifying an empty string.
+     * 
+     * @param groupId The group identifier of the artifact, may be {@code null}.
+     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+     * @param classifier The classifier of the artifact, may be {@code null}.
+     * @param extension The file extension of the artifact, may be {@code null}.
+     * @param version The version of the artifact, may be {@code null}.
+     */
+    public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version )
+    {
+        this( groupId, artifactId, classifier, extension, version, null, (File) null );
+    }
+
+    /**
+     * Creates a new artifact with the specified coordinates. Passing {@code null} for any of the coordinates is
+     * equivalent to specifying an empty string. The optional artifact type provided to this constructor will be used to
+     * determine the artifact's classifier and file extension if the corresponding arguments for this constructor are
+     * {@code null}.
+     * 
+     * @param groupId The group identifier of the artifact, may be {@code null}.
+     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+     * @param classifier The classifier of the artifact, may be {@code null}.
+     * @param extension The file extension of the artifact, may be {@code null}.
+     * @param version The version of the artifact, may be {@code null}.
+     * @param type The artifact type from which to query classifier, file extension and properties, may be {@code null}.
+     */
+    public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
+                            ArtifactType type )
+    {
+        this( groupId, artifactId, classifier, extension, version, null, type );
+    }
+
+    /**
+     * Creates a new artifact with the specified coordinates and properties. Passing {@code null} for any of the
+     * coordinates is equivalent to specifying an empty string. The optional artifact type provided to this constructor
+     * will be used to determine the artifact's classifier and file extension if the corresponding arguments for this
+     * constructor are {@code null}. If the artifact type specifies properties, those will get merged with the
+     * properties passed directly into the constructor, with the latter properties taking precedence.
+     * 
+     * @param groupId The group identifier of the artifact, may be {@code null}.
+     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+     * @param classifier The classifier of the artifact, may be {@code null}.
+     * @param extension The file extension of the artifact, may be {@code null}.
+     * @param version The version of the artifact, may be {@code null}.
+     * @param properties The properties of the artifact, may be {@code null} if none.
+     * @param type The artifact type from which to query classifier, file extension and properties, may be {@code null}.
+     */
+    public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
+                            Map<String, String> properties, ArtifactType type )
+    {
+        this.groupId = emptify( groupId );
+        this.artifactId = emptify( artifactId );
+        if ( classifier != null || type == null )
+        {
+            this.classifier = emptify( classifier );
+        }
+        else
+        {
+            this.classifier = emptify( type.getClassifier() );
+        }
+        if ( extension != null || type == null )
+        {
+            this.extension = emptify( extension );
+        }
+        else
+        {
+            this.extension = emptify( type.getExtension() );
+        }
+        this.version = emptify( version );
+        this.file = null;
+        this.properties = merge( properties, ( type != null ) ? type.getProperties() : null );
+    }
+
+    private static Map<String, String> merge( Map<String, String> dominant, Map<String, String> recessive )
+    {
+        Map<String, String> properties;
+
+        if ( ( dominant == null || dominant.isEmpty() ) && ( recessive == null || recessive.isEmpty() ) )
+        {
+            properties = Collections.emptyMap();
+        }
+        else
+        {
+            properties = new HashMap<String, String>();
+            if ( recessive != null )
+            {
+                properties.putAll( recessive );
+            }
+            if ( dominant != null )
+            {
+                properties.putAll( dominant );
+            }
+            properties = Collections.unmodifiableMap( properties );
+        }
+
+        return properties;
+    }
+
+    /**
+     * Creates a new artifact with the specified coordinates, properties and file. Passing {@code null} for any of the
+     * coordinates is equivalent to specifying an empty string.
+     * 
+     * @param groupId The group identifier of the artifact, may be {@code null}.
+     * @param artifactId The artifact identifier of the artifact, may be {@code null}.
+     * @param classifier The classifier of the artifact, may be {@code null}.
+     * @param extension The file extension of the artifact, may be {@code null}.
+     * @param version The version of the artifact, may be {@code null}.
+     * @param properties The properties of the artifact, may be {@code null} if none.
+     * @param file The resolved file of the artifact, may be {@code null}.
+     */
+    public DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version,
+                            Map<String, String> properties, File file )
+    {
+        this.groupId = emptify( groupId );
+        this.artifactId = emptify( artifactId );
+        this.classifier = emptify( classifier );
+        this.extension = emptify( extension );
+        this.version = emptify( version );
+        this.file = file;
+        this.properties = copyProperties( properties );
+    }
+
+    DefaultArtifact( String groupId, String artifactId, String classifier, String extension, String version, File file,
+                     Map<String, String> properties )
+    {
+        // NOTE: This constructor assumes immutability of the provided properties, for internal use only
+        this.groupId = emptify( groupId );
+        this.artifactId = emptify( artifactId );
+        this.classifier = emptify( classifier );
+        this.extension = emptify( extension );
+        this.version = emptify( version );
+        this.file = file;
+        this.properties = properties;
+    }
+
+    private static String emptify( String str )
+    {
+        return ( str == null ) ? "" : str;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public String getClassifier()
+    {
+        return classifier;
+    }
+
+    public String getExtension()
+    {
+        return extension;
+    }
+
+    public File getFile()
+    {
+        return file;
+    }
+
+    public Map<String, String> getProperties()
+    {
+        return properties;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifactType.java b/org.argeo.slc.repo/src/org/eclipse/aether/artifact/DefaultArtifactType.java
new file mode 100644 (file)
index 0000000..b30cd12
--- /dev/null
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.artifact;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A simple artifact type.
+ */
+public final class DefaultArtifactType
+    implements ArtifactType
+{
+
+    private final String id;
+
+    private final String extension;
+
+    private final String classifier;
+
+    private final Map<String, String> properties;
+
+    /**
+     * Creates a new artifact type with the specified identifier. This constructor assumes the usual file extension
+     * equals the given type id and that the usual classifier is empty. Additionally, the properties
+     * {@link ArtifactProperties#LANGUAGE}, {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} and
+     * {@link ArtifactProperties#INCLUDES_DEPENDENCIES} will be set to {@code "none"}, {@code true} and {@code false},
+     * respectively.
+     * 
+     * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
+     *            property, must not be {@code null} or empty.
+     */
+    public DefaultArtifactType( String id )
+    {
+        this( id, id, "", "none", false, false );
+    }
+
+    /**
+     * Creates a new artifact type with the specified properties. Additionally, the properties
+     * {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} and {@link ArtifactProperties#INCLUDES_DEPENDENCIES} will be
+     * set to {@code true} and {@code false}, respectively.
+     * 
+     * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
+     *            property, must not be {@code null} or empty.
+     * @param extension The usual file extension for artifacts of this type, may be {@code null}.
+     * @param classifier The usual classifier for artifacts of this type, may be {@code null}.
+     * @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}.
+     */
+    public DefaultArtifactType( String id, String extension, String classifier, String language )
+    {
+        this( id, extension, classifier, language, true, false );
+    }
+
+    /**
+     * Creates a new artifact type with the specified properties.
+     * 
+     * @param id The identifier of the type which will also be used as the value for the {@link ArtifactProperties#TYPE}
+     *            property, must not be {@code null} or empty.
+     * @param extension The usual file extension for artifacts of this type, may be {@code null}.
+     * @param classifier The usual classifier for artifacts of this type, may be {@code null}.
+     * @param language The value for the {@link ArtifactProperties#LANGUAGE} property, may be {@code null}.
+     * @param constitutesBuildPath The value for the {@link ArtifactProperties#CONSTITUTES_BUILD_PATH} property.
+     * @param includesDependencies The value for the {@link ArtifactProperties#INCLUDES_DEPENDENCIES} property.
+     */
+    public DefaultArtifactType( String id, String extension, String classifier, String language,
+                                boolean constitutesBuildPath, boolean includesDependencies )
+    {
+        if ( id == null || id.length() < 0 )
+        {
+            throw new IllegalArgumentException( "no type id specified" );
+        }
+        this.id = id;
+        this.extension = emptify( extension );
+        this.classifier = emptify( classifier );
+        Map<String, String> props = new HashMap<String, String>();
+        props.put( ArtifactProperties.TYPE, id );
+        props.put( ArtifactProperties.LANGUAGE, ( language != null && language.length() > 0 ) ? language : "none" );
+        props.put( ArtifactProperties.INCLUDES_DEPENDENCIES, Boolean.toString( includesDependencies ) );
+        props.put( ArtifactProperties.CONSTITUTES_BUILD_PATH, Boolean.toString( constitutesBuildPath ) );
+        properties = Collections.unmodifiableMap( props );
+    }
+
+    /**
+     * Creates a new artifact type with the specified properties.
+     * 
+     * @param id The identifier of the type, must not be {@code null} or empty.
+     * @param extension The usual file extension for artifacts of this type, may be {@code null}.
+     * @param classifier The usual classifier for artifacts of this type, may be {@code null}.
+     * @param properties The properties for artifacts of this type, may be {@code null}.
+     */
+    public DefaultArtifactType( String id, String extension, String classifier, Map<String, String> properties )
+    {
+        if ( id == null || id.length() < 0 )
+        {
+            throw new IllegalArgumentException( "no type id specified" );
+        }
+        this.id = id;
+        this.extension = emptify( extension );
+        this.classifier = emptify( classifier );
+        this.properties = AbstractArtifact.copyProperties( properties );
+    }
+
+    private static String emptify( String str )
+    {
+        return ( str == null ) ? "" : str;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public String getExtension()
+    {
+        return extension;
+    }
+
+    public String getClassifier()
+    {
+        return classifier;
+    }
+
+    public Map<String, String> getProperties()
+    {
+        return properties;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/artifact/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/artifact/package-info.java
new file mode 100644 (file)
index 0000000..6d676d1
--- /dev/null
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The definition of an artifact, that is the primary entity managed by the repository system.
+ */
+package org.eclipse.aether.artifact;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectRequest.java
new file mode 100644 (file)
index 0000000..8568385
--- /dev/null
@@ -0,0 +1,347 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * A request to collect the transitive dependencies and to build a dependency graph from them. There are three ways to
+ * create a dependency graph. First, only the root dependency can be given. Second, a root dependency and direct
+ * dependencies can be specified in which case the specified direct dependencies are merged with the direct dependencies
+ * retrieved from the artifact descriptor of the root dependency. And last, only direct dependencies can be specified in
+ * which case the root node of the resulting graph has no associated dependency.
+ * 
+ * @see RepositorySystem#collectDependencies(RepositorySystemSession, CollectRequest)
+ */
+public final class CollectRequest
+{
+
+    private Artifact rootArtifact;
+
+    private Dependency root;
+
+    private List<Dependency> dependencies = Collections.emptyList();
+
+    private List<Dependency> managedDependencies = Collections.emptyList();
+
+    private List<RemoteRepository> repositories = Collections.emptyList();
+
+    private String context = "";
+
+    private RequestTrace trace;
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public CollectRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a request with the specified properties.
+     * 
+     * @param root The root dependency whose transitive dependencies should be collected, may be {@code null}.
+     * @param repositories The repositories to use for the collection, may be {@code null}.
+     */
+    public CollectRequest( Dependency root, List<RemoteRepository> repositories )
+    {
+        setRoot( root );
+        setRepositories( repositories );
+    }
+
+    /**
+     * Creates a new request with the specified properties.
+     * 
+     * @param root The root dependency whose transitive dependencies should be collected, may be {@code null}.
+     * @param dependencies The direct dependencies to merge with the direct dependencies from the root dependency's
+     *            artifact descriptor.
+     * @param repositories The repositories to use for the collection, may be {@code null}.
+     */
+    public CollectRequest( Dependency root, List<Dependency> dependencies, List<RemoteRepository> repositories )
+    {
+        setRoot( root );
+        setDependencies( dependencies );
+        setRepositories( repositories );
+    }
+
+    /**
+     * Creates a new request with the specified properties.
+     * 
+     * @param dependencies The direct dependencies of some imaginary root, may be {@code null}.
+     * @param managedDependencies The dependency management information to apply to the transitive dependencies, may be
+     *            {@code null}.
+     * @param repositories The repositories to use for the collection, may be {@code null}.
+     */
+    public CollectRequest( List<Dependency> dependencies, List<Dependency> managedDependencies,
+                           List<RemoteRepository> repositories )
+    {
+        setDependencies( dependencies );
+        setManagedDependencies( managedDependencies );
+        setRepositories( repositories );
+    }
+
+    /**
+     * Gets the root artifact for the dependency graph.
+     * 
+     * @return The root artifact for the dependency graph or {@code null} if none.
+     */
+    public Artifact getRootArtifact()
+    {
+        return rootArtifact;
+    }
+
+    /**
+     * Sets the root artifact for the dependency graph. This must not be confused with {@link #setRoot(Dependency)}: The
+     * root <em>dependency</em>, like any other specified dependency, will be subject to dependency
+     * collection/resolution, i.e. should have an artifact descriptor and a corresponding artifact file. The root
+     * <em>artifact</em> on the other hand is only used as a label for the root node of the graph in case no root
+     * dependency was specified. As such, the configured root artifact is ignored if {@link #getRoot()} does not return
+     * {@code null}.
+     * 
+     * @param rootArtifact The root artifact for the dependency graph, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest setRootArtifact( Artifact rootArtifact )
+    {
+        this.rootArtifact = rootArtifact;
+        return this;
+    }
+
+    /**
+     * Gets the root dependency of the graph.
+     * 
+     * @return The root dependency of the graph or {@code null} if none.
+     */
+    public Dependency getRoot()
+    {
+        return root;
+    }
+
+    /**
+     * Sets the root dependency of the graph.
+     * 
+     * @param root The root dependency of the graph, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest setRoot( Dependency root )
+    {
+        this.root = root;
+        return this;
+    }
+
+    /**
+     * Gets the direct dependencies.
+     * 
+     * @return The direct dependencies, never {@code null}.
+     */
+    public List<Dependency> getDependencies()
+    {
+        return dependencies;
+    }
+
+    /**
+     * Sets the direct dependencies. If both a root dependency and direct dependencies are given in the request, the
+     * direct dependencies from the request will be merged with the direct dependencies from the root dependency's
+     * artifact descriptor, giving higher priority to the dependencies from the request.
+     * 
+     * @param dependencies The direct dependencies, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest setDependencies( List<Dependency> dependencies )
+    {
+        if ( dependencies == null )
+        {
+            this.dependencies = Collections.emptyList();
+        }
+        else
+        {
+            this.dependencies = dependencies;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified direct dependency.
+     * 
+     * @param dependency The dependency to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest addDependency( Dependency dependency )
+    {
+        if ( dependency != null )
+        {
+            if ( this.dependencies.isEmpty() )
+            {
+                this.dependencies = new ArrayList<Dependency>();
+            }
+            this.dependencies.add( dependency );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the dependency management to apply to transitive dependencies.
+     * 
+     * @return The dependency management to apply to transitive dependencies, never {@code null}.
+     */
+    public List<Dependency> getManagedDependencies()
+    {
+        return managedDependencies;
+    }
+
+    /**
+     * Sets the dependency management to apply to transitive dependencies. To clarify, this management does not apply to
+     * the direct dependencies of the root node.
+     * 
+     * @param managedDependencies The dependency management, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest setManagedDependencies( List<Dependency> managedDependencies )
+    {
+        if ( managedDependencies == null )
+        {
+            this.managedDependencies = Collections.emptyList();
+        }
+        else
+        {
+            this.managedDependencies = managedDependencies;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified managed dependency.
+     * 
+     * @param managedDependency The managed dependency to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest addManagedDependency( Dependency managedDependency )
+    {
+        if ( managedDependency != null )
+        {
+            if ( this.managedDependencies.isEmpty() )
+            {
+                this.managedDependencies = new ArrayList<Dependency>();
+            }
+            this.managedDependencies.add( managedDependency );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the repositories to use for the collection.
+     * 
+     * @return The repositories to use for the collection, never {@code null}.
+     */
+    public List<RemoteRepository> getRepositories()
+    {
+        return repositories;
+    }
+
+    /**
+     * Sets the repositories to use for the collection.
+     * 
+     * @param repositories The repositories to use for the collection, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest setRepositories( List<RemoteRepository> repositories )
+    {
+        if ( repositories == null )
+        {
+            this.repositories = Collections.emptyList();
+        }
+        else
+        {
+            this.repositories = repositories;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified repository for collection.
+     * 
+     * @param repository The repository to collect dependency information from, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest addRepository( RemoteRepository repository )
+    {
+        if ( repository != null )
+        {
+            if ( this.repositories.isEmpty() )
+            {
+                this.repositories = new ArrayList<RemoteRepository>();
+            }
+            this.repositories.add( repository );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the context in which this request is made.
+     * 
+     * @return The context, never {@code null}.
+     */
+    public String getRequestContext()
+    {
+        return context;
+    }
+
+    /**
+     * Sets the context in which this request is made.
+     * 
+     * @param context The context, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest setRequestContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+        return this;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    /**
+     * Sets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @param trace The trace information about the higher level operation, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public CollectRequest setTrace( RequestTrace trace )
+    {
+        this.trace = trace;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getRoot() + " -> " + getDependencies() + " < " + getRepositories();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/CollectResult.java
new file mode 100644 (file)
index 0000000..4975190
--- /dev/null
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.graph.DependencyCycle;
+import org.eclipse.aether.graph.DependencyNode;
+
+/**
+ * The result of a dependency collection request.
+ * 
+ * @see RepositorySystem#collectDependencies(RepositorySystemSession, CollectRequest)
+ */
+public final class CollectResult
+{
+
+    private final CollectRequest request;
+
+    private List<Exception> exceptions;
+
+    private List<DependencyCycle> cycles;
+
+    private DependencyNode root;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The resolution request, must not be {@code null}.
+     */
+    public CollectResult( CollectRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "dependency collection request has not been specified" );
+        }
+        this.request = request;
+        exceptions = Collections.emptyList();
+        cycles = Collections.emptyList();
+    }
+
+    /**
+     * Gets the collection request that was made.
+     * 
+     * @return The collection request, never {@code null}.
+     */
+    public CollectRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the exceptions that occurred while building the dependency graph.
+     * 
+     * @return The exceptions that occurred, never {@code null}.
+     */
+    public List<Exception> getExceptions()
+    {
+        return exceptions;
+    }
+
+    /**
+     * Records the specified exception while building the dependency graph.
+     * 
+     * @param exception The exception to record, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public CollectResult addException( Exception exception )
+    {
+        if ( exception != null )
+        {
+            if ( exceptions.isEmpty() )
+            {
+                exceptions = new ArrayList<Exception>();
+            }
+            exceptions.add( exception );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the dependency cycles that were encountered while building the dependency graph.
+     * 
+     * @return The dependency cycles in the (raw) graph, never {@code null}.
+     */
+    public List<DependencyCycle> getCycles()
+    {
+        return cycles;
+    }
+
+    /**
+     * Records the specified dependency cycle.
+     * 
+     * @param cycle The dependency cycle to record, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public CollectResult addCycle( DependencyCycle cycle )
+    {
+        if ( cycle != null )
+        {
+            if ( cycles.isEmpty() )
+            {
+                cycles = new ArrayList<DependencyCycle>();
+            }
+            cycles.add( cycle );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the root node of the dependency graph.
+     * 
+     * @return The root node of the dependency graph or {@code null} if none.
+     */
+    public DependencyNode getRoot()
+    {
+        return root;
+    }
+
+    /**
+     * Sets the root node of the dependency graph.
+     * 
+     * @param root The root node of the dependency graph, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public CollectResult setRoot( DependencyNode root )
+    {
+        this.root = root;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return String.valueOf( getRoot() );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionContext.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionContext.java
new file mode 100644 (file)
index 0000000..3b8fbc2
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.Dependency;
+
+/**
+ * A context used during dependency collection to update the dependency manager, selector and traverser.
+ * 
+ * @see DependencyManager#deriveChildManager(DependencyCollectionContext)
+ * @see DependencyTraverser#deriveChildTraverser(DependencyCollectionContext)
+ * @see DependencySelector#deriveChildSelector(DependencyCollectionContext)
+ * @see VersionFilter#deriveChildFilter(DependencyCollectionContext)
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface DependencyCollectionContext
+{
+
+    /**
+     * Gets the repository system session during which the dependency collection happens.
+     * 
+     * @return The repository system session, never {@code null}.
+     */
+    RepositorySystemSession getSession();
+
+    /**
+     * Gets the artifact whose children are to be processed next during dependency collection. For all nodes but the
+     * root, this is simply shorthand for {@code getDependency().getArtifact()}. In case of the root node however,
+     * {@link #getDependency()} might be {@code null} while the node still has an artifact which serves as its label and
+     * is not to be resolved.
+     * 
+     * @return The artifact whose children are going to be processed or {@code null} in case of the root node without
+     *         dependency and label.
+     */
+    Artifact getArtifact();
+
+    /**
+     * Gets the dependency whose children are to be processed next during dependency collection.
+     * 
+     * @return The dependency whose children are going to be processed or {@code null} in case of the root node without
+     *         dependency.
+     */
+    Dependency getDependency();
+
+    /**
+     * Gets the dependency management information that was contributed by the artifact descriptor of the current
+     * dependency.
+     * 
+     * @return The dependency management information, never {@code null}.
+     */
+    List<Dependency> getManagedDependencies();
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionException.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyCollectionException.java
new file mode 100644 (file)
index 0000000..0d26674
--- /dev/null
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case of bad artifact descriptors, version ranges or other issues encountered during calculation of the
+ * dependency graph.
+ */
+public class DependencyCollectionException
+    extends RepositoryException
+{
+
+    private final transient CollectResult result;
+
+    /**
+     * Creates a new exception with the specified result.
+     * 
+     * @param result The collection result at the point the exception occurred, may be {@code null}.
+     */
+    public DependencyCollectionException( CollectResult result )
+    {
+        super( "Failed to collect dependencies for " + getSource( result ), getCause( result ) );
+        this.result = result;
+    }
+
+    /**
+     * Creates a new exception with the specified result and detail message.
+     * 
+     * @param result The collection result at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public DependencyCollectionException( CollectResult result, String message )
+    {
+        super( message, getCause( result ) );
+        this.result = result;
+    }
+
+    /**
+     * Creates a new exception with the specified result, detail message and cause.
+     * 
+     * @param result The collection result at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public DependencyCollectionException( CollectResult result, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.result = result;
+    }
+
+    /**
+     * Gets the collection result at the point the exception occurred. Despite being incomplete, callers might want to
+     * use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
+     * 
+     * @return The collection result or {@code null} if unknown.
+     */
+    public CollectResult getResult()
+    {
+        return result;
+    }
+
+    private static String getSource( CollectResult result )
+    {
+        if ( result == null )
+        {
+            return "";
+        }
+
+        CollectRequest request = result.getRequest();
+        if ( request.getRoot() != null )
+        {
+            return request.getRoot().toString();
+        }
+        if ( request.getRootArtifact() != null )
+        {
+            return request.getRootArtifact().toString();
+        }
+
+        return request.getDependencies().toString();
+    }
+
+    private static Throwable getCause( CollectResult result )
+    {
+        Throwable cause = null;
+        if ( result != null && !result.getExceptions().isEmpty() )
+        {
+            cause = result.getExceptions().get( 0 );
+        }
+        return cause;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformationContext.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformationContext.java
new file mode 100644 (file)
index 0000000..d3980da
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import org.eclipse.aether.RepositorySystemSession;
+
+/**
+ * A context used during dependency collection to exchange information within a chain of dependency graph transformers.
+ * 
+ * @see DependencyGraphTransformer
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface DependencyGraphTransformationContext
+{
+
+    /**
+     * Gets the repository system session during which the graph transformation happens.
+     * 
+     * @return The repository system session, never {@code null}.
+     */
+    RepositorySystemSession getSession();
+
+    /**
+     * Gets a keyed value from the context.
+     * 
+     * @param key The key used to query the value, must not be {@code null}.
+     * @return The queried value or {@code null} if none.
+     */
+    Object get( Object key );
+
+    /**
+     * Puts a keyed value into the context.
+     * 
+     * @param key The key used to store the value, must not be {@code null}.
+     * @param value The value to store, may be {@code null} to remove the mapping.
+     * @return The previous value associated with the key or {@code null} if none.
+     */
+    Object put( Object key, Object value );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformer.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyGraphTransformer.java
new file mode 100644 (file)
index 0000000..b3deebe
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.graph.DependencyNode;
+
+/**
+ * Transforms a given dependency graph.
+ * <p>
+ * <strong>Note:</strong> Implementations must be stateless.
+ * <p>
+ * <em>Warning:</em> Dependency graphs may generally contain cycles. As such a graph transformer that cannot assume for
+ * sure that cycles have already been eliminated must gracefully handle cyclic graphs, e.g. guard against infinite
+ * recursion.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getDependencyGraphTransformer()
+ */
+public interface DependencyGraphTransformer
+{
+
+    /**
+     * Transforms the dependency graph denoted by the specified root node. The transformer may directly change the
+     * provided input graph or create a new graph, the former is recommended for performance reasons.
+     * 
+     * @param node The root node of the (possibly cyclic!) graph to transform, must not be {@code null}.
+     * @param context The graph transformation context, must not be {@code null}.
+     * @return The result graph of the transformation, never {@code null}.
+     * @throws RepositoryException If the transformation failed.
+     */
+    DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context )
+        throws RepositoryException;
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManagement.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManagement.java
new file mode 100644 (file)
index 0000000..f0aac73
--- /dev/null
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.Exclusion;
+
+/**
+ * The management updates to apply to a dependency.
+ * 
+ * @see DependencyManager#manageDependency(Dependency)
+ */
+public final class DependencyManagement
+{
+
+    private String version;
+
+    private String scope;
+
+    private Boolean optional;
+
+    private Collection<Exclusion> exclusions;
+
+    private Map<String, String> properties;
+
+    /**
+     * Creates an empty management update.
+     */
+    public DependencyManagement()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Gets the new version to apply to the dependency.
+     * 
+     * @return The new version or {@code null} if the version is not managed and the existing dependency version should
+     *         remain unchanged.
+     */
+    public String getVersion()
+    {
+        return version;
+    }
+
+    /**
+     * Sets the new version to apply to the dependency.
+     * 
+     * @param version The new version, may be {@code null} if the version is not managed.
+     * @return This management update for chaining, never {@code null}.
+     */
+    public DependencyManagement setVersion( String version )
+    {
+        this.version = version;
+        return this;
+    }
+
+    /**
+     * Gets the new scope to apply to the dependency.
+     * 
+     * @return The new scope or {@code null} if the scope is not managed and the existing dependency scope should remain
+     *         unchanged.
+     */
+    public String getScope()
+    {
+        return scope;
+    }
+
+    /**
+     * Sets the new scope to apply to the dependency.
+     * 
+     * @param scope The new scope, may be {@code null} if the scope is not managed.
+     * @return This management update for chaining, never {@code null}.
+     */
+    public DependencyManagement setScope( String scope )
+    {
+        this.scope = scope;
+        return this;
+    }
+
+    /**
+     * Gets the new optional flag to apply to the dependency.
+     * 
+     * @return The new optional flag or {@code null} if the flag is not managed and the existing optional flag of the
+     *         dependency should remain unchanged.
+     */
+    public Boolean getOptional()
+    {
+        return optional;
+    }
+
+    /**
+     * Sets the new optional flag to apply to the dependency.
+     * 
+     * @param optional The optional flag, may be {@code null} if the flag is not managed.
+     * @return This management update for chaining, never {@code null}.
+     */
+    public DependencyManagement setOptional( Boolean optional )
+    {
+        this.optional = optional;
+        return this;
+    }
+
+    /**
+     * Gets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
+     * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
+     * with information from dependency management or overridden by it.
+     * 
+     * @return The new exclusions or {@code null} if the exclusions are not managed and the existing dependency
+     *         exclusions should remain unchanged.
+     */
+    public Collection<Exclusion> getExclusions()
+    {
+        return exclusions;
+    }
+
+    /**
+     * Sets the new exclusions to apply to the dependency. Note that this collection denotes the complete set of
+     * exclusions for the dependency, i.e. the dependency manager controls whether any existing exclusions get merged
+     * with information from dependency management or overridden by it.
+     * 
+     * @param exclusions The new exclusions, may be {@code null} if the exclusions are not managed.
+     * @return This management update for chaining, never {@code null}.
+     */
+    public DependencyManagement setExclusions( Collection<Exclusion> exclusions )
+    {
+        this.exclusions = exclusions;
+        return this;
+    }
+
+    /**
+     * Gets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
+     * i.e. the dependency manager controls whether any existing properties get merged with the information from
+     * dependency management or overridden by it.
+     * 
+     * @return The new artifact properties or {@code null} if the properties are not managed and the existing properties
+     *         should remain unchanged.
+     */
+    public Map<String, String> getProperties()
+    {
+        return properties;
+    }
+
+    /**
+     * Sets the new properties to apply to the dependency. Note that this map denotes the complete set of properties,
+     * i.e. the dependency manager controls whether any existing properties get merged with the information from
+     * dependency management or overridden by it.
+     * 
+     * @param properties The new artifact properties, may be {@code null} if the properties are not managed.
+     * @return This management update for chaining, never {@code null}.
+     */
+    public DependencyManagement setProperties( Map<String, String> properties )
+    {
+        this.properties = properties;
+        return this;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManager.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyManager.java
new file mode 100644 (file)
index 0000000..e214f66
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import org.eclipse.aether.graph.Dependency;
+
+/**
+ * Applies dependency management to the dependencies of a dependency node.
+ * <p>
+ * <strong>Note:</strong> Implementations must be stateless.
+ * <p>
+ * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
+ * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getDependencyManager()
+ * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
+ *      CollectRequest)
+ */
+public interface DependencyManager
+{
+
+    /**
+     * Applies dependency management to the specified dependency.
+     * 
+     * @param dependency The dependency to manage, must not be {@code null}.
+     * @return The management update to apply to the dependency or {@code null} if the dependency is not managed at all.
+     */
+    DependencyManagement manageDependency( Dependency dependency );
+
+    /**
+     * Derives a dependency manager for the specified collection context. When calculating the child manager,
+     * implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
+     * 
+     * @param context The dependency collection context, must not be {@code null}.
+     * @return The dependency manager for the dependencies of the target node or {@code null} if dependency management
+     *         should no longer be applied.
+     */
+    DependencyManager deriveChildManager( DependencyCollectionContext context );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencySelector.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencySelector.java
new file mode 100644 (file)
index 0000000..de503be
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import org.eclipse.aether.graph.Dependency;
+
+/**
+ * Decides what dependencies to include in the dependency graph.
+ * <p>
+ * <strong>Note:</strong> Implementations must be stateless.
+ * <p>
+ * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
+ * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getDependencySelector()
+ * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
+ *      CollectRequest)
+ */
+public interface DependencySelector
+{
+
+    /**
+     * Decides whether the specified dependency should be included in the dependency graph.
+     * 
+     * @param dependency The dependency to check, must not be {@code null}.
+     * @return {@code false} if the dependency should be excluded from the children of the current node, {@code true}
+     *         otherwise.
+     */
+    boolean selectDependency( Dependency dependency );
+
+    /**
+     * Derives a dependency selector for the specified collection context. When calculating the child selector,
+     * implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
+     * 
+     * @param context The dependency collection context, must not be {@code null}.
+     * @return The dependency selector for the target node or {@code null} if dependencies should be unconditionally
+     *         included in the sub graph.
+     */
+    DependencySelector deriveChildSelector( DependencyCollectionContext context );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyTraverser.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/DependencyTraverser.java
new file mode 100644 (file)
index 0000000..8140395
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import org.eclipse.aether.graph.Dependency;
+
+/**
+ * Decides whether the dependencies of a dependency node should be traversed as well.
+ * <p>
+ * <strong>Note:</strong> Implementations must be stateless.
+ * <p>
+ * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
+ * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getDependencyTraverser()
+ * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
+ *      CollectRequest)
+ */
+public interface DependencyTraverser
+{
+
+    /**
+     * Decides whether the dependencies of the specified dependency should be traversed.
+     * 
+     * @param dependency The dependency to check, must not be {@code null}.
+     * @return {@code true} if the dependency graph builder should recurse into the specified dependency and process its
+     *         dependencies, {@code false} otherwise.
+     */
+    boolean traverseDependency( Dependency dependency );
+
+    /**
+     * Derives a dependency traverser that will be used to decide whether the transitive dependencies of the dependency
+     * given in the collection context shall be traversed. When calculating the child traverser, implementors are
+     * strongly advised to simply return the current instance if nothing changed to help save memory.
+     * 
+     * @param context The dependency collection context, must not be {@code null}.
+     * @return The dependency traverser for the target node or {@code null} if dependencies should be unconditionally
+     *         traversed in the sub graph.
+     */
+    DependencyTraverser deriveChildTraverser( DependencyCollectionContext context );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/UnsolvableVersionConflictException.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/UnsolvableVersionConflictException.java
new file mode 100644 (file)
index 0000000..8db5590
--- /dev/null
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.version.VersionConstraint;
+
+/**
+ * Thrown in case of an unsolvable conflict between different version constraints for a dependency.
+ */
+public class UnsolvableVersionConflictException
+    extends RepositoryException
+{
+
+    private final transient Collection<String> versions;
+
+    private final transient Collection<? extends List<? extends DependencyNode>> paths;
+
+    /**
+     * Creates a new exception with the specified paths to conflicting nodes in the dependency graph.
+     * 
+     * @param paths The paths to the dependency nodes that participate in the version conflict, may be {@code null}.
+     */
+    public UnsolvableVersionConflictException( Collection<? extends List<? extends DependencyNode>> paths )
+    {
+        super( "Could not resolve version conflict among " + toPaths( paths ) );
+        if ( paths == null )
+        {
+            this.paths = Collections.emptyList();
+            this.versions = Collections.emptyList();
+        }
+        else
+        {
+            this.paths = paths;
+            this.versions = new LinkedHashSet<String>();
+            for ( List<? extends DependencyNode> path : paths )
+            {
+                VersionConstraint constraint = path.get( path.size() - 1 ).getVersionConstraint();
+                if ( constraint != null && constraint.getRange() != null )
+                {
+                    versions.add( constraint.toString() );
+                }
+            }
+        }
+    }
+
+    private static String toPaths( Collection<? extends List<? extends DependencyNode>> paths )
+    {
+        String result = "";
+
+        if ( paths != null )
+        {
+            Collection<String> strings = new LinkedHashSet<String>();
+
+            for ( List<? extends DependencyNode> path : paths )
+            {
+                strings.add( toPath( path ) );
+            }
+
+            result = strings.toString();
+        }
+
+        return result;
+    }
+
+    private static String toPath( List<? extends DependencyNode> path )
+    {
+        StringBuilder buffer = new StringBuilder( 256 );
+
+        for ( Iterator<? extends DependencyNode> it = path.iterator(); it.hasNext(); )
+        {
+            DependencyNode node = it.next();
+            if ( node.getDependency() == null )
+            {
+                continue;
+            }
+
+            Artifact artifact = node.getDependency().getArtifact();
+            buffer.append( artifact.getGroupId() );
+            buffer.append( ':' ).append( artifact.getArtifactId() );
+            buffer.append( ':' ).append( artifact.getExtension() );
+            if ( artifact.getClassifier().length() > 0 )
+            {
+                buffer.append( ':' ).append( artifact.getClassifier() );
+            }
+            buffer.append( ':' ).append( node.getVersionConstraint() );
+
+            if ( it.hasNext() )
+            {
+                buffer.append( " -> " );
+            }
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * Gets the paths leading to the conflicting dependencies.
+     * 
+     * @return The (read-only) paths leading to the conflicting dependencies, never {@code null}.
+     */
+    public Collection<? extends List<? extends DependencyNode>> getPaths()
+    {
+        return paths;
+    }
+
+    /**
+     * Gets the conflicting version constraints of the dependency.
+     * 
+     * @return The (read-only) conflicting version constraints, never {@code null}.
+     */
+    public Collection<String> getVersions()
+    {
+        return versions;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/VersionFilter.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/VersionFilter.java
new file mode 100644 (file)
index 0000000..02e7ab3
--- /dev/null
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.collection;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.repository.ArtifactRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.version.Version;
+import org.eclipse.aether.version.VersionConstraint;
+
+/**
+ * Decides which versions matching a version range should actually be considered for the dependency graph. The version
+ * filter is not invoked for dependencies that do not declare a version range but a single version.
+ * <p>
+ * <strong>Note:</strong> Implementations must be stateless.
+ * <p>
+ * <em>Warning:</em> This hook is called from a hot spot and therefore implementations should pay attention to
+ * performance. Among others, implementations should provide a semantic {@link Object#equals(Object) equals()} method.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getVersionFilter()
+ * @see org.eclipse.aether.RepositorySystem#collectDependencies(org.eclipse.aether.RepositorySystemSession,
+ *      CollectRequest)
+ */
+public interface VersionFilter
+{
+
+    /**
+     * A context used during version filtering to hold relevant data.
+     * 
+     * @noimplement This interface is not intended to be implemented by clients.
+     * @noextend This interface is not intended to be extended by clients.
+     */
+    interface VersionFilterContext
+        extends Iterable<Version>
+    {
+
+        /**
+         * Gets the repository system session during which the version filtering happens.
+         * 
+         * @return The repository system session, never {@code null}.
+         */
+        RepositorySystemSession getSession();
+
+        /**
+         * Gets the dependency whose version range is being filtered.
+         * 
+         * @return The dependency, never {@code null}.
+         */
+        Dependency getDependency();
+
+        /**
+         * Gets the total number of available versions. This count reflects any removals made during version filtering.
+         * 
+         * @return The total number of available versions.
+         */
+        int getCount();
+
+        /**
+         * Gets an iterator over the available versions of the dependency. The iterator returns versions in ascending
+         * order. Use {@link Iterator#remove()} to exclude a version from further consideration in the dependency graph.
+         * 
+         * @return The iterator of available versions, never {@code null}.
+         */
+        Iterator<Version> iterator();
+
+        /**
+         * Gets the version constraint that was parsed from the dependency's version string.
+         * 
+         * @return The parsed version constraint, never {@code null}.
+         */
+        VersionConstraint getVersionConstraint();
+
+        /**
+         * Gets the repository from which the specified version was resolved.
+         * 
+         * @param version The version whose source repository should be retrieved, must not be {@code null}.
+         * @return The repository from which the version was resolved or {@code null} if unknown.
+         */
+        ArtifactRepository getRepository( Version version );
+
+        /**
+         * Gets the remote repositories from which the versions were resolved.
+         * 
+         * @return The (read-only) list of repositories, never {@code null}.
+         */
+        List<RemoteRepository> getRepositories();
+
+    }
+
+    /**
+     * Filters the available versions for a given dependency. Implementations will usually call
+     * {@link VersionFilterContext#iterator() context.iterator()} to inspect the available versions and use
+     * {@link java.util.Iterator#remove()} to delete unacceptable versions. If no versions remain after all filtering
+     * has been performed, the dependency collection process will automatically fail, i.e. implementations need not
+     * handle this situation on their own.
+     * 
+     * @param context The version filter context, must not be {@code null}.
+     * @throws RepositoryException If the filtering could not be performed.
+     */
+    void filterVersions( VersionFilterContext context )
+        throws RepositoryException;
+
+    /**
+     * Derives a version filter for the specified collection context. The derived filter will be used to handle version
+     * ranges encountered in child dependencies of the current node. When calculating the child filter, implementors are
+     * strongly advised to simply return the current instance if nothing changed to help save memory.
+     * 
+     * @param context The dependency collection context, must not be {@code null}.
+     * @return The version filter for the target node or {@code null} if versions should not be filtered any more.
+     */
+    VersionFilter deriveChildFilter( DependencyCollectionContext context );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/collection/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/collection/package-info.java
new file mode 100644 (file)
index 0000000..dd7df2e
--- /dev/null
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The types and extension points for collecting the transitive dependencies of an artifact and building a dependency
+ * graph.
+ */
+package org.eclipse.aether.collection;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployRequest.java
new file mode 100644 (file)
index 0000000..a5372dd
--- /dev/null
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.deployment;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * A request to deploy artifacts and their accompanying metadata into the a remote repository.
+ * 
+ * @see RepositorySystem#deploy(RepositorySystemSession, DeployRequest)
+ */
+public final class DeployRequest
+{
+
+    private Collection<Artifact> artifacts = Collections.emptyList();
+
+    private Collection<Metadata> metadata = Collections.emptyList();
+
+    private RemoteRepository repository;
+
+    private RequestTrace trace;
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public DeployRequest()
+    {
+    }
+
+    /**
+     * Gets the artifact to deploy.
+     * 
+     * @return The artifacts to deploy, never {@code null}.
+     */
+    public Collection<Artifact> getArtifacts()
+    {
+        return artifacts;
+    }
+
+    /**
+     * Sets the artifacts to deploy.
+     * 
+     * @param artifacts The artifacts to deploy, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DeployRequest setArtifacts( Collection<Artifact> artifacts )
+    {
+        if ( artifacts == null )
+        {
+            this.artifacts = Collections.emptyList();
+        }
+        else
+        {
+            this.artifacts = artifacts;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified artifacts for deployment.
+     * 
+     * @param artifact The artifact to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DeployRequest addArtifact( Artifact artifact )
+    {
+        if ( artifact != null )
+        {
+            if ( artifacts.isEmpty() )
+            {
+                artifacts = new ArrayList<Artifact>();
+            }
+            artifacts.add( artifact );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the metadata to deploy.
+     * 
+     * @return The metadata to deploy, never {@code null}.
+     */
+    public Collection<Metadata> getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Sets the metadata to deploy.
+     * 
+     * @param metadata The metadata to deploy, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DeployRequest setMetadata( Collection<Metadata> metadata )
+    {
+        if ( metadata == null )
+        {
+            this.metadata = Collections.emptyList();
+        }
+        else
+        {
+            this.metadata = metadata;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified metadata for deployment.
+     * 
+     * @param metadata The metadata to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DeployRequest addMetadata( Metadata metadata )
+    {
+        if ( metadata != null )
+        {
+            if ( this.metadata.isEmpty() )
+            {
+                this.metadata = new ArrayList<Metadata>();
+            }
+            this.metadata.add( metadata );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the repository to deploy to.
+     * 
+     * @return The repository to deploy to or {@code null} if not set.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the repository to deploy to.
+     * 
+     * @param repository The repository to deploy to, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DeployRequest setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    /**
+     * Sets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @param trace The trace information about the higher level operation, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DeployRequest setTrace( RequestTrace trace )
+    {
+        this.trace = trace;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifacts() + ", " + getMetadata() + " > " + getRepository();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeployResult.java
new file mode 100644 (file)
index 0000000..fcda3ca
--- /dev/null
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.deployment;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.metadata.Metadata;
+
+/**
+ * The result of deploying artifacts and their accompanying metadata into the a remote repository.
+ * 
+ * @see RepositorySystem#deploy(RepositorySystemSession, DeployRequest)
+ */
+public final class DeployResult
+{
+
+    private final DeployRequest request;
+
+    private Collection<Artifact> artifacts;
+
+    private Collection<Metadata> metadata;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The deployment request, must not be {@code null}.
+     */
+    public DeployResult( DeployRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "deploy request has not been specified" );
+        }
+        this.request = request;
+        artifacts = Collections.emptyList();
+        metadata = Collections.emptyList();
+    }
+
+    /**
+     * Gets the deploy request that was made.
+     * 
+     * @return The deploy request, never {@code null}.
+     */
+    public DeployRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the artifacts that got deployed.
+     * 
+     * @return The deployed artifacts, never {@code null}.
+     */
+    public Collection<Artifact> getArtifacts()
+    {
+        return artifacts;
+    }
+
+    /**
+     * Sets the artifacts that got deployed.
+     * 
+     * @param artifacts The deployed artifacts, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public DeployResult setArtifacts( Collection<Artifact> artifacts )
+    {
+        if ( artifacts == null )
+        {
+            this.artifacts = Collections.emptyList();
+        }
+        else
+        {
+            this.artifacts = artifacts;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified artifacts to the result.
+     * 
+     * @param artifact The deployed artifact to add, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public DeployResult addArtifact( Artifact artifact )
+    {
+        if ( artifact != null )
+        {
+            if ( artifacts.isEmpty() )
+            {
+                artifacts = new ArrayList<Artifact>();
+            }
+            artifacts.add( artifact );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the metadata that got deployed. Note that due to automatically generated metadata, there might have been
+     * more metadata deployed than originally specified in the deploy request.
+     * 
+     * @return The deployed metadata, never {@code null}.
+     */
+    public Collection<Metadata> getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Sets the metadata that got deployed.
+     * 
+     * @param metadata The deployed metadata, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public DeployResult setMetadata( Collection<Metadata> metadata )
+    {
+        if ( metadata == null )
+        {
+            this.metadata = Collections.emptyList();
+        }
+        else
+        {
+            this.metadata = metadata;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified metadata to this result.
+     * 
+     * @param metadata The deployed metadata to add, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public DeployResult addMetadata( Metadata metadata )
+    {
+        if ( metadata != null )
+        {
+            if ( this.metadata.isEmpty() )
+            {
+                this.metadata = new ArrayList<Metadata>();
+            }
+            this.metadata.add( metadata );
+        }
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifacts() + ", " + getMetadata();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeploymentException.java b/org.argeo.slc.repo/src/org/eclipse/aether/deployment/DeploymentException.java
new file mode 100644 (file)
index 0000000..f631530
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.deployment;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case of a deployment error like authentication failure.
+ */
+public class DeploymentException
+    extends RepositoryException
+{
+
+    /**
+     * Creates a new exception with the specified detail message.
+     * 
+     * @param message The detail message, may be {@code null}.
+     */
+    public DeploymentException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * Creates a new exception with the specified detail message and cause.
+     * 
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public DeploymentException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/deployment/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/deployment/package-info.java
new file mode 100644 (file)
index 0000000..dd5a35d
--- /dev/null
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The types supporting the publishing of artifacts to a remote repository.
+ */
+package org.eclipse.aether.deployment;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/graph/DefaultDependencyNode.java b/org.argeo.slc.repo/src/org/eclipse/aether/graph/DefaultDependencyNode.java
new file mode 100644 (file)
index 0000000..c702d23
--- /dev/null
@@ -0,0 +1,359 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.graph;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.version.Version;
+import org.eclipse.aether.version.VersionConstraint;
+
+/**
+ * A node within a dependency graph.
+ */
+public final class DefaultDependencyNode
+    implements DependencyNode
+{
+
+    private List<DependencyNode> children;
+
+    private Dependency dependency;
+
+    private Artifact artifact;
+
+    private List<? extends Artifact> relocations;
+
+    private Collection<? extends Artifact> aliases;
+
+    private VersionConstraint versionConstraint;
+
+    private Version version;
+
+    private byte managedBits;
+
+    private List<RemoteRepository> repositories;
+
+    private String context;
+
+    private Map<Object, Object> data;
+
+    /**
+     * Creates a new node with the specified dependency.
+     * 
+     * @param dependency The dependency associated with this node, may be {@code null} for a root node.
+     */
+    public DefaultDependencyNode( Dependency dependency )
+    {
+        this.dependency = dependency;
+        artifact = ( dependency != null ) ? dependency.getArtifact() : null;
+        children = new ArrayList<DependencyNode>( 0 );
+        aliases = relocations = Collections.emptyList();
+        repositories = Collections.emptyList();
+        context = "";
+        data = Collections.emptyMap();
+    }
+
+    /**
+     * Creates a new root node with the specified artifact as its label. Note that the new node has no dependency, i.e.
+     * {@link #getDependency()} will return {@code null}. Put differently, the specified artifact will not be subject to
+     * dependency collection/resolution.
+     * 
+     * @param artifact The artifact to use as label for this node, may be {@code null}.
+     */
+    public DefaultDependencyNode( Artifact artifact )
+    {
+        this.artifact = artifact;
+        children = new ArrayList<DependencyNode>( 0 );
+        aliases = relocations = Collections.emptyList();
+        repositories = Collections.emptyList();
+        context = "";
+        data = Collections.emptyMap();
+    }
+
+    /**
+     * Creates a mostly shallow clone of the specified node. The new node has its own copy of any custom data and
+     * initially no children.
+     * 
+     * @param node The node to copy, must not be {@code null}.
+     */
+    public DefaultDependencyNode( DependencyNode node )
+    {
+        dependency = node.getDependency();
+        artifact = node.getArtifact();
+        children = new ArrayList<DependencyNode>( 0 );
+        setAliases( node.getAliases() );
+        setRequestContext( node.getRequestContext() );
+        setManagedBits( node.getManagedBits() );
+        setRelocations( node.getRelocations() );
+        setRepositories( node.getRepositories() );
+        setVersion( node.getVersion() );
+        setVersionConstraint( node.getVersionConstraint() );
+        Map<?, ?> data = node.getData();
+        setData( data.isEmpty() ? null : new HashMap<Object, Object>( data ) );
+    }
+
+    public List<DependencyNode> getChildren()
+    {
+        return children;
+    }
+
+    public void setChildren( List<DependencyNode> children )
+    {
+        if ( children == null )
+        {
+            this.children = new ArrayList<DependencyNode>( 0 );
+        }
+        else
+        {
+            this.children = children;
+        }
+    }
+
+    public Dependency getDependency()
+    {
+        return dependency;
+    }
+
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    public void setArtifact( Artifact artifact )
+    {
+        if ( dependency == null )
+        {
+            throw new UnsupportedOperationException( "node does not have a dependency" );
+        }
+        dependency = dependency.setArtifact( artifact );
+        this.artifact = dependency.getArtifact();
+    }
+
+    public List<? extends Artifact> getRelocations()
+    {
+        return relocations;
+    }
+
+    /**
+     * Sets the sequence of relocations that was followed to resolve this dependency's artifact.
+     * 
+     * @param relocations The sequence of relocations, may be {@code null}.
+     */
+    public void setRelocations( List<? extends Artifact> relocations )
+    {
+        if ( relocations == null || relocations.isEmpty() )
+        {
+            this.relocations = Collections.emptyList();
+        }
+        else
+        {
+            this.relocations = relocations;
+        }
+    }
+
+    public Collection<? extends Artifact> getAliases()
+    {
+        return aliases;
+    }
+
+    /**
+     * Sets the known aliases for this dependency's artifact.
+     * 
+     * @param aliases The known aliases, may be {@code null}.
+     */
+    public void setAliases( Collection<? extends Artifact> aliases )
+    {
+        if ( aliases == null || aliases.isEmpty() )
+        {
+            this.aliases = Collections.emptyList();
+        }
+        else
+        {
+            this.aliases = aliases;
+        }
+    }
+
+    public VersionConstraint getVersionConstraint()
+    {
+        return versionConstraint;
+    }
+
+    /**
+     * Sets the version constraint that was parsed from the dependency's version declaration.
+     * 
+     * @param versionConstraint The version constraint for this node, may be {@code null}.
+     */
+    public void setVersionConstraint( VersionConstraint versionConstraint )
+    {
+        this.versionConstraint = versionConstraint;
+    }
+
+    public Version getVersion()
+    {
+        return version;
+    }
+
+    /**
+     * Sets the version that was selected for the dependency's target artifact.
+     * 
+     * @param version The parsed version, may be {@code null}.
+     */
+    public void setVersion( Version version )
+    {
+        this.version = version;
+    }
+
+    public void setScope( String scope )
+    {
+        if ( dependency == null )
+        {
+            throw new UnsupportedOperationException( "node does not have a dependency" );
+        }
+        dependency = dependency.setScope( scope );
+    }
+
+    public void setOptional( Boolean optional )
+    {
+        if ( dependency == null )
+        {
+            throw new UnsupportedOperationException( "node does not have a dependency" );
+        }
+        dependency = dependency.setOptional( optional );
+    }
+
+    public int getManagedBits()
+    {
+        return managedBits;
+    }
+
+    /**
+     * Sets a bit field indicating which attributes of this node were subject to dependency management.
+     * 
+     * @param managedBits The bit field indicating the managed attributes or {@code 0} if dependency management wasn't
+     *            applied.
+     */
+    public void setManagedBits( int managedBits )
+    {
+        this.managedBits = (byte) ( managedBits & 0x1F );
+    }
+
+    public List<RemoteRepository> getRepositories()
+    {
+        return repositories;
+    }
+
+    /**
+     * Sets the remote repositories from which this node's artifact shall be resolved.
+     * 
+     * @param repositories The remote repositories to use for artifact resolution, may be {@code null}.
+     */
+    public void setRepositories( List<RemoteRepository> repositories )
+    {
+        if ( repositories == null || repositories.isEmpty() )
+        {
+            this.repositories = Collections.emptyList();
+        }
+        else
+        {
+            this.repositories = repositories;
+        }
+    }
+
+    public String getRequestContext()
+    {
+        return context;
+    }
+
+    public void setRequestContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+    }
+
+    public Map<Object, Object> getData()
+    {
+        return data;
+    }
+
+    public void setData( Map<Object, Object> data )
+    {
+        if ( data == null )
+        {
+            this.data = Collections.emptyMap();
+        }
+        else
+        {
+            this.data = data;
+        }
+    }
+
+    public void setData( Object key, Object value )
+    {
+        if ( key == null )
+        {
+            throw new IllegalArgumentException( "key must not be null" );
+        }
+
+        if ( value == null )
+        {
+            if ( !data.isEmpty() )
+            {
+                data.remove( key );
+
+                if ( data.isEmpty() )
+                {
+                    data = Collections.emptyMap();
+                }
+            }
+        }
+        else
+        {
+            if ( data.isEmpty() )
+            {
+                data = new HashMap<Object, Object>( 1, 2 ); // nodes can be numerous so let's be space conservative
+            }
+            data.put( key, value );
+        }
+    }
+
+    public boolean accept( DependencyVisitor visitor )
+    {
+        if ( visitor.visitEnter( this ) )
+        {
+            for ( DependencyNode child : children )
+            {
+                if ( !child.accept( visitor ) )
+                {
+                    break;
+                }
+            }
+        }
+
+        return visitor.visitLeave( this );
+    }
+
+    @Override
+    public String toString()
+    {
+        Dependency dep = getDependency();
+        if ( dep == null )
+        {
+            return String.valueOf( getArtifact() );
+        }
+        return dep.toString();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/graph/Dependency.java b/org.argeo.slc.repo/src/org/eclipse/aether/graph/Dependency.java
new file mode 100644 (file)
index 0000000..72ea0f6
--- /dev/null
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.graph;
+
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * A dependency to some artifact. <em>Note:</em> Instances of this class are immutable and the exposed mutators return
+ * new objects rather than changing the current instance.
+ */
+public final class Dependency
+{
+
+    private final Artifact artifact;
+
+    private final String scope;
+
+    private final Boolean optional;
+
+    private final Set<Exclusion> exclusions;
+
+    /**
+     * Creates a mandatory dependency on the specified artifact with the given scope.
+     * 
+     * @param artifact The artifact being depended on, must not be {@code null}.
+     * @param scope The scope of the dependency, may be {@code null}.
+     */
+    public Dependency( Artifact artifact, String scope )
+    {
+        this( artifact, scope, false );
+    }
+
+    /**
+     * Creates a dependency on the specified artifact with the given scope.
+     * 
+     * @param artifact The artifact being depended on, must not be {@code null}.
+     * @param scope The scope of the dependency, may be {@code null}.
+     * @param optional A flag whether the dependency is optional or mandatory, may be {@code null}.
+     */
+    public Dependency( Artifact artifact, String scope, Boolean optional )
+    {
+        this( artifact, scope, optional, null );
+    }
+
+    /**
+     * Creates a dependency on the specified artifact with the given scope and exclusions.
+     * 
+     * @param artifact The artifact being depended on, must not be {@code null}.
+     * @param scope The scope of the dependency, may be {@code null}.
+     * @param optional A flag whether the dependency is optional or mandatory, may be {@code null}.
+     * @param exclusions The exclusions that apply to transitive dependencies, may be {@code null} if none.
+     */
+    public Dependency( Artifact artifact, String scope, Boolean optional, Collection<Exclusion> exclusions )
+    {
+        this( artifact, scope, Exclusions.copy( exclusions ), optional );
+    }
+
+    private Dependency( Artifact artifact, String scope, Set<Exclusion> exclusions, Boolean optional )
+    {
+        // NOTE: This constructor assumes immutability of the provided exclusion collection, for internal use only
+        if ( artifact == null )
+        {
+            throw new IllegalArgumentException( "no artifact specified for dependency" );
+        }
+        this.artifact = artifact;
+        this.scope = ( scope != null ) ? scope : "";
+        this.optional = optional;
+        this.exclusions = exclusions;
+    }
+
+    /**
+     * Gets the artifact being depended on.
+     * 
+     * @return The artifact, never {@code null}.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the artifact being depended on.
+     * 
+     * @param artifact The artifact, must not be {@code null}.
+     * @return The new dependency, never {@code null}.
+     */
+    public Dependency setArtifact( Artifact artifact )
+    {
+        if ( this.artifact.equals( artifact ) )
+        {
+            return this;
+        }
+        return new Dependency( artifact, scope, exclusions, optional );
+    }
+
+    /**
+     * Gets the scope of the dependency. The scope defines in which context this dependency is relevant.
+     * 
+     * @return The scope or an empty string if not set, never {@code null}.
+     */
+    public String getScope()
+    {
+        return scope;
+    }
+
+    /**
+     * Sets the scope of the dependency, e.g. "compile".
+     * 
+     * @param scope The scope of the dependency, may be {@code null}.
+     * @return The new dependency, never {@code null}.
+     */
+    public Dependency setScope( String scope )
+    {
+        if ( this.scope.equals( scope ) || ( scope == null && this.scope.length() <= 0 ) )
+        {
+            return this;
+        }
+        return new Dependency( artifact, scope, exclusions, optional );
+    }
+
+    /**
+     * Indicates whether this dependency is optional or not. Optional dependencies can be ignored in some contexts.
+     * 
+     * @return {@code true} if the dependency is (definitively) optional, {@code false} otherwise.
+     */
+    public boolean isOptional()
+    {
+        return Boolean.TRUE.equals( optional );
+    }
+
+    /**
+     * Gets the optional flag for the dependency. Note: Most clients will usually call {@link #isOptional()} to
+     * determine the optional flag, this method is for advanced use cases where three-valued logic is required.
+     * 
+     * @return The optional flag or {@code null} if unspecified.
+     */
+    public Boolean getOptional()
+    {
+        return optional;
+    }
+
+    /**
+     * Sets the optional flag for the dependency.
+     * 
+     * @param optional {@code true} if the dependency is optional, {@code false} if the dependency is mandatory, may be
+     *            {@code null} if unspecified.
+     * @return The new dependency, never {@code null}.
+     */
+    public Dependency setOptional( Boolean optional )
+    {
+        if ( eq( this.optional, optional ) )
+        {
+            return this;
+        }
+        return new Dependency( artifact, scope, exclusions, optional );
+    }
+
+    /**
+     * Gets the exclusions for this dependency. Exclusions can be used to remove transitive dependencies during
+     * resolution.
+     * 
+     * @return The (read-only) exclusions, never {@code null}.
+     */
+    public Collection<Exclusion> getExclusions()
+    {
+        return exclusions;
+    }
+
+    /**
+     * Sets the exclusions for the dependency.
+     * 
+     * @param exclusions The exclusions, may be {@code null}.
+     * @return The new dependency, never {@code null}.
+     */
+    public Dependency setExclusions( Collection<Exclusion> exclusions )
+    {
+        if ( hasEquivalentExclusions( exclusions ) )
+        {
+            return this;
+        }
+        return new Dependency( artifact, scope, optional, exclusions );
+    }
+
+    private boolean hasEquivalentExclusions( Collection<Exclusion> exclusions )
+    {
+        if ( exclusions == null || exclusions.isEmpty() )
+        {
+            return this.exclusions.isEmpty();
+        }
+        if ( exclusions instanceof Set )
+        {
+            return this.exclusions.equals( exclusions );
+        }
+        return exclusions.size() >= this.exclusions.size() && this.exclusions.containsAll( exclusions )
+            && exclusions.containsAll( this.exclusions );
+    }
+
+    @Override
+    public String toString()
+    {
+        return String.valueOf( getArtifact() ) + " (" + getScope() + ( isOptional() ? "?" : "" ) + ")";
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+        else if ( obj == null || !getClass().equals( obj.getClass() ) )
+        {
+            return false;
+        }
+
+        Dependency that = (Dependency) obj;
+
+        return artifact.equals( that.artifact ) && scope.equals( that.scope ) && eq( optional, that.optional )
+            && exclusions.equals( that.exclusions );
+    }
+
+    private static <T> boolean eq( T o1, T o2 )
+    {
+        return ( o1 != null ) ? o1.equals( o2 ) : o2 == null;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = 17;
+        hash = hash * 31 + artifact.hashCode();
+        hash = hash * 31 + scope.hashCode();
+        hash = hash * 31 + ( optional != null ? optional.hashCode() : 0 );
+        hash = hash * 31 + exclusions.size();
+        return hash;
+    }
+
+    private static class Exclusions
+        extends AbstractSet<Exclusion>
+    {
+
+        private final Exclusion[] exclusions;
+
+        public static Set<Exclusion> copy( Collection<Exclusion> exclusions )
+        {
+            if ( exclusions == null || exclusions.isEmpty() )
+            {
+                return Collections.emptySet();
+            }
+            return new Exclusions( exclusions );
+        }
+
+        private Exclusions( Collection<Exclusion> exclusions )
+        {
+            if ( exclusions.size() > 1 && !( exclusions instanceof Set ) )
+            {
+                exclusions = new LinkedHashSet<Exclusion>( exclusions );
+            }
+            this.exclusions = exclusions.toArray( new Exclusion[exclusions.size()] );
+        }
+
+        @Override
+        public Iterator<Exclusion> iterator()
+        {
+            return new Iterator<Exclusion>()
+            {
+
+                private int cursor = 0;
+
+                public boolean hasNext()
+                {
+                    return cursor < exclusions.length;
+                }
+
+                public Exclusion next()
+                {
+                    try
+                    {
+                        Exclusion exclusion = exclusions[cursor];
+                        cursor++;
+                        return exclusion;
+                    }
+                    catch ( IndexOutOfBoundsException e )
+                    {
+                        throw new NoSuchElementException();
+                    }
+                }
+
+                public void remove()
+                {
+                    throw new UnsupportedOperationException();
+                }
+
+            };
+        }
+
+        @Override
+        public int size()
+        {
+            return exclusions.length;
+        }
+
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyCycle.java b/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyCycle.java
new file mode 100644 (file)
index 0000000..68f9a32
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.graph;
+
+import java.util.List;
+
+/**
+ * A cycle within a dependency graph, that is a sequence of dependencies d_1, d_2, ..., d_n where d_1 and d_n have the
+ * same versionless coordinates. In more practical terms, a cycle occurs when a project directly or indirectly depends
+ * on its own output artifact.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface DependencyCycle
+{
+
+    /**
+     * Gets the dependencies that lead to the first dependency on the cycle, starting from the root of the dependency
+     * graph.
+     * 
+     * @return The (read-only) sequence of dependencies that precedes the cycle in the graph, potentially empty but
+     *         never {@code null}.
+     */
+    List<Dependency> getPrecedingDependencies();
+
+    /**
+     * Gets the dependencies that actually form the cycle. For example, a -&gt; b -&gt; c -&gt; a, i.e. the last
+     * dependency in this sequence duplicates the first element and closes the cycle. Hence the length of the cycle is
+     * the size of the returned sequence minus 1.
+     * 
+     * @return The (read-only) sequence of dependencies that forms the cycle, never {@code null}.
+     */
+    List<Dependency> getCyclicDependencies();
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyFilter.java b/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyFilter.java
new file mode 100644 (file)
index 0000000..c776ddc
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.graph;
+
+import java.util.List;
+
+/**
+ * A filter to include/exclude dependency nodes during other operations.
+ */
+public interface DependencyFilter
+{
+
+    /**
+     * Indicates whether the specified dependency node shall be included or excluded.
+     * 
+     * @param node The dependency node to filter, must not be {@code null}.
+     * @param parents The (read-only) chain of parent nodes that leads to the node to be filtered, must not be
+     *            {@code null}. Iterating this (possibly empty) list walks up the dependency graph towards the root
+     *            node, i.e. the immediate parent node (if any) is the first node in the list. The size of the list also
+     *            denotes the zero-based depth of the filtered node.
+     * @return {@code true} to include the dependency node, {@code false} to exclude it.
+     */
+    boolean accept( DependencyNode node, List<DependencyNode> parents );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyNode.java b/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyNode.java
new file mode 100644 (file)
index 0000000..4e34597
--- /dev/null
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.graph;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.version.Version;
+import org.eclipse.aether.version.VersionConstraint;
+
+/**
+ * A node within a dependency graph. To conserve memory, dependency graphs may reuse a given node instance multiple
+ * times to represent reoccurring dependencies. As such clients traversing a dependency graph should be prepared to
+ * discover multiple paths leading to the same node instance unless the input graph is known to be a duplicate-free
+ * tree. <em>Note:</em> Unless otherwise noted, implementation classes are not thread-safe and dependency nodes should
+ * not be mutated by concurrent threads.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface DependencyNode
+{
+
+    /**
+     * A bit flag indicating the dependency version was subject to dependency management
+     * 
+     * @see #getManagedBits()
+     */
+    int MANAGED_VERSION = 0x01;
+
+    /**
+     * A bit flag indicating the dependency scope was subject to dependency management
+     * 
+     * @see #getManagedBits()
+     */
+    int MANAGED_SCOPE = 0x02;
+
+    /**
+     * A bit flag indicating the optional flag was subject to dependency management
+     * 
+     * @see #getManagedBits()
+     */
+    int MANAGED_OPTIONAL = 0x04;
+
+    /**
+     * A bit flag indicating the artifact properties were subject to dependency management
+     * 
+     * @see #getManagedBits()
+     */
+    int MANAGED_PROPERTIES = 0x08;
+
+    /**
+     * A bit flag indicating the exclusions were subject to dependency management
+     * 
+     * @see #getManagedBits()
+     */
+    int MANAGED_EXCLUSIONS = 0x10;
+
+    /**
+     * Gets the child nodes of this node. To conserve memory, dependency nodes with equal dependencies may share the
+     * same child list instance. Hence clients mutating the child list need to be aware that these changes might affect
+     * more than this node. Where this is not desired, the child list should be copied before mutation if the client
+     * cannot be sure whether it might be shared with other nodes in the graph.
+     * 
+     * @return The child nodes of this node, never {@code null}.
+     */
+    List<DependencyNode> getChildren();
+
+    /**
+     * Sets the child nodes of this node.
+     * 
+     * @param children The child nodes, may be {@code null}
+     */
+    void setChildren( List<DependencyNode> children );
+
+    /**
+     * Gets the dependency associated with this node. <em>Note:</em> For dependency graphs that have been constructed
+     * without a root dependency, this method will yield {@code null} when invoked on the graph's root node. The root
+     * node of such graphs may however still have a label as returned by {@link #getArtifact()}.
+     * 
+     * @return The dependency or {@code null} if none.
+     */
+    Dependency getDependency();
+
+    /**
+     * Gets the artifact associated with this node. If this node is associated with a dependency, this is equivalent to
+     * {@code getDependency().getArtifact()}. Otherwise the artifact merely provides a label for this node in which case
+     * the artifact must not be subjected to dependency collection/resolution.
+     * 
+     * @return The associated artifact or {@code null} if none.
+     */
+    Artifact getArtifact();
+
+    /**
+     * Updates the artifact of the dependency after resolution. The new artifact must have the same coordinates as the
+     * original artifact. This method may only be invoked if this node actually has a dependency, i.e. if
+     * {@link #getDependency()} is not null.
+     * 
+     * @param artifact The artifact satisfying the dependency, must not be {@code null}.
+     */
+    void setArtifact( Artifact artifact );
+
+    /**
+     * Gets the sequence of relocations that was followed to resolve the artifact referenced by the dependency.
+     * 
+     * @return The (read-only) sequence of relocations, never {@code null}.
+     */
+    List<? extends Artifact> getRelocations();
+
+    /**
+     * Gets the known aliases for this dependency's artifact. An alias can be used to mark a patched rebuild of some
+     * other artifact as such, thereby allowing conflict resolution to consider the patched and the original artifact as
+     * a conflict.
+     * 
+     * @return The (read-only) set of known aliases, never {@code null}.
+     */
+    Collection<? extends Artifact> getAliases();
+
+    /**
+     * Gets the version constraint that was parsed from the dependency's version declaration.
+     * 
+     * @return The version constraint for this node or {@code null}.
+     */
+    VersionConstraint getVersionConstraint();
+
+    /**
+     * Gets the version that was selected for the dependency's target artifact.
+     * 
+     * @return The parsed version or {@code null}.
+     */
+    Version getVersion();
+
+    /**
+     * Sets the scope of the dependency. This method may only be invoked if this node actually has a dependency, i.e. if
+     * {@link #getDependency()} is not null.
+     * 
+     * @param scope The scope, may be {@code null}.
+     */
+    void setScope( String scope );
+
+    /**
+     * Sets the optional flag of the dependency. This method may only be invoked if this node actually has a dependency,
+     * i.e. if {@link #getDependency()} is not null.
+     * 
+     * @param optional The optional flag, may be {@code null}.
+     */
+    void setOptional( Boolean optional );
+
+    /**
+     * Gets a bit field indicating which attributes of this node were subject to dependency management.
+     * 
+     * @return A bit field containing any of the bits {@link #MANAGED_VERSION}, {@link #MANAGED_SCOPE},
+     *         {@link #MANAGED_OPTIONAL}, {@link #MANAGED_PROPERTIES} and {@link #MANAGED_EXCLUSIONS} if the
+     *         corresponding attribute was set via dependency management.
+     */
+    int getManagedBits();
+
+    /**
+     * Gets the remote repositories from which this node's artifact shall be resolved.
+     * 
+     * @return The (read-only) list of remote repositories to use for artifact resolution, never {@code null}.
+     */
+    List<RemoteRepository> getRepositories();
+
+    /**
+     * Gets the request context in which this dependency node was created.
+     * 
+     * @return The request context, never {@code null}.
+     */
+    String getRequestContext();
+
+    /**
+     * Sets the request context in which this dependency node was created.
+     * 
+     * @param context The context, may be {@code null}.
+     */
+    void setRequestContext( String context );
+
+    /**
+     * Gets the custom data associated with this dependency node. Clients of the repository system can use this data to
+     * annotate dependency nodes with domain-specific information. Note that the returned map is read-only and
+     * {@link #setData(Object, Object)} needs to be used to update the custom data.
+     * 
+     * @return The (read-only) key-value mappings, never {@code null}.
+     */
+    Map<?, ?> getData();
+
+    /**
+     * Sets the custom data associated with this dependency node.
+     * 
+     * @param data The new custom data, may be {@code null}.
+     */
+    void setData( Map<Object, Object> data );
+
+    /**
+     * Associates the specified dependency node data with the given key. <em>Note:</em> This method must not be called
+     * while {@link #getData()} is being iterated.
+     * 
+     * @param key The key under which to store the data, must not be {@code null}.
+     * @param value The data to associate with the key, may be {@code null} to remove the mapping.
+     */
+    void setData( Object key, Object value );
+
+    /**
+     * Traverses this node and potentially its children using the specified visitor.
+     * 
+     * @param visitor The visitor to call back, must not be {@code null}.
+     * @return {@code true} to visit siblings nodes of this node as well, {@code false} to skip siblings.
+     */
+    boolean accept( DependencyVisitor visitor );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyVisitor.java b/org.argeo.slc.repo/src/org/eclipse/aether/graph/DependencyVisitor.java
new file mode 100644 (file)
index 0000000..d4ba213
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.graph;
+
+/**
+ * A visitor for nodes of the dependency graph.
+ * 
+ * @see DependencyNode#accept(DependencyVisitor)
+ */
+public interface DependencyVisitor
+{
+
+    /**
+     * Notifies the visitor of a node visit before its children have been processed.
+     * 
+     * @param node The dependency node being visited, must not be {@code null}.
+     * @return {@code true} to visit child nodes of the specified node as well, {@code false} to skip children.
+     */
+    boolean visitEnter( DependencyNode node );
+
+    /**
+     * Notifies the visitor of a node visit after its children have been processed. Note that this method is always
+     * invoked regardless whether any children have actually been visited.
+     * 
+     * @param node The dependency node being visited, must not be {@code null}.
+     * @return {@code true} to visit siblings nodes of the specified node as well, {@code false} to skip siblings.
+     */
+    boolean visitLeave( DependencyNode node );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/graph/Exclusion.java b/org.argeo.slc.repo/src/org/eclipse/aether/graph/Exclusion.java
new file mode 100644 (file)
index 0000000..4d6b7ba
--- /dev/null
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.graph;
+
+/**
+ * An exclusion of one or more transitive dependencies. <em>Note:</em> Instances of this class are immutable and the
+ * exposed mutators return new objects rather than changing the current instance.
+ * 
+ * @see Dependency#getExclusions()
+ */
+public final class Exclusion
+{
+
+    private final String groupId;
+
+    private final String artifactId;
+
+    private final String classifier;
+
+    private final String extension;
+
+    /**
+     * Creates an exclusion for artifacts with the specified coordinates.
+     * 
+     * @param groupId The group identifier, may be {@code null}.
+     * @param artifactId The artifact identifier, may be {@code null}.
+     * @param classifier The classifier, may be {@code null}.
+     * @param extension The file extension, may be {@code null}.
+     */
+    public Exclusion( String groupId, String artifactId, String classifier, String extension )
+    {
+        this.groupId = ( groupId != null ) ? groupId : "";
+        this.artifactId = ( artifactId != null ) ? artifactId : "";
+        this.classifier = ( classifier != null ) ? classifier : "";
+        this.extension = ( extension != null ) ? extension : "";
+    }
+
+    /**
+     * Gets the group identifier for artifacts to exclude.
+     * 
+     * @return The group identifier, never {@code null}.
+     */
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    /**
+     * Gets the artifact identifier for artifacts to exclude.
+     * 
+     * @return The artifact identifier, never {@code null}.
+     */
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    /**
+     * Gets the classifier for artifacts to exclude.
+     * 
+     * @return The classifier, never {@code null}.
+     */
+    public String getClassifier()
+    {
+        return classifier;
+    }
+
+    /**
+     * Gets the file extension for artifacts to exclude.
+     * 
+     * @return The file extension of artifacts to exclude, never {@code null}.
+     */
+    public String getExtension()
+    {
+        return extension;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getGroupId() + ':' + getArtifactId() + ':' + getExtension()
+            + ( getClassifier().length() > 0 ? ':' + getClassifier() : "" );
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+        else if ( obj == null || !getClass().equals( obj.getClass() ) )
+        {
+            return false;
+        }
+
+        Exclusion that = (Exclusion) obj;
+
+        return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId )
+            && extension.equals( that.extension ) && classifier.equals( that.classifier );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = 17;
+        hash = hash * 31 + artifactId.hashCode();
+        hash = hash * 31 + groupId.hashCode();
+        hash = hash * 31 + classifier.hashCode();
+        hash = hash * 31 + extension.hashCode();
+        return hash;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/graph/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/graph/package-info.java
new file mode 100644 (file)
index 0000000..70879a3
--- /dev/null
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The representation of a dependency graph by means of connected dependency nodes.
+ */
+package org.eclipse.aether.graph;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallRequest.java
new file mode 100644 (file)
index 0000000..330f85a
--- /dev/null
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.installation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.metadata.Metadata;
+
+/**
+ * A request to install artifacts and their accompanying metadata into the local repository.
+ * 
+ * @see RepositorySystem#install(RepositorySystemSession, InstallRequest)
+ */
+public final class InstallRequest
+{
+
+    private Collection<Artifact> artifacts = Collections.emptyList();
+
+    private Collection<Metadata> metadata = Collections.emptyList();
+
+    private RequestTrace trace;
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public InstallRequest()
+    {
+    }
+
+    /**
+     * Gets the artifact to install.
+     * 
+     * @return The artifacts to install, never {@code null}.
+     */
+    public Collection<Artifact> getArtifacts()
+    {
+        return artifacts;
+    }
+
+    /**
+     * Sets the artifacts to install.
+     * 
+     * @param artifacts The artifacts to install, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public InstallRequest setArtifacts( Collection<Artifact> artifacts )
+    {
+        if ( artifacts == null )
+        {
+            this.artifacts = Collections.emptyList();
+        }
+        else
+        {
+            this.artifacts = artifacts;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified artifacts for installation.
+     * 
+     * @param artifact The artifact to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public InstallRequest addArtifact( Artifact artifact )
+    {
+        if ( artifact != null )
+        {
+            if ( artifacts.isEmpty() )
+            {
+                artifacts = new ArrayList<Artifact>();
+            }
+            artifacts.add( artifact );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the metadata to install.
+     * 
+     * @return The metadata to install, never {@code null}.
+     */
+    public Collection<Metadata> getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Sets the metadata to install.
+     * 
+     * @param metadata The metadata to install.
+     * @return This request for chaining, never {@code null}.
+     */
+    public InstallRequest setMetadata( Collection<Metadata> metadata )
+    {
+        if ( metadata == null )
+        {
+            this.metadata = Collections.emptyList();
+        }
+        else
+        {
+            this.metadata = metadata;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified metadata for installation.
+     * 
+     * @param metadata The metadata to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public InstallRequest addMetadata( Metadata metadata )
+    {
+        if ( metadata != null )
+        {
+            if ( this.metadata.isEmpty() )
+            {
+                this.metadata = new ArrayList<Metadata>();
+            }
+            this.metadata.add( metadata );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    /**
+     * Sets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @param trace The trace information about the higher level operation, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public InstallRequest setTrace( RequestTrace trace )
+    {
+        this.trace = trace;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifacts() + ", " + getMetadata();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallResult.java
new file mode 100644 (file)
index 0000000..fe3ade1
--- /dev/null
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.installation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.metadata.Metadata;
+
+/**
+ * The result of installing artifacts and their accompanying metadata into the a remote repository.
+ * 
+ * @see RepositorySystem#install(RepositorySystemSession, InstallRequest)
+ */
+public final class InstallResult
+{
+
+    private final InstallRequest request;
+
+    private Collection<Artifact> artifacts;
+
+    private Collection<Metadata> metadata;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The installation request, must not be {@code null}.
+     */
+    public InstallResult( InstallRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "install request has not been specified" );
+        }
+        this.request = request;
+        artifacts = Collections.emptyList();
+        metadata = Collections.emptyList();
+    }
+
+    /**
+     * Gets the install request that was made.
+     * 
+     * @return The install request, never {@code null}.
+     */
+    public InstallRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the artifacts that got installed.
+     * 
+     * @return The installed artifacts, never {@code null}.
+     */
+    public Collection<Artifact> getArtifacts()
+    {
+        return artifacts;
+    }
+
+    /**
+     * Sets the artifacts that got installed.
+     * 
+     * @param artifacts The installed artifacts, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public InstallResult setArtifacts( Collection<Artifact> artifacts )
+    {
+        if ( artifacts == null )
+        {
+            this.artifacts = Collections.emptyList();
+        }
+        else
+        {
+            this.artifacts = artifacts;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified artifacts to the result.
+     * 
+     * @param artifact The installed artifact to add, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public InstallResult addArtifact( Artifact artifact )
+    {
+        if ( artifact != null )
+        {
+            if ( artifacts.isEmpty() )
+            {
+                artifacts = new ArrayList<Artifact>();
+            }
+            artifacts.add( artifact );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the metadata that got installed. Note that due to automatically generated metadata, there might have been
+     * more metadata installed than originally specified in the install request.
+     * 
+     * @return The installed metadata, never {@code null}.
+     */
+    public Collection<Metadata> getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Sets the metadata that got installed.
+     * 
+     * @param metadata The installed metadata, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public InstallResult setMetadata( Collection<Metadata> metadata )
+    {
+        if ( metadata == null )
+        {
+            this.metadata = Collections.emptyList();
+        }
+        else
+        {
+            this.metadata = metadata;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified metadata to this result.
+     * 
+     * @param metadata The installed metadata to add, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public InstallResult addMetadata( Metadata metadata )
+    {
+        if ( metadata != null )
+        {
+            if ( this.metadata.isEmpty() )
+            {
+                this.metadata = new ArrayList<Metadata>();
+            }
+            this.metadata.add( metadata );
+        }
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifacts() + ", " + getMetadata();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallationException.java b/org.argeo.slc.repo/src/org/eclipse/aether/installation/InstallationException.java
new file mode 100644 (file)
index 0000000..e976665
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.installation;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case of an installation error like an IO error.
+ */
+public class InstallationException
+    extends RepositoryException
+{
+
+    /**
+     * Creates a new exception with the specified detail message.
+     * 
+     * @param message The detail message, may be {@code null}.
+     */
+    public InstallationException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * Creates a new exception with the specified detail message and cause.
+     * 
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public InstallationException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/installation/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/installation/package-info.java
new file mode 100644 (file)
index 0000000..35b910b
--- /dev/null
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The types supporting the publishing of artifacts to a local repository.
+ */
+package org.eclipse.aether.installation;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/metadata/AbstractMetadata.java b/org.argeo.slc.repo/src/org/eclipse/aether/metadata/AbstractMetadata.java
new file mode 100644 (file)
index 0000000..d95eb54
--- /dev/null
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.metadata;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A skeleton class for metadata.
+ */
+public abstract class AbstractMetadata
+    implements Metadata
+{
+
+    private Metadata newInstance( Map<String, String> properties, File file )
+    {
+        return new DefaultMetadata( getGroupId(), getArtifactId(), getVersion(), getType(), getNature(), file,
+                                    properties );
+    }
+
+    public Metadata setFile( File file )
+    {
+        File current = getFile();
+        if ( ( current == null ) ? file == null : current.equals( file ) )
+        {
+            return this;
+        }
+        return newInstance( getProperties(), file );
+    }
+
+    public Metadata setProperties( Map<String, String> properties )
+    {
+        Map<String, String> current = getProperties();
+        if ( current.equals( properties ) || ( properties == null && current.isEmpty() ) )
+        {
+            return this;
+        }
+        return newInstance( copyProperties( properties ), getFile() );
+    }
+
+    public String getProperty( String key, String defaultValue )
+    {
+        String value = getProperties().get( key );
+        return ( value != null ) ? value : defaultValue;
+    }
+
+    /**
+     * Copies the specified metadata properties. This utility method should be used when creating new metadata instances
+     * with caller-supplied properties.
+     * 
+     * @param properties The properties to copy, may be {@code null}.
+     * @return The copied and read-only properties, never {@code null}.
+     */
+    protected static Map<String, String> copyProperties( Map<String, String> properties )
+    {
+        if ( properties != null && !properties.isEmpty() )
+        {
+            return Collections.unmodifiableMap( new HashMap<String, String>( properties ) );
+        }
+        else
+        {
+            return Collections.emptyMap();
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder buffer = new StringBuilder( 128 );
+        if ( getGroupId().length() > 0 )
+        {
+            buffer.append( getGroupId() );
+        }
+        if ( getArtifactId().length() > 0 )
+        {
+            buffer.append( ':' ).append( getArtifactId() );
+        }
+        if ( getVersion().length() > 0 )
+        {
+            buffer.append( ':' ).append( getVersion() );
+        }
+        buffer.append( '/' ).append( getType() );
+        return buffer.toString();
+    }
+
+    /**
+     * Compares this metadata with the specified object.
+     * 
+     * @param obj The object to compare this metadata against, may be {@code null}.
+     * @return {@code true} if and only if the specified object is another {@link Metadata} with equal coordinates,
+     *         type, nature, properties and file, {@code false} otherwise.
+     */
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+        else if ( !( obj instanceof Metadata ) )
+        {
+            return false;
+        }
+
+        Metadata that = (Metadata) obj;
+
+        return getArtifactId().equals( that.getArtifactId() ) && getGroupId().equals( that.getGroupId() )
+            && getVersion().equals( that.getVersion() ) && getType().equals( that.getType() )
+            && getNature().equals( that.getNature() ) && eq( getFile(), that.getFile() )
+            && eq( getProperties(), that.getProperties() );
+    }
+
+    private static <T> boolean eq( T s1, T s2 )
+    {
+        return s1 != null ? s1.equals( s2 ) : s2 == null;
+    }
+
+    /**
+     * Returns a hash code for this metadata.
+     * 
+     * @return A hash code for the metadata.
+     */
+    @Override
+    public int hashCode()
+    {
+        int hash = 17;
+        hash = hash * 31 + getGroupId().hashCode();
+        hash = hash * 31 + getArtifactId().hashCode();
+        hash = hash * 31 + getType().hashCode();
+        hash = hash * 31 + getNature().hashCode();
+        hash = hash * 31 + getVersion().hashCode();
+        hash = hash * 31 + hash( getFile() );
+        return hash;
+    }
+
+    private static int hash( Object obj )
+    {
+        return ( obj != null ) ? obj.hashCode() : 0;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/metadata/DefaultMetadata.java b/org.argeo.slc.repo/src/org/eclipse/aether/metadata/DefaultMetadata.java
new file mode 100644 (file)
index 0000000..aa9c830
--- /dev/null
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.metadata;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ * A basic metadata instance. <em>Note:</em> Instances of this class are immutable and the exposed mutators return new
+ * objects rather than changing the current instance.
+ */
+public final class DefaultMetadata
+    extends AbstractMetadata
+{
+
+    private final String groupId;
+
+    private final String artifactId;
+
+    private final String version;
+
+    private final String type;
+
+    private final Nature nature;
+
+    private final File file;
+
+    private final Map<String, String> properties;
+
+    /**
+     * Creates a new metadata for the repository root with the specific type and nature.
+     * 
+     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
+     * @param nature The nature of the metadata, must not be {@code null}.
+     */
+    public DefaultMetadata( String type, Nature nature )
+    {
+        this( "", "", "", type, nature, null, (File) null );
+    }
+
+    /**
+     * Creates a new metadata for the groupId level with the specific type and nature.
+     * 
+     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
+     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
+     * @param nature The nature of the metadata, must not be {@code null}.
+     */
+    public DefaultMetadata( String groupId, String type, Nature nature )
+    {
+        this( groupId, "", "", type, nature, null, (File) null );
+    }
+
+    /**
+     * Creates a new metadata for the groupId:artifactId level with the specific type and nature.
+     * 
+     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
+     * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
+     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
+     * @param nature The nature of the metadata, must not be {@code null}.
+     */
+    public DefaultMetadata( String groupId, String artifactId, String type, Nature nature )
+    {
+        this( groupId, artifactId, "", type, nature, null, (File) null );
+    }
+
+    /**
+     * Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
+     * 
+     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
+     * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
+     * @param version The version to which this metadata applies, may be {@code null}.
+     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
+     * @param nature The nature of the metadata, must not be {@code null}.
+     */
+    public DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature )
+    {
+        this( groupId, artifactId, version, type, nature, null, (File) null );
+    }
+
+    /**
+     * Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
+     * 
+     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
+     * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
+     * @param version The version to which this metadata applies, may be {@code null}.
+     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
+     * @param nature The nature of the metadata, must not be {@code null}.
+     * @param file The resolved file of the metadata, may be {@code null}.
+     */
+    public DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature, File file )
+    {
+        this( groupId, artifactId, version, type, nature, null, file );
+    }
+
+    /**
+     * Creates a new metadata for the groupId:artifactId:version level with the specific type and nature.
+     * 
+     * @param groupId The group identifier to which this metadata applies, may be {@code null}.
+     * @param artifactId The artifact identifier to which this metadata applies, may be {@code null}.
+     * @param version The version to which this metadata applies, may be {@code null}.
+     * @param type The type of the metadata, e.g. "maven-metadata.xml", may be {@code null}.
+     * @param nature The nature of the metadata, must not be {@code null}.
+     * @param properties The properties of the metadata, may be {@code null} if none.
+     * @param file The resolved file of the metadata, may be {@code null}.
+     */
+    public DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature,
+                            Map<String, String> properties, File file )
+    {
+        this.groupId = emptify( groupId );
+        this.artifactId = emptify( artifactId );
+        this.version = emptify( version );
+        this.type = emptify( type );
+        if ( nature == null )
+        {
+            throw new IllegalArgumentException( "metadata nature was not specified" );
+        }
+        this.nature = nature;
+        this.file = file;
+        this.properties = copyProperties( properties );
+    }
+
+    DefaultMetadata( String groupId, String artifactId, String version, String type, Nature nature, File file,
+                     Map<String, String> properties )
+    {
+        // NOTE: This constructor assumes immutability of the provided properties, for internal use only
+        this.groupId = emptify( groupId );
+        this.artifactId = emptify( artifactId );
+        this.version = emptify( version );
+        this.type = emptify( type );
+        this.nature = nature;
+        this.file = file;
+        this.properties = properties;
+    }
+
+    private static String emptify( String str )
+    {
+        return ( str == null ) ? "" : str;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public Nature getNature()
+    {
+        return nature;
+    }
+
+    public File getFile()
+    {
+        return file;
+    }
+
+    public Map<String, String> getProperties()
+    {
+        return properties;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/metadata/MergeableMetadata.java b/org.argeo.slc.repo/src/org/eclipse/aether/metadata/MergeableMetadata.java
new file mode 100644 (file)
index 0000000..25f15df
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.metadata;
+
+import java.io.File;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * A piece of metadata that needs to be merged with any current metadata before installation/deployment.
+ */
+public interface MergeableMetadata
+    extends Metadata
+{
+
+    /**
+     * Merges this metadata into the current metadata (if any). Note that this method will be invoked regardless whether
+     * metadata currently exists or not.
+     * 
+     * @param current The path to the current metadata file, may not exist but must not be {@code null}.
+     * @param result The path to the result file where the merged metadata should be stored, must not be {@code null}.
+     * @throws RepositoryException If the metadata could not be merged.
+     */
+    void merge( File current, File result )
+        throws RepositoryException;
+
+    /**
+     * Indicates whether this metadata has been merged.
+     * 
+     * @return {@code true} if the metadata has been merged, {@code false} otherwise.
+     */
+    boolean isMerged();
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/metadata/Metadata.java b/org.argeo.slc.repo/src/org/eclipse/aether/metadata/Metadata.java
new file mode 100644 (file)
index 0000000..328544a
--- /dev/null
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.metadata;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ * A piece of repository metadata, e.g. an index of available versions. In contrast to an artifact, which usually exists
+ * in only one repository, metadata usually exists in multiple repositories and each repository contains a different
+ * copy of the metadata. <em>Note:</em> Metadata instances are supposed to be immutable, e.g. any exposed mutator method
+ * returns a new metadata instance and leaves the original instance unchanged. Implementors are strongly advised to obey
+ * this contract. <em>Note:</em> Implementors are strongly advised to inherit from {@link AbstractMetadata} instead of
+ * directly implementing this interface.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface Metadata
+{
+
+    /**
+     * The nature of the metadata.
+     */
+    enum Nature
+    {
+        /**
+         * The metadata refers to release artifacts only.
+         */
+        RELEASE,
+
+        /**
+         * The metadata refers to snapshot artifacts only.
+         */
+        SNAPSHOT,
+
+        /**
+         * The metadata refers to either release or snapshot artifacts.
+         */
+        RELEASE_OR_SNAPSHOT
+    }
+
+    /**
+     * Gets the group identifier of this metadata.
+     * 
+     * @return The group identifier or an empty string if the metadata applies to the entire repository, never
+     *         {@code null}.
+     */
+    String getGroupId();
+
+    /**
+     * Gets the artifact identifier of this metadata.
+     * 
+     * @return The artifact identifier or an empty string if the metadata applies to the groupId level only, never
+     *         {@code null}.
+     */
+    String getArtifactId();
+
+    /**
+     * Gets the version of this metadata.
+     * 
+     * @return The version or an empty string if the metadata applies to the groupId:artifactId level only, never
+     *         {@code null}.
+     */
+    String getVersion();
+
+    /**
+     * Gets the type of the metadata, e.g. "maven-metadata.xml".
+     * 
+     * @return The type of the metadata, never {@code null}.
+     */
+    String getType();
+
+    /**
+     * Gets the nature of this metadata. The nature indicates to what artifact versions the metadata refers.
+     * 
+     * @return The nature, never {@code null}.
+     */
+    Nature getNature();
+
+    /**
+     * Gets the file of this metadata. Note that only resolved metadata has a file associated with it.
+     * 
+     * @return The file or {@code null} if none.
+     */
+    File getFile();
+
+    /**
+     * Sets the file of the metadata.
+     * 
+     * @param file The file of the metadata, may be {@code null}
+     * @return The new metadata, never {@code null}.
+     */
+    Metadata setFile( File file );
+
+    /**
+     * Gets the specified property.
+     * 
+     * @param key The name of the property, must not be {@code null}.
+     * @param defaultValue The default value to return in case the property is not set, may be {@code null}.
+     * @return The requested property value or {@code null} if the property is not set and no default value was
+     *         provided.
+     */
+    String getProperty( String key, String defaultValue );
+
+    /**
+     * Gets the properties of this metadata.
+     * 
+     * @return The (read-only) properties, never {@code null}.
+     */
+    Map<String, String> getProperties();
+
+    /**
+     * Sets the properties for the metadata.
+     * 
+     * @param properties The properties for the metadata, may be {@code null}.
+     * @return The new metadata, never {@code null}.
+     */
+    Metadata setProperties( Map<String, String> properties );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/metadata/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/metadata/package-info.java
new file mode 100644 (file)
index 0000000..141a837
--- /dev/null
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The definition of metadata, that is an auxiliary entity managed by the repository system to locate artifacts.
+ */
+package org.eclipse.aether.metadata;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/package-info.java
new file mode 100644 (file)
index 0000000..7268b46
--- /dev/null
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The primary API of the {@link org.eclipse.aether.RepositorySystem} and its functionality.
+ */
+package org.eclipse.aether;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/ArtifactRepository.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/ArtifactRepository.java
new file mode 100644 (file)
index 0000000..2000f8b
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+/**
+ * A repository hosting artifacts.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface ArtifactRepository
+{
+
+    /**
+     * Gets the type of the repository, for example "default".
+     * 
+     * @return The (case-sensitive) type of the repository, never {@code null}.
+     */
+    String getContentType();
+
+    /**
+     * Gets the identifier of this repository.
+     * 
+     * @return The (case-sensitive) identifier, never {@code null}.
+     */
+    String getId();
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/Authentication.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/Authentication.java
new file mode 100644 (file)
index 0000000..c1eaac0
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.util.Map;
+
+/**
+ * The authentication to use for accessing a protected resource. This acts basically as an extensible callback mechanism
+ * from which network operations can request authentication data like username and password when needed.
+ */
+public interface Authentication
+{
+
+    /**
+     * Fills the given authentication context with the data from this authentication callback. To do so, implementors
+     * have to call {@link AuthenticationContext#put(String, Object)}. <br>
+     * <br>
+     * The {@code key} parameter supplied to this method acts merely as a hint for interactive callbacks that want to
+     * prompt the user for only that authentication data which is required. Implementations are free to ignore this
+     * parameter and put all the data they have into the authentication context at once.
+     * 
+     * @param context The authentication context to populate, must not be {@code null}.
+     * @param key The key denoting a specific piece of authentication data that is being requested for a network
+     *            operation, may be {@code null}.
+     * @param data Any (read-only) extra data in form of key value pairs that might be useful when getting the
+     *            authentication data, may be {@code null}.
+     */
+    void fill( AuthenticationContext context, String key, Map<String, String> data );
+
+    /**
+     * Updates the given digest with data from this authentication callback. To do so, implementors have to call the
+     * {@code update()} methods in {@link AuthenticationDigest}.
+     * 
+     * @param digest The digest to update, must not be {@code null}.
+     */
+    void digest( AuthenticationDigest digest );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationContext.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationContext.java
new file mode 100644 (file)
index 0000000..5b1ba2c
--- /dev/null
@@ -0,0 +1,380 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.io.Closeable;
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.aether.RepositorySystemSession;
+
+/**
+ * A glorified map of key value pairs holding (cleartext) authentication data. Authentication contexts are used
+ * internally when network operations need to access secured repositories or proxies. Each authentication context
+ * manages the credentials required to access a single host. Unlike {@link Authentication} callbacks which exist for a
+ * potentially long time like the duration of a repository system session, an authentication context has a supposedly
+ * short lifetime and should be {@link #close() closed} as soon as the corresponding network operation has finished:
+ * 
+ * <pre>
+ * AuthenticationContext context = AuthenticationContext.forRepository( session, repository );
+ * try {
+ *     // get credentials
+ *     char[] password = context.get( AuthenticationContext.PASSWORD, char[].class );
+ *     // perform network operation using retrieved credentials
+ *     ...
+ * } finally {
+ *     // erase confidential authentication data from heap memory
+ *     AuthenticationContext.close( context );
+ * }
+ * </pre>
+ * 
+ * The same authentication data can often be presented using different data types, e.g. a password can be presented
+ * using a character array or (less securely) using a string. For ease of use, an authentication context treats the
+ * following groups of data types as equivalent and converts values automatically during retrieval:
+ * <ul>
+ * <li>{@code String}, {@code char[]}</li>
+ * <li>{@code String}, {@code File}</li>
+ * </ul>
+ * An authentication context is thread-safe.
+ */
+public final class AuthenticationContext
+    implements Closeable
+{
+
+    /**
+     * The key used to store the username. The corresponding authentication data should be of type {@link String}.
+     */
+    public static final String USERNAME = "username";
+
+    /**
+     * The key used to store the password. The corresponding authentication data should be of type {@code char[]} or
+     * {@link String}.
+     */
+    public static final String PASSWORD = "password";
+
+    /**
+     * The key used to store the NTLM domain. The corresponding authentication data should be of type {@link String}.
+     */
+    public static final String NTLM_DOMAIN = "ntlm.domain";
+
+    /**
+     * The key used to store the NTML workstation. The corresponding authentication data should be of type
+     * {@link String}.
+     */
+    public static final String NTLM_WORKSTATION = "ntlm.workstation";
+
+    /**
+     * The key used to store the pathname to a private key file. The corresponding authentication data should be of type
+     * {@link String} or {@link File}.
+     */
+    public static final String PRIVATE_KEY_PATH = "privateKey.path";
+
+    /**
+     * The key used to store the passphrase protecting the private key. The corresponding authentication data should be
+     * of type {@code char[]} or {@link String}.
+     */
+    public static final String PRIVATE_KEY_PASSPHRASE = "privateKey.passphrase";
+
+    /**
+     * The key used to store the acceptance policy for unknown host keys. The corresponding authentication data should
+     * be of type {@link Boolean}. When querying this authentication data, the extra data should provide
+     * {@link #HOST_KEY_REMOTE} and {@link #HOST_KEY_LOCAL}, e.g. to enable a well-founded decision of the user during
+     * an interactive prompt.
+     */
+    public static final String HOST_KEY_ACCEPTANCE = "hostKey.acceptance";
+
+    /**
+     * The key used to store the fingerprint of the public key advertised by remote host. Note that this key is used to
+     * query the extra data passed to {@link #get(String, Map, Class)} when getting {@link #HOST_KEY_ACCEPTANCE}, not
+     * the authentication data in a context.
+     */
+    public static final String HOST_KEY_REMOTE = "hostKey.remote";
+
+    /**
+     * The key used to store the fingerprint of the public key expected from remote host as recorded in a known hosts
+     * database. Note that this key is used to query the extra data passed to {@link #get(String, Map, Class)} when
+     * getting {@link #HOST_KEY_ACCEPTANCE}, not the authentication data in a context.
+     */
+    public static final String HOST_KEY_LOCAL = "hostKey.local";
+
+    /**
+     * The key used to store the SSL context. The corresponding authentication data should be of type
+     * {@link javax.net.ssl.SSLContext}.
+     */
+    public static final String SSL_CONTEXT = "ssl.context";
+
+    /**
+     * The key used to store the SSL hostname verifier. The corresponding authentication data should be of type
+     * {@link javax.net.ssl.HostnameVerifier}.
+     */
+    public static final String SSL_HOSTNAME_VERIFIER = "ssl.hostnameVerifier";
+
+    private final RepositorySystemSession session;
+
+    private final RemoteRepository repository;
+
+    private final Proxy proxy;
+
+    private final Authentication auth;
+
+    private final Map<String, Object> authData;
+
+    private boolean fillingAuthData;
+
+    /**
+     * Gets an authentication context for the specified repository.
+     * 
+     * @param session The repository system session during which the repository is accessed, must not be {@code null}.
+     * @param repository The repository for which to create an authentication context, must not be {@code null}.
+     * @return An authentication context for the repository or {@code null} if no authentication is configured for it.
+     */
+    public static AuthenticationContext forRepository( RepositorySystemSession session, RemoteRepository repository )
+    {
+        return newInstance( session, repository, null, repository.getAuthentication() );
+    }
+
+    /**
+     * Gets an authentication context for the proxy of the specified repository.
+     * 
+     * @param session The repository system session during which the repository is accessed, must not be {@code null}.
+     * @param repository The repository for whose proxy to create an authentication context, must not be {@code null}.
+     * @return An authentication context for the proxy or {@code null} if no proxy is set or no authentication is
+     *         configured for it.
+     */
+    public static AuthenticationContext forProxy( RepositorySystemSession session, RemoteRepository repository )
+    {
+        Proxy proxy = repository.getProxy();
+        return newInstance( session, repository, proxy, ( proxy != null ) ? proxy.getAuthentication() : null );
+    }
+
+    private static AuthenticationContext newInstance( RepositorySystemSession session, RemoteRepository repository,
+                                                      Proxy proxy, Authentication auth )
+    {
+        if ( auth == null )
+        {
+            return null;
+        }
+        return new AuthenticationContext( session, repository, proxy, auth );
+    }
+
+    private AuthenticationContext( RepositorySystemSession session, RemoteRepository repository, Proxy proxy,
+                                   Authentication auth )
+    {
+        if ( session == null )
+        {
+            throw new IllegalArgumentException( "repository system session missing" );
+        }
+        this.session = session;
+        this.repository = repository;
+        this.proxy = proxy;
+        this.auth = auth;
+        authData = new HashMap<String, Object>();
+    }
+
+    /**
+     * Gets the repository system session during which the authentication happens.
+     * 
+     * @return The repository system session, never {@code null}.
+     */
+    public RepositorySystemSession getSession()
+    {
+        return session;
+    }
+
+    /**
+     * Gets the repository requiring authentication. If {@link #getProxy()} is not {@code null}, the data gathered by
+     * this authentication context does not apply to the repository's host but rather the proxy.
+     * 
+     * @return The repository to be contacted, never {@code null}.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Gets the proxy (if any) to be authenticated with.
+     * 
+     * @return The proxy or {@code null} if authenticating directly with the repository's host.
+     */
+    public Proxy getProxy()
+    {
+        return proxy;
+    }
+
+    /**
+     * Gets the authentication data for the specified key.
+     * 
+     * @param key The key whose authentication data should be retrieved, must not be {@code null}.
+     * @return The requested authentication data or {@code null} if none.
+     */
+    public String get( String key )
+    {
+        return get( key, null, String.class );
+    }
+
+    /**
+     * Gets the authentication data for the specified key.
+     * 
+     * @param <T> The data type of the authentication data.
+     * @param key The key whose authentication data should be retrieved, must not be {@code null}.
+     * @param type The expected type of the authentication data, must not be {@code null}.
+     * @return The requested authentication data or {@code null} if none or if the data doesn't match the expected type.
+     */
+    public <T> T get( String key, Class<T> type )
+    {
+        return get( key, null, type );
+    }
+
+    /**
+     * Gets the authentication data for the specified key.
+     * 
+     * @param <T> The data type of the authentication data.
+     * @param key The key whose authentication data should be retrieved, must not be {@code null}.
+     * @param data Any (read-only) extra data in form of key value pairs that might be useful when getting the
+     *            authentication data, may be {@code null}.
+     * @param type The expected type of the authentication data, must not be {@code null}.
+     * @return The requested authentication data or {@code null} if none or if the data doesn't match the expected type.
+     */
+    public <T> T get( String key, Map<String, String> data, Class<T> type )
+    {
+        if ( key == null )
+        {
+            throw new IllegalArgumentException( "authentication data key missing" );
+        }
+        Object value;
+        synchronized ( authData )
+        {
+            value = authData.get( key );
+            if ( value == null && !authData.containsKey( key ) && !fillingAuthData )
+            {
+                if ( auth != null )
+                {
+                    try
+                    {
+                        fillingAuthData = true;
+                        auth.fill( this, key, data );
+                    }
+                    finally
+                    {
+                        fillingAuthData = false;
+                    }
+                    value = authData.get( key );
+                }
+                if ( value == null )
+                {
+                    authData.put( key, value );
+                }
+            }
+        }
+
+        return convert( value, type );
+    }
+
+    private <T> T convert( Object value, Class<T> type )
+    {
+        if ( !type.isInstance( value ) )
+        {
+            if ( String.class.equals( type ) )
+            {
+                if ( value instanceof File )
+                {
+                    value = ( (File) value ).getPath();
+                }
+                else if ( value instanceof char[] )
+                {
+                    value = new String( (char[]) value );
+                }
+            }
+            else if ( File.class.equals( type ) )
+            {
+                if ( value instanceof String )
+                {
+                    value = new File( (String) value );
+                }
+            }
+            else if ( char[].class.equals( type ) )
+            {
+                if ( value instanceof String )
+                {
+                    value = ( (String) value ).toCharArray();
+                }
+            }
+        }
+
+        if ( type.isInstance( value ) )
+        {
+            return type.cast( value );
+        }
+
+        return null;
+    }
+
+    /**
+     * Puts the specified authentication data into this context. This method should only be called from implementors of
+     * {@link Authentication#fill(AuthenticationContext, String, Map)}. Passed in character arrays are not cloned and
+     * become owned by this context, i.e. get erased when the context gets closed.
+     * 
+     * @param key The key to associate the authentication data with, must not be {@code null}.
+     * @param value The (cleartext) authentication data to store, may be {@code null}.
+     */
+    public void put( String key, Object value )
+    {
+        if ( key == null )
+        {
+            throw new IllegalArgumentException( "authentication data key missing" );
+        }
+        synchronized ( authData )
+        {
+            Object oldValue = authData.put( key, value );
+            if ( oldValue instanceof char[] )
+            {
+                Arrays.fill( (char[]) oldValue, '\0' );
+            }
+        }
+    }
+
+    /**
+     * Closes this authentication context and erases sensitive authentication data from heap memory. Closing an already
+     * closed context has no effect.
+     */
+    public void close()
+    {
+        synchronized ( authData )
+        {
+            for ( Object value : authData.values() )
+            {
+                if ( value instanceof char[] )
+                {
+                    Arrays.fill( (char[]) value, '\0' );
+                }
+            }
+            authData.clear();
+        }
+    }
+
+    /**
+     * Closes the specified authentication context. This is a convenience method doing a {@code null} check before
+     * calling {@link #close()} on the given context.
+     * 
+     * @param context The authentication context to close, may be {@code null}.
+     */
+    public static void close( AuthenticationContext context )
+    {
+        if ( context != null )
+        {
+            context.close();
+        }
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationDigest.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationDigest.java
new file mode 100644 (file)
index 0000000..f702b4a
--- /dev/null
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import org.eclipse.aether.RepositorySystemSession;
+
+/**
+ * A helper to calculate a fingerprint/digest for the authentication data of a repository/proxy. Such a fingerprint can
+ * be used to detect changes in the authentication data across JVM restarts without exposing sensitive information.
+ */
+public final class AuthenticationDigest
+{
+
+    private final MessageDigest digest;
+
+    private final RepositorySystemSession session;
+
+    private final RemoteRepository repository;
+
+    private final Proxy proxy;
+
+    /**
+     * Gets the fingerprint for the authentication of the specified repository.
+     * 
+     * @param session The repository system session during which the fingerprint is requested, must not be {@code null}.
+     * @param repository The repository whose authentication is to be fingerprinted, must not be {@code null}.
+     * @return The fingerprint of the repository authentication or an empty string if no authentication is configured,
+     *         never {@code null}.
+     */
+    public static String forRepository( RepositorySystemSession session, RemoteRepository repository )
+    {
+        String digest = "";
+        Authentication auth = repository.getAuthentication();
+        if ( auth != null )
+        {
+            AuthenticationDigest authDigest = new AuthenticationDigest( session, repository, null );
+            auth.digest( authDigest );
+            digest = authDigest.digest();
+        }
+        return digest;
+    }
+
+    /**
+     * Gets the fingerprint for the authentication of the specified repository's proxy.
+     * 
+     * @param session The repository system session during which the fingerprint is requested, must not be {@code null}.
+     * @param repository The repository whose proxy authentication is to be fingerprinted, must not be {@code null}.
+     * @return The fingerprint of the proxy authentication or an empty string if no proxy is present or if no proxy
+     *         authentication is configured, never {@code null}.
+     */
+    public static String forProxy( RepositorySystemSession session, RemoteRepository repository )
+    {
+        String digest = "";
+        Proxy proxy = repository.getProxy();
+        if ( proxy != null )
+        {
+            Authentication auth = proxy.getAuthentication();
+            if ( auth != null )
+            {
+                AuthenticationDigest authDigest = new AuthenticationDigest( session, repository, proxy );
+                auth.digest( authDigest );
+                digest = authDigest.digest();
+            }
+        }
+        return digest;
+    }
+
+    private AuthenticationDigest( RepositorySystemSession session, RemoteRepository repository, Proxy proxy )
+    {
+        this.session = session;
+        this.repository = repository;
+        this.proxy = proxy;
+        digest = newDigest();
+    }
+
+    private static MessageDigest newDigest()
+    {
+        try
+        {
+            return MessageDigest.getInstance( "SHA-1" );
+        }
+        catch ( NoSuchAlgorithmException e )
+        {
+            try
+            {
+                return MessageDigest.getInstance( "MD5" );
+            }
+            catch ( NoSuchAlgorithmException ne )
+            {
+                throw new IllegalStateException( ne );
+            }
+        }
+    }
+
+    /**
+     * Gets the repository system session during which the authentication fingerprint is calculated.
+     * 
+     * @return The repository system session, never {@code null}.
+     */
+    public RepositorySystemSession getSession()
+    {
+        return session;
+    }
+
+    /**
+     * Gets the repository requiring authentication. If {@link #getProxy()} is not {@code null}, the data gathered by
+     * this authentication digest does not apply to the repository's host but rather the proxy.
+     * 
+     * @return The repository to be contacted, never {@code null}.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Gets the proxy (if any) to be authenticated with.
+     * 
+     * @return The proxy or {@code null} if authenticating directly with the repository's host.
+     */
+    public Proxy getProxy()
+    {
+        return proxy;
+    }
+
+    /**
+     * Updates the digest with the specified strings.
+     * 
+     * @param strings The strings to update the digest with, may be {@code null} or contain {@code null} elements.
+     */
+    public void update( String... strings )
+    {
+        if ( strings != null )
+        {
+            for ( String string : strings )
+            {
+                if ( string != null )
+                {
+                    try
+                    {
+                        digest.update( string.getBytes( "UTF-8" ) );
+                    }
+                    catch ( UnsupportedEncodingException e )
+                    {
+                        throw new IllegalStateException( e );
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Updates the digest with the specified characters.
+     * 
+     * @param chars The characters to update the digest with, may be {@code null}.
+     */
+    public void update( char... chars )
+    {
+        if ( chars != null )
+        {
+            for ( char c : chars )
+            {
+                digest.update( (byte) ( c >> 8 ) );
+                digest.update( (byte) ( c & 0xFF ) );
+            }
+        }
+    }
+
+    /**
+     * Updates the digest with the specified bytes.
+     * 
+     * @param bytes The bytes to update the digest with, may be {@code null}.
+     */
+    public void update( byte... bytes )
+    {
+        if ( bytes != null )
+        {
+            digest.update( bytes );
+        }
+    }
+
+    private String digest()
+    {
+        byte[] bytes = digest.digest();
+        StringBuilder buffer = new StringBuilder( bytes.length * 2 );
+        for ( byte aByte : bytes )
+        {
+            int b = aByte & 0xFF;
+            if ( b < 0x10 )
+            {
+                buffer.append( '0' );
+            }
+            buffer.append( Integer.toHexString( b ) );
+        }
+        return buffer.toString();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationSelector.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/AuthenticationSelector.java
new file mode 100644 (file)
index 0000000..46c9bab
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+/**
+ * Selects authentication for a given remote repository.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getAuthenticationSelector()
+ */
+public interface AuthenticationSelector
+{
+
+    /**
+     * Selects authentication for the specified remote repository.
+     * 
+     * @param repository The repository for which to select authentication, must not be {@code null}.
+     * @return The selected authentication or {@code null} if none.
+     */
+    Authentication getAuthentication( RemoteRepository repository );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRegistration.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRegistration.java
new file mode 100644 (file)
index 0000000..af6ea4e
--- /dev/null
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * A request to register an artifact within the local repository. Certain local repository implementations can refuse to
+ * serve physically present artifacts if those haven't been previously registered to them.
+ * 
+ * @see LocalRepositoryManager#add(RepositorySystemSession, LocalArtifactRegistration)
+ */
+public final class LocalArtifactRegistration
+{
+
+    private Artifact artifact;
+
+    private RemoteRepository repository;
+
+    private Collection<String> contexts = Collections.emptyList();
+
+    /**
+     * Creates an uninitialized registration.
+     */
+    public LocalArtifactRegistration()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a registration request for the specified (locally installed) artifact.
+     * 
+     * @param artifact The artifact to register, may be {@code null}.
+     */
+    public LocalArtifactRegistration( Artifact artifact )
+    {
+        setArtifact( artifact );
+    }
+
+    /**
+     * Creates a registration request for the specified artifact.
+     * 
+     * @param artifact The artifact to register, may be {@code null}.
+     * @param repository The remote repository from which the artifact was resolved or {@code null} if the artifact was
+     *            locally installed.
+     * @param contexts The resolution contexts, may be {@code null}.
+     */
+    public LocalArtifactRegistration( Artifact artifact, RemoteRepository repository, Collection<String> contexts )
+    {
+        setArtifact( artifact );
+        setRepository( repository );
+        setContexts( contexts );
+    }
+
+    /**
+     * Gets the artifact to register.
+     * 
+     * @return The artifact or {@code null} if not set.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the artifact to register.
+     * 
+     * @param artifact The artifact, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public LocalArtifactRegistration setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+        return this;
+    }
+
+    /**
+     * Gets the remote repository from which the artifact was resolved.
+     * 
+     * @return The remote repository or {@code null} if the artifact was locally installed.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the remote repository from which the artifact was resolved.
+     * 
+     * @param repository The remote repository or {@code null} if the artifact was locally installed.
+     * @return This request for chaining, never {@code null}.
+     */
+    public LocalArtifactRegistration setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    /**
+     * Gets the resolution contexts in which the artifact is available.
+     * 
+     * @return The resolution contexts in which the artifact is available, never {@code null}.
+     */
+    public Collection<String> getContexts()
+    {
+        return contexts;
+    }
+
+    /**
+     * Sets the resolution contexts in which the artifact is available.
+     * 
+     * @param contexts The resolution contexts, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public LocalArtifactRegistration setContexts( Collection<String> contexts )
+    {
+        if ( contexts != null )
+        {
+            this.contexts = contexts;
+        }
+        else
+        {
+            this.contexts = Collections.emptyList();
+        }
+        return this;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactRequest.java
new file mode 100644 (file)
index 0000000..3cc67f8
--- /dev/null
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * A query to the local repository for the existence of an artifact.
+ * 
+ * @see LocalRepositoryManager#find(RepositorySystemSession, LocalArtifactRequest)
+ */
+public final class LocalArtifactRequest
+{
+
+    private Artifact artifact;
+
+    private String context = "";
+
+    private List<RemoteRepository> repositories = Collections.emptyList();
+
+    /**
+     * Creates an uninitialized query.
+     */
+    public LocalArtifactRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a query with the specified properties.
+     * 
+     * @param artifact The artifact to query for, may be {@code null}.
+     * @param repositories The remote repositories that should be considered as potential sources for the artifact, may
+     *            be {@code null} or empty to only consider locally installed artifacts.
+     * @param context The resolution context for the artifact, may be {@code null}.
+     */
+    public LocalArtifactRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
+    {
+        setArtifact( artifact );
+        setRepositories( repositories );
+        setContext( context );
+    }
+
+    /**
+     * Gets the artifact to query for.
+     * 
+     * @return The artifact or {@code null} if not set.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the artifact to query for.
+     * 
+     * @param artifact The artifact, may be {@code null}.
+     * @return This query for chaining, never {@code null}.
+     */
+    public LocalArtifactRequest setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+        return this;
+    }
+
+    /**
+     * Gets the resolution context.
+     * 
+     * @return The resolution context, never {@code null}.
+     */
+    public String getContext()
+    {
+        return context;
+    }
+
+    /**
+     * Sets the resolution context.
+     * 
+     * @param context The resolution context, may be {@code null}.
+     * @return This query for chaining, never {@code null}.
+     */
+    public LocalArtifactRequest setContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+        return this;
+    }
+
+    /**
+     * Gets the remote repositories to consider as sources of the artifact.
+     * 
+     * @return The remote repositories, never {@code null}.
+     */
+    public List<RemoteRepository> getRepositories()
+    {
+        return repositories;
+    }
+
+    /**
+     * Sets the remote repositories to consider as sources of the artifact.
+     * 
+     * @param repositories The remote repositories, may be {@code null} or empty to only consider locally installed
+     *            artifacts.
+     * @return This query for chaining, never {@code null}.
+     */
+    public LocalArtifactRequest setRepositories( List<RemoteRepository> repositories )
+    {
+        if ( repositories != null )
+        {
+            this.repositories = repositories;
+        }
+        else
+        {
+            this.repositories = Collections.emptyList();
+        }
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifact() + " @ " + getRepositories();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalArtifactResult.java
new file mode 100644 (file)
index 0000000..065b823
--- /dev/null
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.io.File;
+
+import org.eclipse.aether.RepositorySystemSession;
+
+/**
+ * A result from the local repository about the existence of an artifact.
+ * 
+ * @see LocalRepositoryManager#find(RepositorySystemSession, LocalArtifactRequest)
+ */
+public final class LocalArtifactResult
+{
+
+    private final LocalArtifactRequest request;
+
+    private File file;
+
+    private boolean available;
+
+    private RemoteRepository repository;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The local artifact request, must not be {@code null}.
+     */
+    public LocalArtifactResult( LocalArtifactRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "local artifact request has not been specified" );
+        }
+        this.request = request;
+    }
+
+    /**
+     * Gets the request corresponding to this result.
+     * 
+     * @return The corresponding request, never {@code null}.
+     */
+    public LocalArtifactRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the file to the requested artifact. Note that this file must not be used unless {@link #isAvailable()}
+     * returns {@code true}. An artifact file can be found but considered unavailable if the artifact was cached from a
+     * remote repository that is not part of the list of remote repositories used for the query.
+     * 
+     * @return The file to the requested artifact or {@code null} if the artifact does not exist locally.
+     */
+    public File getFile()
+    {
+        return file;
+    }
+
+    /**
+     * Sets the file to requested artifact.
+     * 
+     * @param file The artifact file, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public LocalArtifactResult setFile( File file )
+    {
+        this.file = file;
+        return this;
+    }
+
+    /**
+     * Indicates whether the requested artifact is available for use. As a minimum, the file needs to be physically
+     * existent in the local repository to be available. Additionally, a local repository manager can consider the list
+     * of supplied remote repositories to determine whether the artifact is logically available and mark an artifact
+     * unavailable (despite its physical existence) if it is not known to be hosted by any of the provided repositories.
+     * 
+     * @return {@code true} if the artifact is available, {@code false} otherwise.
+     * @see LocalArtifactRequest#getRepositories()
+     */
+    public boolean isAvailable()
+    {
+        return available;
+    }
+
+    /**
+     * Sets whether the artifact is available.
+     * 
+     * @param available {@code true} if the artifact is available, {@code false} otherwise.
+     * @return This result for chaining, never {@code null}.
+     */
+    public LocalArtifactResult setAvailable( boolean available )
+    {
+        this.available = available;
+        return this;
+    }
+
+    /**
+     * Gets the (first) remote repository from which the artifact was cached (if any).
+     * 
+     * @return The remote repository from which the artifact was originally retrieved or {@code null} if unknown or if
+     *         the artifact has been locally installed.
+     * @see LocalArtifactRequest#getRepositories()
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the (first) remote repository from which the artifact was cached.
+     * 
+     * @param repository The remote repository from which the artifact was originally retrieved, may be {@code null} if
+     *            unknown or if the artifact has been locally installed.
+     * @return This result for chaining, never {@code null}.
+     */
+    public LocalArtifactResult setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getFile() + " (" + ( isAvailable() ? "available" : "unavailable" ) + ")";
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRegistration.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRegistration.java
new file mode 100644 (file)
index 0000000..a01ba3e
--- /dev/null
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.metadata.Metadata;
+
+/**
+ * A request to register metadata within the local repository.
+ * 
+ * @see LocalRepositoryManager#add(RepositorySystemSession, LocalMetadataRegistration)
+ */
+public final class LocalMetadataRegistration
+{
+
+    private Metadata metadata;
+
+    private RemoteRepository repository;
+
+    private Collection<String> contexts = Collections.emptyList();
+
+    /**
+     * Creates an uninitialized registration.
+     */
+    public LocalMetadataRegistration()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a registration request for the specified metadata accompanying a locally installed artifact.
+     * 
+     * @param metadata The metadata to register, may be {@code null}.
+     */
+    public LocalMetadataRegistration( Metadata metadata )
+    {
+        setMetadata( metadata );
+    }
+
+    /**
+     * Creates a registration request for the specified metadata.
+     * 
+     * @param metadata The metadata to register, may be {@code null}.
+     * @param repository The remote repository from which the metadata was resolved or {@code null} if the metadata
+     *            accompanies a locally installed artifact.
+     * @param contexts The resolution contexts, may be {@code null}.
+     */
+    public LocalMetadataRegistration( Metadata metadata, RemoteRepository repository, Collection<String> contexts )
+    {
+        setMetadata( metadata );
+        setRepository( repository );
+        setContexts( contexts );
+    }
+
+    /**
+     * Gets the metadata to register.
+     * 
+     * @return The metadata or {@code null} if not set.
+     */
+    public Metadata getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Sets the metadata to register.
+     * 
+     * @param metadata The metadata, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public LocalMetadataRegistration setMetadata( Metadata metadata )
+    {
+        this.metadata = metadata;
+        return this;
+    }
+
+    /**
+     * Gets the remote repository from which the metadata was resolved.
+     * 
+     * @return The remote repository or {@code null} if the metadata was locally installed.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the remote repository from which the metadata was resolved.
+     * 
+     * @param repository The remote repository or {@code null} if the metadata accompanies a locally installed artifact.
+     * @return This request for chaining, never {@code null}.
+     */
+    public LocalMetadataRegistration setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    /**
+     * Gets the resolution contexts in which the metadata is available.
+     * 
+     * @return The resolution contexts in which the metadata is available, never {@code null}.
+     */
+    public Collection<String> getContexts()
+    {
+        return contexts;
+    }
+
+    /**
+     * Sets the resolution contexts in which the metadata is available.
+     * 
+     * @param contexts The resolution contexts, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public LocalMetadataRegistration setContexts( Collection<String> contexts )
+    {
+        if ( contexts != null )
+        {
+            this.contexts = contexts;
+        }
+        else
+        {
+            this.contexts = Collections.emptyList();
+        }
+        return this;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataRequest.java
new file mode 100644 (file)
index 0000000..0ee4dc5
--- /dev/null
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.metadata.Metadata;
+
+/**
+ * A query to the local repository for the existence of metadata.
+ * 
+ * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest)
+ */
+public final class LocalMetadataRequest
+{
+
+    private Metadata metadata;
+
+    private String context = "";
+
+    private RemoteRepository repository = null;
+
+    /**
+     * Creates an uninitialized query.
+     */
+    public LocalMetadataRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a query with the specified properties.
+     * 
+     * @param metadata The metadata to query for, may be {@code null}.
+     * @param repository The source remote repository for the metadata, may be {@code null} for local metadata.
+     * @param context The resolution context for the metadata, may be {@code null}.
+     */
+    public LocalMetadataRequest( Metadata metadata, RemoteRepository repository, String context )
+    {
+        setMetadata( metadata );
+        setRepository( repository );
+        setContext( context );
+    }
+
+    /**
+     * Gets the metadata to query for.
+     * 
+     * @return The metadata or {@code null} if not set.
+     */
+    public Metadata getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Sets the metadata to query for.
+     * 
+     * @param metadata The metadata, may be {@code null}.
+     * @return This query for chaining, never {@code null}.
+     */
+    public LocalMetadataRequest setMetadata( Metadata metadata )
+    {
+        this.metadata = metadata;
+        return this;
+    }
+
+    /**
+     * Gets the resolution context.
+     * 
+     * @return The resolution context, never {@code null}.
+     */
+    public String getContext()
+    {
+        return context;
+    }
+
+    /**
+     * Sets the resolution context.
+     * 
+     * @param context The resolution context, may be {@code null}.
+     * @return This query for chaining, never {@code null}.
+     */
+    public LocalMetadataRequest setContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+        return this;
+    }
+
+    /**
+     * Gets the remote repository to use as source of the metadata.
+     * 
+     * @return The remote repositories, may be {@code null} for local metadata.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the remote repository to use as sources of the metadata.
+     * 
+     * @param repository The remote repository, may be {@code null}.
+     * @return This query for chaining, may be {@code null} for local metadata.
+     */
+    public LocalMetadataRequest setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getMetadata() + " @ " + getRepository();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalMetadataResult.java
new file mode 100644 (file)
index 0000000..6f3687a
--- /dev/null
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.io.File;
+
+import org.eclipse.aether.RepositorySystemSession;
+
+/**
+ * A result from the local repository about the existence of metadata.
+ * 
+ * @see LocalRepositoryManager#find(RepositorySystemSession, LocalMetadataRequest)
+ */
+public final class LocalMetadataResult
+{
+
+    private final LocalMetadataRequest request;
+
+    private File file;
+
+    private boolean stale;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The local metadata request, must not be {@code null}.
+     */
+    public LocalMetadataResult( LocalMetadataRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "local metadata request has not been specified" );
+        }
+        this.request = request;
+    }
+
+    /**
+     * Gets the request corresponding to this result.
+     * 
+     * @return The corresponding request, never {@code null}.
+     */
+    public LocalMetadataRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the file to the requested metadata if the metadata is available in the local repository.
+     * 
+     * @return The file to the requested metadata or {@code null}.
+     */
+    public File getFile()
+    {
+        return file;
+    }
+
+    /**
+     * Sets the file to requested metadata.
+     * 
+     * @param file The metadata file, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public LocalMetadataResult setFile( File file )
+    {
+        this.file = file;
+        return this;
+    }
+
+    /**
+     * This value indicates whether the metadata is stale and should be updated.
+     * 
+     * @return {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
+     */
+    public boolean isStale()
+    {
+        return stale;
+    }
+
+    /**
+     * Sets whether the metadata is stale.
+     * 
+     * @param stale {@code true} if the metadata is stale and should be updated, {@code false} otherwise.
+     * @return This result for chaining, never {@code null}.
+     */
+    public LocalMetadataResult setStale( boolean stale )
+    {
+        this.stale = stale;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return request.toString() + "(" + getFile() + ")";
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepository.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepository.java
new file mode 100644 (file)
index 0000000..91b09d8
--- /dev/null
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.io.File;
+
+/**
+ * A repository on the local file system used to cache contents of remote repositories and to store locally installed
+ * artifacts. Note that this class merely describes such a repository, actual access to the contained artifacts is
+ * handled by a {@link LocalRepositoryManager} which is usually determined from the {@link #getContentType() type} of
+ * the repository.
+ */
+public final class LocalRepository
+    implements ArtifactRepository
+{
+
+    private final File basedir;
+
+    private final String type;
+
+    /**
+     * Creates a new local repository with the specified base directory and unknown type.
+     * 
+     * @param basedir The base directory of the repository, may be {@code null}.
+     */
+    public LocalRepository( String basedir )
+    {
+        this( ( basedir != null ) ? new File( basedir ) : null, "" );
+    }
+
+    /**
+     * Creates a new local repository with the specified base directory and unknown type.
+     * 
+     * @param basedir The base directory of the repository, may be {@code null}.
+     */
+    public LocalRepository( File basedir )
+    {
+        this( basedir, "" );
+    }
+
+    /**
+     * Creates a new local repository with the specified properties.
+     * 
+     * @param basedir The base directory of the repository, may be {@code null}.
+     * @param type The type of the repository, may be {@code null}.
+     */
+    public LocalRepository( File basedir, String type )
+    {
+        this.basedir = basedir;
+        this.type = ( type != null ) ? type : "";
+    }
+
+    public String getContentType()
+    {
+        return type;
+    }
+
+    public String getId()
+    {
+        return "local";
+    }
+
+    /**
+     * Gets the base directory of the repository.
+     * 
+     * @return The base directory or {@code null} if none.
+     */
+    public File getBasedir()
+    {
+        return basedir;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getBasedir() + " (" + getContentType() + ")";
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null || !getClass().equals( obj.getClass() ) )
+        {
+            return false;
+        }
+
+        LocalRepository that = (LocalRepository) obj;
+
+        return eq( basedir, that.basedir ) && eq( type, that.type );
+    }
+
+    private static <T> boolean eq( T s1, T s2 )
+    {
+        return s1 != null ? s1.equals( s2 ) : s2 == null;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = 17;
+        hash = hash * 31 + hash( basedir );
+        hash = hash * 31 + hash( type );
+        return hash;
+    }
+
+    private static int hash( Object obj )
+    {
+        return obj != null ? obj.hashCode() : 0;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepositoryManager.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepositoryManager.java
new file mode 100644 (file)
index 0000000..d9d8777
--- /dev/null
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.metadata.Metadata;
+
+/**
+ * Manages access to a local repository.
+ * 
+ * @see RepositorySystemSession#getLocalRepositoryManager()
+ * @see org.eclipse.aether.RepositorySystem#newLocalRepositoryManager(RepositorySystemSession, LocalRepository)
+ */
+public interface LocalRepositoryManager
+{
+
+    /**
+     * Gets the description of the local repository being managed.
+     * 
+     * @return The description of the local repository, never {@code null}.
+     */
+    LocalRepository getRepository();
+
+    /**
+     * Gets the relative path for a locally installed artifact. Note that the artifact need not actually exist yet at
+     * the returned location, the path merely indicates where the artifact would eventually be stored. The path uses the
+     * forward slash as directory separator regardless of the underlying file system.
+     * 
+     * @param artifact The artifact for which to determine the path, must not be {@code null}.
+     * @return The path, relative to the local repository's base directory.
+     */
+    String getPathForLocalArtifact( Artifact artifact );
+
+    /**
+     * Gets the relative path for an artifact cached from a remote repository. Note that the artifact need not actually
+     * exist yet at the returned location, the path merely indicates where the artifact would eventually be stored. The
+     * path uses the forward slash as directory separator regardless of the underlying file system.
+     * 
+     * @param artifact The artifact for which to determine the path, must not be {@code null}.
+     * @param repository The source repository of the artifact, must not be {@code null}.
+     * @param context The resolution context in which the artifact is being requested, may be {@code null}.
+     * @return The path, relative to the local repository's base directory.
+     */
+    String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context );
+
+    /**
+     * Gets the relative path for locally installed metadata. Note that the metadata need not actually exist yet at the
+     * returned location, the path merely indicates where the metadata would eventually be stored. The path uses the
+     * forward slash as directory separator regardless of the underlying file system.
+     * 
+     * @param metadata The metadata for which to determine the path, must not be {@code null}.
+     * @return The path, relative to the local repository's base directory.
+     */
+    String getPathForLocalMetadata( Metadata metadata );
+
+    /**
+     * Gets the relative path for metadata cached from a remote repository. Note that the metadata need not actually
+     * exist yet at the returned location, the path merely indicates where the metadata would eventually be stored. The
+     * path uses the forward slash as directory separator regardless of the underlying file system.
+     * 
+     * @param metadata The metadata for which to determine the path, must not be {@code null}.
+     * @param repository The source repository of the metadata, must not be {@code null}.
+     * @param context The resolution context in which the metadata is being requested, may be {@code null}.
+     * @return The path, relative to the local repository's base directory.
+     */
+    String getPathForRemoteMetadata( Metadata metadata, RemoteRepository repository, String context );
+
+    /**
+     * Queries for the existence of an artifact in the local repository. The request could be satisfied by a locally
+     * installed artifact or a previously downloaded artifact.
+     * 
+     * @param session The repository system session during which the request is made, must not be {@code null}.
+     * @param request The artifact request, must not be {@code null}.
+     * @return The result of the request, never {@code null}.
+     */
+    LocalArtifactResult find( RepositorySystemSession session, LocalArtifactRequest request );
+
+    /**
+     * Registers an installed or resolved artifact with the local repository. Note that artifact registration is merely
+     * concerned about updating the local repository's internal state, not about actually installing the artifact or its
+     * accompanying metadata.
+     * 
+     * @param session The repository system session during which the registration is made, must not be {@code null}.
+     * @param request The registration request, must not be {@code null}.
+     */
+    void add( RepositorySystemSession session, LocalArtifactRegistration request );
+
+    /**
+     * Queries for the existence of metadata in the local repository. The request could be satisfied by locally
+     * installed or previously downloaded metadata.
+     * 
+     * @param session The repository system session during which the request is made, must not be {@code null}.
+     * @param request The metadata request, must not be {@code null}.
+     * @return The result of the request, never {@code null}.
+     */
+    LocalMetadataResult find( RepositorySystemSession session, LocalMetadataRequest request );
+
+    /**
+     * Registers installed or resolved metadata with the local repository. Note that metadata registration is merely
+     * concerned about updating the local repository's internal state, not about actually installing the metadata.
+     * However, this method MUST be called after the actual install to give the repository manager the opportunity to
+     * inspect the added metadata.
+     * 
+     * @param session The repository system session during which the registration is made, must not be {@code null}.
+     * @param request The registration request, must not be {@code null}.
+     */
+    void add( RepositorySystemSession session, LocalMetadataRegistration request );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/MirrorSelector.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/MirrorSelector.java
new file mode 100644 (file)
index 0000000..1614acc
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+/**
+ * Selects a mirror for a given remote repository.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getMirrorSelector()
+ */
+public interface MirrorSelector
+{
+
+    /**
+     * Selects a mirror for the specified repository.
+     * 
+     * @param repository The repository to select a mirror for, must not be {@code null}.
+     * @return The selected mirror or {@code null} if none.
+     * @see RemoteRepository#getMirroredRepositories()
+     */
+    RemoteRepository getMirror( RemoteRepository repository );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/NoLocalRepositoryManagerException.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/NoLocalRepositoryManagerException.java
new file mode 100644 (file)
index 0000000..203ccfb
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case of an unsupported local repository type.
+ */
+public class NoLocalRepositoryManagerException
+    extends RepositoryException
+{
+
+    private final transient LocalRepository repository;
+
+    /**
+     * Creates a new exception with the specified repository.
+     * 
+     * @param repository The local repository for which no support is available, may be {@code null}.
+     */
+    public NoLocalRepositoryManagerException( LocalRepository repository )
+    {
+        this( repository, toMessage( repository ) );
+    }
+
+    /**
+     * Creates a new exception with the specified repository and detail message.
+     * 
+     * @param repository The local repository for which no support is available, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public NoLocalRepositoryManagerException( LocalRepository repository, String message )
+    {
+        super( message );
+        this.repository = repository;
+    }
+
+    /**
+     * Creates a new exception with the specified repository and cause.
+     * 
+     * @param repository The local repository for which no support is available, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public NoLocalRepositoryManagerException( LocalRepository repository, Throwable cause )
+    {
+        this( repository, toMessage( repository ), cause );
+    }
+
+    /**
+     * Creates a new exception with the specified repository, detail message and cause.
+     * 
+     * @param repository The local repository for which no support is available, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public NoLocalRepositoryManagerException( LocalRepository repository, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.repository = repository;
+    }
+
+    private static String toMessage( LocalRepository repository )
+    {
+        if ( repository != null )
+        {
+            return "No manager available for local repository (" + repository.getBasedir().getAbsolutePath()
+                + ") of type " + repository.getContentType();
+        }
+        else
+        {
+            return "No manager available for local repository";
+        }
+    }
+
+    /**
+     * Gets the local repository whose content type is not supported.
+     * 
+     * @return The unsupported local repository or {@code null} if unknown.
+     */
+    public LocalRepository getRepository()
+    {
+        return repository;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/Proxy.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/Proxy.java
new file mode 100644 (file)
index 0000000..b575bbc
--- /dev/null
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+/**
+ * A proxy to use for connections to a repository.
+ */
+public final class Proxy
+{
+
+    /**
+     * Type denoting a proxy for HTTP transfers.
+     */
+    public static final String TYPE_HTTP = "http";
+
+    /**
+     * Type denoting a proxy for HTTPS transfers.
+     */
+    public static final String TYPE_HTTPS = "https";
+
+    private final String type;
+
+    private final String host;
+
+    private final int port;
+
+    private final Authentication auth;
+
+    /**
+     * Creates a new proxy with the specified properties and no authentication.
+     * 
+     * @param type The type of the proxy, e.g. "http", may be {@code null}.
+     * @param host The host of the proxy, may be {@code null}.
+     * @param port The port of the proxy.
+     */
+    public Proxy( String type, String host, int port )
+    {
+        this( type, host, port, null );
+    }
+
+    /**
+     * Creates a new proxy with the specified properties.
+     * 
+     * @param type The type of the proxy, e.g. "http", may be {@code null}.
+     * @param host The host of the proxy, may be {@code null}.
+     * @param port The port of the proxy.
+     * @param auth The authentication to use for the proxy connection, may be {@code null}.
+     */
+    public Proxy( String type, String host, int port, Authentication auth )
+    {
+        this.type = ( type != null ) ? type : "";
+        this.host = ( host != null ) ? host : "";
+        this.port = port;
+        this.auth = auth;
+    }
+
+    /**
+     * Gets the type of this proxy.
+     * 
+     * @return The type of this proxy, never {@code null}.
+     */
+    public String getType()
+    {
+        return type;
+    }
+
+    /**
+     * Gets the host for this proxy.
+     * 
+     * @return The host for this proxy, never {@code null}.
+     */
+    public String getHost()
+    {
+        return host;
+    }
+
+    /**
+     * Gets the port number for this proxy.
+     * 
+     * @return The port number for this proxy.
+     */
+    public int getPort()
+    {
+        return port;
+    }
+
+    /**
+     * Gets the authentication to use for the proxy connection.
+     * 
+     * @return The authentication to use or {@code null} if none.
+     */
+    public Authentication getAuthentication()
+    {
+        return auth;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getHost() + ':' + getPort();
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null || !getClass().equals( obj.getClass() ) )
+        {
+            return false;
+        }
+
+        Proxy that = (Proxy) obj;
+
+        return eq( type, that.type ) && eq( host, that.host ) && port == that.port && eq( auth, that.auth );
+    }
+
+    private static <T> boolean eq( T s1, T s2 )
+    {
+        return s1 != null ? s1.equals( s2 ) : s2 == null;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = 17;
+        hash = hash * 31 + hash( host );
+        hash = hash * 31 + hash( type );
+        hash = hash * 31 + port;
+        hash = hash * 31 + hash( auth );
+        return hash;
+    }
+
+    private static int hash( Object obj )
+    {
+        return obj != null ? obj.hashCode() : 0;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/ProxySelector.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/ProxySelector.java
new file mode 100644 (file)
index 0000000..680474c
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+/**
+ * Selects a proxy for a given remote repository.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getProxySelector()
+ */
+public interface ProxySelector
+{
+
+    /**
+     * Selects a proxy for the specified remote repository.
+     * 
+     * @param repository The repository for which to select a proxy, must not be {@code null}.
+     * @return The selected proxy or {@code null} if none.
+     */
+    Proxy getProxy( RemoteRepository repository );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/RemoteRepository.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/RemoteRepository.java
new file mode 100644 (file)
index 0000000..aaa9acc
--- /dev/null
@@ -0,0 +1,573 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A repository on a remote server.
+ */
+public final class RemoteRepository
+    implements ArtifactRepository
+{
+
+    private static final Pattern URL_PATTERN =
+        Pattern.compile( "([^:/]+(:[^:/]{2,}+(?=://))?):(//([^@/]*@)?([^/:]+))?.*" );
+
+    private final String id;
+
+    private final String type;
+
+    private final String url;
+
+    private final String host;
+
+    private final String protocol;
+
+    private final RepositoryPolicy releasePolicy;
+
+    private final RepositoryPolicy snapshotPolicy;
+
+    private final Proxy proxy;
+
+    private final Authentication authentication;
+
+    private final List<RemoteRepository> mirroredRepositories;
+
+    private final boolean repositoryManager;
+
+    RemoteRepository( Builder builder )
+    {
+        if ( builder.prototype != null )
+        {
+            id = ( builder.delta & Builder.ID ) != 0 ? builder.id : builder.prototype.id;
+            type = ( builder.delta & Builder.TYPE ) != 0 ? builder.type : builder.prototype.type;
+            url = ( builder.delta & Builder.URL ) != 0 ? builder.url : builder.prototype.url;
+            releasePolicy =
+                ( builder.delta & Builder.RELEASES ) != 0 ? builder.releasePolicy : builder.prototype.releasePolicy;
+            snapshotPolicy =
+                ( builder.delta & Builder.SNAPSHOTS ) != 0 ? builder.snapshotPolicy : builder.prototype.snapshotPolicy;
+            proxy = ( builder.delta & Builder.PROXY ) != 0 ? builder.proxy : builder.prototype.proxy;
+            authentication =
+                ( builder.delta & Builder.AUTH ) != 0 ? builder.authentication : builder.prototype.authentication;
+            repositoryManager =
+                ( builder.delta & Builder.REPOMAN ) != 0 ? builder.repositoryManager
+                                : builder.prototype.repositoryManager;
+            mirroredRepositories =
+                ( builder.delta & Builder.MIRRORED ) != 0 ? copy( builder.mirroredRepositories )
+                                : builder.prototype.mirroredRepositories;
+        }
+        else
+        {
+            id = builder.id;
+            type = builder.type;
+            url = builder.url;
+            releasePolicy = builder.releasePolicy;
+            snapshotPolicy = builder.snapshotPolicy;
+            proxy = builder.proxy;
+            authentication = builder.authentication;
+            repositoryManager = builder.repositoryManager;
+            mirroredRepositories = copy( builder.mirroredRepositories );
+        }
+
+        Matcher m = URL_PATTERN.matcher( url );
+        if ( m.matches() )
+        {
+            protocol = m.group( 1 );
+            String host = m.group( 5 );
+            this.host = ( host != null ) ? host : "";
+        }
+        else
+        {
+            protocol = host = "";
+        }
+    }
+
+    private static List<RemoteRepository> copy( List<RemoteRepository> repos )
+    {
+        if ( repos == null || repos.isEmpty() )
+        {
+            return Collections.emptyList();
+        }
+        return Collections.unmodifiableList( Arrays.asList( repos.toArray( new RemoteRepository[repos.size()] ) ) );
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public String getContentType()
+    {
+        return type;
+    }
+
+    /**
+     * Gets the (base) URL of this repository.
+     * 
+     * @return The (base) URL of this repository, never {@code null}.
+     */
+    public String getUrl()
+    {
+        return url;
+    }
+
+    /**
+     * Gets the protocol part from the repository's URL, for example {@code file} or {@code http}. As suggested by RFC
+     * 2396, section 3.1 "Scheme Component", the protocol name should be treated case-insensitively.
+     * 
+     * @return The protocol or an empty string if none, never {@code null}.
+     */
+    public String getProtocol()
+    {
+        return protocol;
+    }
+
+    /**
+     * Gets the host part from the repository's URL.
+     * 
+     * @return The host or an empty string if none, never {@code null}.
+     */
+    public String getHost()
+    {
+        return host;
+    }
+
+    /**
+     * Gets the policy to apply for snapshot/release artifacts.
+     * 
+     * @param snapshot {@code true} to retrieve the snapshot policy, {@code false} to retrieve the release policy.
+     * @return The requested repository policy, never {@code null}.
+     */
+    public RepositoryPolicy getPolicy( boolean snapshot )
+    {
+        return snapshot ? snapshotPolicy : releasePolicy;
+    }
+
+    /**
+     * Gets the proxy that has been selected for this repository.
+     * 
+     * @return The selected proxy or {@code null} if none.
+     */
+    public Proxy getProxy()
+    {
+        return proxy;
+    }
+
+    /**
+     * Gets the authentication that has been selected for this repository.
+     * 
+     * @return The selected authentication or {@code null} if none.
+     */
+    public Authentication getAuthentication()
+    {
+        return authentication;
+    }
+
+    /**
+     * Gets the repositories that this repository serves as a mirror for.
+     * 
+     * @return The (read-only) repositories being mirrored by this repository, never {@code null}.
+     */
+    public List<RemoteRepository> getMirroredRepositories()
+    {
+        return mirroredRepositories;
+    }
+
+    /**
+     * Indicates whether this repository refers to a repository manager or not.
+     * 
+     * @return {@code true} if this repository is a repository manager, {@code false} otherwise.
+     */
+    public boolean isRepositoryManager()
+    {
+        return repositoryManager;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder buffer = new StringBuilder( 256 );
+        buffer.append( getId() );
+        buffer.append( " (" ).append( getUrl() );
+        buffer.append( ", " ).append( getContentType() );
+        boolean r = getPolicy( false ).isEnabled(), s = getPolicy( true ).isEnabled();
+        if ( r && s )
+        {
+            buffer.append( ", releases+snapshots" );
+        }
+        else if ( r )
+        {
+            buffer.append( ", releases" );
+        }
+        else if ( s )
+        {
+            buffer.append( ", snapshots" );
+        }
+        else
+        {
+            buffer.append( ", disabled" );
+        }
+        if ( isRepositoryManager() )
+        {
+            buffer.append( ", managed" );
+        }
+        buffer.append( ")" );
+        return buffer.toString();
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null || !getClass().equals( obj.getClass() ) )
+        {
+            return false;
+        }
+
+        RemoteRepository that = (RemoteRepository) obj;
+
+        return eq( url, that.url ) && eq( type, that.type ) && eq( id, that.id )
+            && eq( releasePolicy, that.releasePolicy ) && eq( snapshotPolicy, that.snapshotPolicy )
+            && eq( proxy, that.proxy ) && eq( authentication, that.authentication )
+            && eq( mirroredRepositories, that.mirroredRepositories ) && repositoryManager == that.repositoryManager;
+    }
+
+    private static <T> boolean eq( T s1, T s2 )
+    {
+        return s1 != null ? s1.equals( s2 ) : s2 == null;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = 17;
+        hash = hash * 31 + hash( url );
+        hash = hash * 31 + hash( type );
+        hash = hash * 31 + hash( id );
+        hash = hash * 31 + hash( releasePolicy );
+        hash = hash * 31 + hash( snapshotPolicy );
+        hash = hash * 31 + hash( proxy );
+        hash = hash * 31 + hash( authentication );
+        hash = hash * 31 + hash( mirroredRepositories );
+        hash = hash * 31 + ( repositoryManager ? 1 : 0 );
+        return hash;
+    }
+
+    private static int hash( Object obj )
+    {
+        return obj != null ? obj.hashCode() : 0;
+    }
+
+    /**
+     * A builder to create remote repositories.
+     */
+    public static final class Builder
+    {
+
+        private static final RepositoryPolicy DEFAULT_POLICY = new RepositoryPolicy();
+
+        static final int ID = 0x0001, TYPE = 0x0002, URL = 0x0004, RELEASES = 0x0008, SNAPSHOTS = 0x0010,
+                        PROXY = 0x0020, AUTH = 0x0040, MIRRORED = 0x0080, REPOMAN = 0x0100;
+
+        int delta;
+
+        RemoteRepository prototype;
+
+        String id;
+
+        String type;
+
+        String url;
+
+        RepositoryPolicy releasePolicy = DEFAULT_POLICY;
+
+        RepositoryPolicy snapshotPolicy = DEFAULT_POLICY;
+
+        Proxy proxy;
+
+        Authentication authentication;
+
+        List<RemoteRepository> mirroredRepositories;
+
+        boolean repositoryManager;
+
+        /**
+         * Creates a new repository builder.
+         * 
+         * @param id The identifier of the repository, may be {@code null}.
+         * @param type The type of the repository, may be {@code null}.
+         * @param url The (base) URL of the repository, may be {@code null}.
+         */
+        public Builder( String id, String type, String url )
+        {
+            this.id = ( id != null ) ? id : "";
+            this.type = ( type != null ) ? type : "";
+            this.url = ( url != null ) ? url : "";
+        }
+
+        /**
+         * Creates a new repository builder which uses the specified remote repository as a prototype for the new one.
+         * All properties which have not been set on the builder will be copied from the prototype when building the
+         * repository.
+         * 
+         * @param prototype The remote repository to use as prototype, must not be {@code null}.
+         */
+        public Builder( RemoteRepository prototype )
+        {
+            if ( prototype == null )
+            {
+                throw new IllegalArgumentException( "repository prototype missing" );
+            }
+            this.prototype = prototype;
+        }
+
+        /**
+         * Builds a new remote repository from the current values of this builder. The state of the builder itself
+         * remains unchanged.
+         * 
+         * @return The remote repository, never {@code null}.
+         */
+        public RemoteRepository build()
+        {
+            if ( prototype != null && delta == 0 )
+            {
+                return prototype;
+            }
+            return new RemoteRepository( this );
+        }
+
+        private <T> void delta( int flag, T builder, T prototype )
+        {
+            boolean equal = ( builder != null ) ? builder.equals( prototype ) : prototype == null;
+            if ( equal )
+            {
+                delta &= ~flag;
+            }
+            else
+            {
+                delta |= flag;
+            }
+        }
+
+        /**
+         * Sets the identifier of the repository.
+         * 
+         * @param id The identifier of the repository, may be {@code null}.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setId( String id )
+        {
+            this.id = ( id != null ) ? id : "";
+            if ( prototype != null )
+            {
+                delta( ID, this.id, prototype.getId() );
+            }
+            return this;
+        }
+
+        /**
+         * Sets the type of the repository, e.g. "default".
+         * 
+         * @param type The type of the repository, may be {@code null}.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setContentType( String type )
+        {
+            this.type = ( type != null ) ? type : "";
+            if ( prototype != null )
+            {
+                delta( TYPE, this.type, prototype.getContentType() );
+            }
+            return this;
+        }
+
+        /**
+         * Sets the (base) URL of the repository.
+         * 
+         * @param url The URL of the repository, may be {@code null}.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setUrl( String url )
+        {
+            this.url = ( url != null ) ? url : "";
+            if ( prototype != null )
+            {
+                delta( URL, this.url, prototype.getUrl() );
+            }
+            return this;
+        }
+
+        /**
+         * Sets the policy to apply for snapshot and release artifacts.
+         * 
+         * @param policy The repository policy to set, may be {@code null} to use a default policy.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setPolicy( RepositoryPolicy policy )
+        {
+            this.releasePolicy = this.snapshotPolicy = ( policy != null ) ? policy : DEFAULT_POLICY;
+            if ( prototype != null )
+            {
+                delta( RELEASES, this.releasePolicy, prototype.getPolicy( false ) );
+                delta( SNAPSHOTS, this.snapshotPolicy, prototype.getPolicy( true ) );
+            }
+            return this;
+        }
+
+        /**
+         * Sets the policy to apply for release artifacts.
+         * 
+         * @param releasePolicy The repository policy to set, may be {@code null} to use a default policy.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setReleasePolicy( RepositoryPolicy releasePolicy )
+        {
+            this.releasePolicy = ( releasePolicy != null ) ? releasePolicy : DEFAULT_POLICY;
+            if ( prototype != null )
+            {
+                delta( RELEASES, this.releasePolicy, prototype.getPolicy( false ) );
+            }
+            return this;
+        }
+
+        /**
+         * Sets the policy to apply for snapshot artifacts.
+         * 
+         * @param snapshotPolicy The repository policy to set, may be {@code null} to use a default policy.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setSnapshotPolicy( RepositoryPolicy snapshotPolicy )
+        {
+            this.snapshotPolicy = ( snapshotPolicy != null ) ? snapshotPolicy : DEFAULT_POLICY;
+            if ( prototype != null )
+            {
+                delta( SNAPSHOTS, this.snapshotPolicy, prototype.getPolicy( true ) );
+            }
+            return this;
+        }
+
+        /**
+         * Sets the proxy to use in order to access the repository.
+         * 
+         * @param proxy The proxy to use, may be {@code null}.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setProxy( Proxy proxy )
+        {
+            this.proxy = proxy;
+            if ( prototype != null )
+            {
+                delta( PROXY, this.proxy, prototype.getProxy() );
+            }
+            return this;
+        }
+
+        /**
+         * Sets the authentication to use in order to access the repository.
+         * 
+         * @param authentication The authentication to use, may be {@code null}.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setAuthentication( Authentication authentication )
+        {
+            this.authentication = authentication;
+            if ( prototype != null )
+            {
+                delta( AUTH, this.authentication, prototype.getAuthentication() );
+            }
+            return this;
+        }
+
+        /**
+         * Sets the repositories being mirrored by the repository.
+         * 
+         * @param mirroredRepositories The repositories being mirrored by the repository, may be {@code null}.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setMirroredRepositories( List<RemoteRepository> mirroredRepositories )
+        {
+            if ( this.mirroredRepositories == null )
+            {
+                this.mirroredRepositories = new ArrayList<RemoteRepository>();
+            }
+            else
+            {
+                this.mirroredRepositories.clear();
+            }
+            if ( mirroredRepositories != null )
+            {
+                this.mirroredRepositories.addAll( mirroredRepositories );
+            }
+            if ( prototype != null )
+            {
+                delta( MIRRORED, this.mirroredRepositories, prototype.getMirroredRepositories() );
+            }
+            return this;
+        }
+
+        /**
+         * Adds the specified repository to the list of repositories being mirrored by the repository. If this builder
+         * was {@link #RemoteRepository.Builder(RemoteRepository) constructed from a prototype}, the given repository
+         * will be added to the list of mirrored repositories from the prototype.
+         * 
+         * @param mirroredRepository The repository being mirrored by the repository, may be {@code null}.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder addMirroredRepository( RemoteRepository mirroredRepository )
+        {
+            if ( mirroredRepository != null )
+            {
+                if ( this.mirroredRepositories == null )
+                {
+                    this.mirroredRepositories = new ArrayList<RemoteRepository>();
+                    if ( prototype != null )
+                    {
+                        mirroredRepositories.addAll( prototype.getMirroredRepositories() );
+                    }
+                }
+                mirroredRepositories.add( mirroredRepository );
+                if ( prototype != null )
+                {
+                    delta |= MIRRORED;
+                }
+            }
+            return this;
+        }
+
+        /**
+         * Marks the repository as a repository manager or not.
+         * 
+         * @param repositoryManager {@code true} if the repository points at a repository manager, {@code false} if the
+         *            repository is just serving static contents.
+         * @return This builder for chaining, never {@code null}.
+         */
+        public Builder setRepositoryManager( boolean repositoryManager )
+        {
+            this.repositoryManager = repositoryManager;
+            if ( prototype != null )
+            {
+                delta( REPOMAN, this.repositoryManager, prototype.isRepositoryManager() );
+            }
+            return this;
+        }
+
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/RepositoryPolicy.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/RepositoryPolicy.java
new file mode 100644 (file)
index 0000000..05224a8
--- /dev/null
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+/**
+ * A policy controlling access to a repository.
+ */
+public final class RepositoryPolicy
+{
+
+    /**
+     * Never update locally cached data.
+     */
+    public static final String UPDATE_POLICY_NEVER = "never";
+
+    /**
+     * Always update locally cached data.
+     */
+    public static final String UPDATE_POLICY_ALWAYS = "always";
+
+    /**
+     * Update locally cached data once a day.
+     */
+    public static final String UPDATE_POLICY_DAILY = "daily";
+
+    /**
+     * Update locally cached data every X minutes as given by "interval:X".
+     */
+    public static final String UPDATE_POLICY_INTERVAL = "interval";
+
+    /**
+     * Verify checksums and fail the resolution if they do not match.
+     */
+    public static final String CHECKSUM_POLICY_FAIL = "fail";
+
+    /**
+     * Verify checksums and warn if they do not match.
+     */
+    public static final String CHECKSUM_POLICY_WARN = "warn";
+
+    /**
+     * Do not verify checksums.
+     */
+    public static final String CHECKSUM_POLICY_IGNORE = "ignore";
+
+    private final boolean enabled;
+
+    private final String updatePolicy;
+
+    private final String checksumPolicy;
+
+    /**
+     * Creates a new policy with checksum warnings and daily update checks.
+     */
+    public RepositoryPolicy()
+    {
+        this( true, UPDATE_POLICY_DAILY, CHECKSUM_POLICY_WARN );
+    }
+
+    /**
+     * Creates a new policy with the specified settings.
+     * 
+     * @param enabled A flag whether the associated repository should be accessed or not.
+     * @param updatePolicy The update interval after which locally cached data from the repository is considered stale
+     *            and should be refetched, may be {@code null}.
+     * @param checksumPolicy The way checksum verification should be handled, may be {@code null}.
+     */
+    public RepositoryPolicy( boolean enabled, String updatePolicy, String checksumPolicy )
+    {
+        this.enabled = enabled;
+        this.updatePolicy = ( updatePolicy != null ) ? updatePolicy : "";
+        this.checksumPolicy = ( checksumPolicy != null ) ? checksumPolicy : "";
+    }
+
+    /**
+     * Indicates whether the associated repository should be contacted or not.
+     * 
+     * @return {@code true} if the repository should be contacted, {@code false} otherwise.
+     */
+    public boolean isEnabled()
+    {
+        return enabled;
+    }
+
+    /**
+     * Gets the update policy for locally cached data from the repository.
+     * 
+     * @return The update policy, never {@code null}.
+     */
+    public String getUpdatePolicy()
+    {
+        return updatePolicy;
+    }
+
+    /**
+     * Gets the policy for checksum validation.
+     * 
+     * @return The checksum policy, never {@code null}.
+     */
+    public String getChecksumPolicy()
+    {
+        return checksumPolicy;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder buffer = new StringBuilder( 256 );
+        buffer.append( "enabled=" ).append( isEnabled() );
+        buffer.append( ", checksums=" ).append( getChecksumPolicy() );
+        buffer.append( ", updates=" ).append( getUpdatePolicy() );
+        return buffer.toString();
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+
+        if ( obj == null || !getClass().equals( obj.getClass() ) )
+        {
+            return false;
+        }
+
+        RepositoryPolicy that = (RepositoryPolicy) obj;
+
+        return enabled == that.enabled && updatePolicy.equals( that.updatePolicy )
+            && checksumPolicy.equals( that.checksumPolicy );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = 17;
+        hash = hash * 31 + ( enabled ? 1 : 0 );
+        hash = hash * 31 + updatePolicy.hashCode();
+        hash = hash * 31 + checksumPolicy.hashCode();
+        return hash;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceReader.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceReader.java
new file mode 100644 (file)
index 0000000..570f6b6
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * Manages a repository backed by the IDE workspace, a build session or a similar ad-hoc collection of artifacts.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getWorkspaceReader()
+ */
+public interface WorkspaceReader
+{
+
+    /**
+     * Gets a description of the workspace repository.
+     * 
+     * @return The repository description, never {@code null}.
+     */
+    WorkspaceRepository getRepository();
+
+    /**
+     * Locates the specified artifact.
+     * 
+     * @param artifact The artifact to locate, must not be {@code null}.
+     * @return The path to the artifact or {@code null} if the artifact is not available.
+     */
+    File findArtifact( Artifact artifact );
+
+    /**
+     * Determines all available versions of the specified artifact.
+     * 
+     * @param artifact The artifact whose versions should be listed, must not be {@code null}.
+     * @return The available versions of the artifact, must not be {@code null}.
+     */
+    List<String> findVersions( Artifact artifact );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceRepository.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceRepository.java
new file mode 100644 (file)
index 0000000..811c589
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.repository;
+
+import java.util.UUID;
+
+/**
+ * A repository backed by an IDE workspace, the output of a build session or similar ad-hoc collection of artifacts. As
+ * far as the repository system is concerned, a workspace repository is read-only, i.e. can only be used for artifact
+ * resolution but not installation/deployment. Note that this class merely describes such a repository, actual access to
+ * the contained artifacts is handled by a {@link WorkspaceReader}.
+ */
+public final class WorkspaceRepository
+    implements ArtifactRepository
+{
+
+    private final String type;
+
+    private final Object key;
+
+    /**
+     * Creates a new workspace repository of type {@code "workspace"} and a random key.
+     */
+    public WorkspaceRepository()
+    {
+        this( "workspace" );
+    }
+
+    /**
+     * Creates a new workspace repository with the specified type and a random key.
+     * 
+     * @param type The type of the repository, may be {@code null}.
+     */
+    public WorkspaceRepository( String type )
+    {
+        this( type, null );
+    }
+
+    /**
+     * Creates a new workspace repository with the specified type and key. The key is used to distinguish one workspace
+     * from another and should be sensitive to the artifacts that are (potentially) available in the workspace.
+     * 
+     * @param type The type of the repository, may be {@code null}.
+     * @param key The (comparison) key for the repository, may be {@code null} to generate a unique random key.
+     */
+    public WorkspaceRepository( String type, Object key )
+    {
+        this.type = ( type != null ) ? type : "";
+        this.key = ( key != null ) ? key : UUID.randomUUID().toString().replace( "-", "" );
+    }
+
+    public String getContentType()
+    {
+        return type;
+    }
+
+    public String getId()
+    {
+        return "workspace";
+    }
+
+    /**
+     * Gets the key of this workspace repository. The key is used to distinguish one workspace from another and should
+     * be sensitive to the artifacts that are (potentially) available in the workspace.
+     * 
+     * @return The (comparison) key for this workspace repository, never {@code null}.
+     */
+    public Object getKey()
+    {
+        return key;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "(" + getContentType() + ")";
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null || !getClass().equals( obj.getClass() ) )
+        {
+            return false;
+        }
+
+        WorkspaceRepository that = (WorkspaceRepository) obj;
+
+        return getContentType().equals( that.getContentType() ) && getKey().equals( that.getKey() );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = 17;
+        hash = hash * 31 + getKey().hashCode();
+        hash = hash * 31 + getContentType().hashCode();
+        return hash;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/repository/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/repository/package-info.java
new file mode 100644 (file)
index 0000000..21ab2bc
--- /dev/null
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The definition of various kinds of repositories that host artifacts.
+ */
+package org.eclipse.aether.repository;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorException.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorException.java
new file mode 100644 (file)
index 0000000..7dae7f4
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case of an unreadable or unresolvable artifact descriptor.
+ */
+public class ArtifactDescriptorException
+    extends RepositoryException
+{
+
+    private final transient ArtifactDescriptorResult result;
+
+    /**
+     * Creates a new exception with the specified result.
+     * 
+     * @param result The descriptor result at the point the exception occurred, may be {@code null}.
+     */
+    public ArtifactDescriptorException( ArtifactDescriptorResult result )
+    {
+        super( "Failed to read artifact descriptor"
+            + ( result != null ? " for " + result.getRequest().getArtifact() : "" ), getCause( result ) );
+        this.result = result;
+    }
+
+    /**
+     * Creates a new exception with the specified result and detail message.
+     * 
+     * @param result The descriptor result at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public ArtifactDescriptorException( ArtifactDescriptorResult result, String message )
+    {
+        super( message, getCause( result ) );
+        this.result = result;
+    }
+
+    /**
+     * Creates a new exception with the specified result, detail message and cause.
+     * 
+     * @param result The descriptor result at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public ArtifactDescriptorException( ArtifactDescriptorResult result, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.result = result;
+    }
+
+    /**
+     * Gets the descriptor result at the point the exception occurred. Despite being incomplete, callers might want to
+     * use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
+     * 
+     * @return The descriptor result or {@code null} if unknown.
+     */
+    public ArtifactDescriptorResult getResult()
+    {
+        return result;
+    }
+
+    private static Throwable getCause( ArtifactDescriptorResult result )
+    {
+        Throwable cause = null;
+        if ( result != null && !result.getExceptions().isEmpty() )
+        {
+            cause = result.getExceptions().get( 0 );
+        }
+        return cause;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicy.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicy.java
new file mode 100644 (file)
index 0000000..ec519fe
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.RepositorySystemSession;
+
+/**
+ * Controls the handling of errors related to reading an artifact descriptor.
+ * 
+ * @see RepositorySystemSession#getArtifactDescriptorPolicy()
+ */
+public interface ArtifactDescriptorPolicy
+{
+
+    /**
+     * Bit mask indicating that errors while reading the artifact descriptor should not be tolerated.
+     */
+    int STRICT = 0x00;
+
+    /**
+     * Bit flag indicating that missing artifact descriptors should be silently ignored.
+     */
+    int IGNORE_MISSING = 0x01;
+
+    /**
+     * Bit flag indicating that existent but invalid artifact descriptors should be silently ignored.
+     */
+    int IGNORE_INVALID = 0x02;
+
+    /**
+     * Bit mask indicating that all errors should be silently ignored.
+     */
+    int IGNORE_ERRORS = IGNORE_MISSING | IGNORE_INVALID;
+
+    /**
+     * Gets the error policy for an artifact's descriptor.
+     * 
+     * @param session The repository session during which the policy is determined, must not be {@code null}.
+     * @param request The policy request holding further details, must not be {@code null}.
+     * @return The bit mask describing the desired error policy.
+     */
+    int getPolicy( RepositorySystemSession session, ArtifactDescriptorPolicyRequest request );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicyRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorPolicyRequest.java
new file mode 100644 (file)
index 0000000..2edf0c5
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.artifact.Artifact;
+
+/**
+ * A query for the error policy for a given artifact's descriptor.
+ * 
+ * @see ArtifactDescriptorPolicy
+ */
+public final class ArtifactDescriptorPolicyRequest
+{
+
+    private Artifact artifact;
+
+    private String context = "";
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public ArtifactDescriptorPolicyRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a request for the specified artifact.
+     * 
+     * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
+     * @param context The context in which this request is made, may be {@code null}.
+     */
+    public ArtifactDescriptorPolicyRequest( Artifact artifact, String context )
+    {
+        setArtifact( artifact );
+        setRequestContext( context );
+    }
+
+    /**
+     * Gets the artifact for whose descriptor to determine the error policy.
+     * 
+     * @return The artifact for whose descriptor to determine the error policy or {@code null} if not set.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the artifact for whose descriptor to determine the error policy.
+     * 
+     * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorPolicyRequest setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+        return this;
+    }
+
+    /**
+     * Gets the context in which this request is made.
+     * 
+     * @return The context, never {@code null}.
+     */
+    public String getRequestContext()
+    {
+        return context;
+    }
+
+    /**
+     * Sets the context in which this request is made.
+     * 
+     * @param context The context, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorPolicyRequest setRequestContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return String.valueOf( getArtifact() );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorRequest.java
new file mode 100644 (file)
index 0000000..9a1ba65
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * A request to read an artifact descriptor.
+ * 
+ * @see RepositorySystem#readArtifactDescriptor(RepositorySystemSession, ArtifactDescriptorRequest)
+ */
+public final class ArtifactDescriptorRequest
+{
+
+    private Artifact artifact;
+
+    private List<RemoteRepository> repositories = Collections.emptyList();
+
+    private String context = "";
+
+    private RequestTrace trace;
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public ArtifactDescriptorRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a request with the specified properties.
+     * 
+     * @param artifact The artifact whose descriptor should be read, may be {@code null}.
+     * @param repositories The repositories to resolve the descriptor from, may be {@code null}.
+     * @param context The context in which this request is made, may be {@code null}.
+     */
+    public ArtifactDescriptorRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
+    {
+        setArtifact( artifact );
+        setRepositories( repositories );
+        setRequestContext( context );
+    }
+
+    /**
+     * Gets the artifact whose descriptor shall be read.
+     * 
+     * @return The artifact or {@code null} if not set.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the artifact whose descriptor shall be read. Eventually, a valid request must have an artifact set.
+     * 
+     * @param artifact The artifact, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorRequest setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+        return this;
+    }
+
+    /**
+     * Gets the repositories to resolve the descriptor from.
+     * 
+     * @return The repositories, never {@code null}.
+     */
+    public List<RemoteRepository> getRepositories()
+    {
+        return repositories;
+    }
+
+    /**
+     * Sets the repositories to resolve the descriptor from.
+     * 
+     * @param repositories The repositories, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorRequest setRepositories( List<RemoteRepository> repositories )
+    {
+        if ( repositories == null )
+        {
+            this.repositories = Collections.emptyList();
+        }
+        else
+        {
+            this.repositories = repositories;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified repository for the resolution of the artifact descriptor.
+     * 
+     * @param repository The repository to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorRequest addRepository( RemoteRepository repository )
+    {
+        if ( repository != null )
+        {
+            if ( this.repositories.isEmpty() )
+            {
+                this.repositories = new ArrayList<RemoteRepository>();
+            }
+            this.repositories.add( repository );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the context in which this request is made.
+     * 
+     * @return The context, never {@code null}.
+     */
+    public String getRequestContext()
+    {
+        return context;
+    }
+
+    /**
+     * Sets the context in which this request is made.
+     * 
+     * @param context The context, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorRequest setRequestContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+        return this;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    /**
+     * Sets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @param trace The trace information about the higher level operation, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorRequest setTrace( RequestTrace trace )
+    {
+        this.trace = trace;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifact() + " < " + getRepositories();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactDescriptorResult.java
new file mode 100644 (file)
index 0000000..3de8d5e
--- /dev/null
@@ -0,0 +1,457 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.repository.ArtifactRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * The result from reading an artifact descriptor.
+ * 
+ * @see RepositorySystem#readArtifactDescriptor(RepositorySystemSession, ArtifactDescriptorRequest)
+ */
+public final class ArtifactDescriptorResult
+{
+
+    private final ArtifactDescriptorRequest request;
+
+    private List<Exception> exceptions;
+
+    private List<Artifact> relocations;
+
+    private Collection<Artifact> aliases;
+
+    private Artifact artifact;
+
+    private ArtifactRepository repository;
+
+    private List<Dependency> dependencies;
+
+    private List<Dependency> managedDependencies;
+
+    private List<RemoteRepository> repositories;
+
+    private Map<String, Object> properties;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The descriptor request, must not be {@code null}.
+     */
+    public ArtifactDescriptorResult( ArtifactDescriptorRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "artifact descriptor request has not been specified" );
+        }
+        this.request = request;
+        artifact = request.getArtifact();
+        exceptions = Collections.emptyList();
+        relocations = Collections.emptyList();
+        aliases = Collections.emptyList();
+        dependencies = managedDependencies = Collections.emptyList();
+        repositories = Collections.emptyList();
+        properties = Collections.emptyMap();
+    }
+
+    /**
+     * Gets the descriptor request that was made.
+     * 
+     * @return The descriptor request, never {@code null}.
+     */
+    public ArtifactDescriptorRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the exceptions that occurred while reading the artifact descriptor.
+     * 
+     * @return The exceptions that occurred, never {@code null}.
+     */
+    public List<Exception> getExceptions()
+    {
+        return exceptions;
+    }
+
+    /**
+     * Sets the exceptions that occurred while reading the artifact descriptor.
+     * 
+     * @param exceptions The exceptions that occurred, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult setExceptions( List<Exception> exceptions )
+    {
+        if ( exceptions == null )
+        {
+            this.exceptions = Collections.emptyList();
+        }
+        else
+        {
+            this.exceptions = exceptions;
+        }
+        return this;
+    }
+
+    /**
+     * Records the specified exception while reading the artifact descriptor.
+     * 
+     * @param exception The exception to record, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult addException( Exception exception )
+    {
+        if ( exception != null )
+        {
+            if ( exceptions.isEmpty() )
+            {
+                exceptions = new ArrayList<Exception>();
+            }
+            exceptions.add( exception );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the relocations that were processed to read the artifact descriptor. The returned list denotes the hops that
+     * lead to the final artifact coordinates as given by {@link #getArtifact()}.
+     * 
+     * @return The relocations that were processed, never {@code null}.
+     */
+    public List<Artifact> getRelocations()
+    {
+        return relocations;
+    }
+
+    /**
+     * Sets the relocations that were processed to read the artifact descriptor.
+     * 
+     * @param relocations The relocations that were processed, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult setRelocations( List<Artifact> relocations )
+    {
+        if ( relocations == null )
+        {
+            this.relocations = Collections.emptyList();
+        }
+        else
+        {
+            this.relocations = relocations;
+        }
+        return this;
+    }
+
+    /**
+     * Records the specified relocation hop while locating the artifact descriptor.
+     * 
+     * @param artifact The artifact that got relocated, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult addRelocation( Artifact artifact )
+    {
+        if ( artifact != null )
+        {
+            if ( relocations.isEmpty() )
+            {
+                relocations = new ArrayList<Artifact>();
+            }
+            relocations.add( artifact );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the known aliases for this artifact. An alias denotes a different artifact with (almost) the same contents
+     * and can be used to mark a patched rebuild of some other artifact as such, thereby allowing conflict resolution to
+     * consider the patched and the original artifact as a conflict.
+     * 
+     * @return The aliases of the artifact, never {@code null}.
+     */
+    public Collection<Artifact> getAliases()
+    {
+        return aliases;
+    }
+
+    /**
+     * Sets the aliases of the artifact.
+     * 
+     * @param aliases The aliases of the artifact, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult setAliases( Collection<Artifact> aliases )
+    {
+        if ( aliases == null )
+        {
+            this.aliases = Collections.emptyList();
+        }
+        else
+        {
+            this.aliases = aliases;
+        }
+        return this;
+    }
+
+    /**
+     * Records the specified alias.
+     * 
+     * @param alias The alias for the artifact, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult addAlias( Artifact alias )
+    {
+        if ( alias != null )
+        {
+            if ( aliases.isEmpty() )
+            {
+                aliases = new ArrayList<Artifact>();
+            }
+            aliases.add( alias );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the artifact whose descriptor was read. This can be a different artifact than originally requested in case
+     * relocations were encountered.
+     * 
+     * @return The artifact after following any relocations, never {@code null}.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the artifact whose descriptor was read.
+     * 
+     * @param artifact The artifact whose descriptor was read, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+        return this;
+    }
+
+    /**
+     * Gets the repository from which the descriptor was eventually resolved.
+     * 
+     * @return The repository from which the descriptor was resolved or {@code null} if unknown.
+     */
+    public ArtifactRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the repository from which the descriptor was resolved.
+     * 
+     * @param repository The repository from which the descriptor was resolved, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult setRepository( ArtifactRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    /**
+     * Gets the list of direct dependencies of the artifact.
+     * 
+     * @return The list of direct dependencies, never {@code null}
+     */
+    public List<Dependency> getDependencies()
+    {
+        return dependencies;
+    }
+
+    /**
+     * Sets the list of direct dependencies of the artifact.
+     * 
+     * @param dependencies The list of direct dependencies, may be {@code null}
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult setDependencies( List<Dependency> dependencies )
+    {
+        if ( dependencies == null )
+        {
+            this.dependencies = Collections.emptyList();
+        }
+        else
+        {
+            this.dependencies = dependencies;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified direct dependency.
+     * 
+     * @param dependency The direct dependency to add, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult addDependency( Dependency dependency )
+    {
+        if ( dependency != null )
+        {
+            if ( dependencies.isEmpty() )
+            {
+                dependencies = new ArrayList<Dependency>();
+            }
+            dependencies.add( dependency );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the dependency management information.
+     * 
+     * @return The dependency management information.
+     */
+    public List<Dependency> getManagedDependencies()
+    {
+        return managedDependencies;
+    }
+
+    /**
+     * Sets the dependency management information.
+     * 
+     * @param dependencies The dependency management information, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult setManagedDependencies( List<Dependency> dependencies )
+    {
+        if ( dependencies == null )
+        {
+            this.managedDependencies = Collections.emptyList();
+        }
+        else
+        {
+            this.managedDependencies = dependencies;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified managed dependency.
+     * 
+     * @param dependency The managed dependency to add, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult addManagedDependency( Dependency dependency )
+    {
+        if ( dependency != null )
+        {
+            if ( managedDependencies.isEmpty() )
+            {
+                managedDependencies = new ArrayList<Dependency>();
+            }
+            managedDependencies.add( dependency );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the remote repositories listed in the artifact descriptor.
+     * 
+     * @return The remote repositories listed in the artifact descriptor, never {@code null}.
+     */
+    public List<RemoteRepository> getRepositories()
+    {
+        return repositories;
+    }
+
+    /**
+     * Sets the remote repositories listed in the artifact descriptor.
+     * 
+     * @param repositories The remote repositories listed in the artifact descriptor, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult setRepositories( List<RemoteRepository> repositories )
+    {
+        if ( repositories == null )
+        {
+            this.repositories = Collections.emptyList();
+        }
+        else
+        {
+            this.repositories = repositories;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified remote repository.
+     * 
+     * @param repository The remote repository to add, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult addRepository( RemoteRepository repository )
+    {
+        if ( repository != null )
+        {
+            if ( repositories.isEmpty() )
+            {
+                repositories = new ArrayList<RemoteRepository>();
+            }
+            repositories.add( repository );
+        }
+        return this;
+    }
+
+    /**
+     * Gets any additional information about the artifact in form of key-value pairs. <em>Note:</em> Regardless of their
+     * actual type, all property values must be treated as being read-only.
+     * 
+     * @return The additional information about the artifact, never {@code null}.
+     */
+    public Map<String, Object> getProperties()
+    {
+        return properties;
+    }
+
+    /**
+     * Sets any additional information about the artifact in form of key-value pairs.
+     * 
+     * @param properties The additional information about the artifact, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactDescriptorResult setProperties( Map<String, Object> properties )
+    {
+        if ( properties == null )
+        {
+            this.properties = Collections.emptyMap();
+        }
+        else
+        {
+            this.properties = properties;
+        }
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifact() + " -> " + getDependencies();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactRequest.java
new file mode 100644 (file)
index 0000000..6076ea5
--- /dev/null
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * A request to resolve an artifact.
+ * 
+ * @see RepositorySystem#resolveArtifacts(RepositorySystemSession, java.util.Collection)
+ * @see Artifact#getFile()
+ */
+public final class ArtifactRequest
+{
+
+    private Artifact artifact;
+
+    private DependencyNode node;
+
+    private List<RemoteRepository> repositories = Collections.emptyList();
+
+    private String context = "";
+
+    private RequestTrace trace;
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public ArtifactRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a request with the specified properties.
+     * 
+     * @param artifact The artifact to resolve, may be {@code null}.
+     * @param repositories The repositories to resolve the artifact from, may be {@code null}.
+     * @param context The context in which this request is made, may be {@code null}.
+     */
+    public ArtifactRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
+    {
+        setArtifact( artifact );
+        setRepositories( repositories );
+        setRequestContext( context );
+    }
+
+    /**
+     * Creates a request from the specified dependency node.
+     * 
+     * @param node The dependency node to resolve, may be {@code null}.
+     */
+    public ArtifactRequest( DependencyNode node )
+    {
+        setDependencyNode( node );
+        setRepositories( node.getRepositories() );
+        setRequestContext( node.getRequestContext() );
+    }
+
+    /**
+     * Gets the artifact to resolve.
+     * 
+     * @return The artifact to resolve or {@code null}.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the artifact to resolve.
+     * 
+     * @param artifact The artifact to resolve, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactRequest setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+        return this;
+    }
+
+    /**
+     * Gets the dependency node (if any) for which to resolve the artifact.
+     * 
+     * @return The dependency node to resolve or {@code null} if unknown.
+     */
+    public DependencyNode getDependencyNode()
+    {
+        return node;
+    }
+
+    /**
+     * Sets the dependency node to resolve.
+     * 
+     * @param node The dependency node to resolve, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactRequest setDependencyNode( DependencyNode node )
+    {
+        this.node = node;
+        if ( node != null )
+        {
+            setArtifact( node.getDependency().getArtifact() );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the repositories to resolve the artifact from.
+     * 
+     * @return The repositories, never {@code null}.
+     */
+    public List<RemoteRepository> getRepositories()
+    {
+        return repositories;
+    }
+
+    /**
+     * Sets the repositories to resolve the artifact from.
+     * 
+     * @param repositories The repositories, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactRequest setRepositories( List<RemoteRepository> repositories )
+    {
+        if ( repositories == null )
+        {
+            this.repositories = Collections.emptyList();
+        }
+        else
+        {
+            this.repositories = repositories;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified repository for the resolution.
+     * 
+     * @param repository The repository to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactRequest addRepository( RemoteRepository repository )
+    {
+        if ( repository != null )
+        {
+            if ( this.repositories.isEmpty() )
+            {
+                this.repositories = new ArrayList<RemoteRepository>();
+            }
+            this.repositories.add( repository );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the context in which this request is made.
+     * 
+     * @return The context, never {@code null}.
+     */
+    public String getRequestContext()
+    {
+        return context;
+    }
+
+    /**
+     * Sets the context in which this request is made.
+     * 
+     * @param context The context, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactRequest setRequestContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+        return this;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    /**
+     * Sets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @param trace The trace information about the higher level operation, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ArtifactRequest setTrace( RequestTrace trace )
+    {
+        this.trace = trace;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifact() + " < " + getRepositories();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResolutionException.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResolutionException.java
new file mode 100644 (file)
index 0000000..67d0514
--- /dev/null
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.transfer.ArtifactNotFoundException;
+import org.eclipse.aether.transfer.RepositoryOfflineException;
+
+/**
+ * Thrown in case of a unresolvable artifacts.
+ */
+public class ArtifactResolutionException
+    extends RepositoryException
+{
+
+    private final transient List<ArtifactResult> results;
+
+    /**
+     * Creates a new exception with the specified results.
+     * 
+     * @param results The resolution results at the point the exception occurred, may be {@code null}.
+     */
+    public ArtifactResolutionException( List<ArtifactResult> results )
+    {
+        super( getMessage( results ), getCause( results ) );
+        this.results = ( results != null ) ? results : Collections.<ArtifactResult> emptyList();
+    }
+
+    /**
+     * Creates a new exception with the specified results and detail message.
+     * 
+     * @param results The resolution results at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public ArtifactResolutionException( List<ArtifactResult> results, String message )
+    {
+        super( message, getCause( results ) );
+        this.results = ( results != null ) ? results : Collections.<ArtifactResult> emptyList();
+    }
+
+    /**
+     * Creates a new exception with the specified results, detail message and cause.
+     * 
+     * @param results The resolution results at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public ArtifactResolutionException( List<ArtifactResult> results, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.results = ( results != null ) ? results : Collections.<ArtifactResult> emptyList();
+    }
+
+    /**
+     * Gets the resolution results at the point the exception occurred. Despite being incomplete, callers might want to
+     * use these results to fail gracefully and continue their operation with whatever interim data has been gathered.
+     * 
+     * @return The resolution results or {@code null} if unknown.
+     */
+    public List<ArtifactResult> getResults()
+    {
+        return results;
+    }
+
+    /**
+     * Gets the first result from {@link #getResults()}. This is a convenience method for cases where callers know only
+     * a single result/request is involved.
+     * 
+     * @return The (first) resolution result or {@code null} if none.
+     */
+    public ArtifactResult getResult()
+    {
+        return ( results != null && !results.isEmpty() ) ? results.get( 0 ) : null;
+    }
+
+    private static String getMessage( List<? extends ArtifactResult> results )
+    {
+        StringBuilder buffer = new StringBuilder( 256 );
+
+        buffer.append( "The following artifacts could not be resolved: " );
+
+        int unresolved = 0;
+
+        String sep = "";
+        for ( ArtifactResult result : results )
+        {
+            if ( !result.isResolved() )
+            {
+                unresolved++;
+
+                buffer.append( sep );
+                buffer.append( result.getRequest().getArtifact() );
+                sep = ", ";
+            }
+        }
+
+        Throwable cause = getCause( results );
+        if ( cause != null )
+        {
+            if ( unresolved == 1 )
+            {
+                buffer.setLength( 0 );
+                buffer.append( cause.getMessage() );
+            }
+            else
+            {
+                buffer.append( ": " ).append( cause.getMessage() );
+            }
+        }
+
+        return buffer.toString();
+    }
+
+    private static Throwable getCause( List<? extends ArtifactResult> results )
+    {
+        for ( ArtifactResult result : results )
+        {
+            if ( !result.isResolved() )
+            {
+                Throwable notFound = null, offline = null;
+                for ( Throwable t : result.getExceptions() )
+                {
+                    if ( t instanceof ArtifactNotFoundException )
+                    {
+                        if ( notFound == null )
+                        {
+                            notFound = t;
+                        }
+                        if ( offline == null && t.getCause() instanceof RepositoryOfflineException )
+                        {
+                            offline = t;
+                        }
+                    }
+                    else
+                    {
+                        return t;
+                    }
+
+                }
+                if ( offline != null )
+                {
+                    return offline;
+                }
+                if ( notFound != null )
+                {
+                    return notFound;
+                }
+            }
+        }
+        return null;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ArtifactResult.java
new file mode 100644 (file)
index 0000000..106ffe0
--- /dev/null
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.ArtifactRepository;
+import org.eclipse.aether.transfer.ArtifactNotFoundException;
+
+/**
+ * The result of an artifact resolution request.
+ * 
+ * @see RepositorySystem#resolveArtifacts(RepositorySystemSession, java.util.Collection)
+ * @see Artifact#getFile()
+ */
+public final class ArtifactResult
+{
+
+    private final ArtifactRequest request;
+
+    private List<Exception> exceptions;
+
+    private Artifact artifact;
+
+    private ArtifactRepository repository;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The resolution request, must not be {@code null}.
+     */
+    public ArtifactResult( ArtifactRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "resolution request has not been specified" );
+        }
+        this.request = request;
+        exceptions = Collections.emptyList();
+    }
+
+    /**
+     * Gets the resolution request that was made.
+     * 
+     * @return The resolution request, never {@code null}.
+     */
+    public ArtifactRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the resolved artifact (if any). Use {@link #getExceptions()} to query the errors that occurred while trying
+     * to resolve the artifact.
+     * 
+     * @return The resolved artifact or {@code null} if the resolution failed.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the resolved artifact.
+     * 
+     * @param artifact The resolved artifact, may be {@code null} if the resolution failed.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactResult setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+        return this;
+    }
+
+    /**
+     * Gets the exceptions that occurred while resolving the artifact. Note that this list can be non-empty even if the
+     * artifact was successfully resolved, e.g. when one of the contacted remote repositories didn't contain the
+     * artifact but a later repository eventually contained it.
+     * 
+     * @return The exceptions that occurred, never {@code null}.
+     * @see #isResolved()
+     */
+    public List<Exception> getExceptions()
+    {
+        return exceptions;
+    }
+
+    /**
+     * Records the specified exception while resolving the artifact.
+     * 
+     * @param exception The exception to record, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactResult addException( Exception exception )
+    {
+        if ( exception != null )
+        {
+            if ( exceptions.isEmpty() )
+            {
+                exceptions = new ArrayList<Exception>();
+            }
+            exceptions.add( exception );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the repository from which the artifact was eventually resolved. Note that successive resolutions of the same
+     * artifact might yield different results if the employed local repository does not track the origin of an artifact.
+     * 
+     * @return The repository from which the artifact was resolved or {@code null} if unknown.
+     */
+    public ArtifactRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the repository from which the artifact was resolved.
+     * 
+     * @param repository The repository from which the artifact was resolved, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public ArtifactResult setRepository( ArtifactRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    /**
+     * Indicates whether the requested artifact was resolved. Note that the artifact might have been successfully
+     * resolved despite {@link #getExceptions()} indicating transfer errors while trying to fetch the artifact from some
+     * of the specified remote repositories.
+     * 
+     * @return {@code true} if the artifact was resolved, {@code false} otherwise.
+     * @see Artifact#getFile()
+     */
+    public boolean isResolved()
+    {
+        return getArtifact() != null && getArtifact().getFile() != null;
+    }
+
+    /**
+     * Indicates whether the requested artifact is not present in any of the specified repositories.
+     * 
+     * @return {@code true} if the artifact is not present in any repository, {@code false} otherwise.
+     */
+    public boolean isMissing()
+    {
+        for ( Exception e : getExceptions() )
+        {
+            if ( !( e instanceof ArtifactNotFoundException ) )
+            {
+                return false;
+            }
+        }
+        return !isResolved();
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifact() + " < " + getRepository();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyRequest.java
new file mode 100644 (file)
index 0000000..f55aff7
--- /dev/null
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.graph.DependencyNode;
+
+/**
+ * A request to resolve transitive dependencies. This request can either be supplied with a {@link CollectRequest} to
+ * calculate the transitive dependencies or with an already resolved dependency graph.
+ * 
+ * @see RepositorySystem#resolveDependencies(RepositorySystemSession, DependencyRequest)
+ * @see Artifact#getFile()
+ */
+public final class DependencyRequest
+{
+
+    private DependencyNode root;
+
+    private CollectRequest collectRequest;
+
+    private DependencyFilter filter;
+
+    private RequestTrace trace;
+
+    /**
+     * Creates an uninitialized request. Note that either {@link #setRoot(DependencyNode)} or
+     * {@link #setCollectRequest(CollectRequest)} must eventually be called to create a valid request.
+     */
+    public DependencyRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a request for the specified dependency graph and with the given resolution filter.
+     * 
+     * @param node The root node of the dependency graph whose artifacts should be resolved, may be {@code null}.
+     * @param filter The resolution filter to use, may be {@code null}.
+     */
+    public DependencyRequest( DependencyNode node, DependencyFilter filter )
+    {
+        setRoot( node );
+        setFilter( filter );
+    }
+
+    /**
+     * Creates a request for the specified collect request and with the given resolution filter.
+     * 
+     * @param request The collect request used to calculate the dependency graph whose artifacts should be resolved, may
+     *            be {@code null}.
+     * @param filter The resolution filter to use, may be {@code null}.
+     */
+    public DependencyRequest( CollectRequest request, DependencyFilter filter )
+    {
+        setCollectRequest( request );
+        setFilter( filter );
+    }
+
+    /**
+     * Gets the root node of the dependency graph whose artifacts should be resolved.
+     * 
+     * @return The root node of the dependency graph or {@code null} if none.
+     */
+    public DependencyNode getRoot()
+    {
+        return root;
+    }
+
+    /**
+     * Sets the root node of the dependency graph whose artifacts should be resolved. When this request is processed,
+     * the nodes of the given dependency graph will be updated to refer to the resolved artifacts. Eventually, either
+     * {@link #setRoot(DependencyNode)} or {@link #setCollectRequest(CollectRequest)} must be called to create a valid
+     * request.
+     * 
+     * @param root The root node of the dependency graph, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DependencyRequest setRoot( DependencyNode root )
+    {
+        this.root = root;
+        return this;
+    }
+
+    /**
+     * Gets the collect request used to calculate the dependency graph whose artifacts should be resolved.
+     * 
+     * @return The collect request or {@code null} if none.
+     */
+    public CollectRequest getCollectRequest()
+    {
+        return collectRequest;
+    }
+
+    /**
+     * Sets the collect request used to calculate the dependency graph whose artifacts should be resolved. Eventually,
+     * either {@link #setRoot(DependencyNode)} or {@link #setCollectRequest(CollectRequest)} must be called to create a
+     * valid request. If this request is supplied with a dependency node via {@link #setRoot(DependencyNode)}, the
+     * collect request is ignored.
+     * 
+     * @param collectRequest The collect request, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DependencyRequest setCollectRequest( CollectRequest collectRequest )
+    {
+        this.collectRequest = collectRequest;
+        return this;
+    }
+
+    /**
+     * Gets the resolution filter used to select which artifacts of the dependency graph should be resolved.
+     * 
+     * @return The resolution filter or {@code null} to resolve all artifacts of the dependency graph.
+     */
+    public DependencyFilter getFilter()
+    {
+        return filter;
+    }
+
+    /**
+     * Sets the resolution filter used to select which artifacts of the dependency graph should be resolved. For
+     * example, use this filter to restrict resolution to dependencies of a certain scope.
+     * 
+     * @param filter The resolution filter, may be {@code null} to resolve all artifacts of the dependency graph.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DependencyRequest setFilter( DependencyFilter filter )
+    {
+        this.filter = filter;
+        return this;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    /**
+     * Sets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @param trace The trace information about the higher level operation, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public DependencyRequest setTrace( RequestTrace trace )
+    {
+        this.trace = trace;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        if ( root != null )
+        {
+            return String.valueOf( root );
+        }
+        return String.valueOf( collectRequest );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResolutionException.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResolutionException.java
new file mode 100644 (file)
index 0000000..27d9bb2
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case of a unresolvable dependencies.
+ */
+public class DependencyResolutionException
+    extends RepositoryException
+{
+
+    private final transient DependencyResult result;
+
+    /**
+     * Creates a new exception with the specified result and cause.
+     * 
+     * @param result The dependency result at the point the exception occurred, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public DependencyResolutionException( DependencyResult result, Throwable cause )
+    {
+        super( getMessage( cause ), cause );
+        this.result = result;
+    }
+
+    /**
+     * Creates a new exception with the specified result, detail message and cause.
+     * 
+     * @param result The dependency result at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public DependencyResolutionException( DependencyResult result, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.result = result;
+    }
+
+    private static String getMessage( Throwable cause )
+    {
+        String msg = null;
+        if ( cause != null )
+        {
+            msg = cause.getMessage();
+        }
+        if ( msg == null || msg.length() <= 0 )
+        {
+            msg = "Could not resolve transitive dependencies";
+        }
+        return msg;
+    }
+
+    /**
+     * Gets the dependency result at the point the exception occurred. Despite being incomplete, callers might want to
+     * use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
+     * 
+     * @return The dependency result or {@code null} if unknown.
+     */
+    public DependencyResult getResult()
+    {
+        return result;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResult.java
new file mode 100644 (file)
index 0000000..3cc8d3a
--- /dev/null
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.graph.DependencyCycle;
+import org.eclipse.aether.graph.DependencyNode;
+
+/**
+ * The result of a dependency resolution request.
+ * 
+ * @see RepositorySystem#resolveDependencies(RepositorySystemSession, DependencyRequest)
+ */
+public final class DependencyResult
+{
+
+    private final DependencyRequest request;
+
+    private DependencyNode root;
+
+    private List<DependencyCycle> cycles;
+
+    private List<Exception> collectExceptions;
+
+    private List<ArtifactResult> artifactResults;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The resolution request, must not be {@code null}.
+     */
+    public DependencyResult( DependencyRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "dependency request has not been specified" );
+        }
+        this.request = request;
+        root = request.getRoot();
+        cycles = Collections.emptyList();
+        collectExceptions = Collections.emptyList();
+        artifactResults = Collections.emptyList();
+    }
+
+    /**
+     * Gets the resolution request that was made.
+     * 
+     * @return The resolution request, never {@code null}.
+     */
+    public DependencyRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the root node of the resolved dependency graph. Note that this dependency graph might be
+     * incomplete/unfinished in case of {@link #getCollectExceptions()} indicating errors during its calculation.
+     * 
+     * @return The root node of the resolved dependency graph or {@code null} if none.
+     */
+    public DependencyNode getRoot()
+    {
+        return root;
+    }
+
+    /**
+     * Sets the root node of the resolved dependency graph.
+     * 
+     * @param root The root node of the resolved dependency graph, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public DependencyResult setRoot( DependencyNode root )
+    {
+        this.root = root;
+        return this;
+    }
+
+    /**
+     * Gets the dependency cycles that were encountered while building the dependency graph. Note that dependency cycles
+     * will only be reported here if the underlying request was created from a
+     * {@link org.eclipse.aether.collection.CollectRequest CollectRequest}. If the underlying {@link DependencyRequest}
+     * was created from an existing dependency graph, information about cycles will not be available in this result.
+     * 
+     * @return The dependency cycles in the (raw) graph, never {@code null}.
+     */
+    public List<DependencyCycle> getCycles()
+    {
+        return cycles;
+    }
+
+    /**
+     * Records the specified dependency cycles while building the dependency graph.
+     * 
+     * @param cycles The dependency cycles to record, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public DependencyResult setCycles( List<DependencyCycle> cycles )
+    {
+        if ( cycles == null )
+        {
+            this.cycles = Collections.emptyList();
+        }
+        else
+        {
+            this.cycles = cycles;
+        }
+        return this;
+    }
+
+    /**
+     * Gets the exceptions that occurred while building the dependency graph.
+     * 
+     * @return The exceptions that occurred, never {@code null}.
+     */
+    public List<Exception> getCollectExceptions()
+    {
+        return collectExceptions;
+    }
+
+    /**
+     * Records the specified exceptions while building the dependency graph.
+     * 
+     * @param exceptions The exceptions to record, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public DependencyResult setCollectExceptions( List<Exception> exceptions )
+    {
+        if ( exceptions == null )
+        {
+            this.collectExceptions = Collections.emptyList();
+        }
+        else
+        {
+            this.collectExceptions = exceptions;
+        }
+        return this;
+    }
+
+    /**
+     * Gets the resolution results for the dependency artifacts that matched {@link DependencyRequest#getFilter()}.
+     * 
+     * @return The resolution results for the dependency artifacts, never {@code null}.
+     */
+    public List<ArtifactResult> getArtifactResults()
+    {
+        return artifactResults;
+    }
+
+    /**
+     * Sets the resolution results for the artifacts that matched {@link DependencyRequest#getFilter()}.
+     * 
+     * @param results The resolution results for the artifacts, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public DependencyResult setArtifactResults( List<ArtifactResult> results )
+    {
+        if ( results == null )
+        {
+            this.artifactResults = Collections.emptyList();
+        }
+        else
+        {
+            this.artifactResults = results;
+        }
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return String.valueOf( artifactResults );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataRequest.java
new file mode 100644 (file)
index 0000000..2f6c5f1
--- /dev/null
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * A request to resolve metadata from either a remote repository or the local repository.
+ * 
+ * @see RepositorySystem#resolveMetadata(RepositorySystemSession, java.util.Collection)
+ * @see Metadata#getFile()
+ */
+public final class MetadataRequest
+{
+
+    private Metadata metadata;
+
+    private RemoteRepository repository;
+
+    private String context = "";
+
+    private boolean deleteLocalCopyIfMissing;
+
+    private boolean favorLocalRepository;
+
+    private RequestTrace trace;
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public MetadataRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a request to resolve the specified metadata from the local repository.
+     * 
+     * @param metadata The metadata to resolve, may be {@code null}.
+     */
+    public MetadataRequest( Metadata metadata )
+    {
+        setMetadata( metadata );
+    }
+
+    /**
+     * Creates a request with the specified properties.
+     * 
+     * @param metadata The metadata to resolve, may be {@code null}.
+     * @param repository The repository to resolve the metadata from, may be {@code null} to resolve from the local
+     *            repository.
+     * @param context The context in which this request is made, may be {@code null}.
+     */
+    public MetadataRequest( Metadata metadata, RemoteRepository repository, String context )
+    {
+        setMetadata( metadata );
+        setRepository( repository );
+        setRequestContext( context );
+    }
+
+    /**
+     * Gets the metadata to resolve.
+     * 
+     * @return The metadata or {@code null} if not set.
+     */
+    public Metadata getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Sets the metadata to resolve.
+     * 
+     * @param metadata The metadata, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public MetadataRequest setMetadata( Metadata metadata )
+    {
+        this.metadata = metadata;
+        return this;
+    }
+
+    /**
+     * Gets the repository from which the metadata should be resolved.
+     * 
+     * @return The repository or {@code null} to resolve from the local repository.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the repository from which the metadata should be resolved.
+     * 
+     * @param repository The repository, may be {@code null} to resolve from the local repository.
+     * @return This request for chaining, never {@code null}.
+     */
+    public MetadataRequest setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    /**
+     * Gets the context in which this request is made.
+     * 
+     * @return The context, never {@code null}.
+     */
+    public String getRequestContext()
+    {
+        return context;
+    }
+
+    /**
+     * Sets the context in which this request is made.
+     * 
+     * @param context The context, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public MetadataRequest setRequestContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+        return this;
+    }
+
+    /**
+     * Indicates whether the locally cached copy of the metadata should be removed if the corresponding file does not
+     * exist (any more) in the remote repository.
+     * 
+     * @return {@code true} if locally cached metadata should be deleted if no corresponding remote file exists,
+     *         {@code false} to keep the local copy.
+     */
+    public boolean isDeleteLocalCopyIfMissing()
+    {
+        return deleteLocalCopyIfMissing;
+    }
+
+    /**
+     * Controls whether the locally cached copy of the metadata should be removed if the corresponding file does not
+     * exist (any more) in the remote repository.
+     * 
+     * @param deleteLocalCopyIfMissing {@code true} if locally cached metadata should be deleted if no corresponding
+     *            remote file exists, {@code false} to keep the local copy.
+     * @return This request for chaining, never {@code null}.
+     */
+    public MetadataRequest setDeleteLocalCopyIfMissing( boolean deleteLocalCopyIfMissing )
+    {
+        this.deleteLocalCopyIfMissing = deleteLocalCopyIfMissing;
+        return this;
+    }
+
+    /**
+     * Indicates whether the metadata resolution should be suppressed if the corresponding metadata of the local
+     * repository is up-to-date according to the update policy of the remote repository. In this case, the metadata
+     * resolution will even be suppressed if no local copy of the remote metadata exists yet.
+     * 
+     * @return {@code true} to suppress resolution of remote metadata if the corresponding metadata of the local
+     *         repository is up-to-date, {@code false} to resolve the remote metadata normally according to the update
+     *         policy.
+     */
+    public boolean isFavorLocalRepository()
+    {
+        return favorLocalRepository;
+    }
+
+    /**
+     * Controls resolution of remote metadata when already corresponding metadata of the local repository exists. In
+     * cases where the local repository's metadata is sufficient and going to be preferred, resolution of the remote
+     * metadata can be suppressed to avoid unnecessary network access.
+     * 
+     * @param favorLocalRepository {@code true} to suppress resolution of remote metadata if the corresponding metadata
+     *            of the local repository is up-to-date, {@code false} to resolve the remote metadata normally according
+     *            to the update policy.
+     * @return This request for chaining, never {@code null}.
+     */
+    public MetadataRequest setFavorLocalRepository( boolean favorLocalRepository )
+    {
+        this.favorLocalRepository = favorLocalRepository;
+        return this;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    /**
+     * Sets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @param trace The trace information about the higher level operation, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public MetadataRequest setTrace( RequestTrace trace )
+    {
+        this.trace = trace;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getMetadata() + " < " + getRepository();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/MetadataResult.java
new file mode 100644 (file)
index 0000000..3e5a7b8
--- /dev/null
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.transfer.MetadataNotFoundException;
+
+/**
+ * The result of a metadata resolution request.
+ * 
+ * @see RepositorySystem#resolveMetadata(RepositorySystemSession, java.util.Collection)
+ */
+public final class MetadataResult
+{
+
+    private final MetadataRequest request;
+
+    private Exception exception;
+
+    private boolean updated;
+
+    private Metadata metadata;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The resolution request, must not be {@code null}.
+     */
+    public MetadataResult( MetadataRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "metadata request has not been specified" );
+        }
+        this.request = request;
+    }
+
+    /**
+     * Gets the resolution request that was made.
+     * 
+     * @return The resolution request, never {@code null}.
+     */
+    public MetadataRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the resolved metadata (if any).
+     * 
+     * @return The resolved metadata or {@code null} if the resolution failed.
+     */
+    public Metadata getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Sets the resolved metadata.
+     * 
+     * @param metadata The resolved metadata, may be {@code null} if the resolution failed.
+     * @return This result for chaining, never {@code null}.
+     */
+    public MetadataResult setMetadata( Metadata metadata )
+    {
+        this.metadata = metadata;
+        return this;
+    }
+
+    /**
+     * Records the specified exception while resolving the metadata.
+     * 
+     * @param exception The exception to record, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public MetadataResult setException( Exception exception )
+    {
+        this.exception = exception;
+        return this;
+    }
+
+    /**
+     * Gets the exception that occurred while resolving the metadata.
+     * 
+     * @return The exception that occurred or {@code null} if none.
+     */
+    public Exception getException()
+    {
+        return exception;
+    }
+
+    /**
+     * Sets the updated flag for the metadata.
+     * 
+     * @param updated {@code true} if the metadata was actually fetched from the remote repository during the
+     *            resolution, {@code false} if the metadata was resolved from a locally cached copy.
+     * @return This result for chaining, never {@code null}.
+     */
+    public MetadataResult setUpdated( boolean updated )
+    {
+        this.updated = updated;
+        return this;
+    }
+
+    /**
+     * Indicates whether the metadata was actually fetched from the remote repository or resolved from the local cache.
+     * If metadata has been locally cached during a previous resolution request and this local copy is still up-to-date
+     * according to the remote repository's update policy, no remote access is made.
+     * 
+     * @return {@code true} if the metadata was actually fetched from the remote repository during the resolution,
+     *         {@code false} if the metadata was resolved from a locally cached copy.
+     */
+    public boolean isUpdated()
+    {
+        return updated;
+    }
+
+    /**
+     * Indicates whether the requested metadata was resolved. Note that the metadata might have been successfully
+     * resolved (from the local cache) despite {@link #getException()} indicating a transfer error while trying to
+     * refetch the metadata from the remote repository.
+     * 
+     * @return {@code true} if the metadata was resolved, {@code false} otherwise.
+     * @see Metadata#getFile()
+     */
+    public boolean isResolved()
+    {
+        return getMetadata() != null && getMetadata().getFile() != null;
+    }
+
+    /**
+     * Indicates whether the requested metadata is not present in the remote repository.
+     * 
+     * @return {@code true} if the metadata is not present in the remote repository, {@code false} otherwise.
+     */
+    public boolean isMissing()
+    {
+        return getException() instanceof MetadataNotFoundException;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getMetadata() + ( isUpdated() ? " (updated)" : " (cached)" );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicy.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicy.java
new file mode 100644 (file)
index 0000000..50d1a01
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.metadata.Metadata;
+
+/**
+ * Controls the caching of resolution errors for artifacts/metadata from remote repositories. If caching is enabled for
+ * a given resource, a marker will be set (usually somewhere in the local repository) to suppress repeated resolution
+ * attempts for the broken resource, thereby avoiding expensive but useless network IO. The error marker is considered
+ * stale once the repository's update policy has expired at which point a future resolution attempt will be allowed.
+ * Error caching considers the current network settings such that fixes to the configuration like authentication or
+ * proxy automatically trigger revalidation with the remote side regardless of the time elapsed since the previous
+ * resolution error.
+ * 
+ * @see RepositorySystemSession#getResolutionErrorPolicy()
+ */
+public interface ResolutionErrorPolicy
+{
+
+    /**
+     * Bit mask indicating that resolution errors should not be cached in the local repository. This forces the system
+     * to always query the remote repository for locally missing artifacts/metadata.
+     */
+    int CACHE_DISABLED = 0x00;
+
+    /**
+     * Bit flag indicating whether missing artifacts/metadata should be cached in the local repository. If caching is
+     * enabled, resolution will not be reattempted until the update policy for the affected resource has expired.
+     */
+    int CACHE_NOT_FOUND = 0x01;
+
+    /**
+     * Bit flag indicating whether connectivity/transfer errors (e.g. unreachable host, bad authentication) should be
+     * cached in the local repository. If caching is enabled, resolution will not be reattempted until the update policy
+     * for the affected resource has expired.
+     */
+    int CACHE_TRANSFER_ERROR = 0x02;
+
+    /**
+     * Bit mask indicating that all resolution errors should be cached in the local repository.
+     */
+    int CACHE_ALL = CACHE_NOT_FOUND | CACHE_TRANSFER_ERROR;
+
+    /**
+     * Gets the error policy for an artifact.
+     * 
+     * @param session The repository session during which the policy is determined, must not be {@code null}.
+     * @param request The policy request holding further details, must not be {@code null}.
+     * @return The bit mask describing the desired error policy.
+     */
+    int getArtifactPolicy( RepositorySystemSession session, ResolutionErrorPolicyRequest<Artifact> request );
+
+    /**
+     * Gets the error policy for some metadata.
+     * 
+     * @param session The repository session during which the policy is determined, must not be {@code null}.
+     * @param request The policy request holding further details, must not be {@code null}.
+     * @return The bit mask describing the desired error policy.
+     */
+    int getMetadataPolicy( RepositorySystemSession session, ResolutionErrorPolicyRequest<Metadata> request );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicyRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/ResolutionErrorPolicyRequest.java
new file mode 100644 (file)
index 0000000..6d05cf3
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * A query for the resolution error policy for a given artifact/metadata.
+ * 
+ * @param <T> The type of the affected repository item (artifact or metadata).
+ * @see ResolutionErrorPolicy
+ */
+public final class ResolutionErrorPolicyRequest<T>
+{
+
+    private T item;
+
+    private RemoteRepository repository;
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public ResolutionErrorPolicyRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a request for the specified artifact/metadata and remote repository.
+     * 
+     * @param item The artifact/metadata for which to determine the error policy, may be {@code null}.
+     * @param repository The repository from which the resolution is attempted, may be {@code null}.
+     */
+    public ResolutionErrorPolicyRequest( T item, RemoteRepository repository )
+    {
+        setItem( item );
+        setRepository( repository );
+    }
+
+    /**
+     * Gets the artifact/metadata for which to determine the error policy.
+     * 
+     * @return The artifact/metadata for which to determine the error policy or {@code null} if not set.
+     */
+    public T getItem()
+    {
+        return item;
+    }
+
+    /**
+     * Sets the artifact/metadata for which to determine the error policy.
+     * 
+     * @param item The artifact/metadata for which to determine the error policy, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ResolutionErrorPolicyRequest<T> setItem( T item )
+    {
+        this.item = item;
+        return this;
+    }
+
+    /**
+     * Gets the remote repository from which the resolution of the artifact/metadata is attempted.
+     * 
+     * @return The involved remote repository or {@code null} if not set.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the remote repository from which the resolution of the artifact/metadata is attempted.
+     * 
+     * @param repository The repository from which the resolution is attempted, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public ResolutionErrorPolicyRequest<T> setRepository( RemoteRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getItem() + " < " + getRepository();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeRequest.java
new file mode 100644 (file)
index 0000000..b40feb6
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * A request to resolve a version range.
+ * 
+ * @see RepositorySystem#resolveVersionRange(RepositorySystemSession, VersionRangeRequest)
+ */
+public final class VersionRangeRequest
+{
+
+    private Artifact artifact;
+
+    private List<RemoteRepository> repositories = Collections.emptyList();
+
+    private String context = "";
+
+    private RequestTrace trace;
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public VersionRangeRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a request with the specified properties.
+     * 
+     * @param artifact The artifact whose version range should be resolved, may be {@code null}.
+     * @param repositories The repositories to resolve the version from, may be {@code null}.
+     * @param context The context in which this request is made, may be {@code null}.
+     */
+    public VersionRangeRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
+    {
+        setArtifact( artifact );
+        setRepositories( repositories );
+        setRequestContext( context );
+    }
+
+    /**
+     * Gets the artifact whose version range shall be resolved.
+     * 
+     * @return The artifact or {@code null} if not set.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the artifact whose version range shall be resolved.
+     * 
+     * @param artifact The artifact, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRangeRequest setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+        return this;
+    }
+
+    /**
+     * Gets the repositories to resolve the version range from.
+     * 
+     * @return The repositories, never {@code null}.
+     */
+    public List<RemoteRepository> getRepositories()
+    {
+        return repositories;
+    }
+
+    /**
+     * Sets the repositories to resolve the version range from.
+     * 
+     * @param repositories The repositories, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRangeRequest setRepositories( List<RemoteRepository> repositories )
+    {
+        if ( repositories == null )
+        {
+            this.repositories = Collections.emptyList();
+        }
+        else
+        {
+            this.repositories = repositories;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified repository for the resolution.
+     * 
+     * @param repository The repository to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRangeRequest addRepository( RemoteRepository repository )
+    {
+        if ( repository != null )
+        {
+            if ( this.repositories.isEmpty() )
+            {
+                this.repositories = new ArrayList<RemoteRepository>();
+            }
+            this.repositories.add( repository );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the context in which this request is made.
+     * 
+     * @return The context, never {@code null}.
+     */
+    public String getRequestContext()
+    {
+        return context;
+    }
+
+    /**
+     * Sets the context in which this request is made.
+     * 
+     * @param context The context, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRangeRequest setRequestContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+        return this;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    /**
+     * Sets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @param trace The trace information about the higher level operation, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRangeRequest setTrace( RequestTrace trace )
+    {
+        this.trace = trace;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifact() + " < " + getRepositories();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResolutionException.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResolutionException.java
new file mode 100644 (file)
index 0000000..6e62e3f
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case of an unparseable or unresolvable version range.
+ */
+public class VersionRangeResolutionException
+    extends RepositoryException
+{
+
+    private final transient VersionRangeResult result;
+
+    /**
+     * Creates a new exception with the specified result.
+     * 
+     * @param result The version range result at the point the exception occurred, may be {@code null}.
+     */
+    public VersionRangeResolutionException( VersionRangeResult result )
+    {
+        super( getMessage( result ), getCause( result ) );
+        this.result = result;
+    }
+
+    private static String getMessage( VersionRangeResult result )
+    {
+        StringBuilder buffer = new StringBuilder( 256 );
+        buffer.append( "Failed to resolve version range" );
+        if ( result != null )
+        {
+            buffer.append( " for " ).append( result.getRequest().getArtifact() );
+            if ( !result.getExceptions().isEmpty() )
+            {
+                buffer.append( ": " ).append( result.getExceptions().iterator().next().getMessage() );
+            }
+        }
+        return buffer.toString();
+    }
+
+    private static Throwable getCause( VersionRangeResult result )
+    {
+        Throwable cause = null;
+        if ( result != null && !result.getExceptions().isEmpty() )
+        {
+            cause = result.getExceptions().get( 0 );
+        }
+        return cause;
+    }
+
+    /**
+     * Creates a new exception with the specified result and detail message.
+     * 
+     * @param result The version range result at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public VersionRangeResolutionException( VersionRangeResult result, String message )
+    {
+        super( message );
+        this.result = result;
+    }
+
+    /**
+     * Creates a new exception with the specified result, detail message and cause.
+     * 
+     * @param result The version range result at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public VersionRangeResolutionException( VersionRangeResult result, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.result = result;
+    }
+
+    /**
+     * Gets the version range result at the point the exception occurred. Despite being incomplete, callers might want
+     * to use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
+     * 
+     * @return The version range result or {@code null} if unknown.
+     */
+    public VersionRangeResult getResult()
+    {
+        return result;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRangeResult.java
new file mode 100644 (file)
index 0000000..fd233f1
--- /dev/null
@@ -0,0 +1,231 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.ArtifactRepository;
+import org.eclipse.aether.version.Version;
+import org.eclipse.aether.version.VersionConstraint;
+
+/**
+ * The result of a version range resolution request.
+ * 
+ * @see RepositorySystem#resolveVersionRange(RepositorySystemSession, VersionRangeRequest)
+ */
+public final class VersionRangeResult
+{
+
+    private final VersionRangeRequest request;
+
+    private List<Exception> exceptions;
+
+    private List<Version> versions;
+
+    private Map<Version, ArtifactRepository> repositories;
+
+    private VersionConstraint versionConstraint;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The resolution request, must not be {@code null}.
+     */
+    public VersionRangeResult( VersionRangeRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "version range request has not been specified" );
+        }
+        this.request = request;
+        exceptions = Collections.emptyList();
+        versions = Collections.emptyList();
+        repositories = Collections.emptyMap();
+    }
+
+    /**
+     * Gets the resolution request that was made.
+     * 
+     * @return The resolution request, never {@code null}.
+     */
+    public VersionRangeRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the exceptions that occurred while resolving the version range.
+     * 
+     * @return The exceptions that occurred, never {@code null}.
+     */
+    public List<Exception> getExceptions()
+    {
+        return exceptions;
+    }
+
+    /**
+     * Records the specified exception while resolving the version range.
+     * 
+     * @param exception The exception to record, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public VersionRangeResult addException( Exception exception )
+    {
+        if ( exception != null )
+        {
+            if ( exceptions.isEmpty() )
+            {
+                exceptions = new ArrayList<Exception>();
+            }
+            exceptions.add( exception );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the versions (in ascending order) that matched the requested range.
+     * 
+     * @return The matching versions (if any), never {@code null}.
+     */
+    public List<Version> getVersions()
+    {
+        return versions;
+    }
+
+    /**
+     * Adds the specified version to the result. Note that versions must be added in ascending order.
+     * 
+     * @param version The version to add, must not be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public VersionRangeResult addVersion( Version version )
+    {
+        if ( versions.isEmpty() )
+        {
+            versions = new ArrayList<Version>();
+        }
+        versions.add( version );
+        return this;
+    }
+
+    /**
+     * Sets the versions (in ascending order) matching the requested range.
+     * 
+     * @param versions The matching versions, may be empty or {@code null} if none.
+     * @return This result for chaining, never {@code null}.
+     */
+    public VersionRangeResult setVersions( List<Version> versions )
+    {
+        if ( versions == null )
+        {
+            this.versions = Collections.emptyList();
+        }
+        else
+        {
+            this.versions = versions;
+        }
+        return this;
+    }
+
+    /**
+     * Gets the lowest version matching the requested range.
+     * 
+     * @return The lowest matching version or {@code null} if no versions matched the requested range.
+     */
+    public Version getLowestVersion()
+    {
+        if ( versions.isEmpty() )
+        {
+            return null;
+        }
+        return versions.get( 0 );
+    }
+
+    /**
+     * Gets the highest version matching the requested range.
+     * 
+     * @return The highest matching version or {@code null} if no versions matched the requested range.
+     */
+    public Version getHighestVersion()
+    {
+        if ( versions.isEmpty() )
+        {
+            return null;
+        }
+        return versions.get( versions.size() - 1 );
+    }
+
+    /**
+     * Gets the repository from which the specified version was resolved.
+     * 
+     * @param version The version whose source repository should be retrieved, must not be {@code null}.
+     * @return The repository from which the version was resolved or {@code null} if unknown.
+     */
+    public ArtifactRepository getRepository( Version version )
+    {
+        return repositories.get( version );
+    }
+
+    /**
+     * Records the repository from which the specified version was resolved
+     * 
+     * @param version The version whose source repository is to be recorded, must not be {@code null}.
+     * @param repository The repository from which the version was resolved, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public VersionRangeResult setRepository( Version version, ArtifactRepository repository )
+    {
+        if ( repository != null )
+        {
+            if ( repositories.isEmpty() )
+            {
+                repositories = new HashMap<Version, ArtifactRepository>();
+            }
+            repositories.put( version, repository );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the version constraint that was parsed from the artifact's version string.
+     * 
+     * @return The parsed version constraint or {@code null}.
+     */
+    public VersionConstraint getVersionConstraint()
+    {
+        return versionConstraint;
+    }
+
+    /**
+     * Sets the version constraint that was parsed from the artifact's version string.
+     * 
+     * @param versionConstraint The parsed version constraint, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public VersionRangeResult setVersionConstraint( VersionConstraint versionConstraint )
+    {
+        this.versionConstraint = versionConstraint;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return String.valueOf( repositories );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRequest.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionRequest.java
new file mode 100644 (file)
index 0000000..e18701b
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.RequestTrace;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * A request to resolve a metaversion.
+ * 
+ * @see RepositorySystem#resolveVersion(RepositorySystemSession, VersionRequest)
+ */
+public final class VersionRequest
+{
+
+    private Artifact artifact;
+
+    private List<RemoteRepository> repositories = Collections.emptyList();
+
+    private String context = "";
+
+    private RequestTrace trace;
+
+    /**
+     * Creates an uninitialized request.
+     */
+    public VersionRequest()
+    {
+        // enables default constructor
+    }
+
+    /**
+     * Creates a request with the specified properties.
+     * 
+     * @param artifact The artifact whose (meta-)version should be resolved, may be {@code null}.
+     * @param repositories The repositories to resolve the version from, may be {@code null}.
+     * @param context The context in which this request is made, may be {@code null}.
+     */
+    public VersionRequest( Artifact artifact, List<RemoteRepository> repositories, String context )
+    {
+        setArtifact( artifact );
+        setRepositories( repositories );
+        setRequestContext( context );
+    }
+
+    /**
+     * Gets the artifact whose (meta-)version shall be resolved.
+     * 
+     * @return The artifact or {@code null} if not set.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Sets the artifact whose (meta-)version shall be resolved.
+     * 
+     * @param artifact The artifact, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRequest setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+        return this;
+    }
+
+    /**
+     * Gets the repositories to resolve the version from.
+     * 
+     * @return The repositories, never {@code null}.
+     */
+    public List<RemoteRepository> getRepositories()
+    {
+        return repositories;
+    }
+
+    /**
+     * Sets the repositories to resolve the version from.
+     * 
+     * @param repositories The repositories, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRequest setRepositories( List<RemoteRepository> repositories )
+    {
+        if ( repositories == null )
+        {
+            this.repositories = Collections.emptyList();
+        }
+        else
+        {
+            this.repositories = repositories;
+        }
+        return this;
+    }
+
+    /**
+     * Adds the specified repository for the resolution.
+     * 
+     * @param repository The repository to add, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRequest addRepository( RemoteRepository repository )
+    {
+        if ( repository != null )
+        {
+            if ( this.repositories.isEmpty() )
+            {
+                this.repositories = new ArrayList<RemoteRepository>();
+            }
+            this.repositories.add( repository );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the context in which this request is made.
+     * 
+     * @return The context, never {@code null}.
+     */
+    public String getRequestContext()
+    {
+        return context;
+    }
+
+    /**
+     * Sets the context in which this request is made.
+     * 
+     * @param context The context, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRequest setRequestContext( String context )
+    {
+        this.context = ( context != null ) ? context : "";
+        return this;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    /**
+     * Sets the trace information that describes the higher level request/operation in which this request is issued.
+     * 
+     * @param trace The trace information about the higher level operation, may be {@code null}.
+     * @return This request for chaining, never {@code null}.
+     */
+    public VersionRequest setTrace( RequestTrace trace )
+    {
+        this.trace = trace;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getArtifact() + " < " + getRepositories();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResolutionException.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResolutionException.java
new file mode 100644 (file)
index 0000000..25f381e
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case of an unresolvable metaversion.
+ */
+public class VersionResolutionException
+    extends RepositoryException
+{
+
+    private final transient VersionResult result;
+
+    /**
+     * Creates a new exception with the specified result.
+     * 
+     * @param result The version result at the point the exception occurred, may be {@code null}.
+     */
+    public VersionResolutionException( VersionResult result )
+    {
+        super( getMessage( result ), getCause( result ) );
+        this.result = result;
+    }
+
+    private static String getMessage( VersionResult result )
+    {
+        StringBuilder buffer = new StringBuilder( 256 );
+        buffer.append( "Failed to resolve version" );
+        if ( result != null )
+        {
+            buffer.append( " for " ).append( result.getRequest().getArtifact() );
+            if ( !result.getExceptions().isEmpty() )
+            {
+                buffer.append( ": " ).append( result.getExceptions().iterator().next().getMessage() );
+            }
+        }
+        return buffer.toString();
+    }
+
+    private static Throwable getCause( VersionResult result )
+    {
+        Throwable cause = null;
+        if ( result != null && !result.getExceptions().isEmpty() )
+        {
+            cause = result.getExceptions().get( 0 );
+        }
+        return cause;
+    }
+
+    /**
+     * Creates a new exception with the specified result and detail message.
+     * 
+     * @param result The version result at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public VersionResolutionException( VersionResult result, String message )
+    {
+        super( message, getCause( result ) );
+        this.result = result;
+    }
+
+    /**
+     * Creates a new exception with the specified result, detail message and cause.
+     * 
+     * @param result The version result at the point the exception occurred, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public VersionResolutionException( VersionResult result, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.result = result;
+    }
+
+    /**
+     * Gets the version result at the point the exception occurred. Despite being incomplete, callers might want to use
+     * this result to fail gracefully and continue their operation with whatever interim data has been gathered.
+     * 
+     * @return The version result or {@code null} if unknown.
+     */
+    public VersionResult getResult()
+    {
+        return result;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResult.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/VersionResult.java
new file mode 100644 (file)
index 0000000..2e76b1c
--- /dev/null
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.resolution;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.ArtifactRepository;
+
+/**
+ * The result of a version resolution request.
+ * 
+ * @see RepositorySystem#resolveVersion(RepositorySystemSession, VersionRequest)
+ */
+public final class VersionResult
+{
+
+    private final VersionRequest request;
+
+    private List<Exception> exceptions;
+
+    private String version;
+
+    private ArtifactRepository repository;
+
+    /**
+     * Creates a new result for the specified request.
+     * 
+     * @param request The resolution request, must not be {@code null}.
+     */
+    public VersionResult( VersionRequest request )
+    {
+        if ( request == null )
+        {
+            throw new IllegalArgumentException( "version request has not been specified" );
+        }
+        this.request = request;
+        exceptions = Collections.emptyList();
+    }
+
+    /**
+     * Gets the resolution request that was made.
+     * 
+     * @return The resolution request, never {@code null}.
+     */
+    public VersionRequest getRequest()
+    {
+        return request;
+    }
+
+    /**
+     * Gets the exceptions that occurred while resolving the version.
+     * 
+     * @return The exceptions that occurred, never {@code null}.
+     */
+    public List<Exception> getExceptions()
+    {
+        return exceptions;
+    }
+
+    /**
+     * Records the specified exception while resolving the version.
+     * 
+     * @param exception The exception to record, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public VersionResult addException( Exception exception )
+    {
+        if ( exception != null )
+        {
+            if ( exceptions.isEmpty() )
+            {
+                exceptions = new ArrayList<Exception>();
+            }
+            exceptions.add( exception );
+        }
+        return this;
+    }
+
+    /**
+     * Gets the resolved version.
+     * 
+     * @return The resolved version or {@code null} if the resolution failed.
+     */
+    public String getVersion()
+    {
+        return version;
+    }
+
+    /**
+     * Sets the resolved version.
+     * 
+     * @param version The resolved version, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public VersionResult setVersion( String version )
+    {
+        this.version = version;
+        return this;
+    }
+
+    /**
+     * Gets the repository from which the version was eventually resolved.
+     * 
+     * @return The repository from which the version was resolved or {@code null} if unknown.
+     */
+    public ArtifactRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Sets the repository from which the version was resolved.
+     * 
+     * @param repository The repository from which the version was resolved, may be {@code null}.
+     * @return This result for chaining, never {@code null}.
+     */
+    public VersionResult setRepository( ArtifactRepository repository )
+    {
+        this.repository = repository;
+        return this;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getVersion() + " @ " + getRepository();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/resolution/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/resolution/package-info.java
new file mode 100644 (file)
index 0000000..84b825b
--- /dev/null
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The types supporting the resolution of artifacts and metadata from repositories.
+ */
+package org.eclipse.aether.resolution;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/AbstractTransferListener.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/AbstractTransferListener.java
new file mode 100644 (file)
index 0000000..01aff17
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+/**
+ * A skeleton implementation for custom transfer listeners. The callback methods in this class do nothing.
+ */
+public abstract class AbstractTransferListener
+    implements TransferListener
+{
+
+    /**
+     * Enables subclassing.
+     */
+    protected AbstractTransferListener()
+    {
+    }
+
+    public void transferInitiated( TransferEvent event )
+        throws TransferCancelledException
+    {
+    }
+
+    public void transferStarted( TransferEvent event )
+        throws TransferCancelledException
+    {
+    }
+
+    public void transferProgressed( TransferEvent event )
+        throws TransferCancelledException
+    {
+    }
+
+    public void transferCorrupted( TransferEvent event )
+        throws TransferCancelledException
+    {
+    }
+
+    public void transferSucceeded( TransferEvent event )
+    {
+    }
+
+    public void transferFailed( TransferEvent event )
+    {
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactNotFoundException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactNotFoundException.java
new file mode 100644 (file)
index 0000000..3813743
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.ArtifactProperties;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * Thrown when an artifact was not found in a particular repository.
+ */
+public class ArtifactNotFoundException
+    extends ArtifactTransferException
+{
+
+    /**
+     * Creates a new exception with the specified artifact and repository.
+     * 
+     * @param artifact The missing artifact, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     */
+    public ArtifactNotFoundException( Artifact artifact, RemoteRepository repository )
+    {
+        super( artifact, repository, getMessage( artifact, repository ) );
+    }
+
+    private static String getMessage( Artifact artifact, RemoteRepository repository )
+    {
+        StringBuilder buffer = new StringBuilder( 256 );
+        buffer.append( "Could not find artifact " ).append( artifact );
+        buffer.append( getString( " in ", repository ) );
+        if ( artifact != null )
+        {
+            String localPath = artifact.getProperty( ArtifactProperties.LOCAL_PATH, null );
+            if ( localPath != null && repository == null )
+            {
+                buffer.append( " at specified path " ).append( localPath );
+            }
+            String downloadUrl = artifact.getProperty( ArtifactProperties.DOWNLOAD_URL, null );
+            if ( downloadUrl != null )
+            {
+                buffer.append( ", try downloading from " ).append( downloadUrl );
+            }
+        }
+        return buffer.toString();
+    }
+
+    /**
+     * Creates a new exception with the specified artifact, repository and detail message.
+     * 
+     * @param artifact The missing artifact, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public ArtifactNotFoundException( Artifact artifact, RemoteRepository repository, String message )
+    {
+        super( artifact, repository, message );
+    }
+
+    /**
+     * Creates a new exception with the specified artifact, repository and detail message.
+     * 
+     * @param artifact The missing artifact, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
+     *            exception actually just occurred.
+     */
+    public ArtifactNotFoundException( Artifact artifact, RemoteRepository repository, String message, boolean fromCache )
+    {
+        super( artifact, repository, message, fromCache );
+    }
+
+    /**
+     * Creates a new exception with the specified artifact, repository, detail message and cause.
+     * 
+     * @param artifact The missing artifact, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public ArtifactNotFoundException( Artifact artifact, RemoteRepository repository, String message, Throwable cause )
+    {
+        super( artifact, repository, message, cause );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactTransferException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ArtifactTransferException.java
new file mode 100644 (file)
index 0000000..5a481ee
--- /dev/null
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * Thrown when an artifact could not be uploaded/downloaded to/from a particular remote repository.
+ */
+public class ArtifactTransferException
+    extends RepositoryException
+{
+
+    private final transient Artifact artifact;
+
+    private final transient RemoteRepository repository;
+
+    private final boolean fromCache;
+
+    static String getString( String prefix, RemoteRepository repository )
+    {
+        if ( repository == null )
+        {
+            return "";
+        }
+        else
+        {
+            return prefix + repository.getId() + " (" + repository.getUrl() + ")";
+        }
+    }
+
+    /**
+     * Creates a new exception with the specified artifact, repository and detail message.
+     * 
+     * @param artifact The untransferable artifact, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public ArtifactTransferException( Artifact artifact, RemoteRepository repository, String message )
+    {
+        this( artifact, repository, message, false );
+    }
+
+    /**
+     * Creates a new exception with the specified artifact, repository and detail message.
+     * 
+     * @param artifact The untransferable artifact, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
+     *            exception actually just occurred.
+     */
+    public ArtifactTransferException( Artifact artifact, RemoteRepository repository, String message, boolean fromCache )
+    {
+        super( message );
+        this.artifact = artifact;
+        this.repository = repository;
+        this.fromCache = fromCache;
+    }
+
+    /**
+     * Creates a new exception with the specified artifact, repository and cause.
+     * 
+     * @param artifact The untransferable artifact, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public ArtifactTransferException( Artifact artifact, RemoteRepository repository, Throwable cause )
+    {
+        this( artifact, repository, "Could not transfer artifact " + artifact + getString( " from/to ", repository )
+            + getMessage( ": ", cause ), cause );
+    }
+
+    /**
+     * Creates a new exception with the specified artifact, repository, detail message and cause.
+     * 
+     * @param artifact The untransferable artifact, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public ArtifactTransferException( Artifact artifact, RemoteRepository repository, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.artifact = artifact;
+        this.repository = repository;
+        this.fromCache = false;
+    }
+
+    /**
+     * Gets the artifact that could not be transferred.
+     * 
+     * @return The troublesome artifact or {@code null} if unknown.
+     */
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    /**
+     * Gets the remote repository involved in the transfer.
+     * 
+     * @return The involved remote repository or {@code null} if unknown.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Indicates whether this exception actually just occurred or was played back from the error cache.
+     * 
+     * @return {@code true} if the exception was played back from the error cache, {@code false} if the exception
+     *         actually occurred just now.
+     */
+    public boolean isFromCache()
+    {
+        return fromCache;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ChecksumFailureException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/ChecksumFailureException.java
new file mode 100644 (file)
index 0000000..e3f248a
--- /dev/null
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case of a checksum failure during an artifact/metadata download.
+ */
+public class ChecksumFailureException
+    extends RepositoryException
+{
+
+    private final String expected;
+
+    private final String actual;
+
+    private final boolean retryWorthy;
+
+    /**
+     * Creates a new exception with the specified expected and actual checksum. The resulting exception is
+     * {@link #isRetryWorthy() retry-worthy}.
+     * 
+     * @param expected The expected checksum as declared by the hosting repository, may be {@code null}.
+     * @param actual The actual checksum as computed from the local bytes, may be {@code null}.
+     */
+    public ChecksumFailureException( String expected, String actual )
+    {
+        super( "Checksum validation failed, expected " + expected + " but is " + actual );
+        this.expected = expected;
+        this.actual = actual;
+        retryWorthy = true;
+    }
+
+    /**
+     * Creates a new exception with the specified detail message. The resulting exception is not
+     * {@link #isRetryWorthy() retry-worthy}.
+     * 
+     * @param message The detail message, may be {@code null}.
+     */
+    public ChecksumFailureException( String message )
+    {
+        this( false, message, null );
+    }
+
+    /**
+     * Creates a new exception with the specified cause. The resulting exception is not {@link #isRetryWorthy()
+     * retry-worthy}.
+     * 
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public ChecksumFailureException( Throwable cause )
+    {
+        this( "Checksum validation failed" + getMessage( ": ", cause ), cause );
+    }
+
+    /**
+     * Creates a new exception with the specified detail message and cause. The resulting exception is not
+     * {@link #isRetryWorthy() retry-worthy}.
+     * 
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public ChecksumFailureException( String message, Throwable cause )
+    {
+        this( false, message, cause );
+    }
+
+    /**
+     * Creates a new exception with the specified retry flag, detail message and cause.
+     * 
+     * @param retryWorthy {@code true} if the exception is retry-worthy, {@code false} otherwise.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public ChecksumFailureException( boolean retryWorthy, String message, Throwable cause )
+    {
+        super( message, cause );
+        expected = actual = "";
+        this.retryWorthy = retryWorthy;
+    }
+
+    /**
+     * Gets the expected checksum for the downloaded artifact/metadata.
+     * 
+     * @return The expected checksum as declared by the hosting repository or {@code null} if unknown.
+     */
+    public String getExpected()
+    {
+        return expected;
+    }
+
+    /**
+     * Gets the actual checksum for the downloaded artifact/metadata.
+     * 
+     * @return The actual checksum as computed from the local bytes or {@code null} if unknown.
+     */
+    public String getActual()
+    {
+        return actual;
+    }
+
+    /**
+     * Indicates whether the corresponding download is retry-worthy.
+     * 
+     * @return {@code true} if retrying the download might solve the checksum failure, {@code false} if the checksum
+     *         failure is non-recoverable.
+     */
+    public boolean isRetryWorthy()
+    {
+        return retryWorthy;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataNotFoundException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataNotFoundException.java
new file mode 100644 (file)
index 0000000..af9a840
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * Thrown when metadata was not found in a particular repository.
+ */
+public class MetadataNotFoundException
+    extends MetadataTransferException
+{
+
+    /**
+     * Creates a new exception with the specified metadata and local repository.
+     * 
+     * @param metadata The missing metadata, may be {@code null}.
+     * @param repository The involved local repository, may be {@code null}.
+     */
+    public MetadataNotFoundException( Metadata metadata, LocalRepository repository )
+    {
+        super( metadata, null, "Could not find metadata " + metadata + getString( " in ", repository ) );
+    }
+
+    private static String getString( String prefix, LocalRepository repository )
+    {
+        if ( repository == null )
+        {
+            return "";
+        }
+        else
+        {
+            return prefix + repository.getId() + " (" + repository.getBasedir() + ")";
+        }
+    }
+
+    /**
+     * Creates a new exception with the specified metadata and repository.
+     * 
+     * @param metadata The missing metadata, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     */
+    public MetadataNotFoundException( Metadata metadata, RemoteRepository repository )
+    {
+        super( metadata, repository, "Could not find metadata " + metadata + getString( " in ", repository ) );
+    }
+
+    /**
+     * Creates a new exception with the specified metadata, repository and detail message.
+     * 
+     * @param metadata The missing metadata, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message )
+    {
+        super( metadata, repository, message );
+    }
+
+    /**
+     * Creates a new exception with the specified metadata, repository and detail message.
+     * 
+     * @param metadata The missing metadata, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
+     *            exception actually just occurred.
+     */
+    public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message, boolean fromCache )
+    {
+        super( metadata, repository, message, fromCache );
+    }
+
+    /**
+     * Creates a new exception with the specified metadata, repository, detail message and cause.
+     * 
+     * @param metadata The missing metadata, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message, Throwable cause )
+    {
+        super( metadata, repository, message, cause );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataTransferException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataTransferException.java
new file mode 100644 (file)
index 0000000..f86b986
--- /dev/null
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.metadata.Metadata;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * Thrown when metadata could not be uploaded/downloaded to/from a particular remote repository.
+ */
+public class MetadataTransferException
+    extends RepositoryException
+{
+
+    private final transient Metadata metadata;
+
+    private final transient RemoteRepository repository;
+
+    private final boolean fromCache;
+
+    static String getString( String prefix, RemoteRepository repository )
+    {
+        if ( repository == null )
+        {
+            return "";
+        }
+        else
+        {
+            return prefix + repository.getId() + " (" + repository.getUrl() + ")";
+        }
+    }
+
+    /**
+     * Creates a new exception with the specified metadata, repository and detail message.
+     * 
+     * @param metadata The untransferable metadata, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public MetadataTransferException( Metadata metadata, RemoteRepository repository, String message )
+    {
+        this( metadata, repository, message, false );
+    }
+
+    /**
+     * Creates a new exception with the specified metadata, repository and detail message.
+     * 
+     * @param metadata The untransferable metadata, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
+     *            exception actually just occurred.
+     */
+    public MetadataTransferException( Metadata metadata, RemoteRepository repository, String message, boolean fromCache )
+    {
+        super( message );
+        this.metadata = metadata;
+        this.repository = repository;
+        this.fromCache = fromCache;
+    }
+
+    /**
+     * Creates a new exception with the specified metadata, repository and cause.
+     * 
+     * @param metadata The untransferable metadata, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public MetadataTransferException( Metadata metadata, RemoteRepository repository, Throwable cause )
+    {
+        this( metadata, repository, "Could not transfer metadata " + metadata + getString( " from/to ", repository )
+            + getMessage( ": ", cause ), cause );
+    }
+
+    /**
+     * Creates a new exception with the specified metadata, repository, detail message and cause.
+     * 
+     * @param metadata The untransferable metadata, may be {@code null}.
+     * @param repository The involved remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public MetadataTransferException( Metadata metadata, RemoteRepository repository, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.metadata = metadata;
+        this.repository = repository;
+        this.fromCache = false;
+    }
+
+    /**
+     * Gets the metadata that could not be transferred.
+     * 
+     * @return The troublesome metadata or {@code null} if unknown.
+     */
+    public Metadata getMetadata()
+    {
+        return metadata;
+    }
+
+    /**
+     * Gets the remote repository involved in the transfer.
+     * 
+     * @return The involved remote repository or {@code null} if unknown.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+    /**
+     * Indicates whether this exception actually just occurred or was played back from the error cache.
+     * 
+     * @return {@code true} if the exception was played back from the error cache, {@code false} if the exception
+     *         actually occurred just now.
+     */
+    public boolean isFromCache()
+    {
+        return fromCache;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryConnectorException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryConnectorException.java
new file mode 100644 (file)
index 0000000..c91be2b
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * Thrown in case of an unsupported remote repository type.
+ */
+public class NoRepositoryConnectorException
+    extends RepositoryException
+{
+
+    private final transient RemoteRepository repository;
+
+    /**
+     * Creates a new exception with the specified repository.
+     * 
+     * @param repository The remote repository whose content type is not supported, may be {@code null}.
+     */
+    public NoRepositoryConnectorException( RemoteRepository repository )
+    {
+        this( repository, toMessage( repository ) );
+    }
+
+    /**
+     * Creates a new exception with the specified repository and detail message.
+     * 
+     * @param repository The remote repository whose content type is not supported, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public NoRepositoryConnectorException( RemoteRepository repository, String message )
+    {
+        super( message );
+        this.repository = repository;
+    }
+
+    /**
+     * Creates a new exception with the specified repository and cause.
+     * 
+     * @param repository The remote repository whose content type is not supported, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public NoRepositoryConnectorException( RemoteRepository repository, Throwable cause )
+    {
+        this( repository, toMessage( repository ), cause );
+    }
+
+    /**
+     * Creates a new exception with the specified repository, detail message and cause.
+     * 
+     * @param repository The remote repository whose content type is not supported, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public NoRepositoryConnectorException( RemoteRepository repository, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.repository = repository;
+    }
+
+    private static String toMessage( RemoteRepository repository )
+    {
+        if ( repository != null )
+        {
+            return "No connector available to access repository " + repository.getId() + " (" + repository.getUrl()
+                + ") of type " + repository.getContentType();
+        }
+        else
+        {
+            return "No connector available to access repository";
+        }
+    }
+
+    /**
+     * Gets the remote repository whose content type is not supported.
+     * 
+     * @return The unsupported remote repository or {@code null} if unknown.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryLayoutException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoRepositoryLayoutException.java
new file mode 100644 (file)
index 0000000..3176601
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * Thrown in case of an unsupported repository layout.
+ */
+public class NoRepositoryLayoutException
+    extends RepositoryException
+{
+
+    private final transient RemoteRepository repository;
+
+    /**
+     * Creates a new exception with the specified repository.
+     * 
+     * @param repository The remote repository whose layout is not supported, may be {@code null}.
+     */
+    public NoRepositoryLayoutException( RemoteRepository repository )
+    {
+        this( repository, toMessage( repository ) );
+    }
+
+    /**
+     * Creates a new exception with the specified repository and detail message.
+     * 
+     * @param repository The remote repository whose layout is not supported, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public NoRepositoryLayoutException( RemoteRepository repository, String message )
+    {
+        super( message );
+        this.repository = repository;
+    }
+
+    /**
+     * Creates a new exception with the specified repository and cause.
+     * 
+     * @param repository The remote repository whose layout is not supported, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public NoRepositoryLayoutException( RemoteRepository repository, Throwable cause )
+    {
+        this( repository, toMessage( repository ), cause );
+    }
+
+    /**
+     * Creates a new exception with the specified repository, detail message and cause.
+     * 
+     * @param repository The remote repository whose layout is not supported, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public NoRepositoryLayoutException( RemoteRepository repository, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.repository = repository;
+    }
+
+    private static String toMessage( RemoteRepository repository )
+    {
+        if ( repository != null )
+        {
+            return "Unsupported repository layout " + repository.getContentType();
+        }
+        else
+        {
+            return "Unsupported repository layout";
+        }
+    }
+
+    /**
+     * Gets the remote repository whose layout is not supported.
+     * 
+     * @return The unsupported remote repository or {@code null} if unknown.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoTransporterException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoTransporterException.java
new file mode 100644 (file)
index 0000000..895b066
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * Thrown in case of an unsupported transport protocol.
+ */
+public class NoTransporterException
+    extends RepositoryException
+{
+
+    private final transient RemoteRepository repository;
+
+    /**
+     * Creates a new exception with the specified repository.
+     * 
+     * @param repository The remote repository whose transport layout is not supported, may be {@code null}.
+     */
+    public NoTransporterException( RemoteRepository repository )
+    {
+        this( repository, toMessage( repository ) );
+    }
+
+    /**
+     * Creates a new exception with the specified repository and detail message.
+     * 
+     * @param repository The remote repository whose transport layout is not supported, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public NoTransporterException( RemoteRepository repository, String message )
+    {
+        super( message );
+        this.repository = repository;
+    }
+
+    /**
+     * Creates a new exception with the specified repository and cause.
+     * 
+     * @param repository The remote repository whose transport layout is not supported, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public NoTransporterException( RemoteRepository repository, Throwable cause )
+    {
+        this( repository, toMessage( repository ), cause );
+    }
+
+    /**
+     * Creates a new exception with the specified repository, detail message and cause.
+     * 
+     * @param repository The remote repository whose transport layout is not supported, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public NoTransporterException( RemoteRepository repository, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.repository = repository;
+    }
+
+    private static String toMessage( RemoteRepository repository )
+    {
+        if ( repository != null )
+        {
+            return "Unsupported transport protocol " + repository.getProtocol();
+        }
+        else
+        {
+            return "Unsupported transport protocol";
+        }
+    }
+
+    /**
+     * Gets the remote repository whose transport protocol is not supported.
+     * 
+     * @return The unsupported remote repository or {@code null} if unknown.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/RepositoryOfflineException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/RepositoryOfflineException.java
new file mode 100644 (file)
index 0000000..1115054
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.RepositoryException;
+import org.eclipse.aether.repository.RemoteRepository;
+
+/**
+ * Thrown when a transfer could not be performed because a remote repository is not accessible in offline mode.
+ */
+public class RepositoryOfflineException
+    extends RepositoryException
+{
+
+    private final transient RemoteRepository repository;
+
+    private static String getMessage( RemoteRepository repository )
+    {
+        if ( repository == null )
+        {
+            return "Cannot access remote repositories in offline mode";
+        }
+        else
+        {
+            return "Cannot access " + repository.getId() + " (" + repository.getUrl() + ") in offline mode";
+        }
+    }
+
+    /**
+     * Creates a new exception with the specified repository.
+     * 
+     * @param repository The inaccessible remote repository, may be {@code null}.
+     */
+    public RepositoryOfflineException( RemoteRepository repository )
+    {
+        super( getMessage( repository ) );
+        this.repository = repository;
+    }
+
+    /**
+     * Creates a new exception with the specified repository and detail message.
+     * 
+     * @param repository The inaccessible remote repository, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public RepositoryOfflineException( RemoteRepository repository, String message )
+    {
+        super( message );
+        this.repository = repository;
+    }
+
+    /**
+     * Gets the remote repository that could not be accessed due to offline mode.
+     * 
+     * @return The inaccessible remote repository or {@code null} if unknown.
+     */
+    public RemoteRepository getRepository()
+    {
+        return repository;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferCancelledException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferCancelledException.java
new file mode 100644 (file)
index 0000000..5f4ed5b
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown in case an upload/download was cancelled (e.g. due to user request).
+ */
+public class TransferCancelledException
+    extends RepositoryException
+{
+
+    /**
+     * Creates a new exception with a stock detail message.
+     */
+    public TransferCancelledException()
+    {
+        super( "The operation was cancelled." );
+    }
+
+    /**
+     * Creates a new exception with the specified detail message.
+     * 
+     * @param message The detail message, may be {@code null}.
+     */
+    public TransferCancelledException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * Creates a new exception with the specified detail message and cause.
+     * 
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public TransferCancelledException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferEvent.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferEvent.java
new file mode 100644 (file)
index 0000000..9be298f
--- /dev/null
@@ -0,0 +1,423 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import java.nio.ByteBuffer;
+
+import org.eclipse.aether.RepositorySystemSession;
+
+/**
+ * An event fired to a transfer listener during an artifact/metadata transfer.
+ * 
+ * @see TransferListener
+ * @see TransferEvent.Builder
+ */
+public final class TransferEvent
+{
+
+    /**
+     * The type of the event.
+     */
+    public enum EventType
+    {
+
+        /**
+         * @see TransferListener#transferInitiated(TransferEvent)
+         */
+        INITIATED,
+
+        /**
+         * @see TransferListener#transferStarted(TransferEvent)
+         */
+        STARTED,
+
+        /**
+         * @see TransferListener#transferProgressed(TransferEvent)
+         */
+        PROGRESSED,
+
+        /**
+         * @see TransferListener#transferCorrupted(TransferEvent)
+         */
+        CORRUPTED,
+
+        /**
+         * @see TransferListener#transferSucceeded(TransferEvent)
+         */
+        SUCCEEDED,
+
+        /**
+         * @see TransferListener#transferFailed(TransferEvent)
+         */
+        FAILED
+
+    }
+
+    /**
+     * The type of the request/transfer being performed.
+     */
+    public enum RequestType
+    {
+
+        /**
+         * Download artifact/metadata.
+         */
+        GET,
+
+        /**
+         * Check artifact/metadata existence only.
+         */
+        GET_EXISTENCE,
+
+        /**
+         * Upload artifact/metadata.
+         */
+        PUT,
+
+    }
+
+    private final EventType type;
+
+    private final RequestType requestType;
+
+    private final RepositorySystemSession session;
+
+    private final TransferResource resource;
+
+    private final ByteBuffer dataBuffer;
+
+    private final long transferredBytes;
+
+    private final Exception exception;
+
+    TransferEvent( Builder builder )
+    {
+        type = builder.type;
+        requestType = builder.requestType;
+        session = builder.session;
+        resource = builder.resource;
+        dataBuffer = builder.dataBuffer;
+        transferredBytes = builder.transferredBytes;
+        exception = builder.exception;
+    }
+
+    /**
+     * Gets the type of the event.
+     * 
+     * @return The type of the event, never {@code null}.
+     */
+    public EventType getType()
+    {
+        return type;
+    }
+
+    /**
+     * Gets the type of the request/transfer.
+     * 
+     * @return The type of the request/transfer, never {@code null}.
+     */
+    public RequestType getRequestType()
+    {
+        return requestType;
+    }
+
+    /**
+     * Gets the repository system session during which the event occurred.
+     * 
+     * @return The repository system session during which the event occurred, never {@code null}.
+     */
+    public RepositorySystemSession getSession()
+    {
+        return session;
+    }
+
+    /**
+     * Gets the resource that is being transferred.
+     * 
+     * @return The resource being transferred, never {@code null}.
+     */
+    public TransferResource getResource()
+    {
+        return resource;
+    }
+
+    /**
+     * Gets the total number of bytes that have been transferred since the download/upload of the resource was started.
+     * If a download has been resumed, the returned count includes the bytes that were already downloaded during the
+     * previous attempt. In other words, the ratio of transferred bytes to the content length of the resource indicates
+     * the percentage of transfer completion.
+     * 
+     * @return The total number of bytes that have been transferred since the transfer started, never negative.
+     * @see #getDataLength()
+     * @see TransferResource#getResumeOffset()
+     */
+    public long getTransferredBytes()
+    {
+        return transferredBytes;
+    }
+
+    /**
+     * Gets the byte buffer holding the transferred bytes since the last event. A listener must assume this buffer to be
+     * owned by the event source and must not change any byte in this buffer. Also, the buffer is only valid for the
+     * duration of the event callback, i.e. the next event might reuse the same buffer (with updated contents).
+     * Therefore, if the actual event processing is deferred, the byte buffer would have to be cloned to create an
+     * immutable snapshot of its contents.
+     * 
+     * @return The (read-only) byte buffer or {@code null} if not applicable to the event, i.e. if the event type is not
+     *         {@link EventType#PROGRESSED}.
+     */
+    public ByteBuffer getDataBuffer()
+    {
+        return ( dataBuffer != null ) ? dataBuffer.asReadOnlyBuffer() : null;
+    }
+
+    /**
+     * Gets the number of bytes that have been transferred since the last event.
+     * 
+     * @return The number of bytes that have been transferred since the last event, possibly zero but never negative.
+     * @see #getTransferredBytes()
+     */
+    public int getDataLength()
+    {
+        return ( dataBuffer != null ) ? dataBuffer.remaining() : 0;
+    }
+
+    /**
+     * Gets the error that occurred during the transfer.
+     * 
+     * @return The error that occurred or {@code null} if none.
+     */
+    public Exception getException()
+    {
+        return exception;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getRequestType() + " " + getType() + " " + getResource();
+    }
+
+    /**
+     * A builder to create transfer events.
+     */
+    public static final class Builder
+    {
+
+        EventType type;
+
+        RequestType requestType;
+
+        RepositorySystemSession session;
+
+        TransferResource resource;
+
+        ByteBuffer dataBuffer;
+
+        long transferredBytes;
+
+        Exception exception;
+
+        /**
+         * Creates a new transfer event builder for the specified session and the given resource.
+         * 
+         * @param session The repository system session, must not be {@code null}.
+         * @param resource The resource being transferred, must not be {@code null}.
+         */
+        public Builder( RepositorySystemSession session, TransferResource resource )
+        {
+            if ( session == null )
+            {
+                throw new IllegalArgumentException( "session not specified" );
+            }
+            if ( resource == null )
+            {
+                throw new IllegalArgumentException( "transfer resource not specified" );
+            }
+            this.session = session;
+            this.resource = resource;
+            type = EventType.INITIATED;
+            requestType = RequestType.GET;
+        }
+
+        private Builder( Builder prototype )
+        {
+            session = prototype.session;
+            resource = prototype.resource;
+            type = prototype.type;
+            requestType = prototype.requestType;
+            dataBuffer = prototype.dataBuffer;
+            transferredBytes = prototype.transferredBytes;
+            exception = prototype.exception;
+        }
+
+        /**
+         * Creates a new transfer event builder from the current values of this builder. The state of this builder
+         * remains unchanged.
+         * 
+         * @return The new event builder, never {@code null}.
+         */
+        public Builder copy()
+        {
+            return new Builder( this );
+        }
+
+        /**
+         * Sets the type of the event and resets event-specific fields. In more detail, the data buffer and the
+         * exception fields are set to {@code null}. Furthermore, the total number of transferred bytes is set to
+         * {@code 0} if the event type is {@link EventType#STARTED}.
+         * 
+         * @param type The type of the event, must not be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder resetType( EventType type )
+        {
+            if ( type == null )
+            {
+                throw new IllegalArgumentException( "event type not specified" );
+            }
+            this.type = type;
+            dataBuffer = null;
+            exception = null;
+            switch ( type )
+            {
+                case INITIATED:
+                case STARTED:
+                    transferredBytes = 0;
+                default:
+            }
+            return this;
+        }
+
+        /**
+         * Sets the type of the event. When re-using the same builder to generate a sequence of events for one transfer,
+         * {@link #resetType(TransferEvent.EventType)} might be more handy.
+         * 
+         * @param type The type of the event, must not be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setType( EventType type )
+        {
+            if ( type == null )
+            {
+                throw new IllegalArgumentException( "event type not specified" );
+            }
+            this.type = type;
+            return this;
+        }
+
+        /**
+         * Sets the type of the request/transfer.
+         * 
+         * @param requestType The request/transfer type, must not be {@code null}.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setRequestType( RequestType requestType )
+        {
+            if ( requestType == null )
+            {
+                throw new IllegalArgumentException( "request type not specified" );
+            }
+            this.requestType = requestType;
+            return this;
+        }
+
+        /**
+         * Sets the total number of bytes that have been transferred so far during the download/upload of the resource.
+         * If a download is being resumed, the count must include the bytes that were already downloaded in the previous
+         * attempt and from which the current transfer started. In this case, the event type {@link EventType#STARTED}
+         * should indicate from what byte the download resumes.
+         * 
+         * @param transferredBytes The total number of bytes that have been transferred so far during the
+         *            download/upload of the resource, must not be negative.
+         * @return This event builder for chaining, never {@code null}.
+         * @see TransferResource#setResumeOffset(long)
+         */
+        public Builder setTransferredBytes( long transferredBytes )
+        {
+            if ( transferredBytes < 0 )
+            {
+                throw new IllegalArgumentException( "number of transferred bytes cannot be negative" );
+            }
+            this.transferredBytes = transferredBytes;
+            return this;
+        }
+
+        /**
+         * Increments the total number of bytes that have been transferred so far during the download/upload.
+         * 
+         * @param transferredBytes The number of bytes that have been transferred since the last event, must not be
+         *            negative.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder addTransferredBytes( long transferredBytes )
+        {
+            if ( transferredBytes < 0 )
+            {
+                throw new IllegalArgumentException( "number of transferred bytes cannot be negative" );
+            }
+            this.transferredBytes += transferredBytes;
+            return this;
+        }
+
+        /**
+         * Sets the byte buffer holding the transferred bytes since the last event.
+         * 
+         * @param buffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if not
+         *            applicable to the event.
+         * @param offset The starting point of valid bytes in the array.
+         * @param length The number of valid bytes, must not be negative.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setDataBuffer( byte[] buffer, int offset, int length )
+        {
+            return setDataBuffer( ( buffer != null ) ? ByteBuffer.wrap( buffer, offset, length ) : null );
+        }
+
+        /**
+         * Sets the byte buffer holding the transferred bytes since the last event.
+         * 
+         * @param dataBuffer The byte buffer holding the transferred bytes since the last event, may be {@code null} if
+         *            not applicable to the event.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setDataBuffer( ByteBuffer dataBuffer )
+        {
+            this.dataBuffer = dataBuffer;
+            return this;
+        }
+
+        /**
+         * Sets the error that occurred during the transfer.
+         * 
+         * @param exception The error that occurred during the transfer, may be {@code null} if none.
+         * @return This event builder for chaining, never {@code null}.
+         */
+        public Builder setException( Exception exception )
+        {
+            this.exception = exception;
+            return this;
+        }
+
+        /**
+         * Builds a new transfer event from the current values of this builder. The state of the builder itself remains
+         * unchanged.
+         * 
+         * @return The transfer event, never {@code null}.
+         */
+        public TransferEvent build()
+        {
+            return new TransferEvent( this );
+        }
+
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferListener.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferListener.java
new file mode 100644 (file)
index 0000000..26c016d
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+/**
+ * A listener being notified of artifact/metadata transfers from/to remote repositories. The listener may be called from
+ * an arbitrary thread. Reusing common regular expression syntax, the sequence of events is roughly as follows:
+ * 
+ * <pre>
+ * INITIATED ( STARTED PROGRESSED* CORRUPTED? )* ( SUCCEEDED | FAILED )
+ * </pre>
+ * 
+ * <em>Note:</em> Implementors are strongly advised to inherit from {@link AbstractTransferListener} instead of directly
+ * implementing this interface.
+ * 
+ * @see org.eclipse.aether.RepositorySystemSession#getTransferListener()
+ * @see org.eclipse.aether.RepositoryListener
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface TransferListener
+{
+
+    /**
+     * Notifies the listener about the initiation of a transfer. This event gets fired before any actual network access
+     * to the remote repository and usually indicates some thread is now about to perform the transfer. For a given
+     * transfer request, this event is the first one being fired and it must be emitted exactly once.
+     * 
+     * @param event The event details, must not be {@code null}.
+     * @throws TransferCancelledException If the transfer should be aborted.
+     */
+    void transferInitiated( TransferEvent event )
+        throws TransferCancelledException;
+
+    /**
+     * Notifies the listener about the start of a data transfer. This event indicates a successful connection to the
+     * remote repository. In case of a download, the requested remote resource exists and its size is given by
+     * {@link TransferResource#getContentLength()} if possible. This event may be fired multiple times for given
+     * transfer request if said transfer needs to be repeated (e.g. in response to an authentication challenge).
+     * 
+     * @param event The event details, must not be {@code null}.
+     * @throws TransferCancelledException If the transfer should be aborted.
+     */
+    void transferStarted( TransferEvent event )
+        throws TransferCancelledException;
+
+    /**
+     * Notifies the listener about some progress in the data transfer. This event may even be fired if actually zero
+     * bytes have been transferred since the last event, for instance to enable cancellation.
+     * 
+     * @param event The event details, must not be {@code null}.
+     * @throws TransferCancelledException If the transfer should be aborted.
+     */
+    void transferProgressed( TransferEvent event )
+        throws TransferCancelledException;
+
+    /**
+     * Notifies the listener that a checksum validation failed. {@link TransferEvent#getException()} will be of type
+     * {@link ChecksumFailureException} and can be used to query further details about the expected/actual checksums.
+     * 
+     * @param event The event details, must not be {@code null}.
+     * @throws TransferCancelledException If the transfer should be aborted.
+     */
+    void transferCorrupted( TransferEvent event )
+        throws TransferCancelledException;
+
+    /**
+     * Notifies the listener about the successful completion of a transfer. This event must be fired exactly once for a
+     * given transfer request unless said request failed.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void transferSucceeded( TransferEvent event );
+
+    /**
+     * Notifies the listener about the unsuccessful termination of a transfer. {@link TransferEvent#getException()} will
+     * provide further information about the failure.
+     * 
+     * @param event The event details, must not be {@code null}.
+     */
+    void transferFailed( TransferEvent event );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferResource.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/TransferResource.java
new file mode 100644 (file)
index 0000000..b9510fb
--- /dev/null
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.transfer;
+
+import java.io.File;
+
+import org.eclipse.aether.RequestTrace;
+
+/**
+ * Describes a resource being uploaded or downloaded by the repository system.
+ */
+public final class TransferResource
+{
+
+    private final String repositoryUrl;
+
+    private final String resourceName;
+
+    private final File file;
+
+    private final long startTime;
+
+    private final RequestTrace trace;
+
+    private long contentLength = -1;
+
+    private long resumeOffset;
+
+    /**
+     * Creates a new transfer resource with the specified properties.
+     * 
+     * @param repositoryUrl The base URL of the repository, may be {@code null} or empty if unknown. If not empty, a
+     *            trailing slash will automatically be added if missing.
+     * @param resourceName The relative path to the resource within the repository, may be {@code null}. A leading slash
+     *            (if any) will be automatically removed.
+     * @param file The source/target file involved in the transfer, may be {@code null}.
+     * @param trace The trace information, may be {@code null}.
+     */
+    public TransferResource( String repositoryUrl, String resourceName, File file, RequestTrace trace )
+    {
+        if ( repositoryUrl == null || repositoryUrl.length() <= 0 )
+        {
+            this.repositoryUrl = "";
+        }
+        else if ( repositoryUrl.endsWith( "/" ) )
+        {
+            this.repositoryUrl = repositoryUrl;
+        }
+        else
+        {
+            this.repositoryUrl = repositoryUrl + '/';
+        }
+
+        if ( resourceName == null || resourceName.length() <= 0 )
+        {
+            this.resourceName = "";
+        }
+        else if ( resourceName.startsWith( "/" ) )
+        {
+            this.resourceName = resourceName.substring( 1 );
+        }
+        else
+        {
+            this.resourceName = resourceName;
+        }
+
+        this.file = file;
+
+        this.trace = trace;
+
+        startTime = System.currentTimeMillis();
+    }
+
+    /**
+     * The base URL of the repository, e.g. "http://repo1.maven.org/maven2/". Unless the URL is unknown, it will be
+     * terminated by a trailing slash.
+     * 
+     * @return The base URL of the repository or an empty string if unknown, never {@code null}.
+     */
+    public String getRepositoryUrl()
+    {
+        return repositoryUrl;
+    }
+
+    /**
+     * The path of the resource relative to the repository's base URL, e.g. "org/apache/maven/maven/3.0/maven-3.0.pom".
+     * 
+     * @return The path of the resource, never {@code null}.
+     */
+    public String getResourceName()
+    {
+        return resourceName;
+    }
+
+    /**
+     * Gets the local file being uploaded or downloaded. When the repository system merely checks for the existence of a
+     * remote resource, no local file will be involved in the transfer.
+     * 
+     * @return The source/target file involved in the transfer or {@code null} if none.
+     */
+    public File getFile()
+    {
+        return file;
+    }
+
+    /**
+     * The size of the resource in bytes. Note that the size of a resource during downloads might be unknown to the
+     * client which is usually the case when transfers employ compression like gzip. In general, the content length is
+     * not known until the transfer has {@link TransferListener#transferStarted(TransferEvent) started}.
+     * 
+     * @return The size of the resource in bytes or a negative value if unknown.
+     */
+    public long getContentLength()
+    {
+        return contentLength;
+    }
+
+    /**
+     * Sets the size of the resource in bytes.
+     * 
+     * @param contentLength The size of the resource in bytes or a negative value if unknown.
+     * @return This resource for chaining, never {@code null}.
+     */
+    public TransferResource setContentLength( long contentLength )
+    {
+        this.contentLength = contentLength;
+        return this;
+    }
+
+    /**
+     * Gets the byte offset within the resource from which the download starts. A positive offset indicates a previous
+     * download attempt is being resumed, {@code 0} means the transfer starts at the first byte.
+     * 
+     * @return The zero-based index of the first byte being transferred, never negative.
+     */
+    public long getResumeOffset()
+    {
+        return resumeOffset;
+    }
+
+    /**
+     * Sets the byte offset within the resource at which the download starts.
+     * 
+     * @param resumeOffset The zero-based index of the first byte being transferred, must not be negative.
+     * @return This resource for chaining, never {@code null}.
+     */
+    public TransferResource setResumeOffset( long resumeOffset )
+    {
+        if ( resumeOffset < 0 )
+        {
+            throw new IllegalArgumentException( "resume offset cannot be negative" );
+        }
+        this.resumeOffset = resumeOffset;
+        return this;
+    }
+
+    /**
+     * Gets the timestamp when the transfer of this resource was started.
+     * 
+     * @return The timestamp when the transfer of this resource was started.
+     */
+    public long getTransferStartTime()
+    {
+        return startTime;
+    }
+
+    /**
+     * Gets the trace information that describes the higher level request/operation during which this resource is
+     * transferred.
+     * 
+     * @return The trace information about the higher level operation or {@code null} if none.
+     */
+    public RequestTrace getTrace()
+    {
+        return trace;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getRepositoryUrl() + getResourceName() + " <> " + getFile();
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/package-info.java
new file mode 100644 (file)
index 0000000..5ce9ff3
--- /dev/null
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * A listener and various exception types dealing with the transfer of a resource between the local system and a remote
+ * repository.
+ */
+package org.eclipse.aether.transfer;
+
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/version/InvalidVersionSpecificationException.java b/org.argeo.slc.repo/src/org/eclipse/aether/version/InvalidVersionSpecificationException.java
new file mode 100644 (file)
index 0000000..b3690c5
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.version;
+
+import org.eclipse.aether.RepositoryException;
+
+/**
+ * Thrown when a version or version range could not be parsed.
+ */
+public class InvalidVersionSpecificationException
+    extends RepositoryException
+{
+
+    private final String version;
+
+    /**
+     * Creates a new exception with the specified version and detail message.
+     * 
+     * @param version The invalid version specification, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     */
+    public InvalidVersionSpecificationException( String version, String message )
+    {
+        super( message );
+        this.version = version;
+    }
+
+    /**
+     * Creates a new exception with the specified version and cause.
+     * 
+     * @param version The invalid version specification, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public InvalidVersionSpecificationException( String version, Throwable cause )
+    {
+        super( "Could not parse version specification " + version + getMessage( ": ", cause ), cause );
+        this.version = version;
+    }
+
+    /**
+     * Creates a new exception with the specified version, detail message and cause.
+     * 
+     * @param version The invalid version specification, may be {@code null}.
+     * @param message The detail message, may be {@code null}.
+     * @param cause The exception that caused this one, may be {@code null}.
+     */
+    public InvalidVersionSpecificationException( String version, String message, Throwable cause )
+    {
+        super( message, cause );
+        this.version = version;
+    }
+
+    /**
+     * Gets the version or version range that could not be parsed.
+     * 
+     * @return The invalid version specification or {@code null} if unknown.
+     */
+    public String getVersion()
+    {
+        return version;
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/version/Version.java b/org.argeo.slc.repo/src/org/eclipse/aether/version/Version.java
new file mode 100644 (file)
index 0000000..4aceba6
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.version;
+
+/**
+ * A parsed artifact version.
+ */
+public interface Version
+    extends Comparable<Version>
+{
+
+    /**
+     * Gets the original string representation of the version.
+     * 
+     * @return The string representation of the version, never {@code null}.
+     */
+    String toString();
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionConstraint.java b/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionConstraint.java
new file mode 100644 (file)
index 0000000..dcb3b68
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.version;
+
+/**
+ * A constraint on versions for a dependency. A constraint can either consist of a version range (e.g. "[1, ]") or a
+ * single version (e.g. "1.1"). In the first case, the constraint expresses a hard requirement on a version matching the
+ * range. In the second case, the constraint expresses a soft requirement on a specific version (i.e. a recommendation).
+ */
+public interface VersionConstraint
+{
+
+    /**
+     * Gets the version range of this constraint.
+     * 
+     * @return The version range or {@code null} if none.
+     */
+    VersionRange getRange();
+
+    /**
+     * Gets the version recommended by this constraint.
+     * 
+     * @return The recommended version or {@code null} if none.
+     */
+    Version getVersion();
+
+    /**
+     * Determines whether the specified version satisfies this constraint. In more detail, a version satisfies this
+     * constraint if it matches its version range or if this constraint has no version range and the specified version
+     * equals the version recommended by the constraint.
+     * 
+     * @param version The version to test, must not be {@code null}.
+     * @return {@code true} if the specified version satisfies this constraint, {@code false} otherwise.
+     */
+    boolean containsVersion( Version version );
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionRange.java b/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionRange.java
new file mode 100644 (file)
index 0000000..cbc2405
--- /dev/null
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.version;
+
+/**
+ * A range of versions.
+ */
+public interface VersionRange
+{
+
+    /**
+     * Determines whether the specified version is contained within this range.
+     * 
+     * @param version The version to test, must not be {@code null}.
+     * @return {@code true} if this range contains the specified version, {@code false} otherwise.
+     */
+    boolean containsVersion( Version version );
+
+    /**
+     * Gets a lower bound (if any) for this range. If existent, this range does not contain any version smaller than its
+     * lower bound. Note that complex version ranges might exclude some versions even within their bounds.
+     * 
+     * @return A lower bound for this range or {@code null} is there is none.
+     */
+    Bound getLowerBound();
+
+    /**
+     * Gets an upper bound (if any) for this range. If existent, this range does not contain any version greater than
+     * its upper bound. Note that complex version ranges might exclude some versions even within their bounds.
+     * 
+     * @return An upper bound for this range or {@code null} is there is none.
+     */
+    Bound getUpperBound();
+
+    /**
+     * A bound of a version range.
+     */
+    static final class Bound
+    {
+
+        private final Version version;
+
+        private final boolean inclusive;
+
+        /**
+         * Creates a new bound with the specified properties.
+         * 
+         * @param version The bounding version, must not be {@code null}.
+         * @param inclusive A flag whether the specified version is included in the range or not.
+         */
+        public Bound( Version version, boolean inclusive )
+        {
+            if ( version == null )
+            {
+                throw new IllegalArgumentException( "version missing" );
+            }
+            this.version = version;
+            this.inclusive = inclusive;
+        }
+
+        /**
+         * Gets the bounding version.
+         * 
+         * @return The bounding version, never {@code null}.
+         */
+        public Version getVersion()
+        {
+            return version;
+        }
+
+        /**
+         * Indicates whether the bounding version is included in the range or not.
+         * 
+         * @return {@code true} if the bounding version is included in the range, {@code false} if not.
+         */
+        public boolean isInclusive()
+        {
+            return inclusive;
+        }
+
+        @Override
+        public boolean equals( Object obj )
+        {
+            if ( obj == this )
+            {
+                return true;
+            }
+            else if ( obj == null || !getClass().equals( obj.getClass() ) )
+            {
+                return false;
+            }
+
+            Bound that = (Bound) obj;
+            return inclusive == that.inclusive && version.equals( that.version );
+        }
+
+        @Override
+        public int hashCode()
+        {
+            int hash = 17;
+            hash = hash * 31 + version.hashCode();
+            hash = hash * 31 + ( inclusive ? 1 : 0 );
+            return hash;
+        }
+
+        @Override
+        public String toString()
+        {
+            return String.valueOf( version );
+        }
+
+    }
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionScheme.java b/org.argeo.slc.repo/src/org/eclipse/aether/version/VersionScheme.java
new file mode 100644 (file)
index 0000000..c19177a
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.aether.version;
+
+/**
+ * A version scheme that handles interpretation of version strings to facilitate their comparison.
+ */
+public interface VersionScheme
+{
+
+    /**
+     * Parses the specified version string, for example "1.0".
+     * 
+     * @param version The version string to parse, must not be {@code null}.
+     * @return The parsed version, never {@code null}.
+     * @throws InvalidVersionSpecificationException If the string violates the syntax rules of this scheme.
+     */
+    Version parseVersion( String version )
+        throws InvalidVersionSpecificationException;
+
+    /**
+     * Parses the specified version range specification, for example "[1.0,2.0)".
+     * 
+     * @param range The range specification to parse, must not be {@code null}.
+     * @return The parsed version range, never {@code null}.
+     * @throws InvalidVersionSpecificationException If the range specification violates the syntax rules of this scheme.
+     */
+    VersionRange parseVersionRange( String range )
+        throws InvalidVersionSpecificationException;
+
+    /**
+     * Parses the specified version constraint specification, for example "1.0" or "[1.0,2.0),(2.0,)".
+     * 
+     * @param constraint The constraint specification to parse, must not be {@code null}.
+     * @return The parsed version constraint, never {@code null}.
+     * @throws InvalidVersionSpecificationException If the constraint specification violates the syntax rules of this
+     *             scheme.
+     */
+    VersionConstraint parseVersionConstraint( final String constraint )
+        throws InvalidVersionSpecificationException;
+
+}
diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/version/package-info.java b/org.argeo.slc.repo/src/org/eclipse/aether/version/package-info.java
new file mode 100644 (file)
index 0000000..7ef8c85
--- /dev/null
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Sonatype, Inc.
+ * 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:
+ *    Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+/**
+ * The definition of a version scheme for parsing and comparing versions.
+ */
+package org.eclipse.aether.version;
+
diff --git a/org.argeo.slc.runtime/.classpath b/org.argeo.slc.runtime/.classpath
new file mode 100644 (file)
index 0000000..e801ebf
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.argeo.slc.runtime/.gitignore b/org.argeo.slc.runtime/.gitignore
new file mode 100644 (file)
index 0000000..09e3bc9
--- /dev/null
@@ -0,0 +1,2 @@
+/bin/
+/target/
diff --git a/org.argeo.slc.runtime/.project b/org.argeo.slc.runtime/.project
new file mode 100644 (file)
index 0000000..10ad5da
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.runtime</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/org.argeo.slc.runtime/META-INF/.gitignore b/org.argeo.slc.runtime/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/org.argeo.slc.runtime/bnd.bnd b/org.argeo.slc.runtime/bnd.bnd
new file mode 100644 (file)
index 0000000..9384c2a
--- /dev/null
@@ -0,0 +1,2 @@
+Import-Package: org.argeo.slc.deploy,\
+*
\ No newline at end of file
diff --git a/org.argeo.slc.runtime/build.properties b/org.argeo.slc.runtime/build.properties
new file mode 100644 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/org.argeo.slc.runtime/pom.xml b/org.argeo.slc.runtime/pom.xml
new file mode 100644 (file)
index 0000000..0c32839
--- /dev/null
@@ -0,0 +1,19 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.slc</groupId>
+               <artifactId>argeo-slc</artifactId>
+               <version>2.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.runtime</artifactId>
+       <name>SLC Runtime</name>
+       <dependencies>
+               <!-- SLC -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.api</artifactId>
+                       <version>2.3-SNAPSHOT</version>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/AbstractExecutionModulesManager.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/AbstractExecutionModulesManager.java
new file mode 100644 (file)
index 0000000..a31f18c
--- /dev/null
@@ -0,0 +1,147 @@
+package org.argeo.slc.runtime;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.execution.RealizedFlow;
+
+/** Provides the base feature of an execution module manager. */
+public abstract class AbstractExecutionModulesManager implements
+               ExecutionModulesManager {
+       private final static Log log = LogFactory
+                       .getLog(AbstractExecutionModulesManager.class);
+
+       // private List<FilteredNotifier> filteredNotifiers = Collections
+       // .synchronizedList(new ArrayList<FilteredNotifier>());
+
+       protected abstract ExecutionFlow findExecutionFlow(String moduleName,
+                       String moduleVersion, String flowName);
+
+       protected abstract ExecutionContext findExecutionContext(String moduleName,
+                       String moduleVersion);
+
+       protected abstract ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
+                       String moduleName, String moduleVersion);
+
+       public void execute(RealizedFlow realizedFlow) {
+               if (log.isTraceEnabled())
+                       log.trace("Executing " + realizedFlow);
+
+               String moduleName = realizedFlow.getModuleName();
+               String moduleVersion = realizedFlow.getModuleVersion();
+
+               Map<? extends String, ? extends Object> variablesToAdd = getExecutionFlowDescriptorConverter(
+                               moduleName, moduleVersion).convertValues(
+                               realizedFlow.getFlowDescriptor());
+               ExecutionContext executionContext = findExecutionContext(moduleName,
+                               moduleVersion);
+               for (String key : variablesToAdd.keySet())
+                       executionContext.setVariable(key, variablesToAdd.get(key));
+
+               ExecutionFlow flow = findExecutionFlow(moduleName, moduleVersion,
+                               realizedFlow.getFlowDescriptor().getName());
+
+               //
+               // Actually runs the flow, IN THIS THREAD
+               //
+               executionContext.beforeFlow(flow);
+               try {
+                       flow.run();
+               } finally {
+                       executionContext.afterFlow(flow);
+               }
+               //
+               //
+               //
+       }
+
+       // public void dispatchUpdateStatus(ExecutionProcess process,
+       // String oldStatus, String newStatus) {
+       // // filtered notifiers
+       // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+       // .hasNext();) {
+       // FilteredNotifier filteredNotifier = it.next();
+       // if (filteredNotifier.receiveFrom(process))
+       // filteredNotifier.getNotifier().updateStatus(process, oldStatus,
+       // newStatus);
+       // }
+       //
+       // }
+
+       // public void dispatchAddSteps(ExecutionProcess process,
+       // List<ExecutionStep> steps) {
+       // process.addSteps(steps);
+       // for (Iterator<FilteredNotifier> it = filteredNotifiers.iterator(); it
+       // .hasNext();) {
+       // FilteredNotifier filteredNotifier = it.next();
+       // if (filteredNotifier.receiveFrom(process))
+       // filteredNotifier.getNotifier().addSteps(process, steps);
+       // }
+       // }
+
+       // public void registerProcessNotifier(ExecutionProcessNotifier notifier,
+       // Map<String, String> properties) {
+       // filteredNotifiers.add(new FilteredNotifier(notifier, properties));
+       // }
+       //
+       // public void unregisterProcessNotifier(ExecutionProcessNotifier notifier,
+       // Map<String, String> properties) {
+       // filteredNotifiers.remove(notifier);
+       // }
+
+       // protected class FilteredNotifier {
+       // private final ExecutionProcessNotifier notifier;
+       // private final String processId;
+       //
+       // public FilteredNotifier(ExecutionProcessNotifier notifier,
+       // Map<String, String> properties) {
+       // super();
+       // this.notifier = notifier;
+       // if (properties == null)
+       // properties = new HashMap<String, String>();
+       // if (properties.containsKey(SLC_PROCESS_ID))
+       // processId = properties.get(SLC_PROCESS_ID);
+       // else
+       // processId = null;
+       // }
+       //
+       // /**
+       // * Whether event from this process should be received by this listener.
+       // */
+       // public Boolean receiveFrom(ExecutionProcess process) {
+       // if (processId != null)
+       // if (process.getUuid().equals(processId))
+       // return true;
+       // else
+       // return false;
+       // return true;
+       // }
+       //
+       // @Override
+       // public int hashCode() {
+       // return notifier.hashCode();
+       // }
+       //
+       // @Override
+       // public boolean equals(Object obj) {
+       // if (obj instanceof FilteredNotifier) {
+       // FilteredNotifier fn = (FilteredNotifier) obj;
+       // return notifier.equals(fn.notifier);
+       // } else if (obj instanceof ExecutionProcessNotifier) {
+       // ExecutionProcessNotifier epn = (ExecutionProcessNotifier) obj;
+       // return notifier.equals(epn);
+       // } else
+       // return false;
+       // }
+       //
+       // public ExecutionProcessNotifier getNotifier() {
+       // return notifier;
+       // }
+       //
+       // }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgent.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgent.java
new file mode 100644 (file)
index 0000000..6fc255a
--- /dev/null
@@ -0,0 +1,206 @@
+package org.argeo.slc.runtime;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLDecoder;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionModuleDescriptor;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.SlcAgent;
+
+/** Implements the base methods of an SLC agent. */
+public class DefaultAgent implements SlcAgent {
+       // private final static Log log = LogFactory.getLog(DefaultAgent.class);
+       /** UTF-8 charset for encoding. */
+       private final static String UTF8 = "UTF-8";
+
+       private String agentUuid = null;
+       private ExecutionModulesManager modulesManager;
+
+       private ThreadGroup processesThreadGroup;
+       private Map<String, ProcessThread> runningProcesses = Collections
+                       .synchronizedMap(new HashMap<String, ProcessThread>());
+
+       private String defaultModulePrefix = null;
+
+       /*
+        * LIFECYCLE
+        */
+       /** Initialization */
+       public void init() {
+               agentUuid = initAgentUuid();
+               processesThreadGroup = new ThreadGroup("SLC Processes of Agent #"
+                               + agentUuid);
+       }
+
+       /** Clean up (needs to be called by overriding method) */
+       public void destroy() {
+       }
+
+       /**
+        * Called during initialization in order to determines the agent UUID. To be
+        * overridden. By default creates a new one per instance.
+        */
+       protected String initAgentUuid() {
+               return UUID.randomUUID().toString();
+       }
+
+       /*
+        * SLC AGENT
+        */
+       public void process(ExecutionProcess process) {
+               ProcessThread processThread = createProcessThread(processesThreadGroup,
+                               modulesManager, process);
+               processThread.start();
+               runningProcesses.put(process.getUuid(), processThread);
+
+               // clean up old processes
+               Iterator<ProcessThread> it = runningProcesses.values().iterator();
+               while (it.hasNext()) {
+                       ProcessThread pThread = it.next();
+                       if (!pThread.isAlive())
+                               it.remove();
+               }
+       }
+
+       public String process(List<URI> uris) {
+               DefaultProcess process = new DefaultProcess();
+               for (URI uri : uris) {
+                       String[] path = uri.getPath().split("/");
+                       if (path.length < 3)
+                               throw new SlcException("Badly formatted URI: " + uri);
+                       NameVersion nameVersion = new DefaultNameVersion(path[1]);
+                       StringBuilder flow = new StringBuilder();
+                       for (int i = 2; i < path.length; i++)
+                               flow.append('/').append(path[i]);
+
+                       Map<String, Object> values = getQueryMap(uri.getQuery());
+                       // Get execution module descriptor
+                       ExecutionModuleDescriptor emd = getExecutionModuleDescriptor(
+                                       nameVersion.getName(), nameVersion.getVersion());
+                       process.getRealizedFlows().add(
+                                       emd.asRealizedFlow(flow.toString(), values));
+               }
+               process(process);
+               return process.getUuid();
+       }
+
+       public void kill(String processUuid) {
+               if (runningProcesses.containsKey(processUuid)) {
+                       runningProcesses.get(processUuid).interrupt();
+               } else {
+                       // assume is finished
+               }
+       }
+
+       public void waitFor(String processUuid, Long millis) {
+               if (runningProcesses.containsKey(processUuid)) {
+                       try {
+                               if (millis != null)
+                                       runningProcesses.get(processUuid).join(millis);
+                               else
+                                       runningProcesses.get(processUuid).join();
+                       } catch (InterruptedException e) {
+                               // silent
+                       }
+               } else {
+                       // assume is finished
+               }
+       }
+
+       /** Creates the thread which will coordinate the execution for this agent. */
+       protected ProcessThread createProcessThread(
+                       ThreadGroup processesThreadGroup,
+                       ExecutionModulesManager modulesManager, ExecutionProcess process) {
+               ProcessThread processThread = new ProcessThread(processesThreadGroup,
+                               modulesManager, process);
+               return processThread;
+       }
+
+       public ExecutionModuleDescriptor getExecutionModuleDescriptor(
+                       String moduleName, String moduleVersion) {
+               // Get execution module descriptor
+               ExecutionModuleDescriptor emd;
+               try {
+                       modulesManager
+                                       .start(new DefaultNameVersion(moduleName, moduleVersion));
+                       emd = modulesManager.getExecutionModuleDescriptor(moduleName,
+                                       moduleVersion);
+               } catch (SlcException e) {
+                       if (defaultModulePrefix != null) {
+                               moduleName = defaultModulePrefix + "." + moduleName;
+                               modulesManager.start(new DefaultNameVersion(moduleName,
+                                               moduleVersion));
+                               emd = modulesManager.getExecutionModuleDescriptor(moduleName,
+                                               moduleVersion);
+                       } else
+                               throw e;
+               }
+               return emd;
+       }
+
+       public List<ExecutionModuleDescriptor> listExecutionModuleDescriptors() {
+               return modulesManager.listExecutionModules();
+       }
+
+       public boolean ping() {
+               return true;
+       }
+
+       /*
+        * UTILITIES
+        */
+       /**
+        * @param query
+        *            can be null
+        */
+       static Map<String, Object> getQueryMap(String query) {
+               Map<String, Object> map = new LinkedHashMap<String, Object>();
+               if (query == null)
+                       return map;
+               String[] params = query.split("&");
+               for (String param : params) {
+                       String[] arr = param.split("=");
+                       String name = arr[0];
+                       Object value = arr.length > 1 ? param.split("=")[1] : Boolean.TRUE;
+                       try {
+                               map.put(URLDecoder.decode(name, UTF8),
+                                               URLDecoder.decode(value.toString(), UTF8));
+                       } catch (UnsupportedEncodingException e) {
+                               throw new SlcException("Cannot decode '" + param + "'", e);
+                       }
+               }
+               return map;
+       }
+
+       /*
+        * BEAN
+        */
+       public void setModulesManager(ExecutionModulesManager modulesManager) {
+               this.modulesManager = modulesManager;
+       }
+
+       public void setDefaultModulePrefix(String defaultModulePrefix) {
+               this.defaultModulePrefix = defaultModulePrefix;
+       }
+
+       public String getAgentUuid() {
+               return agentUuid;
+       }
+
+       @Override
+       public String toString() {
+               return "Agent #" + getAgentUuid();
+       }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgentCli.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultAgentCli.java
new file mode 100644 (file)
index 0000000..2e6d7f1
--- /dev/null
@@ -0,0 +1,238 @@
+package org.argeo.slc.runtime;
+
+import java.net.URI;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionModuleDescriptor;
+import org.argeo.slc.execution.ExecutionSpec;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.SlcAgent;
+import org.argeo.slc.execution.SlcAgentCli;
+
+/**
+ * Authenticates thread and executes synchronously a command line execution.
+ * Reference implementation of args to URIs algorithm.
+ */
+public class DefaultAgentCli implements SlcAgentCli {
+       private final static Log log = LogFactory.getLog(DefaultAgentCli.class);
+
+       private final static String UTF8 = "UTF-8";
+       private SlcAgent agent;
+//     private AuthenticationManager authenticationManager;
+
+       private Long timeout = 24 * 60 * 60 * 1000l;
+
+       public String process(String[] args) {
+//             if (SecurityContextHolder.getContext().getAuthentication() == null) {
+//                     OsAuthenticationToken oat = new OsAuthenticationToken();
+//                     Authentication authentication = authenticationManager
+//                                     .authenticate(oat);
+//                     SecurityContextHolder.getContext()
+//                                     .setAuthentication(authentication);
+//             }
+
+               if (args.length > 0 && args[0].equals("help")) {
+                       StringBuilder buf = new StringBuilder();
+                       help(args, buf);
+                       log.info("\n" + buf);
+                       return buf.toString();
+               } else {
+                       List<URI> uris = asURIs(args);
+                       String processUuid = agent.process(uris);
+                       agent.waitFor(processUuid, timeout);
+                       return processUuid;
+               }
+       }
+
+       protected void help(String[] rawArgs, StringBuilder buf) {
+               String[] args = Arrays.copyOfRange(rawArgs, 1, rawArgs.length);
+               if (args.length == 0) {// modules
+                       for (ExecutionModuleDescriptor emd : agent
+                                       .listExecutionModuleDescriptors()) {
+                               appendModule(emd, buf);
+                       }
+               } else if (args.length == 1 && !args[0].contains("/")) {// single module
+                       NameVersion nameVersion = new DefaultNameVersion(args[0]);
+                       ExecutionModuleDescriptor emd = agent.getExecutionModuleDescriptor(
+                                       nameVersion.getName(), nameVersion.getVersion());
+                       appendModule(emd, buf);
+
+                       // flows
+                       for (ExecutionFlowDescriptor efd : emd.getExecutionFlows()) {
+                               buf.append(" ").append(efd.getName());
+                               if (efd.getDescription() != null
+                                               && !efd.getDescription().trim().equals(""))
+                                       buf.append(" : ").append(" ").append(efd.getDescription());
+                               buf.append('\n');
+                       }
+                       return;
+               } else {
+                       List<URI> uris = asURIs(args);
+                       for (URI uri : uris) {
+                               appendUriHelp(uri, buf);
+                       }
+               }
+       }
+
+       protected void appendUriHelp(URI uri, StringBuilder buf) {
+               String[] path = uri.getPath().split("/");
+               NameVersion nameVersion = new DefaultNameVersion(path[1]);
+               ExecutionModuleDescriptor emd = agent.getExecutionModuleDescriptor(
+                               nameVersion.getName(), nameVersion.getVersion());
+
+               StringBuilder flow = new StringBuilder();
+               for (int i = 2; i < path.length; i++)
+                       flow.append('/').append(path[i]);
+               String flowPath = flow.toString();
+               ExecutionFlowDescriptor efd = findExecutionFlowDescriptor(emd, flowPath);
+               if (efd == null)
+                       throw new SlcException("Flow " + uri + " not found");
+
+               appendModule(emd, buf);
+
+               buf.append(" ").append(efd.getName());
+               if (efd.getDescription() != null
+                               && !efd.getDescription().trim().equals(""))
+                       buf.append(" : ").append(" ").append(efd.getDescription());
+               buf.append('\n');
+               Map<String, Object> values = DefaultAgent.getQueryMap(uri.getQuery());
+               ExecutionSpec spec = efd.getExecutionSpec();
+               for (String attrKey : spec.getAttributes().keySet()) {
+                       ExecutionSpecAttribute esa = spec.getAttributes().get(attrKey);
+                       buf.append("  --").append(attrKey);
+                       if (values.containsKey(attrKey))
+                               buf.append(" ").append(values.get(attrKey));
+                       if (esa.getValue() != null)
+                               buf.append(" (").append(esa.getValue()).append(')');
+                       buf.append('\n');
+               }
+       }
+
+       private void appendModule(ExecutionModuleDescriptor emd, StringBuilder buf) {
+               buf.append("# ").append(emd.getName());
+               if (emd.getDescription() != null
+                               && !emd.getDescription().trim().equals(""))
+                       buf.append(" : ").append(emd.getDescription());
+               if (emd.getVersion() != null)
+                       buf.append(" (v").append(emd.getVersion()).append(")");
+               buf.append('\n');
+       }
+
+       public static List<URI> asURIs(String[] args) {
+               try {
+                       List<URI> uris = new ArrayList<URI>();
+                       List<String> leftOvers = new ArrayList<String>();
+
+                       Boolean hasArgs = false;
+                       String currKey = null;
+                       StringBuilder currUri = null;
+                       Iterator<String> argIt = Arrays.asList(args).iterator();
+                       while (argIt.hasNext()) {
+                               String arg = argIt.next();
+                               if (!arg.startsWith("-")) {
+                                       if (currKey != null) {// value
+                                               currUri.append(URLEncoder.encode(arg, UTF8));
+                                               currKey = null;
+                                       } else { // module
+                                               if (currUri != null) {
+                                                       uris.add(new URI(currUri.toString()));
+                                               }
+                                               currUri = new StringBuilder("flow:");
+
+                                               String currModule = arg;
+                                               currUri.append('/').append(currModule);
+                                               if (!arg.contains("/")) {
+                                                       // flow path not in arg go to next arg
+                                                       if (!argIt.hasNext())
+                                                               throw new SlcException("No flow found");
+                                                       String currFlow = argIt.next();
+                                                       if (!currFlow.startsWith("/"))
+                                                               currFlow = "/" + currFlow;
+                                                       currUri.append(currFlow);
+                                               }
+                                       }
+                               } else {
+                                       if (currUri == null) {// first args
+                                               leftOvers.add(arg);
+                                       } else {
+                                               String key;
+                                               if (arg.startsWith("--"))
+                                                       key = arg.substring(2);
+                                               else if (arg.startsWith("-"))
+                                                       key = arg.substring(1);
+                                               else {
+                                                       throw new SlcException("Cannot intepret key: "
+                                                                       + arg);
+                                               }
+
+                                               if (!hasArgs) {
+                                                       currUri.append('?');
+                                                       hasArgs = true;
+                                               } else {
+                                                       currUri.append('&');
+                                               }
+
+                                               // deal with boolean keys
+                                               if (currKey != null) {// value
+                                                       currUri.append(URLEncoder.encode("true", UTF8));
+                                                       currKey = null;
+                                               }
+
+                                               currKey = key;
+                                               currUri.append(URLEncoder.encode(key, UTF8))
+                                                               .append('=');
+                                       }
+                               }
+                       }
+                       if (currUri != null)
+                               uris.add(new URI(currUri.toString()));
+                       return uris;
+               } catch (Exception e) {
+                       throw new SlcException("Cannot convert " + Arrays.toString(args)
+                                       + " to flow URI", e);
+               }
+       }
+
+       private ExecutionFlowDescriptor findExecutionFlowDescriptor(
+                       ExecutionModuleDescriptor emd, String flowPath) {
+               ExecutionFlowDescriptor flowDescriptor = null;
+               for (ExecutionFlowDescriptor efd : emd.getExecutionFlows()) {
+                       String name = efd.getName();
+                       // normalize name as flow path
+                       if (!name.startsWith("/"))
+                               name = "/" + name;
+                       if (name.endsWith("/"))
+                               name = name.substring(0, name.length() - 1);
+                       if (name.equals(flowPath)) {
+                               flowDescriptor = efd;
+                               break;
+                       }
+               }
+               return flowDescriptor;
+       }
+
+       public void setAgent(SlcAgent agent) {
+               this.agent = agent;
+       }
+
+//     public void setAuthenticationManager(
+//                     AuthenticationManager authenticationManager) {
+//             this.authenticationManager = authenticationManager;
+//     }
+
+       public void setTimeout(Long timeout) {
+               this.timeout = timeout;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionFlow.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionFlow.java
new file mode 100644 (file)
index 0000000..f99ce9d
--- /dev/null
@@ -0,0 +1,245 @@
+package org.argeo.slc.runtime;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionSpec;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+
+/** Default implementation of an execution flow. */
+public class DefaultExecutionFlow implements ExecutionFlow {
+       private final static Log log = LogFactory.getLog(DefaultExecutionFlow.class);
+
+       private final ExecutionSpec executionSpec;
+       private String name = null;
+       private Map<String, Object> parameters = new HashMap<String, Object>();
+       private List<Runnable> executables = new ArrayList<Runnable>();
+
+       private String path;
+
+       private Boolean failOnError = true;
+
+       // Only needed if stacked execution flows are used
+       private ExecutionContext executionContext = null;
+
+       public DefaultExecutionFlow() {
+               this.executionSpec = new DefaultExecutionSpec();
+       }
+
+       public DefaultExecutionFlow(ExecutionSpec executionSpec) {
+               this.executionSpec = executionSpec;
+       }
+
+       public DefaultExecutionFlow(ExecutionSpec executionSpec, Map<String, Object> parameters) {
+               // be sure to have an execution spec
+               this.executionSpec = (executionSpec == null) ? new DefaultExecutionSpec() : executionSpec;
+
+               // only parameters contained in the executionSpec can be set
+               for (String parameter : parameters.keySet()) {
+                       if (!executionSpec.getAttributes().containsKey(parameter)) {
+                               throw new SlcException("Parameter " + parameter + " is not defined in the ExecutionSpec");
+                       }
+               }
+
+               // set the parameters
+               this.parameters.putAll(parameters);
+
+               // check that all the required parameters are defined
+//             MapBindingResult errors = new MapBindingResult(parameters, "execution#"
+//                             + getName());
+               Map<String, String> errors = new HashMap<>();
+               for (String key : executionSpec.getAttributes().keySet()) {
+                       ExecutionSpecAttribute attr = executionSpec.getAttributes().get(key);
+
+                       if (attr.getIsImmutable() && !isSetAsParameter(key)) {
+                               errors.put(key, "Immutable but not set");
+                               break;
+                       }
+
+                       if (attr.getIsConstant() && !isSetAsParameter(key)) {
+                               errors.put(key, "Constant but not set as parameter");
+                               break;
+                       }
+
+                       if (attr.getIsHidden() && !isSetAsParameter(key)) {
+                               errors.put(key, "Hidden but not set as parameter");
+                               break;
+                       }
+               }
+
+               if (!errors.isEmpty())
+                       throw new SlcException("Could not prepare execution flow: " + errors.toString());
+
+       }
+
+       public void run() {
+               try {
+                       for (Runnable executable : executables) {
+                               if (Thread.interrupted()) {
+                                       log.error("Flow '" + getName() + "' killed before '" + executable + "'");
+                                       Thread.currentThread().interrupt();
+                                       return;
+                                       // throw new ThreadDeath();
+                               }
+                               this.doExecuteRunnable(executable);
+                       }
+               } catch (RuntimeException e) {
+                       if (Thread.interrupted()) {
+                               log.error("Flow '" + getName() + "' killed while receiving an unrelated exception", e);
+                               Thread.currentThread().interrupt();
+                               return;
+                               // throw new ThreadDeath();
+                       }
+                       if (failOnError)
+                               throw e;
+                       else {
+                               log.error("Execution flow failed," + " but process did not fail" + " because failOnError property"
+                                               + " is set to false: " + e);
+                               if (log.isTraceEnabled())
+                                       e.printStackTrace();
+                       }
+               }
+       }
+
+       /**
+        * List sub-runnables that would be executed if run() method would be called.
+        */
+       public Iterator<Runnable> runnables() {
+               return executables.iterator();
+       }
+
+       /**
+        * If there is one and only one runnable wrapped return it, throw an exeception
+        * otherwise.
+        */
+       public Runnable getRunnable() {
+               if (executables.size() == 1)
+                       return executables.get(0);
+               else
+                       throw new SlcException("There are " + executables.size() + " runnables in flow " + getName());
+       }
+
+       public void doExecuteRunnable(Runnable runnable) {
+               try {
+                       if (executionContext != null)
+                               if (runnable instanceof ExecutionFlow)
+                                       executionContext.beforeFlow((ExecutionFlow) runnable);
+                       runnable.run();
+               } finally {
+                       if (executionContext != null)
+                               if (runnable instanceof ExecutionFlow)
+                                       executionContext.afterFlow((ExecutionFlow) runnable);
+               }
+       }
+
+       public void init() throws Exception {
+               if (path == null) {
+                       if (name.charAt(0) == '/') {
+                               path = name.substring(0, name.lastIndexOf('/'));
+                       }
+               }
+
+               if (path != null) {
+                       for (Runnable executable : executables) {
+                               if (executable instanceof DefaultExecutionFlow) {
+                                       // so we don't need to have DefaultExecutionFlow
+                                       // implementing StructureAware
+                                       // FIXME: probably has side effects
+                                       DefaultExecutionFlow flow = (DefaultExecutionFlow) executable;
+                                       String newPath = path + '/' + flow.getName();
+                                       flow.setPath(newPath);
+                                       log.warn(newPath + " was forcibly set on " + flow);
+                               }
+                       }
+               }
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public void setExecutables(List<Runnable> executables) {
+               this.executables = executables;
+       }
+
+       public void setParameters(Map<String, Object> attributes) {
+               this.parameters = attributes;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public ExecutionSpec getExecutionSpec() {
+               return executionSpec;
+       }
+
+       public Object getParameter(String parameterName) {
+               // Verify that there is a spec attribute
+               ExecutionSpecAttribute specAttr = null;
+               if (executionSpec.getAttributes().containsKey(parameterName)) {
+                       specAttr = executionSpec.getAttributes().get(parameterName);
+               } else {
+                       throw new SlcException("Key " + parameterName + " is not defined in the specifications of " + toString());
+               }
+
+               if (parameters.containsKey(parameterName)) {
+                       Object paramValue = parameters.get(parameterName);
+                       return paramValue;
+               } else {
+                       if (specAttr.getValue() != null) {
+                               return specAttr.getValue();
+                       }
+               }
+               throw new SlcException("Key " + parameterName + " is not set as parameter in " + toString());
+       }
+
+       public Boolean isSetAsParameter(String key) {
+               return parameters.containsKey(key) || (executionSpec.getAttributes().containsKey(key)
+                               && executionSpec.getAttributes().get(key).getValue() != null);
+       }
+
+       @Override
+       public String toString() {
+               return new StringBuffer("Execution flow ").append(name).toString();
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               return ((ExecutionFlow) obj).getName().equals(name);
+       }
+
+       @Override
+       public int hashCode() {
+               return name.hashCode();
+       }
+
+       public String getPath() {
+               return path;
+       }
+
+       public void setPath(String path) {
+               this.path = path;
+       }
+
+       public Boolean getFailOnError() {
+               return failOnError;
+       }
+
+       public void setFailOnError(Boolean failOnError) {
+               this.failOnError = failOnError;
+       }
+
+       public void setExecutionContext(ExecutionContext executionContext) {
+               this.executionContext = executionContext;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionSpec.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionSpec.java
new file mode 100644 (file)
index 0000000..16790a4
--- /dev/null
@@ -0,0 +1,67 @@
+package org.argeo.slc.runtime;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.argeo.slc.execution.ExecutionSpec;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.execution.RefValueChoice;
+
+/** Spring based implementation of execution specifications. */
+public class DefaultExecutionSpec implements ExecutionSpec, Serializable {
+       private static final long serialVersionUID = 7042162759380893595L;
+       private String description;
+       private Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
+
+       private String name = INTERNAL_NAME;
+
+       public Map<String, ExecutionSpecAttribute> getAttributes() {
+               return attributes;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       public void setAttributes(Map<String, ExecutionSpecAttribute> attributes) {
+               this.attributes = attributes;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       /**
+        * The Spring bean name (only relevant for specs declared has high-level beans)
+        */
+       public String getName() {
+               return name;
+       }
+
+       public boolean equals(Object obj) {
+               return ((ExecutionSpec) obj).getName().equals(name);
+       }
+
+       /**
+        * The Spring bean description (only relevant for specs declared has high-level
+        * beans)
+        */
+       public String getDescription() {
+               return description;
+       }
+
+       /**
+        * Generates a list of ref value choices based on the bean available in the
+        * application ocntext.
+        */
+       protected List<RefValueChoice> buildRefValueChoices(RefSpecAttribute rsa) {
+               List<RefValueChoice> choices = new ArrayList<RefValueChoice>();
+               // FIXME implement something
+               return choices;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionStack.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultExecutionStack.java
new file mode 100644 (file)
index 0000000..af98a16
--- /dev/null
@@ -0,0 +1,129 @@
+package org.argeo.slc.runtime;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+import java.util.UUID;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.ExecutionStack;
+
+/** Canonical implementation of an execution stack. */
+public class DefaultExecutionStack implements ExecutionStack {
+
+       private final static Log log = LogFactory
+                       .getLog(DefaultExecutionStack.class);
+
+       private final Stack<ExecutionFlowRuntime> stack = new Stack<ExecutionFlowRuntime>();
+
+       public synchronized void enterFlow(ExecutionFlow executionFlow) {
+               ExecutionFlowRuntime runtime = new ExecutionFlowRuntime(executionFlow);
+               stack.push(runtime);
+
+               Map<String, ExecutionSpecAttribute> specAttrs = executionFlow
+                               .getExecutionSpec().getAttributes();
+               for (String key : specAttrs.keySet()) {
+                       if (executionFlow.isSetAsParameter(key)) {
+                               runtime.getLocalVariables().put(key,
+                                               executionFlow.getParameter(key));
+                       }
+               }
+       }
+
+       public synchronized String getCurrentStackLevelUuid() {
+               return stack.peek().getUuid();
+       }
+
+       public synchronized Integer getStackSize() {
+               return stack.size();
+       }
+
+       /**
+        * Looks for a set variable in the stack, starting at the upper flows
+        * 
+        * @return the variable or <code>null</code> if not found
+        */
+       public synchronized Object findLocalVariable(String key) {
+               Object obj = null;
+               for (int i = 0; i < stack.size(); i++) {
+                       if (stack.get(i).getLocalVariables().containsKey(key)) {
+                               obj = stack.get(i).getLocalVariables().get(key);
+                               break;
+                       }
+               }
+               return obj;
+       }
+
+       public synchronized void leaveFlow(ExecutionFlow executionFlow) {
+               ExecutionFlowRuntime leftEf = stack.pop();
+
+               if (!leftEf.getExecutionFlow().getName()
+                               .equals(executionFlow.getName()))
+                       throw new SlcException("Asked to leave " + executionFlow
+                                       + " but last is " + leftEf);
+
+               leftEf.getScopedObjects().clear();
+               leftEf.getLocalVariables().clear();
+       }
+
+       public synchronized void addScopedObject(String name, Object obj) {
+               ExecutionFlowRuntime runtime = stack.peek();
+               // TODO: check that the object is not set yet ?
+               if (log.isDebugEnabled()) {
+                       Object existing = findScopedObject(name);
+                       if (existing != null)
+                               log.warn("Scoped object " + name + " of type " + obj.getClass()
+                                               + " already registered in " + runtime);
+               }
+               runtime.getScopedObjects().put(name, obj);
+       }
+
+       /** @return </code>null<code> if not found */
+       public synchronized Object findScopedObject(String name) {
+               Object obj = null;
+               for (int i = stack.size() - 1; i >= 0; i--) {
+                       if (stack.get(i).getScopedObjects().containsKey(name)) {
+                               obj = stack.get(i).getScopedObjects().get(name);
+                               break;
+                       }
+               }
+               return obj;
+       }
+
+       protected static class ExecutionFlowRuntime {
+               private final ExecutionFlow executionFlow;
+               private final Map<String, Object> scopedObjects = new HashMap<String, Object>();
+               private final Map<String, Object> localVariables = new HashMap<String, Object>();
+               private final String uuid = UUID.randomUUID().toString();
+
+               public ExecutionFlowRuntime(ExecutionFlow executionFlow) {
+                       this.executionFlow = executionFlow;
+               }
+
+               public ExecutionFlow getExecutionFlow() {
+                       return executionFlow;
+               }
+
+               public Map<String, Object> getScopedObjects() {
+                       return scopedObjects;
+               }
+
+               public String getUuid() {
+                       return uuid;
+               }
+
+               public Map<String, Object> getLocalVariables() {
+                       return localVariables;
+               }
+
+               @Override
+               public String toString() {
+                       return "Stack Level #" + uuid;
+               }
+
+       }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultProcess.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/DefaultProcess.java
new file mode 100644 (file)
index 0000000..9e98685
--- /dev/null
@@ -0,0 +1,55 @@
+package org.argeo.slc.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.ExecutionStep;
+import org.argeo.slc.execution.RealizedFlow;
+
+/** Canonical implementation of an {@link ExecutionProcess} as a bean. */
+public class DefaultProcess implements ExecutionProcess {
+       private String uuid = UUID.randomUUID().toString();
+       private String status = ExecutionProcess.NEW;
+
+       private List<ExecutionStep> steps = new ArrayList<ExecutionStep>();
+       private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();
+
+       public String getUuid() {
+               return uuid;
+       }
+
+       public String getStatus() {
+               return status;
+       }
+
+       public void setStatus(String status) {
+               this.status = status;
+       }
+
+       public void addSteps(List<ExecutionStep> steps) {
+               steps.addAll(steps);
+       }
+
+       public List<RealizedFlow> getRealizedFlows() {
+               return realizedFlows;
+       }
+
+       public List<ExecutionStep> getSteps() {
+               return steps;
+       }
+
+       public void setSteps(List<ExecutionStep> steps) {
+               this.steps = steps;
+       }
+
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+
+       public void setRealizedFlows(List<RealizedFlow> realizedFlows) {
+               this.realizedFlows = realizedFlows;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ExecutionThread.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ExecutionThread.java
new file mode 100644 (file)
index 0000000..d940905
--- /dev/null
@@ -0,0 +1,116 @@
+package org.argeo.slc.runtime;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.execution.ExecutionFlowDescriptor;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.execution.ExecutionStep;
+import org.argeo.slc.execution.FlowConfigurationException;
+import org.argeo.slc.execution.RealizedFlow;
+
+/** Thread of a single execution */
+public class ExecutionThread extends Thread {
+       public final static String SYSPROP_EXECUTION_AUTO_UPGRADE = "slc.execution.autoupgrade";
+       private final static Log log = LogFactory.getLog(ExecutionThread.class);
+
+       private ExecutionModulesManager executionModulesManager;
+       private final RealizedFlow realizedFlow;
+       private final AccessControlContext accessControlContext;
+
+       private List<Runnable> destructionCallbacks = new ArrayList<Runnable>();
+
+       public ExecutionThread(ProcessThreadGroup processThreadGroup, ExecutionModulesManager executionModulesManager,
+                       RealizedFlow realizedFlow) {
+               super(processThreadGroup, "Flow " + realizedFlow.getFlowDescriptor().getName());
+               this.realizedFlow = realizedFlow;
+               this.executionModulesManager = executionModulesManager;
+               accessControlContext = AccessController.getContext();
+       }
+
+       public void run() {
+               // authenticate thread
+               // Authentication authentication = getProcessThreadGroup()
+               // .getAuthentication();
+               // if (authentication == null)
+               // throw new SlcException("Can only execute authenticated threads");
+               // SecurityContextHolder.getContext().setAuthentication(authentication);
+
+               // Retrieve execution flow descriptor
+               ExecutionFlowDescriptor executionFlowDescriptor = realizedFlow.getFlowDescriptor();
+               String flowName = executionFlowDescriptor.getName();
+
+               getProcessThreadGroup().dispatchAddStep(
+                               new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.PHASE_START, "Flow " + flowName));
+
+               try {
+                       Subject subject = Subject.getSubject(accessControlContext);
+                       try {
+                               Subject.doAs(subject, new PrivilegedExceptionAction<Void>() {
+
+                                       @Override
+                                       public Void run() throws Exception {
+                                               String autoUpgrade = System.getProperty(SYSPROP_EXECUTION_AUTO_UPGRADE);
+                                               if (autoUpgrade != null && autoUpgrade.equals("true"))
+                                                       executionModulesManager.upgrade(realizedFlow.getModuleNameVersion());
+                                               executionModulesManager.start(realizedFlow.getModuleNameVersion());
+                                               //
+                                               // START FLOW
+                                               //
+                                               executionModulesManager.execute(realizedFlow);
+                                               // END FLOW
+                                               return null;
+                                       }
+
+                               });
+                       } catch (PrivilegedActionException privilegedActionException) {
+                               throw (Exception) privilegedActionException.getCause();
+                       }
+               } catch (FlowConfigurationException e) {
+                       String msg = "Configuration problem with flow " + flowName + ":\n" + e.getMessage();
+                       log.error(msg);
+                       getProcessThreadGroup().dispatchAddStep(
+                                       new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.ERROR, msg + " " + e.getMessage()));
+               } catch (Exception e) {
+                       // TODO: re-throw exception ?
+                       String msg = "Execution of flow " + flowName + " failed.";
+                       log.error(msg, e);
+                       getProcessThreadGroup().dispatchAddStep(
+                                       new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.ERROR, msg + " " + e.getMessage()));
+               } finally {
+                       getProcessThreadGroup().dispatchAddStep(
+                                       new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.PHASE_END, "Flow " + flowName));
+                       processDestructionCallbacks();
+               }
+       }
+
+       private synchronized void processDestructionCallbacks() {
+               for (int i = destructionCallbacks.size() - 1; i >= 0; i--) {
+                       try {
+                               destructionCallbacks.get(i).run();
+                       } catch (Exception e) {
+                               log.warn("Could not process destruction callback " + i + " in thread " + getName(), e);
+                       }
+               }
+       }
+
+       /**
+        * Gather object destruction callback to be called in reverse order at the
+        * end of the thread
+        */
+       public synchronized void registerDestructionCallback(String name, Runnable callback) {
+               destructionCallbacks.add(callback);
+       }
+
+       protected ProcessThreadGroup getProcessThreadGroup() {
+               return (ProcessThreadGroup) getThreadGroup();
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/InstantiationManager.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/InstantiationManager.java
new file mode 100644 (file)
index 0000000..4aea94f
--- /dev/null
@@ -0,0 +1,108 @@
+package org.argeo.slc.runtime;
+
+import java.util.Stack;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionSpecAttribute;
+import org.argeo.slc.execution.RefSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveSpecAttribute;
+import org.argeo.slc.primitive.PrimitiveUtils;
+
+/** Manage parameters that need to be set during the instantiation of a flow */
+public class InstantiationManager {
+
+       private final static Log log = LogFactory
+                       .getLog(InstantiationManager.class);
+
+       private ThreadLocal<Stack<ExecutionFlow>> flowStack = new ThreadLocal<Stack<ExecutionFlow>>();
+
+       public Object createRef(String name) {
+
+               if ((flowStack.get() == null) || flowStack.get().empty()) {
+                       throw new SlcException("No flow is currently initializing."
+                                       + " Declare ParameterRef as inner beans or prototypes.");
+               }
+
+               return getInitializingFlowParameter(name);
+       }
+
+       public void flowInitializationStarted(ExecutionFlow flow, String flowName) {
+               // set the flow name if it is DefaultExecutionFlow
+               if (flow instanceof DefaultExecutionFlow) {
+                       ((DefaultExecutionFlow) flow).setName(flowName);
+               }
+
+               if (log.isTraceEnabled())
+                       log.trace("Start initialization of " + flow.hashCode() + " ("
+                                       + flow + " - " + flow.getClass() + ")");
+
+               // log.info("# flowInitializationStarted " + flowName);
+               // create a stack for this thread if there is none
+               if (flowStack.get() == null) {
+                       flowStack.set(new Stack<ExecutionFlow>());
+               }
+               flowStack.get().push(flow);
+       }
+
+       public void flowInitializationFinished(ExecutionFlow flow, String flowName) {
+               if (log.isTraceEnabled())
+                       log.trace("Finish initialization of " + flow.hashCode() + " ("
+                                       + flow + " - " + flow.getClass() + ")");
+
+               if (flowStack.get() != null) {
+                       ExecutionFlow registeredFlow = flowStack.get().pop();
+                       if (registeredFlow != null) {
+                               if (!flow.getName().equals(registeredFlow.getName()))
+                                       throw new SlcException("Current flow is " + flow);
+                               // log.info("# flowInitializationFinished " + flowName);
+                               // initializingFlow.set(null);
+                       }
+               } else {
+                       // happens for flows imported as services
+                       log.warn("flowInitializationFinished - Flow Stack is null");
+               }
+       }
+
+       protected ExecutionFlow findInitializingFlowWithParameter(String key) {
+               if ((flowStack.get() == null) || flowStack.get().empty())
+                       throw new SlcException("No initializing flow available.");
+
+               // first look in the outer flow (that may override parameters)
+               for (int i = 0; i < flowStack.get().size(); i++) {
+                       if (flowStack.get().elementAt(i).isSetAsParameter(key)) {
+                               return flowStack.get().elementAt(i);
+                       }
+               }
+               throw new SlcException("Key " + key + " is not set as parameter in "
+                               + flowStack.get().firstElement().toString() + " (stack size="
+                               + flowStack.get().size() + ")");
+
+       }
+
+       public Object getInitializingFlowParameter(String key) {
+               return findInitializingFlowWithParameter(key).getParameter(key);
+       }
+
+       public Class<?> getInitializingFlowParameterClass(String key) {
+               ExecutionSpecAttribute attr = findInitializingFlowWithParameter(key)
+                               .getExecutionSpec().getAttributes().get(key);
+               if (attr instanceof RefSpecAttribute)
+                       return ((RefSpecAttribute) attr).getTargetClass();
+               else if (attr instanceof PrimitiveSpecAttribute) {
+                       String type = ((PrimitiveSpecAttribute) attr).getType();
+                       Class<?> clss = PrimitiveUtils.typeAsClass(type);
+                       if (clss == null)
+                               throw new SlcException("Cannot convert type " + type
+                                               + " to class.");
+                       return clss;
+               } else
+                       return null;
+       }
+
+       public Boolean isInFlowInitialization() {
+               return (flowStack.get() != null) && !flowStack.get().empty();
+       }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThread.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThread.java
new file mode 100644 (file)
index 0000000..2c4f73c
--- /dev/null
@@ -0,0 +1,215 @@
+package org.argeo.slc.runtime;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.ExecutionStep;
+import org.argeo.slc.execution.RealizedFlow;
+
+/**
+ * Main thread coordinating an {@link ExecutionProcess}, launching parallel or
+ * sequential {@link ExecutionThread}s.
+ */
+public class ProcessThread extends Thread {
+       private final static Log log = LogFactory.getLog(ProcessThread.class);
+
+       private final ExecutionModulesManager executionModulesManager;
+       private final ExecutionProcess process;
+       private final ProcessThreadGroup processThreadGroup;
+
+       private Set<ExecutionThread> executionThreads = Collections.synchronizedSet(new HashSet<ExecutionThread>());
+
+       // private Boolean hadAnError = false;
+       private Boolean killed = false;
+
+       private final AccessControlContext accessControlContext;
+
+       public ProcessThread(ThreadGroup processesThreadGroup, ExecutionModulesManager executionModulesManager,
+                       ExecutionProcess process) {
+               super(processesThreadGroup, "SLC Process #" + process.getUuid());
+               this.executionModulesManager = executionModulesManager;
+               this.process = process;
+               processThreadGroup = new ProcessThreadGroup(process);
+               accessControlContext = AccessController.getContext();
+       }
+
+       public final void run() {
+               // authenticate thread
+               // Authentication authentication = getProcessThreadGroup()
+               // .getAuthentication();
+               // if (authentication == null)
+               // throw new SlcException("Can only execute authenticated threads");
+               // SecurityContextHolder.getContext().setAuthentication(authentication);
+
+               log.info("\n##\n## SLC Process #" + process.getUuid() + " STARTED\n##\n");
+
+               // Start logging
+               new LoggingThread().start();
+
+               process.setStatus(ExecutionProcess.RUNNING);
+               try {
+                       Subject subject = Subject.getSubject(accessControlContext);
+                       try {
+                               Subject.doAs(subject, new PrivilegedExceptionAction<Void>() {
+
+                                       @Override
+                                       public Void run() throws Exception {
+                                               process();
+                                               return null;
+                                       }
+
+                               });
+                       } catch (PrivilegedActionException privilegedActionException) {
+                               Throwable cause = privilegedActionException.getCause();
+                               if (cause instanceof InterruptedException)
+                                       throw (InterruptedException) cause;
+                               else
+                                       throw new SlcException("Cannot process", cause);
+                       }
+                       // process();
+               } catch (InterruptedException e) {
+                       die();
+                       return;
+               } catch (Exception e) {
+                       String msg = "Process " + getProcess().getUuid() + " failed unexpectedly.";
+                       log.error(msg, e);
+                       getProcessThreadGroup()
+                                       .dispatchAddStep(new ExecutionStep("Process", ExecutionStep.ERROR, msg + " " + e.getMessage()));
+               }
+
+               // waits for all execution threads to complete (in case they were
+               // started asynchronously)
+               for (ExecutionThread executionThread : executionThreads) {
+                       if (executionThread.isAlive()) {
+                               try {
+                                       executionThread.join();
+                               } catch (InterruptedException e) {
+                                       die();
+                                       return;
+                               }
+                       }
+               }
+
+               computeFinalStatus();
+       }
+
+       /** Make sure this is called BEFORE all the threads are interrupted. */
+       private void computeFinalStatus() {
+               // String oldStatus = process.getStatus();
+               // TODO: error management at flow level?
+               if (killed)
+                       process.setStatus(ExecutionProcess.KILLED);
+               else if (processThreadGroup.hadAnError())
+                       process.setStatus(ExecutionProcess.ERROR);
+               else
+                       process.setStatus(ExecutionProcess.COMPLETED);
+               // executionModulesManager.dispatchUpdateStatus(process, oldStatus,
+               // process.getStatus());
+               log.info("\n## SLC Process #" + process.getUuid() + " " + process.getStatus() + "\n");
+       }
+
+       /** Called when being killed */
+       private synchronized void die() {
+               killed = true;
+               computeFinalStatus();
+               for (ExecutionThread executionThread : executionThreads) {
+                       try {
+                               executionThread.interrupt();
+                       } catch (Exception e) {
+                               log.error("Cannot interrupt " + executionThread);
+                       }
+               }
+               processThreadGroup.interrupt();
+       }
+
+       /**
+        * Implementation specific execution. To be overridden in order to deal with
+        * custom process types. Default expects an {@link SlcExecution}.
+        */
+       protected void process() throws InterruptedException {
+               List<RealizedFlow> flowsToProcess = new ArrayList<RealizedFlow>();
+               flowsToProcess.addAll(process.getRealizedFlows());
+               while (flowsToProcess.size() > 0) {
+                       RealizedFlow realizedFlow = flowsToProcess.remove(0);
+                       execute(realizedFlow, true);
+               }
+       }
+
+       /** @return the (distinct) thread used for this execution */
+       protected final void execute(RealizedFlow realizedFlow, Boolean synchronous) throws InterruptedException {
+               if (killed)
+                       return;
+
+               ExecutionThread thread = new ExecutionThread(processThreadGroup, executionModulesManager, realizedFlow);
+               executionThreads.add(thread);
+               thread.start();
+
+               if (synchronous)
+                       thread.join();
+
+               return;
+       }
+
+       // public void notifyError() {
+       // hadAnError = true;
+       // }
+       //
+       // public synchronized void flowCompleted() {
+       // // notifyAll();
+       // }
+
+       public ExecutionProcess getProcess() {
+               return process;
+       }
+
+       public ProcessThreadGroup getProcessThreadGroup() {
+               return processThreadGroup;
+       }
+
+       public ExecutionModulesManager getExecutionModulesManager() {
+               return executionModulesManager;
+       }
+
+       private class LoggingThread extends Thread {
+
+               public LoggingThread() {
+                       super("SLC Process Logger #" + process.getUuid());
+               }
+
+               public void run() {
+                       boolean run = true;
+                       while (run) {
+                               List<ExecutionStep> newSteps = new ArrayList<ExecutionStep>();
+                               processThreadGroup.getSteps().drainTo(newSteps);
+                               if (newSteps.size() > 0) {
+                                       // System.out.println(steps.size() + " steps");
+                                       process.addSteps(newSteps);
+                               }
+
+                               try {
+                                       Thread.sleep(1000);
+                               } catch (InterruptedException e) {
+                                       break;
+                               }
+
+                               if (!ProcessThread.this.isAlive() && processThreadGroup.getSteps().size() == 0)
+                                       run = false;
+                       }
+               }
+
+       }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThreadGroup.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/ProcessThreadGroup.java
new file mode 100644 (file)
index 0000000..79f38d7
--- /dev/null
@@ -0,0 +1,53 @@
+package org.argeo.slc.runtime;
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+
+import org.argeo.slc.execution.ExecutionProcess;
+import org.argeo.slc.execution.ExecutionStep;
+
+/** The thread group attached to a given {@link SlcExecution}. */
+public class ProcessThreadGroup extends ThreadGroup {
+//     private final Authentication authentication;
+       private final static Integer STEPS_BUFFER_CAPACITY = 5000;
+
+       private BlockingQueue<ExecutionStep> steps = new ArrayBlockingQueue<ExecutionStep>(
+                       STEPS_BUFFER_CAPACITY);
+
+       private Boolean hadAnError = false;
+
+       public ProcessThreadGroup(ExecutionProcess executionProcess) {
+               super("SLC Process #" + executionProcess.getUuid() + " thread group");
+//             this.authentication = SecurityContextHolder.getContext()
+//                             .getAuthentication();
+       }
+
+//     public Authentication getAuthentication() {
+//             return authentication;
+//     }
+
+       public void dispatchAddStep(ExecutionStep step) {
+               // ExecutionProcess slcProcess = processThread.getProcess();
+               // List<ExecutionStep> steps = new ArrayList<ExecutionStep>();
+               // steps.add(step);
+               // TODO clarify why we don't dispatch steps, must be a reason
+               // dispatchAddSteps(steps);
+               // slcProcess.addSteps(steps);
+               if (step.getType().equals(ExecutionStep.ERROR))
+                       hadAnError = true;
+               this.steps.add(step);
+       }
+
+       // public void dispatchAddSteps(List<ExecutionStep> steps) {
+       // ExecutionProcess slcProcess = processThread.getProcess();
+       // executionModulesManager.dispatchAddSteps(slcProcess, steps);
+       // }
+
+       public BlockingQueue<ExecutionStep> getSteps() {
+               return steps;
+       }
+
+       public Boolean hadAnError() {
+               return hadAnError;
+       }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/CloseTestResult.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/CloseTestResult.java
new file mode 100644 (file)
index 0000000..2bb48b8
--- /dev/null
@@ -0,0 +1,16 @@
+package org.argeo.slc.runtime.tasks;
+
+import org.argeo.slc.test.TestResult;
+
+public class CloseTestResult implements Runnable {
+       private TestResult testResult;
+
+       public void run() {
+               testResult.close();
+       }
+
+       public void setTestResult(TestResult testResult) {
+               this.testResult = testResult;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/Echo.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/Echo.java
new file mode 100644 (file)
index 0000000..a6e60d3
--- /dev/null
@@ -0,0 +1,47 @@
+package org.argeo.slc.runtime.tasks;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+
+public class Echo implements Runnable {
+       private final static Log defaultLog = LogFactory.getLog(Echo.class);
+       private Path writeTo = null;
+
+       private Log log;
+       private Object message;
+
+       public void run() {
+               log().info(message);
+
+               if (writeTo != null) {
+                       try {
+                               File file = writeTo.toFile();
+                               if (log().isDebugEnabled())
+                                       log().debug("Write to " + file);
+                               if (message != null)
+                                       FileUtils.writeStringToFile(file, message.toString());
+                       } catch (IOException e) {
+                               throw new SlcException("Could not write to " + writeTo, e);
+                       }
+               }
+       }
+
+       private Log log() {
+               return log != null ? log : defaultLog;
+       }
+
+       public void setMessage(Object message) {
+               this.message = message;
+       }
+
+       public void setWriteTo(Path writeTo) {
+               this.writeTo = writeTo;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/If.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/If.java
new file mode 100644 (file)
index 0000000..08eb804
--- /dev/null
@@ -0,0 +1,49 @@
+package org.argeo.slc.runtime.tasks;
+
+import org.argeo.slc.SlcException;
+
+/** Conditional execution */
+public class If implements Runnable {
+       private Boolean is;
+       private Boolean not;
+       private Runnable then;
+       private Runnable els;
+
+       public void run() {
+               if (is == null && not == null)
+                       throw new SlcException("No condition set");
+               if (is != null && not != null)
+                       throw new SlcException("Both is and not cannot be set");
+
+               boolean bool = (is != null ? is : !not);
+               if (bool) {
+                       if (then != null)
+                               then.run();
+               } else {
+                       if (els != null)
+                               els.run();
+               }
+
+       }
+
+       public void setIs(Boolean bool) {
+               this.is = bool;
+       }
+
+       public void setThen(Runnable then) {
+               this.then = then;
+       }
+
+       public void setEls(Runnable els) {
+               this.els = els;
+       }
+
+       public Boolean getNot() {
+               return not;
+       }
+
+       public void setNot(Boolean not) {
+               this.not = not;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/JvmProcess.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/JvmProcess.java
new file mode 100644 (file)
index 0000000..c89f2b8
--- /dev/null
@@ -0,0 +1,230 @@
+package org.argeo.slc.runtime.tasks;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.slc.SlcException;
+
+/** A Java Virtual Machine process. */
+public class JvmProcess extends SystemCall {
+       private Properties systemProperties = new Properties();
+       private List<Path> classpath = new ArrayList<Path>();
+       private List<Path> pBootClasspath = new ArrayList<Path>();
+       private Path jvm = null;
+       private String mainClass;
+       private String mainJar;
+       private List<String> jvmArgs = new ArrayList<String>();
+       private List<String> args = new ArrayList<String>();
+
+       private String systemPropertiesFileProperty = null;
+       private String systemPropertiesFileDir = null;
+       private String systemPropertiesFileName = null;
+
+       public void init() throws Exception {
+               List<Object> command = new ArrayList<Object>();
+               if (jvm != null)
+                       command.add(asFile(jvm).getPath());
+               else
+                       command.add("java");
+
+               if (pBootClasspath.size() > 0) {
+                       StringBuffer buf = new StringBuffer("-Xbootclasspath/p:");
+                       Boolean first = true;
+                       for (Path res : pBootClasspath) {
+                               if (first)
+                                       first = false;
+                               else
+                                       buf.append(File.pathSeparatorChar);
+
+                               buf.append(asFile(res));
+                       }
+                       command.add(buf.toString());
+               }
+
+               for (String jvmArg : jvmArgs) {
+                       command.add(jvmArg);
+               }
+
+               if (classpath.size() > 0) {
+                       command.add("-cp");
+                       StringBuffer buf = new StringBuffer("");
+                       for (Path res : classpath) {
+                               if (buf.length() != 0)
+                                       buf.append(File.pathSeparatorChar);
+                               buf.append(asFile(res));
+                       }
+                       command.add(buf.toString());
+               }
+
+               if (systemPropertiesFileProperty == null) {
+                       // pass system properties as argument
+                       for (Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
+                               command.add("-D" + entry.getKey() + "=" + entry.getValue());
+                       }
+               } else {
+                       // write system properties in a file to work around OS limitations
+                       // with command line (e.g. Win XP)
+                       String dir = systemPropertiesFileDir;
+                       if (dir == null)
+                               dir = getExecDirToUse();
+                       String fileName = systemPropertiesFileName;
+                       if (fileName == null)
+                               fileName = systemPropertiesFileProperty + ".properties";
+
+                       // Write file
+                       FileOutputStream fos = null;
+                       File file = new File(dir + File.separator + fileName);
+                       try {
+
+                               if (!file.getParentFile().exists())
+                                       file.getParentFile().mkdirs();
+                               fos = new FileOutputStream(file);
+                               systemProperties.store(fos, "Automatically generated by " + getClass());
+                               command.add("-D" + systemPropertiesFileProperty + "=" + file.getCanonicalPath());
+                       } catch (IOException e) {
+                               throw new SlcException("Cannot write to system properties to " + file, e);
+                       } finally {
+                               IOUtils.closeQuietly(fos);
+                       }
+               }
+
+               // Program
+               if (mainClass != null) {
+                       command.add(mainClass);
+               } else if (mainJar != null) {
+                       command.add("-jar");
+                       command.add(mainJar);
+               } else {
+                       throw new SlcException("No main class or jar defined");
+               }
+
+               for (String arg : args) {
+                       command.add(arg);
+               }
+
+               setCommand(command);
+       }
+
+       protected File asFile(Path res) {
+               File file = res.toFile();
+               if (!file.exists())
+                       return copyToTempFile(res);
+               else
+                       return res.toFile();
+       }
+
+       protected File copyToTempFile(Path res) {
+               File tempFile;
+               FileOutputStream fos;
+               try {
+                       tempFile = File.createTempFile("slcJvmProcess-", res.getFileName().toString());
+                       tempFile.deleteOnExit();
+                       fos = new FileOutputStream(tempFile);
+                       IOUtils.copy(Files.newInputStream(res), fos);
+               } catch (IOException e) {
+                       throw new SlcException("Cannot copy " + res + " to temp file.", e);
+               }
+               IOUtils.closeQuietly(fos);
+               return tempFile;
+       }
+
+       /** Append the argument (for chaining) */
+       @Override
+       public SystemCall arg(String arg) {
+               args.add(arg);
+               return this;
+       }
+
+       /** Append the argument (for chaining) */
+       @Override
+       public SystemCall arg(String arg, String value) {
+               args.add(arg);
+               args.add(value);
+               return this;
+       }
+
+       public Properties getSystemProperties() {
+               return systemProperties;
+       }
+
+       public void setSystemProperties(Properties systemProperties) {
+               this.systemProperties = systemProperties;
+       }
+
+       public List<Path> getClasspath() {
+               return classpath;
+       }
+
+       public void setClasspath(List<Path> classpath) {
+               this.classpath = classpath;
+       }
+
+       public List<Path> getPBootClasspath() {
+               return pBootClasspath;
+       }
+
+       public void setPBootClasspath(List<Path> bootClasspath) {
+               pBootClasspath = bootClasspath;
+       }
+
+       public Path getJvm() {
+               return jvm;
+       }
+
+       public void setJvm(Path jvm) {
+               this.jvm = jvm;
+       }
+
+       public String getMainClass() {
+               return mainClass;
+       }
+
+       public void setMainClass(String mainClass) {
+               this.mainClass = mainClass;
+       }
+
+       public String getMainJar() {
+               return mainJar;
+       }
+
+       public void setMainJar(String mainJar) {
+               this.mainJar = mainJar;
+       }
+
+       public List<String> getJvmArgs() {
+               return jvmArgs;
+       }
+
+       public void setJvmArgs(List<String> jvmArgs) {
+               this.jvmArgs = jvmArgs;
+       }
+
+       public List<String> getArgs() {
+               return args;
+       }
+
+       public void setArgs(List<String> args) {
+               this.args = args;
+       }
+
+       public void setSystemPropertiesFileProperty(String systemPropertiesFilePropertyName) {
+               this.systemPropertiesFileProperty = systemPropertiesFilePropertyName;
+       }
+
+       public void setSystemPropertiesFileDir(String systemPropertiesFileDir) {
+               this.systemPropertiesFileDir = systemPropertiesFileDir;
+       }
+
+       public void setSystemPropertiesFileName(String systemPropertiesFileName) {
+               this.systemPropertiesFileName = systemPropertiesFileName;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCall.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCall.java
new file mode 100644 (file)
index 0000000..f5e8502
--- /dev/null
@@ -0,0 +1,746 @@
+package org.argeo.slc.runtime.tasks;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.security.auth.callback.CallbackHandler;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteResultHandler;
+import org.apache.commons.exec.ExecuteStreamHandler;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.LogOutputStream;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.exec.ShutdownHookProcessDestroyer;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.UnsupportedException;
+import org.argeo.slc.execution.ExecutionResources;
+import org.argeo.slc.runtime.test.SimpleResultPart;
+import org.argeo.slc.test.TestResult;
+import org.argeo.slc.test.TestStatus;
+
+/** Execute an OS specific system call. */
+public class SystemCall implements Runnable {
+       public final static String LOG_STDOUT = "System.out";
+
+       private final Log log = LogFactory.getLog(getClass());
+
+       private String execDir;
+
+       private String cmd = null;
+       private List<Object> command = null;
+
+       private Executor executor = new DefaultExecutor();
+       private Boolean synchronous = true;
+
+       private String stdErrLogLevel = "ERROR";
+       private String stdOutLogLevel = "INFO";
+
+       private Path stdOutFile = null;
+       private Path stdErrFile = null;
+
+       private Path stdInFile = null;
+       /**
+        * If no {@link #stdInFile} provided, writing to this stream will write to the
+        * stdin of the process.
+        */
+       private OutputStream stdInSink = null;
+
+       private Boolean redirectStdOut = false;
+
+       private List<SystemCallOutputListener> outputListeners = Collections
+                       .synchronizedList(new ArrayList<SystemCallOutputListener>());
+
+       private Map<String, List<Object>> osCommands = new HashMap<String, List<Object>>();
+       private Map<String, String> osCmds = new HashMap<String, String>();
+       private Map<String, String> environmentVariables = new HashMap<String, String>();
+
+       private Boolean logCommand = false;
+       private Boolean redirectStreams = true;
+       private Boolean exceptionOnFailed = true;
+       private Boolean mergeEnvironmentVariables = true;
+
+//     private Authentication authentication;
+
+       private String osConsole = null;
+       private String generateScript = null;
+
+       /** 24 hours */
+       private Long watchdogTimeout = 24 * 60 * 60 * 1000l;
+
+       private TestResult testResult;
+
+       private ExecutionResources executionResources;
+
+       /** Sudo the command, as root if empty or as user if not. */
+       private String sudo = null;
+       // TODO make it more secure and robust, test only once
+       private final String sudoPrompt = UUID.randomUUID().toString();
+       private String askPassProgram = "/usr/libexec/openssh/ssh-askpass";
+       @SuppressWarnings("unused")
+       private boolean firstLine = true;
+       @SuppressWarnings("unused")
+       private CallbackHandler callbackHandler;
+       /** Chroot to the this path (must not be empty) */
+       private String chroot = null;
+
+       // Current
+       /** Current watchdog, null if process is completed */
+       ExecuteWatchdog currentWatchdog = null;
+
+       /** Empty constructor */
+       public SystemCall() {
+
+       }
+
+       /**
+        * Constructor based on the provided command list.
+        * 
+        * @param command the command list
+        */
+       public SystemCall(List<Object> command) {
+               this.command = command;
+       }
+
+       /**
+        * Constructor based on the provided command.
+        * 
+        * @param cmd the command. If the provided string contains no space a command
+        *            list is initialized with the argument as first component (useful
+        *            for chained construction)
+        */
+       public SystemCall(String cmd) {
+               if (cmd.indexOf(' ') < 0) {
+                       command = new ArrayList<Object>();
+                       command.add(cmd);
+               } else {
+                       this.cmd = cmd;
+               }
+       }
+
+       /** Executes the system call. */
+       public void run() {
+//             authentication = SecurityContextHolder.getContext().getAuthentication();
+
+               // Manage streams
+               Writer stdOutWriter = null;
+               OutputStream stdOutputStream = null;
+               Writer stdErrWriter = null;
+               InputStream stdInStream = null;
+               if (stdOutFile != null)
+                       if (redirectStdOut)
+                               stdOutputStream = createOutputStream(stdOutFile);
+                       else
+                               stdOutWriter = createWriter(stdOutFile, true);
+
+               if (stdErrFile != null) {
+                       stdErrWriter = createWriter(stdErrFile, true);
+               } else {
+                       if (stdOutFile != null && !redirectStdOut)
+                               stdErrWriter = createWriter(stdOutFile, true);
+               }
+
+               try {
+                       if (stdInFile != null)
+                               stdInStream = Files.newInputStream(stdInFile);
+                       else {
+                               stdInStream = new PipedInputStream();
+                               stdInSink = new PipedOutputStream((PipedInputStream) stdInStream);
+                       }
+               } catch (IOException e2) {
+                       throw new SlcException("Cannot open a stream for " + stdInFile, e2);
+               }
+
+               if (log.isTraceEnabled()) {
+                       log.debug("os.name=" + System.getProperty("os.name"));
+                       log.debug("os.arch=" + System.getProperty("os.arch"));
+                       log.debug("os.version=" + System.getProperty("os.version"));
+               }
+
+               // Execution directory
+               File dir = new File(getExecDirToUse());
+               // if (!dir.exists())
+               // dir.mkdirs();
+
+               // Watchdog to check for lost processes
+               Executor executorToUse;
+               if (executor != null)
+                       executorToUse = executor;
+               else
+                       executorToUse = new DefaultExecutor();
+               executorToUse.setWatchdog(createWatchdog());
+
+               if (redirectStreams) {
+                       // Redirect standard streams
+                       executorToUse.setStreamHandler(
+                                       createExecuteStreamHandler(stdOutWriter, stdOutputStream, stdErrWriter, stdInStream));
+               } else {
+                       // Dummy stream handler (otherwise pump is used)
+                       executorToUse.setStreamHandler(new DummyexecuteStreamHandler());
+               }
+
+               executorToUse.setProcessDestroyer(new ShutdownHookProcessDestroyer());
+               executorToUse.setWorkingDirectory(dir);
+
+               // Command line to use
+               final CommandLine commandLine = createCommandLine();
+               if (logCommand)
+                       log.info("Execute command:\n" + commandLine + "\n in working directory: \n" + dir + "\n");
+
+               // Env variables
+               Map<String, String> environmentVariablesToUse = null;
+               environmentVariablesToUse = new HashMap<String, String>();
+               if (mergeEnvironmentVariables)
+                       environmentVariablesToUse.putAll(System.getenv());
+               if (environmentVariables.size() > 0)
+                       environmentVariablesToUse.putAll(environmentVariables);
+
+               // Execute
+               ExecuteResultHandler executeResultHandler = createExecuteResultHandler(commandLine);
+
+               //
+               // THE EXECUTION PROPER
+               //
+               try {
+                       if (synchronous)
+                               try {
+                                       int exitValue = executorToUse.execute(commandLine, environmentVariablesToUse);
+                                       executeResultHandler.onProcessComplete(exitValue);
+                               } catch (ExecuteException e1) {
+                                       if (e1.getExitValue() == Executor.INVALID_EXITVALUE) {
+                                               Thread.currentThread().interrupt();
+                                               return;
+                                       }
+                                       // Sleep 1s in order to make sure error logs are flushed
+                                       Thread.sleep(1000);
+                                       executeResultHandler.onProcessFailed(e1);
+                               }
+                       else
+                               executorToUse.execute(commandLine, environmentVariablesToUse, executeResultHandler);
+               } catch (SlcException e) {
+                       throw e;
+               } catch (Exception e) {
+                       throw new SlcException("Could not execute command " + commandLine, e);
+               } finally {
+                       IOUtils.closeQuietly(stdOutWriter);
+                       IOUtils.closeQuietly(stdErrWriter);
+                       IOUtils.closeQuietly(stdInStream);
+                       IOUtils.closeQuietly(stdInSink);
+               }
+
+       }
+
+       public synchronized String function() {
+               final StringBuffer buf = new StringBuffer("");
+               SystemCallOutputListener tempOutputListener = new SystemCallOutputListener() {
+                       private Long lineCount = 0l;
+
+                       public void newLine(SystemCall systemCall, String line, Boolean isError) {
+                               if (!isError) {
+                                       if (lineCount != 0l)
+                                               buf.append('\n');
+                                       buf.append(line);
+                                       lineCount++;
+                               }
+                       }
+               };
+               addOutputListener(tempOutputListener);
+               run();
+               removeOutputListener(tempOutputListener);
+               return buf.toString();
+       }
+
+       public String asCommand() {
+               return createCommandLine().toString();
+       }
+
+       @Override
+       public String toString() {
+               return asCommand();
+       }
+
+       /**
+        * Build a command line based on the properties. Can be overridden by specific
+        * command wrappers.
+        */
+       protected CommandLine createCommandLine() {
+               // Check if an OS specific command overrides
+               String osName = System.getProperty("os.name");
+               List<Object> commandToUse = null;
+               if (osCommands.containsKey(osName))
+                       commandToUse = osCommands.get(osName);
+               else
+                       commandToUse = command;
+               String cmdToUse = null;
+               if (osCmds.containsKey(osName))
+                       cmdToUse = osCmds.get(osName);
+               else
+                       cmdToUse = cmd;
+
+               CommandLine commandLine = null;
+
+               // Which command definition to use
+               if (commandToUse == null && cmdToUse == null)
+                       throw new SlcException("Please specify a command.");
+               else if (commandToUse != null && cmdToUse != null)
+                       throw new SlcException("Specify the command either as a line or as a list.");
+               else if (cmdToUse != null) {
+                       if (chroot != null && !chroot.trim().equals(""))
+                               cmdToUse = "chroot \"" + chroot + "\" " + cmdToUse;
+                       if (sudo != null) {
+                               environmentVariables.put("SUDO_ASKPASS", askPassProgram);
+                               if (!sudo.trim().equals(""))
+                                       cmdToUse = "sudo -p " + sudoPrompt + " -u " + sudo + " " + cmdToUse;
+                               else
+                                       cmdToUse = "sudo -p " + sudoPrompt + " " + cmdToUse;
+                       }
+
+                       // GENERATE COMMAND LINE
+                       commandLine = CommandLine.parse(cmdToUse);
+               } else if (commandToUse != null) {
+                       if (commandToUse.size() == 0)
+                               throw new SlcException("Command line is empty.");
+
+                       if (chroot != null && sudo != null) {
+                               commandToUse.add(0, "chroot");
+                               commandToUse.add(1, chroot);
+                       }
+
+                       if (sudo != null) {
+                               environmentVariables.put("SUDO_ASKPASS", askPassProgram);
+                               commandToUse.add(0, "sudo");
+                               commandToUse.add(1, "-p");
+                               commandToUse.add(2, sudoPrompt);
+                               if (!sudo.trim().equals("")) {
+                                       commandToUse.add(3, "-u");
+                                       commandToUse.add(4, sudo);
+                               }
+                       }
+
+                       // GENERATE COMMAND LINE
+                       commandLine = new CommandLine(commandToUse.get(0).toString());
+
+                       for (int i = 1; i < commandToUse.size(); i++) {
+                               if (log.isTraceEnabled())
+                                       log.debug(commandToUse.get(i));
+                               commandLine.addArgument(commandToUse.get(i).toString());
+                       }
+               } else {
+                       // all cases covered previously
+                       throw new UnsupportedException();
+               }
+
+               if (generateScript != null) {
+                       File scriptFile = new File(getExecDirToUse() + File.separator + generateScript);
+                       try {
+                               FileUtils.writeStringToFile(scriptFile,
+                                               (osConsole != null ? osConsole + " " : "") + commandLine.toString());
+                       } catch (IOException e) {
+                               throw new SlcException("Could not generate script " + scriptFile, e);
+                       }
+                       commandLine = new CommandLine(scriptFile);
+               } else {
+                       if (osConsole != null)
+                               commandLine = CommandLine.parse(osConsole + " " + commandLine.toString());
+               }
+
+               return commandLine;
+       }
+
+       /**
+        * Creates a {@link PumpStreamHandler} which redirects streams to the custom
+        * logging mechanism.
+        */
+       protected ExecuteStreamHandler createExecuteStreamHandler(final Writer stdOutWriter,
+                       final OutputStream stdOutputStream, final Writer stdErrWriter, final InputStream stdInStream) {
+
+               // Log writers
+               OutputStream stdout = stdOutputStream != null ? stdOutputStream : new LogOutputStream() {
+                       protected void processLine(String line, int level) {
+                               // if (firstLine) {
+                               // if (sudo != null && callbackHandler != null
+                               // && line.startsWith(sudoPrompt)) {
+                               // try {
+                               // PasswordCallback pc = new PasswordCallback(
+                               // "sudo password", false);
+                               // Callback[] cbs = { pc };
+                               // callbackHandler.handle(cbs);
+                               // char[] pwd = pc.getPassword();
+                               // char[] arr = Arrays.copyOf(pwd,
+                               // pwd.length + 1);
+                               // arr[arr.length - 1] = '\n';
+                               // IOUtils.write(arr, stdInSink);
+                               // stdInSink.flush();
+                               // } catch (Exception e) {
+                               // throw new SlcException(
+                               // "Cannot retrieve sudo password", e);
+                               // }
+                               // }
+                               // firstLine = false;
+                               // }
+
+                               if (line != null && !line.trim().equals(""))
+                                       logStdOut(line);
+
+                               if (stdOutWriter != null)
+                                       appendLineToFile(stdOutWriter, line);
+                       }
+               };
+
+               OutputStream stderr = new LogOutputStream() {
+                       protected void processLine(String line, int level) {
+                               if (line != null && !line.trim().equals(""))
+                                       logStdErr(line);
+                               if (stdErrWriter != null)
+                                       appendLineToFile(stdErrWriter, line);
+                       }
+               };
+
+               PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(stdout, stderr, stdInStream) {
+
+                       @Override
+                       public void stop() throws IOException {
+                               // prevents the method to block when joining stdin
+                               if (stdInSink != null)
+                                       IOUtils.closeQuietly(stdInSink);
+
+                               super.stop();
+                       }
+               };
+               return pumpStreamHandler;
+       }
+
+       /** Creates the default {@link ExecuteResultHandler}. */
+       protected ExecuteResultHandler createExecuteResultHandler(final CommandLine commandLine) {
+               return new ExecuteResultHandler() {
+
+                       public void onProcessComplete(int exitValue) {
+                               String msg = "System call '" + commandLine + "' properly completed.";
+                               if (log.isTraceEnabled())
+                                       log.trace(msg);
+                               if (testResult != null) {
+                                       forwardPath(testResult);
+                                       testResult.addResultPart(new SimpleResultPart(TestStatus.PASSED, msg));
+                               }
+                               releaseWatchdog();
+                       }
+
+                       public void onProcessFailed(ExecuteException e) {
+
+                               String msg = "System call '" + commandLine + "' failed.";
+                               if (testResult != null) {
+                                       forwardPath(testResult);
+                                       testResult.addResultPart(new SimpleResultPart(TestStatus.ERROR, msg, e));
+                               } else {
+                                       if (exceptionOnFailed)
+                                               throw new SlcException(msg, e);
+                                       else
+                                               log.error(msg, e);
+                               }
+                               releaseWatchdog();
+                       }
+               };
+       }
+
+       @Deprecated
+       protected void forwardPath(TestResult testResult) {
+               // TODO: allocate a TreeSPath
+       }
+
+       /**
+        * Shortcut method getting the execDir to use
+        */
+       protected String getExecDirToUse() {
+               try {
+                       if (execDir != null) {
+                               return execDir;
+                       }
+                       return System.getProperty("user.dir");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot find exec dir", e);
+               }
+       }
+
+       protected void logStdOut(String line) {
+               for (SystemCallOutputListener outputListener : outputListeners)
+                       outputListener.newLine(this, line, false);
+               log(stdOutLogLevel, line);
+       }
+
+       protected void logStdErr(String line) {
+               for (SystemCallOutputListener outputListener : outputListeners)
+                       outputListener.newLine(this, line, true);
+               log(stdErrLogLevel, line);
+       }
+
+       /** Log from the underlying streams. */
+       protected void log(String logLevel, String line) {
+               // TODO optimize
+//             if (SecurityContextHolder.getContext().getAuthentication() == null) {
+//                     SecurityContextHolder.getContext()
+//                                     .setAuthentication(authentication);
+//             }
+
+               if ("ERROR".equals(logLevel))
+                       log.error(line);
+               else if ("WARN".equals(logLevel))
+                       log.warn(line);
+               else if ("INFO".equals(logLevel))
+                       log.info(line);
+               else if ("DEBUG".equals(logLevel))
+                       log.debug(line);
+               else if ("TRACE".equals(logLevel))
+                       log.trace(line);
+               else if (LOG_STDOUT.equals(logLevel))
+                       System.out.println(line);
+               else if ("System.err".equals(logLevel))
+                       System.err.println(line);
+               else
+                       throw new SlcException("Unknown log level " + logLevel);
+       }
+
+       /** Append line to a log file. */
+       protected void appendLineToFile(Writer writer, String line) {
+               try {
+                       writer.append(line).append('\n');
+               } catch (IOException e) {
+                       log.error("Cannot write to log file", e);
+               }
+       }
+
+       /** Creates the writer for the output/err files. */
+       protected Writer createWriter(Path target, Boolean append) {
+               FileWriter writer = null;
+               try {
+
+                       final File file;
+                       if (executionResources != null)
+                               file = new File(executionResources.getAsOsPath(target, true));
+                       else
+                               file = target.toFile();
+                       writer = new FileWriter(file, append);
+               } catch (IOException e) {
+                       log.error("Cannot get file for " + target, e);
+                       IOUtils.closeQuietly(writer);
+               }
+               return writer;
+       }
+
+       /** Creates an outputstream for the output/err files. */
+       protected OutputStream createOutputStream(Path target) {
+               FileOutputStream out = null;
+               try {
+
+                       final File file;
+                       if (executionResources != null)
+                               file = new File(executionResources.getAsOsPath(target, true));
+                       else
+                               file = target.toFile();
+                       out = new FileOutputStream(file, false);
+               } catch (IOException e) {
+                       log.error("Cannot get file for " + target, e);
+                       IOUtils.closeQuietly(out);
+               }
+               return out;
+       }
+
+       /** Append the argument (for chaining) */
+       public SystemCall arg(String arg) {
+               if (command == null)
+                       command = new ArrayList<Object>();
+               command.add(arg);
+               return this;
+       }
+
+       /** Append the argument (for chaining) */
+       public SystemCall arg(String arg, String value) {
+               if (command == null)
+                       command = new ArrayList<Object>();
+               command.add(arg);
+               command.add(value);
+               return this;
+       }
+
+       // CONTROL
+       public synchronized Boolean isRunning() {
+               return currentWatchdog != null;
+       }
+
+       private synchronized ExecuteWatchdog createWatchdog() {
+//             if (currentWatchdog != null)
+//                     throw new SlcException("A process is already being monitored");
+               currentWatchdog = new ExecuteWatchdog(watchdogTimeout);
+               return currentWatchdog;
+       }
+
+       private synchronized void releaseWatchdog() {
+               currentWatchdog = null;
+       }
+
+       public synchronized void kill() {
+               if (currentWatchdog != null)
+                       currentWatchdog.destroyProcess();
+       }
+
+       /** */
+       public void setCmd(String command) {
+               this.cmd = command;
+       }
+
+       public void setCommand(List<Object> command) {
+               this.command = command;
+       }
+
+       public void setExecDir(String execdir) {
+               this.execDir = execdir;
+       }
+
+       public void setStdErrLogLevel(String stdErrLogLevel) {
+               this.stdErrLogLevel = stdErrLogLevel;
+       }
+
+       public void setStdOutLogLevel(String stdOutLogLevel) {
+               this.stdOutLogLevel = stdOutLogLevel;
+       }
+
+       public void setSynchronous(Boolean synchronous) {
+               this.synchronous = synchronous;
+       }
+
+       public void setOsCommands(Map<String, List<Object>> osCommands) {
+               this.osCommands = osCommands;
+       }
+
+       public void setOsCmds(Map<String, String> osCmds) {
+               this.osCmds = osCmds;
+       }
+
+       public void setEnvironmentVariables(Map<String, String> environmentVariables) {
+               this.environmentVariables = environmentVariables;
+       }
+
+       public Map<String, String> getEnvironmentVariables() {
+               return environmentVariables;
+       }
+
+       public void setWatchdogTimeout(Long watchdogTimeout) {
+               this.watchdogTimeout = watchdogTimeout;
+       }
+
+       public void setStdOutFile(Path stdOutFile) {
+               this.stdOutFile = stdOutFile;
+       }
+
+       public void setStdErrFile(Path stdErrFile) {
+               this.stdErrFile = stdErrFile;
+       }
+
+       public void setStdInFile(Path stdInFile) {
+               this.stdInFile = stdInFile;
+       }
+
+       public void setTestResult(TestResult testResult) {
+               this.testResult = testResult;
+       }
+
+       public void setLogCommand(Boolean logCommand) {
+               this.logCommand = logCommand;
+       }
+
+       public void setRedirectStreams(Boolean redirectStreams) {
+               this.redirectStreams = redirectStreams;
+       }
+
+       public void setExceptionOnFailed(Boolean exceptionOnFailed) {
+               this.exceptionOnFailed = exceptionOnFailed;
+       }
+
+       public void setMergeEnvironmentVariables(Boolean mergeEnvironmentVariables) {
+               this.mergeEnvironmentVariables = mergeEnvironmentVariables;
+       }
+
+       public void setOsConsole(String osConsole) {
+               this.osConsole = osConsole;
+       }
+
+       public void setGenerateScript(String generateScript) {
+               this.generateScript = generateScript;
+       }
+
+       public void setExecutionResources(ExecutionResources executionResources) {
+               this.executionResources = executionResources;
+       }
+
+       public void setRedirectStdOut(Boolean redirectStdOut) {
+               this.redirectStdOut = redirectStdOut;
+       }
+
+       public void addOutputListener(SystemCallOutputListener outputListener) {
+               outputListeners.add(outputListener);
+       }
+
+       public void removeOutputListener(SystemCallOutputListener outputListener) {
+               outputListeners.remove(outputListener);
+       }
+
+       public void setOutputListeners(List<SystemCallOutputListener> outputListeners) {
+               this.outputListeners = outputListeners;
+       }
+
+       public void setExecutor(Executor executor) {
+               this.executor = executor;
+       }
+
+       public void setSudo(String sudo) {
+               this.sudo = sudo;
+       }
+
+       public void setCallbackHandler(CallbackHandler callbackHandler) {
+               this.callbackHandler = callbackHandler;
+       }
+
+       public void setChroot(String chroot) {
+               this.chroot = chroot;
+       }
+
+       private class DummyexecuteStreamHandler implements ExecuteStreamHandler {
+
+               public void setProcessErrorStream(InputStream is) throws IOException {
+               }
+
+               public void setProcessInputStream(OutputStream os) throws IOException {
+               }
+
+               public void setProcessOutputStream(InputStream is) throws IOException {
+               }
+
+               public void start() throws IOException {
+               }
+
+               public void stop() {
+               }
+
+       }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCallOutputListener.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/tasks/SystemCallOutputListener.java
new file mode 100644 (file)
index 0000000..bedd15a
--- /dev/null
@@ -0,0 +1,5 @@
+package org.argeo.slc.runtime.tasks;
+
+public interface SystemCallOutputListener {
+       public void newLine(SystemCall systemCall, String line, Boolean isError);
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestData.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestData.java
new file mode 100644 (file)
index 0000000..ec6261d
--- /dev/null
@@ -0,0 +1,25 @@
+package org.argeo.slc.runtime.test;
+
+import org.argeo.slc.test.TestData;
+
+public class BasicTestData implements TestData {
+       private Object expected;
+       private Object reached;
+
+       public Object getExpected() {
+               return expected;
+       }
+
+       public void setExpected(Object expected) {
+               this.expected = expected;
+       }
+
+       public Object getReached() {
+               return reached;
+       }
+
+       public void setReached(Object reached) {
+               this.reached = reached;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestDefinition.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/BasicTestDefinition.java
new file mode 100644 (file)
index 0000000..3bc49f6
--- /dev/null
@@ -0,0 +1,45 @@
+package org.argeo.slc.runtime.test;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.test.IncompatibleTestDataException;
+import org.argeo.slc.test.TestData;
+import org.argeo.slc.test.TestDefinition;
+import org.argeo.slc.test.TestResult;
+import org.argeo.slc.test.TestRun;
+import org.argeo.slc.test.TestStatus;
+import org.argeo.slc.test.context.ContextAware;
+
+/** Understands basic test data and context aware test data. */
+public class BasicTestDefinition implements TestDefinition {
+
+       public void execute(TestRun testRun) {
+               if (testRun.<TestData> getTestData() instanceof BasicTestData) {
+                       BasicTestData testData = testRun.getTestData();
+                       TestResult result = testRun.getTestResult();
+
+                       if (result == null)
+                               throw new SlcException("No test result defined.");
+
+                       try {
+                               if (testData.getExpected().equals(testData.getReached())) {
+                                       result.addResultPart(new SimpleResultPart(
+                                                       TestStatus.PASSED, "Reached and expected equals"));
+                               } else {
+                                       result.addResultPart(new SimpleResultPart(
+                                                       TestStatus.FAILED, "Expected "
+                                                                       + testData.getExpected() + " but reached "
+                                                                       + testData.getReached()));
+                               }
+                       } catch (Exception e) {
+                               result.addResultPart(new SimpleResultPart(TestStatus.ERROR,
+                                               "Could not compare", e));
+                       }
+               } else if (testRun.<TestData> getTestData() instanceof ContextAware) {
+                       TestData testData = testRun.getTestData();
+                       ContextUtils.compareReachedExpected((ContextAware) testData,
+                                       testRun.getTestResult());
+               } else {
+                       throw new IncompatibleTestDataException(testRun);
+               }
+       }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/ContextUtils.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/ContextUtils.java
new file mode 100644 (file)
index 0000000..97d7305
--- /dev/null
@@ -0,0 +1,124 @@
+package org.argeo.slc.runtime.test;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.test.TestResult;
+import org.argeo.slc.test.TestStatus;
+import org.argeo.slc.test.context.ContextAware;
+import org.argeo.slc.test.context.ParentContextAware;
+
+/** Utilities for comparing and synchronising contexts. */
+public class ContextUtils {
+       private final static Log log = LogFactory.getLog(ContextUtils.class);
+
+       public static void compareReachedExpected(ContextAware contextAware,
+                       TestResult testResult) {
+               for (String key : contextAware.getExpectedValues().keySet()) {
+
+                       // Compare expected values with reached ones
+                       Object expectedValue = contextAware.getExpectedValues().get(key);
+
+                       if (expectedValue.toString().equals(
+                                       contextAware.getContextSkipFlag())) {
+                               if (log.isDebugEnabled())
+                                       log.debug("Skipped check for key '" + key + "'");
+                               continue;
+                       }
+
+                       if (contextAware.getValues().containsKey(key)) {
+                               Object reachedValue = contextAware.getValues().get(key);
+
+                               if (expectedValue.equals(contextAware.getContextAnyFlag())) {
+                                       testResult.addResultPart(new SimpleResultPart(
+                                                       TestStatus.PASSED, "Expected any value for key '"
+                                                                       + key + "'"));
+                               } else if (expectedValue.equals(reachedValue)) {
+                                       testResult.addResultPart(new SimpleResultPart(
+                                                       TestStatus.PASSED, "Values matched for key '" + key
+                                                                       + "'"));
+                               } else {
+                                       testResult.addResultPart(new SimpleResultPart(
+                                                       TestStatus.FAILED, "Mismatch for key '" + key
+                                                                       + "': expected '" + expectedValue
+                                                                       + "' but reached '" + reachedValue + "'"));
+                               }
+                       } else {
+                               testResult.addResultPart(new SimpleResultPart(
+                                               TestStatus.FAILED, "No value reached for key '" + key
+                                                               + "'"));
+                       }
+               }
+       }
+
+       /**
+        * Makes sure that all children and sub-children of parent share the same
+        * maps for values and expected values.
+        */
+       public static void synchronize(ParentContextAware parent) {
+               Map<String, Object> expectedValuesCommon = new TreeMap<String, Object>(
+                               parent.getExpectedValues());
+               synchronize(parent, expectedValuesCommon);
+               if (log.isDebugEnabled())
+                       log.debug("Synchronized context " + parent);
+
+       }
+
+       private static void synchronize(ParentContextAware parent,
+                       Map<String, Object> expectedValuesCommon) {
+               for (ContextAware child : parent.getChildContexts()) {
+                       // Values
+                       putNotContained(parent.getValues(), child.getValues());
+                       child.setValues(parent.getValues());
+
+                       // Expected Values
+                       // Expected values reference is not overridden: each child has its
+                       // own expected values map.
+                       overrideContained(expectedValuesCommon, child.getExpectedValues());
+
+                       // Creates a new Map in order not to disturb other context using the
+                       // same keys
+                       Map<String, Object> expectedValuesCommonChild = new TreeMap<String, Object>(
+                                       expectedValuesCommon);
+                       putNotContained(expectedValuesCommonChild,
+                                       child.getExpectedValues());
+
+                       if (child instanceof ParentContextAware) {
+                               // Recursive sync
+                               synchronize((ParentContextAware) child,
+                                               expectedValuesCommonChild);
+                       }
+               }
+
+       }
+
+       /**
+        * Put into common map the values from child map which are not already
+        * defined in common map.
+        */
+       public static void putNotContained(Map<String, Object> commonMap,
+                       Map<String, Object> childMap) {
+               for (String key : childMap.keySet()) {
+                       if (!commonMap.containsKey(key)) {
+                               commonMap.put(key, childMap.get(key));
+                       }
+               }
+       }
+
+       /** Overrides child map values with the values already set in common map */
+       public static void overrideContained(Map<String, Object> commonMap,
+                       Map<String, Object> childMap) {
+               for (String key : childMap.keySet()) {
+                       if (commonMap.containsKey(key)) {
+                               childMap.put(key, commonMap.get(key));
+                       }
+               }
+       }
+
+       /** Makes sure this cannot be instantiated. */
+       private ContextUtils() {
+
+       }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleResultPart.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleResultPart.java
new file mode 100644 (file)
index 0000000..7ba7464
--- /dev/null
@@ -0,0 +1,135 @@
+package org.argeo.slc.runtime.test;
+
+import java.io.Serializable;
+
+import org.argeo.slc.test.TestResultPart;
+import org.argeo.slc.test.TestRun;
+import org.argeo.slc.test.TestRunAware;
+import org.argeo.slc.test.TestStatus;
+
+/**
+ * <p>
+ * Basic implementation of a result part, implementing the standard three status
+ * approach for test results.
+ * </p>
+ * 
+ * @see TestStatus
+ */
+public class SimpleResultPart implements TestResultPart, TestStatus,
+               TestRunAware, Serializable {
+       private static final long serialVersionUID = 6669675957685071901L;
+
+       private Long tid;
+
+       private String testRunUuid;
+
+       /** The status. Default to ERROR since it should always be explicitely set. */
+       private Integer status = ERROR;
+       private String message;
+       private String exceptionMessage;
+
+       public SimpleResultPart() {
+       }
+
+       public SimpleResultPart(Integer status, String message) {
+               this(status, message, null);
+       }
+
+       public SimpleResultPart(Integer status, String message, Exception exception) {
+               this.status = status;
+               this.message = message;
+               setException(exception);
+       }
+
+       public String getMessage() {
+               return message;
+       }
+
+       public void setMessage(String message) {
+               this.message = message;
+       }
+
+       public void setStatus(Integer status) {
+               this.status = status;
+       }
+
+       public Integer getStatus() {
+               return status;
+       }
+
+       public String getExceptionMessage() {
+               return exceptionMessage;
+       }
+
+       public void setException(Exception exception) {
+               if (exception == null)
+                       return;
+
+               StringBuffer buf = new StringBuffer("");
+               buf.append(exception.toString());
+               buf.append('\n');
+               for (StackTraceElement elem : exception.getStackTrace()) {
+                       buf.append('\t').append(elem.toString()).append('\n');
+               }
+
+               if (exception.getCause() != null)
+                       addRootCause(buf, exception.getCause());
+
+               this.exceptionMessage = buf.toString();
+       }
+
+       protected void addRootCause(StringBuffer buf, Throwable cause) {
+               if (cause == null)
+                       return;
+
+               buf.append("Caused by: " + cause.getMessage());
+               for (StackTraceElement elem : cause.getStackTrace()) {
+                       buf.append('\t').append(elem.toString()).append('\n');
+               }
+
+               if (cause.getCause() != null) {
+                       addRootCause(buf, cause.getCause());
+               }
+       }
+
+       @Override
+       public String toString() {
+               StringBuffer buf = new StringBuffer("");
+               buf.append(SlcTestUtils.statusToString(status));
+               if (status == PASSED || status == FAILED) {
+                       buf.append(' ');
+               } else if (status == ERROR) {
+                       buf.append("  ");
+               }
+               buf.append(message);
+               return buf.toString();
+       }
+
+       /** @deprecated */
+       Long getTid() {
+               return tid;
+       }
+
+       /** @deprecated */
+       void setTid(Long tid) {
+               this.tid = tid;
+       }
+
+       public String getTestRunUuid() {
+               return testRunUuid;
+       }
+
+       /** For ORM */
+       public void setTestRunUuid(String testRunUuid) {
+               this.testRunUuid = testRunUuid;
+       }
+
+       public void notifyTestRun(TestRun testRun) {
+               testRunUuid = testRun.getUuid();
+       }
+
+       public void setExceptionMessage(String exceptionMessage) {
+               this.exceptionMessage = exceptionMessage;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestResult.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestResult.java
new file mode 100644 (file)
index 0000000..3791a7e
--- /dev/null
@@ -0,0 +1,88 @@
+package org.argeo.slc.runtime.test;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.UUID;
+import java.util.Vector;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.test.TestResult;
+import org.argeo.slc.test.TestResultPart;
+import org.argeo.slc.test.TestRun;
+
+/**
+ * Basic implementation of a test result containing only a list of result parts.
+ */
+public class SimpleTestResult implements TestResult {
+       private static Log log = LogFactory.getLog(SimpleTestResult.class);
+
+       private String uuid;
+       private String currentTestRunUuid;
+
+       private Boolean throwError = true;
+
+       private Date closeDate;
+       private List<TestResultPart> parts = new Vector<TestResultPart>();
+
+       private Map<String, String> attributes = new TreeMap<String, String>();
+
+       public void addResultPart(TestResultPart part) {
+               if (throwError && part.getStatus() == ERROR) {
+                       throw new SlcException(
+                                       "There was an error in the underlying test: "
+                                                       + part.getExceptionMessage());
+               }
+               parts.add(part);
+               if (log.isDebugEnabled())
+                       log.debug(part);
+       }
+
+       public void close() {
+               parts.clear();
+               closeDate = new Date();
+       }
+
+       public List<TestResultPart> getParts() {
+               return parts;
+       }
+
+       public Date getCloseDate() {
+               return closeDate;
+       }
+
+       public void setThrowError(Boolean throwError) {
+               this.throwError = throwError;
+       }
+
+       public void notifyTestRun(TestRun testRun) {
+               currentTestRunUuid = testRun.getUuid();
+       }
+
+       public String getUuid() {
+               if (uuid == null) {
+                       uuid = UUID.randomUUID().toString();
+               }
+               return uuid;
+       }
+
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+
+       public String getCurrentTestRunUuid() {
+               return currentTestRunUuid;
+       }
+
+       public Map<String, String> getAttributes() {
+               return attributes;
+       }
+
+       public void setAttributes(Map<String, String> attributes) {
+               this.attributes = attributes;
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestRun.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SimpleTestRun.java
new file mode 100644 (file)
index 0000000..bc01452
--- /dev/null
@@ -0,0 +1,95 @@
+package org.argeo.slc.runtime.test;
+
+import java.util.UUID;
+
+import org.argeo.slc.deploy.DeployedSystem;
+import org.argeo.slc.test.ExecutableTestRun;
+import org.argeo.slc.test.TestData;
+import org.argeo.slc.test.TestDefinition;
+import org.argeo.slc.test.TestResult;
+import org.argeo.slc.test.WritableTestRun;
+
+/**
+ * A basic bean implementation of a <code>WritableTestRun</code>, holding
+ * references to the various parts of a test run.
+ */
+public class SimpleTestRun implements WritableTestRun, ExecutableTestRun {
+       private String uuid;
+
+       // private String slcExecutionUuid;
+       // private String slcExecutionStepUuid;
+
+       private DeployedSystem deployedSystem;
+       private TestData testData;
+       private TestDefinition testDefinition;
+       private TestResult testResult;
+
+       /** Executes the underlying test definition. */
+       public void run() {
+               uuid = UUID.randomUUID().toString();
+               if (testResult != null)
+                       testResult.notifyTestRun(this);
+
+               testDefinition.execute(this);
+       }
+
+       @SuppressWarnings("unchecked")
+       public <T extends DeployedSystem> T getDeployedSystem() {
+               return (T) deployedSystem;
+       }
+
+       public void setDeployedSystem(DeployedSystem deployedSystem) {
+               this.deployedSystem = deployedSystem;
+       }
+
+       @SuppressWarnings("unchecked")
+       public <T extends TestData> T getTestData() {
+               return (T) testData;
+       }
+
+       public void setTestData(TestData testData) {
+               this.testData = testData;
+       }
+
+       @SuppressWarnings("unchecked")
+       public <T extends TestDefinition> T getTestDefinition() {
+               return (T) testDefinition;
+       }
+
+       public void setTestDefinition(TestDefinition testDefinition) {
+               this.testDefinition = testDefinition;
+       }
+
+       @SuppressWarnings("unchecked")
+       public <T extends TestResult> T getTestResult() {
+               return (T) testResult;
+       }
+
+       public void setTestResult(TestResult testResult) {
+               this.testResult = testResult;
+       }
+
+       public String getUuid() {
+               return uuid;
+       }
+
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+
+       // public String getSlcExecutionUuid() {
+       // return slcExecutionUuid;
+       // }
+       //
+       // public void setSlcExecutionUuid(String slcExecutionUuid) {
+       // this.slcExecutionUuid = slcExecutionUuid;
+       // }
+       //
+       // public String getSlcExecutionStepUuid() {
+       // return slcExecutionStepUuid;
+       // }
+       //
+       // public void setSlcExecutionStepUuid(String slcExecutionStepUuid) {
+       // this.slcExecutionStepUuid = slcExecutionStepUuid;
+       // }
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SlcTestUtils.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/SlcTestUtils.java
new file mode 100644 (file)
index 0000000..5275d0f
--- /dev/null
@@ -0,0 +1,35 @@
+package org.argeo.slc.runtime.test;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.test.TestStatus;
+
+public abstract class SlcTestUtils {
+       public static String statusToString(Integer status) {
+               if (status.equals(TestStatus.PASSED)) {
+                       return TestStatus.STATUSSTR_PASSED;
+               } else if (status.equals(TestStatus.FAILED)) {
+                       return TestStatus.STATUSSTR_FAILED;
+               } else if (status.equals(TestStatus.ERROR)) {
+                       return TestStatus.STATUSSTR_ERROR;
+               } else {
+                       throw new SlcException("Unrecognized status " + status);
+               }
+       }
+
+       public static Integer stringToStatus(String statusStr) {
+               if (statusStr.equals(TestStatus.STATUSSTR_PASSED)) {
+                       return TestStatus.PASSED;
+               } else if (statusStr.equals(TestStatus.STATUSSTR_FAILED)) {
+                       return TestStatus.FAILED;
+               } else if (statusStr.equals(TestStatus.STATUSSTR_ERROR)) {
+                       return TestStatus.ERROR;
+               } else {
+                       throw new SlcException("Unrecognized status string " + statusStr);
+               }
+       }
+
+       private SlcTestUtils() {
+
+       }
+
+}
diff --git a/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java b/org.argeo.slc.runtime/src/org/argeo/slc/runtime/test/TestDataUtils.java
new file mode 100644 (file)
index 0000000..872f1a5
--- /dev/null
@@ -0,0 +1,48 @@
+package org.argeo.slc.runtime.test;
+
+import org.argeo.slc.UnsupportedException;
+import org.argeo.slc.test.TestData;
+import org.argeo.slc.test.TestDataProvider;
+
+/** Utilities for dealing with test datas. */
+public class TestDataUtils {
+       /** Extracts the test data from the given provider. */
+       public static <T extends TestData> T getFromProvider(Object obj,
+                       Class<T> clss, String key) {
+               if (obj instanceof TestDataProvider) {
+                       TestDataProvider testDataProvider = (TestDataProvider) obj;
+                       return testDataProvider.getTestData(clss, key);
+               } else {
+                       throw new UnsupportedException("test data provider", obj);
+               }
+       }
+
+       /**
+        * Extracts the test data from the given provider using <code>null</code>
+        * as key.
+        */
+       public static <T extends TestData> T getFromProvider(Object obj,
+                       Class<T> clss) {
+               return getFromProvider(obj, clss, null);
+       }
+
+       /**
+        * Returns it self after making the proper checks. Used for test data being
+        * their own data providers.
+        */
+       @SuppressWarnings("unchecked")
+       public static <T extends TestData> T getItSelf(Class<T> clss,
+                       TestData testDataObject) {
+               if (clss.isAssignableFrom(testDataObject.getClass())) {
+                       return (T) testDataObject;
+               } else {
+                       throw new UnsupportedException("test data", testDataObject);
+               }
+
+       }
+
+       /** Makes sure this is an utility class. */
+       private TestDataUtils() {
+
+       }
+}
diff --git a/pom.xml b/pom.xml
index 9eca86166b0b5f09285d0a065309fb9b7fec9239..68da924b8fccc99fd78cb1d909ca42b8ed9ec383 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@
                <version.argeo-tp-extras>2.1.13</version.argeo-tp-extras>
                <version.argeo-commons>2.3-SNAPSHOT</version.argeo-commons>
 
-               <version.slc>2.3.1-SNAPSHOT</version.slc>
+               <version.slc>2.3-SNAPSHOT</version.slc>
                <developmentCycle.startDate>2015-02-12</developmentCycle.startDate>
                <developmentCycle.slc>2.3</developmentCycle.slc>
                <version.argeo-commons-legacy>2.1.86</version.argeo-commons-legacy>
                <argeo.rpm.stagingRepository>/srv/rpmfactory/unstable/argeo-osgi-2/argeo</argeo.rpm.stagingRepository>
        </properties>
        <modules>
-               <!-- Legacy UI -->
-               <module>legacy</module>
+               <!-- SLC framework -->
+               <module>org.argeo.slc.api</module>
+               <module>org.argeo.slc.runtime</module>
+               <module>org.argeo.slc.jcr</module>
+               <module>org.argeo.slc.repo</module>
+               <module>org.argeo.slc.factory</module>
+               
+               <!-- CMS extensions -->
                <module>cms</module>
 
+               <!-- Legacy -->
+               <module>legacy</module>
+
                <!-- Distribution -->
-               <module>lib</module>
                <module>dep</module>
-               <module>demo</module>
                <module>ide</module>
        </modules>
        <url>http://projects.argeo.org/slc/</url>
                        <distribution>repo</distribution>
                </license>
        </licenses>
+       <dependencies>
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>argeo-tp</artifactId>
+                       <version>${version.argeo-tp}</version>
+                       <scope>provided</scope>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.apache</groupId>
+                                       <artifactId>org.apache.xerces</artifactId>
+                               </exclusion>
+                               <!-- Avoid slf4j implementations lurking in the classpath. -->
+                               <exclusion>
+                                       <groupId>org.argeo.tp.sdk</groupId>
+                                       <artifactId>biz.aQute.bndlib</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>org.argeo.tp.misc</groupId>
+                                       <artifactId>slf4j.osgi</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+       </dependencies>
        <dependencyManagement>
                <dependencies>
                        <dependency>