X

Subscribe to BloggerHow updates..

Recommend us on Google+

Get updates in your mail

New posts will get delivered to your mail box directly.Its free and we never spam you. Enter your mail here and click on subscribe. Check your mail box for a confirmation mail.

Get updates in your RSS reader

Subscribe using RSS and read updates using your favorite RSS reader..
RSS

Like us on Facebook

Get updates directly on your Facebook wall.

Follow us on Twitter

Get updates as tweets..

Circle me on Google plus

Add me to your circle and get new post updates in Google plus stream.


If the requirements to access files from document media and do some operaions on that file ,then the below code snippet will help us.

long folderId = 0;
try {
ThemeDisplay themeDisplay = (ThemeDisplay) request
.getAttribute(WebKeys.THEME_DISPLAY);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId());
List<DLFolder> groupFolder = DLFolderLocalServiceUtil.getFolders(
themeDisplay.getScopeGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
boolean IsFolderExits = false;
if (groupFolder.size() > 0) {
for (DLFolder folders : groupFolder) {
                              //To get particalar folderId
      if ("FolderName".equalsIgnoreCase(folders
.getName().trim())) {
folderId = folders.getFolderId();
IsFolderExits = true;
break;
}

}
}

                  String file = null;
List<DLFileEntry> fileEntries = null;
if (Validator.isNotNull(folderId)) {

try {
                              //To get the List of files exits in that particular folder
fileEntries = DLFileEntryLocalServiceUtil.getFileEntries(
themeDisplay.getScopeGroupId(), Long.valueOf(folderId));

} catch (NumberFormatException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
if (fileEntries.size() > 0) {

for (DLFileEntry entries : fileEntries) {
                                   //This will provide us to get the complete file Location of document Media
file = PropsUtil.get("dl.hook.file.system.root.dir") + "/"
+ entries.getCompanyId() + "/"
+ entries.getFolderId() + "/" + entries.getName()
+ "/" + entries.getVersion();
}
}
}


} catch (SystemException e) {
e.printStackTrace();
} catch (PortalException e) {
e.printStackTrace();
}
Share article
Older Post Newer Post

0 comments:

Post a Comment

To Top