public void processAction(ActionEvent actionEvent) throws AbortProcessingException {

      try {
        FolderUserObject folderUserObject = docLibModelBean.getSelectedFolderUserObject();
        DLFolder dlFolder = folderUserObject.getDlFolder();
        long groupId = dlFolder.getGroupId();
        long repositoryId = dlFolder.getRepositoryId();
        boolean mountPoint = dlFolder.getMountPoint();
        long parentFolderId = dlFolder.getFolderId();
        ServiceContext serviceContext = new ServiceContext();

        // Temporary: Make the default setting be that community members can view the file. Need to
        // develop a
        // "Viewable By" permissions Facelet composite component UI similar to
        // portal-web/docroot/html/taglib/ui/input_permissions/page.jsp
        serviceContext.setAddGroupPermissions(true);
        DLFolderServiceUtil.addFolder(
            groupId,
            repositoryId,
            mountPoint,
            parentFolderId,
            folderName,
            folderDescription,
            serviceContext);
        docLibModelBean.forceTreeRequery();
        logger.debug("Added folderName=[{0}] description=[{1}]", folderName, folderDescription);
      } catch (Exception e) {
        logger.error(e.getMessage(), e);
        liferayFacesContext.addGlobalUnexpectedErrorMessage();
      }

      docLibViewBean.setPopupRendered(false);
    }
  @Test
  public void testCreateRepositoryFromExistingRepositoryId() throws Exception {

    DLFolder dlFolder = DLTestUtil.addDLFolder(_group.getGroupId());

    RepositoryFactoryUtil.create(dlFolder.getRepositoryId());
  }
  @Test
  public void testCreateLocalRepositoryFromExistingRepositoryId() throws Exception {

    DLFolder dlFolder = DLTestUtil.addDLFolder(_group.getGroupId());

    RepositoryLocalServiceUtil.getLocalRepositoryImpl(dlFolder.getRepositoryId());
  }
