]> source.dussan.org Git - archiva.git/blob
afdc7c146c1b096d3e6dcace9383c07a4fa01294
[archiva.git] /
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *   http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 define("archiva/admin/repository/10maven2/proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout"
20   ,"knockout.simpleGrid","knockout.sortable","select2"],
21   function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
22
23   ProxyConnector=function(sourceRepoId,targetRepoId,proxyId,blackListPatterns,whiteListPatterns,policiesEntries,propertiesEntries,
24                           disabled,order){
25     var self=this;
26
27     this.modified=ko.observable(false);
28
29     //private String sourceRepoId;
30     this.sourceRepoId=ko.observable(sourceRepoId);
31     this.sourceRepoId.subscribe(function(newValue){
32       self.modified(true);
33     });
34
35     //private String targetRepoId;
36     this.targetRepoId=ko.observable(targetRepoId);
37     this.targetRepoId.subscribe(function(newValue){
38       self.modified(true);
39     });
40
41     this.previousProxyId=proxyId;
42
43     //private String proxyId;
44     this.proxyId=ko.observable(proxyId);
45     this.proxyId.subscribe(function(newValue){
46       if(newValue!=self.previousProxyId){
47         $.log("proxyId modified:"+newValue+",previous:"+self.previousProxyId);
48         self.previousProxyId=newValue;
49         self.modified(true);
50       }
51     });
52
53     //private List<String> blackListPatterns;
54     this.blackListPatterns=ko.observableArray(blackListPatterns==null?[]:blackListPatterns);
55     this.blackListPatterns.subscribe(function(newValue){
56       self.modified(true);
57     });
58
59     //private List<String> whiteListPatterns;
60     this.whiteListPatterns=ko.observableArray(whiteListPatterns==null?[]:whiteListPatterns);
61     this.whiteListPatterns.subscribe(function(newValue){
62       self.modified(true);
63     });
64
65     //private List<PropertyEntry> policiesEntries;
66     this.policiesEntries=ko.observableArray(policiesEntries==null?new Array():policiesEntries);
67     this.policiesEntries.subscribe(function(newValue){
68       self.modified(true);
69     });
70
71     //private List<PropertyEntry> properties;
72     this.propertiesEntries=ko.observableArray(propertiesEntries==null?new Array():propertiesEntries);
73     this.propertiesEntries.subscribe(function(newValue){
74       self.modified(true);
75     });
76
77     //private boolean disabled = false;
78     this.disabled=ko.observable(disabled);
79     this.disabled.subscribe(function(newValue){
80       self.modified(true);
81     });
82
83     //private int order = 0;
84     this.order=ko.observable(order?order:0);
85     this.order.subscribe(function(newValue){
86       self.modified(true);
87     });
88
89
90
91     this.updatePolicyEntry=function(key,value){
92       $.log("updatePolicyEntry:"+key+":"+value);
93       var found=false;
94       for(var i=0;i<self.policiesEntries().length;i++){
95         if (self.policiesEntries()[i].key==key){
96           self.policiesEntries()[i].value=value;
97           found=true;
98           self.modified(true);
99         }
100       }
101       if(!found){
102         self.policiesEntries().push(new Entry(key,value));
103       }
104     }
105
106   }
107
108   PolicyInformation=function(options,defaultOption,id,name){
109
110     var self=this;
111     this.modified=ko.observable(false);
112
113     //private List<String> options;
114     this.options=ko.observableArray(options);
115     this.options.subscribe(function(newValue){self.modified(true)});
116
117     //private String defaultOption;
118     this.defaultOption=ko.observable(defaultOption);
119     this.defaultOption.subscribe(function(newValue){self.modified(true)});
120
121     //private String id;
122     this.id=ko.observable(id);
123     this.id.subscribe(function(newValue){self.modified(true)});
124
125     //private String name;
126     this.name=ko.observable(name);
127     this.name.subscribe(function(newValue){self.modified(true)});
128
129   }
130
131   ProxyConnectorViewModel=function(proxyConnector,update,proxyConnectorsViewModel){
132     var self=this;
133     this.proxyConnector=proxyConnector;
134     this.proxyConnectorsViewModel=proxyConnectorsViewModel;
135     this.update=update;
136     this.modified=ko.observable(false);
137
138     isUpdate=function(){
139       return self.update;
140     }
141
142     getSelectedPolicyOption=function(id){
143       var policiesEntries=self.proxyConnector.policiesEntries();
144       if (policiesEntries!=null){
145         for (i=0;i<policiesEntries.length;i++){
146           var curKey = $.isFunction(policiesEntries[i].key)? policiesEntries[i].key():policiesEntries[i].key;
147           if (id==curKey){
148             return $.isFunction(policiesEntries[i].value)? policiesEntries[i].value():policiesEntries[i].value;
149           }
150         }
151       }
152       return "";
153     }
154
155     changePolicyOption=function(id){
156       var selectedOption=$("#main-content").find("#policy-"+id ).find("option:selected");
157       if (selectedOption.length>0){
158         var value = selectedOption.val();
159         $.log("changePolicyOption:"+id+":"+value);
160         self.proxyConnector.updatePolicyEntry(id,value);
161
162       }
163     }
164
165
166     getPolicyOptions=function(id){
167       var policyInformations=self.proxyConnectorsViewModel.policyInformations();
168       for(var i=0;i<policyInformations.length;i++){
169         if (policyInformations[i].id()==id){
170           return policyInformations[i].options();
171         }
172       }
173     }
174
175
176
177     addBlacklistPattern=function(){
178       var pattern = $("#main-content").find("#blacklist-value").val();
179       var tab =  self.proxyConnector.blackListPatterns();
180       tab.push(pattern);
181       self.proxyConnector.blackListPatterns(tab);
182       self.proxyConnector.modified(true);
183     }
184
185     removeBlacklistPattern=function(pattern){
186       self.proxyConnector.blackListPatterns.remove(pattern);
187       self.proxyConnector.modified(true);
188     }
189
190     addWhitelistPattern=function(){
191       var pattern = $("#main-content" ).find("#whitelist-value").val();
192       var tab =  self.proxyConnector.whiteListPatterns();
193       tab.push(pattern);
194       self.proxyConnector.whiteListPatterns(tab);
195       self.proxyConnector.modified(true);
196
197     }
198
199     removeWhitelistPattern=function(pattern){
200       self.proxyConnector.whiteListPatterns.remove(pattern);
201       self.proxyConnector.modified(true);
202     }
203
204     this.save=function(){
205       //FIXME data controls !!!
206       clearUserMessages();
207       var userMessages=$("#user-messages");
208       userMessages.html(mediumSpinnerImg());
209       $("#proxy-connector-btn-save" ).button("loading");
210       // update is delete then add
211       if (this.update){
212         $.ajax("restServices/archivaServices/proxyConnectorService/updateProxyConnector",
213           {
214             type: "POST",
215             data: ko.toJSON(self.proxyConnector),
216             contentType: 'application/json',
217             dataType: 'json',
218             success: function(data) {
219               displaySuccessMessage($.i18n.prop('proxyconnector.updated'));
220               activateProxyConnectorsGridTab();
221               self.proxyConnector.modified(false);
222             },
223             error: function(data) {
224               var res = $.parseJSON(data.responseText);
225               displayRestError(res);
226             },
227             complete: function(){
228               removeMediumSpinnerImg(userMessages);
229               $("#proxy-connector-btn-save" ).button("reset");
230             }
231           }
232         );
233       } else {
234
235         $.ajax("restServices/archivaServices/proxyConnectorService/addProxyConnector",
236           {
237             type: "POST",
238             data: ko.toJSON(self.proxyConnector),
239             contentType: 'application/json',
240             dataType: 'json',
241             success: function(data) {
242               displaySuccessMessage($.i18n.prop('proxyconnector.added'));
243               activateProxyConnectorsGridTab();
244               self.proxyConnector.modified(false);
245               self.proxyConnectorsViewModel.proxyConnectors.push(self.proxyConnector);
246             },
247             error: function(data) {
248               var res = $.parseJSON(data.responseText);
249               displayRestError(res);
250             },
251             complete: function(){
252               removeMediumSpinnerImg(userMessages);
253               $("#proxy-connector-btn-save" ).button("reset");
254             }
255           }
256         );
257       }
258     }
259
260     this.deleteProperty=function(key){
261       for(var i=0;i<self.proxyConnector.propertiesEntries().length;i++){
262         var entry=self.proxyConnector.propertiesEntries()[i];
263         if (entry.key()==key()){
264           self.proxyConnector.propertiesEntries.remove(entry);
265           self.proxyConnector.modified(true);
266         }
267       }
268
269     }
270
271     this.addProperty=function(){
272       var mainContent=$("#main-content");
273       var key=mainContent.find("#property-key").val();
274       var value=mainContent.find("#property-value").val();
275       var oldTab = self.proxyConnector.propertiesEntries();
276       oldTab.push(new Entry(key,value));
277       self.proxyConnector.propertiesEntries(oldTab);
278       mainContent.find("#property-key").val("");
279       mainContent.find("#property-value").val("");
280       self.proxyConnector.modified(true);
281     }
282
283     displayGrid=function(){
284       activateProxyConnectorsGridTab();
285     }
286   }
287
288   ProxyConnectorsViewModel=function(){
289     var self=this;
290     this.proxyConnectors=ko.observableArray([]);
291     this.proxyConnectors.subscribe(function(newValue){
292       $.log("ProxyConnectorsViewModel#proxyConnectors modified");
293       self.proxyConnectors().sort(function(a,b){
294         if ( a.sourceRepoId()== b.sourceRepoId()) return a.order() - b.order();
295         return (a.sourceRepoId() > b.sourceRepoId())? -1:1;
296       });
297     });
298     this.policyInformations=ko.observableArray([]);
299     this.managedRepositories=ko.observableArray([]);
300     this.remoteRepositories=ko.observableArray([]);
301     this.networkProxies=ko.observableArray([]);
302
303     this.bulkSave=function(){
304       return getModifiedProxyConnectors().length>0;
305     }
306
307     getModifiedProxyConnectors=function(){
308       var prx = $.grep(self.proxyConnectors(),
309           function (proxyConnector,i) {
310             return proxyConnector.modified();
311           });
312       return prx;
313     }
314
315     this.updateModifiedProxyConnectors=function(){
316       var modifiedProxyConnectors = getModifiedProxyConnectors();
317
318       openDialogConfirm(function(){
319                           for(var i=0;i<modifiedProxyConnectors.length;i++){
320                             var viewModel = new ProxyConnectorViewModel(modifiedProxyConnectors[i],true,self,false);
321                             viewModel.save();
322                           }
323                           closeDialogConfirm();
324                         },
325                         $.i18n.prop('ok'),
326                         $.i18n.prop('cancel'),
327                         $.i18n.prop('proxy-connectors.bulk.save.confirm.title'),
328                         $.i18n.prop('proxy.connector.bulk.save.confirm',modifiedProxyConnectors.length));
329     }
330
331     updateProxyConnector=function(proxyConnector){
332       var viewModel = new ProxyConnectorViewModel(proxyConnector,true,self,false);
333       viewModel.save();
334     }
335
336     editProxyConnector=function(proxyConnector){
337       var proxyConnectorViewModel=new ProxyConnectorViewModel(proxyConnector,true,self);
338       var mainContent = $("#main-content");
339       mainContent.find("#proxy-connectors-edit").html($("#proxy-connector-edit-form-tmpl").tmpl());
340       ko.applyBindings(proxyConnectorViewModel,mainContent.find("#proxy-connectors-edit").get(0));
341       activateProxyConnectorsEditTab();
342       mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("edit"));
343     }
344
345     deleteProxyConnector=function(proxyConnector){
346
347       openDialogConfirm(
348           function(){
349             clearUserMessages();
350             removeProxyConnector(proxyConnector,function(){
351             displaySuccessMessage($.i18n.prop('proxyconnector.removed'));
352             self.proxyConnectors.remove(proxyConnector);
353             closeDialogConfirm();
354           })}, $.i18n.prop('ok'), $.i18n.prop('cancel'), $.i18n.prop('proxyconnector.delete.confirm'),
355           $("#proxy-connector-delete-warning-tmpl").tmpl(proxyConnector));
356
357
358     }
359
360
361     getManagedRepository=function(id){
362       return findManagedRepository(id,self.managedRepositories());
363     }
364
365     getRemoteRepository=function(id){
366       var remoteRepository=$.grep(self.remoteRepositories(),
367                                       function(repo,idx){
368                                         return repo.id()==id;
369                                       }
370                             );
371       return ($.isArray(remoteRepository) && remoteRepository.length>0) ? remoteRepository[0]:new RemoteRepository();
372     }
373
374     getProxyConnector=function(sourceRepoId,targetRepoId){
375       var proxyConnectors=$.grep(self.proxyConnectors(),
376                                       function(proxyConnector,idx){
377                                         return proxyConnector.sourceRepoId()==sourceRepoId
378                                             && proxyConnector.targetRepoId()==targetRepoId;
379                                       }
380                                   );
381       var res = ($.isArray(proxyConnectors) && proxyConnectors.length>0) ? proxyConnectors[0]:new ProxyConnector();
382       return res;
383     }
384     showSettings=function(){
385       $.log("showSettings");
386       $("#body_content" ).find(".popover" ).hide();
387       //$("#main-content").find("[id^='proxy-connectors-grid-remoterepo-settings-edit-']" ).popover("hide");
388     }
389     buildSettings=function(proxyConnector){
390       var tmplHtml = $("#proxy-connectors-remote-settings-popover-tmpl")
391                                            .tmpl({
392                                                 proxyConnectorsViewModel: self,
393                                                 proxyConnector:ko.toJS(proxyConnector)
394                                                 } ).html();
395
396       var targetImg = $(("#proxy-connectors-grid-remoterepo-settings-edit-")
397                             +proxyConnector.sourceRepoId().replace(/\./g,"\\\.")+"-"+proxyConnector.targetRepoId().replace(/\./g,"\\\."));
398       return tmplHtml;
399     }
400
401     this.displaySettings=function(sourceRepoId,targetRepoId,targetContentStartId, targetImgStartId){
402       var proxyConnector=getProxyConnector(sourceRepoId,targetRepoId);
403       showSettings(proxyConnector,targetContentStartId,targetImgStartId);
404     }
405
406     this.findPolicyInformationName=function(id){
407       for(var i=0;i<self.policyInformations().length;i++){
408         if (id==self.policyInformations()[i].id()){
409           return self.policyInformations()[i].name();
410         }
411       }
412       return null;
413     }
414
415     orderChangeAware=function(proxyConnector){
416       return findProxyConnectorsWithSourceId(proxyConnector).length>1;
417     }
418
419     findProxyConnectorsWithSourceId=function(proxyConnector){
420       return $.grep(self.proxyConnectors(),function(curProxyConnector,idx){
421                                                   return curProxyConnector.sourceRepoId()==proxyConnector.sourceRepoId();
422                                                 }
423                                             );
424     }
425
426     displayOrderEdit=function(proxyConnector){
427       var proxyConnectors=findProxyConnectorsWithSourceId(proxyConnector);
428       $.log("displayOrderEdit:"+proxyConnector.sourceRepoId()+",number:"+proxyConnectors.length);
429
430       var managedRepository = getManagedRepository(proxyConnector.sourceRepoId());
431       var proxyConnectorEditOrderViewModel=new ProxyConnectorEditOrderViewModel(proxyConnectors,self,managedRepository);
432       ko.applyBindings(proxyConnectorEditOrderViewModel,$("#main-content").find("#proxy-connector-edit-order").get(0));
433       activateProxyConnectorsEditOrderTab();
434     }
435
436     this.displayGrid=function(){
437       this.gridViewModel = new ko.simpleGrid.viewModel({
438         data: self.proxyConnectors,
439         pageSize: 5,
440         gridUpdateCallBack: function(){
441           $("#main-content" ).find("#proxyConnectorsTable" ).find("[title]").tooltip();
442         }
443       });
444       var mainContent = $("#main-content");
445
446       ko.applyBindings(this,mainContent.find("#proxy-connectors-view").get(0));
447       var prxGrids=mainContent.find("[id^='proxy-connectors-grid-remoterepo-settings-edit-']");
448       prxGrids.popover();
449       removeSmallSpinnerImg();
450       mainContent.find("#proxy-connectors-view-tabs #proxy-connectors-view-tabs-a-network-proxies-grid").tab('show');
451
452       mainContent.find("#proxy-connectors-view-tabs").on('show', function (e) {
453         $.log("on show:"+$(e.target).attr("href"));
454         if ($(e.target).attr("href")=="#proxy-connectors-edit") {
455           $.log("#proxy-connectors-edit");
456           var proxyConnector=new ProxyConnector();
457           var defaultPolicies=new Array();
458           // populate with defaut policies options
459           for (i=0;i<self.policyInformations().length;i++){
460             defaultPolicies.push(new Entry(self.policyInformations()[i].id(),self.policyInformations()[i].defaultOption));
461           }
462           proxyConnector.policiesEntries(defaultPolicies);
463           var proxyConnectorViewModel=new ProxyConnectorViewModel(proxyConnector,false,self);
464           mainContent.find("#proxy-connectors-edit").html($("#proxy-connector-edit-form-tmpl").tmpl());
465           ko.applyBindings(proxyConnectorViewModel,mainContent.find("#proxy-connectors-edit").get(0));
466           mainContent.find("#sourceRepoId" ).select2();
467           mainContent.find("#targetRepoId" ).select2();
468         }
469         if ($(e.target).attr("href")=="#proxy-connectors-view") {
470           $("#proxy-connectors-view-tabs-a-network-proxies-grid").html($.i18n.prop("proxy-connectors.grid.tab.title"));
471           mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("add"));
472         }
473         if ($(e.target).attr("href")=="#proxy-connectors-edit-order") {
474           activateProxyConnectorsEditOrderTab();
475         }
476
477       });
478     }
479
480   }
481
482   ProxyConnectorEditOrderViewModel=function(proxyConnectors,proxyConnectorsViewModel,managedRepository){
483     var self=this;
484     this.proxyConnectors=ko.observableArray(proxyConnectors);
485     this.proxyConnectorsViewModel=proxyConnectorsViewModel;
486     this.managedRepository=managedRepository;
487     proxyConnectorMoved=function(arg){
488       $.log("proxyConnectorMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
489       // if only 1 move just update two whereas update all with the new order
490       if (arg.targetIndex-arg.sourceIndex==1){
491         self.proxyConnectors()[arg.targetIndex].order(arg.targetIndex+1);
492         self.proxyConnectors()[arg.sourceIndex].order(arg.sourceIndex+1);
493       } else {
494         for (i=0;i<self.proxyConnectors().length;i++){
495           self.proxyConnectors()[i].order(i+1);
496         }
497       }
498     }
499
500     this.findRemoteRepository=function(id){
501       $.log("findRemoteRepository:"+id());
502       for(var i=0;i<self.proxyConnectorsViewModel.remoteRepositories().length;i++){
503         if (self.proxyConnectorsViewModel.remoteRepositories()[i].id()==id()){
504           return self.proxyConnectorsViewModel.remoteRepositories()[i];
505         }
506       }
507       return null;
508     }
509
510     this.updateModifiedProxyConnectors=function(){
511       self.proxyConnectorsViewModel.updateModifiedProxyConnectors();
512     }
513
514     displaySettings=function(sourceRepoId,targetRepoId){
515       $.log("ProxyConnectorEditOrderViewModel#showSettings:"+sourceRepoId+"-"+targetRepoId);
516       self.proxyConnectorsViewModel.displaySettings(sourceRepoId,targetRepoId,
517                                                     "#proxy-connectors-order-remoterepo-settings-content-",
518                                                     "#proxy-connectors-order-remoterepo-settings-edit-");
519     }
520
521   }
522
523   displayProxyConnectors=function(){
524     screenChange();
525     var mainContent = $("#main-content");
526     mainContent.html($("#proxyConnectorsMain").tmpl());
527     mainContent.append(smallSpinnerImg());
528
529     this.proxyConnectorsViewModel = new ProxyConnectorsViewModel();
530     var self=this;
531
532     loadManagedRepositories(function(data) {
533       self.proxyConnectorsViewModel.managedRepositories(mapManagedRepositories(data));
534
535       loadRemoteRepositories(function(data) {
536         self.proxyConnectorsViewModel.remoteRepositories(mapRemoteRepositories(data));
537
538         loadNetworkProxies(function(data) {
539           self.proxyConnectorsViewModel.networkProxies(mapNetworkProxies(data));
540
541           loadAllPolicies( function(data) {
542             self.proxyConnectorsViewModel.policyInformations(mapPolicyInformations(data));
543
544             loadAllProxyConnectors( function(data) {
545               self.proxyConnectorsViewModel.proxyConnectors(mapProxyConnectors(data));
546               self.proxyConnectorsViewModel.displayGrid();
547             });
548
549           });
550
551         });
552
553       });
554
555     });
556
557   }
558
559   loadAllPolicies=function(successCallBackFn,errorCallBackFn){
560     $.ajax("restServices/archivaServices/proxyConnectorService/allPolicies", {
561         type: "GET",
562         dataType: 'json',
563         success: successCallBackFn,
564         error: errorCallBackFn
565       }
566     );
567   }
568
569   loadAllProxyConnectors=function(successCallBackFn,errorCallBackFn){
570     $.ajax("restServices/archivaServices/proxyConnectorService/getProxyConnectors", {
571       type: "GET",
572       dataType: 'json',
573       success: successCallBackFn,
574       error: errorCallBackFn
575      });
576   }
577
578   activateProxyConnectorsGridTab=function(){
579     var mainContent = $("#main-content");
580     mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
581     mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
582
583     mainContent.find("#proxy-connectors-view").addClass("active");
584     mainContent.find("#proxy-connectors-view-tabs-li-grid").addClass("active");
585     mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("add"));
586
587   }
588
589   activateProxyConnectorsEditTab=function(){
590     var mainContent = $("#main-content");
591
592     mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
593     mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
594
595     mainContent.find("#proxy-connectors-edit").addClass("active");
596     mainContent.find("#proxy-connectors-view-tabs-li-edit").addClass("active");
597   }
598
599   activateProxyConnectorsEditOrderTab=function(){
600     var mainContent = $("#main-content");
601
602     mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
603     mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
604
605     mainContent.find("#proxy-connector-edit-order").addClass("active");
606     mainContent.find("#proxy-connectors-view-tabs-li-edit-order").addClass("active");
607   }
608
609   mapProxyConnector=function(data){
610     if (data==null){
611       return null;
612     }
613     var policiesEntries = data.policiesEntries == null ? []: $.each(data.policiesEntries,function(item){
614       return new Entry(item.key, item.value);
615     });
616     if (!$.isArray(policiesEntries)){
617       policiesEntries=[];
618     }
619     var propertiesEntries = data.propertiesEntries == null ? []: $.each(data.propertiesEntries,function(item){
620           return new Entry(item.key, item.value);
621         });
622     if (!$.isArray(propertiesEntries)){
623       propertiesEntries=[];
624     }
625     return new ProxyConnector(data.sourceRepoId,data.targetRepoId,data.proxyId,mapStringArray(data.blackListPatterns),
626                               mapStringArray(data.whiteListPatterns),policiesEntries,propertiesEntries,
627                               data.disabled,data.order);
628   }
629
630   mapProxyConnectors=function(data){
631     var mappedProxyConnectors = $.map(data, function(item) {
632       return mapProxyConnector(item);
633     });
634     return mappedProxyConnectors;
635   }
636
637   mapPolicyInformation=function(data){
638     if (data==null){
639       return null;
640     }
641     var policyInformation = new PolicyInformation(mapStringArray(data.options),data.defaultOption,data.id,data.name);
642     $.log("policyInformation.options:"+policyInformation.options());
643     return policyInformation;
644   }
645
646   mapPolicyInformations=function(data){
647     return $.map(data, function(item) {
648               return mapPolicyInformation(item);
649            });
650   }
651
652   removeProxyConnector=function(proxyConnector,fnSuccessCallback){
653     clearUserMessages();
654     var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
655     url += "sourceRepoId="+encodeURIComponent(proxyConnector.sourceRepoId());
656     url += "&targetRepoId="+encodeURIComponent(proxyConnector.targetRepoId());
657     $.ajax(url,
658       {
659         type: "GET",
660         contentType: 'application/json',
661         success: function(data) {
662           fnSuccessCallback();
663         },
664         error: function(data) {
665           var res = $.parseJSON(data.responseText);
666           displayRestError(res);
667         }
668       }
669     );
670
671   }
672
673 });