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.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            @Override
031            public RepositoryEntry addRepositoryEntry(
032                            long groupId, long repositoryId, String mappedId,
033                            ServiceContext serviceContext)
034                    throws SystemException {
035    
036                    long repositoryEntryId = counterLocalService.increment();
037    
038                    RepositoryEntry repositoryEntry = repositoryEntryPersistence.create(
039                            repositoryEntryId);
040    
041                    repositoryEntry.setGroupId(groupId);
042                    repositoryEntry.setUuid(serviceContext.getUuid());
043                    repositoryEntry.setRepositoryId(repositoryId);
044                    repositoryEntry.setMappedId(mappedId);
045    
046                    repositoryEntryPersistence.update(repositoryEntry, false);
047    
048                    return repositoryEntry;
049            }
050    
051            @Override
052            public RepositoryEntry updateRepositoryEntry(
053                            long repositoryEntryId, String mappedId)
054                    throws PortalException, SystemException {
055    
056                    RepositoryEntry repositoryEntry =
057                            repositoryEntryPersistence.findByPrimaryKey(repositoryEntryId);
058    
059                    repositoryEntry.setMappedId(mappedId);
060    
061                    repositoryEntryPersistence.update(repositoryEntry, false);
062    
063                    return repositoryEntry;
064            }
065    
066    }