Pages

Wednesday, April 1, 2015

Create folders in Document Media programatically in Liferay

long folderId = 0;
try {
ThemeDisplay themeDisplay = (ThemeDisplay) request
.getAttribute(WebKeys.THEME_DISPLAY);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId());
                       //To get the List of folders of an Organization
List<DLFolder> groupFolder = DLFolderLocalServiceUtil.getFolders(
themeDisplay.getScopeGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
   //To create a folder in an Organization
DLFolder folder = DLFolderLocalServiceUtil.addFolder(
themeDisplay.getUserId(),
themeDisplay.getScopeGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
"Folder Name", "Folder Description",
serviceContext);

}

} catch (SystemException e) {
e.printStackTrace();
} catch (PortalException e) {
e.printStackTrace();
}

No comments:

Post a Comment