You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/01/30 10:47:42 UTC

svn commit: r1237581 - in /archiva/trunk/archiva-modules/archiva-web: archiva-rest/archiva-rest-api/ archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ archiva-webapp-js/src/main/webapp/js/archiva/

Author: olamy
Date: Mon Jan 30 09:47:41 2012
New Revision: 1237581

URL: http://svn.apache.org/viewvc?rev=1237581&view=rev
Log:
proxy connector screen add PolicyInformation bean

Added:
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java   (with props)
Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml?rev=1237581&r1=1237580&r2=1237581&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml Mon Jan 30 09:47:41 2012
@@ -38,9 +38,14 @@
     <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>

Added: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java?rev=1237581&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java Mon Jan 30 09:47:41 2012
@@ -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();
+    }
+}

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PolicyInformation.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js?rev=1237581&r1=1237580&r2=1237581&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js Mon Jan 30 09:47:41 2012
@@ -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