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.portal.service.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.model.LayoutRevision;
021    import com.liferay.portal.model.RecentLayoutRevision;
022    import com.liferay.portal.service.base.RecentLayoutRevisionLocalServiceBaseImpl;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     * @author Preston Crary
027     */
028    @ProviderType
029    public class RecentLayoutRevisionLocalServiceImpl
030            extends RecentLayoutRevisionLocalServiceBaseImpl {
031    
032            @Override
033            public RecentLayoutRevision addRecentLayoutRevision(
034                            long userId, long layoutRevisionId, long layoutSetBranchId,
035                            long plid)
036                    throws PortalException {
037    
038                    LayoutRevision layoutRevision =
039                            layoutRevisionPersistence.findByPrimaryKey(layoutRevisionId);
040    
041                    RecentLayoutRevision recentLayoutRevision =
042                            recentLayoutRevisionPersistence.create(
043                                    counterLocalService.increment());
044    
045                    recentLayoutRevision.setGroupId(layoutRevision.getGroupId());
046                    recentLayoutRevision.setCompanyId(layoutRevision.getCompanyId());
047                    recentLayoutRevision.setUserId(userId);
048                    recentLayoutRevision.setLayoutRevisionId(layoutRevisionId);
049                    recentLayoutRevision.setLayoutSetBranchId(layoutSetBranchId);
050                    recentLayoutRevision.setPlid(plid);
051    
052                    return recentLayoutRevisionPersistence.update(recentLayoutRevision);
053            }
054    
055            @Override
056            public void deleteRecentLayoutRevisions(long layoutRevisionId) {
057                    recentLayoutRevisionPersistence.removeByLayoutRevisionId(
058                            layoutRevisionId);
059            }
060    
061            @Override
062            public void deleteUserRecentLayoutRevisions(long userId) {
063                    recentLayoutRevisionPersistence.removeByUserId(userId);
064            }
065    
066            @Override
067            public RecentLayoutRevision fetchRecentLayoutRevision(
068                    long userId, long layoutSetBranchId, long plid) {
069    
070                    return recentLayoutRevisionPersistence.fetchByU_L_P(
071                            userId, layoutSetBranchId, plid);
072            }
073    
074    }