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.portlet.expando.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.security.permission.ActionKeys;
20  import com.liferay.portlet.expando.model.ExpandoColumn;
21  import com.liferay.portlet.expando.model.ExpandoValue;
22  import com.liferay.portlet.expando.service.base.ExpandoValueServiceBaseImpl;
23  import com.liferay.portlet.expando.service.permission.ExpandoColumnPermission;
24  
25  import java.io.Serializable;
26  
27  /**
28   * <a href="ExpandoValueServiceImpl.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class ExpandoValueServiceImpl extends ExpandoValueServiceBaseImpl {
33  
34      public ExpandoValue addValue(
35              long companyId, String className, String tableName,
36              String columnName, long classPK, Object data)
37          throws PortalException, SystemException {
38  
39          ExpandoColumn column = expandoColumnLocalService.getColumn(
40              companyId, className, tableName, columnName);
41  
42          ExpandoColumnPermission.check(
43              getPermissionChecker(), column, ActionKeys.UPDATE);
44  
45          return expandoValueLocalService.addValue(
46              companyId, className, tableName, columnName, classPK, data);
47      }
48  
49      public Serializable getData(
50              long companyId, String className, String tableName,
51              String columnName, long classPK)
52          throws PortalException, SystemException {
53  
54          ExpandoColumn column = expandoColumnLocalService.getColumn(
55              companyId, className, tableName, columnName);
56  
57          if (ExpandoColumnPermission.contains(
58                  getPermissionChecker(), column, ActionKeys.VIEW)) {
59  
60              return expandoValueLocalService.getData(
61                  companyId, className, tableName, columnName, classPK);
62          }
63          else {
64              return null;
65          }
66      }
67  
68  }