001
014
015 package com.liferay.portlet.sites.action;
016
017 import com.liferay.portal.DuplicateGroupException;
018 import com.liferay.portal.GroupFriendlyURLException;
019 import com.liferay.portal.GroupNameException;
020 import com.liferay.portal.GroupParentException;
021 import com.liferay.portal.LayoutSetVirtualHostException;
022 import com.liferay.portal.LocaleException;
023 import com.liferay.portal.NoSuchGroupException;
024 import com.liferay.portal.NoSuchLayoutException;
025 import com.liferay.portal.PendingBackgroundTaskException;
026 import com.liferay.portal.RemoteExportException;
027 import com.liferay.portal.RemoteOptionsException;
028 import com.liferay.portal.RequiredGroupException;
029 import com.liferay.portal.kernel.dao.orm.QueryUtil;
030 import com.liferay.portal.kernel.exception.PortalException;
031 import com.liferay.portal.kernel.exception.SystemException;
032 import com.liferay.portal.kernel.servlet.SessionErrors;
033 import com.liferay.portal.kernel.staging.StagingUtil;
034 import com.liferay.portal.kernel.util.Constants;
035 import com.liferay.portal.kernel.util.GetterUtil;
036 import com.liferay.portal.kernel.util.HttpUtil;
037 import com.liferay.portal.kernel.util.ListUtil;
038 import com.liferay.portal.kernel.util.ParamUtil;
039 import com.liferay.portal.kernel.util.PrefsPropsUtil;
040 import com.liferay.portal.kernel.util.PropertiesParamUtil;
041 import com.liferay.portal.kernel.util.PropsKeys;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.kernel.util.UnicodeProperties;
045 import com.liferay.portal.kernel.util.UniqueList;
046 import com.liferay.portal.kernel.util.Validator;
047 import com.liferay.portal.liveusers.LiveUsers;
048 import com.liferay.portal.model.Group;
049 import com.liferay.portal.model.GroupConstants;
050 import com.liferay.portal.model.Layout;
051 import com.liferay.portal.model.LayoutConstants;
052 import com.liferay.portal.model.LayoutSet;
053 import com.liferay.portal.model.LayoutSetPrototype;
054 import com.liferay.portal.model.MembershipRequest;
055 import com.liferay.portal.model.MembershipRequestConstants;
056 import com.liferay.portal.model.Role;
057 import com.liferay.portal.model.Team;
058 import com.liferay.portal.security.auth.PrincipalException;
059 import com.liferay.portal.service.GroupLocalServiceUtil;
060 import com.liferay.portal.service.GroupServiceUtil;
061 import com.liferay.portal.service.LayoutLocalServiceUtil;
062 import com.liferay.portal.service.LayoutSetLocalServiceUtil;
063 import com.liferay.portal.service.LayoutSetPrototypeServiceUtil;
064 import com.liferay.portal.service.LayoutSetServiceUtil;
065 import com.liferay.portal.service.MembershipRequestLocalServiceUtil;
066 import com.liferay.portal.service.MembershipRequestServiceUtil;
067 import com.liferay.portal.service.RoleLocalServiceUtil;
068 import com.liferay.portal.service.ServiceContext;
069 import com.liferay.portal.service.ServiceContextFactory;
070 import com.liferay.portal.service.TeamLocalServiceUtil;
071 import com.liferay.portal.struts.PortletAction;
072 import com.liferay.portal.theme.ThemeDisplay;
073 import com.liferay.portal.util.PortalUtil;
074 import com.liferay.portal.util.PortletKeys;
075 import com.liferay.portal.util.WebKeys;
076 import com.liferay.portlet.asset.AssetCategoryException;
077 import com.liferay.portlet.asset.AssetTagException;
078 import com.liferay.portlet.sites.util.Sites;
079 import com.liferay.portlet.sites.util.SitesUtil;
080
081 import java.util.ArrayList;
082 import java.util.List;
083
084 import javax.portlet.ActionRequest;
085 import javax.portlet.ActionResponse;
086 import javax.portlet.PortletConfig;
087 import javax.portlet.PortletRequest;
088 import javax.portlet.PortletURL;
089 import javax.portlet.RenderRequest;
090 import javax.portlet.RenderResponse;
091
092 import org.apache.struts.action.ActionForm;
093 import org.apache.struts.action.ActionForward;
094 import org.apache.struts.action.ActionMapping;
095
096
101 public class EditGroupAction extends PortletAction {
102
103 @Override
104 public void processAction(
105 ActionMapping actionMapping, ActionForm actionForm,
106 PortletConfig portletConfig, ActionRequest actionRequest,
107 ActionResponse actionResponse)
108 throws Exception {
109
110 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
111 WebKeys.THEME_DISPLAY);
112
113 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
114
115 String redirect = ParamUtil.getString(actionRequest, "redirect");
116 String closeRedirect = ParamUtil.getString(
117 actionRequest, "closeRedirect");
118
119 try {
120 if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
121 Object[] returnValue = updateGroup(actionRequest);
122
123 Group group = (Group)returnValue[0];
124
125 Layout layout = themeDisplay.getLayout();
126
127 Group layoutGroup = layout.getGroup();
128
129 if (cmd.equals(Constants.ADD) && layoutGroup.isControlPanel()) {
130 themeDisplay.setScopeGroupId(group.getGroupId());
131
132 PortletURL siteAdministrationURL =
133 PortalUtil.getSiteAdministrationURL(
134 actionResponse, themeDisplay,
135 PortletKeys.SITE_SETTINGS);
136
137 redirect = siteAdministrationURL.toString();
138
139 hideDefaultSuccessMessage(portletConfig, actionRequest);
140 }
141 else {
142 String oldFriendlyURL = (String)returnValue[1];
143 String oldStagingFriendlyURL = (String)returnValue[2];
144 long newRefererPlid = (Long)returnValue[3];
145
146 redirect = HttpUtil.setParameter(
147 redirect, "doAsGroupId", group.getGroupId());
148 redirect = HttpUtil.setParameter(
149 redirect, "refererPlid", newRefererPlid);
150
151 closeRedirect = updateCloseRedirect(
152 closeRedirect, group, themeDisplay, oldFriendlyURL,
153 oldStagingFriendlyURL);
154 }
155 }
156 else if (cmd.equals(Constants.DEACTIVATE) ||
157 cmd.equals(Constants.RESTORE)) {
158
159 updateActive(actionRequest, cmd);
160 }
161 else if (cmd.equals(Constants.DELETE)) {
162 deleteGroups(actionRequest);
163 }
164 else if (cmd.equals("reset_merge_fail_count_and_merge")) {
165 resetMergeFailCountAndMerge(actionRequest);
166 }
167
168 sendRedirect(
169 portletConfig, actionRequest, actionResponse, redirect,
170 closeRedirect);
171 }
172 catch (Exception e) {
173 if (e instanceof NoSuchGroupException ||
174 e instanceof PrincipalException) {
175
176 SessionErrors.add(actionRequest, e.getClass());
177
178 setForward(actionRequest, "portlet.sites_admin.error");
179 }
180 else if (e instanceof AssetCategoryException ||
181 e instanceof AssetTagException ||
182 e instanceof DuplicateGroupException ||
183 e instanceof GroupFriendlyURLException ||
184 e instanceof GroupNameException ||
185 e instanceof GroupParentException ||
186 e instanceof LayoutSetVirtualHostException ||
187 e instanceof LocaleException ||
188 e instanceof PendingBackgroundTaskException ||
189 e instanceof RemoteExportException ||
190 e instanceof RemoteOptionsException ||
191 e instanceof RequiredGroupException ||
192 e instanceof SystemException) {
193
194 SessionErrors.add(actionRequest, e.getClass(), e);
195 }
196 else {
197 throw e;
198 }
199 }
200 }
201
202 @Override
203 public ActionForward render(
204 ActionMapping actionMapping, ActionForm actionForm,
205 PortletConfig portletConfig, RenderRequest renderRequest,
206 RenderResponse renderResponse)
207 throws Exception {
208
209 try {
210 ActionUtil.getGroup(renderRequest);
211 }
212 catch (Exception e) {
213 if (e instanceof NoSuchGroupException ||
214 e instanceof PrincipalException) {
215
216 SessionErrors.add(renderRequest, e.getClass());
217
218 return actionMapping.findForward("portlet.sites_admin.error");
219 }
220 else {
221 throw e;
222 }
223 }
224
225 return actionMapping.findForward(
226 getForward(renderRequest, "portlet.sites_admin.edit_site"));
227 }
228
229 protected void deleteGroups(ActionRequest actionRequest) throws Exception {
230 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
231 WebKeys.THEME_DISPLAY);
232
233 long[] deleteGroupIds = null;
234
235 long groupId = ParamUtil.getLong(actionRequest, "groupId");
236
237 if (groupId > 0) {
238 deleteGroupIds = new long[] {groupId};
239 }
240 else {
241 deleteGroupIds = StringUtil.split(
242 ParamUtil.getString(actionRequest, "deleteGroupIds"), 0L);
243 }
244
245 for (long deleteGroupId : deleteGroupIds) {
246 GroupServiceUtil.deleteGroup(deleteGroupId);
247
248 LiveUsers.deleteGroup(themeDisplay.getCompanyId(), deleteGroupId);
249 }
250 }
251
252 protected long getRefererGroupId(ThemeDisplay themeDisplay)
253 throws Exception {
254
255 long refererGroupId = 0;
256
257 try {
258 Layout refererLayout = LayoutLocalServiceUtil.getLayout(
259 themeDisplay.getRefererPlid());
260
261 refererGroupId = refererLayout.getGroupId();
262 }
263 catch (NoSuchLayoutException nsle) {
264 }
265
266 return refererGroupId;
267 }
268
269 protected List<Role> getRoles(PortletRequest portletRequest)
270 throws Exception {
271
272 List<Role> roles = new ArrayList<Role>();
273
274 long[] siteRolesRoleIds = StringUtil.split(
275 ParamUtil.getString(portletRequest, "siteRolesRoleIds"), 0L);
276
277 for (long siteRolesRoleId : siteRolesRoleIds) {
278 if (siteRolesRoleId == 0) {
279 continue;
280 }
281
282 Role role = RoleLocalServiceUtil.getRole(siteRolesRoleId);
283
284 roles.add(role);
285 }
286
287 return roles;
288 }
289
290 protected List<Team> getTeams(PortletRequest portletRequest)
291 throws Exception {
292
293 List<Team> teams = new UniqueList<Team>();
294
295 long[] teamsTeamIds = StringUtil.split(
296 ParamUtil.getString(portletRequest, "teamsTeamIds"), 0L);
297
298 for (long teamsTeamId : teamsTeamIds) {
299 if (teamsTeamId == 0) {
300 continue;
301 }
302
303 Team team = TeamLocalServiceUtil.getTeam(teamsTeamId);
304
305 teams.add(team);
306 }
307
308 return teams;
309 }
310
311
325 protected void resetMergeFailCountAndMerge(ActionRequest actionRequest)
326 throws Exception {
327
328 long layoutSetPrototypeId = ParamUtil.getLong(
329 actionRequest, "layoutSetPrototypeId");
330
331 LayoutSetPrototype layoutSetPrototype =
332 LayoutSetPrototypeServiceUtil.getLayoutSetPrototype(
333 layoutSetPrototypeId);
334
335 SitesUtil.setMergeFailCount(layoutSetPrototype, 0);
336
337 long groupId = ParamUtil.getLong(actionRequest, "groupId");
338 boolean privateLayoutSet = ParamUtil.getBoolean(
339 actionRequest, "privateLayoutSet");
340
341 LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(
342 groupId, privateLayoutSet);
343
344 SitesUtil.resetPrototype(layoutSet);
345
346 Group group = GroupLocalServiceUtil.getGroup(groupId);
347
348 SitesUtil.mergeLayoutSetPrototypeLayouts(group, layoutSet);
349
350 layoutSetPrototype =
351 LayoutSetPrototypeServiceUtil.getLayoutSetPrototype(
352 layoutSetPrototypeId);
353
354 if (SitesUtil.getMergeFailCount(layoutSetPrototype) > 0) {
355 SessionErrors.add(actionRequest, "resetMergeFailCountAndMerge");
356 }
357 }
358
359 protected void updateActive(ActionRequest actionRequest, String cmd)
360 throws Exception {
361
362 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
363 WebKeys.THEME_DISPLAY);
364
365 long groupId = ParamUtil.getLong(actionRequest, "groupId");
366
367 if ((groupId == themeDisplay.getDoAsGroupId()) ||
368 (groupId == themeDisplay.getScopeGroupId()) ||
369 (groupId == getRefererGroupId(themeDisplay))) {
370
371 throw new RequiredGroupException(
372 String.valueOf(groupId), RequiredGroupException.CURRENT_GROUP);
373 }
374
375 Group group = GroupServiceUtil.getGroup(groupId);
376
377 boolean active = false;
378
379 if (cmd.equals(Constants.RESTORE)) {
380 active = true;
381 }
382
383 ServiceContext serviceContext = ServiceContextFactory.getInstance(
384 Group.class.getName(), actionRequest);
385
386 GroupServiceUtil.updateGroup(
387 groupId, group.getParentGroupId(), group.getName(),
388 group.getDescription(), group.getType(), group.isManualMembership(),
389 group.getMembershipRestriction(), group.getFriendlyURL(), active,
390 serviceContext);
391 }
392
393 protected String updateCloseRedirect(
394 String closeRedirect, Group group, ThemeDisplay themeDisplay,
395 String oldFriendlyURL, String oldStagingFriendlyURL)
396 throws PortalException, SystemException {
397
398 if (Validator.isNull(closeRedirect) || (group == null)) {
399 return closeRedirect;
400 }
401
402 String oldPath = null;
403 String newPath = null;
404
405 if (Validator.isNotNull(oldFriendlyURL)) {
406 oldPath = oldFriendlyURL;
407 newPath = group.getFriendlyURL();
408
409 if (closeRedirect.contains(oldPath)) {
410 closeRedirect = PortalUtil.updateRedirect(
411 closeRedirect, oldPath, newPath);
412 }
413 else {
414 closeRedirect = PortalUtil.getGroupFriendlyURL(
415 group, false, themeDisplay);
416 }
417 }
418
419 if (Validator.isNotNull(oldStagingFriendlyURL)) {
420 Group stagingGroup = group.getStagingGroup();
421
422 if (GroupLocalServiceUtil.fetchGroup(
423 stagingGroup.getGroupId()) == null) {
424
425 oldPath = oldStagingFriendlyURL;
426 newPath = group.getFriendlyURL();
427 }
428 else {
429 oldPath = oldStagingFriendlyURL;
430 newPath = stagingGroup.getFriendlyURL();
431 }
432
433 if (closeRedirect.contains(oldPath)) {
434 closeRedirect = PortalUtil.updateRedirect(
435 closeRedirect, oldPath, newPath);
436 }
437 else {
438 closeRedirect = PortalUtil.getGroupFriendlyURL(
439 group, false, themeDisplay);
440 }
441 }
442
443 return closeRedirect;
444 }
445
446 protected Object[] updateGroup(ActionRequest actionRequest)
447 throws Exception {
448
449 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
450 WebKeys.THEME_DISPLAY);
451
452 long userId = PortalUtil.getUserId(actionRequest);
453
454 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
455
456 long parentGroupId = ParamUtil.getLong(
457 actionRequest, "parentGroupSearchContainerPrimaryKeys",
458 GroupConstants.DEFAULT_PARENT_GROUP_ID);
459 String name = null;
460 String description = null;
461 int type = 0;
462 String friendlyURL = null;
463 boolean active = false;
464 boolean manualMembership = true;
465
466 int membershipRestriction =
467 GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION;
468
469 boolean actionRequestMembershipRestriction = ParamUtil.getBoolean(
470 actionRequest, "membershipRestriction");
471
472 if (actionRequestMembershipRestriction &&
473 (parentGroupId != GroupConstants.DEFAULT_PARENT_GROUP_ID)) {
474
475 membershipRestriction =
476 GroupConstants.MEMBERSHIP_RESTRICTION_TO_PARENT_SITE_MEMBERS;
477 }
478
479 ServiceContext serviceContext = ServiceContextFactory.getInstance(
480 Group.class.getName(), actionRequest);
481
482 Group liveGroup = null;
483 String oldFriendlyURL = null;
484 String oldStagingFriendlyURL = null;
485
486 if (liveGroupId <= 0) {
487
488
489
490 name = ParamUtil.getString(actionRequest, "name");
491 description = ParamUtil.getString(actionRequest, "description");
492 type = ParamUtil.getInteger(actionRequest, "type");
493 friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL");
494 active = ParamUtil.getBoolean(actionRequest, "active");
495 manualMembership = ParamUtil.getBoolean(
496 actionRequest, "manualMembership");
497
498 liveGroup = GroupServiceUtil.addGroup(
499 parentGroupId, GroupConstants.DEFAULT_LIVE_GROUP_ID, name,
500 description, type, manualMembership, membershipRestriction,
501 friendlyURL, true, active, serviceContext);
502
503 LiveUsers.joinGroup(
504 themeDisplay.getCompanyId(), liveGroup.getGroupId(), userId);
505 }
506 else {
507
508
509
510 liveGroup = GroupLocalServiceUtil.getGroup(liveGroupId);
511
512 oldFriendlyURL = liveGroup.getFriendlyURL();
513
514 name = ParamUtil.getString(
515 actionRequest, "name", liveGroup.getName());
516 description = ParamUtil.getString(
517 actionRequest, "description", liveGroup.getDescription());
518 type = ParamUtil.getInteger(
519 actionRequest, "type", liveGroup.getType());
520 friendlyURL = ParamUtil.getString(
521 actionRequest, "friendlyURL", liveGroup.getFriendlyURL());
522 active = ParamUtil.getBoolean(
523 actionRequest, "active", liveGroup.getActive());
524 manualMembership = ParamUtil.getBoolean(
525 actionRequest, "manualMembership",
526 liveGroup.isManualMembership());
527
528 liveGroup = GroupServiceUtil.updateGroup(
529 liveGroupId, parentGroupId, name, description, type,
530 manualMembership, membershipRestriction, friendlyURL, active,
531 serviceContext);
532
533 if (type == GroupConstants.TYPE_SITE_OPEN) {
534 List<MembershipRequest> membershipRequests =
535 MembershipRequestLocalServiceUtil.search(
536 liveGroupId, MembershipRequestConstants.STATUS_PENDING,
537 QueryUtil.ALL_POS, QueryUtil.ALL_POS);
538
539 for (MembershipRequest membershipRequest : membershipRequests) {
540 MembershipRequestServiceUtil.updateStatus(
541 membershipRequest.getMembershipRequestId(),
542 themeDisplay.translate(
543 "your-membership-has-been-approved"),
544 MembershipRequestConstants.STATUS_APPROVED,
545 serviceContext);
546
547 LiveUsers.joinGroup(
548 themeDisplay.getCompanyId(),
549 membershipRequest.getGroupId(),
550 new long[] {membershipRequest.getUserId()});
551 }
552 }
553 }
554
555
556
557 UnicodeProperties typeSettingsProperties =
558 liveGroup.getTypeSettingsProperties();
559
560 String customJspServletContextName = ParamUtil.getString(
561 actionRequest, "customJspServletContextName",
562 typeSettingsProperties.getProperty("customJspServletContextName"));
563
564 typeSettingsProperties.setProperty(
565 "customJspServletContextName", customJspServletContextName);
566
567 typeSettingsProperties.setProperty(
568 "defaultSiteRoleIds",
569 ListUtil.toString(
570 getRoles(actionRequest), Role.ROLE_ID_ACCESSOR,
571 StringPool.COMMA));
572 typeSettingsProperties.setProperty(
573 "defaultTeamIds",
574 ListUtil.toString(
575 getTeams(actionRequest), Team.TEAM_ID_ACCESSOR,
576 StringPool.COMMA));
577
578 String[] analyticsTypes = PrefsPropsUtil.getStringArray(
579 themeDisplay.getCompanyId(), PropsKeys.ADMIN_ANALYTICS_TYPES,
580 StringPool.NEW_LINE);
581
582 for (String analyticsType : analyticsTypes) {
583 if (analyticsType.equalsIgnoreCase("google")) {
584 String googleAnalyticsId = ParamUtil.getString(
585 actionRequest, "googleAnalyticsId",
586 typeSettingsProperties.getProperty("googleAnalyticsId"));
587
588 typeSettingsProperties.setProperty(
589 "googleAnalyticsId", googleAnalyticsId);
590 }
591 else {
592 String analyticsScript = ParamUtil.getString(
593 actionRequest, Sites.ANALYTICS_PREFIX + analyticsType,
594 typeSettingsProperties.getProperty(analyticsType));
595
596 typeSettingsProperties.setProperty(
597 Sites.ANALYTICS_PREFIX + analyticsType, analyticsScript);
598 }
599 }
600
601 String publicRobots = ParamUtil.getString(
602 actionRequest, "publicRobots",
603 liveGroup.getTypeSettingsProperty("false-robots.txt"));
604 String privateRobots = ParamUtil.getString(
605 actionRequest, "privateRobots",
606 liveGroup.getTypeSettingsProperty("true-robots.txt"));
607
608 typeSettingsProperties.setProperty("false-robots.txt", publicRobots);
609 typeSettingsProperties.setProperty("true-robots.txt", privateRobots);
610
611 boolean trashEnabled = ParamUtil.getBoolean(
612 actionRequest, "trashEnabled",
613 GetterUtil.getBoolean(
614 typeSettingsProperties.getProperty("trashEnabled"), true));
615
616 typeSettingsProperties.setProperty(
617 "trashEnabled", String.valueOf(trashEnabled));
618
619 int trashEntriesMaxAgeCompany = PrefsPropsUtil.getInteger(
620 themeDisplay.getCompanyId(), PropsKeys.TRASH_ENTRIES_MAX_AGE);
621
622 double trashEntriesMaxAgeGroup = ParamUtil.getDouble(
623 actionRequest, "trashEntriesMaxAge");
624
625 if (trashEntriesMaxAgeGroup > 0) {
626 trashEntriesMaxAgeGroup *= 1440;
627 }
628 else {
629 trashEntriesMaxAgeGroup = GetterUtil.getInteger(
630 typeSettingsProperties.getProperty("trashEntriesMaxAge"),
631 trashEntriesMaxAgeCompany);
632 }
633
634 if (trashEntriesMaxAgeGroup != trashEntriesMaxAgeCompany) {
635 typeSettingsProperties.setProperty(
636 "trashEntriesMaxAge",
637 String.valueOf(GetterUtil.getInteger(trashEntriesMaxAgeGroup)));
638 }
639 else {
640 typeSettingsProperties.remove("trashEntriesMaxAge");
641 }
642
643 int contentSharingWithChildrenEnabled = ParamUtil.getInteger(
644 actionRequest, "contentSharingWithChildrenEnabled",
645 GetterUtil.getInteger(
646 typeSettingsProperties.getProperty(
647 "contentSharingWithChildrenEnabled"),
648 Sites.CONTENT_SHARING_WITH_CHILDREN_DEFAULT_VALUE));
649
650 typeSettingsProperties.setProperty(
651 "contentSharingWithChildrenEnabled",
652 String.valueOf(contentSharingWithChildrenEnabled));
653
654 UnicodeProperties formTypeSettingsProperties =
655 PropertiesParamUtil.getProperties(
656 actionRequest, "TypeSettingsProperties--");
657
658 typeSettingsProperties.putAll(formTypeSettingsProperties);
659
660
661
662 LayoutSet publicLayoutSet = liveGroup.getPublicLayoutSet();
663
664 String publicVirtualHost = ParamUtil.getString(
665 actionRequest, "publicVirtualHost",
666 publicLayoutSet.getVirtualHostname());
667
668 LayoutSetServiceUtil.updateVirtualHost(
669 liveGroup.getGroupId(), false, publicVirtualHost);
670
671 LayoutSet privateLayoutSet = liveGroup.getPrivateLayoutSet();
672
673 String privateVirtualHost = ParamUtil.getString(
674 actionRequest, "privateVirtualHost",
675 privateLayoutSet.getVirtualHostname());
676
677 LayoutSetServiceUtil.updateVirtualHost(
678 liveGroup.getGroupId(), true, privateVirtualHost);
679
680
681
682 if (liveGroup.hasStagingGroup()) {
683 Group stagingGroup = liveGroup.getStagingGroup();
684
685 oldStagingFriendlyURL = stagingGroup.getFriendlyURL();
686
687 friendlyURL = ParamUtil.getString(
688 actionRequest, "stagingFriendlyURL",
689 stagingGroup.getFriendlyURL());
690
691 GroupServiceUtil.updateFriendlyURL(
692 stagingGroup.getGroupId(), friendlyURL);
693
694 LayoutSet stagingPublicLayoutSet =
695 stagingGroup.getPublicLayoutSet();
696
697 publicVirtualHost = ParamUtil.getString(
698 actionRequest, "stagingPublicVirtualHost",
699 stagingPublicLayoutSet.getVirtualHostname());
700
701 LayoutSetServiceUtil.updateVirtualHost(
702 stagingGroup.getGroupId(), false, publicVirtualHost);
703
704 LayoutSet stagingPrivateLayoutSet =
705 stagingGroup.getPrivateLayoutSet();
706
707 privateVirtualHost = ParamUtil.getString(
708 actionRequest, "stagingPrivateVirtualHost",
709 stagingPrivateLayoutSet.getVirtualHostname());
710
711 LayoutSetServiceUtil.updateVirtualHost(
712 stagingGroup.getGroupId(), true, privateVirtualHost);
713 }
714
715 liveGroup = GroupServiceUtil.updateGroup(
716 liveGroup.getGroupId(), typeSettingsProperties.toString());
717
718
719
720 if (!liveGroup.isStaged()) {
721 long privateLayoutSetPrototypeId = ParamUtil.getLong(
722 actionRequest, "privateLayoutSetPrototypeId");
723 long publicLayoutSetPrototypeId = ParamUtil.getLong(
724 actionRequest, "publicLayoutSetPrototypeId");
725
726 boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(
727 actionRequest, "privateLayoutSetPrototypeLinkEnabled",
728 privateLayoutSet.isLayoutSetPrototypeLinkEnabled());
729 boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(
730 actionRequest, "publicLayoutSetPrototypeLinkEnabled",
731 publicLayoutSet.isLayoutSetPrototypeLinkEnabled());
732
733 if ((privateLayoutSetPrototypeId == 0) &&
734 (publicLayoutSetPrototypeId == 0) &&
735 !privateLayoutSetPrototypeLinkEnabled &&
736 !publicLayoutSetPrototypeLinkEnabled) {
737
738 long layoutSetPrototypeId = ParamUtil.getLong(
739 actionRequest, "layoutSetPrototypeId");
740 int layoutSetVisibility = ParamUtil.getInteger(
741 actionRequest, "layoutSetVisibility");
742 boolean layoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(
743 actionRequest, "layoutSetPrototypeLinkEnabled",
744 (layoutSetPrototypeId > 0));
745
746 if (layoutSetVisibility == _LAYOUT_SET_VISIBILITY_PRIVATE) {
747 privateLayoutSetPrototypeId = layoutSetPrototypeId;
748
749 privateLayoutSetPrototypeLinkEnabled =
750 layoutSetPrototypeLinkEnabled;
751 }
752 else {
753 publicLayoutSetPrototypeId = layoutSetPrototypeId;
754
755 publicLayoutSetPrototypeLinkEnabled =
756 layoutSetPrototypeLinkEnabled;
757 }
758 }
759
760 SitesUtil.updateLayoutSetPrototypesLinks(
761 liveGroup, publicLayoutSetPrototypeId,
762 privateLayoutSetPrototypeId,
763 publicLayoutSetPrototypeLinkEnabled,
764 privateLayoutSetPrototypeLinkEnabled);
765 }
766
767
768
769 String redirect = ParamUtil.getString(actionRequest, "redirect");
770
771 long refererPlid = GetterUtil.getLong(
772 HttpUtil.getParameter(redirect, "refererPlid", false));
773
774 if (!privateLayoutSet.isLayoutSetPrototypeLinkActive() &&
775 !publicLayoutSet.isLayoutSetPrototypeLinkActive()) {
776
777 if ((refererPlid > 0) && liveGroup.hasStagingGroup() &&
778 (themeDisplay.getScopeGroupId() != liveGroup.getGroupId())) {
779
780 Layout firstLayout = LayoutLocalServiceUtil.fetchFirstLayout(
781 liveGroup.getGroupId(), false,
782 LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
783
784 if (firstLayout == null) {
785 firstLayout = LayoutLocalServiceUtil.fetchFirstLayout(
786 liveGroup.getGroupId(), true,
787 LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
788 }
789
790 if (firstLayout != null) {
791 refererPlid = firstLayout.getPlid();
792 }
793 else {
794 refererPlid = 0;
795 }
796 }
797
798 StagingUtil.updateStaging(actionRequest, liveGroup);
799 }
800
801 return new Object[] {
802 liveGroup, oldFriendlyURL, oldStagingFriendlyURL, refererPlid};
803 }
804
805 private static final int _LAYOUT_SET_VISIBILITY_PRIVATE = 1;
806
807 }