Created
March 21, 2018 16:46
-
-
Save CorneAussems/c6daec7a42e40cd0d0a0e569f9357e8a to your computer and use it in GitHub Desktop.
Liferay DXP JournalFolderTree with file download groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.liferay.portal.kernel.util.PortalUtil; | |
import com.liferay.portal.kernel.service.ServiceContext; | |
import com.liferay.portlet.journal.service.*; | |
import com.liferay.journal.service.impl.*; | |
import com.liferay.journal.service.*; | |
import com.liferay.portal.kernel.service.*; | |
import com.liferay.portal.kernel.dao.orm.*; | |
final def SCRIPT_ID = "MYSCRIPT1" | |
outputFile = new File("""${System.getProperty("liferay.home")}/scripting/out-${SCRIPT_ID}.txt""") | |
outputFile.getParentFile().mkdirs() | |
def trace(message) { | |
//out.println(message) | |
outputFile << "${message}\n" | |
} | |
def getChildFolders(groupId, parentFolderId) { | |
def journalFolders = JournalFolderLocalServiceUtil.getFolders(groupId, parentFolderId); | |
if(journalFolders.size() > 0){ | |
trace("<UL>"); | |
for( x=0; x<journalFolders.size();x++){ | |
trace("<li>"+journalFolders[x].getName()+"</li>"); | |
getChildFolders(groupId, journalFolders[x].getFolderId()); | |
} | |
trace("</UL>"); | |
} | |
} | |
try { | |
trace("START"); | |
long companyId = PortalUtil.getDefaultCompanyId(); | |
long groupId = 20143; //HeyHema | |
def group = GroupLocalServiceUtil.getGroup(companyId,"Guest"); | |
trace("groupId:"+group.getGroupId()); | |
def groupFolders = JournalFolderLocalServiceUtil.getFolders(group.getGroupId()); | |
trace("<UL>"); | |
//for( i=0; i<groupFolders.size();i++){ | |
for( i=0; i<1;i++){ | |
trace("<li>"+groupFolders[i].getName()+"</li>"); | |
getChildFolders(groupId, groupFolders[i].getFolderId() ); | |
} | |
trace("</UL>"); | |
trace("END"); | |
}catch (e) { | |
out.println("Error = " + e.getMessage()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment