Skip to content

Commit

Permalink
Remove the unsupported description field
Browse files Browse the repository at this point in the history
The ability to set this was removed in pan 8 back in 2008.

This is backwards incompatible as it changes the on-disk DB format.
  • Loading branch information
jrha committed Nov 27, 2024
1 parent dcd76d4 commit c6febe2
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 73 deletions.
19 changes: 1 addition & 18 deletions src/main/perl/CacheManager/Element.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ EDG::WP4::CCM::CacheManager::Element - Element class
$path = $element->getPath()
$type = $element->getType();
$checksum = $element->getChecksum();
$description = $element->getDescription();
$value = $element->getValue();
$boolean = $element->isType($type);
$boolean = $element->isResource();
Expand Down Expand Up @@ -86,7 +85,6 @@ sub new
$self->{PATH} = undef; # should be a Path object
$self->{TYPE} = undef; # should a valid TYPE constant)
$self->{CHECKSUM} = undef;
$self->{DESCRIPTION} = undef;
$self->{VALUE} = undef;

# path can be a string or a Path object
Expand Down Expand Up @@ -343,18 +341,6 @@ sub getChecksum
return $self->{CHECKSUM};
}

=item getDescription()
Returns the element's description
=cut

sub getDescription
{
my $self = shift;
return $self->{DESCRIPTION};
}

=item getValue()
Returns the element's value, as a string
Expand Down Expand Up @@ -646,13 +632,10 @@ sub _read_metadata
return;
}

