fixed: Syndicated Content URLs using macros not updated by caching workflow

This commit is contained in:
Graham Knop 2008-03-25 20:53:03 +00:00
parent 0bf48f9349
commit b65defdf03
2 changed files with 46 additions and 56 deletions

View file

@ -21,6 +21,7 @@
- fixed: Thingy shows things from other Thingies - fixed: Thingy shows things from other Thingies
- fixed: Collaboration System errors when missing RSS From Parent - fixed: Collaboration System errors when missing RSS From Parent
- fixed: Syndicated Content picks wrong entries for interleaving - fixed: Syndicated Content picks wrong entries for interleaving
- fixed: Syndicated Content URLs using macros not updated by caching workflow
7.5.7 7.5.7
- fixed: HttpProxy mixes original site's content encoding with WebGUI's - fixed: HttpProxy mixes original site's content encoding with WebGUI's

View file

@ -69,48 +69,38 @@ See WebGUI::Workflow::Activity::execute() for details.
=cut =cut
sub execute { sub execute {
my $self = shift; my $self = shift;
my $object = shift; my $object = shift;
my $instance = shift; my $instance = shift;
unless (defined $instance) { unless (defined $instance) {
$self->session->errorHandler->error("Could not instanciate Workflow Instance in GetSyndicatedContent Activity"); $self->session->errorHandler->error("Could not instanciate Workflow Instance in GetSyndicatedContent Activity");
return $self->ERROR; return $self->ERROR;
} }
my @syndicatedUrls = @{$self->getSyndicatedUrls($instance)}; # start time to check for timeouts
my @arrayCopy = @syndicatedUrls; # copy we can delete elements from inside the foreach loop my $time = time();
my $time = time();
foreach my $urls (@syndicatedUrls) { my @syndicatedUrls = @{$self->getSyndicatedUrls($instance)};
#Loop through the SyndicatedWobjects and split all the URLs they are syndicating off into while (my $url = shift(@syndicatedUrls)) {
#a separate array. # Get RSS data, which will be stored in the cache
my @urlsToSyndicate = split(/\s+/,$urls); $self->session->errorHandler->info("GetSyndicatedContent workflow: Caching $url");
my $returnValue = WebGUI::Asset::Wobject::SyndicatedContent::_get_rss_data($self->session, $url);
if (!defined $returnValue) {
$self->session->errorHandler->error("GetSyndicatedContent Workflow Activity: _get_rss_data returned undef while trying to process syndicated content url $url, which usually indicates an improper URL, or a malformed document");
next;
}
# Check for timeout
last
if (time() - $time > 55);
}
foreach my $url (@urlsToSyndicate) { # if there are urls left, we need to process again
# We could timeout in here but I don't see a good way to handle that right now if (scalar(@syndicatedUrls) > 0) {
# May need to fix this in the future. $instance->setScratch("syndicatedUrls", JSON::to_json(\@syndicatedUrls));
my $returnValue = WebGUI::Asset::Wobject::SyndicatedContent::_get_rss_data($self->session, $url); return $self->WAITING;
unless (defined $returnValue) { }
$self->session->errorHandler->error("GetSyndicatedContent Workflow Activity: _get_rss_data returned undef while trying to process syndicated content url $url, which usually indicates an improper URL, or a malformed document"); $instance->deleteScratch("syndicatedUrls");
next; return $self->COMPLETE;
}
}
# Delete this element from the array
splice(@arrayCopy,0,1);
# Check for timeout
last unless (time() - $time <= 60);
}
# See if we're done
if (scalar(@arrayCopy) > 0) {
$instance->setScratch("syndicatedUrls", JSON::to_json(@arrayCopy));
return $self->WAITING;
}
$instance->deleteScratch("syndicatedUrls");
return $self->COMPLETE;
} }
#--------------------------------------------------------------------- #---------------------------------------------------------------------
@ -126,24 +116,23 @@ A reference to the current webgui session
=cut =cut
sub getSyndicatedUrls { sub getSyndicatedUrls {
my $self = shift; my $self = shift;
my $instance = shift; my $instance = shift;
my $syndicatedUrls = $instance->getScratch("syndicatedUrls"); my $syndicatedUrls = $instance->getScratch("syndicatedUrls");
if ($syndicatedUrls) {
unless ($syndicatedUrls) { return JSON::from_json($syndicatedUrls);
my $urls = $self->session->db->buildArrayRef("select }
distinct SyndicatedContent.rssUrl from SyndicatedContent
left join
asset on SyndicatedContent.assetId=asset.assetId
where
asset.state='published'"
);
$instance->setScratch("syndicatedUrls", JSON::to_json($urls));
return $urls;
}
return JSON::from_json($syndicatedUrls); my $urls = [];
my $assets = WebGUI::Asset->getRoot($self->session)->getLineage(['descendants'], {
includeOnlyClasses => ['WebGUI::Asset::Wobject::SyndicatedContent'],
returnObjects => 1,
});
foreach my $asset (@$assets) {
push @$urls, split(/\s+/, $asset->getRssUrl);
}
$instance->setScratch("syndicatedUrls", JSON::to_json($urls));
return $urls;
} }