From 95e33a55340c3315e3d7547da0ead9e22707ca74 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 20 Sep 2012 19:43:45 +0000 Subject: [PATCH] implements merging repositories in the new ui git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1388178 13f79535-47bb-0310-9956-ffa450edef68 --- .../DefaultMergeRepositoriesService.java | 2 + .../apache/archiva/i18n/default.properties | 2 + .../main/webapp/js/archiva/repositories.js | 100 ++++++++++++++++++ .../webapp/js/templates/archiva/modal.html | 10 ++ .../js/templates/archiva/repositories.html | 39 +++++++ 5 files changed, 153 insertions(+) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java index 26cc07c54..d309c9889 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultMergeRepositoriesService.java @@ -50,6 +50,8 @@ public class DefaultMergeRepositoriesService implements MergeRepositoriesService { + // FIXME check archiva-merge-repository to sourceRepoId + @Inject @Named ( value = "repositoryMerger#maven2" ) private Maven2RepositoryMerger repositoryMerger; diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index 45c6ce5e8..2848daa57 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -98,6 +98,8 @@ skipPackedIndexCreation=Skip Packed Index creation skipPackedIndexCreation.help.title=Skip Packed Index creation skipPackedIndexCreation.help.content=Will prevent creating packed and incremental indexes which are consumed by remote repositories manager and/or IDE. managedrepository.actions=Actions +managedrepository.repomerge.dialog.header=Choose a target repository for merging +managedrepository.mergerepo=Merge this repository # remote repositories screen remoterepository.downloadremoteindex.now=Download Remote Index Now diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js index 236f0a117..132031560 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js @@ -526,8 +526,108 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery } + mergeRepo=function(managedRepository){ + $("#user-messages" ).html(mediumSpinnerImg()); + // is there any artifacts to merge ? + var artifactsNumberUrl = "restServices/archivaServices/browseService/artifacts/"+encodeURIComponent(managedRepository.id()); + $.ajax(artifactsNumberUrl,{ + type: "GET", + dataType: 'json', + success: function(data){ + var artifacts=mapArtifacts(data); + $.log("artifactsNumber for '" + managedRepository.id() + "': " + artifacts.length); + + if (artifacts<1){ + displayWarningMessage($.i18n.prop("managedrepository.merge.noartifacts", managedRepository.id())); + return; + } + + $.log("merge repo open dialog"); + var dialogMergeRepo=$("#dialog-modal-merge-repo"); + if (window.modalMergeRepoDialog==null) { + window.modalMergeRepoDialog = dialogMergeRepo.modal(); + + } + + loadManagedRepositories(function(data){ + + var managedRepositories = $.map(mapManagedRepositories(data), function(item) { + return item.id()==managedRepository.id()?null:item; + }); + $("#dialog-modal-merge-repo-body-text").html($("#merge-repo-dialog-content" ) + .tmpl({sourceRepoId:managedRepository.id(),repositories:managedRepositories})); + window.modalMergeRepoDialog.modal('show'); + }); + + }, + complete: function(){ + $.log("complete removeMediumSpinnerImg"); + removeMediumSpinnerImg("#user-messages"); + } + } + ); + + } + + + } + + + mergeRepositories=function(sourceRepository,targetRepository){ + $.log("mergeRepositories:"+sourceRepository+":"+targetRepository); + + var mergeRepoDialogBodyId="dialog-modal-merge-repo-body-text"; + var mergeRepoDialogBody=$("#"+mergeRepoDialogBodyId); + mergeRepoDialogBody.html(mediumSpinnerImg()); + + // check conflicts + var url = "restServices/archivaServices/mergeRepositoriesService/mergeConflictedArtifacts/"+encodeURIComponent(sourceRepository); + url+="/"+encodeURIComponent(targetRepository); + $.ajax(url, { + type: "GET", + dataType: 'json', + success: function(data){ + var artifacts=mapArtifacts(data); + if (artifacts && artifacts.length){ + // we have conflicts ask to skip or not + $.log("conflicts:"+artifacts.length); + displayWarningMessage($.i18n.prop("managedrepository.merge.conflicts", artifacts.length),"dialog-modal-merge-repo-body-text"); + $.tmpl($("#merge-repo-skip-conflicts").html(), + { artifacts:artifacts, sourceRepository: sourceRepository, targetRepository:targetRepository }) + .appendTo( "#dialog-modal-merge-repo-body-text" ); + } else { + doMerge(sourceRepository,targetRepository,false); + } + }, + complete: function(){ + $.log("complete removeMediumSpinnerImg"); + removeMediumSpinnerImg("#dialog-modal-merge-repo-body-text"); + } + }); + + + + } + + doMerge=function(sourceRepository,targetRepository,skipConflicts){ + $.log("doMerge:"+sourceRepository+" to " + targetRepository + ", skipConflicts: " + skipConflicts); + window.modalMergeRepoDialog.modal('hide'); + $("#user-messages" ).html(mediumSpinnerImg()); + var url = "restServices/archivaServices/mergeRepositoriesService/mergeRepositories/"+encodeURIComponent(sourceRepository); + url+="/"+encodeURIComponent(targetRepository); + url+="/"+skipConflicts; + $.ajax(url, { + type: "GET", + dataType: 'json', + success: function(data){ + displaySuccessMessage($.i18n.prop("managedrepository.merge.success", sourceRepository,targetRepository)); + }, + complete: function(){ + removeMediumSpinnerImg("#user-messages"); + } + }); } activateManagedRepositoriesGridTab=function(){ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/modal.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/modal.html index 890d1abf2..e447e9a44 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/modal.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/modal.html @@ -28,4 +28,14 @@ ${$.i18n.prop('cancel')} ${$.i18n.prop('ok')} + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html index 957c8cea5..2b52399d9 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html @@ -146,6 +146,20 @@ ${$.i18n.prop('managedrepository.pomsnippet')} +
  • + {{if row.stageRepoNeeded()}} + stage + {{/if}} +
  • +
  • + + + + + + ${$.i18n.prop('managedrepository.mergerepo')} + +
  • @@ -1177,4 +1191,29 @@
    ${$.i18n.prop('warning.not.undone.operation')}
    + + + + + + \ No newline at end of file -- 2.39.5