@Override
  public AllowableActions getAllowableActions(
      CallContext callContext, String repositoryId, String objectId) {

    exceptionService.invalidArgumentRequired("objectId", objectId);

    Lock lock = threadLockService.getReadLock(repositoryId, objectId);

    try {
      lock.lock();

      // //////////////////
      // General Exception
      // //////////////////
      Content content = contentService.getContent(repositoryId, objectId);
      exceptionService.objectNotFound(DomainType.OBJECT, content, objectId);
      // NOTE: The permission key doesn't exist according to CMIS
      // specification.

      // //////////////////
      // Body of the method
      // //////////////////
      return compileService.compileAllowableActions(callContext, repositoryId, content);

    } finally {
      lock.unlock();
    }
  }
  @Override
  public List<RenditionData> getRenditions(
      CallContext callContext,
      String repositoryId,
      String objectId,
      String renditionFilter,
      BigInteger maxItems,
      BigInteger skipCount,
      ExtensionsData extension) {

    Lock lock = threadLockService.getReadLock(repositoryId, objectId);
    try {
      lock.lock();

      List<Rendition> renditions = contentService.getRenditions(repositoryId, objectId);

      List<RenditionData> results = new ArrayList<RenditionData>();
      for (Rendition rnd : renditions) {
        RenditionDataImpl data =
            new RenditionDataImpl(
                rnd.getId(),
                rnd.getMimetype(),
                BigInteger.valueOf(rnd.getLength()),
                rnd.getKind(),
                rnd.getTitle(),
                BigInteger.valueOf(rnd.getWidth()),
                BigInteger.valueOf(rnd.getHeight()),
                rnd.getRenditionDocumentId());
        results.add(data);
      }
      return results;
    } finally {
      lock.unlock();
    }
  }
  @Override
  public ContentStream getContentStream(
      CallContext callContext,
      String repositoryId,
      String objectId,
      String streamId,
      BigInteger offset,
      BigInteger length) {

    exceptionService.invalidArgumentRequired("objectId", objectId);

    Lock lock = threadLockService.getReadLock(repositoryId, objectId);
    try {
      lock.lock();

      // //////////////////
      // General Exception
      // //////////////////
      Content content = contentService.getContent(repositoryId, objectId);
      exceptionService.objectNotFound(DomainType.OBJECT, content, objectId);
      exceptionService.permissionDenied(
          callContext, repositoryId, PermissionMapping.CAN_GET_PROPERTIES_OBJECT, content);

      // //////////////////
      // Body of the method
      // //////////////////
      if (streamId == null) {
        return getContentStreamInternal(repositoryId, content, offset, length);
      } else {
        return getRenditionStream(repositoryId, content, streamId);
      }
    } finally {
      lock.unlock();
    }
  }
  @Override
  public ObjectData getObject(
      CallContext callContext,
      String repositoryId,
      String objectId,
      String filter,
      Boolean includeAllowableActions,
      IncludeRelationships includeRelationships,
      String renditionFilter,
      Boolean includePolicyIds,
      Boolean includeAcl,
      ExtensionsData extension) {

    exceptionService.invalidArgumentRequired("objectId", objectId);

    Lock lock = threadLockService.getReadLock(repositoryId, objectId);
    try {
      lock.lock();

      // //////////////////
      // General Exception
      // //////////////////
      Content content = contentService.getContent(repositoryId, objectId);
      // WORK AROUND: getObject(versionSeriesId) is interpreted as
      // getDocumentOflatestVersion
      if (content == null) {
        VersionSeries versionSeries = contentService.getVersionSeries(repositoryId, objectId);
        if (versionSeries != null) {
          content = contentService.getDocumentOfLatestVersion(repositoryId, objectId);
        }
      }
      exceptionService.objectNotFound(DomainType.OBJECT, content, objectId);
      exceptionService.permissionDenied(
          callContext, repositoryId, PermissionMapping.CAN_GET_PROPERTIES_OBJECT, content);

      // //////////////////
      // Body of the method
      // //////////////////
      ObjectData object =
          compileService.compileObjectData(
              callContext,
              repositoryId,
              content,
              filter,
              includeAllowableActions,
              includeRelationships,
              null,
              includeAcl);

      return object;
    } finally {
      lock.unlock();
    }
  }
  @Override
  public ObjectData getObjectByPath(
      CallContext callContext,
      String repositoryId,
      String path,
      String filter,
      Boolean includeAllowableActions,
      IncludeRelationships includeRelationships,
      String renditionFilter,
      Boolean includePolicyIds,
      Boolean includeAcl,
      ExtensionsData extension) {
    // //////////////////
    // General Exception
    // //////////////////
    exceptionService.invalidArgumentRequired("objectId", path);
    // FIXME path is not preserved in db.
    Content content = contentService.getContentByPath(repositoryId, path);

    // TODO create objectNotFoundByPath method
    exceptionService.objectNotFoundByPath(DomainType.OBJECT, content, path);

    Lock lock = threadLockService.getReadLock(repositoryId, content.getId());
    try {
      lock.lock();

      exceptionService.permissionDenied(
          callContext, repositoryId, PermissionMapping.CAN_GET_PROPERTIES_OBJECT, content);

      // //////////////////
      // Body of the method
      // //////////////////
      return compileService.compileObjectData(
          callContext,
          repositoryId,
          content,
          filter,
          includeAllowableActions,
          includeRelationships,
          renditionFilter,
          includeAcl);
    } finally {
      lock.unlock();
    }
  }