Package com.gentics.cr

Examples of com.gentics.cr.CRResolvableBean


  }
 
 

  private CRResolvableBean createFileBean(String filename, String pubDir, String objecttype, String content, Integer timestamp) {
    CRResolvableBean bean = new CRResolvableBean();
    bean.set("filename", filename);
    bean.set("pub_dir", pubDir);
    bean.set("obj_type", objecttype);
    bean.set("binarycontent", content);
    bean.set("timestamp", timestamp);
    return bean;
  }
View Full Code Here


  }
 
  @Test
  public void testUpToDateFileWithSlashDirectory() {
    Integer timestamp = ((int) (upToDateFile.lastModified() / 1000)) - 100;
    CRResolvableBean resolvable = prepareResolvable(upToDateFile, timestamp);
    resolvable.set("pub_dir", "/");
    boolean result = checker.checkUpToDate("new", timestamp, "timestamp", resolvable);
    assertTrue("the filesystem update checker didn't return true for an up to date file (" + upToDateFile.getPath()
        + ")", result);
    checker.deleteStaleObjects();
    assertTrue("up to date file was deleted after if was decided its up to date.", upToDateFile.exists());
View Full Code Here

    UseCase ucProcessSearchMeta = startUseCase("LuceneRequestProcessor.getObjects(" + name
      + ")#processSearch.Metaresolvables");

    Object metaKey = request.get(META_RESOLVABLE_KEY);
    if (metaKey != null && (Boolean) metaKey) {
      final CRResolvableBean metaBean;
      if (showParsedQuery) {
        metaBean = new CRMetaResolvableBean(searchResult, request, parsedQuery, start, count);
      } else {
        metaBean = new CRMetaResolvableBean(searchResult, request, start, count);
      }
View Full Code Here

    if (docs != null) {
      String idAttribute = (String) config.get(ID_ATTRIBUTE_KEY);
      for (Entry<Document, Float> entry : docs.entrySet()) {
        Document doc = entry.getKey();
        Float score = entry.getValue();
        CRResolvableBean crBean = new CRResolvableBean(doc.get(idAttribute));
        if (getStoredAttributes) {
          for (Field field : toFieldList(doc.getFields())) {
            if (field.isStored()) {
              if (field.isBinary()) {
                crBean.set(field.name(), field.getBinaryValue());
              } else {
                crBean.set(field.name(), field.stringValue());
              }
            }
          }
        }
        if (scoreAttribute != null && !"".equals(scoreAttribute)) {
          crBean.set(scoreAttribute, score);
        }
        //DO HIGHLIGHTING
        doHighlighting(crBean, doc, parsedQuery, reader);

        LOGGER.debug("Found " + crBean.getContentid() + " with score " + score.toString());
        result.add(crBean);
      }
    }
  }
View Full Code Here

      status.setCurrentStatusString("Starting to index slices.");
      int objCount = 0;
      try {
        for (Iterator<CRResolvableBean> iterator = objectsToIndex.iterator(); iterator.hasNext();) {
          CRResolvableBean bean = iterator.next();
          iterator.remove();
          objCount++;
          String descriptorValue = bean.getString(descriptorName);
          String synonymValue = bean.getString(synonymName);
          if (descriptorValue != null && synonymValue != null) {
            descriptorValue = descriptorValue.toLowerCase();
            if (synonymValue != null) {
              synonymValue = synonymValue.toLowerCase();
            }
View Full Code Here

  /**
   * check if the file corresponding to the object is newer than the given timestamp and remove the file from {@link #files}.
   */
  @Override
  protected boolean checkUpToDate(String identifyer, Object timestamp, String timestampattribute, Resolvable object) {
    CRResolvableBean bean = new CRResolvableBean(object);
    if (!"10002".equals(bean.getObj_type())) {
      String publicationDirectory;
      if (ignorePubDir) {
        publicationDirectory = "";
      } else {
        publicationDirectory = bean.getString("pub_dir");
      }
      String filename = bean.getString("filename");
      assertNotNull("Bean " + bean.getContentid() + " has no attribute pub_dir.", publicationDirectory);
      assertNotNull("Bean " + bean.getContentid() + " has no attribute filename.", filename);
      if (logger.isDebugEnabled()) {
        logger.debug("Checking " + publicationDirectory + filename + ".");
      }
      Integer updatetimestamp = null;
      if (timestamp instanceof Integer) {
        updatetimestamp = (Integer) timestamp;
      } else if (timestamp instanceof Long) {
        logger.warn("You are giving me a Long as updatetimestamp. The API at indexUpdateChecker#checkUpToDate says you shouldn't. "
            + "This can lead to troubles. I'm assuming the timestamp is in milliseconds not in seconds.");
        updatetimestamp = (int) ((Long) timestamp / 1000L);
      }
      File file = new File(new File(directory, publicationDirectory), filename);
      removeFileFromDeletionList(publicationDirectory + filename);
      if (file.exists() && file.isFile() && (file.lastModified() / 1000) >= updatetimestamp) {
        return true;
      }
    } else if (!ignorePubDir) {
      //it would just make no sense to check for check for folders existence if the pub_dir attribute is ignored
      String publicationDirectory = bean.getString("pub_dir");
      File file = new File(directory, publicationDirectory);
      removeFileFromDeletionList(publicationDirectory);
      if (file.exists() && file.isDirectory()) {
        return true;
      }
View Full Code Here

          return null;
        }
        Iterator<CRResolvableBean> resolvableIterator = objectsToIndex.iterator();
        try {
          while (resolvableIterator.hasNext()) {
            CRResolvableBean crElement = resolvableIterator.next();
            Object crElementIDObject = crElement.get(idAttribute);
            if (crElementIDObject == null) {
              log.error("IDAttribute is null!");
            }
            String crElementID = crElementIDObject.toString();
            Object crElementTimestamp = crElement.get(timestampAttribute);
            //TODO: if any transformers change an attribute that is used for the update check we have to run the transformers
            //before
            if (!indexUpdateChecker.isUpToDate(
              crElementID,
              crElementTimestamp,
View Full Code Here

   * @param attributes - attributes to resolve via the keys of the map
   * @return {@link ExpressionQueryRequest} to use for evaluating the expressions
   */
  private ExpressionQueryRequest
      prepareQueryRequest(final CRResolvableBean bean, final Map<String, Object> attributes) {
    CRResolvableBean resolvable = new CRResolvableBean();
    resolvable.setAttrMap(attributes);
    resolvable.set("object", bean);
    resolvable.set("page", bean);
    PropertyResolver resolver = new PropertyResolver(resolvable);
    return new ExpressionQueryRequest(resolver, new HashMap<String, String>(0));

  }
View Full Code Here

        log.error("Datasource error while getting object for url " + url);
      } finally {
        CRDatabaseFactory.releaseDatasource(ds);
      }
    }
    CRResolvableBean ret = null;
    if (contentObject != null) {
      ret = new CRResolvableBean(contentObject, new String[] {});
    }
    return ret;
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testTypePerFilename() throws Exception {

    CRResolvableBean bean = new CRResolvableBean();
    bean.set("filename", "my.new.testpic.jpg");
    String type = ImageMimetypeMapper.getTypeFromBean(bean);
    String shouldbe = "jpeg";
    assertEquals("The type (" + type + ") should be (" + shouldbe + ")", type, shouldbe);
  }
View Full Code Here

TOP

Related Classes of com.gentics.cr.CRResolvableBean

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.