Okay so here's a long answer and a possible Solution I think.
First the Code to add a Layout Template to a Site:
1
2 private void addDefaultLayout(Group newGroup) throws Exception {
3
4 MethodKey key = new MethodKey(
5 "com.liferay.portlet.sites.util.SitesUtil",
6 "applyLayoutSetPrototypes", Group.class, long.class, long.class,
7 ServiceContext.class);
8 List<LayoutSetPrototype> allLayoutPrototypes = LayoutSetPrototypeLocalServiceUtil
9 .getLayoutSetPrototypes(-1, -1);
10 LayoutSetPrototype projectDefaultLayout = null;
11 for (LayoutSetPrototype layoutSetPrototype : allLayoutPrototypes) {
12 if (layoutSetPrototype.getName().contains("ProjectDefault")) {
13 projectDefaultLayout = layoutSetPrototype;
14 s_logger.info("Found Template with id: "
15 + layoutSetPrototype.getLayoutSetPrototypeId());
16
17 break;
18 }
19 }
20
21 PortalClassInvoker.invoke(true, key, newGroup,
22 projectDefaultLayout.getLayoutSetPrototypeId(), 0,
23 m_liferayFacesContext.getServiceContext());
24 }
This Method invokes the SitesUtil Class as it's not available in the Portal Service JAR. After that I get every LayputPrototype and fetch the one I need. Then I invoke the Method in the SitesUtil Class and that basically does the trick. It takes about 5-7 seconds because some DB Queries are beeing processed. But now for the actual Problem I had:
As I wrote above I had the Problem that the scope wasn't set to the new Group Id which was pretty annoying. If found out, that this is related to a Bug:
LPS-25860 and
LPS-27246. In the later Link a guy posted a possible Workaround which solved my Problem. I wrote a simple Hook using his modified jsp-File. If someone wants to use it, it's in the Attachments of the later Link too. So.. Problem solved! Thanks for the help!
Cheers Marc
Por favor, faça login para denunciar.