@Override
  public String saveDocument(
      DsSessionDto aSessionDto,
      DsDocumentDto aDocumentDto,
      String aKey,
      boolean aKeyIsNumeric,
      String aValue,
      String aSecurityPolicyName,
      String aContentFileKey) {

    if ("bug".equals(aSessionDto.getUsername())) {
      throw new IllegalStateException("this is a bug");
    }

    Transaction tx = entityStore.getEnvironment().beginTransaction(null, null);

    Document doc = new Document();
    doc.setFileKey(aContentFileKey);

    doc.setFileName(getFileName(aDocumentDto));
    documentPrimaryIndex.put(doc);
    tx.commit();

    return String.valueOf(doc.getId());
  }
  @Override
  public void deleteDocument(DsSessionDto aSessionDto, String aDocumentId) {

    if ("bug".equals(aSessionDto.getUsername())) {
      throw new IllegalStateException("this is a bug");
    }

    Transaction tx = entityStore.getEnvironment().beginTransaction(null, null);
    documentPrimaryIndex.delete(Long.valueOf(aDocumentId));
    tx.commit();
  }