aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-10-26 12:58:50 +0000
committerOlivier Lamy <olamy@apache.org>2012-10-26 12:58:50 +0000
commit30ffd9ee14cad99bb72590f18b168cda44d5c02e (patch)
tree68c2c8837d943ed46cf9d8eac883dcf3cadc8fc5
parent24164038d9f44c7c4f67f8c86a57237fd156bb31 (diff)
downloadarchiva-30ffd9ee14cad99bb72590f18b168cda44d5c02e.tar.gz
archiva-30ffd9ee14cad99bb72590f18b168cda44d5c02e.zip
[MRM-1705] Feature to add custom parameters and/or headers when requesting an external repositories.
implements ui for extra headers. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1402495 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties5
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js36
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html28
3 files changed, 67 insertions, 2 deletions
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 bdf72b627..ac9059a0d 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
@@ -37,6 +37,9 @@ url=Url
directory=Directory
save.all=Save all
common.loading=Loading...
+key=Key
+value=Value
+key.empty.error.message=Key cannot be empty
authz.karma.needed=You need to be authenticated for this action or have more privileges.
error.500=An error has happened you must contact the administrator to check the logs.
@@ -160,6 +163,8 @@ remoterepository.download.remote.full=Full download ?
remoterepository.download.remote.scheduled=Download Remote Index of repository {0} scheduled.
remoterepository.delete.confirm=Are you sure to delete Remote Repository {0} ?
remoterepository.deleted=Remote repository {0} deleted.
+remoteRepository.extraParametersEntries=Additionnal url parameters
+remoteRepository.extraHeadersEntries=Additionnal Http Headers
#network proxy
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 4d605a8e9..0b961f8fe 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
@@ -877,7 +877,12 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
addExtraParameter=function(){
var mainContent=$("#main-content");
+ mainContent.find("#extra-parameters-error" ).html("");
var key=mainContent.find("#extraParameter-key").val();
+ if($.trim(key).length<1){
+ displayErrorMessage( $.i18n.prop("key.empty.error.message"),"extra-parameters-error");
+ return;
+ }
var value=mainContent.find("#extraParameter-value").val();
$.log("addExtraParameter="+key+":"+value);
var oldTab = self.remoteRepository.extraParametersEntries();
@@ -898,6 +903,37 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
}
}
+ addExtraHeader=function(){
+
+ var mainContent=$("#main-content");
+ mainContent.find("#extra-headers-error" ).html("");
+ var key=mainContent.find("#extraHeader-key").val();
+ if( $.trim(key).length<1){
+ if($.trim(key).length<1){
+ displayErrorMessage( $.i18n.prop("key.empty.error.message"),"extra-headers-error");
+ return;
+ }
+ }
+ var value=mainContent.find("#extraHeader-value").val();
+ $.log("addExtraParameter="+key+":"+value);
+ var oldTab = self.remoteRepository.extraHeadersEntries();
+ oldTab.push(new Entry(key,value));
+ self.remoteRepository.extraHeadersEntries(oldTab);
+ mainContent.find("#extraHeader-key").val("");
+ mainContent.find("#extraHeader-value").val("");
+ self.remoteRepository.modified(true);
+ }
+
+ deleteExtraHeader=function(key){
+ for(var i=0;i<self.remoteRepository.extraHeadersEntries().length;i++){
+ var entry=self.remoteRepository.extraHeadersEntries()[i];
+ if (entry.key==key){
+ self.remoteRepository.extraHeadersEntries.remove(entry);
+ self.remoteRepository.modified(true);
+ }
+ }
+ }
+
}
RemoteRepositoriesViewModel=function(){
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 b87750654..2eab91934 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
@@ -629,10 +629,11 @@
<div class="row-fluid">
<div class="control-group span6">
<h4>${$.i18n.prop('remoteRepository.extraParametersEntries')}</h4>
+ <div id="extra-parameters-error"></div>
<table class="table">
<thead>
- <th><input type="text" id="extraParameter-key"/></th>
- <th><input type="text" id="extraParameter-value"/></th>
+ <th>${$.i18n.prop('key')}:<input type="text" id="extraParameter-key"/></th>
+ <th>${$.i18n.prop('value')}:<input type="text" id="extraParameter-value"/></th>
<th><a href="#" data-bind="click: function(){ addExtraParameter() }">${$.i18n.prop('add')}</a></th>
</thead>
<tbody>
@@ -648,6 +649,29 @@
</div>
</div>
+ <div class="row-fluid">
+ <div class="control-group span6">
+ <h4>${$.i18n.prop('remoteRepository.extraHeadersEntries')}</h4>
+ <div id="extra-headers-error"></div>
+ <table class="table">
+ <thead>
+ <th>${$.i18n.prop('key')}:<input type="text" id="extraHeader-key"/></th>
+ <th>${$.i18n.prop('value')}:<input type="text" id="extraHeader-value"/></th>
+ <th><a href="#" data-bind="click: function(){ addExtraHeader() }">${$.i18n.prop('add')}</a></th>
+ </thead>
+ <tbody>
+ {{each(i, extraHeaderEntry) remoteRepository.extraHeadersEntries}}
+ <tr>
+ <td>${extraHeaderEntry.key}</td>
+ <td>${extraHeaderEntry.value}</td>
+ <td><a href="#" data-bind="click: function(){ deleteExtraHeader(extraHeaderEntry.key)}">${$.i18n.prop('delete')}</a></td>
+ </tr>
+ {{/each}}
+ </tbody>
+ </table>
+ </div>
+ </div>
+
</fieldset>
<button data-bind="click: save" data-loading-text="${$.i18n.prop('common.loading')}" id="remote-repository-save-button" class="btn">${$.i18n.prop('save')}</button>
<button data-bind="click: displayGrid" class="btn">${$.i18n.prop('cancel')}</button>