foreach my $md (qw(TYPE CHECKSUM DESCRIPTION)) {
foreach my $md (qw(TYPE CHECKSUM)) {
my $val = $hashref->{$keys->{$md}};
if (defined($val)) {
$self->{$md} = $val;
} elsif ($md eq 'DESCRIPTION') {
# metadata attribute "description" is optional
$self->{$md} = "";
} else {
throw_error("failed to read element's $md eid $self->{EID}");
return;
Expand Down
4 changes: 2 additions & 2 deletions src/main/perl/CacheManager/Encode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Readonly::Hash our %NAME_TYPE_MAP => {

# sorted names to compute pack'ed values for
# using offset based on index in this array
Readonly::Array our @EIDS_PACK => qw(VALUE TYPE CHECKSUM DESCRIPTION);
Readonly::Array our @EIDS_PACK => qw(VALUE TYPE CHECKSUM);

# DB filenames (typically in profilepath)
Readonly our $PATH2EID => 'path2eid';
Expand Down Expand Up @@ -144,7 +144,7 @@ sub decode_eid
=item encode_eids
Given C<eid>, return the keys of the tie'ed DB hashref
for C<VALUE>, C<TYPE>, C<CHECKSUM> and C<DESCRIPTION>
for C<VALUE>, C<TYPE> and C<CHECKSUM>
as used in the C<eid2data> DB.
=cut
Expand Down
1 change: 0 additions & 1 deletion src/main/perl/Fetch/XMLPanProfile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use constant VALID_ATTRIBUTES => {
CHECKSUM => 1,
ACL => 1,
ENCODING => 1,
DESCRIPTION => 1,
USERTYPE => 1
};

Expand Down
2 changes: 1 addition & 1 deletion src/test/perl/cli.t
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ like($txt,
qr{eid2data:\n0 => a\0c\0e\n10000000 => nlist\n20000000 => 1740877ebcb53b5132e75cff986cd705\n1 => b}m,
"dumpdb output eid2data");
like($txt,
qr{path2eid and eid2data combined:\n/ \(0\) =>\n V: a\0c\0e\n T: nlist\n C: 1740877ebcb53b5132e75cff986cd705\n D: <undef>\n/a \(1\) =>\n},
qr{path2eid and eid2data combined:\n/ \(0\) =>\n V: a\0c\0e\n T: nlist\n C: 1740877ebcb53b5132e75cff986cd705\n/a \(1\) =>\n},
"dumpdb ouptut combined path2eid eid2data");
diag $txt;

Expand Down
12 changes: 1 addition & 11 deletions src/test/perl/element.t
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ sub gen_dbm ($$) {
# checksum
$key = 0x20000001;
$hash{pack("L", $key)} = md5_hex("$val|$type");
# description
$key = 0x30000001;
$hash{pack("L", $key)} = "an example of string";

# value
$key = 0x00000002;
Expand All @@ -85,15 +82,12 @@ sub gen_dbm ($$) {
# checksum
$key = 0x20000002;
$hash{pack("L", $key)} = md5_hex("$val|$type");
# description
$key = 0x30000002;
$hash{pack("L", $key)} = "an example of list";

untie(%hash);
}

my ($element, $property, $resource, $path);
my ($type, $checksum, $description, $value);
my ($type, $checksum, $value);
my ($string);

my ($cm, $config, $cache_dir, $profile);
Expand Down Expand Up @@ -157,10 +151,6 @@ is($type, EDG::WP4::CCM::CacheManager::Element->STRING, "Element->getType()" );
$checksum = $element->getChecksum();
is($checksum, md5_hex("a string|string"), "Element->getChecksum()");

# test getDescription()
$description = $element->getDescription();
is($description, "an example of string", "Element->getDescription()");

# test getValue()
$value = $element->getValue();
is($value, "a string", "Element->getValue()");
Expand Down
3 changes: 1 addition & 2 deletions src/test/perl/encode.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ foreach my $name (sort keys %map) {
is(type_from_name('something'), UNDEFINED, "type_from_name returns UNDEFINED");

is_deeply(\@EIDS_PACK,
[qw(VALUE TYPE CHECKSUM DESCRIPTION)],
[qw(VALUE TYPE CHECKSUM)],
"EIDS_PACK array");

is_deeply(encode_eids(123), {
VALUE => pack('L', 123),
TYPE => pack('L', 1 << 28 | 123),
CHECKSUM => pack('L', 2 << 28 | 123),
DESCRIPTION => pack('L', 3 << 28 | 123),
}, "encode_eids for id 123");

is(decode_eid(encode_eids(123)->{VALUE}), 123, "decode encoded eid returns original");
Expand Down
6 changes: 0 additions & 6 deletions src/test/perl/property.t
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ sub gen_dbm
$key = 0x20000001;
$hash{pack("L", $key)} = md5_hex("$val|$type");

# description
$key = 0x30000001;
$hash{pack("L", $key)} = "an example of string";
untie(%hash);

return (SUCCESS);
Expand Down Expand Up @@ -106,9 +103,6 @@ is($property->getType(), EDG::WP4::CCM::CacheManager::Element->STRING, "property
# test getChecksum()
is($property->getChecksum(), md5_hex("a string|string"), "property Element->getChecksum()");

# test getDescription()
is($property->getDescription(), "an example of string", "property Element->getDescription()");

# test getValue()
ok($property->getValue(), "property Element->getValue()");

Expand Down
32 changes: 2 additions & 30 deletions src/test/perl/resource.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use warnings;
use POSIX qw (getpid);
use DB_File;
use Digest::MD5 qw(md5_hex);
use Test::Simple tests => 41;
use Test::Simple tests => 40;
use LC::Exception qw(SUCCESS throw_error);

use EDG::WP4::CCM::CacheManager qw ($DATA_DN $GLOBAL_LOCK_FN
Expand All @@ -21,7 +21,7 @@ use EDG::WP4::CCM::Path;
use CCMTest qw (eok make_file);

my ($resource, $path, $string, $type);
my ($checksum, $description, $value);
my ($checksum, $value);

my ($cm, $config, $cache_dir, $profile, %hash, $key, @array, $i, $name);

Expand Down Expand Up @@ -101,10 +101,6 @@ sub gen_dbm ($$) {
$key = 0x20000001;
$hash{pack("L",$key)} = md5_hex("$value|$type");

# description
$key = 0x30000001;
$hash{pack("L",$key)} = "an example of list";

# value
$key = 0x00000002;
$value = "element 0";
Expand All @@ -119,10 +115,6 @@ sub gen_dbm ($$) {
$key = 0x20000002;
$hash{pack("L",$key)} = md5_hex("$key|$value");

# description
$key = 0x30000002;
$hash{pack("L",$key)} = "an example of string";

# value
$key = 0x00000003;
$value = "element 1";
Expand All @@ -137,10 +129,6 @@ sub gen_dbm ($$) {
$key = 0x20000003;
$hash{pack("L",$key)} = md5_hex("$key|$value");

# description
$key = 0x30000003;
$hash{pack("L",$key)} = "an example of string";

# value
$key = 0x00000004;
$value = chr(122).chr(101).chr(114).chr(111).chr(0).chr(111).chr(110).chr(101);
Expand All @@ -155,10 +143,6 @@ sub gen_dbm ($$) {
$key = 0x20000004;
$hash{pack("L",$key)} = md5_hex("$key|$value");

# description
$key = 0x30000004;
$hash{pack("L",$key)} = "an example of nlist";

# value
$key = 0x00000005;
$value = "element zero";
Expand All @@ -173,10 +157,6 @@ sub gen_dbm ($$) {
$key = 0x20000005;
$hash{pack("L",$key)} = md5_hex("$key|$value");

# description
$key = 0x30000005;
$hash{pack("L",$key)} = "an example of string";

# value
$key = 0x00000006;
$value = "element one";
Expand All @@ -191,10 +171,6 @@ sub gen_dbm ($$) {
$key = 0x20000006;
$hash{pack("L",$key)} = md5_hex("$key|$value");

# description
$key = 0x30000006;
$hash{pack("L",$key)} = "an example of string";

untie(%hash);

return (1);
Expand Down Expand Up @@ -239,10 +215,6 @@ ok($type == EDG::WP4::CCM::CacheManager::Resource->LIST, "Resource->getType()");
$checksum = $resource->getChecksum();
ok($checksum eq md5_hex(chr(48).chr(0).chr(49)."|list"), "Resource->getChecksum()");

# test getDescription()
$description = $resource->getDescription();
ok($description eq "an example of list", "Resource->getDescription()");

# test getValue()
$value = $resource->getValue();
ok($value eq chr(48).chr(0).chr(49), "Resource->getValue()");
Expand Down
2 changes: 0 additions & 2 deletions src/test/perl/xmlpan.t
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ sub InterpretNode
$val->{ACL} = $att->{$a};
} elsif ($a eq 'encoding') {
$val->{ENCODING} = $att->{$a};
} elsif ($a eq 'description') {
$val->{DESCRIPTION} = $att->{$a};
} elsif ($a eq 'type') {
$val->{USERTYPE} = $att->{$a};
} else {
Expand Down

0 comments on commit c6febe2

Please sign in to comment.