Package com.gentics.cr.exceptions

Examples of com.gentics.cr.exceptions.CRException


      Collection<CRResolvableBean> slice = null;
      try {
        status.setCurrentStatusString("Writer accquired. Starting" + "index job.");

        if (rp == null) {
          throw new CRException("FATAL ERROR", "RequestProcessor not available");
        }

        String bsString = (String) config.get(BATCH_SIZE_KEY);

        int crBatchSize = batchSize;

        if (bsString != null) {
          try {
            crBatchSize = Integer.parseInt(bsString);
          } catch (NumberFormatException e) {
            log.error("The configured " + BATCH_SIZE_KEY + " for the Current CR" + " did not contain a parsable integer. ", e);
          }
        }

        // and get the current rule
        String rule = (String) config.get(RULE_KEY);

        if (rule == null) {
          rule = "";
        }
        if (rule.length() == 0) {
          rule = "(1 == 1)";
        } else {
          rule = "(" + rule + ")";
        }

        List<ContentTransformer> transformerlist = ContentTransformer.getTransformerList(config);

        boolean create = true;

        if (indexLocation.isContainingIndex()) {
          create = false;
          log.debug("Index already exists.");
        }
        if (indexLocation instanceof LuceneIndexLocation) {
          luceneIndexUpdateChecker = new LuceneIndexUpdateChecker((LuceneIndexLocation) indexLocation, CR_FIELD_KEY, crid,
              idAttribute);
        } else {
          log.error("IndexLocation is not created for Lucene. " + "Using the " + CRLuceneIndexJob.class.getName()
              + " requires that you use the " + LuceneIndexLocation.class.getName()
              + ". You can configure another Job by setting the " + IndexLocation.UPDATEJOBCLASS_KEY + " key in your config.");
          throw new CRException(new CRError("Error", "IndexLocation is not created for Lucene."));
        }
        Collection<CRResolvableBean> objectsToIndex = null;
        //Clear Index and remove stale Documents
        //if (!create) {
        log.debug("Will do differential index.");
        try {
          CRRequest req = new CRRequest();
          req.setRequestFilter(rule);
          req.set(CR_FIELD_KEY, crid);
          status.setCurrentStatusString("Get objects to update " + "in the index ...");
          objectsToIndex = getObjectsToUpdate(req, rp, false, luceneIndexUpdateChecker);
        } catch (Exception e) {
          log.error("ERROR while cleaning index", e);
        }
        //}
        //Obtain accessor and writer after clean
        if (indexLocation instanceof LuceneIndexLocation) {
          indexAccessor = ((LuceneIndexLocation) indexLocation).getAccessor();
          indexWriter = indexAccessor.getWriter();
          indexReader = indexAccessor.getReader(false);
          useFacets = ((LuceneIndexLocation) indexLocation).useFacets();
          if (useFacets) {
            taxonomyAccessor = ((LuceneIndexLocation) indexLocation).getTaxonomyAccessor();
            taxonomyWriter = taxonomyAccessor.getTaxonomyWriter();
          }
        } else {
          log.error("IndexLocation is not created for Lucene. " + "Using the " + CRLuceneIndexJob.class.getName()
              + " requires that you use the " + LuceneIndexLocation.class.getName()
              + ". You can configure another Job by setting the " + IndexLocation.UPDATEJOBCLASS_KEY + " key in your config.");
          throw new CRException(new CRError("Error", "IndexLocation is not created for Lucene."));
        }
        log.debug("Using rule: " + rule);
        // prepare the map of indexed/stored attributes
        Map<String, Boolean> attributes = new HashMap<String, Boolean>();
        List<String> containedAttributes = IndexerUtil.getListFromString(config.getString(CONTAINED_ATTRIBUTES_KEY), ",");
View Full Code Here


          break;
        }
        this.status.setObjectsDone(this.status.getObjectsDone() + 1);
      }
    } catch (Exception e) {
      throw new CRException(e);
    } finally {
      uc.stop();
    }
  }
View Full Code Here

  @Override
  protected void indexCR(IndexLocation indexLocation, CRConfigUtil config) throws CRException {
    try {
      reIndex();
    } catch (IOException e) {
      throw new CRException("Could not access the DidYouMean- index! " + e.getMessage());
    }

  }
View Full Code Here

        doNavigation,
        request.getSortArray(),
        request);
    } catch (IOException ex) {
      LOGGER.error("Error while getting search results from index.");
      throw new CRException(ex);
    }
    ucSearch.stop();
    LOGGER.debug("Search in Index took " + (System.currentTimeMillis() - indexSearchStartTime) + "ms");
    /**
     * process search
View Full Code Here

    if (count <= 0) {
      String message = "Default count is lower or equal to 0! This will "
          + "result in an error. Overthink your config (insert rp."
          + "<number>.searchcount=<value> in your properties file)!";
      LOGGER.error(message);
      throw new CRException(new CRError("Error", message));
    }
    return count;
  }
View Full Code Here

  private int getStart(final CRRequest request) throws CRException {
    int start = request.getStart();
    if (start < 0) {
      String message = "Bad request: start is lower than 0!";
      LOGGER.error(message);
      throw new CRException(new CRError("Error", message));
    }
    return start;
  }
View Full Code Here

        }
      }
    } catch (Exception e) {
      if (config.getBoolean("FAILONMAXCLAUSES")) {
        log.debug("Error getting the results.", e);
        throw new CRException(e);
      } else {
        log.error("Error getting the results.", e);
        result = null;
      }
View Full Code Here

  @Override
  protected final void indexCR(final IndexLocation indexLocation, final CRConfigUtil config) throws CRException {
    try {
      reIndex();
    } catch (IOException e) {
      throw new CRException("Could not access the SYN - index! " + e.getMessage());
    }

  }
View Full Code Here

    IndexWriter synonymWriter = synonymAccessor.getWriter();
    Collection<CRResolvableBean> objectsToIndex = null;
    try {
      if (rp == null) {
        throw new CRException("FATAL ERROR", "RequestProcessor not available");
      }

      // and get the current rule
      String rule = (String) config.get(RULE_KEY);
      if (rule == null) {
View Full Code Here

   * @param message - message to put into the exception.
   * @param object - object to check for beeing not <code>null</code>
   */
  protected static void assertNotNull(final String message, final Object object) {
    if (object == null) {
      throw new RuntimeException(new CRException(message));
    }
  }
View Full Code Here

TOP

Related Classes of com.gentics.cr.exceptions.CRException

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.