]> source.dussan.org Git - archiva.git/blob
48019c72abb92922f09bf33c8513b1021343e4d1
[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/maven2/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       tab.sort();
195       self.proxyConnector.whiteListPatterns(tab);
196       self.proxyConnector.modified(true);
197
198     }
199
200     removeWhitelistPattern=function(pattern){
201       self.proxyConnector.whiteListPatterns.remove(pattern);
202       self.proxyConnector.modified(true);
203     }
204
205     this.save=function(){
206       //FIXME data controls !!!
207       clearUserMessages();
208       var userMessages=$("#user-messages");
209       userMessages.html(mediumSpinnerImg());
210       $("#proxy-connector-btn-save" ).button("loading");
211       // update is delete then add
212       if (this.update){
213         $.ajax("restServices/archivaServices/proxyConnectorService/updateProxyConnector",
214           {
215             type: "POST",
216             data: ko.toJSON(self.proxyConnector),
217             contentType: 'application/json',
218             dataType: 'json',
219             success: function(data) {
220               displaySuccessMessage($.i18n.prop('proxyconnector.updated'));
221               activateProxyConnectorsGridTab();
222               self.proxyConnector.modified(false);
223             },
224             error: function(data) {
225               var res = $.parseJSON(data.responseText);
226               displayRestError(res);
227             },
228             complete: function(){
229               removeMediumSpinnerImg(userMessages);
230               $("#proxy-connector-btn-save" ).button("reset");
231             }
232           }
233         );
234       } else {
235
236         $.ajax("restServices/archivaServices/proxyConnectorService/addProxyConnector",
237           {
238             type: "POST",
239             data: ko.toJSON(self.proxyConnector),
240             contentType: 'application/json',
241             dataType: 'json',
242             success: function(data) {
243               displaySuccessMessage($.i18n.prop('proxyconnector.added'));
244               activateProxyConnectorsGridTab();
245               self.proxyConnector.modified(false);
246               self.proxyConnectorsViewModel.proxyConnectors.push(self.proxyConnector);
247             },
248             error: function(data) {
249               var res = $.parseJSON(data.responseText);
250               displayRestError(res);
251             },
252             complete: function(){
253               removeMediumSpinnerImg(userMessages);
254               $("#proxy-connector-btn-save" ).button("reset");
255             }
256           }
257         );
258       }
259     }
260
261     this.deleteProperty=function(key){
262       for(var i=0;i<self.proxyConnector.propertiesEntries().length;i++){
263         var entry=self.proxyConnector.propertiesEntries()[i];
264         if (entry.key()==key()){
265           self.proxyConnector.propertiesEntries.remove(entry);
266           self.proxyConnector.modified(true);
267         }
268       }
269
270     }
271
272     this.addProperty=function(){
273       var mainContent=$("#main-content");
274       var key=mainContent.find("#property-key").val();
275       var value=mainContent.find("#property-value").val();
276       var oldTab = self.proxyConnector.propertiesEntries();
277       oldTab.push(new Entry(key,value));
278       self.proxyConnector.propertiesEntries(oldTab);
279       mainContent.find("#property-key").val("");
280       mainContent.find("#property-value").val("");
281       self.proxyConnector.modified(true);
282     }
283
284     displayGrid=function(){
285       activateProxyConnectorsGridTab();
286     }
287   }
288
289   ProxyConnectorsViewModel=function(){
290     var self=this;
291     this.proxyConnectors=ko.observableArray([]);
292     this.proxyConnectors.subscribe(function(newValue){
293       $.log("ProxyConnectorsViewModel#proxyConnectors modified");
294       self.proxyConnectors().sort(function(a,b){
295         if ( a.sourceRepoId()== b.sourceRepoId()) return a.order() - b.order();
296         return (a.sourceRepoId() > b.sourceRepoId())? -1:1;
297       });
298     });
299     this.policyInformations=ko.observableArray([]);
300     this.managedRepositories=ko.observableArray([]);
301     this.remoteRepositories=ko.observableArray([]);
302     this.networkProxies=ko.observableArray([]);
303
304     this.bulkSave=function(){
305       return getModifiedProxyConnectors().length>0;
306     }
307
308     getModifiedProxyConnectors=function(){
309       var prx = $.grep(self.proxyConnectors(),
310           function (proxyConnector,i) {
311             return proxyConnector.modified();
312           });
313       return prx;
314     }
315
316     this.updateModifiedProxyConnectors=function(){
317       var modifiedProxyConnectors = getModifiedProxyConnectors();
318
319       openDialogConfirm(function(){
320                           for(var i=0;i<modifiedProxyConnectors.length;i++){
321                             var viewModel = new ProxyConnectorViewModel(modifiedProxyConnectors[i],true,self,false);
322                             viewModel.save();
323                           }
324                           closeDialogConfirm();
325                         },
326                         $.i18n.prop('ok'),
327                         $.i18n.prop('cancel'),
328                         $.i18n.prop('proxy-connectors.bulk.save.confirm.title'),
329                         $.i18n.prop('proxy.connector.bulk.save.confirm',modifiedProxyConnectors.length));
330     }
331
332     updateProxyConnector=function(proxyConnector){
333       var viewModel = new ProxyConnectorViewModel(proxyConnector,true,self,false);
334       viewModel.save();
335     }
336
337     editProxyConnector=function(proxyConnector){
338       var proxyConnectorViewModel=new ProxyConnectorViewModel(proxyConnector,true,self);
339       var mainContent = $("#main-content");
340       mainContent.find("#proxy-connectors-edit").html($("#proxy-connector-edit-form-tmpl").tmpl());
341       ko.applyBindings(proxyConnectorViewModel,mainContent.find("#proxy-connectors-edit").get(0));
342       activateProxyConnectorsEditTab();
343       mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("edit"));
344     }
345
346     deleteProxyConnector=function(proxyConnector){
347
348       openDialogConfirm(
349           function(){
350             clearUserMessages();
351             removeProxyConnector(proxyConnector,function(){
352             displaySuccessMessage($.i18n.prop('proxyconnector.removed'));
353             self.proxyConnectors.remove(proxyConnector);
354             closeDialogConfirm();
355           })}, $.i18n.prop('ok'), $.i18n.prop('cancel'), $.i18n.prop('proxyconnector.delete.confirm'),
356           $("#proxy-connector-delete-warning-tmpl").tmpl(proxyConnector));
357
358
359     }
360
361
362     getManagedRepository=function(id){
363       return findManagedRepository(id,self.managedRepositories());
364     }
365
366     getRemoteRepository=function(id){
367       var remoteRepository=$.grep(self.remoteRepositories(),
368                                       function(repo,idx){
369                                         return repo.id()==id;
370                                       }
371                             );
372       return ($.isArray(remoteRepository) && remoteRepository.length>0) ? remoteRepository[0]:new RemoteRepository();
373     }
374
375     getProxyConnector=function(sourceRepoId,targetRepoId){
376       var proxyConnectors=$.grep(self.proxyConnectors(),
377                                       function(proxyConnector,idx){
378                                         return proxyConnector.sourceRepoId()==sourceRepoId
379                                             && proxyConnector.targetRepoId()==targetRepoId;
380                                       }
381                                   );
382       var res = ($.isArray(proxyConnectors) && proxyConnectors.length>0) ? proxyConnectors[0]:new ProxyConnector();
383       return res;
384     }
385     showSettings=function(){
386       $.log("showSettings");
387       $("#body_content" ).find(".popover" ).hide();
388       //$("#main-content").find("[id^='proxy-connectors-grid-remoterepo-settings-edit-']" ).popover("hide");
389     }
390     buildSettings=function(proxyConnector){
391       var tmplHtml = $("#proxy-connectors-remote-settings-popover-tmpl")
392                                            .tmpl({
393                                                 proxyConnectorsViewModel: self,
394                                                 proxyConnector:ko.toJS(proxyConnector)
395                                                 } ).html();
396
397       var targetImg = $(("#proxy-connectors-grid-remoterepo-settings-edit-")
398                             +proxyConnector.sourceRepoId().replace(/\./g,"\\\.")+"-"+proxyConnector.targetRepoId().replace(/\./g,"\\\."));
399       return tmplHtml;
400     }
401
402     this.displaySettings=function(sourceRepoId,targetRepoId,targetContentStartId, targetImgStartId){
403       var proxyConnector=getProxyConnector(sourceRepoId,targetRepoId);
404       showSettings(proxyConnector,targetContentStartId,targetImgStartId);
405     }
406
407     this.findPolicyInformationName=function(id){
408       for(var i=0;i<self.policyInformations().length;i++){
409         if (id==self.policyInformations()[i].id()){
410           return self.policyInformations()[i].name();
411         }
412       }
413       return null;
414     }
415
416     orderChangeAware=function(proxyConnector){
417       return findProxyConnectorsWithSourceId(proxyConnector).length>1;
418     }
419
420     findProxyConnectorsWithSourceId=function(proxyConnector){
421       return $.grep(self.proxyConnectors(),function(curProxyConnector,idx){
422                                                   return curProxyConnector.sourceRepoId()==proxyConnector.sourceRepoId();
423                                                 }
424                                             );
425     }
426
427     displayOrderEdit=function(proxyConnector){
428       var proxyConnectors=findProxyConnectorsWithSourceId(proxyConnector);
429       $.log("displayOrderEdit:"+proxyConnector.sourceRepoId()+",number:"+proxyConnectors.length);
430
431       var managedRepository = getManagedRepository(proxyConnector.sourceRepoId());
432       var proxyConnectorEditOrderViewModel=new ProxyConnectorEditOrderViewModel(proxyConnectors,self,managedRepository);
433       ko.applyBindings(proxyConnectorEditOrderViewModel,$("#main-content").find("#proxy-connector-edit-order").get(0));
434       activateProxyConnectorsEditOrderTab();
435     }
436
437     this.displayGrid=function(){
438       this.gridViewModel = new ko.simpleGrid.viewModel({
439         data: self.proxyConnectors,
440         pageSize: 5,
441         gridUpdateCallBack: function(){
442           $("#main-content" ).find("#proxyConnectorsTable" ).find("[title]").tooltip();
443         }
444       });
445       var mainContent = $("#main-content");
446
447       ko.applyBindings(this,mainContent.find("#proxy-connectors-view").get(0));
448       var prxGrids=mainContent.find("[id^='proxy-connectors-grid-remoterepo-settings-edit-']");
449       prxGrids.popover();
450       removeSmallSpinnerImg();
451       mainContent.find("#proxy-connectors-view-tabs #proxy-connectors-view-tabs-a-network-proxies-grid").tab('show');
452
453       mainContent.find("#proxy-connectors-view-tabs").on('show', function (e) {
454         $.log("on show:"+$(e.target).attr("href"));
455         if ($(e.target).attr("href")=="#proxy-connectors-edit") {
456           $.log("#proxy-connectors-edit");
457           var proxyConnector=new ProxyConnector();
458           var defaultPolicies=new Array();
459           // populate with defaut policies options
460           for (i=0;i<self.policyInformations().length;i++){
461             defaultPolicies.push(new Entry(self.policyInformations()[i].id(),self.policyInformations()[i].defaultOption));
462           }
463           proxyConnector.policiesEntries(defaultPolicies);
464           var proxyConnectorViewModel=new ProxyConnectorViewModel(proxyConnector,false,self);
465           mainContent.find("#proxy-connectors-edit").html($("#proxy-connector-edit-form-tmpl").tmpl());
466           ko.applyBindings(proxyConnectorViewModel,mainContent.find("#proxy-connectors-edit").get(0));
467           mainContent.find("#sourceRepoId" ).select2();
468           mainContent.find("#targetRepoId" ).select2();
469         }
470         if ($(e.target).attr("href")=="#proxy-connectors-view") {
471           $("#proxy-connectors-view-tabs-a-network-proxies-grid").html($.i18n.prop("proxy-connectors.grid.tab.title"));
472           mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("add"));
473         }
474         if ($(e.target).attr("href")=="#proxy-connectors-edit-order") {
475           activateProxyConnectorsEditOrderTab();
476         }
477
478       });
479     }
480
481   }
482
483   ProxyConnectorEditOrderViewModel=function(proxyConnectors,proxyConnectorsViewModel,managedRepository){
484     var self=this;
485     this.proxyConnectors=ko.observableArray(proxyConnectors);
486     this.proxyConnectorsViewModel=proxyConnectorsViewModel;
487     this.managedRepository=managedRepository;
488     proxyConnectorMoved=function(arg){
489       $.log("proxyConnectorMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
490       // if only 1 move just update two whereas update all with the new order
491       if (arg.targetIndex-arg.sourceIndex==1){
492         self.proxyConnectors()[arg.targetIndex].order(arg.targetIndex+1);
493         self.proxyConnectors()[arg.sourceIndex].order(arg.sourceIndex+1);
494       } else {
495         for (i=0;i<self.proxyConnectors().length;i++){
496           self.proxyConnectors()[i].order(i+1);
497         }
498       }
499     }
500
501     this.findRemoteRepository=function(id){
502       $.log("findRemoteRepository:"+id());
503       for(var i=0;i<self.proxyConnectorsViewModel.remoteRepositories().length;i++){
504         if (self.proxyConnectorsViewModel.remoteRepositories()[i].id()==id()){
505           return self.proxyConnectorsViewModel.remoteRepositories()[i];
506         }
507       }
508       return null;
509     }
510
511     this.updateModifiedProxyConnectors=function(){
512       self.proxyConnectorsViewModel.updateModifiedProxyConnectors();
513     }
514
515     displaySettings=function(sourceRepoId,targetRepoId){
516       $.log("ProxyConnectorEditOrderViewModel#showSettings:"+sourceRepoId+"-"+targetRepoId);
517       self.proxyConnectorsViewModel.displaySettings(sourceRepoId,targetRepoId,
518                                                     "#proxy-connectors-order-remoterepo-settings-content-",
519                                                     "#proxy-connectors-order-remoterepo-settings-edit-");
520     }
521
522   }
523
524   displayProxyConnectors=function(){
525     screenChange();
526     var mainContent = $("#main-content");
527     mainContent.html($("#proxyConnectorsMain").tmpl());
528     mainContent.append(smallSpinnerImg());
529
530     this.proxyConnectorsViewModel = new ProxyConnectorsViewModel();
531     var self=this;
532
533     loadManagedRepositories(function(data) {
534       self.proxyConnectorsViewModel.managedRepositories(mapManagedRepositories(data));
535
536       loadRemoteRepositories(function(data) {
537         self.proxyConnectorsViewModel.remoteRepositories(mapRemoteRepositories(data));
538
539         loadNetworkProxies(function(data) {
540           self.proxyConnectorsViewModel.networkProxies(mapNetworkProxies(data));
541
542           loadAllPolicies( function(data) {
543             self.proxyConnectorsViewModel.policyInformations(mapPolicyInformations(data));
544
545             loadAllProxyConnectors( function(data) {
546               self.proxyConnectorsViewModel.proxyConnectors(mapProxyConnectors(data));
547               self.proxyConnectorsViewModel.displayGrid();
548             });
549
550           });
551
552         });
553
554       });
555
556     });
557
558   }
559
560   loadAllPolicies=function(successCallBackFn,errorCallBackFn){
561     $.ajax("restServices/archivaServices/proxyConnectorService/allPolicies", {
562         type: "GET",
563         dataType: 'json',
564         success: successCallBackFn,
565         error: errorCallBackFn
566       }
567     );
568   }
569
570   loadAllProxyConnectors=function(successCallBackFn,errorCallBackFn){
571     $.ajax("restServices/archivaServices/proxyConnectorService/getProxyConnectors", {
572       type: "GET",
573       dataType: 'json',
574       success: successCallBackFn,
575       error: errorCallBackFn
576      });
577   }
578
579   activateProxyConnectorsGridTab=function(){
580     var mainContent = $("#main-content");
581     mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
582     mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
583
584     mainContent.find("#proxy-connectors-view").addClass("active");
585     mainContent.find("#proxy-connectors-view-tabs-li-grid").addClass("active");
586     mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("add"));
587
588   }
589
590   activateProxyConnectorsEditTab=function(){
591     var mainContent = $("#main-content");
592
593     mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
594     mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
595
596     mainContent.find("#proxy-connectors-edit").addClass("active");
597     mainContent.find("#proxy-connectors-view-tabs-li-edit").addClass("active");
598   }
599
600   activateProxyConnectorsEditOrderTab=function(){
601     var mainContent = $("#main-content");
602
603     mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
604     mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
605
606     mainContent.find("#proxy-connector-edit-order").addClass("active");
607     mainContent.find("#proxy-connectors-view-tabs-li-edit-order").addClass("active");
608   }
609
610   mapProxyConnector=function(data){
611     if (data==null){
612       return null;
613     }
614     var policiesEntries = data.policiesEntries == null ? []: $.each(data.policiesEntries,function(item){
615       return new Entry(item.key, item.value);
616     });
617     if (!$.isArray(policiesEntries)){
618       policiesEntries=[];
619     }
620     var propertiesEntries = data.propertiesEntries == null ? []: $.each(data.propertiesEntries,function(item){
621           return new Entry(item.key, item.value);
622         });
623     if (!$.isArray(propertiesEntries)){
624       propertiesEntries=[];
625     }
626     return new ProxyConnector(data.sourceRepoId,data.targetRepoId,data.proxyId,mapStringArray(data.blackListPatterns),
627                               mapStringArray(data.whiteListPatterns),policiesEntries,propertiesEntries,
628                               data.disabled,data.order);
629   }
630
631   mapProxyConnectors=function(data){
632     var mappedProxyConnectors = $.map(data, function(item) {
633       return mapProxyConnector(item);
634     });
635     return mappedProxyConnectors;
636   }
637
638   mapPolicyInformation=function(data){
639     if (data==null){
640       return null;
641     }
642     var policyInformation = new PolicyInformation(mapStringArray(data.options),data.defaultOption,data.id,data.name);
643     $.log("policyInformation.options:"+policyInformation.options());
644     return policyInformation;
645   }
646
647   mapPolicyInformations=function(data){
648     return $.map(data, function(item) {
649               return mapPolicyInformation(item);
650            });
651   }
652
653   removeProxyConnector=function(proxyConnector,fnSuccessCallback){
654     clearUserMessages();
655     var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
656     url += "sourceRepoId="+encodeURIComponent(proxyConnector.sourceRepoId());
657     url += "&targetRepoId="+encodeURIComponent(proxyConnector.targetRepoId());
658     $.ajax(url,
659       {
660         type: "GET",
661         contentType: 'application/json',
662         success: function(data) {
663           fnSuccessCallback();
664         },
665         error: function(data) {
666           var res = $.parseJSON(data.responseText);
667           displayRestError(res);
668         }
669       }
670     );
671
672   }
673
674 });