removes commented out code and print statements and adds more api validation 
and fixes some tests a annd adds some docs


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/3b1df01e
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/3b1df01e
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/3b1df01e

Branch: refs/heads/master
Commit: 3b1df01eb776e8dca82ef8cb6b1e9a3f12dc250f
Parents: e695229
Author: Jeremy Mitchell <mitchell...@gmail.com>
Authored: Wed Mar 8 16:06:09 2017 -0700
Committer: Jeremy Mitchell <mitchell...@gmail.com>
Committed: Thu Mar 9 08:04:20 2017 -0700

----------------------------------------------------------------------
 .../development/traffic_ops_api/v12/cdn.rst     |  54 +++++--
 .../traffic_ops_api/v12/deliveryservice.rst     |   6 -
 .../development/traffic_ops_api/v12/profile.rst | 151 +++++++++++--------
 traffic_ops/app/lib/API/Cdn.pm                  |  32 ++--
 traffic_ops/app/lib/API/Deliveryservice.pm      |   6 +-
 traffic_ops/app/lib/API/Profile.pm              |  31 ++--
 .../lib/Fixtures/Integration/Deliveryservice.pm |   8 -
 traffic_ops/app/lib/Fixtures/Parameter.pm       |   9 --
 traffic_ops/app/lib/UI/Cdn.pm                   |   4 -
 traffic_ops/app/t/api/1.1/cachegroupparameter.t |   2 +-
 10 files changed, 175 insertions(+), 128 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/docs/source/development/traffic_ops_api/v12/cdn.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/cdn.rst 
b/docs/source/development/traffic_ops_api/v12/cdn.rst
index da10799..650b0a9 100644
--- a/docs/source/development/traffic_ops_api/v12/cdn.rst
+++ b/docs/source/development/traffic_ops_api/v12/cdn.rst
@@ -38,6 +38,8 @@ CDN
   
+-------------------+--------+-------------------------------------------------+
   | ``name``          | string | CDN name.                                     
  |
   
+-------------------+--------+-------------------------------------------------+
+  | ``domainName``    | string | TLD of the CDN.                               
  |
+  
+-------------------+--------+-------------------------------------------------+
   | ``dnssecEnabled`` |  bool  | DNSSEC enabled.                               
  |
   
+-------------------+--------+-------------------------------------------------+
   | ``lastUpdated``   | string |                                               
  |
