Example usage for com.liferay.portal.kernel.exception NoSuchTicketException NoSuchTicketException

List of usage examples for com.liferay.portal.kernel.exception NoSuchTicketException NoSuchTicketException

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.exception NoSuchTicketException NoSuchTicketException.

Prototype

public NoSuchTicketException(Throwable cause) 

Source Link

Usage

From source file:com.liferay.subscription.web.internal.portlet.action.UnsubscribeMVCActionCommand.java

License:Open Source License

private Ticket _getTicket(String key) throws PortalException {
    Ticket ticket = _ticketLocalService.getTicket(key);

    if (ticket.getType() != SubscriptionConstants.TICKET_TYPE) {
        throw new NoSuchTicketException("Invalid type " + ticket.getType());
    }/*from ww w  .ja v  a  2  s  . co m*/

    String className = ticket.getClassName();

    if (!className.equals(Subscription.class.getName())) {
        throw new NoSuchTicketException("Invalid className " + className);
    }

    return ticket;
}

From source file:com.liferay.subscription.web.internal.portlet.action.UnsubscribeMVCActionCommand.java

License:Open Source License

private Subscription _unsubscribe(String key, long userId) throws PortalException {

    Ticket ticket = _getTicket(key);/*from  www.j  a v  a  2  s  . c  o  m*/

    long subscriptionId = ticket.getClassPK();

    if (ticket.isExpired()) {
        _ticketLocalService.deleteTicket(ticket);

        throw new NoSuchTicketException("{ticketKey=" + key + "}");
    }

    Subscription subscription = _subscriptionLocalService.getSubscription(subscriptionId);

    _checkUser(userId, subscription);

    _subscriptionLocalService.deleteSubscription(subscription);

    return subscription;
}