]> source.dussan.org Git - archiva.git/commitdiff
proxy connector screen add PolicyInformation bean
authorOlivier Lamy <olamy@apache.org>
Mon, 30 Jan 2012 09:47:41 +0000 (09:47 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 30 Jan 2012 09:47:41 +0000 (09:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1237581 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js

index 1c6ab93127fd11c872fdeccab73b1c5b623e8a2a..d28c32ed101d433a12f620c04838a7af17b78aae 100644 (file)
     <dependency>
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-repository-admin-api</artifactId>
+    </dependency>
 
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-policies</artifactId>
     </dependency>
 
+
     <dependency>
       <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-authorization-api</artifactId>
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java
new file mode 100644 (file)
index 0000000..1702a53
--- /dev/null
@@ -0,0 +1,104 @@
+package org.apache.archiva.rest.api.model;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+@XmlRootElement( name = "policyInformation" )
+public class PolicyInformation
+{
+    private List<String> options;
+
+    private String defaultOption;
+
+    private String id;
+
+    private String name;
+
+    public PolicyInformation()
+    {
+        // no op
+    }
+
+    public PolicyInformation( List<String> options, String defaultOption, String id, String name )
+    {
+        this.options = options;
+        this.defaultOption = defaultOption;
+        this.id = id;
+        this.name = name;
+    }
+
+    public List<String> getOptions()
+    {
+        return options;
+    }
+
+    public void setOptions( List<String> options )
+    {
+        this.options = options;
+    }
+
+    public String getDefaultOption()
+    {
+        return defaultOption;
+    }
+
+    public void setDefaultOption( String defaultOption )
+    {
+        this.defaultOption = defaultOption;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    @Override
+    public String toString()
+    {
+        final StringBuilder sb = new StringBuilder();
+        sb.append( "PolicyInformation" );
+        sb.append( "{options=" ).append( options );
+        sb.append( ", defaultOption='" ).append( defaultOption ).append( '\'' );
+        sb.append( ", id='" ).append( id ).append( '\'' );
+        sb.append( ", name='" ).append( name ).append( '\'' );
+        sb.append( '}' );
+        return sb.toString();
+    }
+}
index e608884de3ef3dd90037d882ec4ce4e7231b5e56..4f253262f2d6bbb8f32e399e5c10512a686601c0 100644 (file)
@@ -31,9 +31,9 @@ $(function() {
     //private List<String> whiteListPatterns;
     this.whiteListPatterns=ko.observableArray(whiteListPatterns);
     //private Map<String, String> policies;
-
+   this.policies=ko.observable(policies);
     //private Map<String, String> properties;
-
+    this.properties=ko.observable(properties);
     //private boolean disabled = false;
     this.disabled=ko.observable(disabled);
     //private int order = 0;
@@ -43,6 +43,113 @@ $(function() {
   displayProxyConnectors=function(){
     $("#main-content").html($("#proxyConnectorsMain").tmpl());
     $("#main-content").append(smallSpinnerImg());
+  PolicyInformation=function(options,defaultOption,id,name){
+    //private List<String> options;
+    this.options=ko.observableArray(options);
+    //private String defaultOption;
+    this.defaultOption=ko.observable(defaultOption);
+    //private String id;
+    this.id=ko.observable(id);
+    //private String name;
+    this.name=ko.observable(name);
+  }
+
+  ProxyConnectorsViewModel=function(){
+    this.proxyConnectors=ko.observableArray([]);
+    var self=this;
+
+    editProxyConnector=function(proxyConnector){
+
+    }
+
+    this.displayGrid=function(){
+      var sourcesRepos=[];
+      //sourceRepoId
+      for(i=0;i<self.proxyConnectors().length;i++){
+        var curSrcRepo=self.proxyConnectors()[i].sourceRepoId();
+        var curTarget=self.proxyConnectors()[i].targetRepoId;
+        var sourceRepo = $.grep(sourcesRepos,
+                                function(srcRepo,idx){
+                                  $.log("grep:"+srcRepo.source);
+                                  $.log("sourcesRepos.length:"+sourcesRepos.length);
+                                  for (i=0;i<sourcesRepos.length;i++){
+                                    if (srcRepo.source==sourcesRepos[i].source){
+                                      return true;
+                                    }
+                                  }
+                                  return false;
+                                }
+        );
+        if (sourceRepo!=null){
+          $.log("sourceRepoId:"+curSrcRepo);
+          sourcesRepos.push({source:curSrcRepo,targetRepos:[curTarget]});
+        } else {
+          sourceRepo.targetRepos.push(curTarget);
+        }
+      }
+
+      $.log("sourcesRepo.length:"+sourcesRepos.length);
+      for(i=0;i<sourcesRepos.length;i++){
+        $.log(sourcesRepos.targetRepos.length);
+      }
+    }
+  }
+
+  displayProxyConnectors=function(){
+    $("#main-content").html($("#proxyConnectorsMain").tmpl());
+    $("#main-content").append(smallSpinnerImg());
+
+    var proxyConnectorsViewModel = new ProxyConnectorsViewModel();
+
+    $.ajax("restServices/archivaServices/proxyConnectorService/getProxyConnectors", {
+        type: "GET",
+        dataType: 'json',
+        success: function(data) {
+          proxyConnectorsViewModel.proxyConnectors(mapProxyConnectors(data));
+          proxyConnectorsViewModel.displayGrid();
+        }
+      }
+    );
+
+    $.ajax("restServices/archivaServices/proxyConnectorService/allPolicies", {
+        type: "GET",
+        dataType: 'json',
+        success: function(data) {
+          mapPolicyInformations(data);
+        }
+      }
+    );
+
+
+  }
+
+  mapProxyConnector=function(data){
+    if (data==null){
+      return null;
+    }
+    return new ProxyConnector(data.sourceRepoId,data.targetRepoId,data.proxyId,mapStringArray(data.blackListPatterns),
+                              mapStringArray(data.whiteListPatterns),data.policies,data.properties,
+                              data.disabled,data.order);
+  }
+
+  mapProxyConnectors=function(data){
+    var mappedProxyConnectors = $.map(data.proxyConnector, function(item) {
+      return mapProxyConnector(item);
+    });
+    return mappedProxyConnectors;
+  }
+
+  mapPolicyInformation=function(data){
+    if (data==null){
+      return null;
+    }
+    return new PolicyInformation(mapStringArray(data.options),data.defaultOption,data.id,data.name);
+  }
+
+  mapPolicyInformations=function(data){
+    return $.map(data.policyInformation, function(item) {
+          return mapPolicyInformation(item);
+        });
   }
 
 });
\ No newline at end of file