}
else {
layoutSetPrototype =
LayoutSetPrototypeLocalServiceUtil.addLayoutSetPrototype(
userId, companyId, getTargetValueMap(),
StringPool.BLANK, true, true, new ServiceContext());
}
group = layoutSetPrototype.getGroup();
targetClassPK = layoutSetPrototype.getLayoutSetPrototypeId();
}
else if (targetClassName.equals(Group.class.getName())) {
if (targetValue.equals(GroupConstants.GUEST)) {
group = GroupLocalServiceUtil.getGroup(
companyId, GroupConstants.GUEST);
List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(
group.getGroupId(), false,
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, false, 0, 1);
if (!layouts.isEmpty()) {
Layout layout = layouts.get(0);
LayoutTypePortlet layoutTypePortlet =
(LayoutTypePortlet)layout.getLayoutType();
List<String> portletIds = layoutTypePortlet.getPortletIds();
if (portletIds.size() != 2) {
existing = true;
}
for (String portletId : portletIds) {
if (!portletId.equals("47") &&
!portletId.equals("58")) {
existing = true;
}
}
}
}
else {
group = GroupLocalServiceUtil.fetchGroup(
companyId, targetValue);
if (group != null) {
existing = true;
}
else {
group = GroupLocalServiceUtil.addGroup(
userId, GroupConstants.DEFAULT_PARENT_GROUP_ID,
StringPool.BLANK,
GroupConstants.DEFAULT_PARENT_GROUP_ID,
GroupConstants.DEFAULT_LIVE_GROUP_ID, targetValue,
StringPool.BLANK, GroupConstants.TYPE_SITE_OPEN, true,
GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, null,
true, true, new ServiceContext());
}
}
targetClassPK = group.getGroupId();
}