001
014
015 package com.liferay.portlet.documentlibrary.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portlet.documentlibrary.model.DLSync;
020 import com.liferay.portlet.documentlibrary.model.DLSyncConstants;
021 import com.liferay.portlet.documentlibrary.service.base.DLSyncLocalServiceBaseImpl;
022
023 import java.util.Date;
024
025
028 public class DLSyncLocalServiceImpl extends DLSyncLocalServiceBaseImpl {
029
030 public DLSync addSync(
031 long fileId, long companyId, long repositoryId, long parentFolderId,
032 String type)
033 throws SystemException {
034
035 Date now = new Date();
036
037 long syncId = counterLocalService.increment();
038
039 DLSync dlSync = dlSyncPersistence.create(syncId);
040
041 dlSync.setCompanyId(companyId);
042 dlSync.setCreateDate(now);
043 dlSync.setModifiedDate(now);
044 dlSync.setFileId(fileId);
045 dlSync.setRepositoryId(repositoryId);
046 dlSync.setParentFolderId(parentFolderId);
047 dlSync.setEvent(DLSyncConstants.EVENT_ADD);
048 dlSync.setType(type);
049
050 dlSyncPersistence.update(dlSync, false);
051
052 return dlSync;
053 }
054
055 public DLSync updateSync(long fileId, long parentFolderId, String event)
056 throws PortalException, SystemException {
057
058 DLSync dlSync = null;
059
060 if (event == DLSyncConstants.EVENT_DELETE) {
061 dlSync = dlSyncPersistence.fetchByFileId(fileId);
062
063 if (dlSync == null) {
064 return null;
065 }
066 }
067 else {
068 dlSync = dlSyncPersistence.findByFileId(fileId);
069 }
070
071 dlSync.setModifiedDate(new Date());
072 dlSync.setParentFolderId(parentFolderId);
073 dlSync.setEvent(event);
074
075 dlSyncPersistence.update(dlSync, false);
076
077 return dlSync;
078 }
079
080 }