001
014
015 package com.liferay.portal.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
019 import com.liferay.portal.model.Ticket;
020 import com.liferay.portal.service.ServiceContext;
021 import com.liferay.portal.service.base.TicketLocalServiceBaseImpl;
022
023 import java.util.Date;
024
025
028 public class TicketLocalServiceImpl extends TicketLocalServiceBaseImpl {
029
030 @Override
031 public Ticket addDistinctTicket(
032 long companyId, String className, long classPK, int type,
033 String extraInfo, Date expirationDate, ServiceContext serviceContext) {
034
035 long classNameId = classNameLocalService.getClassNameId(className);
036
037 ticketPersistence.removeByC_C_T(classNameId, classPK, type);
038
039 return addTicket(
040 companyId, className, classPK, type, extraInfo, expirationDate,
041 serviceContext);
042 }
043
044 @Override
045 public Ticket addTicket(
046 long companyId, String className, long classPK, int type,
047 String extraInfo, Date expirationDate, ServiceContext serviceContext) {
048
049 long classNameId = classNameLocalService.getClassNameId(className);
050
051 long ticketId = counterLocalService.increment();
052
053 Ticket ticket = ticketPersistence.create(ticketId);
054
055 ticket.setCompanyId(companyId);
056 ticket.setCreateDate(new Date());
057 ticket.setClassNameId(classNameId);
058 ticket.setClassPK(classPK);
059 ticket.setKey(PortalUUIDUtil.generate());
060 ticket.setType(type);
061 ticket.setExtraInfo(extraInfo);
062 ticket.setExpirationDate(expirationDate);
063
064 ticketPersistence.update(ticket);
065
066 return ticket;
067 }
068
069 @Override
070 public Ticket fetchTicket(String key) {
071 return ticketPersistence.fetchByKey(key);
072 }
073
074 @Override
075 public Ticket getTicket(String key) throws PortalException {
076 return ticketPersistence.findByKey(key);
077 }
078
079 }