Skip to content

Instantly share code, notes, and snippets.

@evaldeslacasa
Last active August 29, 2015 14:14
Show Gist options
  • Save evaldeslacasa/2223f63caff59795801a to your computer and use it in GitHub Desktop.
Save evaldeslacasa/2223f63caff59795801a to your computer and use it in GitHub Desktop.
This script aims to avoid patching the bug happening in Liferay 6.2 CE ga2 where Structure Ids weren't exposed, even when disabling the autogeneration of Ids. It can be run through the scripting console in the Control Panel. To understand the issue, visit: https://issues.liferay.com/browse/LPS-48441.
import com.liferay.portlet.journal.service.JournalStructureLocalServiceUtil;
import com.liferay.portlet.journal.model.JournalStructure;
List<JournalStructure> lista = JournalStructureLocalServiceUtil.getStructures();
println(lista);
JournalStructure myStructure = JournalStructureLocalServiceUtil.getStructure(10903);
// hard coded id of the structure that you want, mine was 10903
println(myStructure);
myStructure.setStructureId("MY_STRUCTURE_ID");
println(myStructure);
JournalStructureLocalServiceUtil.updateJournalStructure(myStructure);
// this call updates the structure in the database
JournalStructure structureChanged = JournalStructureLocalServiceUtil.getStructure(10181,"REMEMBER_ME_TERMS");
// 10181 is the site id of the structure
println(structureChanged);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment