Fixed unpublishing events.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29696 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
N Smith
2011-08-11 16:52:06 +00:00
parent 7c9c6be018
commit 7b493bb3e6
9 changed files with 140 additions and 145 deletions

View File

@@ -38,10 +38,14 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.publishing.PublishingDetails;
import org.alfresco.service.cmr.publishing.PublishingEvent;
import org.alfresco.service.cmr.publishing.PublishingQueue;
import org.alfresco.service.cmr.publishing.PublishingService;
import org.alfresco.service.cmr.publishing.Status;
import org.alfresco.service.cmr.publishing.channels.Channel;
import org.alfresco.service.cmr.publishing.channels.ChannelService;
import org.alfresco.service.cmr.publishing.channels.ChannelType;
@@ -272,4 +276,31 @@ public class PublishingTestHelper
writer.putContent(theContent);
}
public PublishingEvent publishAndWait(final PublishingDetails details, RetryingTransactionHelper transactionHelper) throws InterruptedException
{
RetryingTransactionCallback<String> startWorkflowCallback = new RetryingTransactionCallback<String>()
{
public String execute() throws Throwable
{
return scheduleEvent(details);
}
};
String eventId = transactionHelper.doInTransaction(startWorkflowCallback);
int i = 0;
while(i<100)
{
Thread.sleep(200);
PublishingEvent event = publishingService.getPublishingEvent(eventId);
Status status = event.getStatus();
if(Status.IN_PROGRESS!=status && Status.SCHEDULED!=status)
{
return event;
}
i++;
}
throw new IllegalStateException("The publishing event did not complete after 20s!");
}
}