Exemple #4
0
  public static SyncDLObject toSyncDLObject(DLFolder dlFolder, String event) {
    SyncDLObject syncDLObject = new SyncDLObjectImpl();

    syncDLObject.setCompanyId(dlFolder.getCompanyId());
    syncDLObject.setCreateDate(dlFolder.getCreateDate());
    syncDLObject.setModifiedDate(dlFolder.getModifiedDate());
    syncDLObject.setRepositoryId(dlFolder.getRepositoryId());
    syncDLObject.setParentFolderId(dlFolder.getParentFolderId());
    syncDLObject.setName(dlFolder.getName());
    syncDLObject.setExtension(StringPool.BLANK);
    syncDLObject.setMimeType(StringPool.BLANK);
    syncDLObject.setDescription(dlFolder.getDescription());
    syncDLObject.setChangeLog(StringPool.BLANK);
    syncDLObject.setExtraSettings(StringPool.BLANK);
    syncDLObject.setVersion(StringPool.BLANK);
    syncDLObject.setSize(0);
    syncDLObject.setChecksum(StringPool.BLANK);
    syncDLObject.setEvent(event);
    syncDLObject.setLockExpirationDate(null);
    syncDLObject.setLockUserId(0);
    syncDLObject.setLockUserName(StringPool.BLANK);
    syncDLObject.setType(SyncConstants.TYPE_FOLDER);
    syncDLObject.setTypePK(dlFolder.getFolderId());
    syncDLObject.setTypeUuid(dlFolder.getUuid());

    return syncDLObject;
  }
  protected void initByFolderId(long folderId) {
    try {
      DLFolder dlFolder = dlFolderLocalService.getFolder(folderId);

      initByRepositoryId(dlFolder.getRepositoryId());
    } catch (Exception e) {
      if (_log.isTraceEnabled()) {
        if (e instanceof NoSuchFolderException) {
          _log.trace(e.getMessage());
        } else {
          _log.trace(e, e);
        }
      }
    }
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    DLFolder newDLFolder = _persistence.create(pk);

    newDLFolder.setUuid(ServiceTestUtil.randomString());

    newDLFolder.setGroupId(ServiceTestUtil.nextLong());

    newDLFolder.setCompanyId(ServiceTestUtil.nextLong());

    newDLFolder.setUserId(ServiceTestUtil.nextLong());

    newDLFolder.setUserName(ServiceTestUtil.randomString());

    newDLFolder.setCreateDate(ServiceTestUtil.nextDate());

    newDLFolder.setModifiedDate(ServiceTestUtil.nextDate());

    newDLFolder.setRepositoryId(ServiceTestUtil.nextLong());

    newDLFolder.setMountPoint(ServiceTestUtil.randomBoolean());

    newDLFolder.setParentFolderId(ServiceTestUtil.nextLong());

    newDLFolder.setName(ServiceTestUtil.randomString());

    newDLFolder.setDescription(ServiceTestUtil.randomString());

    newDLFolder.setLastPostDate(ServiceTestUtil.nextDate());

    newDLFolder.setDefaultFileEntryTypeId(ServiceTestUtil.nextLong());

    newDLFolder.setHidden(ServiceTestUtil.randomBoolean());

    newDLFolder.setOverrideFileEntryTypes(ServiceTestUtil.randomBoolean());

    newDLFolder.setStatus(ServiceTestUtil.nextInt());

    newDLFolder.setStatusByUserId(ServiceTestUtil.nextLong());

    newDLFolder.setStatusByUserName(ServiceTestUtil.randomString());

    newDLFolder.setStatusDate(ServiceTestUtil.nextDate());

    _persistence.update(newDLFolder);

    DLFolder existingDLFolder = _persistence.findByPrimaryKey(newDLFolder.getPrimaryKey());

    Assert.assertEquals(existingDLFolder.getUuid(), newDLFolder.getUuid());
    Assert.assertEquals(existingDLFolder.getFolderId(), newDLFolder.getFolderId());
    Assert.assertEquals(existingDLFolder.getGroupId(), newDLFolder.getGroupId());
    Assert.assertEquals(existingDLFolder.getCompanyId(), newDLFolder.getCompanyId());
    Assert.assertEquals(existingDLFolder.getUserId(), newDLFolder.getUserId());
    Assert.assertEquals(existingDLFolder.getUserName(), newDLFolder.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFolder.getCreateDate()),
        Time.getShortTimestamp(newDLFolder.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFolder.getModifiedDate()),
        Time.getShortTimestamp(newDLFolder.getModifiedDate()));
    Assert.assertEquals(existingDLFolder.getRepositoryId(), newDLFolder.getRepositoryId());
    Assert.assertEquals(existingDLFolder.getMountPoint(), newDLFolder.getMountPoint());
    Assert.assertEquals(existingDLFolder.getParentFolderId(), newDLFolder.getParentFolderId());
    Assert.assertEquals(existingDLFolder.getName(), newDLFolder.getName());
    Assert.assertEquals(existingDLFolder.getDescription(), newDLFolder.getDescription());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFolder.getLastPostDate()),
        Time.getShortTimestamp(newDLFolder.getLastPostDate()));
    Assert.assertEquals(
        existingDLFolder.getDefaultFileEntryTypeId(), newDLFolder.getDefaultFileEntryTypeId());
    Assert.assertEquals(existingDLFolder.getHidden(), newDLFolder.getHidden());
    Assert.assertEquals(
        existingDLFolder.getOverrideFileEntryTypes(), newDLFolder.getOverrideFileEntryTypes());
    Assert.assertEquals(existingDLFolder.getStatus(), newDLFolder.getStatus());
    Assert.assertEquals(existingDLFolder.getStatusByUserId(), newDLFolder.getStatusByUserId());
    Assert.assertEquals(existingDLFolder.getStatusByUserName(), newDLFolder.getStatusByUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDLFolder.getStatusDate()),
        Time.getShortTimestamp(newDLFolder.getStatusDate()));
  }