Class AgendaCalendarSubscriptionRest

java.lang.Object
org.exoplatform.agenda.rest.AgendaCalendarSubscriptionRest

@RestController public class AgendaCalendarSubscriptionRest extends Object
Manages the user's subscriptions to calendar links (EXO-90278).

No rule lives here. Who may read or change a subscription, which links may be read and what is imported are AgendaCalendarSubscriptionService's; this resource maps its exceptions to statuses: 404 for a subscription that does not exist, 403 for one that is not the user's, 400 with the refusal's message code, 429 for a refresh asked a moment ago or too many reads at once, and 409 for a refresh already running. The asking user comes from the session, never from a parameter. Responses carry URLs, which may embed a secret, and are never cached.

A refusal writes its own body, {"message": "<code>"}: it is not left to Spring's error page, whose message the platform does not include (server.error.include-message is no longer bound by Spring Boot 4), so the drawer would only ever see a generic error.

  • Constructor Summary

    Constructors
    Constructor
    Description
    AgendaCalendarSubscriptionRest(org.exoplatform.agenda.service.AgendaCalendarSubscriptionService subscriptionService)
    Builds the resource.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<Map<String,String>>
    checkUrl(jakarta.servlet.http.HttpServletRequest request, CalendarSubscriptionRequestEntity body)
    Checks that a link can be subscribed to, and answers the calendar's own name.
    org.springframework.http.ResponseEntity<?>
    createSubscription(jakarta.servlet.http.HttpServletRequest request, CalendarSubscriptionRequestEntity body)
    Subscribes the user to a link.
    org.springframework.http.ResponseEntity<?>
    deleteSubscription(jakarta.servlet.http.HttpServletRequest request, long subscriptionId)
    Unsubscribes: removes the subscription, its calendar and its events.
    org.springframework.http.ResponseEntity<?>
    getSubscriptions(jakarta.servlet.http.HttpServletRequest request)
    Lists the user's subscriptions.
    org.springframework.http.ResponseEntity<?>
    refreshSubscription(jakarta.servlet.http.HttpServletRequest request, long subscriptionId)
    Refreshes a subscription now.
    org.springframework.http.ResponseEntity<?>
    updateSubscription(jakarta.servlet.http.HttpServletRequest request, long subscriptionId, CalendarSubscriptionRequestEntity body)
    Changes the name, the colour or the link of a subscription.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AgendaCalendarSubscriptionRest

      @Autowired public AgendaCalendarSubscriptionRest(org.exoplatform.agenda.service.AgendaCalendarSubscriptionService subscriptionService)
      Builds the resource.
      Parameters:
      subscriptionService - holder of every subscription rule
  • Method Details

    • getSubscriptions

      @GetMapping("calendars/subscriptions") @Secured("users") public org.springframework.http.ResponseEntity<?> getSubscriptions(jakarta.servlet.http.HttpServletRequest request)
      Lists the user's subscriptions.
      Parameters:
      request - the request
      Returns:
      the subscriptions
    • checkUrl

      @PostMapping("calendars/subscriptions/check") @Secured("users") public org.springframework.http.ResponseEntity<Map<String,String>> checkUrl(jakarta.servlet.http.HttpServletRequest request, @RequestBody CalendarSubscriptionRequestEntity body)
      Checks that a link can be subscribed to, and answers the calendar's own name.
      Parameters:
      request - the request
      body - the link
      Returns:
      {"name": ...}, the name null when the calendar names none
    • createSubscription

      @PostMapping("calendars/subscriptions") @Secured("users") public org.springframework.http.ResponseEntity<?> createSubscription(jakarta.servlet.http.HttpServletRequest request, @RequestBody CalendarSubscriptionRequestEntity body)
      Subscribes the user to a link.
      Parameters:
      request - the request
      body - the link, the name and the colour
      Returns:
      the subscription
    • updateSubscription

      @PutMapping("calendars/subscriptions/{subscriptionId}") @Secured("users") public org.springframework.http.ResponseEntity<?> updateSubscription(jakarta.servlet.http.HttpServletRequest request, @PathVariable("subscriptionId") long subscriptionId, @RequestBody CalendarSubscriptionRequestEntity body)
      Changes the name, the colour or the link of a subscription.
      Parameters:
      request - the request
      subscriptionId - technical identifier of the subscription
      body - the fields to change, blank ones kept
      Returns:
      the subscription as it now stands
    • refreshSubscription

      @PostMapping("calendars/subscriptions/{subscriptionId}/refresh") @Secured("users") public org.springframework.http.ResponseEntity<?> refreshSubscription(jakarta.servlet.http.HttpServletRequest request, @PathVariable("subscriptionId") long subscriptionId)
      Refreshes a subscription now.
      Parameters:
      request - the request
      subscriptionId - technical identifier of the subscription
      Returns:
      the subscription after the refresh, a failure recorded on it
    • deleteSubscription

      @DeleteMapping("calendars/subscriptions/{subscriptionId}") @Secured("users") public org.springframework.http.ResponseEntity<?> deleteSubscription(jakarta.servlet.http.HttpServletRequest request, @PathVariable("subscriptionId") long subscriptionId)
      Unsubscribes: removes the subscription, its calendar and its events.
      Parameters:
      request - the request
      subscriptionId - technical identifier of the subscription
      Returns:
      no content