1
22
23 package com.liferay.portlet.communities.action;
24
25 import com.liferay.portal.LayoutFriendlyURLException;
26 import com.liferay.portal.LayoutHiddenException;
27 import com.liferay.portal.LayoutNameException;
28 import com.liferay.portal.LayoutParentLayoutIdException;
29 import com.liferay.portal.LayoutSetVirtualHostException;
30 import com.liferay.portal.LayoutTypeException;
31 import com.liferay.portal.NoSuchGroupException;
32 import com.liferay.portal.NoSuchLayoutException;
33 import com.liferay.portal.RemoteExportException;
34 import com.liferay.portal.RequiredLayoutException;
35 import com.liferay.portal.events.EventsProcessor;
36 import com.liferay.portal.kernel.configuration.Filter;
37 import com.liferay.portal.kernel.language.LanguageUtil;
38 import com.liferay.portal.kernel.servlet.SessionErrors;
39 import com.liferay.portal.kernel.upload.UploadPortletRequest;
40 import com.liferay.portal.kernel.util.Constants;
41 import com.liferay.portal.kernel.util.FileUtil;
42 import com.liferay.portal.kernel.util.LocaleUtil;
43 import com.liferay.portal.kernel.util.ParamUtil;
44 import com.liferay.portal.kernel.util.StringUtil;
45 import com.liferay.portal.kernel.util.UnicodeProperties;
46 import com.liferay.portal.kernel.util.Validator;
47 import com.liferay.portal.model.ColorScheme;
48 import com.liferay.portal.model.Group;
49 import com.liferay.portal.model.Layout;
50 import com.liferay.portal.model.LayoutConstants;
51 import com.liferay.portal.model.LayoutTypePortlet;
52 import com.liferay.portal.model.PortletPreferencesIds;
53 import com.liferay.portal.model.User;
54 import com.liferay.portal.security.auth.PrincipalException;
55 import com.liferay.portal.security.permission.ActionKeys;
56 import com.liferay.portal.security.permission.PermissionChecker;
57 import com.liferay.portal.service.GroupLocalServiceUtil;
58 import com.liferay.portal.service.GroupServiceUtil;
59 import com.liferay.portal.service.LayoutLocalServiceUtil;
60 import com.liferay.portal.service.LayoutServiceUtil;
61 import com.liferay.portal.service.LayoutSetServiceUtil;
62 import com.liferay.portal.service.PortletPreferencesLocalServiceUtil;
63 import com.liferay.portal.service.ThemeLocalServiceUtil;
64 import com.liferay.portal.service.UserLocalServiceUtil;
65 import com.liferay.portal.service.permission.GroupPermissionUtil;
66 import com.liferay.portal.service.permission.OrganizationPermissionUtil;
67 import com.liferay.portal.service.permission.UserPermissionUtil;
68 import com.liferay.portal.struts.PortletAction;
69 import com.liferay.portal.theme.ThemeDisplay;
70 import com.liferay.portal.util.PortalUtil;
71 import com.liferay.portal.util.PortletKeys;
72 import com.liferay.portal.util.PropsKeys;
73 import com.liferay.portal.util.PropsUtil;
74 import com.liferay.portal.util.PropsValues;
75 import com.liferay.portal.util.WebKeys;
76 import com.liferay.portlet.PortletPreferencesFactoryUtil;
77 import com.liferay.portlet.communities.util.CommunitiesUtil;
78 import com.liferay.portlet.communities.util.StagingUtil;
79 import com.liferay.portlet.tasks.NoSuchProposalException;
80 import com.liferay.util.servlet.UploadException;
81
82 import java.io.File;
83
84 import java.util.HashMap;
85 import java.util.List;
86 import java.util.Locale;
87 import java.util.Map;
88
89 import javax.portlet.ActionRequest;
90 import javax.portlet.ActionResponse;
91 import javax.portlet.PortletConfig;
92 import javax.portlet.PortletPreferences;
93 import javax.portlet.PortletRequest;
94 import javax.portlet.PortletRequestDispatcher;
95 import javax.portlet.RenderRequest;
96 import javax.portlet.RenderResponse;
97 import javax.portlet.ResourceRequest;
98 import javax.portlet.ResourceResponse;
99
100 import javax.servlet.http.HttpServletRequest;
101 import javax.servlet.http.HttpServletResponse;
102
103 import org.apache.struts.action.ActionForm;
104 import org.apache.struts.action.ActionForward;
105 import org.apache.struts.action.ActionMapping;
106
107
113 public class EditPagesAction extends PortletAction {
114
115 public void processAction(
116 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
117 ActionRequest actionRequest, ActionResponse actionResponse)
118 throws Exception {
119
120 try {
121 checkPermissions(actionRequest);
122 }
123 catch (PrincipalException pe) {
124 return;
125 }
126
127 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
128
129 try {
130 if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
131 updateLayout(actionRequest, actionResponse);
132 }
133 else if (cmd.equals(Constants.DELETE)) {
134 CommunitiesUtil.deleteLayout(actionRequest, actionResponse);
135 }
136 else if (cmd.equals("copy_from_live")) {
137 StagingUtil.copyFromLive(actionRequest);
138 }
139 else if (cmd.equals("display_order")) {
140 updateDisplayOrder(actionRequest);
141 }
142 else if (cmd.equals("logo")) {
143 updateLogo(actionRequest);
144 }
145 else if (cmd.equals("look_and_feel")) {
146 updateLookAndFeel(actionRequest);
147 }
148 else if (cmd.equals("merge_pages")) {
149 updateMergePages(actionRequest);
150 }
151 else if (cmd.equals("monitoring")) {
152 updateMonitoring(actionRequest);
153 }
154 else if (cmd.equals("publish_to_live")) {
155 StagingUtil.publishToLive(actionRequest);
156 }
157 else if (cmd.equals("publish_to_remote")) {
158 StagingUtil.publishToRemote(actionRequest);
159 }
160 else if (cmd.equals("schedule_copy_from_live")) {
161 StagingUtil.scheduleCopyFromLive(actionRequest);
162 }
163 else if (cmd.equals("schedule_publish_to_live")) {
164 StagingUtil.schedulePublishToLive(actionRequest);
165 }
166 else if (cmd.equals("schedule_publish_to_remote")) {
167 StagingUtil.schedulePublishToRemote(actionRequest);
168 }
169 else if (cmd.equals("staging")) {
170 StagingUtil.updateStaging(actionRequest);
171 }
172 else if (cmd.equals("unschedule_copy_from_live")) {
173 StagingUtil.unscheduleCopyFromLive(actionRequest);
174 }
175 else if (cmd.equals("unschedule_publish_to_live")) {
176 StagingUtil.unschedulePublishToLive(actionRequest);
177 }
178 else if (cmd.equals("unschedule_publish_to_remote")) {
179 StagingUtil.unschedulePublishToRemote(actionRequest);
180 }
181 else if (cmd.equals("virtual_host")) {
182 updateVirtualHost(actionRequest);
183 }
184 else if (cmd.equals("workflow")) {
185 updateWorkflow(actionRequest);
186 }
187
188 String redirect = ParamUtil.getString(
189 actionRequest, "pagesRedirect");
190
191 sendRedirect(actionRequest, actionResponse, redirect);
192 }
193 catch (Exception e) {
194 if (e instanceof NoSuchLayoutException ||
195 e instanceof NoSuchProposalException ||
196 e instanceof PrincipalException) {
197
198 SessionErrors.add(actionRequest, e.getClass().getName());
199
200 setForward(actionRequest, "portlet.communities.error");
201 }
202 else if (e instanceof RemoteExportException) {
203 SessionErrors.add(actionRequest, e.getClass().getName(), e);
204
205 String redirect = ParamUtil.getString(
206 actionRequest, "pagesRedirect");
207
208 sendRedirect(actionRequest, actionResponse, redirect);
209 }
210 else if (e instanceof LayoutFriendlyURLException ||
211 e instanceof LayoutHiddenException ||
212 e instanceof LayoutNameException ||
213 e instanceof LayoutParentLayoutIdException ||
214 e instanceof LayoutSetVirtualHostException ||
215 e instanceof LayoutTypeException ||
216 e instanceof RequiredLayoutException ||
217 e instanceof UploadException) {
218
219 if (e instanceof LayoutFriendlyURLException) {
220 SessionErrors.add(
221 actionRequest,
222 LayoutFriendlyURLException.class.getName(), e);
223 }
224 else {
225 SessionErrors.add(actionRequest, e.getClass().getName(), e);
226 }
227 }
228 else {
229 throw e;
230 }
231 }
232 }
233
234 public ActionForward render(
235 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
236 RenderRequest renderRequest, RenderResponse renderResponse)
237 throws Exception {
238
239 try {
240 checkPermissions(renderRequest);
241 }
242 catch (PrincipalException pe) {
243 SessionErrors.add(
244 renderRequest, PrincipalException.class.getName());
245
246 return mapping.findForward("portlet.communities.error");
247 }
248
249 try {
250 ActionUtil.getGroup(renderRequest);
251 }
252 catch (Exception e) {
253 if (e instanceof NoSuchGroupException ||
254 e instanceof PrincipalException) {
255
256 SessionErrors.add(renderRequest, e.getClass().getName());
257
258 return mapping.findForward("portlet.communities.error");
259 }
260 else {
261 throw e;
262 }
263 }
264
265 return mapping.findForward(
266 getForward(renderRequest, "portlet.communities.edit_pages"));
267 }
268
269 public void serveResource(
270 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
271 ResourceRequest resourceRequest, ResourceResponse resourceResponse)
272 throws Exception {
273
274 String path =
275 "/html/portlet/communities/scheduled_publishing_events.jsp";
276
277 PortletRequestDispatcher prd =
278 portletConfig.getPortletContext().getRequestDispatcher(path);
279
280 prd.include(resourceRequest, resourceResponse);
281 }
282
283 protected void checkPermissions(PortletRequest portletRequest)
284 throws Exception {
285
286
288 ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
289 WebKeys.THEME_DISPLAY);
290
291 PermissionChecker permissionChecker =
292 themeDisplay.getPermissionChecker();
293
294 long groupId = ParamUtil.getLong(portletRequest, "groupId");
295 boolean privateLayout = ParamUtil.getBoolean(
296 portletRequest, "privateLayout");
297
298 Group group = GroupLocalServiceUtil.getGroup(groupId);
299
300 if (group.isCommunity()) {
301 if (!GroupPermissionUtil.contains(
302 permissionChecker, group.getGroupId(),
303 ActionKeys.APPROVE_PROPOSAL) &&
304 !GroupPermissionUtil.contains(
305 permissionChecker, group.getGroupId(),
306 ActionKeys.MANAGE_LAYOUTS)) {
307
308 throw new PrincipalException();
309 }
310 }
311 else if (group.isOrganization()) {
312 long organizationId = group.getClassPK();
313
314 if (!OrganizationPermissionUtil.contains(
315 permissionChecker, organizationId,
316 ActionKeys.APPROVE_PROPOSAL) &&
317 !OrganizationPermissionUtil.contains(
318 permissionChecker, organizationId,
319 ActionKeys.MANAGE_LAYOUTS)) {
320
321 throw new PrincipalException();
322 }
323 }
324 else if (group.isUser()) {
325 long groupUserId = group.getClassPK();
326
327 User groupUser = UserLocalServiceUtil.getUserById(groupUserId);
328
329 long[] organizationIds = groupUser.getOrganizationIds();
330
331 UserPermissionUtil.check(
332 permissionChecker, groupUserId, organizationIds,
333 ActionKeys.UPDATE);
334
335 if ((privateLayout &&
336 !PropsValues.LAYOUT_USER_PRIVATE_LAYOUTS_MODIFIABLE) ||
337 (!privateLayout &&
338 !PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_MODIFIABLE)) {
339
340 throw new PrincipalException();
341 }
342 }
343 }
344
345 protected void copyPreferences(
346 ActionRequest actionRequest, Layout layout, Layout copyLayout)
347 throws Exception {
348
349 long companyId = layout.getCompanyId();
350
351 LayoutTypePortlet copyLayoutTypePortlet =
352 (LayoutTypePortlet)copyLayout.getLayoutType();
353
354 List<String> copyPortletIds = copyLayoutTypePortlet.getPortletIds();
355
356 for (String copyPortletId : copyPortletIds) {
357 HttpServletRequest request = PortalUtil.getHttpServletRequest(
358 actionRequest);
359
360
362 PortletPreferencesIds portletPreferencesIds =
363 PortletPreferencesFactoryUtil.getPortletPreferencesIds(
364 request, layout, copyPortletId);
365
366 PortletPreferencesLocalServiceUtil.getPreferences(
367 portletPreferencesIds);
368
369 PortletPreferencesIds copyPortletPreferencesIds =
370 PortletPreferencesFactoryUtil.getPortletPreferencesIds(
371 request, copyLayout, copyPortletId);
372
373 PortletPreferences copyPrefs =
374 PortletPreferencesLocalServiceUtil.getPreferences(
375 copyPortletPreferencesIds);
376
377 PortletPreferencesLocalServiceUtil.updatePreferences(
378 portletPreferencesIds.getOwnerId(),
379 portletPreferencesIds.getOwnerType(),
380 portletPreferencesIds.getPlid(),
381 portletPreferencesIds.getPortletId(), copyPrefs);
382
383
385 PortletPreferencesLocalServiceUtil.getPreferences(
386 companyId, PortletKeys.PREFS_OWNER_ID_DEFAULT,
387 PortletKeys.PREFS_OWNER_TYPE_LAYOUT, layout.getPlid(),
388 copyPortletId);
389
390 copyPrefs =
391 PortletPreferencesLocalServiceUtil.getPreferences(
392 companyId, PortletKeys.PREFS_OWNER_ID_DEFAULT,
393 PortletKeys.PREFS_OWNER_TYPE_LAYOUT, copyLayout.getPlid(),
394 copyPortletId);
395
396 PortletPreferencesLocalServiceUtil.updatePreferences(
397 PortletKeys.PREFS_OWNER_ID_DEFAULT,
398 PortletKeys.PREFS_OWNER_TYPE_LAYOUT, layout.getPlid(),
399 copyPortletId, copyPrefs);
400 }
401 }
402
403 protected UnicodeProperties getTypeSettingsProperties(
404 ActionRequest actionRequest) {
405
406 UnicodeProperties typeSettingsProperties = new UnicodeProperties(true);
407
408 String prefix = "TypeSettingsProperties(";
409
410 for (String paramName: actionRequest.getParameterMap().keySet()) {
411 if (paramName.startsWith(prefix)) {
412 String key = paramName.substring(
413 prefix.length(), paramName.length() - 1);
414
415 typeSettingsProperties.setProperty(
416 key, actionRequest.getParameter(paramName));
417 }
418 }
419
420 return typeSettingsProperties;
421 }
422
423 protected void updateDisplayOrder(ActionRequest actionRequest)
424 throws Exception {
425
426 long groupId = ParamUtil.getLong(actionRequest, "groupId");
427 boolean privateLayout = ParamUtil.getBoolean(
428 actionRequest, "privateLayout");
429 long parentLayoutId = ParamUtil.getLong(
430 actionRequest, "parentLayoutId");
431 long[] layoutIds = StringUtil.split(
432 ParamUtil.getString(actionRequest, "layoutIds"), 0L);
433
434 LayoutServiceUtil.setLayouts(
435 groupId, privateLayout, parentLayoutId, layoutIds);
436 }
437
438 protected void updateLayout(
439 ActionRequest actionRequest, ActionResponse actionResponse)
440 throws Exception {
441
442 UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(
443 actionRequest);
444
445 String cmd = ParamUtil.getString(uploadRequest, Constants.CMD);
446
447 long groupId = ParamUtil.getLong(actionRequest, "groupId");
448 boolean privateLayout = ParamUtil.getBoolean(
449 actionRequest, "privateLayout");
450 long layoutId = ParamUtil.getLong(actionRequest, "layoutId");
451 long parentLayoutId = ParamUtil.getLong(
452 uploadRequest, "parentLayoutId");
453 String description = ParamUtil.getString(uploadRequest, "description");
454 String type = ParamUtil.getString(uploadRequest, "type");
455 boolean hidden = ParamUtil.getBoolean(uploadRequest, "hidden");
456 String friendlyURL = ParamUtil.getString(uploadRequest, "friendlyURL");
457 boolean iconImage = ParamUtil.getBoolean(uploadRequest, "iconImage");
458 byte[] iconBytes = FileUtil.getBytes(
459 uploadRequest.getFile("iconFileName"));
460
461 boolean inheritFromParentLayoutId = ParamUtil.getBoolean(
462 uploadRequest, "inheritFromParentLayoutId");
463
464 long copyLayoutId = ParamUtil.getLong(uploadRequest, "copyLayoutId");
465
466 Locale[] locales = LanguageUtil.getAvailableLocales();
467
468 Map<Locale, String> localeNamesMap = new HashMap<Locale, String>();
469 Map<Locale, String> localeTitlesMap = new HashMap<Locale, String>();
470
471 for (Locale locale : locales) {
472 String languageId = LocaleUtil.toLanguageId(locale);
473
474 localeNamesMap.put(
475 locale,
476 ParamUtil.getString(uploadRequest, "name_" + languageId));
477 localeTitlesMap.put(
478 locale,
479 ParamUtil.getString(uploadRequest, "title_" + languageId));
480 }
481
482 if (cmd.equals(Constants.ADD)) {
483
484
486 if (inheritFromParentLayoutId && (parentLayoutId > 0)) {
487 Layout parentLayout = LayoutLocalServiceUtil.getLayout(
488 groupId, privateLayout, parentLayoutId);
489
490 Layout layout = LayoutServiceUtil.addLayout(
491 groupId, privateLayout, parentLayoutId, localeNamesMap,
492 localeTitlesMap, description, parentLayout.getType(),
493 parentLayout.isHidden(), friendlyURL);
494
495 LayoutServiceUtil.updateLayout(
496 layout.getGroupId(), layout.isPrivateLayout(),
497 layout.getLayoutId(), parentLayout.getTypeSettings());
498 }
499 else {
500 LayoutServiceUtil.addLayout(
501 groupId, privateLayout, parentLayoutId, localeNamesMap,
502 localeTitlesMap, description, type, hidden, friendlyURL);
503 }
504 }
505 else {
506
507
509 Layout layout = LayoutLocalServiceUtil.getLayout(
510 groupId, privateLayout, layoutId);
511
512 layout = LayoutServiceUtil.updateLayout(
513 groupId, privateLayout, layoutId, layout.getParentLayoutId(),
514 localeNamesMap, localeTitlesMap, description, type, hidden,
515 friendlyURL, Boolean.valueOf(iconImage), iconBytes);
516
517 UnicodeProperties formTypeSettingsProperties =
518 getTypeSettingsProperties(actionRequest);
519
520 if (type.equals(LayoutConstants.TYPE_PORTLET)) {
521 if ((copyLayoutId > 0) &&
522 (copyLayoutId != layout.getLayoutId())) {
523
524 try {
525 Layout copyLayout = LayoutLocalServiceUtil.getLayout(
526 groupId, privateLayout, copyLayoutId);
527
528 if (copyLayout.getType().equals(
529 LayoutConstants.TYPE_PORTLET)) {
530
531 LayoutServiceUtil.updateLayout(
532 groupId, privateLayout, layoutId,
533 copyLayout.getTypeSettings());
534
535 copyPreferences(actionRequest, layout, copyLayout);
536 }
537 }
538 catch (NoSuchLayoutException nsle) {
539 }
540 }
541 else {
542 UnicodeProperties layoutTypeSettingsProperties =
543 layout.getTypeSettingsProperties();
544
545 for (String property: formTypeSettingsProperties.keySet()) {
546 layoutTypeSettingsProperties.setProperty(
547 property,
548 formTypeSettingsProperties.getProperty(property));
549 }
550
551 LayoutServiceUtil.updateLayout(
552 groupId, privateLayout, layoutId,
553 layout.getTypeSettings());
554 }
555 }
556 else {
557 layout.setTypeSettingsProperties(formTypeSettingsProperties);
558
559 LayoutServiceUtil.updateLayout(
560 groupId, privateLayout, layoutId, layout.getTypeSettings());
561 }
562
563 HttpServletResponse response = PortalUtil.getHttpServletResponse(
564 actionResponse);
565
566 String[] eventClasses = StringUtil.split(
567 PropsUtil.get(
568 PropsKeys.LAYOUT_CONFIGURATION_ACTION_UPDATE,
569 new Filter(type)));
570
571 EventsProcessor.process(
572 PropsKeys.LAYOUT_CONFIGURATION_ACTION_UPDATE, eventClasses,
573 uploadRequest, response);
574 }
575 }
576
577 protected void updateLogo(ActionRequest actionRequest) throws Exception {
578 UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(
579 actionRequest);
580
581 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
582 long stagingGroupId = ParamUtil.getLong(
583 actionRequest, "stagingGroupId");
584
585 boolean privateLayout = ParamUtil.getBoolean(
586 actionRequest, "privateLayout");
587 boolean logo = ParamUtil.getBoolean(actionRequest, "logo");
588
589 File file = uploadRequest.getFile("logoFileName");
590 byte[] bytes = FileUtil.getBytes(file);
591
592 if (logo && ((bytes == null) || (bytes.length == 0))) {
593 throw new UploadException();
594 }
595
596 LayoutSetServiceUtil.updateLogo(liveGroupId, privateLayout, logo, file);
597
598 if (stagingGroupId > 0) {
599 LayoutSetServiceUtil.updateLogo(
600 stagingGroupId, privateLayout, logo, file);
601 }
602 }
603
604 protected void updateLookAndFeel(ActionRequest actionRequest)
605 throws Exception {
606
607 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
608 WebKeys.THEME_DISPLAY);
609
610 long companyId = themeDisplay.getCompanyId();
611
612 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
613 long stagingGroupId = ParamUtil.getLong(
614 actionRequest, "stagingGroupId");
615
616 boolean privateLayout = ParamUtil.getBoolean(
617 actionRequest, "privateLayout");
618 long layoutId = ParamUtil.getLong(actionRequest, "layoutId");
619 String themeId = ParamUtil.getString(actionRequest, "themeId");
620 String colorSchemeId = ParamUtil.getString(
621 actionRequest, "colorSchemeId");
622 String css = ParamUtil.getString(actionRequest, "css");
623 boolean wapTheme = ParamUtil.getBoolean(actionRequest, "wapTheme");
624
625 updateLookAndFeel(
626 companyId, liveGroupId, privateLayout, layoutId, themeId,
627 colorSchemeId, css, wapTheme);
628
629 if (stagingGroupId > 0) {
630 updateLookAndFeel(
631 companyId, stagingGroupId, privateLayout, layoutId, themeId,
632 colorSchemeId, css, wapTheme);
633 }
634 }
635
636 protected void updateLookAndFeel(
637 long companyId, long groupId, boolean privateLayout, long layoutId,
638 String themeId, String colorSchemeId, String css, boolean wapTheme)
639 throws Exception {
640
641 if (Validator.isNotNull(themeId) && Validator.isNull(colorSchemeId)) {
642 ColorScheme colorScheme = ThemeLocalServiceUtil.getColorScheme(
643 companyId, themeId, colorSchemeId, wapTheme);
644
645 colorSchemeId = colorScheme.getColorSchemeId();
646 }
647
648 if (layoutId <= 0) {
649 LayoutSetServiceUtil.updateLookAndFeel(
650 groupId, privateLayout, themeId, colorSchemeId, css, wapTheme);
651 }
652 else {
653 LayoutServiceUtil.updateLookAndFeel(
654 groupId, privateLayout, layoutId, themeId, colorSchemeId, css,
655 wapTheme);
656 }
657 }
658
659 protected void updateMergePages(ActionRequest actionRequest)
660 throws Exception {
661
662 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
663
664 boolean mergeGuestPublicPages = ParamUtil.getBoolean(
665 actionRequest, "mergeGuestPublicPages");
666
667 Group liveGroup = GroupLocalServiceUtil.getGroup(liveGroupId);
668
669 UnicodeProperties props = liveGroup.getTypeSettingsProperties();
670
671 props.setProperty(
672 "mergeGuestPublicPages", String.valueOf(mergeGuestPublicPages));
673
674 GroupServiceUtil.updateGroup(liveGroupId, liveGroup.getTypeSettings());
675 }
676
677 protected void updateMonitoring(ActionRequest actionRequest)
678 throws Exception {
679
680 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
681
682 String googleAnalyticsId = ParamUtil.getString(
683 actionRequest, "googleAnalyticsId");
684
685 Group liveGroup = GroupLocalServiceUtil.getGroup(liveGroupId);
686
687 UnicodeProperties props = liveGroup.getTypeSettingsProperties();
688
689 props.setProperty("googleAnalyticsId", googleAnalyticsId);
690
691 GroupServiceUtil.updateGroup(liveGroupId, liveGroup.getTypeSettings());
692 }
693
694 protected void updateVirtualHost(ActionRequest actionRequest)
695 throws Exception {
696
697 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
698
699 String publicVirtualHost = ParamUtil.getString(
700 actionRequest, "publicVirtualHost");
701 String privateVirtualHost = ParamUtil.getString(
702 actionRequest, "privateVirtualHost");
703 String friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL");
704
705 LayoutSetServiceUtil.updateVirtualHost(
706 liveGroupId, false, publicVirtualHost);
707
708 LayoutSetServiceUtil.updateVirtualHost(
709 liveGroupId, true, privateVirtualHost);
710
711 GroupServiceUtil.updateFriendlyURL(liveGroupId, friendlyURL);
712 }
713
714 protected void updateWorkflow(ActionRequest actionRequest)
715 throws Exception {
716
717 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
718
719 boolean workflowEnabled = ParamUtil.getBoolean(
720 actionRequest, "workflowEnabled");
721 int workflowStages = ParamUtil.getInteger(
722 actionRequest, "workflowStages");
723
724 StringBuilder sb = new StringBuilder();
725
726 for (int i = 1; i <= workflowStages; i++) {
727 String workflowRoleName = ParamUtil.getString(
728 actionRequest, "workflowRoleName_" + i);
729
730 sb.append(workflowRoleName);
731
732 if ((i + 1) <= workflowStages) {
733 sb.append(",");
734 }
735 }
736
737 String workflowRoleNames = sb.toString();
738
739 GroupServiceUtil.updateWorkflow(
740 liveGroupId, workflowEnabled, workflowStages, workflowRoleNames);
741 }
742
743 }