This is an automated email from the ASF dual-hosted git repository.

elsloo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit 16896974085669bebce296c4a116f96b5b047b0f
Author: Jan van Doorn <jan_vando...@cable.comcast.com>
AuthorDate: Fri Nov 18 12:40:43 2016 -0700

    Add deep_caching_type to DB, API, CRConfig, and UI.
    
    (cherry picked from commit 160a539446c46f9a593e208492bded4781418c6e)
---
 .../20171012000000_add_deep_caching_type.sql       | 23 ++++++++++++++++++++++
 traffic_ops/app/lib/API/Deliveryservice.pm         | 14 +++++++++++--
 traffic_ops/app/lib/UI/DeliveryService.pm          |  3 +++
 traffic_ops/app/lib/UI/Topology.pm                 |  5 +++++
 .../app/templates/delivery_service/_form.html.ep   | 15 ++++++++++++++
 5 files changed, 58 insertions(+), 2 deletions(-)

diff --git 
a/traffic_ops/app/db/migrations/20171012000000_add_deep_caching_type.sql 
b/traffic_ops/app/db/migrations/20171012000000_add_deep_caching_type.sql
new file mode 100644
index 0000000..17c78cc
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20171012000000_add_deep_caching_type.sql
@@ -0,0 +1,23 @@
+/*
+       Licensed 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.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+
+alter table deliveryservice add column deep_caching_type smallint default 0;
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+
+ alter table deliveryservice drop column deep_caching_type;
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm 
b/traffic_ops/app/lib/API/Deliveryservice.pm
index 5db2fd2..b78b5a7 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -106,6 +106,7 @@ sub index {
                                "cdnId"                => $row->cdn->id,
                                "cdnName"              => $row->cdn->name,
                                "checkPath"            => $row->check_path,
+                               "deepCachingType"      => 
$row->deep_caching_type,
                                "displayName"          => $row->display_name,
                                "dnsBypassCname"       => 
$row->dns_bypass_cname,
                                "dnsBypassIp"          => $row->dns_bypass_ip,
@@ -226,6 +227,7 @@ sub show {
                                "cdnId"                => $row->cdn->id,
                                "cdnName"              => $row->cdn->name,
                                "checkPath"            => $row->check_path,
+                               "deepCachingType"      => 
$row->deep_caching_type,
                                "displayName"          => $row->display_name,
                                "dnsBypassCname"       => 
$row->dns_bypass_cname,
                                "dnsBypassIp"          => $row->dns_bypass_ip,
@@ -332,6 +334,7 @@ sub update {
                ccr_dns_ttl            => $params->{ccrDnsTtl},
                cdn_id                 => $params->{cdnId},
                check_path             => $params->{checkPath},
+               deep_caching_type      => $params->{deepCachingType},
                display_name           => $params->{displayName},
                dns_bypass_cname       => $params->{dnsBypassCname},
                dns_bypass_ip          => $params->{dnsBypassIp},
@@ -429,6 +432,7 @@ sub update {
                                "cdnId"                    => $rs->cdn->id,
                                "cdnName"                  => $rs->cdn->name,
                                "checkPath"                => $rs->check_path,
+                               "deepCachingType"          => 
$rs->deep_caching_type,
                                "displayName"              => $rs->display_name,
                                "dnsBypassCname"           => 
$rs->dns_bypass_cname,
                                "dnsBypassIp"              => 
$rs->dns_bypass_ip,
@@ -560,6 +564,7 @@ sub safe_update {
                                "cdnId"                    => $rs->cdn->id,
                                "cdnName"                  => $rs->cdn->name,
                                "checkPath"                => $rs->check_path,
+                               "deepCachingType"          => 
$rs->deep_caching_type,
                                "displayName"              => $rs->display_name,
                                "dnsBypassCname"           => 
$rs->dns_bypass_cname,
                                "dnsBypassIp"              => 
$rs->dns_bypass_ip,
@@ -666,6 +671,7 @@ sub create {
                ccr_dns_ttl            => $params->{ccrDnsTtl},
                cdn_id                 => $params->{cdnId},
                check_path             => $params->{checkPath},
+               deep_caching_type      => $params->{deepCachingType},
                display_name           => $params->{displayName},
                dns_bypass_cname       => $params->{dnsBypassCname},
                dns_bypass_ip          => $params->{dnsBypassIp},
@@ -774,6 +780,7 @@ sub create {
                                "cdnId"                    => $insert->cdn->id,
                                "cdnName"                  => 
$insert->cdn->name,
                                "checkPath"                => 
$insert->check_path,
+                               "deepCachingType"          => 
$insert->deep_caching_type,
                                "displayName"              => 
$insert->display_name,
                                "dnsBypassCname"           => 
$insert->dns_bypass_cname,
                                "dnsBypassIp"              => 
$insert->dns_bypass_ip,
@@ -966,6 +973,7 @@ sub get_deliveryservices_by_serverId {
                                        "cdnId"                => $row->cdn->id,
                                        "cdnName"              => 
$row->cdn->name,
                                        "checkPath"            => 
$row->check_path,
+                                       "deepCachingType"      => 
$row->deep_caching_type,
                                        "displayName"          => 
$row->display_name,
                                        "dnsBypassCname"       => 
$row->dns_bypass_cname,
                                        "dnsBypassIp"          => 
$row->dns_bypass_ip,
@@ -1064,6 +1072,7 @@ sub get_deliveryservices_by_userId {
                                        "cdnId"                => $row->cdn->id,
                                        "cdnName"              => 
$row->cdn->name,
                                        "checkPath"            => 
$row->check_path,
+                                       "deepCachingType"      => 
$row->deep_caching_type,
                                        "displayName"          => 
$row->display_name,
                                        "dnsBypassCname"       => 
$row->dns_bypass_cname,
                                        "dnsBypassIp"          => 
$row->dns_bypass_ip,
@@ -1335,7 +1344,7 @@ sub is_deliveryservice_request_valid {
 
        my $rules = {
                fields => [
-                       qw/customer contentType deliveryProtocol routingType 
routingName serviceDesc peakBPSEstimate peakTPSEstimate maxLibrarySizeEstimate 
originURL hasOriginDynamicRemap originTestFile hasOriginACLWhitelist 
originHeaders otherOriginSecurity queryStringHandling rangeRequestHandling 
hasSignedURLs hasNegativeCachingCustomization negativeCachingCustomizationNote 
serviceAliases rateLimitingGBPS rateLimitingTPS overflowService 
headerRewriteEdge headerRewriteMid headerRewriteRedirectRouter notes/
+                       qw/customer contentType deepCachingType 
deliveryProtocol routingType routingName serviceDesc peakBPSEstimate 
peakTPSEstimate maxLibrarySizeEstimate originURL hasOriginDynamicRemap 
originTestFile hasOriginACLWhitelist originHeaders otherOriginSecurity 
queryStringHandling rangeRequestHandling hasSignedURLs 
hasNegativeCachingCustomization negativeCachingCustomizationNote serviceAliases 
rateLimitingGBPS rateLimitingTPS overflowService headerRewriteEdge 
headerRewriteMid headerRewriteRedire [...]
                ],
 
                # Validation checks to perform
@@ -1370,7 +1379,7 @@ sub is_deliveryservice_valid {
 
        my $rules = {
                fields => [
-                       qw/active cacheurl ccrDnsTtl cdnId checkPath 
displayName dnsBypassCname dnsBypassIp dnsBypassIp6 dnsBypassTtl dscp 
edgeHeaderRewrite geoLimitRedirectURL geoLimit geoLimitCountries geoProvider 
globalMaxMbps globalMaxTps httpBypassFqdn infoUrl initialDispersion 
ipv6RoutingEnabled logsEnabled longDesc longDesc1 longDesc2 maxDnsAnswers 
midHeaderRewrite missLat missLong multiSiteOrigin multiSiteOriginAlgorithm 
orgServerFqdn originShield profileId protocol qstringIgnore 
rangeRequestHandling [...]
+                       qw/active cacheurl ccrDnsTtl cdnId checkPath 
deepCachingType displayName dnsBypassCname dnsBypassIp dnsBypassIp6 
dnsBypassTtl dscp edgeHeaderRewrite geoLimitRedirectURL geoLimit 
geoLimitCountries geoProvider globalMaxMbps globalMaxTps httpBypassFqdn infoUrl 
initialDispersion ipv6RoutingEnabled logsEnabled longDesc longDesc1 longDesc2 
maxDnsAnswers midHeaderRewrite missLat missLong multiSiteOrigin 
multiSiteOriginAlgorithm orgServerFqdn originShield profileId protocol 
qstringIgnore rang [...]
                ],
 
                # validation checks to perform for ALL delivery services
@@ -1378,6 +1387,7 @@ sub is_deliveryservice_valid {
                        active                          => [ is_required("is 
required") ],
                        cdnId                           => [ is_required("is 
required"), \&is_valid_int_or_undef ],
                        ccrDnsTtl                       => [ 
\&is_valid_int_or_undef ],
+                       deepCachingType      => [ is_like( qr/^[01]$/, "must be 
0 (never) or 1 (always)" ) ],
                        dnsBypassTtl                    => [ 
\&is_valid_int_or_undef ],
                        dscp                            => [ is_required("is 
required"), \&is_valid_int_or_undef ],
                        displayName                     => [ is_required("is 
required"), is_long_at_most( 48, 'too long' ) ],
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm 
b/traffic_ops/app/lib/UI/DeliveryService.pm
index c9fac43..f1c47d9 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -255,6 +255,7 @@ sub read {
                                "initial_dispersion"          => 
$row->initial_dispersion,
                                "regional_geo_blocking"       => 
$row->regional_geo_blocking,
                                "logs_enabled"                => 
\$row->logs_enabled,
+                               "deep_caching_type"           => 
$row->deep_caching_type,
                        }
                );
        }
@@ -835,6 +836,7 @@ sub update {
                        remap_text         => $self->paramAsScalar( 
'ds.remap_text',         undef ),
                        initial_dispersion => $self->paramAsScalar( 
'ds.initial_dispersion', 1 ),
                        logs_enabled       => 
$self->paramAsScalar('ds.logs_enabled'),
+                       deep_caching_type  => 
$self->paramAsScalar('ds.deep_caching_type'),
                );
 
                my $typename = $self->typename();
@@ -1073,6 +1075,7 @@ sub create {
                                initial_dispersion => $self->paramAsScalar( 
'ds.initial_dispersion', 1 ),
                                logs_enabled       => 
$self->paramAsScalar('ds.logs_enabled'),
                                tenant_id => $tenant_id,
+                               deep_caching_type  => 
$self->paramAsScalar('ds.deep_caching_type'),
                };
 
                my $insert = 
$self->db->resultset('Deliveryservice')->create($new_ds);
diff --git a/traffic_ops/app/lib/UI/Topology.pm 
b/traffic_ops/app/lib/UI/Topology.pm
index e22addd..93c176b 100644
--- a/traffic_ops/app/lib/UI/Topology.pm
+++ b/traffic_ops/app/lib/UI/Topology.pm
@@ -399,6 +399,8 @@ sub gen_crconfig_json {
             $data_obj->{'deliveryServices'}->{ $row->xml_id }->{'geoEnabled'} 
= $geoEnabled;
         }
 
+        $data_obj->{'deliveryServices'}->{ $row->xml_id }->{'deepCachingType'} 
= $row->deep_caching_type;
+
         # Default to 'http only'
         $data_obj->{'deliveryServices'}->{ $row->xml_id }->{'sslEnabled'} = 
'false';
         $data_obj->{'deliveryServices'}->{ $row->xml_id 
}->{'protocol'}->{'acceptHttps'} = 'false';
@@ -705,6 +707,9 @@ sub stringify_ds {
     if ( defined( $ds->{'missLocation'} ) ) {
         $string .= "|GeoMiss: " . $ds->{'missLocation'}->{'lat'} . "," . 
$ds->{'missLocation'}->{'long'};
     }
+    if (defined( $ds->{'deepCachingType'} ) ) {
+        $string .= "|deepCachingType: " . $ds->{'deepCachingType'};
+    }
     if ( defined( $ds->{'bypassDestination'} ) ) {
         $string .= "<br>|BypassDest:";
         if ( defined( $ds->{'bypassDestination'}->{'DNS'}->{'ip'} ) ) {
diff --git a/traffic_ops/app/templates/delivery_service/_form.html.ep 
b/traffic_ops/app/templates/delivery_service/_form.html.ep
index 36cff33..50d1802 100644
--- a/traffic_ops/app/templates/delivery_service/_form.html.ep
+++ b/traffic_ops/app/templates/delivery_service/_form.html.ep
@@ -617,4 +617,19 @@
                        <% } %>
                <% } %>
        </div>
+       <div class="block form-row" id="deep_caching_type">
+               <% unless (field('ds.deep_caching_type')->valid) { %>
+                       <span class="field-with-error"><%= 
field('ds.deep_caching_type')->error %></span>
+               <% } %>
+               %= label_for 'deep_caching_type' => '* Deep Caching', class => 
'label'
+               <% if ($priv_level >= 20) { %>
+               %= field('ds.deep_caching_type')->select([["Never" => 0], 
["Always" => 1]]);
+               <% } else { %>
+                       <%  if ($ds->deep_caching_type == 0 ) {%>
+                               %= field('ds.deep_caching_type')->text(class => 
'field', readonly => 'readonly', value => 'Never');
+                       <% } elsif ($ds->deep_caching_type == 1 ) {%>
+                               %= field('ds.deep_caching_type')->text(class => 
'field', readonly => 'readonly', value => 'Always');
+                       <% } %>
+               <% } %>
+       </div>
 </div>

-- 
To stop receiving notification emails like this one, please contact
els...@apache.org.

Reply via email to