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.NoSuchContentSearchException;
25  import com.liferay.portlet.journal.service.JournalContentSearchLocalServiceUtil;
26  
27  import javax.servlet.http.HttpServletRequest;
28  import javax.servlet.http.HttpServletResponse;
29  
30  /**
31   * <a href="LayoutTypeArticleConfigurationDeleteAction.java.html"><b><i>View
32   * Source</i></b></a>
33   *
34   * @author Raymond Augé
35   */
36  public class LayoutTypeArticleConfigurationDeleteAction extends Action {
37  
38      public void run(HttpServletRequest request, HttpServletResponse response)
39          throws ActionException {
40  
41          try {
42              long groupId = ParamUtil.getLong(request, "groupId");
43              boolean privateLayout = ParamUtil.getBoolean(
44                  request, "privateLayout");
45              long layoutId = ParamUtil.getLong(request, "layoutId");
46  
47              Layout layout = LayoutLocalServiceUtil.getLayout(
48                  groupId, privateLayout, layoutId);
49  
50              UnicodeProperties typeSettingsProperties =
51                  layout.getTypeSettingsProperties();
52  
53              String articleId = typeSettingsProperties.getProperty("article-id");
54  
55              if (Validator.isNull(articleId)) {
56                  return;
57              }
58  
59              try {
60                  JournalContentSearchLocalServiceUtil.deleteArticleContentSearch(
61                      layout.getGroupId(), layout.isPrivateLayout(),
62                      layout.getLayoutId(), StringPool.BLANK, articleId);
63              }
64              catch (NoSuchContentSearchException nscse) {
65              }
66          }
67          catch (Exception e) {
68              throw new ActionException(e);
69          }
70      }
71  
72  }