@Override
  public Folder addAttachmentsFolder() throws PortalException, SystemException {

    if (_attachmentsFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      return PortletFileRepositoryUtil.getPortletFolder(_attachmentsFolderId);
    }

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);

    Repository repository =
        PortletFileRepositoryUtil.addPortletRepository(
            getGroupId(), PortletKeys.MESSAGE_BOARDS, serviceContext);

    MBThread thread = getThread();

    Folder threadFolder = thread.addAttachmentsFolder();

    Folder folder =
        PortletFileRepositoryUtil.addPortletFolder(
            getUserId(),
            repository.getRepositoryId(),
            threadFolder.getFolderId(),
            String.valueOf(getMessageId()),
            serviceContext);

    _attachmentsFolderId = folder.getFolderId();

    return folder;
  }
  public Folder moveFolderToTrash(long userId, Folder folder)
      throws PortalException, SystemException {

    // Folder

    DLFolder dlFolder =
        dlFolderLocalService.updateStatus(
            userId,
            folder.getFolderId(),
            WorkflowConstants.STATUS_IN_TRASH,
            new HashMap<String, Serializable>(),
            new ServiceContext());

    dlFolder.setName(DLAppUtil.appendTrashNamespace(dlFolder.getName()));

    dlFolderPersistence.update(dlFolder, false);

    // File rank

    dlFileRankLocalService.disableFileRanksByFolderId(folder.getFolderId());

    // Trash

    trashEntryLocalService.addTrashEntry(
        userId,
        folder.getGroupId(),
        DLFolderConstants.getClassName(),
        folder.getFolderId(),
        WorkflowConstants.STATUS_APPROVED,
        null,
        null);

    return new LiferayFolder(dlFolder);
  }
  public void restoreFolderFromTrash(long userId, Folder folder)
      throws PortalException, SystemException {

    // Folder

    TrashEntry trashEntry =
        trashEntryLocalService.getEntry(DLFolderConstants.getClassName(), folder.getFolderId());

    DLFolder dlFolder =
        dlFolderLocalService.updateStatus(
            userId,
            folder.getFolderId(),
            WorkflowConstants.STATUS_APPROVED,
            new HashMap<String, Serializable>(),
            new ServiceContext());

    dlFolder.setName(DLAppUtil.stripTrashNamespace(dlFolder.getName()));

    dlFolderPersistence.update(dlFolder, false);

    // File rank

    dlFileRankLocalService.enableFileRanksByFolderId(folder.getFolderId());

    // Trash

    trashEntryLocalService.deleteEntry(trashEntry.getEntryId());
  }
  public static void addPortletBreadcrumbEntries(
      Folder folder, HttpServletRequest request, PortletURL portletURL) throws Exception {

    long defaultFolderId = _getDefaultFolderId(request);

    List<Folder> ancestorFolders = Collections.emptyList();

    if ((folder != null) && (folder.getFolderId() != defaultFolderId)) {
      ancestorFolders = folder.getAncestors();

      int indexOfRootFolder = -1;

      for (int i = 0; i < ancestorFolders.size(); i++) {
        Folder ancestorFolder = ancestorFolders.get(i);

        if (defaultFolderId == ancestorFolder.getFolderId()) {
          indexOfRootFolder = i;
        }
      }

      if (indexOfRootFolder > -1) {
        ancestorFolders = ancestorFolders.subList(0, indexOfRootFolder);
      }
    }

    Collections.reverse(ancestorFolders);

    for (Folder ancestorFolder : ancestorFolders) {
      portletURL.setParameter("folderId", String.valueOf(ancestorFolder.getFolderId()));

      Map<String, Object> data = new HashMap<String, Object>();

      data.put("folder-id", ancestorFolder.getFolderId());

      PortalUtil.addPortletBreadcrumbEntry(
          request, ancestorFolder.getName(), portletURL.toString(), data);
    }

    long folderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;

    if (folder != null) {
      folderId = folder.getFolderId();
    }

    portletURL.setParameter("folderId", String.valueOf(folderId));

    if ((folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) && (folderId != defaultFolderId)) {

      Map<String, Object> data = new HashMap<String, Object>();

      data.put("folder-id", folderId);

      PortalUtil.addPortletBreadcrumbEntry(request, folder.getName(), portletURL.toString(), data);
    }
  }
  public static void addPortletBreadcrumbEntries(
      Folder folder, HttpServletRequest request, RenderResponse renderResponse) throws Exception {

    String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName");

    PortletURL portletURL = renderResponse.createRenderURL();

    if (mvcRenderCommandName.equals("/document_library/select_folder")) {
      ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

      portletURL.setParameter("mvcRenderCommandName", mvcRenderCommandName);
      portletURL.setWindowState(LiferayWindowState.POP_UP);

      PortalUtil.addPortletBreadcrumbEntry(
          request, themeDisplay.translate("home"), portletURL.toString());
    } else {
      portletURL.setParameter("mvcRenderCommandName", "/image_gallery_display/view");
    }

    long defaultFolderId = getDefaultFolderId(request);

    List<Folder> ancestorFolders = Collections.emptyList();

    if ((folder != null) && (folder.getFolderId() != defaultFolderId)) {
      ancestorFolders = folder.getAncestors();

      int indexOfRootFolder = -1;

      for (int i = 0; i < ancestorFolders.size(); i++) {
        Folder ancestorFolder = ancestorFolders.get(i);

        if (defaultFolderId == ancestorFolder.getFolderId()) {
          indexOfRootFolder = i;
        }
      }

      if (indexOfRootFolder > -1) {
        ancestorFolders = ancestorFolders.subList(0, indexOfRootFolder);
      }
    }

    Collections.reverse(ancestorFolders);

    for (Folder ancestorFolder : ancestorFolders) {
      portletURL.setParameter("folderId", String.valueOf(ancestorFolder.getFolderId()));

      PortalUtil.addPortletBreadcrumbEntry(
          request, ancestorFolder.getName(), portletURL.toString());
    }

    portletURL.setParameter("folderId", String.valueOf(folder.getFolderId()));

    PortalUtil.addPortletBreadcrumbEntry(request, folder.getName(), portletURL.toString());
  }
  private void _getFolders(CommandArgument commandArgument, Document document, Node rootNode)
      throws Exception {

    Element foldersElement = document.createElement("Folders");

    rootNode.appendChild(foldersElement);

    if (commandArgument.getCurrentFolder().equals(StringPool.SLASH)) {
      getRootFolders(commandArgument, document, foldersElement);
    } else {
      Group group = commandArgument.getCurrentGroup();

      Folder folder = _getFolder(group.getGroupId(), commandArgument.getCurrentFolder());

      List<Folder> folders = DLAppServiceUtil.getFolders(group.getGroupId(), folder.getFolderId());

      for (Folder curFolder : folders) {
        Element folderElement = document.createElement("Folder");

        foldersElement.appendChild(folderElement);

        folderElement.setAttribute("name", curFolder.getName());
      }
    }
  }
  private Folder _getFolder(long groupId, String folderName) throws Exception {

    DLFolder dlFolder = new DLFolderImpl();

    dlFolder.setFolderId(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
    dlFolder.setGroupId(groupId);

    Folder folder = new LiferayFolder(dlFolder);

    if (folderName.equals(StringPool.SLASH)) {
      return folder;
    }

    StringTokenizer st = new StringTokenizer(folderName, StringPool.SLASH);

    while (st.hasMoreTokens()) {
      String curFolderName = st.nextToken();

      List<Folder> folders = DLAppServiceUtil.getFolders(groupId, folder.getFolderId());

      for (Folder curFolder : folders) {
        if (curFolder.getName().equals(curFolderName)) {
          folder = curFolder;

          break;
        }
      }
    }

    return folder;
  }
  @Override
  protected FileEntry addFileEntry(
      long userId,
      long groupId,
      long folderId,
      String fileName,
      String contentType,
      InputStream inputStream,
      long size,
      ServiceContext serviceContext)
      throws PortalException {

    Folder folder = BlogsEntryLocalServiceUtil.addAttachmentsFolder(userId, groupId);

    return PortletFileRepositoryUtil.addPortletFileEntry(
        groupId,
        userId,
        BlogsEntry.class.getName(),
        0,
        BlogsConstants.SERVICE_NAME,
        folder.getFolderId(),
        inputStream,
        fileName,
        contentType,
        true);
  }
  protected String fileUpload(
      CommandArgument commandArgument, String fileName, File file, String extension) {

    try {
      Group group = commandArgument.getCurrentGroup();

      Folder folder = _getFolder(group.getGroupId(), commandArgument.getCurrentFolder());

      long folderId = folder.getFolderId();
      String title = fileName;
      String description = StringPool.BLANK;
      String changeLog = StringPool.BLANK;

      ServiceContext serviceContext = new ServiceContext();

      serviceContext.setAddCommunityPermissions(true);
      serviceContext.setAddGuestPermissions(true);

      DLAppServiceUtil.addFileEntry(
          group.getGroupId(), folderId, title, description, changeLog, file, serviceContext);
    } catch (Exception e) {
      throw new FCKException(e);
    }

    return "0";
  }
  @Override
  public Folder addAttachmentsFolder() throws PortalException {
    if (_attachmentsFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      return PortletFileRepositoryUtil.getPortletFolder(_attachmentsFolderId);
    }

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);

    Repository repository =
        PortletFileRepositoryUtil.addPortletRepository(
            getGroupId(), PortletKeys.BACKGROUND_TASK, serviceContext);

    Folder folder =
        PortletFileRepositoryUtil.addPortletFolder(
            getUserId(),
            repository.getRepositoryId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            String.valueOf(getBackgroundTaskId()),
            serviceContext);

    _attachmentsFolderId = folder.getFolderId();

    return folder;
  }
  @Override
  public void deleteFolder(long parentFolderId, String name) throws PortalException {

    Folder folder = getFolder(parentFolderId, name);

    deleteFolder(folder.getFolderId());
  }
  protected void moveAttachmentsFolders(
      MBMessage message,
      long oldAttachmentsFolderId,
      MBThread oldThread,
      MBThread newThread,
      ServiceContext serviceContext)
      throws PortalException {

    if (oldAttachmentsFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      Folder newThreadFolder = newThread.addAttachmentsFolder();

      PortletFileRepositoryUtil.movePortletFolder(
          message.getGroupId(),
          message.getUserId(),
          oldAttachmentsFolderId,
          newThreadFolder.getFolderId(),
          serviceContext);
    }

    List<MBMessage> childMessages =
        mbMessagePersistence.findByT_P(oldThread.getThreadId(), message.getMessageId());

    for (MBMessage childMessage : childMessages) {
      moveAttachmentsFolders(
          childMessage,
          childMessage.getAttachmentsFolderId(),
          oldThread,
          newThread,
          serviceContext);
    }
  }
  protected void deleteImages(ActionRequest actionRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long[] deleteFileEntryIds = null;

    long fileEntryId = ParamUtil.getLong(actionRequest, "fileEntryId");

    if (fileEntryId > 0) {
      deleteFileEntryIds = new long[] {fileEntryId};
    } else {
      deleteFileEntryIds =
          StringUtil.split(ParamUtil.getString(actionRequest, "deleteFileEntryIds"), 0L);
    }

    Folder folder =
        _blogsEntryLocalService.addAttachmentsFolder(
            themeDisplay.getUserId(), themeDisplay.getScopeGroupId());

    for (long deleteFileEntryId : deleteFileEntryIds) {
      FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(deleteFileEntryId);

      if (fileEntry.getFolderId() != folder.getFolderId()) {
        continue;
      }

      if ((fileEntry.getUserId() == themeDisplay.getUserId())
          || BlogsPermission.contains(
              themeDisplay.getPermissionChecker(),
              themeDisplay.getScopeGroupId(),
              ActionKeys.UPDATE)) {

        PortletFileRepositoryUtil.deletePortletFileEntry(deleteFileEntryId);
      }
    }
  }
  @Override
  public long getAttachmentsFolderId() {
    if (_attachmentsFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      return _attachmentsFolderId;
    }

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);

    Repository repository =
        PortletFileRepositoryUtil.fetchPortletRepository(getGroupId(), PortletKeys.BACKGROUND_TASK);

    if (repository == null) {
      return DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
    }

    try {
      Folder folder =
          PortletFileRepositoryUtil.getPortletFolder(
              repository.getRepositoryId(),
              DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
              String.valueOf(getBackgroundTaskId()));

      _attachmentsFolderId = folder.getFolderId();
    } catch (Exception e) {
    }

    return _attachmentsFolderId;
  }
  @Override
  public void unlockFolder(long parentFolderId, String name, String lockUuid)
      throws PortalException {

    Folder folder = getFolder(parentFolderId, name);

    unlockFolder(folder.getFolderId(), lockUuid);
  }
  @Test
  public void testUpdateAssetWhenUpdatingFolder() throws Throwable {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    Folder folder = addFolder(false, "Old Name");

    DLAppLocalServiceUtil.updateFolder(
        folder.getFolderId(),
        folder.getParentFolderId(),
        "New Name",
        RandomTestUtil.randomString(),
        serviceContext);

    AssetEntry assetEntry =
        AssetEntryLocalServiceUtil.getEntry(DLFolderConstants.getClassName(), folder.getFolderId());

    Assert.assertEquals("New Name", assetEntry.getTitle());
  }
  public Folder moveFolderFromTrash(
      long userId, Folder folder, long parentFolderId, ServiceContext serviceContext)
      throws PortalException, SystemException {

    // Folder

    dlFolderLocalService.updateStatus(
        userId,
        folder.getFolderId(),
        WorkflowConstants.STATUS_APPROVED,
        new HashMap<String, Serializable>(),
        new ServiceContext());

    // File rank

    dlFileRankLocalService.enableFileRanksByFolderId(folder.getFolderId());

    return dlAppService.moveFolder(folder.getFolderId(), parentFolderId, serviceContext);
  }
  @Override
  protected String doExportData(
      PortletDataContext portletDataContext,
      String portletId,
      PortletPreferences portletPreferences)
      throws Exception {

    portletDataContext.addPermissions(
        "com.liferay.portlet.documentlibrary", portletDataContext.getScopeGroupId());

    long rootFolderId = GetterUtil.getLong(portletPreferences.getValue("rootFolderId", null));

    Document document = SAXReaderUtil.createDocument();

    Element rootElement = document.addElement("documentlibrary-display-data");

    Element fileEntryTypesElement = rootElement.addElement("file-entry-types");
    Element foldersElement = rootElement.addElement("folders");
    Element fileEntriesElement = rootElement.addElement("file-entries");
    Element fileShortcutsElement = rootElement.addElement("file-shortcuts");
    Element fileRanksElement = rootElement.addElement("file-ranks");

    if (rootFolderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      List<Folder> folders = FolderUtil.findByRepositoryId(portletDataContext.getScopeGroupId());

      for (Folder folder : folders) {
        DLPortletDataHandlerImpl.exportFolder(
            portletDataContext,
            fileEntryTypesElement,
            foldersElement,
            fileEntriesElement,
            fileShortcutsElement,
            fileRanksElement,
            folder,
            false);
      }
    } else {
      Folder folder = FolderUtil.findByPrimaryKey(rootFolderId);

      rootElement.addAttribute("root-folder-id", String.valueOf(folder.getFolderId()));

      DLPortletDataHandlerImpl.exportFolder(
          portletDataContext,
          fileEntryTypesElement,
          foldersElement,
          fileEntriesElement,
          fileShortcutsElement,
          fileRanksElement,
          folder,
          true);
    }

    return document.formattedString();
  }
  public void deleteFolder(Folder folder) throws PortalException, SystemException {

    // Sync

    if (!isStagingGroup(folder.getGroupId())) {
      dlSyncLocalService.updateSync(
          folder.getFolderId(),
          folder.getParentFolderId(),
          folder.getName(),
          folder.getDescription(),
          DLSyncConstants.EVENT_DELETE,
          "-1");
    }

    // Trash

    if (folder.getModel() instanceof DLFolder) {
      trashEntryLocalService.deleteEntry(DLFolderConstants.getClassName(), folder.getFolderId());
    }
  }
  public void moveFolder(Folder folder) throws PortalException, SystemException {

    if (!isStagingGroup(folder.getGroupId())) {
      dlSyncLocalService.updateSync(
          folder.getFolderId(),
          folder.getParentFolderId(),
          folder.getName(),
          folder.getDescription(),
          DLSyncConstants.EVENT_UPDATE,
          "-1");
    }
  }
  public static void addPortletBreadcrumbEntries(
      long folderId, HttpServletRequest request, RenderResponse renderResponse) throws Exception {

    if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      Folder folder = DLAppLocalServiceUtil.getFolder(folderId);

      if (folder.getFolderId() != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        addPortletBreadcrumbEntries(folder, request, renderResponse);
      }
    }
  }
  protected Folder addFolder(boolean rootFolder, String name) throws Exception {

    long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;

    if (!rootFolder) {
      Folder parentFolder = addFolder(parentFolderId, "Test Folder", true);

      parentFolderId = parentFolder.getFolderId();
    }

    return addFolder(parentFolderId, name);
  }
  protected void copyFolder(
      Repository repository, Folder srcFolder, Folder destFolder, ServiceContext serviceContext)
      throws PortalException, SystemException {

    List<FileEntry> srcFileEntries =
        repository.getFileEntries(
            srcFolder.getFolderId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

    for (FileEntry srcFileEntry : srcFileEntries) {
      try {
        FileEntry fileEntry =
            repository.copyFileEntry(
                destFolder.getGroupId(),
                srcFileEntry.getFileEntryId(),
                destFolder.getFolderId(),
                serviceContext);

        DLProcessorRegistryUtil.trigger(fileEntry);
      } catch (Exception e) {
        _log.error(e, e);

        continue;
      }
    }

    List<Folder> srcSubfolders =
        repository.getFolders(
            srcFolder.getFolderId(), false, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

    for (Folder srcSubfolder : srcSubfolders) {
      Folder destSubfolder =
          repository.addFolder(
              destFolder.getFolderId(),
              srcSubfolder.getName(),
              srcSubfolder.getDescription(),
              serviceContext);

      copyFolder(repository, srcSubfolder, destSubfolder, serviceContext);
    }
  }
  @Test
  public void testMigrateDLWhenFileEntryInFolder() throws Exception {
    ServiceContext serviceContext =
        ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId());

    Folder folder =
        DLAppServiceUtil.addFolder(
            _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            RandomTestUtil.randomString(),
            RandomTestUtil.randomString(),
            serviceContext);

    testMigrateDL(folder.getFolderId());
  }
  @Test
  public void testFileVersionTreePathWhenMovingSubfolderWithFileVersion() throws Exception {

    ServiceContext serviceContext =
        ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId());

    Folder folderA =
        DLAppServiceUtil.addFolder(
            _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            "Folder A",
            RandomTestUtil.randomString(),
            serviceContext);

    Folder folderAA =
        DLAppServiceUtil.addFolder(
            _group.getGroupId(),
            folderA.getFolderId(),
            "Folder AA",
            RandomTestUtil.randomString(),
            serviceContext);

    FileEntry fileEntry = addFileEntry(folderAA.getFolderId(), "Entry.txt");

    DLAppLocalServiceUtil.moveFolder(
        TestPropsValues.getUserId(),
        folderAA.getFolderId(),
        DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
        serviceContext);

    DLFileVersion dlFileVersion =
        DLFileVersionLocalServiceUtil.getFileVersion(
            fileEntry.getFileEntryId(), DLFileEntryConstants.VERSION_DEFAULT);

    Assert.assertEquals(dlFileVersion.buildTreePath(), dlFileVersion.getTreePath());
  }
  @Override
  protected FileEntry fetchFileEntry(long userId, long groupId, long folderId, String fileName)
      throws PortalException {

    Folder folder = BlogsEntryLocalServiceUtil.addAttachmentsFolder(userId, groupId);

    try {
      return PortletFileRepositoryUtil.getPortletFileEntry(groupId, folder.getFolderId(), fileName);
    } catch (PortalException pe) {
      if (_log.isDebugEnabled()) {
        _log.debug(pe, pe);
      }

      return null;
    }
  }
  public void addFolder(Folder folder, ServiceContext serviceContext)
      throws PortalException, SystemException {

    if (!isStagingGroup(folder.getGroupId())) {
      dlSyncLocalService.addSync(
          folder.getFolderId(),
          folder.getUuid(),
          folder.getCompanyId(),
          folder.getRepositoryId(),
          folder.getParentFolderId(),
          folder.getName(),
          folder.getDescription(),
          DLSyncConstants.TYPE_FOLDER,
          "-1");
    }
  }
  /** @see com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter */
  public static boolean hasFiles(HttpServletRequest request) {
    try {

      // Do not use permission checking since this may be called from
      // other contexts that are also managing the principal

      User user = _getUser(request);

      String path = HttpUtil.fixPath(request.getPathInfo());

      String[] pathArray = StringUtil.split(path, CharPool.SLASH);

      if (pathArray.length == 0) {
        return true;
      } else if (_PATH_DDM.equals(pathArray[0])) {
        _checkDDMRecord(pathArray);
      } else if (Validator.isNumber(pathArray[0])) {
        _checkFileEntry(pathArray);
      } else {
        long groupId = _getGroupId(user.getCompanyId(), pathArray[0]);
        long folderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;

        for (int i = 1; i < pathArray.length; i++) {
          try {
            Folder folder = DLAppLocalServiceUtil.getFolder(groupId, folderId, pathArray[i]);

            folderId = folder.getFolderId();
          } catch (NoSuchFolderException nsfe) {
            if (i != (pathArray.length - 1)) {
              return false;
            }

            pathArray =
                new String[] {String.valueOf(groupId), String.valueOf(folderId), pathArray[i]};

            _checkFileEntry(pathArray);
          }
        }
      }
    } catch (Exception e) {
      return false;
    }

    return true;
  }
  public static void addPortletBreadcrumbEntries(
      FileEntry fileEntry, HttpServletRequest request, RenderResponse renderResponse)
      throws Exception {

    Folder folder = fileEntry.getFolder();

    if (folder.getFolderId() != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

      addPortletBreadcrumbEntries(folder, request, renderResponse);
    }

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("struts_action", "/document_library/view_file_entry");
    portletURL.setParameter("fileEntryId", String.valueOf(fileEntry.getFileEntryId()));

    PortalUtil.addPortletBreadcrumbEntry(request, fileEntry.getTitle(), portletURL.toString());
  }
  @Override
  protected StagedModel addStagedModel(
      Group group, Map<String, List<StagedModel>> dependentStagedModelsMap) throws Exception {

    List<StagedModel> folderDependentStagedModels =
        dependentStagedModelsMap.get(DLFolder.class.getSimpleName());

    Folder folder = (Folder) folderDependentStagedModels.get(0);

    List<StagedModel> fileEntryTypeDependentStagedModels =
        dependentStagedModelsMap.get(DLFileEntryType.class.getSimpleName());

    DLFileEntryType dlFileEntryType = (DLFileEntryType) fileEntryTypeDependentStagedModels.get(0);

    folder = DLAppTestUtil.addFolder(group.getGroupId(), folder.getFolderId());

    DLAppTestUtil.updateFolderFileEntryType(folder, dlFileEntryType.getFileEntryTypeId());

    return folder;
  }