use of com.helger.pd.indexer.mgr.PDIndexerManager in project phoss-directory by phax.
the class PageSecureParticipantActions method _deleteDuplicateIDs.
private void _deleteDuplicateIDs(@Nonnull final WebPageExecutionContext aWPEC) {
LOGGER.info("Deleting all duplicate participant identifiers");
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final ICommonsMap<IParticipantIdentifier, ICommonsSortedSet<String>> aDupMap = _getDuplicateSourceMap();
final ICommonsSortedSet<String> aPIsToDelete = new CommonsTreeSet<>();
final ICommonsSortedSet<String> aPIsToAdd = new CommonsTreeSet<>();
for (final Map.Entry<IParticipantIdentifier, ICommonsSortedSet<String>> aEntry : aDupMap.entrySet()) {
final ICommonsSortedSet<String> aSet = aEntry.getValue();
final IParticipantIdentifier aPI = aEntry.getKey();
final String sDesiredVersion = aPI.getURIEncoded();
if (aSet.contains(sDesiredVersion)) {
// Simple kill the other ones
aPIsToDelete.addAll(aSet, x -> !x.equals(sDesiredVersion));
} else {
// Remove all and index the correct version
aPIsToDelete.addAll(aSet);
aPIsToAdd.add(sDesiredVersion);
}
}
if (aPIsToDelete.isNotEmpty()) {
final HCNodeList aNL = new HCNodeList();
// Important to use this identifier factory so that the correct key is
// created
final IIdentifierFactory aIF = SimpleIdentifierFactory.INSTANCE;
final PDIndexerManager aIndexerMgr = PDMetaManager.getIndexerMgr();
String sMsg = "Deleting " + aPIsToDelete.size() + " participant ID(s):";
LOGGER.info(sMsg);
aNL.addChild(h2(sMsg));
HCOL aOL = aNL.addAndReturnChild(new HCOL());
for (final String s : aPIsToDelete.getSorted(IComparator.getComparatorCollating(aDisplayLocale))) {
aOL.addItem(s);
aIndexerMgr.queueWorkItem(aIF.parseParticipantIdentifier(s), EIndexerWorkItemType.DELETE, "duplicate-elimination", PDIndexerManager.HOST_LOCALHOST);
}
if (aPIsToAdd.isNotEmpty()) {
sMsg = "Adding " + aPIsToAdd.size() + " participant ID(s) instead:";
LOGGER.info(sMsg);
aNL.addChild(h2(sMsg));
aOL = aNL.addAndReturnChild(new HCOL());
for (final String s : aPIsToAdd.getSorted(IComparator.getComparatorCollating(aDisplayLocale))) {
aOL.addItem(s);
aIndexerMgr.queueWorkItem(aIF.parseParticipantIdentifier(s), EIndexerWorkItemType.CREATE_UPDATE, "duplicate-elimination", PDIndexerManager.HOST_LOCALHOST);
}
}
aWPEC.postRedirectGetInternal(aNL);
} else {
final String sMsg = "Found no duplicate entries to remove";
LOGGER.info(sMsg);
aWPEC.postRedirectGetInternal(success(sMsg));
}
}
use of com.helger.pd.indexer.mgr.PDIndexerManager in project phoss-directory by phax.
the class SyncAllBusinessCardsJob method syncAllBusinessCards.
@Nonnull
public static EChange syncAllBusinessCards(final boolean bForceSync) {
final LocalDateTime aNow = PDTFactory.getCurrentLocalDateTime();
if (!bForceSync) {
// Only sync every 2 weeks
if (aNow.isBefore(getLastSync().plusWeeks(2))) {
return EChange.UNCHANGED;
}
}
LOGGER.info("Start synchronizing business cards" + (bForceSync ? " (forced)" : ""));
final PDIndexerManager aIndexerMgr = PDMetaManager.getIndexerMgr();
// Queue a work item to re-scan all
final Set<IParticipantIdentifier> aAll = PDMetaManager.getStorageMgr().getAllContainedParticipantIDs(EQueryMode.NON_DELETED_ONLY).keySet();
for (final IParticipantIdentifier aParticipantID : aAll) {
aIndexerMgr.queueWorkItem(aParticipantID, EIndexerWorkItemType.SYNC, "sync-job", PDIndexerManager.HOST_LOCALHOST);
}
LOGGER.info("Finished synchronizing of " + aAll.size() + " business cards");
AuditHelper.onAuditExecuteSuccess("sync-bc-started", Integer.valueOf(aAll.size()), aNow, Boolean.valueOf(bForceSync));
_setLastSync(aNow);
return EChange.CHANGED;
}
use of com.helger.pd.indexer.mgr.PDIndexerManager in project phoss-directory by phax.
the class ReIndexJob method onExecute.
@Override
protected void onExecute(@Nonnull final JobDataMap aJobDataMap, @Nonnull final IJobExecutionContext aContext) throws JobExecutionException {
final PDIndexerManager aIndexerMgr = PDMetaManager.getIndexerMgr();
// First expire all old entries
aIndexerMgr.expireOldEntries();
// Re-index all items now
aIndexerMgr.reIndexParticipantData();
}
Aggregations