Skip to content

Instantly share code, notes, and snippets.

@CorneAussems
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CorneAussems/ab865aa07438e09de96f to your computer and use it in GitHub Desktop.
Save CorneAussems/ab865aa07438e09de96f to your computer and use it in GitHub Desktop.
Groovy Liferay Document Library find
############### generates
Caused by: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
at com.liferay.portal.kernel.messaging.proxy.ProxyRequest.execute(ProxyRequest.java:66)
##############
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.OrderByComparatorFactoryUtil;
import com.liferay.portal.kernel.util.OrderByComparatorFactory;
import com.liferay.portlet.documentlibrary.model.*;
import com.liferay.portlet.documentlibrary.service.*;
import com.liferay.portlet.documentlibrary.service.persistence.*;
// long companyId
companyId = 10154
// long groupId
groupId = 193310
def parentFolderId1 = 0
def start = -1
def end = -1
def OrderByComparatorFactory orderByComparatorFactory = OrderByComparatorFactoryUtil.getOrderByComparatorFactory()
def OrderByComparator obcFolder= orderByComparatorFactory.create('DLFolder', 'name', true)
def OrderByComparator obcFile= orderByComparatorFactory.create('DLFileEntry', 'title', true)
def getMyFolders
getMyFolders = { groupId, parentFolderId, depth ->
def folders = DLFolderLocalServiceUtil.getFolders(groupId, parentFolderId, start, end, obcFolder)
println(parentFolderId+' folders found:'+ folders.size() )
for( i=0; i<folders.size();i++){
def folder = folders[i]
println('folder depth:'+depth)
println('folder:'+folder.getName()+' uuid='+folder.getUuid() + ' folderId=' + folder.getFolderId() )
def files = DLFileEntryLocalServiceUtil.getFileEntries(groupId, folder.getFolderId(), start, end, obcFile)
println('>> files found:'+ files.size())
for( i=0; i<files.size();i++){
def file = files[i]
println('file:'+file.getTitle()+ ' title:' +file.getTitle()+' uuid='+folder.getUuid())
}
def newParentFolderId = folder.getFolderId();
getMyFolders(groupId, newParentFolderId, depth++);
}
}
try{
getMyFolders(groupId, parentFolderId1,0)
} catch (Exception e) {
println(e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment