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.kernel.uuid.PortalUUIDUtil;
020 import com.liferay.portal.model.Ticket;
021 import com.liferay.portal.service.ServiceContext;
022 import com.liferay.portal.service.base.TicketLocalServiceBaseImpl;
023 import com.liferay.portal.util.PortalUtil;
024
025 import java.util.Date;
026
027
030 public class TicketLocalServiceImpl extends TicketLocalServiceBaseImpl {
031
032 @Override
033 public Ticket addDistinctTicket(
034 long companyId, String className, long classPK, int type,
035 String extraInfo, Date expirationDate,
036 ServiceContext serviceContext)
037 throws SystemException {
038
039 long classNameId = classNameLocalService.getClassNameId(className);
040
041 ticketPersistence.removeByC_C_T(classNameId, classPK, type);
042
043 return addTicket(
044 companyId, className, classPK, type, extraInfo, expirationDate,
045 serviceContext);
046 }
047
048 @Override
049 public Ticket addTicket(
050 long companyId, String className, long classPK, int type,
051 String extraInfo, Date expirationDate,
052 ServiceContext serviceContext)
053 throws SystemException {
054
055 long classNameId = PortalUtil.getClassNameId(className);
056 Date now = new Date();
057
058 long ticketId = counterLocalService.increment();
059
060 Ticket ticket = ticketPersistence.create(ticketId);
061
062 ticket.setCompanyId(companyId);
063 ticket.setCreateDate(now);
064 ticket.setClassNameId(classNameId);
065 ticket.setClassPK(classPK);
066 ticket.setKey(PortalUUIDUtil.generate());
067 ticket.setType(type);
068 ticket.setExtraInfo(extraInfo);
069 ticket.setExpirationDate(expirationDate);
070
071 ticketPersistence.update(ticket);
072
073 return ticket;
074 }
075
076 @Override
077 public Ticket fetchTicket(String key) throws SystemException {
078 return ticketPersistence.fetchByKey(key);
079 }
080
081 @Override
082 public Ticket getTicket(String key)
083 throws PortalException, SystemException {
084
085 return ticketPersistence.findByKey(key);
086 }
087
088 }