@Before
  public void setUp() throws Exception {
    SimpleAction simpleAction = new AddDefaultDocumentLibraryStructuresAction();

    String companyIdString = String.valueOf(TestPropsValues.getCompanyId());

    simpleAction.run(new String[] {companyIdString});

    _group = GroupTestUtil.addGroup();

    _folder =
        DLAppLocalServiceUtil.addFolder(
            TestPropsValues.getUserId(),
            _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            "Folder A",
            "",
            ServiceContextTestUtil.getServiceContext(_group.getGroupId()));

    _subfolder =
        DLAppLocalServiceUtil.addFolder(
            TestPropsValues.getUserId(),
            _group.getGroupId(),
            _folder.getFolderId(),
            "SubFolder AA",
            "",
            ServiceContextTestUtil.getServiceContext(_group.getGroupId()));

    _basicDocumentDLFileEntryType =
        DLFileEntryTypeLocalServiceUtil.getFileEntryType(
            DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT);

    _dlFileEntryTypes =
        DLFileEntryTypeLocalServiceUtil.getFileEntryTypes(
            PortalUtil.getCurrentAndAncestorSiteGroupIds(_group.getGroupId()));

    for (DLFileEntryType dlFileEntryType : _dlFileEntryTypes) {
      String name = dlFileEntryType.getName(LocaleUtil.getSiteDefault());

      if (name.equals(DLFileEntryTypeConstants.NAME_CONTRACT)) {
        _contractDLFileEntryType = dlFileEntryType;
      } else if (name.equals(DLFileEntryTypeConstants.NAME_MARKETING_BANNER)) {

        _marketingBannerDLFileEntryType = dlFileEntryType;
      }
    }
  }
  @Override
  public Folder addPortletFolder(
      long userId,
      long repositoryId,
      long parentFolderId,
      String folderName,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    boolean dlAppHelperEnabled = DLAppHelperThreadLocal.isEnabled();

    try {
      DLAppHelperThreadLocal.setEnabled(false);

      return DLAppLocalServiceUtil.getFolder(repositoryId, parentFolderId, folderName);
    } catch (NoSuchFolderException nsfe) {
      return DLAppLocalServiceUtil.addFolder(
          userId, repositoryId, parentFolderId, folderName, StringPool.BLANK, serviceContext);
    } finally {
      DLAppHelperThreadLocal.setEnabled(dlAppHelperEnabled);
    }
  }
  protected Folder addFolder(long parentFolderId, String name, boolean deleteExisting)
      throws Exception {

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    if (deleteExisting) {
      try {
        Folder folder = DLAppLocalServiceUtil.getFolder(_group.getGroupId(), parentFolderId, name);

        DLAppLocalServiceUtil.deleteFolder(folder.getFolderId());
      } catch (NoSuchFolderException nsfe) {
      }
    }

    return DLAppLocalServiceUtil.addFolder(
        TestPropsValues.getUserId(),
        _group.getGroupId(),
        parentFolderId,
        name,
        StringPool.BLANK,
        serviceContext);
  }