public void updateAsset(long userId, Foo foo, long[] assetCategoryIds, String[] assetTagNames)
      throws PortalException, SystemException {

    assetEntryLocalService.updateEntry(
        userId,
        foo.getGroupId(),
        Foo.class.getName(),
        foo.getFooId(),
        foo.getUuid(),
        0,
        assetCategoryIds,
        assetTagNames,
        true,
        null,
        null,
        null,
        null,
        ContentTypes.TEXT_PLAIN_UTF8,
        foo.getField1(),
        null,
        foo.getField1(),
        null,
        null,
        0,
        0,
        null,
        false);
  }
  public void updateFoo(
      long fooId,
      String field1,
      boolean field2,
      int field3,
      Date field4,
      String field5,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    User user = userPersistence.findByPrimaryKey(serviceContext.getUserId());

    Foo foo = fooPersistence.findByPrimaryKey(fooId);

    foo.setModifiedDate(new Date());
    foo.setField1(field1);
    foo.setField2(field2);
    foo.setField3(field3);
    foo.setField4(field4);
    foo.setField5(field5);
    foo.setExpandoBridgeAttributes(serviceContext);

    fooPersistence.update(foo, false);

    updateAsset(
        user.getUserId(),
        foo,
        serviceContext.getAssetCategoryIds(),
        serviceContext.getAssetTagNames());
  }
  /**
   * Adds the foo to the database. Also notifies the appropriate model listeners.
   *
   * @param foo the foo
   * @return the foo that was added
   */
  @Indexable(type = IndexableType.REINDEX)
  @Override
  public Foo addFoo(Foo foo) {
    foo.setNew(true);

    return fooPersistence.update(foo);
  }
  @Override
  public void deleteFoo(Foo foo) throws SystemException {
    try {
      assetEntryLocalService.deleteEntry(Foo.class.getName(), foo.getFooId());
    } catch (PortalException pe) {
    }

    fooPersistence.remove(foo);
  }
  public void addFoo(
      String field1,
      boolean field2,
      int field3,
      Date field4,
      String field5,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    // Foo

    User user = userLocalService.getUserById(serviceContext.getUserId());
    long groupId = serviceContext.getScopeGroupId();
    Date now = new Date();

    long fooId = counterLocalService.increment();

    Foo foo = fooPersistence.create(fooId);

    foo.setGroupId(groupId);
    foo.setCompanyId(user.getCompanyId());
    foo.setUserId(user.getUserId());
    foo.setUserName(user.getFullName());
    foo.setCreateDate(serviceContext.getCreateDate(now));
    foo.setModifiedDate(serviceContext.getModifiedDate(now));
    foo.setField1(field1);
    foo.setField2(field2);
    foo.setField3(field3);
    foo.setField4(field4);
    foo.setField5(field5);
    foo.setExpandoBridgeAttributes(serviceContext);

    fooPersistence.update(foo, false);

    // Asset

    updateAsset(
        user.getUserId(),
        foo,
        serviceContext.getAssetCategoryIds(),
        serviceContext.getAssetTagNames());
  }