/**
   * Creates a new web d a v props with the primary key. Does not add the web d a v props to the
   * database.
   *
   * @param webDavPropsId the primary key for the new web d a v props
   * @return the new web d a v props
   */
  @Override
  public WebDAVProps create(long webDavPropsId) {
    WebDAVProps webDAVProps = new WebDAVPropsImpl();

    webDAVProps.setNew(true);
    webDAVProps.setPrimaryKey(webDavPropsId);

    webDAVProps.setCompanyId(companyProvider.getCompanyId());

    return webDAVProps;
  }
  @Override
  public WebDAVProps updateImpl(WebDAVProps webDAVProps) {
    webDAVProps = toUnwrappedModel(webDAVProps);

    boolean isNew = webDAVProps.isNew();

    WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl) webDAVProps;

    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();

    Date now = new Date();

    if (isNew && (webDAVProps.getCreateDate() == null)) {
      if (serviceContext == null) {
        webDAVProps.setCreateDate(now);
      } else {
        webDAVProps.setCreateDate(serviceContext.getCreateDate(now));
      }
    }

    if (!webDAVPropsModelImpl.hasSetModifiedDate()) {
      if (serviceContext == null) {
        webDAVProps.setModifiedDate(now);
      } else {
        webDAVProps.setModifiedDate(serviceContext.getModifiedDate(now));
      }
    }

    Session session = null;

    try {
      session = openSession();

      if (webDAVProps.isNew()) {
        session.save(webDAVProps);

        webDAVProps.setNew(false);
      } else {
        webDAVProps = (WebDAVProps) session.merge(webDAVProps);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) {
      finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    entityCache.putResult(
        WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED,
        WebDAVPropsImpl.class,
        webDAVProps.getPrimaryKey(),
        webDAVProps,
        false);

    clearUniqueFindersCache(webDAVPropsModelImpl);
    cacheUniqueFindersCache(webDAVPropsModelImpl, isNew);

    webDAVProps.resetOriginalValues();

    return webDAVProps;
  }