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
026
031 public class RepositoryEntryLocalServiceImpl
032 extends RepositoryEntryLocalServiceBaseImpl {
033
034 public RepositoryEntry addRepositoryEntry(
035 long userId, long groupId, long repositoryId, String mappedId,
036 ServiceContext serviceContext)
037 throws PortalException, SystemException {
038
039 User user = userPersistence.findByPrimaryKey(userId);
040 Date now = new Date();
041
042 long repositoryEntryId = counterLocalService.increment();
043
044 RepositoryEntry repositoryEntry = repositoryEntryPersistence.create(
045 repositoryEntryId);
046
047 repositoryEntry.setUuid(serviceContext.getUuid());
048 repositoryEntry.setGroupId(groupId);
049 repositoryEntry.setCompanyId(user.getCompanyId());
050 repositoryEntry.setUserId(userId);
051 repositoryEntry.setUserName(user.getFullName());
052 repositoryEntry.setCreateDate(serviceContext.getCreateDate(now));
053 repositoryEntry.setModifiedDate(serviceContext.getModifiedDate(now));
054 repositoryEntry.setRepositoryId(repositoryId);
055 repositoryEntry.setMappedId(mappedId);
056
057 repositoryEntryPersistence.update(repositoryEntry);
058
059 return repositoryEntry;
060 }
061
062 public RepositoryEntry updateRepositoryEntry(
063 long repositoryEntryId, String mappedId)
064 throws PortalException, SystemException {
065
066 RepositoryEntry repositoryEntry =
067 repositoryEntryPersistence.findByPrimaryKey(repositoryEntryId);
068
069 repositoryEntry.setModifiedDate(new Date());
070 repositoryEntry.setMappedId(mappedId);
071
072 repositoryEntryPersistence.update(repositoryEntry);
073
074 return repositoryEntry;
075 }
076
077 }