public static Map<String,Object> rebuildSolrIndexAuto(DispatchContext dctx,Map<String,Object> context) throws GenericEntityException {
  Map<String,Object> result;
  LocalDispatcher dispatcher=dctx.getDispatcher();
  boolean autoRunEnabled=UtilProperties.getPropertyAsBoolean(SolrUtil.solrConfigName,"solr.index.rebuild.autoRun.enabled",false);
  if (autoRunEnabled) {
    Boolean onlyIfDirty=(Boolean)context.get("onlyIfDirty");
    if (onlyIfDirty == null) {
      onlyIfDirty=UtilProperties.getPropertyAsBoolean(SolrUtil.solrConfigName,"solr.index.rebuild.autoRun.onlyIfDirty",false);
    }
    Debug.logInfo("Solr: auto-run index rebuild: starting (onlyIfDirty: " + onlyIfDirty + ")",module);
    Map<String,Object> servCtx;
    try {
      servCtx=dctx.makeValidContext("rebuildSolrIndex",ModelService.IN_PARAM,context);
      servCtx.put("onlyIfDirty",onlyIfDirty);
      Map<String,Object> servResult=dispatcher.runSync("rebuildSolrIndex",servCtx);
      if (ServiceUtil.isSuccess(servResult)) {
        String respMsg=(String)servResult.get(ModelService.SUCCESS_MESSAGE);
        if (respMsg != null) {
          Debug.logInfo("Solr: auto-run index rebuild: rebuildSolrIndex returned success: " + respMsg,module);
        }
 else {
          Debug.logInfo("Solr: auto-run index rebuild: rebuildSolrIndex returned success",module);
        }
      }
 else {
        Debug.logError("Solr: auto-run index rebuild: rebuildSolrIndex returned an error: " + ServiceUtil.getErrorMessage(servResult),module);
      }
      result=FastMap.newInstance();
      result.putAll(servResult);
    }
 catch (    GenericServiceException e) {
      Debug.logError(e,module);
      return ServiceUtil.returnError(e.getMessage());
    }
  }
 else {
    Debug.logInfo("Solr: auto-run index rebuild: not running - disabled",module);
    result=ServiceUtil.returnSuccess();
  }
  return result;
}

public static Map < String , Object > rebuildSolrIndexAuto ( DispatchContext dctx , Map < String , Object > context ) throws GenericEntityException { Map < String , Object > result ; LocalDispatcher dispatcher = dctx . getDispatcher ( ) ; boolean autoRunEnabled = UtilProperties . getPropertyAsBoolean ( SolrUtil . solrConfigName , "solr.index.rebuild.autoRun.enabled" , false ) ; if ( autoRunEnabled ) { Boolean onlyIfDirty = ( Boolean ) context . get ( "onlyIfDirty" ) ; if ( onlyIfDirty == null ) { onlyIfDirty = UtilProperties . getPropertyAsBoolean ( SolrUtil . solrConfigName , "solr.index.rebuild.autoRun.onlyIfDirty" , false ) ; } Debug . logInfo ( "Solr: auto-run index rebuild: starting (onlyIfDirty: " + onlyIfDirty + ")" , module ) ; Map < String , Object > servCtx ; try { servCtx = dctx . makeValidContext ( "rebuildSolrIndex" , ModelService . IN_PARAM , context ) ; servCtx . put ( "onlyIfDirty" , onlyIfDirty ) ; Map < String , Object > servResult = dispatcher . runSync ( "rebuildSolrIndex" , servCtx ) ; if ( ServiceUtil . isSuccess ( servResult ) ) { String respMsg = ( String ) servResult . get ( ModelService . SUCCESS_MESSAGE ) ; if ( respMsg != null ) { Debug . logInfo ( "Solr: auto-run index rebuild: rebuildSolrIndex returned success: " + respMsg , module ) ; } else { Debug . logInfo ( "Solr: auto-run index rebuild: rebuildSolrIndex returned success" , module ) ; } } else { Debug . logError ( "Solr: auto-run index rebuild: rebuildSolrIndex returned an error: " + ServiceUtil . getErrorMessage ( servResult ) , module ) ; } result = FastMap . newInstance ( ) ; result . putAll ( servResult ) ; } catch ( GenericServiceException e ) { Debug . logError ( e , module ) ; return ServiceUtil . returnError ( e . getMessage ( ) ) ; } } else { Debug . logInfo ( "Solr: auto-run index rebuild: not running - disabled" , module ) ; result = ServiceUtil . returnSuccess ( ) ; } return result ; }
rebuilds the solr index - auto run .
