RM-817: Error: "Unknown aspect specified in query: rma:unpublishedUpdate" in alfresco with RM

* ensure the job doesn't execute before the RM content model is loaded



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@54461 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-08-26 10:00:17 +00:00
parent 887b211919
commit 3e0167e4b1

View File

@@ -30,6 +30,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
@@ -57,29 +58,47 @@ public class PublishUpdatesJobExecuter extends RecordsManagementJobExecuter
/** Publish executor register */ /** Publish executor register */
private PublishExecutorRegistry publishExecutorRegistry; private PublishExecutorRegistry publishExecutorRegistry;
/** Dictionary service */
private DictionaryService dictionaryService;
/** Behaviour filter */ /** Behaviour filter */
private BehaviourFilter behaviourFilter; private BehaviourFilter behaviourFilter;
/**
* @param nodeService node service
*/
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
this.nodeService = nodeService; this.nodeService = nodeService;
} }
/**
* @param searchService search service
*/
public void setSearchService(SearchService searchService) public void setSearchService(SearchService searchService)
{ {
this.searchService = searchService; this.searchService = searchService;
} }
/**
* @param publishExecutorRegistry public executor registry
*/
public void setPublishExecutorRegistry(PublishExecutorRegistry publishExecutorRegistry) public void setPublishExecutorRegistry(PublishExecutorRegistry publishExecutorRegistry)
{ {
this.publishExecutorRegistry = publishExecutorRegistry; this.publishExecutorRegistry = publishExecutorRegistry;
} }
/**
* @param behaviourFilter behaviour filter
*/
public void setBehaviourFilter(BehaviourFilter behaviourFilter) public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{ {
this.behaviourFilter = behaviourFilter; this.behaviourFilter = behaviourFilter;
} }
/**
* @see org.alfresco.module.org_alfresco_module_rm.job.RecordsManagementJobExecuter#executeImpl()
*/
public void executeImpl() public void executeImpl()
{ {
if (logger.isDebugEnabled() == true) if (logger.isDebugEnabled() == true)
@@ -91,44 +110,47 @@ public class PublishUpdatesJobExecuter extends RecordsManagementJobExecuter
{ {
public Object doWork() throws Exception public Object doWork() throws Exception
{ {
// Get a list of the nodes that have updates that need to be published if (rmLoaded() == true)
List<NodeRef> nodeRefs = getUpdatedNodes(); {
// Get a list of the nodes that have updates that need to be published
// Deal with each updated disposition action in turn List<NodeRef> nodeRefs = getUpdatedNodes();
for (NodeRef nodeRef : nodeRefs)
{ // Deal with each updated disposition action in turn
if (nodeService.exists(nodeRef) == true) for (NodeRef nodeRef : nodeRefs)
{ {
// Mark the update node as publishing in progress if (nodeService.exists(nodeRef) == true)
markPublishInProgress(nodeRef);
try
{ {
Date start = new Date(); // Mark the update node as publishing in progress
if (logger.isDebugEnabled() == true) markPublishInProgress(nodeRef);
try
{ {
logger.debug("Starting publish of updates ..."); Date start = new Date();
logger.debug(" - for " + nodeRef.toString()); if (logger.isDebugEnabled() == true)
logger.debug(" - at " + start.toString()); {
} logger.debug("Starting publish of updates ...");
logger.debug(" - for " + nodeRef.toString());
// Publish updates logger.debug(" - at " + start.toString());
publishUpdates(nodeRef); }
// Publish updates
if (logger.isDebugEnabled() == true) publishUpdates(nodeRef);
if (logger.isDebugEnabled() == true)
{
Date end = new Date();
long duration = end.getTime() - start.getTime();
logger.debug("Completed publish of updates ...");
logger.debug(" - for " + nodeRef.toString());
logger.debug(" - at " + end.toString());
logger.debug(" - duration " + Long.toString(duration));
}
}
finally
{ {
Date end = new Date(); // Ensure the update node has either completed the publish or is marked as no longer in progress
long duration = end.getTime() - start.getTime(); unmarkPublishInProgress(nodeRef);
logger.debug("Completed publish of updates ...");
logger.debug(" - for " + nodeRef.toString());
logger.debug(" - at " + end.toString());
logger.debug(" - duration " + Long.toString(duration));
} }
}
finally
{
// Ensure the update node has either completed the publish or is marked as no longer in progress
unmarkPublishInProgress(nodeRef);
} }
} }
} }
@@ -142,6 +164,24 @@ public class PublishUpdatesJobExecuter extends RecordsManagementJobExecuter
} }
} }
/**
* Helper method to determine whether the RM content model has been loaded yet.
*
* @return boolean true if RM content model loaded, false otherwise
*/
private boolean rmLoaded()
{
boolean result = false;
// ensure that the rm content model has been loaded
if (dictionaryService.getAspect(ASPECT_UNPUBLISHED_UPDATE) != null)
{
result = true;
}
return result;
}
/** /**
* Get a list of the nodes with updates pending publish * Get a list of the nodes with updates pending publish
* @return List<NodeRef> list of node refences with updates pending publication * @return List<NodeRef> list of node refences with updates pending publication