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.portlet.tagsadmin.action;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.util.Constants;
20  import com.liferay.portal.kernel.util.ParamUtil;
21  import com.liferay.portal.struts.JSONAction;
22  import com.liferay.portlet.tags.service.TagsPropertyServiceUtil;
23  
24  import javax.servlet.http.HttpServletRequest;
25  import javax.servlet.http.HttpServletResponse;
26  
27  import org.apache.struts.action.ActionForm;
28  import org.apache.struts.action.ActionMapping;
29  
30  /**
31   * <a href="EditPropertyAction.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Brian Wing Shun Chan
34   */
35  public class EditPropertyAction extends JSONAction {
36  
37      public String getJSON(
38              ActionMapping mapping, ActionForm form, HttpServletRequest request,
39              HttpServletResponse response)
40          throws Exception {
41  
42          String cmd = ParamUtil.getString(request, Constants.CMD);
43  
44          try {
45              if (cmd.equals("addProperty")) {
46                  addProperty(request);
47              }
48          }
49          catch (Exception e) {
50              _log.error(e, e);
51          }
52  
53          return null;
54      }
55  
56      protected void addProperty(HttpServletRequest request) throws Exception {
57          long entryId = ParamUtil.getLong(request, "entryId");
58          String key = ParamUtil.getString(request, "key");
59          String value = ParamUtil.getString(request, "value");
60  
61          TagsPropertyServiceUtil.addProperty(entryId, key, value);
62      }
63  
64      private static Log _log = LogFactoryUtil.getLog(EditPropertyAction.class);
65  
66  }