1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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  }