@@ -49,13 +51,15 @@ CDN
      "response": [
            {
               "id": "1"
-              "name": "over-the-top",
+              "name": "cdn1",
+              "domainName": "cdn1.foo.com",
               "dnssecEnabled": false,
               "lastUpdated": "2014-10-02 08:22:43"
            },
            {
               "id": "2"
               "name": "cdn2",
+              "domainName": "cdn2.foo.com",
               "dnssecEnabled": true,
               "lastUpdated": "2014-10-02 08:22:43"
            }
@@ -87,6 +91,8 @@ CDN
   
+-------------------+--------+-------------------------------------------------+
   | ``name``          | string | CDN name.                                     
  |
   
+-------------------+--------+-------------------------------------------------+
+  | ``domainName``    | string | TLD of the CDN.                               
  |
+  
+-------------------+--------+-------------------------------------------------+
   | ``dnssecEnabled`` |  bool  | DNSSEC enabled.                               
  |
   
+-------------------+--------+-------------------------------------------------+
   | ``lastUpdated``   | string |                                               
  |
@@ -99,6 +105,7 @@ CDN
            {
               "id": "2"
               "name": "cdn2",
+              "domainName": "cdn2.foo.com",
               "dnssecEnabled": false,
               "lastUpdated": "2014-10-02 08:22:43"
            }
@@ -130,6 +137,8 @@ CDN
   
+-------------------+--------+-------------------------------------------------+
   | ``name``          | string | CDN name.                                     
  |
   
+-------------------+--------+-------------------------------------------------+
+  | ``domainName``    | string | TLD of the CDN.                               
  |
+  
+-------------------+--------+-------------------------------------------------+
   | ``dnssecEnabled`` |  bool  | DNSSEC enabled.                               
  |
   
+-------------------+--------+-------------------------------------------------+
   | ``lastUpdated``   | string |                                               
  |
@@ -142,6 +151,7 @@ CDN
            {
               "id": "2"
               "name": "cdn2",
+              "domainName": "cdn2.foo.com",
               "dnssecEnabled": false,
               "lastUpdated": "2014-10-02 08:22:43"
            }
@@ -165,16 +175,19 @@ CDN
   
+===================+========+=================================================+
   | ``name``          | string | CDN name.                                     
  |
   
+-------------------+--------+-------------------------------------------------+
-  | ``dnssecEnabled`` |  int   | Whether dnssec is enabled.                    
  |
-  |                   |        | - 0: disabled                                 
  |
-  |                   |        | - 1: enabled                                  
  |
+  | ``domainName``    | string | TLD of the CDN.                               
  |
+  
+-------------------+--------+-------------------------------------------------+
+  | ``dnssecEnabled`` |  bool  | Whether dnssec is enabled.                    
  |
+  |                   |        | - false: disabled                             
  |
+  |                   |        | - true: enabled                               
  |
   
+-------------------+--------+-------------------------------------------------+
 
   **Request Example** ::
 
     {
         "name": "cdn_test",
-        "dnssecEnabled": 0
+        "domainName": "cdn3.foo.com",
+        "dnssecEnabled": true
     }
 
   **Response Properties**
@@ -184,12 +197,14 @@ CDN
   
+====================+========+=================================================+
   | ``response``       |  hash  | The details of the creation, if success.     
   |
   
+--------------------+--------+-------------------------------------------------+
-  | ``>name``          | string | CDN name.                                    
   |
-  
+--------------------+--------+-------------------------------------------------+
   | ``>id``            |  int   | CDN id.                                      
   |
   
+--------------------+--------+-------------------------------------------------+
+  | ``>name``          | string | CDN name.                                    
   |
+  
+--------------------+--------+-------------------------------------------------+
   | ``>dnssecEnabled`` | string | Whether dnssec is enabled.                   
   |
   
+--------------------+--------+-------------------------------------------------+
+  | ``>domainName``    | string | TLD of the CDN.                              
   |
+  
+--------------------+--------+-------------------------------------------------+
   | ``alerts``         | array  | A collection of alert messages.              
   |
   
+--------------------+--------+-------------------------------------------------+
   | ``>level``         | string | Success, info, warning or error.             
   |
@@ -202,9 +217,10 @@ CDN
 
     {
         "response":{
-            "name": "cdn_test",
             "id": 3
-            "dnssecEnabled": 0
+            "name": "cdn_test",
+            "domainName": "cdn3.foo.com",
+            "dnssecEnabled": true
         },
         "alerts":[
             {
@@ -239,9 +255,11 @@ CDN
   
+===================+========+=================================================+
   | ``name``          | string | CDN name.                                     
  |
   
+-------------------+--------+-------------------------------------------------+
-  | ``dnssecEnabled`` | int    | Whether dnssec is enabled.                    
  |
-  |                   |        | - 0: disabled                                 
  |
-  |                   |        | - 1: enabled                                  
  |
+  | ``domainName``    | string | TLD of the CDN.                               
  |
+  
+-------------------+--------+-------------------------------------------------+
+  | ``dnssecEnabled`` |  bool  | Whether dnssec is enabled.                    
  |
+  |                   |        | - false: disabled                             
  |
+  |                   |        | - true: enabled                               
  |
   
+-------------------+--------+-------------------------------------------------+
 
 
@@ -249,7 +267,8 @@ CDN
 
     {
         "name": "cdn_test2",
-        "dnssecEnabled": 0
+        "domainName": "cdn3.foo.com",
+        "dnssecEnabled": false
     }
 
   **Response Properties**
@@ -263,7 +282,9 @@ CDN
   
+--------------------+--------+-------------------------------------------------+
   | ``>id``            |  int   | CDN id.                                      
   |
   
+--------------------+--------+-------------------------------------------------+
-  | ``>dnssecEnabled`` | string | Whether dnssec is enabled.                   
   |
+  | ``>domainName``    | string | TLD of the CDN.                              
   |
+  
+--------------------+--------+-------------------------------------------------+
+  | ``>dnssecEnabled`` |  bool  | Whether dnssec is enabled.                   
   |
   
+--------------------+--------+-------------------------------------------------+
   | ``alerts``         | array  | A collection of alert messages.              
   |
   
+--------------------+--------+-------------------------------------------------+
@@ -276,9 +297,10 @@ CDN
 
     {
         "response":{
+            "id": 3,
             "name": "cdn_test2",
-            "id": 3
-            "dnssecEnabled": 0
+            "domainName": "cdn3.foo.com",
+            "dnssecEnabled": false
         },
         "alerts":[
             {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst 
b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
index 9e81b92..6ceb1d7 100644
--- a/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
+++ b/docs/source/development/traffic_ops_api/v12/deliveryservice.rst
@@ -132,8 +132,6 @@ Delivery Service
   
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``multiSiteOrigin``      |  bool  | Is the Multi Site Origin feature 
enabled for this delivery service (0=false, 1=true). See 
:ref:`rl-multi-site-origin`                |
   
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``multiSiteOriginAlgor`` |  bool  | Is the Multi Site Origin feature 
enabled for this delivery service (0=false, 1=true). See 
:ref:`rl-multi-site-origin`                |
-  
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``orgServerFqdn``        | string | The origin server base URL (FQDN when 
used in this instance, includes the                                             
               |
   |                          |        | protocol (http:// or https://) for use 
in retrieving content from the origin server.                                   
              |
   
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -227,7 +225,6 @@ Delivery Service
             "missLat": "41.881944",
             "missLong": "-87.627778",
             "multiSiteOrigin": false,
-            "multiSiteOriginAlgorithm": null,
             "orgServerFqdn": "http://baz.boo.net";,
             "originShield": null,
             "profileDescription": "Content Router for over-the-top",
@@ -364,8 +361,6 @@ Delivery Service
   
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``multiSiteOrigin``      |  bool  | Is the Multi Site Origin feature 
enabled for this delivery service (0=false, 1=true). See 
:ref:`rl-multi-site-origin`                |
   
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
-  | ``multiSiteOriginAlgor`` |  bool  | Is the Multi Site Origin feature 
enabled for this delivery service (0=false, 1=true). See 
:ref:`rl-multi-site-origin`                |
-  
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
   | ``orgServerFqdn``        | string | The origin server base URL (FQDN when 
used in this instance, includes the                                             
               |
   |                          |        | protocol (http:// or https://) for use 
in retrieving content from the origin server.                                   
              |
   
+--------------------------+--------+--------------------------------------------------------------------------------------------------------------------------------------+
@@ -462,7 +457,6 @@ Delivery Service
             "missLat": "41.881944",
             "missLong": "-87.627778",
             "multiSiteOrigin": false,
-            "multiSiteOriginAlgorithm": null,
             "orgServerFqdn": "http://baz.boo.net";,
             "originShield": null,
             "profileDescription": "Content Router for over-the-top",

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/docs/source/development/traffic_ops_api/v12/profile.rst
----------------------------------------------------------------------
diff --git a/docs/source/development/traffic_ops_api/v12/profile.rst 
b/docs/source/development/traffic_ops_api/v12/profile.rst
index bec8f9f..546222b 100644
--- a/docs/source/development/traffic_ops_api/v12/profile.rst
+++ b/docs/source/development/traffic_ops_api/v12/profile.rst
@@ -35,7 +35,7 @@ Profiles
        
+---------------+----------+----------------------------------------------------+
        |    Name       | Required |                    Description             
        |
        
+===============+==========+====================================================+
-       | ``param``     |   no     | Used to filter profiles by parameter.      
        |
+       | ``param``     |   no     | Used to filter profiles by parameter ID.   
        |
        
+---------------+----------+----------------------------------------------------+
 
        **Response Properties**
@@ -43,24 +43,33 @@ Profiles
        
+-----------------+--------+----------------------------------------------------+
        |    Parameter    |  Type  |                    Description             
        |
        
+=================+========+====================================================+
-       | ``lastUpdated`` | array  | The Time / Date this server entry was last 
updated |
+       | ``id``          | string | Primary key                                
        |
        
+-----------------+--------+----------------------------------------------------+
        | ``name``        | string | The name for the profile                   
        |
        
+-----------------+--------+----------------------------------------------------+
-       | ``id``          | string | Primary key                                
        |
-       
+-----------------+--------+----------------------------------------------------+
        | ``description`` | string | The description for the profile            
        |
        
+-----------------+--------+----------------------------------------------------+
+       | ``cdn``         |  int   | The CDN ID                                 
        |
+       
+-----------------+--------+----------------------------------------------------+
+       | ``cdnName``     | string | The CDN name                               
        |
+       
+-----------------+--------+----------------------------------------------------+
+       | ``type``        | string | Profile type                               
        |
+       
+-----------------+--------+----------------------------------------------------+
+       | ``lastUpdated`` | array  | The Time / Date this server entry was last 
updated |
+       
+-----------------+--------+----------------------------------------------------+
 
   **Response Example** ::
 
     {
      "response": [
         {
-            "lastUpdated": "2012-10-08 19:34:45",
-            "name": "CCR_TOP",
             "id": "8",
-            "description": "Content Router for top.foobar.net"
+            "name": "EDGE_27_PROFILE",
+            "description": "A profile with all the Foo parameters"
+            "cdn": 1
+            "cdnName": "cdn1"
+            "type": "ATS_PROFILE"
+            "lastUpdated": "2012-10-08 19:34:45",
         }
      ]
     }
@@ -86,7 +95,7 @@ Profiles
     {
      "response": [
         {
-            "name": "CCR_TOP"
+            "name": "EDGE_27_PROFILE"
         }
      ]
     }
@@ -112,24 +121,33 @@ Profiles
        
+-----------------+--------+----------------------------------------------------+
        |    Parameter    |  Type  |                    Description             
        |
        
+=================+========+====================================================+
-       | ``lastUpdated`` | array  | The Time / Date this server entry was last 
updated |
+       | ``id``          | string | Primary key                                
        |
        
+-----------------+--------+----------------------------------------------------+
        | ``name``        | string | The name for the profile                   
        |
        
+-----------------+--------+----------------------------------------------------+
-       | ``id``          | string | Primary key                                
        |
-       
+-----------------+--------+----------------------------------------------------+
        | ``description`` | string | The description for the profile            
        |
        
+-----------------+--------+----------------------------------------------------+
+       | ``cdn``         |  int   | The CDN ID                                 
        |
+       
+-----------------+--------+----------------------------------------------------+
+       | ``cdnName``     | string | The CDN name                               
        |
+       
+-----------------+--------+----------------------------------------------------+
+       | ``type``        | string | Profile type                               
        |
+       
+-----------------+--------+----------------------------------------------------+
+       | ``lastUpdated`` | array  | The Time / Date this server entry was last 
updated |
+       
+-----------------+--------+----------------------------------------------------+
 
   **Response Example** ::
 
     {
      "response": [
         {
-            "lastUpdated": "2012-10-08 19:34:45",
-            "name": "CCR_TOP",
             "id": "8",
-            "description": "Content Router for top.foobar.net"
+            "name": "EDGE_27_PROFILE",
+            "description": "A profile with all the Foo parameters"
+            "cdn": 1
+            "cdnName": "cdn1"
+            "type": "ATS_PROFILE"
+            "lastUpdated": "2012-10-08 19:34:45",
         }
      ]
     }
@@ -138,7 +156,7 @@ Profiles
 
 
 **POST /api/1.2/profiles**
-    Create a new empty  profile. 
+    Create a new empty profile.
 
        Authentication Required: Yes
 
@@ -146,19 +164,26 @@ Profiles
 
        **Request Properties**
 
-       
+-----------------------+--------+----------------------------------------------------+
-       |    Parameter          |  Type  |                    Description       
              |
-       
+=======================+========+====================================================+
-       | ``name``              | string | The name of the new profile          
              |
-       
+-----------------------+--------+----------------------------------------------------+
-       | ``description``       | string | new profile description              
              |
-       
+-----------------------+--------+----------------------------------------------------+
+       
+-----------------------+--------+----------+-----------------------------------------+
+       |  Parameter            |  Type  | Required |           Description     
              |
+       
+=======================+========+==========+=========================================+
+       | ``name``              | string | yes      | Profile name              
              |
+       
+-----------------------+--------+----------+-----------------------------------------+
+       | ``description``       | string | yes      | Profile description       
              |
+       
+-----------------------+--------+----------+-----------------------------------------+
+       | ``cdn``               |  int   | no       | CDN ID                    
              |
+       
+-----------------------+--------+----------+-----------------------------------------+
+       | ``type``              | string | yes      | Profile type              
              |
+       
+-----------------------+--------+----------+-----------------------------------------+
+
 
   **Request Example** ::
 
     {
-      "name": "CCR_COPY",
-      "description": "CCR_COPY description",
+      "name": "EDGE_28_PROFILE",
+      "description": "EDGE_28_PROFILE description",
+      "cdn": 1,
+      "type": "ATS_PROFILE"
     }
 
 |
@@ -168,11 +193,15 @@ Profiles
        
+-----------------------+--------+----------------------------------------------------+
        |    Parameter          |  Type  |                    Description       
              |
        
+=======================+========+====================================================+
-       | ``id``                | string | Id of the new profile                
              |
+       | ``id``                | string | Profile ID                           
              |
        
+-----------------------+--------+----------------------------------------------------+
-       | ``name``              | string | The name of the new profile          
              |
+       | ``name``              | string | Profile name                         
              |
+       
+-----------------------+--------+----------------------------------------------------+
+       | ``description``       | string | Profile description                  
              |
+       
+-----------------------+--------+----------------------------------------------------+
+       | ``cdn``               |  int   | CDN ID                               
              |
        
+-----------------------+--------+----------------------------------------------------+
-       | ``description``       | string | new profile description              
              |
+       | ``type``              | string | Profile type                         
              |
        
+-----------------------+--------+----------------------------------------------------+
 
   **Response Example** ::
@@ -181,8 +210,10 @@ Profiles
      "response": [
         {
             "id": "66",
-            "name": "CCR_COPY",
-            "description": "CCR_COPY description",
+            "name": "EDGE_28_PROFILE",
+            "description": "EDGE_28_PROFILE description",
+                       "cdn": 1,
+               "type": "ATS_PROFILE"
         }
      ]
     }
@@ -257,50 +288,52 @@ Profiles
 
        **Request Properties**
 
-       
+-----------------+----------+---------------------------------------------------+
-       | Parameter       | Required | Description                              
         |
-       
+=================+==========+===================================================+
-       | ``name``        | yes      | The new name for the profile.            
         |
-       
+-----------------+----------+---------------------------------------------------+
-       | ``description`` | yes      | The new description for the profile.     
         |
-       
+-----------------+----------+---------------------------------------------------+
+       
+-----------------------+--------+----------+-----------------------------------------+
+       |  Parameter            |  Type  | Required |           Description     
              |
+       
+=======================+========+==========+=========================================+
+       | ``name``              | string | yes      | Profile name              
              |
+       
+-----------------------+--------+----------+-----------------------------------------+
+       | ``description``       | string | yes      | Profile description       
              |
+       
+-----------------------+--------+----------+-----------------------------------------+
+       | ``cdn``               |  int   | no       | CDN ID                    
              |
+       
+-----------------------+--------+----------+-----------------------------------------+
+       | ``type``              | string | yes      | Profile type              
              |
+       
+-----------------------+--------+----------+-----------------------------------------+
 
   **Request Example** ::
 
     {
-      "name": "CCR_UPDATE",
-      "description": "CCR_UPDATE description"
+      "name": "EDGE_28_PROFILE",
+      "description": "EDGE_28_PROFILE description",
+      "cdn": 1,
+      "type": "ATS_PROFILE"
     }
 
        **Response Properties**
 
-       +------------------+--------+----------------------------------+
-       |  Parameter       |  Type  |           Description            |
-       +==================+========+==================================+
-       | ``response``     |        | The updated profile info.        |
-       +------------------+--------+----------------------------------+
-       | ``>id``          | string | Profile id.                      |
-       +------------------+--------+----------------------------------+
-       | ``>name``        | string | Profile name.                    |
-       +------------------+--------+----------------------------------+
-       | ``>description`` | string | Profile description.             |
-       +------------------+--------+----------------------------------+
-       | ``alerts``       | array  | A collection of alert messages.  |
-       +------------------+--------+----------------------------------+
-       | ``>level``       | string | success, info, warning or error. |
-       +------------------+--------+----------------------------------+
-       | ``>text``        | string | Alert message.                   |
-       +------------------+--------+----------------------------------+
-       | ``version``      | string |                                  |
-       +------------------+--------+----------------------------------+
+       
+-----------------------+--------+----------------------------------------------------+
+       |    Parameter          |  Type  |                    Description       
              |
+       
+=======================+========+====================================================+
+       | ``id``                | string | Profile ID                           
              |
+       
+-----------------------+--------+----------------------------------------------------+
+       | ``name``              | string | Profile name                         
              |
+       
+-----------------------+--------+----------------------------------------------------+
+       | ``description``       | string | Profile description                  
              |
+       
+-----------------------+--------+----------------------------------------------------+
+       | ``cdn``               |  int   | CDN ID                               
              |
+       
+-----------------------+--------+----------------------------------------------------+
+       | ``type``              | string | Profile type                         
              |
+       
+-----------------------+--------+----------------------------------------------------+
 
   **Response Example** ::
 
     {
       "response":{
         "id": "219",
-        "name": "CCR_UPDATE",
-        "description": "CCR_UPDATE description"
+        "name": "EDGE_28_PROFILE",
+        "description": "EDGE_28_PROFILE description"
+        "cdn": 1
+        "type": "ATS_PROFILE"
       }
       "alerts":[
         {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/API/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Cdn.pm b/traffic_ops/app/lib/API/Cdn.pm
index af7c0f5..dca96cc 100644
--- a/traffic_ops/app/lib/API/Cdn.pm
+++ b/traffic_ops/app/lib/API/Cdn.pm
@@ -37,10 +37,10 @@ sub index {
                push(
                        @data, {
                                "id"            => $row->id,
+                               "name"          => $row->name,
+                               "domainName"    => $row->domain_name,
                                "dnssecEnabled" => \$row->dnssec_enabled,
                                "lastUpdated"   => $row->last_updated,
-                               "name"          => $row->name,
-                               "domainName"    => $row->domain_name
                        }
                );
        }
@@ -57,10 +57,10 @@ sub show {
                push(
                        @data, {
                                "id"            => $row->id,
+                               "name"          => $row->name,
+                               "domainName"    => $row->domain_name,
                                "dnssecEnabled" => \$row->dnssec_enabled,
                                "lastUpdated"   => $row->last_updated,
-                               "name"          => $row->name,
-                               "domainName"    => $row->domain_name
                        }
                );
        }
@@ -77,10 +77,10 @@ sub name {
                push(
                        @data, {
                                "id"            => $row->id,
+                               "name"          => $row->name,
+                               "domainName"    => $row->domain_name,
                                "dnssecEnabled" => \$row->dnssec_enabled,
                                "lastUpdated"   => $row->last_updated,
-                               "name"          => $row->name,
-                               "domainName"    => $row->domain_name
                        }
                );
        }
@@ -159,10 +159,6 @@ sub update {
                return $self->not_found();
        }
 
-       if ( !defined($params) ) {
-               return $self->alert("parameters must be in JSON format.");
-       }
-
        if ( !defined( $params->{name} ) ) {
                return $self->alert("Name is required.");
        }
@@ -171,22 +167,32 @@ sub update {
                return $self->alert("dnssecEnabled is required.");
        }
 
+       if ( !defined( $params->{domainName} ) ) {
+               return $self->alert("Domain Name is required.");
+       }
+
        my $existing = $self->db->resultset('Cdn')->search( { name => 
$params->{name} } )->single();
        if ( $existing && $existing->id != $cdn->id ) {
-               $self->app->log->error( "a cdn with name '" . $params->{name} . 
"' already exists." );
                return $self->alert( "a cdn with name " . $params->{name} . " 
already exists." );
        }
 
+       $existing = $self->db->resultset('Cdn')->search( { domain_name => 
$params->{domainName} } )->single();
+       if ( $existing && $existing->id != $cdn->id ) {
+               return $self->alert( "a cdn with domain name " . 
$params->{domainName} . " already exists." );
+       }
+
        my $values = {
                name => $params->{name},
                dnssec_enabled => $params->{dnssecEnabled},
+               domain_name => $params->{domainName},
        };
 
        my $rs = $cdn->update($values);
        if ( $rs ) {
                my $response;
-               $response->{id}            = $rs->id;
-               $response->{name}          = $rs->name;
+               $response->{id}                 = $rs->id;
+               $response->{name}               = $rs->name;
+               $response->{domainName}         = $rs->domain_name;
                $response->{dnssecEnabled} = \$rs->dnssec_enabled;
                &log( $self, "Updated CDN name '" . $rs->name . "' for id: " . 
$rs->id, "APICHANGE" );
                return $self->success( $response, "CDN update was successful." 
);

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/API/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm 
b/traffic_ops/app/lib/API/Deliveryservice.pm
index fd91af2..88935fc 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -191,9 +191,9 @@ sub show {
                                "multiSiteOrigin"          => 
\$row->multi_site_origin,
                                "orgServerFqdn"            => 
$row->org_server_fqdn,
                                "originShield"             => 
$row->origin_shield,
-                               "profileId"                => $row->profile->id,
-                               "profileName"              => 
$row->profile->name,
-                               "profileDescription"       => 
$row->profile->description,
+                               "profileId"                => 
defined($row->profile) ? $row->profile->id : undef,
+                               "profileName"              => 
defined($row->profile) ? $row->profile->name : undef,
+                               "profileDescription"       => 
defined($row->profile) ? $row->profile->description : undef,
                                "protocol"                 => $row->protocol,
                                "qstringIgnore"            => 
$row->qstring_ignore,
                                "rangeRequestHandling"     => 
$row->range_request_handling,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/API/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Profile.pm 
b/traffic_ops/app/lib/API/Profile.pm
index 065cd59..8a0793e 100644
--- a/traffic_ops/app/lib/API/Profile.pm
+++ b/traffic_ops/app/lib/API/Profile.pm
@@ -30,16 +30,17 @@ sub index {
        my $parameter_id = $self->param('param');
 
        if ( defined $parameter_id ) {
-               my $rs = $self->db->resultset('ProfileParameter')->search( { 
parameter => $parameter_id },  { prefetch => [ 'profile' ], order_by => 
$orderby }  );
+               my $rs = $self->db->resultset('ProfileParameter')->search( { 
parameter => $parameter_id },  { prefetch => [ 'profile' ] }  );
                while ( my $row = $rs->next ) {
                        push(
                                @data, {
-                                       "id" => $row->profile->id,
-                                       "name" => $row->profile->name,
-                                       "description" => 
$row->profile->description,
-                                       "cdn" => $row->profile->cdn,
-                                       "type" => $row->profile->type,
-                                       "lastUpdated" => 
$row->profile->last_updated
+                                       "id"                    => 
$row->profile->id,
+                                       "name"                  => 
$row->profile->name,
+                                       "description"   => 
$row->profile->description,
+                                       "cdn"                   => 
defined($row->profile->cdn) ? $row->profile->cdn->id : undef,
+                                       "cdnName"               => 
defined($row->profile->cdn) ? $row->profile->cdn->name : undef,
+                                       "type"                  => 
$row->profile->type,
+                                       "lastUpdated"   => 
$row->profile->last_updated
                                }
                        );
                }
@@ -51,7 +52,8 @@ sub index {
                                        "id"          => $row->id,
                                        "name"        => $row->name,
                                        "description" => $row->description,
-                                       "cdn"         => defined($row->cdn) ? 
$row->cdn->name : "-",
+                                       "cdn"         => defined($row->cdn) ? 
$row->cdn->id : undef,
+                                       "cdnName"     => defined($row->cdn) ? 
$row->cdn->name : undef,
                                        "type"        => $row->type,
                                        "lastUpdated" => $row->last_updated
                                }
@@ -107,7 +109,7 @@ sub show {
        my $self = shift;
        my $id   = $self->param('id');
 
-       my $rs_data = $self->db->resultset("Profile")->search( { id => $id } );
+       my $rs_data = $self->db->resultset("Profile")->search( { 'me.id' => $id 
}, { prefetch => [ 'cdn' ] } );
        my @data = ();
        while ( my $row = $rs_data->next ) {
                push(
@@ -115,6 +117,9 @@ sub show {
                                "id"          => $row->id,
                                "name"        => $row->name,
                                "description" => $row->description,
+                               "cdn"         => defined($row->cdn) ? 
$row->cdn->id : undef,
+                               "cdnName"     => defined($row->cdn) ? 
$row->cdn->name : undef,
+                               "type"        => $row->type,
                                "lastUpdated" => $row->last_updated
                        }
                );
@@ -143,6 +148,10 @@ sub create {
                return $self->alert("profile 'description' is required.");
        }
 
+       if ( !defined( $params->{type} ) ) {
+               return $self->alert("Profile type is required.");
+       }
+
        my $existing_profile = $self->db->resultset('Profile')->search( { name 
=> $name } )->get_column('name')->single();
        if ( $existing_profile && $name eq $existing_profile ) {
                return $self->alert("profile with name $name already exists.");
@@ -285,6 +294,10 @@ sub update {
                }
        }
 
+       if ( !defined( $params->{type} ) ) {
+               return $self->alert("Profile type is required.");
+       }
+
        my $cdn = $params->{cdn};
        my $type = $params->{type};
        my $values = {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm 
b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
index 146a5da..80f475d 100644
--- a/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Integration/Deliveryservice.pm
@@ -72,7 +72,6 @@ my %definition_for = (
                        dns_bypass_ip               => '',
                        edge_header_rewrite         => 'add-header 
X-Powered-By: KBLTN [L]',
                        multi_site_origin           => undef,
-                       # multi_site_origin_algorithm => undef,
                        tr_request_headers          => undef,
                },
        },
@@ -83,7 +82,6 @@ my %definition_for = (
                        xml_id                      => 'games-c1',
                        regional_geo_blocking       => 0,
                        multi_site_origin           => undef,
-                       # multi_site_origin_algorithm => undef,
                        protocol                    => '0',
                        dns_bypass_ttl              => undef,
                        edge_header_rewrite         => 'cond 
%{SEND_RESPONSE_HDR_HOOK} __RETURN__ add-header X-CDN-Info 
"KableTown___CACHE_IPV4__" [L]',
@@ -138,7 +136,6 @@ my %definition_for = (
                        type                        => '10',
                        dns_bypass_cname            => undef,
                        multi_site_origin           => undef,
-                       # multi_site_origin_algorithm => undef,
                        qstring_ignore              => '0',
                        ccr_dns_ttl                 => '3600',
                        dscp                        => '40',
@@ -208,7 +205,6 @@ my %definition_for = (
                        long_desc_1                 => 'test-ds1 long_desc_1',
                        max_dns_answers             => '0',
                        multi_site_origin           => '1',
-                       # multi_site_origin_algorithm => '0',
                        active                      => '1',
                        edge_header_rewrite         => 'cond 
%{REMAP_PSEUDO_HOOK} __RETURN__ set-config 
proxy.config.http.transaction_active_timeout_out 5 [L]',
                        global_max_mbps             => '0',
@@ -252,7 +248,6 @@ my %definition_for = (
                        ipv6_routing_enabled        => undef,
                        mid_header_rewrite          => undef,
                        multi_site_origin           => undef,
-                       # multi_site_origin_algorithm => undef,
                        qstring_ignore              => '0',
                        active                      => '1',
                        cacheurl                    => undef,
@@ -305,7 +300,6 @@ my %definition_for = (
                        miss_long                   => '-87.627778',
                        org_server_fqdn             => 
'https://games.origin.kabletown.net',
                        multi_site_origin           => undef,
-                       # multi_site_origin_algorithm => undef,
                        cacheurl                    => undef,
                        dns_bypass_ip               => '',
                        dns_bypass_ip6              => undef,
@@ -352,7 +346,6 @@ my %definition_for = (
                        global_max_tps              => '0',
                        initial_dispersion          => '1',
                        multi_site_origin           => undef,
-                       # multi_site_origin_algorithm => undef,
                        org_server_fqdn             => 
'http://national-tv.origin.kabletown.net',
                        signed                      => '0',
                        display_name                => 'tv-nat-c2',
@@ -392,7 +385,6 @@ my %definition_for = (
                        long_desc                   => 'test- long_desc',
                        long_desc_2                 => 'test- long_desc_2',
                        multi_site_origin           => undef,
-                       # multi_site_origin_algorithm => undef,
                        origin_shield               => undef,
                        protocol                    => '0',
                        ipv6_routing_enabled        => undef,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/Fixtures/Parameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Parameter.pm 
b/traffic_ops/app/lib/Fixtures/Parameter.pm
index d8e4d69..1d645e9 100644
--- a/traffic_ops/app/lib/Fixtures/Parameter.pm
+++ b/traffic_ops/app/lib/Fixtures/Parameter.pm
@@ -19,15 +19,6 @@ use namespace::autoclean;
 use Digest::SHA1 qw(sha1_hex);
 
 my %definition_for = (
-       # domain_name => {
-       #       new   => 'Parameter',
-       #       using => {
-       #               id          => 3,
-       #               name        => 'domain_name',
-       #               value       => 'foo.com',
-       #               config_file => 'CRConfig.json',
-       #       },
-       # },
        health_threadhold_loadavg => {
                new   => 'Parameter',
                using => {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/lib/UI/Cdn.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Cdn.pm b/traffic_ops/app/lib/UI/Cdn.pm
index 3f2f160..5a80899 100644
--- a/traffic_ops/app/lib/UI/Cdn.pm
+++ b/traffic_ops/app/lib/UI/Cdn.pm
@@ -114,10 +114,6 @@ sub create {
     my $data = $self->get_cdns();
     my $cdns = $data->{'cdn'};
 
-    foreach my $f ($self->param) {
-      print $f . " => " . Dumper($self->param($f)) . "\n";
-    }
-
     if ( !$self->isValidCdn() ) {
         $self->stash(
             fbox_layout => 1,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/3b1df01e/traffic_ops/app/t/api/1.1/cachegroupparameter.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.1/cachegroupparameter.t 
b/traffic_ops/app/t/api/1.1/cachegroupparameter.t
index 504f15b..ef65b66 100644
--- a/traffic_ops/app/t/api/1.1/cachegroupparameter.t
+++ b/traffic_ops/app/t/api/1.1/cachegroupparameter.t
@@ -46,7 +46,7 @@ 
$t->get_ok("/api/1.1/cachegroupparameters.json")->status_is(200)->or( sub { diag
   ->json_is( '/response/cachegroupParameters/0/cachegroup', 
'mid-northeast-group' )->json_is( '/response/cachegroupParameters/0/parameter', 
"60" )
   ->json_is( '/response/cachegroupParameters/1/cachegroup', 
'mid-northeast-group' )->json_is( '/response/cachegroupParameters/0/parameter', 
"60" )
   ->json_is( '/response/cachegroupParameters/1/cachegroup', 
'mid-northeast-group' )->json_is( '/response/cachegroupParameters/1/parameter', 
"61" )
-  ->json_is( '/response/cachegroupParameters/2/cachegroup', 
'mid-northwest-group' )->json_is( '/response/cachegroupParameters/2/parameter', 
"60" );
+  ->json_is( '/response/cachegroupParameters/2/cachegroup', 
'mid-northwest-group' )->json_is( '/response/cachegroupParameters/2/parameter', 
"61" );
 
 ok $t->get_ok('/logout')->status_is(302)->or( sub { diag 
$t->tx->res->content->asset->{content}; } );
 $dbh->disconnect();


Reply via email to