3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 # (Except where explictly superceded by other copyright notices)
7 # This work is made available to you under the terms of Version 2 of
8 # the GNU General Public License. A copy of that license should have
9 # been provided with this software, but in any event can be snarfed
12 # This work is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # Unless otherwise specified, all modifications, corrections or
18 # extensions to this work which alter its source code become the
19 # property of Best Practical Solutions, LLC when submitted for
20 # inclusion in the work.
39 This class provides a base class for URIs, such as those handled
53 Create a new RT::URI object.
60 my $class = ref($proto) || $proto;
62 bless( $self, $class );
64 $self->CurrentUser(@_);
73 =head2 FromObject <Object>
75 Given a local object, such as an RT::Ticket or an RT::FM::Article, this routine will return a URI for
84 return undef unless $obj->can('URI');
85 return $self->FromURI($obj->URI);
94 Returns a local object id for this content. You are expected to know what sort of object this is the Id
103 return undef unless ($uri);
106 # Special case: integers passed in as URIs must be ticket ids
107 if ($uri =~ /^(\d+)$/) {
108 $scheme = "fsck.com-rt";
109 } elsif ($uri =~ /^((?:\w|\.|-)+?):/) {
113 $RT::Logger->warning("$self Could not determine a URI scheme for $uri");
117 # load up a resolver object for this scheme
118 $self->_GetResolver($scheme);
120 unless ($self->Resolver->ParseURI($uri)) {
121 $RT::Logger->warning("Resolver ".ref($self->Resolver)." could not parse $uri");
131 =private _GetResolver <scheme>
133 Gets an RT URI resolver for the scheme <scheme>.
134 Falls back to a null resolver. RT::URI::base.
142 $scheme =~ s/(\.|-)/_/g;
147 require RT::URI::$scheme;
148 \$resolver = RT::URI::$scheme->new(\$self->CurrentUser);
152 $self->{'resolver'} = $resolver;
154 $self->{'resolver'} = RT::URI::base->new($self->CurrentUser);
165 Returns a local object id for this content. You are expected to know what sort of object this is the Id
172 return ($self->Resolver->Scheme);
180 Returns a local object id for this content. You are expected to know what sort of object this is the Id
187 return ($self->Resolver->URI);
196 Returns a local object for this content. This will usually be an RT::Ticket or somesuch
203 return($self->Resolver->Object);
214 Returns a local object for this content. This will usually be an RT::Ticket or somesuch
220 return $self->Resolver->IsLocal;
229 Returns this URI's URI resolver object
236 return ($self->{'resolver'});
239 eval "require RT::URI_Vendor";
240 die $@ if ($@ && $@ !~ qr{^Can't locate RT/URI_Vendor.pm});
241 eval "require RT::URI_Local";
242 die $@ if ($@ && $@ !~ qr{^Can't locate RT/URI_Local.pm});