Skip to content

Commit

Permalink
Relocate internal CCM modules
Browse files Browse the repository at this point in the history
  • Loading branch information
stdweird committed Mar 22, 2017
1 parent 052159a commit 1713a03
Show file tree
Hide file tree
Showing 30 changed files with 192 additions and 192 deletions.
8 changes: 4 additions & 4 deletions src/main/perl/CacheManager.pm
@@ -1,7 +1,7 @@
#${PMpre} EDG::WP4::CCM::CacheManager${PMpost}

use LC::Exception qw(SUCCESS throw_error);
use EDG::WP4::CCM::Configuration qw();
use EDG::WP4::CCM::CacheManager::Configuration qw();
use EDG::WP4::CCM::CCfg qw(initCfg getCfgValue);
use MIME::Base64 qw(encode_base64);
use parent qw(Exporter);
Expand Down Expand Up @@ -315,7 +315,7 @@ This method is deprecated in favour of C<getConfiguration>.
Returns unlocked Configuration object.
Unless the object is locked explicitly later by calling the C<lock> method,
C<CCM::Element>s will always be fetched from the current CID,
C<CCM::CacheManager::Element>s will always be fetched from the current CID,
not the CID passed via C<$cid>. (If the $cid parameter is omitted,
the most recently downloaded configuration (when the cache
was not globally locked) is returned.)
Expand Down Expand Up @@ -365,7 +365,7 @@ This method is deprecated in favour of C<getConfiguration>.
Returns unlocked anonymous Configuration object.
Unless the object is locked explicitly later by calling the C<lock> method,
C<CCM::Element>s will always be fetched from the current CID,
C<CCM::CacheManager::Element>s will always be fetched from the current CID,
not the CID passed via C<$cid>. (If the $cid parameter is omitted,
the most recently downloaded configuration (when the cache
was not globally locked) is returned.)
Expand Down Expand Up @@ -414,7 +414,7 @@ sub _getConfig

my $name_template = exists($opts{name_template}) ? $opts{name_template} : $self->{name_template};

my $cfg = EDG::WP4::CCM::Configuration->new($self, $cid, $lc, $anonymous, $name_template);
my $cfg = EDG::WP4::CCM::CacheManager::Configuration->new($self, $cid, $lc, $anonymous, $name_template);
unless (defined($cfg)) {
$ec->rethrow_error();
return ();
Expand Down
@@ -1,9 +1,9 @@
#${PMpre} EDG::WP4::CCM::Configuration${PMpost}
#${PMpre} EDG::WP4::CCM::CacheManager::Configuration${PMpost}

use POSIX qw (getpid);
use LC::Exception qw(SUCCESS throw_error);
use EDG::WP4::CCM::CacheManager;
use EDG::WP4::CCM::Element;
use EDG::WP4::CCM::CacheManager::Element;
use CAF::FileWriter;

use EDG::WP4::CCM::Path;
Expand All @@ -17,7 +17,7 @@ Readonly our $DEFAULT_NAME_TEMPLATE_TYPE => 'name';

=head1 NAME
EDG::WP4::CCM::Configuration - Configuration class
EDG::WP4::CCM::CacheManager::Configuration - Configuration class
=head1 SYNOPSIS
Expand Down Expand Up @@ -58,7 +58,7 @@ When the C<locked> flag is set (or when the C<lock> method is called to set it),
the Configuration instance is bound to the specific CID, even if this is not
the CacheManager's current one (e.g. when a new profile is fetched during the lifetime
of the process, the CacheManager current CID is updated to the latest one).
The locking is relevant when a C<CCM::Element> is accessed via
The locking is relevant when a C<CCM::CacheManager::Element> is accessed via
a C<CCM::Configuration> instance (in particular, when a call to C<_prepareElement>
is made).
As a consequence, an unlocked Configuration instance will always use the
Expand Down Expand Up @@ -357,7 +357,7 @@ sub isLocked
}

# _prepareElement prepares for accessing the actual
# profile data via the EDG::WP4::CCM::Element class.
# profile data via the EDG::WP4::CCM::CacheManager::Element class.
# It converts the C<path> argument to a CCM::Path instance
# (if needed) and updates the CID to the latest available
# if the configuration is not locked.
Expand Down Expand Up @@ -470,9 +470,9 @@ sub getElement
}

# Actual access to the data happens here
my $el = EDG::WP4::CCM::Element->createElement($self, $path);
my $el = EDG::WP4::CCM::CacheManager::Element->createElement($self, $path);
unless ($el) {
throw_error("EDG::WP4::CCM::Element->createElement ($self, $path)", $ec->error);
throw_error("EDG::WP4::CCM::CacheManager::Element->createElement ($self, $path)", $ec->error);
return ();
}
return $el;
Expand Down Expand Up @@ -517,9 +517,9 @@ sub elementExists
}

