001
014
015 package com.liferay.portlet.communities.action;
016
017 import com.liferay.portal.ImageTypeException;
018 import com.liferay.portal.LayoutFriendlyURLException;
019 import com.liferay.portal.LayoutHiddenException;
020 import com.liferay.portal.LayoutNameException;
021 import com.liferay.portal.LayoutParentLayoutIdException;
022 import com.liferay.portal.LayoutSetVirtualHostException;
023 import com.liferay.portal.LayoutTypeException;
024 import com.liferay.portal.NoSuchGroupException;
025 import com.liferay.portal.NoSuchLayoutException;
026 import com.liferay.portal.RemoteExportException;
027 import com.liferay.portal.RemoteOptionsException;
028 import com.liferay.portal.RequiredLayoutException;
029 import com.liferay.portal.events.EventsProcessorUtil;
030 import com.liferay.portal.kernel.exception.SystemException;
031 import com.liferay.portal.kernel.servlet.SessionErrors;
032 import com.liferay.portal.kernel.staging.StagingUtil;
033 import com.liferay.portal.kernel.upload.UploadPortletRequest;
034 import com.liferay.portal.kernel.util.Constants;
035 import com.liferay.portal.kernel.util.FileUtil;
036 import com.liferay.portal.kernel.util.HttpUtil;
037 import com.liferay.portal.kernel.util.LocalizationUtil;
038 import com.liferay.portal.kernel.util.ParamUtil;
039 import com.liferay.portal.kernel.util.PropertiesParamUtil;
040 import com.liferay.portal.kernel.util.PropsKeys;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.kernel.util.UnicodeProperties;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.model.ColorScheme;
046 import com.liferay.portal.model.Group;
047 import com.liferay.portal.model.Layout;
048 import com.liferay.portal.model.LayoutConstants;
049 import com.liferay.portal.model.LayoutPrototype;
050 import com.liferay.portal.model.User;
051 import com.liferay.portal.security.auth.PrincipalException;
052 import com.liferay.portal.security.permission.ActionKeys;
053 import com.liferay.portal.security.permission.PermissionChecker;
054 import com.liferay.portal.service.GroupLocalServiceUtil;
055 import com.liferay.portal.service.GroupServiceUtil;
056 import com.liferay.portal.service.LayoutLocalServiceUtil;
057 import com.liferay.portal.service.LayoutPrototypeServiceUtil;
058 import com.liferay.portal.service.LayoutServiceUtil;
059 import com.liferay.portal.service.LayoutSetServiceUtil;
060 import com.liferay.portal.service.ServiceContext;
061 import com.liferay.portal.service.ServiceContextFactory;
062 import com.liferay.portal.service.ThemeLocalServiceUtil;
063 import com.liferay.portal.service.UserLocalServiceUtil;
064 import com.liferay.portal.service.permission.GroupPermissionUtil;
065 import com.liferay.portal.service.permission.LayoutPermissionUtil;
066 import com.liferay.portal.service.permission.LayoutPrototypePermissionUtil;
067 import com.liferay.portal.service.permission.LayoutSetPrototypePermissionUtil;
068 import com.liferay.portal.service.permission.OrganizationPermissionUtil;
069 import com.liferay.portal.service.permission.UserPermissionUtil;
070 import com.liferay.portal.struts.PortletAction;
071 import com.liferay.portal.theme.ThemeDisplay;
072 import com.liferay.portal.util.LayoutSettings;
073 import com.liferay.portal.util.PortalUtil;
074 import com.liferay.portal.util.PropsValues;
075 import com.liferay.portal.util.WebKeys;
076 import com.liferay.portlet.communities.util.CommunitiesUtil;
077 import com.liferay.portlet.tasks.NoSuchProposalException;
078 import com.liferay.util.servlet.UploadException;
079
080 import java.io.File;
081
082 import java.util.Locale;
083 import java.util.Map;
084
085 import javax.portlet.ActionRequest;
086 import javax.portlet.ActionResponse;
087 import javax.portlet.PortletConfig;
088 import javax.portlet.PortletRequest;
089 import javax.portlet.PortletRequestDispatcher;
090 import javax.portlet.RenderRequest;
091 import javax.portlet.RenderResponse;
092 import javax.portlet.ResourceRequest;
093 import javax.portlet.ResourceResponse;
094
095 import javax.servlet.http.HttpServletResponse;
096
097 import org.apache.struts.action.ActionForm;
098 import org.apache.struts.action.ActionForward;
099 import org.apache.struts.action.ActionMapping;
100
101
104 public class EditPagesAction extends PortletAction {
105
106 public void processAction(
107 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
108 ActionRequest actionRequest, ActionResponse actionResponse)
109 throws Exception {
110
111 try {
112 checkPermissions(actionRequest);
113 }
114 catch (PrincipalException pe) {
115 return;
116 }
117
118 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
119
120 try {
121 Layout layout = null;
122 String oldFriendlyURL = StringPool.BLANK;
123
124 if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
125 Object[] returnValue = updateLayout(
126 actionRequest, actionResponse);
127
128 layout = (Layout)returnValue[0];
129 oldFriendlyURL = (String)returnValue[1];
130 }
131 else if (cmd.equals(Constants.DELETE)) {
132 CommunitiesUtil.deleteLayout(actionRequest, actionResponse);
133 }
134 else if (cmd.equals("copy_from_live")) {
135 StagingUtil.copyFromLive(actionRequest);
136 }
137 else if (cmd.equals("display_order")) {
138 updateDisplayOrder(actionRequest);
139 }
140 else if (cmd.equals("logo")) {
141 updateLogo(actionRequest);
142 }
143 else if (cmd.equals("look_and_feel")) {
144 updateLookAndFeel(actionRequest);
145 }
146 else if (cmd.equals("merge_pages")) {
147 updateMergePages(actionRequest);
148 }
149 else if (cmd.equals("monitoring")) {
150 updateMonitoring(actionRequest);
151 }
152 else if (cmd.equals("publish_to_live")) {
153 StagingUtil.publishToLive(actionRequest);
154 }
155 else if (cmd.equals("publish_to_remote")) {
156 StagingUtil.publishToRemote(actionRequest);
157 }
158 else if (cmd.equals("schedule_copy_from_live")) {
159 StagingUtil.scheduleCopyFromLive(actionRequest);
160 }
161 else if (cmd.equals("schedule_publish_to_live")) {
162 StagingUtil.schedulePublishToLive(actionRequest);
163 }
164 else if (cmd.equals("schedule_publish_to_remote")) {
165 StagingUtil.schedulePublishToRemote(actionRequest);
166 }
167 else if (cmd.equals("staging")) {
168 StagingUtil.updateStaging(actionRequest);
169 }
170 else if (cmd.equals("unschedule_copy_from_live")) {
171 StagingUtil.unscheduleCopyFromLive(actionRequest);
172 }
173 else if (cmd.equals("unschedule_publish_to_live")) {
174 StagingUtil.unschedulePublishToLive(actionRequest);
175 }
176 else if (cmd.equals("unschedule_publish_to_remote")) {
177 StagingUtil.unschedulePublishToRemote(actionRequest);
178 }
179 else if (cmd.equals("virtual_host")) {
180 updateVirtualHost(actionRequest);
181 }
182
183 String redirect = (String)actionRequest.getAttribute(
184 WebKeys.REDIRECT);
185
186 if (Validator.isNull(redirect)) {
187 redirect = ParamUtil.getString(actionRequest, "pagesRedirect");
188 }
189
190 if ((layout != null) && Validator.isNotNull(oldFriendlyURL)) {
191 ThemeDisplay themeDisplay =
192 (ThemeDisplay)actionRequest.getAttribute(
193 WebKeys.THEME_DISPLAY);
194
195 if (layout.getPlid() == themeDisplay.getPlid()) {
196 Group group = layout.getGroup();
197
198 String oldPath = group.getFriendlyURL() + oldFriendlyURL;
199 String newPath =
200 group.getFriendlyURL() + layout.getFriendlyURL();
201
202 redirect = StringUtil.replace(redirect, oldPath, newPath);
203
204 redirect = StringUtil.replace(
205 redirect, HttpUtil.encodeURL(oldPath),
206 HttpUtil.encodeURL(newPath));
207 }
208 }
209
210 sendRedirect(actionRequest, actionResponse, redirect);
211 }
212 catch (Exception e) {
213 if (e instanceof NoSuchLayoutException ||
214 e instanceof NoSuchProposalException ||
215 e instanceof PrincipalException) {
216
217 SessionErrors.add(actionRequest, e.getClass().getName());
218
219 setForward(actionRequest, "portlet.communities.error");
220 }
221 else if (e instanceof ImageTypeException ||
222 e instanceof LayoutFriendlyURLException ||
223 e instanceof LayoutHiddenException ||
224 e instanceof LayoutNameException ||
225 e instanceof LayoutParentLayoutIdException ||
226 e instanceof LayoutSetVirtualHostException ||
227 e instanceof LayoutTypeException ||
228 e instanceof RequiredLayoutException ||
229 e instanceof UploadException) {
230
231 if (e instanceof LayoutFriendlyURLException) {
232 SessionErrors.add(
233 actionRequest,
234 LayoutFriendlyURLException.class.getName(), e);
235 }
236 else {
237 SessionErrors.add(actionRequest, e.getClass().getName(), e);
238 }
239 }
240 else if (e instanceof RemoteExportException ||
241 e instanceof RemoteOptionsException ||
242 e instanceof SystemException) {
243
244 SessionErrors.add(actionRequest, e.getClass().getName(), e);
245
246 String redirect = ParamUtil.getString(
247 actionRequest, "pagesRedirect");
248
249 sendRedirect(actionRequest, actionResponse, redirect);
250 }
251 else {
252 throw e;
253 }
254 }
255 }
256
257 public ActionForward render(
258 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
259 RenderRequest renderRequest, RenderResponse renderResponse)
260 throws Exception {
261
262 try {
263 checkPermissions(renderRequest);
264 }
265 catch (PrincipalException pe) {
266 SessionErrors.add(
267 renderRequest, PrincipalException.class.getName());
268
269 return mapping.findForward("portlet.communities.error");
270 }
271
272 try {
273 getGroup(renderRequest);
274 }
275 catch (Exception e) {
276 if (e instanceof NoSuchGroupException ||
277 e instanceof PrincipalException) {
278
279 SessionErrors.add(renderRequest, e.getClass().getName());
280
281 return mapping.findForward("portlet.communities.error");
282 }
283 else {
284 throw e;
285 }
286 }
287
288 return mapping.findForward(
289 getForward(renderRequest, "portlet.communities.edit_pages"));
290 }
291
292 public void serveResource(
293 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
294 ResourceRequest resourceRequest, ResourceResponse resourceResponse)
295 throws Exception {
296
297 PortletRequestDispatcher portletRequestDispatcher =
298 portletConfig.getPortletContext().getRequestDispatcher(
299 "/html/portlet/communities/scheduled_publishing_events.jsp");
300
301 portletRequestDispatcher.include(resourceRequest, resourceResponse);
302 }
303
304 protected void checkPermissions(PortletRequest portletRequest)
305 throws Exception {
306
307
308
309 ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
310 WebKeys.THEME_DISPLAY);
311
312 PermissionChecker permissionChecker =
313 themeDisplay.getPermissionChecker();
314
315 Group group = getGroup(portletRequest);
316
317 if (group == null) {
318 throw new PrincipalException();
319 }
320
321 Layout layout = themeDisplay.getLayout();
322
323 boolean hasUpdateLayoutPermission = false;
324
325 if (layout != null) {
326 hasUpdateLayoutPermission = LayoutPermissionUtil.contains(
327 permissionChecker, layout.getGroupId(),
328 layout.isPrivateLayout(), layout.getLayoutId(),
329 ActionKeys.UPDATE);
330 }
331
332 if (group.isCommunity()) {
333 String cmd = ParamUtil.getString(portletRequest, Constants.CMD);
334
335 boolean publishToLive =
336 GroupPermissionUtil.contains(
337 permissionChecker, group.getGroupId(),
338 ActionKeys.PUBLISH_STAGING) &&
339 cmd.equals("publish_to_live");
340
341 if (!GroupPermissionUtil.contains(
342 permissionChecker, group.getGroupId(),
343 ActionKeys.APPROVE_PROPOSAL) &&
344 !GroupPermissionUtil.contains(
345 permissionChecker, group.getGroupId(),
346 ActionKeys.MANAGE_LAYOUTS) &&
347 !hasUpdateLayoutPermission && !publishToLive) {
348
349 throw new PrincipalException();
350 }
351 }
352 else if (group.isCompany()) {
353 if (!permissionChecker.isCompanyAdmin()) {
354 throw new PrincipalException();
355 }
356 }
357 else if (group.isLayoutPrototype()) {
358 LayoutPrototypePermissionUtil.check(
359 permissionChecker, group.getClassPK(), ActionKeys.UPDATE);
360 }
361 else if (group.isLayoutSetPrototype()) {
362 LayoutSetPrototypePermissionUtil.check(
363 permissionChecker, group.getClassPK(), ActionKeys.UPDATE);
364 }
365 else if (group.isOrganization()) {
366 long organizationId = group.getOrganizationId();
367
368 String cmd = ParamUtil.getString(portletRequest, Constants.CMD);
369
370 boolean publishToLive =
371 OrganizationPermissionUtil.contains(
372 permissionChecker, organizationId,
373 ActionKeys.PUBLISH_STAGING) &&
374 cmd.equals("publish_to_live");
375
376 if (!OrganizationPermissionUtil.contains(
377 permissionChecker, organizationId,
378 ActionKeys.APPROVE_PROPOSAL) &&
379 !OrganizationPermissionUtil.contains(
380 permissionChecker, organizationId,
381 ActionKeys.MANAGE_LAYOUTS) &&
382 !hasUpdateLayoutPermission && !publishToLive) {
383
384 throw new PrincipalException();
385 }
386 }
387 else if (group.isUser()) {
388 long groupUserId = group.getClassPK();
389
390 User groupUser = UserLocalServiceUtil.getUserById(groupUserId);
391
392 long[] organizationIds = groupUser.getOrganizationIds();
393
394 UserPermissionUtil.check(
395 permissionChecker, groupUserId, organizationIds,
396 ActionKeys.UPDATE);
397
398 if (!PropsValues.LAYOUT_USER_PRIVATE_LAYOUTS_MODIFIABLE &&
399 !PropsValues.LAYOUT_USER_PUBLIC_LAYOUTS_MODIFIABLE) {
400
401 throw new PrincipalException();
402 }
403 }
404 }
405
406 protected Group getGroup(PortletRequest portletRequest) throws Exception {
407 return ActionUtil.getGroup(portletRequest);
408 }
409
410 protected UnicodeProperties getTypeSettingsProperties(
411 ActionRequest actionRequest) {
412
413 return PropertiesParamUtil.getProperties(
414 actionRequest, "TypeSettingsProperties--");
415 }
416
417 protected void updateDisplayOrder(ActionRequest actionRequest)
418 throws Exception {
419
420 long groupId = ParamUtil.getLong(actionRequest, "groupId");
421 boolean privateLayout = ParamUtil.getBoolean(
422 actionRequest, "privateLayout");
423 long parentLayoutId = ParamUtil.getLong(
424 actionRequest, "parentLayoutId");
425 long[] layoutIds = StringUtil.split(
426 ParamUtil.getString(actionRequest, "layoutIds"), 0L);
427
428 LayoutServiceUtil.setLayouts(
429 groupId, privateLayout, parentLayoutId, layoutIds);
430 }
431
432 protected Object[] updateLayout(
433 ActionRequest actionRequest, ActionResponse actionResponse)
434 throws Exception {
435
436 UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(
437 actionRequest);
438
439 String cmd = ParamUtil.getString(uploadRequest, Constants.CMD);
440
441 long groupId = ParamUtil.getLong(actionRequest, "groupId");
442 boolean privateLayout = ParamUtil.getBoolean(
443 actionRequest, "privateLayout");
444 long layoutId = ParamUtil.getLong(actionRequest, "layoutId");
445 long parentLayoutId = ParamUtil.getLong(
446 uploadRequest, "parentLayoutId");
447 String description = ParamUtil.getString(uploadRequest, "description");
448 String type = ParamUtil.getString(uploadRequest, "type");
449 boolean hidden = ParamUtil.getBoolean(uploadRequest, "hidden");
450 String friendlyURL = ParamUtil.getString(uploadRequest, "friendlyURL");
451 boolean iconImage = ParamUtil.getBoolean(uploadRequest, "iconImage");
452 byte[] iconBytes = FileUtil.getBytes(
453 uploadRequest.getFile("iconFileName"));
454 long layoutPrototypeId = ParamUtil.getLong(
455 uploadRequest, "layoutPrototypeId");
456
457 boolean inheritFromParentLayoutId = ParamUtil.getBoolean(
458 uploadRequest, "inheritFromParentLayoutId");
459
460 long copyLayoutId = ParamUtil.getLong(uploadRequest, "copyLayoutId");
461
462 Map<Locale, String> localeNamesMap =
463 LocalizationUtil.getLocalizationMap(actionRequest, "name");
464 Map<Locale, String> localeTitlesMap =
465 LocalizationUtil.getLocalizationMap(actionRequest, "title");
466
467 ServiceContext serviceContext = ServiceContextFactory.getInstance(
468 Layout.class.getName(), actionRequest);
469
470 Layout layout = null;
471 String oldFriendlyURL = StringPool.BLANK;
472
473 if (cmd.equals(Constants.ADD)) {
474
475
476
477 if (inheritFromParentLayoutId && (parentLayoutId > 0)) {
478 Layout parentLayout = LayoutLocalServiceUtil.getLayout(
479 groupId, privateLayout, parentLayoutId);
480
481 layout = LayoutServiceUtil.addLayout(
482 groupId, privateLayout, parentLayoutId, localeNamesMap,
483 localeTitlesMap, description, parentLayout.getType(),
484 hidden, friendlyURL, serviceContext);
485
486 LayoutServiceUtil.updateLayout(
487 layout.getGroupId(), layout.isPrivateLayout(),
488 layout.getLayoutId(), parentLayout.getTypeSettings());
489
490 if (parentLayout.isTypePortlet()) {
491 ActionUtil.copyPreferences(
492 actionRequest, layout, parentLayout);
493 }
494 }
495 else if (layoutPrototypeId > 0) {
496 LayoutPrototype layoutPrototype =
497 LayoutPrototypeServiceUtil.getLayoutPrototype(
498 layoutPrototypeId);
499
500 Layout layoutPrototypeLayout = layoutPrototype.getLayout();
501
502 layout = LayoutServiceUtil.addLayout(
503 groupId, privateLayout, parentLayoutId, localeNamesMap,
504 localeTitlesMap, description, LayoutConstants.TYPE_PORTLET,
505 false, friendlyURL, serviceContext);
506
507 LayoutServiceUtil.updateLayout(
508 layout.getGroupId(), layout.isPrivateLayout(),
509 layout.getLayoutId(),
510 layoutPrototypeLayout.getTypeSettings());
511
512 ActionUtil.copyPreferences(
513 actionRequest, layout, layoutPrototypeLayout);
514
515 if (Validator.isNotNull(layoutPrototypeLayout.getThemeId())) {
516 LayoutServiceUtil.updateLookAndFeel(
517 layout.getGroupId(), layout.isPrivateLayout(),
518 layout.getLayoutId(),
519 layoutPrototypeLayout.getThemeId(),
520 layoutPrototypeLayout.getColorSchemeId(),
521 layoutPrototypeLayout.getCss(), false);
522 }
523
524 if (Validator.isNotNull(
525 layoutPrototypeLayout.getWapThemeId())) {
526
527 LayoutServiceUtil.updateLookAndFeel(
528 layout.getGroupId(), layout.isPrivateLayout(),
529 layout.getLayoutId(),
530 layoutPrototypeLayout.getWapThemeId(),
531 layoutPrototypeLayout.getWapColorSchemeId(),
532 layoutPrototypeLayout.getCss(), true);
533 }
534 }
535 else {
536 LayoutServiceUtil.addLayout(
537 groupId, privateLayout, parentLayoutId, localeNamesMap,
538 localeTitlesMap, description, type, hidden, friendlyURL,
539 serviceContext);
540 }
541 }
542 else {
543
544
545
546 layout = LayoutLocalServiceUtil.getLayout(
547 groupId, privateLayout, layoutId);
548
549 oldFriendlyURL = layout.getFriendlyURL();
550
551 layout = LayoutServiceUtil.updateLayout(
552 groupId, privateLayout, layoutId, layout.getParentLayoutId(),
553 localeNamesMap, localeTitlesMap, description, type, hidden,
554 friendlyURL, Boolean.valueOf(iconImage), iconBytes,
555 serviceContext);
556
557 if (oldFriendlyURL.equals(layout.getFriendlyURL())) {
558 oldFriendlyURL = StringPool.BLANK;
559 }
560
561 UnicodeProperties formTypeSettingsProperties =
562 getTypeSettingsProperties(actionRequest);
563
564 if (type.equals(LayoutConstants.TYPE_PORTLET)) {
565 if ((copyLayoutId > 0) &&
566 (copyLayoutId != layout.getLayoutId())) {
567
568 try {
569 Layout copyLayout = LayoutLocalServiceUtil.getLayout(
570 groupId, privateLayout, copyLayoutId);
571
572 if (copyLayout.isTypePortlet()) {
573 LayoutServiceUtil.updateLayout(
574 groupId, privateLayout, layoutId,
575 copyLayout.getTypeSettings());
576
577 ActionUtil.copyPreferences(
578 actionRequest, layout, copyLayout);
579 }
580 }
581 catch (NoSuchLayoutException nsle) {
582 }
583 }
584 else {
585 UnicodeProperties layoutTypeSettingsProperties =
586 layout.getTypeSettingsProperties();
587
588 layoutTypeSettingsProperties.putAll(
589 formTypeSettingsProperties);
590
591 LayoutServiceUtil.updateLayout(
592 groupId, privateLayout, layoutId,
593 layout.getTypeSettings());
594 }
595 }
596 else {
597 layout.setTypeSettingsProperties(formTypeSettingsProperties);
598
599 LayoutServiceUtil.updateLayout(
600 groupId, privateLayout, layoutId, layout.getTypeSettings());
601 }
602
603 HttpServletResponse response = PortalUtil.getHttpServletResponse(
604 actionResponse);
605
606 LayoutSettings layoutSettings = LayoutSettings.getInstance(layout);
607
608 EventsProcessorUtil.process(
609 PropsKeys.LAYOUT_CONFIGURATION_ACTION_UPDATE,
610 layoutSettings.getConfigurationActionUpdate(), uploadRequest,
611 response);
612 }
613
614 return new Object[] {layout, oldFriendlyURL};
615 }
616
617 protected void updateLogo(ActionRequest actionRequest) throws Exception {
618 UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(
619 actionRequest);
620
621 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
622 long stagingGroupId = ParamUtil.getLong(
623 actionRequest, "stagingGroupId");
624
625 boolean privateLayout = ParamUtil.getBoolean(
626 actionRequest, "privateLayout");
627 boolean logo = ParamUtil.getBoolean(actionRequest, "logo");
628
629 File file = uploadRequest.getFile("logoFileName");
630 byte[] bytes = FileUtil.getBytes(file);
631
632 if (logo && ((bytes == null) || (bytes.length == 0))) {
633 throw new UploadException();
634 }
635
636 LayoutSetServiceUtil.updateLogo(liveGroupId, privateLayout, logo, file);
637
638 if (stagingGroupId > 0) {
639 LayoutSetServiceUtil.updateLogo(
640 stagingGroupId, privateLayout, logo, file);
641 }
642 }
643
644 protected void updateLookAndFeel(ActionRequest actionRequest)
645 throws Exception {
646
647 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
648 WebKeys.THEME_DISPLAY);
649
650 long companyId = themeDisplay.getCompanyId();
651
652 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
653 long stagingGroupId = ParamUtil.getLong(
654 actionRequest, "stagingGroupId");
655
656 boolean privateLayout = ParamUtil.getBoolean(
657 actionRequest, "privateLayout");
658 long layoutId = ParamUtil.getLong(actionRequest, "layoutId");
659 String themeId = ParamUtil.getString(actionRequest, "themeId");
660 String colorSchemeId = ParamUtil.getString(
661 actionRequest, "colorSchemeId");
662 String css = ParamUtil.getString(actionRequest, "css");
663 boolean wapTheme = ParamUtil.getBoolean(actionRequest, "wapTheme");
664
665 if (stagingGroupId > 0) {
666 updateLookAndFeel(
667 companyId, stagingGroupId, privateLayout, layoutId, themeId,
668 colorSchemeId, css, wapTheme);
669 }
670 else {
671 updateLookAndFeel(
672 companyId, liveGroupId, privateLayout, layoutId, themeId,
673 colorSchemeId, css, wapTheme);
674 }
675 }
676
677 protected void updateLookAndFeel(
678 long companyId, long groupId, boolean privateLayout, long layoutId,
679 String themeId, String colorSchemeId, String css, boolean wapTheme)
680 throws Exception {
681
682 if (Validator.isNotNull(themeId) && Validator.isNull(colorSchemeId)) {
683 ColorScheme colorScheme = ThemeLocalServiceUtil.getColorScheme(
684 companyId, themeId, colorSchemeId, wapTheme);
685
686 colorSchemeId = colorScheme.getColorSchemeId();
687 }
688
689 if (layoutId <= 0) {
690 LayoutSetServiceUtil.updateLookAndFeel(
691 groupId, privateLayout, themeId, colorSchemeId, css, wapTheme);
692 }
693 else {
694 LayoutServiceUtil.updateLookAndFeel(
695 groupId, privateLayout, layoutId, themeId, colorSchemeId, css,
696 wapTheme);
697 }
698 }
699
700 protected void updateMergePages(ActionRequest actionRequest)
701 throws Exception {
702
703 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
704
705 boolean mergeGuestPublicPages = ParamUtil.getBoolean(
706 actionRequest, "mergeGuestPublicPages");
707
708 Group liveGroup = GroupLocalServiceUtil.getGroup(liveGroupId);
709
710 UnicodeProperties props = liveGroup.getTypeSettingsProperties();
711
712 props.setProperty(
713 "mergeGuestPublicPages", String.valueOf(mergeGuestPublicPages));
714
715 GroupServiceUtil.updateGroup(liveGroupId, liveGroup.getTypeSettings());
716 }
717
718 protected void updateMonitoring(ActionRequest actionRequest)
719 throws Exception {
720
721 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
722
723 String googleAnalyticsId = ParamUtil.getString(
724 actionRequest, "googleAnalyticsId");
725
726 Group liveGroup = GroupLocalServiceUtil.getGroup(liveGroupId);
727
728 UnicodeProperties props = liveGroup.getTypeSettingsProperties();
729
730 props.setProperty("googleAnalyticsId", googleAnalyticsId);
731
732 GroupServiceUtil.updateGroup(liveGroupId, liveGroup.getTypeSettings());
733 }
734
735 protected void updateVirtualHost(ActionRequest actionRequest)
736 throws Exception {
737
738 long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
739
740 String publicVirtualHost = ParamUtil.getString(
741 actionRequest, "publicVirtualHost");
742 String privateVirtualHost = ParamUtil.getString(
743 actionRequest, "privateVirtualHost");
744 String friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL");
745
746 LayoutSetServiceUtil.updateVirtualHost(
747 liveGroupId, false, publicVirtualHost);
748
749 LayoutSetServiceUtil.updateVirtualHost(
750 liveGroupId, true, privateVirtualHost);
751
752 GroupServiceUtil.updateFriendlyURL(liveGroupId, friendlyURL);
753
754 Group liveGroup = GroupServiceUtil.getGroup(liveGroupId);
755
756 if (liveGroup.hasStagingGroup()) {
757 Group stagingGroup = liveGroup.getStagingGroup();
758
759 publicVirtualHost = ParamUtil.getString(
760 actionRequest, "stagingPublicVirtualHost");
761 privateVirtualHost = ParamUtil.getString(
762 actionRequest, "stagingPrivateVirtualHost");
763 friendlyURL = ParamUtil.getString(
764 actionRequest, "stagingFriendlyURL");
765
766 LayoutSetServiceUtil.updateVirtualHost(
767 stagingGroup.getGroupId(), false, publicVirtualHost);
768
769 LayoutSetServiceUtil.updateVirtualHost(
770 stagingGroup.getGroupId(), true, privateVirtualHost);
771
772 GroupServiceUtil.updateFriendlyURL(
773 stagingGroup.getGroupId(), friendlyURL);
774 }
775 }
776
777 }