001    /**
002     * Copyright (c) 2000-2012 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 com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.RepositoryEntry;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portal.service.base.RepositoryEntryLocalServiceBaseImpl;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     * @author Michael C. Han
026     */
027    public class RepositoryEntryLocalServiceImpl
028            extends RepositoryEntryLocalServiceBaseImpl {
029    
030            public RepositoryEntry addRepositoryEntry(
031                            long groupId, long repositoryId, String mappedId,
032                            ServiceContext serviceContext)
033                    throws SystemException {
034    
035                    long repositoryEntryId = counterLocalService.increment();
036    
037                    RepositoryEntry repositoryEntry = repositoryEntryPersistence.create(
038                            repositoryEntryId);
039    
040                    repositoryEntry.setGroupId(groupId);
041                    repositoryEntry.setUuid(serviceContext.getUuid());
042                    repositoryEntry.setRepositoryId(repositoryId);
043                    repositoryEntry.setMappedId(mappedId);
044    
045                    repositoryEntryPersistence.update(repositoryEntry);
046    
047                    return repositoryEntry;
048            }
049    
050            public RepositoryEntry updateRepositoryEntry(
051                            long repositoryEntryId, String mappedId)
052                    throws PortalException, SystemException {
053    
054                    RepositoryEntry repositoryEntry =
055                            repositoryEntryPersistence.findByPrimaryKey(repositoryEntryId);
056    
057                    repositoryEntry.setMappedId(mappedId);
058    
059                    repositoryEntryPersistence.update(repositoryEntry);
060    
061                    return repositoryEntry;
062            }
063    
064    }