# Actual access to the data happens here
my $ex = EDG::WP4::CCM::Element->elementExists($self, $path);
my $ex = EDG::WP4::CCM::CacheManager::Element->elementExists($self, $path);
unless (defined($ex)) {
throw_error("EDG::WP4::CCM::Element->elementExists ($self, $path)", $ec->error);
throw_error("EDG::WP4::CCM::CacheManager::Element->elementExists ($self, $path)", $ec->error);
return ();
}
return $ex;
Expand Down
10 changes: 5 additions & 5 deletions src/main/perl/DB.pm → src/main/perl/CacheManager/DB.pm
@@ -1,19 +1,19 @@
#${PMpre} EDG::WP4::CCM::DB${PMpost}
#${PMpre} EDG::WP4::CCM::CacheManager::DB${PMpost}

=head1 NAME
EDG::WP4::CCM::DB
EDG::WP4::CCM::CacheManager::DB
=head1 SYNOPSIS
# Class style
my $db = EDG::WP4::CCM::DB->new($prefix, %opts);
my $db = EDG::WP4::CCM::CacheManager::DB->new($prefix, %opts);
# Write the hashref to the database file
$db->write($hashref);
# Open the database and tie to hashref
$db->open($hashref);
# Direct read access to database (combines new and open)
$success = EDG::WP4::CCM::DB::read($hashref, $prefix);
$success = EDG::WP4::CCM::CacheManager::DB::read($hashref, $prefix);
=head1 DESCRIPTION
Expand Down Expand Up @@ -288,7 +288,7 @@ sub read_db
{
my ($hashref, $prefix, %opts) = @_;

my $db = EDG::WP4::CCM::DB->new($prefix, %opts);
my $db = EDG::WP4::CCM::CacheManager::DB->new($prefix, %opts);
return $db->open($hashref);
}

Expand Down
22 changes: 11 additions & 11 deletions src/main/perl/Element.pm → src/main/perl/CacheManager/Element.pm
@@ -1,14 +1,14 @@
#${PMpre} EDG::WP4::CCM::Element${PMpost}
#${PMpre} EDG::WP4::CCM::CacheManager::Element${PMpost}

use DB_File;
use File::Spec;
use Encode qw(decode_utf8);
use LC::Exception qw(SUCCESS throw_error);
use EDG::WP4::CCM::Configuration;
use EDG::WP4::CCM::CacheManager::Configuration;
use EDG::WP4::CCM::Path qw(escape unescape);
use EDG::WP4::CCM::Resource;
use EDG::WP4::CCM::CacheManager::Resource;
use Exporter;
use EDG::WP4::CCM::DB qw(read_db);
use EDG::WP4::CCM::CacheManager::DB qw(read_db);

our @ISA = qw(Exporter);
our @EXPORT = qw(unescape);
Expand Down Expand Up @@ -36,7 +36,7 @@ my $ec = LC::Exception::Context->new->will_store_errors;

=head1 NAME
EDG::WP4::CCM::Element - Element class
EDG::WP4::CCM::CacheManager::Element - Element class
=head1 SYNOPSIS
Expand All @@ -55,10 +55,10 @@ EDG::WP4::CCM::Element - Element class
=head1 DESCRIPTION
The class C<EDG::WP4::CCM::Element> implements those methods
The class C<EDG::WP4::CCM::CacheManager::Element> implements those methods
that are common to all elements and represents a C<Property>.
The class <EDG::WP4::CCM::Element> is a base class for
C<EDG::WP4::CCM::Resource>, which has additional methods.
The class <EDG::WP4::CCM::CacheManager::Element> is a base class for
C<EDG::WP4::CCM::CacheManager::Resource>, which has additional methods.
Type constants:
Expand Down Expand Up @@ -103,7 +103,7 @@ sub new

$config = shift; # profile's directory path

if (!UNIVERSAL::isa($config, "EDG::WP4::CCM::Configuration")) {
if (!UNIVERSAL::isa($config, "EDG::WP4::CCM::CacheManager::Configuration")) {
throw_error("usage: Element->new(config, ele_path)");
return ();
}
Expand Down Expand Up @@ -288,13 +288,13 @@ sub createElement
}

