Merge commit 'f2e0fb509a' into WebGUI8. Some tests still failing.

This commit is contained in:
Colin Kuskie 2010-06-27 22:32:31 -07:00
commit 385931aaab
92 changed files with 1966 additions and 650 deletions

View file

@ -72,26 +72,39 @@ sub execute {
my $self = shift;
my $session = $self->session;
my $epoch = time();
my $expireTime = $epoch + $self->getTTL();
my $getAnArchive = WebGUI::Asset::Wobject::StoryArchive->getIsa($session);
ARCHIVE: while (my $archive = $getAnArchive->()) {
next ARCHIVE unless $archive && $archive->get("archiveAfter");
my $archiveDate = $epoch - $archive->get("archiveAfter");
my $folders = $archive->getLineage(
my $folderIter = $archive->getLineageIterator(
['children'],
{
statusToInclude => ['approved'],
whereClause => 'creationDate < '.$session->db->quote($archiveDate),
returnObjects => 1,
},
);
FOLDER: foreach my $folder (@{ $folders }) {
next FOLDER unless $folder;
my $stories = $folder->getLineage(
['children'], { returnObjects => 1, },
);
STORY: foreach my $story (@{ $stories }) {
next STORY unless $story;
FOLDER: while ( 1 ) {
my $folder;
eval { $folder = $folderIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $folder;
my $storyIter = $folder->getLineageIterator( ['children'] );
STORY: while ( 1 ) {
my $story;
eval { $story = $storyIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $story;
$story->update({ status => 'archived' });
if (time() > $expireTime) {
return $self->WAITING(1);
}
}
$folder->update({ status => 'archived' });
}

View file

@ -107,19 +107,25 @@ sub execute {
# kill temporary assets
my $tempspace = WebGUI::Asset->getTempspace($self->session);
my $children = $tempspace->getLineage(["children"], {
returnObjects => 1,
my $childIter = $tempspace->getLineageIterator(["children"], {
statesToInclude => [qw(trash clipboard published)],
statusToInclude => [qw(pending archived approved)],
});
foreach my $asset (@{$children}) {
if (time() - $asset->get("revisionDate") > $self->get("storageTimeout")) {
unless ($asset->purge) {
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $child;
if (time() - $child->get("revisionDate") > $self->get("storageTimeout")) {
unless ($child->purge) {
return $self->ERROR;
}
}
# taking too long, give up
return $self->WAITING(1) if (time() - $start > 50);
return $self->WAITING(1) if (time() - $start > $self->getTTL);
}
# kill temporary files

View file

@ -76,13 +76,20 @@ sub execute {
# keep track of how much time it's taking
my $start = time;
my $limit = 2_500;
my $timeLimit = 60;
my $timeLimit = $self->getTTL;
my $list = $root->getLineage( ['descendants'], { returnObjects => 1,
my $emsFormIter = $root->getLineageIterator( ['descendants'], {
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
} );
for my $emsForm ( @$list ) {
while ( 1 ) {
my $emsForm;
eval { $emsForm = $emsFormIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $emsForm;
my $daysBeforeCleanup = $emsForm->get('daysBeforeCleanup') ;
next if ! $daysBeforeCleanup;
my $whereClause = q{ submissionStatus='denied' };
@ -91,12 +98,19 @@ sub execute {
}
my $checkDate = time - ( 60*60*24* $daysBeforeCleanup );
$whereClause .= q{ and assetData.lastModified < } . $checkDate;
my $res = $emsForm->getLineage(['children'],{ returnObjects => 1,
my $submissionIter = $emsForm->getLineageIterator(['children'],{
joinClass => 'WebGUI::Asset::EMSSubmission',
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
whereClause => $whereClause,
} );
for my $submission ( @$res ) {
while ( 1 ) {
my $submission;
eval { $submission = $submissionIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $submission;
$submission->purge;
$limit--;
return $self->WAITING(1) if ! $limit or time > $start + $timeLimit;

View file

@ -87,6 +87,7 @@ sub execute {
}
}
my $sth = $self->session->db->read("select groupId,deleteOffset,groupCacheTimeout from groups");
my $expireTime = time() + $self->getTTL();
while (my $data = $sth->hashRef) {
if ($data->{groupCacheTimeout} > 0) {
# there is no need to wait deleteOffset days for expired external group cache data
@ -94,6 +95,10 @@ sub execute {
} else {
$self->session->db->write("delete from groupings where groupId=? and expireDate < ?", [$data->{groupId}, time()-$data->{deleteOffset}]);
}
if (time() > $expireTime) {
$sth->finish;
return $self->WAITING(1);
}
}
return $self->COMPLETE;
}

View file

@ -78,8 +78,9 @@ sub execute {
my $limit = 2_500;
my $timeLimit = 60;
my $list = $root->getLineage( ['descendants'], { returnObjects => 1,
my $list = $root->getLineage( ['descendants'], {
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
returnObjects => 1,
} );
for my $emsForm ( @$list ) {
@ -88,6 +89,7 @@ sub execute {
joinClass => 'WebGUI::Asset::EMSSubmission',
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
whereClause => $whereClause,
returnObjects => 1,
} );
for my $submission ( @$res ) {
my $properties = { className => 'WebGUI::Asset::Sku::EMSTicket' };