/**
   * Returns an internal folder to store all files deleted from a given folder. Provides fast access
   * when searching for files deleted from a given folder.
   */
  private Node legacyGetTrashFolderIdNode(
      final Session session,
      final PentahoJcrConstants pentahoJcrConstants,
      final String origParentFolderPath)
      throws RepositoryException {

    // get folder id
    String folderId = null;
    if (session.itemExists(origParentFolderPath)) {
      folderId = ((Node) session.getItem(origParentFolderPath)).getIdentifier();
    } else {
      throw new RuntimeException(
          Messages.getInstance()
              .getString("DefaultDeleteHelper.ERROR_0001_PATH_NOT_FOUND")); // $NON-NLS-1$
    }

    final String prefix = session.getNamespacePrefix(PentahoJcrConstants.PHO_NS) + ":";
    Node trashInternalFolderNode = getOrCreateTrashInternalFolderNode(session, pentahoJcrConstants);
    if (NodeHelper.hasNode(trashInternalFolderNode, prefix, folderId)) {
      return NodeHelper.getNode(trashInternalFolderNode, prefix, folderId);
    } else {
      // if Trash Structure 1 (legacy) doesn't exist, no need to create it now
      return null;
    }
  }
 /**
  * Creates and/or returns an internal folder to store a single deleted file. This folder is
  * uniquely named and thus prevents same-name sibling conflicts.
  *
  * @param fileId id of file to delete
  */
 private Node getOrCreateTrashFileIdNode(
     final Session session,
     final PentahoJcrConstants pentahoJcrConstants,
     final Serializable fileId)
     throws RepositoryException {
   final String prefix = session.getNamespacePrefix(PentahoJcrConstants.PHO_NS) + ":";
   final String folderName = fileId.toString(); // $NON-NLS-1$
   Node trashInternalFolderNode = getOrCreateTrashInternalFolderNode(session, pentahoJcrConstants);
   if (NodeHelper.hasNode(trashInternalFolderNode, prefix, folderName)) {
     return NodeHelper.getNode(trashInternalFolderNode, prefix, folderName);
   } else {
     return trashInternalFolderNode.addNode(
         prefix + folderName, pentahoJcrConstants.getPHO_NT_INTERNALFOLDER());
   }
 }