if ($ele_type & PROPERTY) {
$element = EDG::WP4::CCM::Element->new($config, $ele_path);
$element = EDG::WP4::CCM::CacheManager::Element->new($config, $ele_path);
unless ($element) {
throw_error("Element->new($config, $ele_path)", $ec->error);
return ();
}
} elsif ($ele_type & RESOURCE) {
$element = EDG::WP4::CCM::Resource->new($config, $ele_path);
$element = EDG::WP4::CCM::CacheManager::Resource->new($config, $ele_path);
unless ($element) {
throw_error("Resource->new($config, $ele_path)", $ec->error);
return ();
Expand Down
@@ -1,13 +1,13 @@
#${PMpre} EDG::WP4::CCM::Resource${PMpost}
#${PMpre} EDG::WP4::CCM::CacheManager::Resource${PMpost}

use LC::Exception qw(SUCCESS throw_error);
use parent qw(EDG::WP4::CCM::Element);
use parent qw(EDG::WP4::CCM::CacheManager::Element);

my $ec = LC::Exception::Context->new->will_store_errors;

=head1 NAME
EDG::WP4::CCM::Resource - Resource class
EDG::WP4::CCM::CacheManager::Resource - Resource class
=head1 SYNOPSIS
Expand Down Expand Up @@ -93,7 +93,7 @@ sub getHash
} else {
$el_path = $path . "/" . $name;
}
$ele = EDG::WP4::CCM::Element->createElement($self->{CONFIG}, $el_path);
$ele = EDG::WP4::CCM::CacheManager::Element->createElement($self->{CONFIG}, $el_path);
unless ($ele) {
throw_error("failed to create element $el_path)", $ec->error);
return ();
Expand Down Expand Up @@ -137,7 +137,7 @@ sub getList
} else {
$el_path = $path . "/" . $i;
}
$ele = EDG::WP4::CCM::Element->createElement($self->{CONFIG}, $el_path);
$ele = EDG::WP4::CCM::CacheManager::Element->createElement($self->{CONFIG}, $el_path);
unless ($ele) {
throw_error("failed to create element $el_path", $ec->error);
return ();
Expand Down Expand Up @@ -217,7 +217,7 @@ sub getCurrentElement
$el_path = $path . "/" . $self->{ELEMENTS}[$self->{CURRENT}];
}

$element = EDG::WP4::CCM::Element->createElement($self->{CONFIG}, $el_path);
$element = EDG::WP4::CCM::CacheManager::Element->createElement($self->{CONFIG}, $el_path);
unless ($element) {
throw_error("failed to create element $el_path", $ec->error);
return ();
Expand Down
@@ -1,10 +1,10 @@
#${PMpre} EDG::WP4::CCM::JSONProfileSimple${PMpost}
#${PMpre} EDG::WP4::CCM::Fetch::JSONProfileSimple${PMpost}

=pod
=head1 SYNOPSIS
EDG::WP4::CCM::JSONProfileSimple->interpret_node($tag, $jsondoc);
EDG::WP4::CCM::Fetch::JSONProfileSimple->interpret_node($tag, $jsondoc);
=head1 DESCRIPTION
Expand Down
@@ -1,10 +1,10 @@
#${PMpre} EDG::WP4::CCM::JSONProfileTyped${PMpost}
#${PMpre} EDG::WP4::CCM::Fetch::JSONProfileTyped${PMpost}

=pod
=head1 SYNOPSIS
EDG::WP4::CCM::JSONProfileTyped->interpret_node($tag, $jsondoc);
EDG::WP4::CCM::Fetch::JSONProfileTyped->interpret_node($tag, $jsondoc);
=head1 DESCRIPTION
Expand Down
8 changes: 4 additions & 4 deletions src/main/perl/Fetch/ProfileCache.pm
Expand Up @@ -14,7 +14,7 @@ Module provides methods to handle the creation of the profile cache.
=cut

use EDG::WP4::CCM::DB;
use EDG::WP4::CCM::CacheManager::DB;

use POSIX;

Expand Down Expand Up @@ -365,7 +365,7 @@ sub choose_interpreter

my $tree;
if ($self->{PROFILE_URL} =~ m{json(?:\.gz)?$}) {
my $module = "EDG::WP4::CCM::JSONProfile" . ($self->{JSON_TYPED} ? 'Typed' : 'Simple' );
my $module = "EDG::WP4::CCM::Fetch::JSONProfile" . ($self->{JSON_TYPED} ? 'Typed' : 'Simple' );
$tree = _decode_json($profile, $self->{JSON_TYPED});
return ($module, ['profile', $tree]);
}
Expand All @@ -376,7 +376,7 @@ sub choose_interpreter
die("XML parse of profile failed: $@") if ($@);

if ($tree->[1]->[0]->{format} eq 'pan') {
return ('EDG::WP4::CCM::XMLPanProfile', $tree);
return ('EDG::WP4::CCM::Fetch::XMLPanProfile', $tree);
} else {
die "Invalid profile format. Did you supply an unsupported XMLDB profile?";
}
Expand Down Expand Up @@ -487,7 +487,7 @@ sub MakeDatabase

foreach my $db ([$path2eid_db, \%path2eid],
[$eid2data_db, \%eid2data]) {
my $ccmdb = EDG::WP4::CCM::DB->new($db->[0], log => $self);
my $ccmdb = EDG::WP4::CCM::CacheManager::DB->new($db->[0], log => $self);
my $err = $ccmdb->write($db->[1], $dbformat, $self->{permission}->{file});
if ($err) {
$self->error($err);
Expand Down
@@ -1,10 +1,10 @@
#${PMpre} EDG::WP4::CCM::XMLPanProfile${PMpost}
#${PMpre} EDG::WP4::CCM::Fetch::XMLPanProfile${PMpost}

=pod
=head1 SYNOPSIS
EDG::WP4::CCM::XMLPanProfile->interpret_node($tag, $xmltree);
EDG::WP4::CCM::Fetch::XMLPanProfile->interpret_node($tag, $xmltree);
=head1 DESCRIPTION
Expand Down
18 changes: 9 additions & 9 deletions src/main/perl/TextRender.pm
Expand Up @@ -2,7 +2,7 @@

use CAF::TextRender qw($YAML_BOOL_PREFIX);
use Readonly;
use EDG::WP4::CCM::TT::Scalar qw(%ELEMENT_TYPES);
use EDG::WP4::CCM::TextRender::Scalar qw(%ELEMENT_TYPES);
use EDG::WP4::CCM::Path qw(escape unescape);
use XML::Parser;
use parent qw(CAF::TextRender Exporter);
Expand Down Expand Up @@ -144,7 +144,7 @@ Readonly::Array our @CCM_FORMATS => sort keys %TEXTRENDER_FORMATS;;
=head1 DESCRIPTION
This class is an extension of the C<CAF::TextRender> class; with the main
difference the support of a C<EDG::WP4::CCM:Element> instance as contents.
difference the support of a C<EDG::WP4::CCM::CacheManager::Element> instance as contents.
=head2 Private methods
Expand Down Expand Up @@ -214,7 +214,7 @@ generates series of blocks
=item contents
C<contents> is either a hash reference holding the contents to pass to the rendering module;
or a C<EDG::WP4::CCM:Element> instance, on which C<getTree> is called with any C<element>
or a C<EDG::WP4::CCM::CacheManager::Element> instance, on which C<getTree> is called with any C<element>
options.
=back
Expand Down Expand Up @@ -428,7 +428,7 @@ sub _make_predefined_options
}

# Return the validated contents. Either the contents are a hashref
# (in that case they are left untouched) or a C<EDG::WP4::CCM::Element> instance
# (in that case they are left untouched) or a C<EDG::WP4::CCM::CacheManager::Element> instance
# in which case C<getTree> is called together with the relevant C<elementopts>
sub make_contents
{
Expand All @@ -441,7 +441,7 @@ sub make_contents
# Additional variables available to both regular hashref and element
my $extra_vars = {
ref => sub { return ref($_[0]) },
is_scalar => sub { my $r = ref($_[0]); return (! $r || $r eq 'EDG::WP4::CCM::TT::Scalar'); },
is_scalar => sub { my $r = ref($_[0]); return (! $r || $r eq 'EDG::WP4::CCM::TextRender::Scalar'); },
is_list => sub { my $r = ref($_[0]); return ($r && ($r eq 'ARRAY')); },
is_hash => sub { my $r = ref($_[0]); return ($r && ($r eq 'HASH')); },
escape => \&escape,
Expand All @@ -452,7 +452,7 @@ sub make_contents
if($ref && ($ref eq "HASH")) {
$contents = $self->{contents};
} elsif ($ref && UNIVERSAL::can($self->{contents}, 'can') &&
$self->{contents}->isa('EDG::WP4::CCM::Element')) {
$self->{contents}->isa('EDG::WP4::CCM::CacheManager::Element')) {
# Test for a blessed reference with UNIVERSAL::can
# UNIVERSAL::can also return true for scalars, so also test
# if it's a reference to start with
Expand All @@ -479,13 +479,13 @@ sub make_contents
}
}

# Last step: add convert methods for scalar types to CCM::TT::Scalar
# Last step: add convert methods for scalar types to CCM::TextRender::Scalar
# if the render method is TT
if ($self->{method_is_tt}) {
foreach my $type (qw(boolean string long double)) {
push(@{$opts{"convert_$type"}}, sub {
my $scalartype = $ELEMENT_TYPES{(uc $type)};
return EDG::WP4::CCM::TT::Scalar->new($_[0], $scalartype);
return EDG::WP4::CCM::TextRender::Scalar->new($_[0], $scalartype);
});
}
}
Expand All @@ -499,7 +499,7 @@ sub make_contents

} else {
return $self->fail("Contents passed is neither a hashref or ",
"a EDG::WP4::CCM::Element instance ",
"a EDG::WP4::CCM::CacheManager::Element instance ",
"(ref ", ref($self->{contents}), ")");
}

Expand Down

0 comments on commit 1713a03

Please sign in to comment.