Package com.dotcms.enterprise.publishing.sitesearch

Examples of com.dotcms.enterprise.publishing.sitesearch.SiteSearchConfig


  public void scheduleJob(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, DotIndexException {

    Map<String, String[]> map = request.getParameterMap();

    SiteSearchConfig config = new SiteSearchConfig();
    for(String key : map.keySet()){
      if(((String[]) map.get(key)).length ==1 && !key.equals("langToIndex")){
        config.put(key,((String[]) map.get(key))[0]);
      }
      else{
        config.put(key,map.get(key));
      }
    }
    String taskName = ((String[]) map.get("QUARTZ_JOB_NAME"))[0];
    String taskPreviousName = map.get("OLD_QUARTZ_JOB_NAME")!=null ? ((String[]) map.get("OLD_QUARTZ_JOB_NAME"))[0] : "";

    if(UtilMethods.isSet(taskPreviousName) && !taskName.equals(taskPreviousName)){
      try {
        if(!config.runNow()){
          APILocator.getSiteSearchAPI().deleteTask(taskPreviousName);
        }
      } catch (Exception e) {
        Logger.error(SiteSearchAjaxAction.class,e.getMessage(),e);
        writeError(response, e.getMessage());

      }
    }

    try {
      if(config.runNow()){
        APILocator.getSiteSearchAPI().executeTaskNow(config);
         String date = DateUtil.getCurrentDate();
                 ActivityLogger.logInfo(getClass(), "Job Started", "User:" + getUser().getUserId() + "; Date: " + date + "; Job Identifier: " + SiteSearchAPI.ES_SITE_SEARCH_NAME  );
                 AdminLogger.log(getClass(), "Job Started", "User:" + getUser().getUserId() + "; Date: " + date + "; Job Identifier: " + SiteSearchAPI.ES_SITE_SEARCH_NAME );
      }
View Full Code Here


  public void scheduleJobNow(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, DotIndexException {
    try {
      Map<String, String[]> map = request.getParameterMap();

      SiteSearchConfig config = new SiteSearchConfig();
      for(String key : map.keySet()){
        if(((String[]) map.get(key)).length ==1){
          config.put(key,((String[]) map.get(key))[0]);
        }
        else{
          config.put(key,map.get(key));
        }
      }

      APILocator.getSiteSearchAPI().scheduleTask(config);
    } catch (Exception e) {
View Full Code Here

        int counter = 0;
        String indexName = null;
        boolean createNew=false;
        for(String lang : languageToIndex) {
          counter = counter + 1;
            SiteSearchConfig config = new SiteSearchConfig();
            config.setJobId(jobId);
            config.setLanguage(Long.parseLong(lang));

            config.setJobName(dataMap.getString("QUARTZ_JOB_NAME"));

            List<Host> hosts=new ArrayList<Host>();

            if(indexAll){
                    hosts = APILocator.getHostAPI().findAll(userToRun, true);
            }else{

                for(String h : indexHosts){
                    hosts.add(APILocator.getHostAPI().find(h, userToRun, true));
                }

            }

            config.setHosts( hosts);

            // reuse or create new indexes as needed
            String indexAlias = dataMap.getString("indexAlias");
            ESIndexAPI iapi=new ESIndexAPI();
            Map<String,String> aliasMap=iapi.getAliasToIndexMap(APILocator.getSiteSearchAPI().listIndices());

            if(counter==1){
              if(indexAlias.equals(APILocator.getIndiciesAPI().loadIndicies().site_search)){
                Logger.info(this, "Index Alias is DEFAULT");
                  indexName = APILocator.getIndiciesAPI().loadIndicies().site_search;
              }
              else if(indexAlias.equals("create-new")){
                Logger.info(this, "Index Alias is default");
                createNew=true;
                  indexName = SiteSearchAPI.ES_SITE_SEARCH_NAME  + "_" + ESMappingAPIImpl.datetimeFormat.format(new Date());
                  APILocator.getSiteSearchAPI().createSiteSearchIndex(indexName, null, 1);
              }
              else {
                  indexName=aliasMap.get(indexAlias);
                  Logger.info(this, "Index Alias is " + indexName);
              }
            }
            if(createNew && languageToIndex.length == counter){
              config.setSwitchIndexWhenDone(true);
            }

            config.setIndexName(indexName);



            // if it is going to be an incremental job, write the bundle to the same folder
            // every time.  Otherwise, create a new folder using a date stamp.
            if(dataMap.get("incremental")!=null){
                config.setId(StringUtils.sanitizeCamelCase(config.getJobName()));
            }
            else{
                String x = UtilMethods.dateToJDBC(new Date()).replace(':', '-').replace(' ', '_');
                config.setId(x);
            }

            config.setStartDate(startDate);
            config.setEndDate(endDate);
            config.setIncremental(incremental);
            config.setUser(userToRun);
            if(include) {
                config.setIncludePatterns(paths);
            }
            else {
                config.setExcludePatterns(paths);
            }

            APILocator.getPublisherAPI().publish(config,status);

        }
View Full Code Here

TOP

Related Classes of com.dotcms.enterprise.publishing.sitesearch.SiteSearchConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.