/** the name of this rendition */
 public String getName() {
   //      final AVMService avmService = this.getServiceRegistry().getAVMService();
   //      return
   // avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
   //
   // AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(),
   //                                        ContentModel.PROP_NAME).getStringValue();
   return AVMNodeConverter.SplitBase(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond())[
       1];
 }
  public List<FormInstanceData.RegenerateResult> regenerateRenditions()
      throws FormNotFoundException {
    if (logger.isDebugEnabled()) {
      logger.debug("regenerating renditions of " + this);
    }

    AVMLockingService avmLockService = this.getServiceRegistry().getAVMLockingService();
    final AVMService avmService = this.getServiceRegistry().getAVMService();
    PropertyValue pv =
        avmService.getNodeProperty(
            AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
            AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(),
            WCMAppModel.PROP_ORIGINAL_PARENT_PATH);

    String originalParentAvmPath =
        (pv == null) ? AVMNodeConverter.SplitBase(this.getPath())[0] : pv.getStringValue();

    final HashSet<RenderingEngineTemplate> allRets =
        new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
    final List<RegenerateResult> result = new LinkedList<RegenerateResult>();
    // regenerate existing renditions
    boolean renditionLockedBefore = false;
    String path = null;

    for (final Rendition r : this.getRenditions()) {
      // Try to skip renditions without rendering engine template.
      if (r instanceof RenditionImpl) {
        RenditionImpl rImpl = (RenditionImpl) r;
        RenderingEngineTemplate ret = rImpl.getRenderingEngineTemplate();
        if ((ret != null) && (ret instanceof RenderingEngineTemplateImpl)) {
          RenderingEngineTemplateImpl retImpl = (RenderingEngineTemplateImpl) ret;
          if (!retImpl.isExists()) {
            continue;
          }
        }
      }
      final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
      if (ret == null || !allRets.contains(ret)) {
        continue;
      }
      try {
        if (logger.isDebugEnabled()) {
          logger.debug("regenerating rendition " + r + " using template " + ret);
        }

        renditionLockedBefore = false;
        path = r.getPath();
        AVMLock lock =
            avmLockService.getLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
        if (lock != null) {
          renditionLockedBefore = true;

          if (logger.isDebugEnabled()) {
            logger.debug("Lock already exists for " + path);
          }
        }

        ret.render(this, r);
        allRets.remove(ret);
        result.add(new RegenerateResult(ret, path, r));
      } catch (Exception e) {
        result.add(new RegenerateResult(ret, path, e));

        // remove lock if there wasn't one before
        if (renditionLockedBefore == false) {
          avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));

          if (logger.isDebugEnabled()) {
            logger.debug("Removed lock for " + path + " as it failed to generate");
          }
        }
      }
    }

    // render all renditions for newly added templates
    for (final RenderingEngineTemplate ret : allRets) {
      try {
        renditionLockedBefore = false;
        path = ret.getOutputPathForRendition(this, originalParentAvmPath, getName());

        if (logger.isDebugEnabled()) {
          logger.debug(
              "regenerating rendition of "
                  + this.getPath()
                  + " at "
                  + path
                  + " using template "
                  + ret);
        }

        AVMLock lock =
            avmLockService.getLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
        if (lock != null) {
          renditionLockedBefore = true;

          if (logger.isDebugEnabled()) {
            logger.debug("Lock already exists for " + path);
          }
        }

        result.add(new RegenerateResult(ret, path, ret.render(this, path)));
      } catch (Exception e) {
        result.add(new RegenerateResult(ret, path, e));

        // remove lock if there wasn't one before
        if (renditionLockedBefore == false) {
          avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));

          if (logger.isDebugEnabled()) {
            logger.debug("Removed lock for " + path + " as it failed to generate");
          }
        }
      }
    }
    return result;
  }