Package org.cyclos.impl.banking
Class TicketServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.banking.TicketServiceImpl
-
- All Implemented Interfaces:
TicketServiceLocal,TicketService,Service
@Service public class TicketServiceImpl extends BaseServiceImpl implements TicketServiceLocal
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description TicketServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TicketVOapprove(ApproveTicketDTO params)Approves a ticket, as a payer, only if status isTicketStatus.OPEN.
If there is no "success URL" defined then it generates a new direct payment and the ticket goes toTicketStatus.PROCESSED.SerializableInputStreambarcode(TicketBarcodeParams params)Generates a two-dimensional barcode (aka QR code) only if status isTicketStatus.OPENcontaining a URL of the form: .../pay/ticket_id (e.g https://www.cyclos.org/pay/1234567890123456789).voidcancel(TicketVO ticketVO)Cancels the ticket only if status isTicketStatus.OPENand the logged user is the ticket's receiver or a manger of him.intcancelAll(UserAccount account)Cancels all open tickets for the given accountvoidcheckExists(String ticketNumber, boolean mustBeOpen)Checks that a ticket with the given number exists, throwingEntityNotFoundExceptionif not.TicketVOcreate(CreateTicketDTO parameters)Creates a new ticket with statusTicketStatus.OPENfor the logged user (i.e setting it as the receiver).voidexpire(Ticket ticket)Expires the given ticketTicketfindByTicketNumber(String ticketNumber)Returns a ticket by ticket number, or throwsEntityNotFoundExceptionif not found.StringgetApproveUrl(Ticket ticket)Returns the URL used to approve the given ticket, or null if the ticket isn't open.CreateTicketDatagetCreateData(UserLocatorVO ownerVO, UserLocatorVO payerVO)Returns data used to crate a new ticket for the given user, optionally with a fixed payer.TicketDatagetData(Ticket ticket)Returns data for a ticketTicketDatagetData(TicketVO vo)Returns data to view the ticket's details.TicketPaymentTypeDatagetTicketPaymentTypeData(UserLocatorVO ownerVO, TransferTypeVO transferType)Returns the data for a specific payment type used to create a new ticketList<PaymentTransferType>listPossiblePaymentTypesForCreateTicket(User ownerOrNull, User payer)Based on the logged user's permissions over the given owner, returns the possible payment types for creating tickets, optionally to the given fixed payerApproveTicketPreviewVOpreviewApprove(TicketVO ticketVO)Previews the payment which would be performed when approving the given ticket as the payer.TicketProcessResultprocess(ProcessTicketDTO params)Processes a ticket as the receiver of the payment (i.e the ticket creator).
Only if the ticket status isTicketStatus.APPROVEDa new direct payment will be generated and the new ticket status will be:TicketStatus.PROCESSED.protected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the network-
Methods inherited from class org.cyclos.impl.BaseServiceImpl
initializeNetworkMappings
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Method Detail
-
approve
public TicketVO approve(ApproveTicketDTO params) throws FrameworkException, TransferException
Description copied from interface:TicketServiceApproves a ticket, as a payer, only if status isTicketStatus.OPEN.
If there is no "success URL" defined then it generates a new direct payment and the ticket goes toTicketStatus.PROCESSED. Otherwise, no payment is generated and the ticket goes toTicketStatus.APPROVEDstatus. The payment will be generated only after being processed by the receiver.- Specified by:
approvein interfaceTicketService- Throws:
FrameworkExceptionTransferException
-
barcode
public SerializableInputStream barcode(TicketBarcodeParams params) throws FrameworkException
Description copied from interface:TicketServiceGenerates a two-dimensional barcode (aka QR code) only if status isTicketStatus.OPENcontaining a URL of the form: .../pay/ticket_id (e.g https://www.cyclos.org/pay/1234567890123456789).- Specified by:
barcodein interfaceTicketService- Throws:
FrameworkException
-
cancel
public void cancel(TicketVO ticketVO) throws FrameworkException
Description copied from interface:TicketServiceCancels the ticket only if status isTicketStatus.OPENand the logged user is the ticket's receiver or a manger of him.- Specified by:
cancelin interfaceTicketService- Throws:
FrameworkException
-
cancelAll
public int cancelAll(UserAccount account)
Description copied from interface:TicketServiceLocalCancels all open tickets for the given account- Specified by:
cancelAllin interfaceTicketServiceLocal
-
checkExists
public void checkExists(String ticketNumber, boolean mustBeOpen)
Description copied from interface:TicketServiceLocalChecks that a ticket with the given number exists, throwingEntityNotFoundExceptionif not. Optionally only succeds if the ticket is open.- Specified by:
checkExistsin interfaceTicketServiceLocal
-
create
public TicketVO create(CreateTicketDTO parameters) throws FrameworkException
Description copied from interface:TicketServiceCreates a new ticket with statusTicketStatus.OPENfor the logged user (i.e setting it as the receiver).- Specified by:
createin interfaceTicketService- Throws:
FrameworkException
-
expire
public void expire(Ticket ticket)
Description copied from interface:TicketServiceLocalExpires the given ticket- Specified by:
expirein interfaceTicketServiceLocal
-
findByTicketNumber
public Ticket findByTicketNumber(String ticketNumber)
Description copied from interface:TicketServiceLocalReturns a ticket by ticket number, or throwsEntityNotFoundExceptionif not found.- Specified by:
findByTicketNumberin interfaceTicketServiceLocal
-
getApproveUrl
public String getApproveUrl(Ticket ticket)
Description copied from interface:TicketServiceLocalReturns the URL used to approve the given ticket, or null if the ticket isn't open.- Specified by:
getApproveUrlin interfaceTicketServiceLocal
-
getCreateData
public CreateTicketData getCreateData(UserLocatorVO ownerVO, UserLocatorVO payerVO) throws FrameworkException
Description copied from interface:TicketServiceReturns data used to crate a new ticket for the given user, optionally with a fixed payer.- Specified by:
getCreateDatain interfaceTicketService- Throws:
FrameworkException
-
getData
public TicketData getData(Ticket ticket) throws FrameworkException
Description copied from interface:TicketServiceLocalReturns data for a ticket- Specified by:
getDatain interfaceTicketServiceLocal- Throws:
FrameworkException
-
getData
public TicketData getData(TicketVO vo) throws FrameworkException
Description copied from interface:TicketServiceReturns data to view the ticket's details.- Specified by:
getDatain interfaceTicketService- Throws:
FrameworkException
-
getTicketPaymentTypeData
public TicketPaymentTypeData getTicketPaymentTypeData(UserLocatorVO ownerVO, TransferTypeVO transferType) throws FrameworkException
Description copied from interface:TicketServiceReturns the data for a specific payment type used to create a new ticket- Specified by:
getTicketPaymentTypeDatain interfaceTicketService- Throws:
FrameworkException
-
listPossiblePaymentTypesForCreateTicket
public List<PaymentTransferType> listPossiblePaymentTypesForCreateTicket(User ownerOrNull, User payer)
Description copied from interface:TicketServiceLocalBased on the logged user's permissions over the given owner, returns the possible payment types for creating tickets, optionally to the given fixed payer- Specified by:
listPossiblePaymentTypesForCreateTicketin interfaceTicketServiceLocal
-
previewApprove
public ApproveTicketPreviewVO previewApprove(TicketVO ticketVO) throws FrameworkException
Description copied from interface:TicketServicePreviews the payment which would be performed when approving the given ticket as the payer. The ticket status must beTicketStatus.APPROVEDorTicketStatus.OPENwithout a success url.- Specified by:
previewApprovein interfaceTicketService- Throws:
FrameworkException
-
process
public TicketProcessResult process(ProcessTicketDTO params) throws TransferException, FrameworkException
Description copied from interface:TicketServiceProcesses a ticket as the receiver of the payment (i.e the ticket creator).
Only if the ticket status isTicketStatus.APPROVEDa new direct payment will be generated and the new ticket status will be:TicketStatus.PROCESSED. There could be a case where this method is invoked for an already processed ticket (e.g. the ticket has both a success url and an success webhook), for it, only in case the given process code is the correct one this method runs without errors and returns the same result as the previous invocation (no payment is generated) but with theTicketProcessResult.ACTUALLY_PROCESSEDflag in false.- Specified by:
processin interfaceTicketService- Throws:
TransferExceptionFrameworkException
-
registerNetworkMappings
protected void registerNetworkMappings(NetworkPathRegistry networkPathRegistry)
Description copied from class:BaseServiceImplNeeds to be overridden by subclasses to register the path up to the network- Specified by:
registerNetworkMappingsin classBaseServiceImpl
-
-