001
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.model.User;
021 import com.liferay.portal.service.ServiceContext;
022 import com.liferay.portal.service.base.RepositoryEntryLocalServiceBaseImpl;
023
024 import java.util.Date;
025 import java.util.List;
026
027
032 public class RepositoryEntryLocalServiceImpl
033 extends RepositoryEntryLocalServiceBaseImpl {
034
035 @Override
036 public RepositoryEntry addRepositoryEntry(
037 long userId, long groupId, long repositoryId, String mappedId,
038 ServiceContext serviceContext)
039 throws PortalException, SystemException {
040
041 User user = userPersistence.findByPrimaryKey(userId);
042 Date now = new Date();
043
044 long repositoryEntryId = counterLocalService.increment();
045
046 RepositoryEntry repositoryEntry = repositoryEntryPersistence.create(
047 repositoryEntryId);
048
049 repositoryEntry.setUuid(serviceContext.getUuid());
050 repositoryEntry.setGroupId(groupId);
051 repositoryEntry.setCompanyId(user.getCompanyId());
052 repositoryEntry.setUserId(userId);
053 repositoryEntry.setUserName(user.getFullName());
054 repositoryEntry.setCreateDate(serviceContext.getCreateDate(now));
055 repositoryEntry.setModifiedDate(serviceContext.getModifiedDate(now));
056 repositoryEntry.setRepositoryId(repositoryId);
057 repositoryEntry.setMappedId(mappedId);
058
059 repositoryEntryPersistence.update(repositoryEntry);
060
061 return repositoryEntry;
062 }
063
064 @Override
065 public List<RepositoryEntry> getRepositoryEntries(long repositoryId)
066 throws SystemException {
067
068 return repositoryEntryPersistence.findByRepositoryId(repositoryId);
069 }
070
071 @Override
072 public RepositoryEntry updateRepositoryEntry(
073 long repositoryEntryId, String mappedId)
074 throws PortalException, SystemException {
075
076 RepositoryEntry repositoryEntry =
077 repositoryEntryPersistence.findByPrimaryKey(repositoryEntryId);
078
079 repositoryEntry.setModifiedDate(new Date());
080 repositoryEntry.setMappedId(mappedId);
081
082 repositoryEntryPersistence.update(repositoryEntry);
083
084 return repositoryEntry;
085 }
086
087 }