public void deleteFileShortcut(DLFileShortcut fileShortcut)
      throws PortalException, SystemException {

    // Resources

    resourceLocalService.deleteResource(
        fileShortcut.getCompanyId(),
        DLFileShortcut.class.getName(),
        ResourceImpl.SCOPE_INDIVIDUAL,
        fileShortcut.getFileShortcutId());

    // File shortcut

    dlFileShortcutPersistence.remove(fileShortcut.getFileShortcutId());
  }
  public void addFileShortcutResources(
      DLFolder folder,
      DLFileShortcut fileShortcut,
      String[] communityPermissions,
      String[] guestPermissions)
      throws PortalException, SystemException {

    resourceLocalService.addModelResources(
        fileShortcut.getCompanyId(),
        folder.getGroupId(),
        fileShortcut.getUserId(),
        DLFileShortcut.class.getName(),
        fileShortcut.getFileShortcutId(),
        communityPermissions,
        guestPermissions);
  }
  public void addFileShortcutResources(
      DLFolder folder,
      DLFileShortcut fileShortcut,
      boolean addCommunityPermissions,
      boolean addGuestPermissions)
      throws PortalException, SystemException {

    resourceLocalService.addResources(
        fileShortcut.getCompanyId(),
        folder.getGroupId(),
        fileShortcut.getUserId(),
        DLFileShortcut.class.getName(),
        fileShortcut.getFileShortcutId(),
        false,
        addCommunityPermissions,
        addGuestPermissions);
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    DLFileShortcut newDLFileShortcut = _persistence.create(pk);

    newDLFileShortcut.setUuid(RandomTestUtil.randomString());

    newDLFileShortcut.setGroupId(RandomTestUtil.nextLong());

    newDLFileShortcut.setCompanyId(RandomTestUtil.nextLong());

    newDLFileShortcut.setUserId(RandomTestUtil.nextLong());

    newDLFileShortcut.setUserName(RandomTestUtil.randomString());

    newDLFileShortcut.setCreateDate(RandomTestUtil.nextDate());

    newDLFileShortcut.setModifiedDate(RandomTestUtil.nextDate());

    newDLFileShortcut.setRepositoryId(RandomTestUtil.nextLong());

    newDLFileShortcut.setFolderId(RandomTestUtil.nextLong());

    newDLFileShortcut.setToFileEntryId(RandomTestUtil.nextLong());

    newDLFileShortcut.setTreePath(RandomTestUtil.randomString());

    newDLFileShortcut.setActive(RandomTestUtil.randomBoolean());

    newDLFileShortcut.setStatus(RandomTestUtil.nextInt());

    newDLFileShortcut.setStatusByUserId(RandomTestUtil.nextLong());

    newDLFileShortcut.setStatusByUserName(RandomTestUtil.randomString());

    newDLFileShortcut.setStatusDate(RandomTestUtil.nextDate());

    _dlFileShortcuts.add(_persistence.update(newDLFileShortcut));

    DLFileShortcut existingDLFileShortcut =
        _persistence.findByPrimaryKey(newDLFileShortcut.getPrimaryKey());

    Assert.assertEquals(existingDLFileShortcut.getUuid(), newDLFileShortcut.getUuid());
    Assert.assertEquals(
        existingDLFileShortcut.getFileShortcutId(), newDLFileShortcut.getFileShortcutId());
    Assert.assertEquals(existingDLFileShortcut.getGroupId(), newDLFileShortcut.getGroupId());
    Assert.assertEquals(existingDLFileShortcut.getCompanyId(), newDLFileShortcut.getCompanyId());
    Assert.assertEquals(existingDLFileShortcut.getUserId(), newDLFileShortcut.getUserId());
    Assert.assertEquals(existingDLFileShortcut.getUserName(), newDLFileShortcut.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileShortcut.getCreateDate()),
        Time.getShortTimestamp(newDLFileShortcut.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileShortcut.getModifiedDate()),
        Time.getShortTimestamp(newDLFileShortcut.getModifiedDate()));
    Assert.assertEquals(
        existingDLFileShortcut.getRepositoryId(), newDLFileShortcut.getRepositoryId());
    Assert.assertEquals(existingDLFileShortcut.getFolderId(), newDLFileShortcut.getFolderId());
    Assert.assertEquals(
        existingDLFileShortcut.getToFileEntryId(), newDLFileShortcut.getToFileEntryId());
    Assert.assertEquals(existingDLFileShortcut.getTreePath(), newDLFileShortcut.getTreePath());
    Assert.assertEquals(existingDLFileShortcut.getActive(), newDLFileShortcut.getActive());
    Assert.assertEquals(existingDLFileShortcut.getStatus(), newDLFileShortcut.getStatus());
    Assert.assertEquals(
        existingDLFileShortcut.getStatusByUserId(), newDLFileShortcut.getStatusByUserId());
    Assert.assertEquals(
        existingDLFileShortcut.getStatusByUserName(), newDLFileShortcut.getStatusByUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFileShortcut.getStatusDate()),
        Time.getShortTimestamp(newDLFileShortcut.getStatusDate()));
  }