Friday, 31 March 2017

Select folder from document library in custom portlet

 To get specific folder folderId from Document media folders hierarchy.

 Need to do, like that other than using loops.

Step-1  Make your folders hierarchy.

public static final String  Base_Folder= "Documents/ABC/XYZ";

In this Base_Folder Variable we need to get FolderId to XYZ folder

    public static long getBaseLiferayFolderId(long groupId) throws PortalException,
     SystemException {
        //here we are geting parentFolderId
      String liferayBasePath = Base_Folder;
      long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
      List<String> folderNames = Arrays.asList(liferayBasePath.split(StringPool.SLASH));
      for (String folderName : folderNames) {
       if (!StringPool.BLANK.equalsIgnoreCase(folderName)) {
        parentFolderId = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, folderName).getFolderId();
       }
      }
      return parentFolderId;
     }

No comments:

Post a Comment