001    /**
002     * Copyright (c) 2000-2013 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.ExpandoColumnPermissionUtil;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class ExpandoColumnServiceImpl extends ExpandoColumnServiceBaseImpl {
030    
031            @Override
032            public ExpandoColumn addColumn(long tableId, String name, int type)
033                    throws PortalException, SystemException {
034    
035                    PortletPermissionUtil.check(
036                            getPermissionChecker(), PortletKeys.EXPANDO,
037                            ActionKeys.ADD_EXPANDO);
038    
039                    return expandoColumnLocalService.addColumn(tableId, name, type);
040            }
041    
042            @Override
043            public ExpandoColumn addColumn(
044                            long tableId, String name, int type, Object defaultData)
045                    throws PortalException, SystemException {
046    
047                    PortletPermissionUtil.check(
048                            getPermissionChecker(), PortletKeys.EXPANDO,
049                            ActionKeys.ADD_EXPANDO);
050    
051                    return expandoColumnLocalService.addColumn(
052                            tableId, name, type, defaultData);
053            }
054    
055            @Override
056            public void deleteColumn(long columnId)
057                    throws PortalException, SystemException {
058    
059                    ExpandoColumnPermissionUtil.check(
060                            getPermissionChecker(), columnId, ActionKeys.DELETE);
061    
062                    expandoColumnLocalService.deleteColumn(columnId);
063            }
064    
065            @Override
066            public ExpandoColumn updateColumn(long columnId, String name, int type)
067                    throws PortalException, SystemException {
068    
069                    ExpandoColumnPermissionUtil.check(
070                            getPermissionChecker(), columnId, ActionKeys.UPDATE);
071    
072                    return expandoColumnLocalService.updateColumn(columnId, name, type);
073            }
074    
075            @Override
076            public ExpandoColumn updateColumn(
077                            long columnId, String name, int type, Object defaultData)
078                    throws PortalException, SystemException {
079    
080                    ExpandoColumnPermissionUtil.check(
081                            getPermissionChecker(), columnId, ActionKeys.UPDATE);
082    
083                    return expandoColumnLocalService.updateColumn(
084                            columnId, name, type, defaultData);
085            }
086    
087            @Override
088            public ExpandoColumn updateTypeSettings(long columnId, String typeSettings)
089                    throws PortalException, SystemException {
090    
091                    ExpandoColumnPermissionUtil.check(
092                            getPermissionChecker(), columnId, ActionKeys.UPDATE);
093    
094                    return expandoColumnLocalService.updateTypeSettings(
095                            columnId, typeSettings);
096            }
097    
098    }