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