001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.expando.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.permission.PortletPermissionUtil;
021    import com.liferay.portal.util.PortletKeys;
022    import com.liferay.portlet.expando.model.ExpandoColumn;
023    import com.liferay.portlet.expando.service.base.ExpandoColumnServiceBaseImpl;
024    import com.liferay.portlet.expando.service.permission.ExpandoColumnPermission;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class ExpandoColumnServiceImpl extends ExpandoColumnServiceBaseImpl {
030    
031            public ExpandoColumn addColumn(long tableId, String name, int type)
032                    throws PortalException, SystemException {
033    
034                    PortletPermissionUtil.check(
035                            getPermissionChecker(), PortletKeys.EXPANDO,
036                            ActionKeys.ADD_EXPANDO);
037    
038                    return expandoColumnLocalService.addColumn(tableId, name, type);
039            }
040    
041            public ExpandoColumn addColumn(
042                            long tableId, String name, int type, Object defaultData)
043                    throws PortalException, SystemException {
044    
045                    PortletPermissionUtil.check(
046                            getPermissionChecker(), PortletKeys.EXPANDO,
047                            ActionKeys.ADD_EXPANDO);
048    
049                    return expandoColumnLocalService.addColumn(
050                            tableId, name, type, defaultData);
051            }
052    
053            public void deleteColumn(long columnId)
054                    throws PortalException, SystemException {
055    
056                    ExpandoColumnPermission.check(
057                            getPermissionChecker(), columnId, ActionKeys.DELETE);
058    
059                    expandoColumnLocalService.deleteColumn(columnId);
060            }
061    
062            public ExpandoColumn updateColumn(long columnId, String name, int type)
063                    throws PortalException, SystemException {
064    
065                    ExpandoColumnPermission.check(
066                            getPermissionChecker(), columnId, ActionKeys.UPDATE);
067    
068                    return expandoColumnLocalService.updateColumn(columnId, name, type);
069            }
070    
071            public ExpandoColumn updateColumn(
072                            long columnId, String name, int type, Object defaultData)
073                    throws PortalException, SystemException {
074    
075                    ExpandoColumnPermission.check(
076                            getPermissionChecker(), columnId, ActionKeys.UPDATE);
077    
078                    return expandoColumnLocalService.updateColumn(
079                            columnId, name, type, defaultData);
080            }
081    
082            public ExpandoColumn updateTypeSettings(long columnId, String typeSettings)
083                    throws PortalException, SystemException {
084    
085                    ExpandoColumnPermission.check(
086                            getPermissionChecker(), columnId, ActionKeys.UPDATE);
087    
088                    return expandoColumnLocalService.updateTypeSettings(
089                            columnId, typeSettings);
090            }
091    
092    }