List<String> existingSignatures = new ArrayList<String>();
logger.info("Before AAAAA:" + internalMessageList.size() + ":" + existingSignatures.size());
Iterator<NotificationMessage> cleanupInternalMessageListIterator = internalMessageList.iterator();
while(cleanupInternalMessageListIterator.hasNext())
{
NotificationMessage notificationMessage = cleanupInternalMessageListIterator.next();
logger.info("Indexing........:" + notificationMessage.getClassName());
if(notificationMessage.getClassName().equals(ContentImpl.class.getName()) || notificationMessage.getClassName().equals(Content.class.getName()))
{
ContentVO contentVO = ContentController.getContentController().getContentVOWithId((Integer)notificationMessage.getObjectId());
ContentTypeDefinitionVO ctdVO = null;
try
{
ctdVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(contentVO.getContentTypeDefinitionId());
}
catch (SystemException sex)
{
logger.warn("Failed to get the content type definition for content with Id: " + contentVO.getContentId() + ". The content will not be indexed. Message: " + sex.getMessage());
logger.info("Failed to get the content type definition for content with Id: " + contentVO.getContentId(), sex);
}
if(ctdVO != null && ctdVO.getName().equals("Meta info"))
{
SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithMetaInfoContentId(contentVO.getContentId());
NotificationMessage newNotificationMessage = new NotificationMessage("" + siteNodeVO.getName(), SiteNodeImpl.class.getName(), "SYSTEM", notificationMessage.getType(), siteNodeVO.getId(), "" + siteNodeVO.getName());
String key = "" + newNotificationMessage.getClassName() + "_" + newNotificationMessage.getObjectId() + "_" + "_" + newNotificationMessage.getType();
if(!existingSignatures.contains(key))
{
logger.info("++++++++++++++Got an META PAGE notification - just adding it AS A PAGE instead: " + newNotificationMessage.getObjectId());
baseEntitiesToIndexMessageList.add(newNotificationMessage);
existingSignatures.add(key);
}
else
{
logger.info("++++++++++++++Skipping Content notification - duplicate existed: " + notificationMessage.getObjectId());
}
}
else
{
String key = "" + notificationMessage.getClassName() + "_" + notificationMessage.getObjectId() + "_" + "_" + notificationMessage.getType();
if(!existingSignatures.contains(key))
{
logger.info("++++++++++++++Got an Content notification - just adding it: " + notificationMessage.getObjectId());
baseEntitiesToIndexMessageList.add(notificationMessage);
existingSignatures.add(key);
}
else
{
logger.info("++++++++++++++Skipping Content notification - duplicate existed: " + notificationMessage.getObjectId());
}
}
}
else if(notificationMessage.getClassName().equals(ContentVersionImpl.class.getName()) || notificationMessage.getClassName().equals(ContentVersion.class.getName()))
{
logger.info("++++++++++++++Got an ContentVersion notification - focus on content: " + notificationMessage.getObjectId());
ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId((Integer)notificationMessage.getObjectId());
ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentVersionVO.getContentId());
if(contentVO.getContentTypeDefinitionId() != null)
{
ContentTypeDefinitionVO ctdVO = null;
try
{
ctdVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(contentVO.getContentTypeDefinitionId());
}
catch (SystemException sex)
{
logger.warn("Failed to get the content type definition for content with Id: " + contentVO.getContentId() + ". The content version will not be indexed. Message: " + sex.getMessage());
logger.info("Failed to get the content type definition for content with Id: " + contentVO.getContentId(), sex);
}
if(ctdVO != null && ctdVO.getName().equals("Meta info"))
{
SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithMetaInfoContentId(contentVO.getContentId());
if (siteNodeVO == null)
{
logger.warn("Got meta info notification but could not find a page for the Content-id. Content.id: " + contentVO.getContentId());
}
else
{
NotificationMessage newNotificationMessage = new NotificationMessage("" + siteNodeVO.getName(), SiteNodeImpl.class.getName(), "SYSTEM", notificationMessage.getType(), siteNodeVO.getId(), "" + siteNodeVO.getName());
String key = "" + newNotificationMessage.getClassName() + "_" + newNotificationMessage.getObjectId() + "_" + newNotificationMessage.getType();
if(!existingSignatures.contains(key))
{
logger.info("++++++++++++++Got an META PAGE notification - just adding it AS A PAGE instead: " + newNotificationMessage.getObjectId());
baseEntitiesToIndexMessageList.add(newNotificationMessage);
existingSignatures.add(key);
}
else
{
logger.info("++++++++++++++Skipping Content notification - duplicate existed: " + notificationMessage.getObjectId());
}
}
}
else
{
NotificationMessage newNotificationMessage = new NotificationMessage("" + contentVersionVO.getContentName(), ContentImpl.class.getName(), "SYSTEM", notificationMessage.getType(), contentVersionVO.getContentId(), "" + contentVersionVO.getContentName());
String key = "" + newNotificationMessage.getClassName() + "_" + newNotificationMessage.getObjectId() + "_" + newNotificationMessage.getType();
if(!existingSignatures.contains(key))
{
logger.info("++++++++++++++Got an Content notification - just adding it: " + newNotificationMessage.getObjectId());
baseEntitiesToIndexMessageList.add(newNotificationMessage);
existingSignatures.add(key);
}
else
{
logger.info("++++++++++++++Skipping Content notification - duplicate existed: " + notificationMessage.getObjectId());
}
}
}
}
else if(notificationMessage.getClassName().equals(DigitalAssetImpl.class.getName()) ||
notificationMessage.getClassName().equals(MediumDigitalAssetImpl.class.getName()) ||
notificationMessage.getClassName().equals(DigitalAsset.class.getName()) ||
notificationMessage.getClassName().equals(SiteNodeImpl.class.getName()) ||
notificationMessage.getClassName().equals(SiteNode.class.getName()) ||
notificationMessage.getClassName().equals(SiteNodeVersionImpl.class.getName()) ||
notificationMessage.getClassName().equals(SiteNodeVersion.class.getName()))
{
logger.info("notificationMessage.getClassName():" + notificationMessage.getClassName());
String key = "" + notificationMessage.getClassName() + "_" + notificationMessage.getObjectId() + "_" + "_" + notificationMessage.getType();
if(notificationMessage.getClassName().equals(SiteNodeVersionImpl.class.getName()) || notificationMessage.getClassName().equals(SiteNodeVersion.class.getName()))
{
logger.info("PPPPPPPPPPPPPPPPPPPPPPPPPP:" + notificationMessage.getObjectId());
SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId((Integer)notificationMessage.getObjectId());
SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeVersionVO.getSiteNodeId());
NotificationMessage newNotificationMessage = new NotificationMessage("" + siteNodeVO.getName(), SiteNodeImpl.class.getName(), "SYSTEM", notificationMessage.getType(), siteNodeVO.getId(), "" + siteNodeVO.getName());
key = "" + newNotificationMessage.getClassName() + "_" + newNotificationMessage.getObjectId() + "_" + newNotificationMessage.getType();
if(!existingSignatures.contains(key))
{
logger.info("++++++++++++++Got an SiteNodeVersionImpl notification - just adding it as SiteNodeImpl: " + newNotificationMessage.getClassName() + ":" + newNotificationMessage.getObjectId());
baseEntitiesToIndexMessageList.add(newNotificationMessage);
existingSignatures.add(key);
}
else
{
logger.info("++++++++++++++Skipping notification - duplicate existed: " + notificationMessage.getClassName() + ":" + notificationMessage.getObjectId());
}
}
else if(notificationMessage.getClassName().equals(SiteNodeImpl.class.getName()) || notificationMessage.getClassName().equals(SiteNode.class.getName()))
{
if(!existingSignatures.contains(key))
{
logger.info("++++++++++++++Got an Page notification - just adding it: " + notificationMessage.getClassName() + ":" + notificationMessage.getObjectId());
baseEntitiesToIndexMessageList.add(notificationMessage);
existingSignatures.add(key);
}
else
{
logger.info("++++++++++++++Skipping notification - duplicate existed: " + notificationMessage.getClassName() + ":" + notificationMessage.getObjectId());
}
}
else
{
NotificationMessage newNotificationMessage = new NotificationMessage("" + notificationMessage.getName(), DigitalAssetImpl.class.getName(), "SYSTEM", notificationMessage.getType(), notificationMessage.getObjectId(), "" + notificationMessage.getName());
key = "" + newNotificationMessage.getClassName() + "_" + newNotificationMessage.getObjectId() + "_" + "_" + newNotificationMessage.getType();
if(!existingSignatures.contains(key))
{
logger.info("++++++++++++++Got an Content notification - just adding it: " + notificationMessage.getClassName() + ":" + notificationMessage.getObjectId());
baseEntitiesToIndexMessageList.add(newNotificationMessage);
existingSignatures.add(key);
}
else
{
logger.info("++++++++++++++Skipping notification - duplicate existed: " + notificationMessage.getClassName() + ":" + notificationMessage.getObjectId());
}
}
}
}
internalMessageList = baseEntitiesToIndexMessageList;
logger.info("After in [" + CmsPropertyHandler.getContextRootPath() + "]:" + internalMessageList.size() + ":" + existingSignatures.size());
try
{
logger.info("notifyListeners actually running");
if(getIsIndexedLocked())
{
logger.warn("The index should not be locked as no indexing is registered to be carried out. Lets unlock it as it may be the result of a crash.");
unlockIndex();
}
//logger.error("Starting indexin of " + qeuedMessages.size());
Timer t = new Timer();
IndexWriter writer = getIndexWriter();
//t.printElapsedTime("Creating writer took");
Database db = CastorDatabaseService.getDatabase();
beginTransaction(db);
try
{
int numberOfMessages = internalMessageList.size();
Iterator internalMessageListIterator = internalMessageList.iterator();
while(internalMessageListIterator.hasNext())
{
NotificationMessage notificationMessage = (NotificationMessage)internalMessageListIterator.next();
try
{
if(logger.isInfoEnabled())
logger.info("Starting indexin of " + notificationMessage);
indexInformation(notificationMessage, writer, internalMessageList, forceVersionIndexing, db);