1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model;
16  
17  import com.liferay.portal.kernel.events.Action;
18  import com.liferay.portal.kernel.events.ActionException;
19  import com.liferay.portal.kernel.util.ParamUtil;
20  import com.liferay.portal.kernel.util.StringPool;
21  import com.liferay.portal.kernel.util.UnicodeProperties;
22  import com.liferay.portal.kernel.util.Validator;
23  import com.liferay.portal.service.LayoutLocalServiceUtil;
24  import com.liferay.portlet.journal.service.JournalContentSearchLocalServiceUtil;
25  
26  import javax.servlet.http.HttpServletRequest;
27  import javax.servlet.http.HttpServletResponse;
28  
29  /**
30   * <a href="LayoutTypeArticleConfigurationUpdateAction.java.html"><b><i>View
31   * Source</i></b></a>
32   *
33   * @author Raymond Augé
34   */
35  public class LayoutTypeArticleConfigurationUpdateAction extends Action {
36  
37      public void run(HttpServletRequest request, HttpServletResponse response)
38          throws ActionException {
39  
40          try {
41              long groupId = ParamUtil.getLong(request, "groupId");
42              boolean privateLayout = ParamUtil.getBoolean(
43                  request, "privateLayout");
44              long layoutId = ParamUtil.getLong(request, "layoutId");
45  
46              Layout layout = LayoutLocalServiceUtil.getLayout(
47                  groupId, privateLayout, layoutId);
48  
49              UnicodeProperties typeSettingsProperties =
50                  layout.getTypeSettingsProperties();
51  
52              String articleId = typeSettingsProperties.getProperty("article-id");
53  
54              if (Validator.isNull(articleId)) {
55                  return;
56              }
57  
58              JournalContentSearchLocalServiceUtil.updateContentSearch(
59                  layout.getGroupId(), layout.isPrivateLayout(),
60                  layout.getLayoutId(), StringPool.BLANK, articleId, true);
61          }
62          catch (Exception e) {
63              throw new ActionException(e);
64          }
65      }
66  
67  }