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 fetchExpandoColumn(long columnId)
064                    throws PortalException {
065    
066                    ExpandoColumnPermissionUtil.check(
067                            getPermissionChecker(), columnId, ActionKeys.VIEW);
068    
069                    return expandoColumnLocalService.fetchExpandoColumn(columnId);
070            }
071    
072            @Override
073            public ExpandoColumn updateColumn(long columnId, String name, int type)
074                    throws PortalException {
075    
076                    ExpandoColumnPermissionUtil.check(
077                            getPermissionChecker(), columnId, ActionKeys.UPDATE);
078    
079                    return expandoColumnLocalService.updateColumn(columnId, name, type);
080            }
081    
082            @Override
083            public ExpandoColumn updateColumn(
084                            long columnId, String name, int type, Object defaultData)
085                    throws PortalException {
086    
087                    ExpandoColumnPermissionUtil.check(
088                            getPermissionChecker(), columnId, ActionKeys.UPDATE);
089    
090                    return expandoColumnLocalService.updateColumn(
091                            columnId, name, type, defaultData);
092            }
093    
094            @Override
095            public ExpandoColumn updateTypeSettings(long columnId, String typeSettings)
096                    throws PortalException {
097    
098                    ExpandoColumnPermissionUtil.check(
099                            getPermissionChecker(), columnId, ActionKeys.UPDATE);
100    
101                    return expandoColumnLocalService.updateTypeSettings(
102                            columnId, typeSettings);
103            }
104    
105    }