Class AgendaCalendarLinkRest

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

@RestController public class AgendaCalendarLinkRest extends Object
Manages the private iCal link of a calendar, and serves the document that link publishes.

The feed is the one handler of this WAR reachable without a session. The portal's security chain lets any request, anonymous included, through to /rest/ and leaves the decision to method security; every other handler carries @Secured("users"), the feed deliberately none — its token is its credential. AgendaRestSecurityTest pins that it stays the only one.

No rule lives here. Who may manage a link and when a link answers are AgendaCalendarLinkService's; this resource maps its exceptions to statuses and renders its answers. The asking user comes from the session, never from a parameter.

A refusal writes its own body, {"message": "<code>"}, never cached — the drawer translates the code; see refusal(org.springframework.http.HttpStatus, java.lang.String).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Extension of the feed URL: many calendar applications expect it.
    static final String
    Path of the feed under the WAR's REST root, token and extension appended.
    static final String
    The kind of a calendar a user owns.
    static final String
    The kind of a calendar a space owns.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AgendaCalendarLinkRest(org.exoplatform.agenda.service.AgendaCalendarLinkService calendarLinkService, org.exoplatform.agenda.service.AgendaCalendarService agendaCalendarService, org.exoplatform.social.core.manager.IdentityManager identityManager)
    Builds the resource.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<?>
    deleteCalendarLink(jakarta.servlet.http.HttpServletRequest request, long calendarId)
    Deletes the link of a calendar.
    org.springframework.http.ResponseEntity<byte[]>
    Serves the calendar a link publishes, to a calendar application with no eXo session.
    org.springframework.http.ResponseEntity<?>
    getCalendarLink(jakarta.servlet.http.HttpServletRequest request, long calendarId)
    Tells whether a calendar has a link, who created it, when, whether it still answers, and — while it answers and can be displayed — its URL.
    org.springframework.http.ResponseEntity<?>
    getCalendarLinks(jakarta.servlet.http.HttpServletRequest request)
    Lists the link of every calendar the user may manage one for and that has one, working or stopped — so a page draws every calendar's publishing state with one request.
    org.springframework.http.ResponseEntity<?>
    saveCalendarLink(jakarta.servlet.http.HttpServletRequest request, long calendarId)
    Creates the link of a calendar, replacing the one it has: the previous URL stops answering at once.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • AgendaCalendarLinkRest

      @Autowired public AgendaCalendarLinkRest(org.exoplatform.agenda.service.AgendaCalendarLinkService calendarLinkService, org.exoplatform.agenda.service.AgendaCalendarService agendaCalendarService, org.exoplatform.social.core.manager.IdentityManager identityManager)
      Builds the resource.
      Parameters:
      calendarLinkService - holder of every calendar link rule
      agendaCalendarService - reads the calendars a listing names
      identityManager - used to name the creator of a link and the owner of a calendar
  • Method Details

    • getCalendarLinks

      @GetMapping("calendars/links") @Secured("users") public org.springframework.http.ResponseEntity<?> getCalendarLinks(jakarta.servlet.http.HttpServletRequest request)
      Lists the link of every calendar the user may manage one for and that has one, working or stopped — so a page draws every calendar's publishing state with one request. Never cached: an entry can carry a working capability URL.
      Parameters:
      request - the authenticated request
      Returns:
      the links, each with its calendar's title and kind
    • getCalendarLink

      @GetMapping("calendars/{calendarId}/link") @Secured("users") public org.springframework.http.ResponseEntity<?> getCalendarLink(jakarta.servlet.http.HttpServletRequest request, @PathVariable("calendarId") long calendarId)
      Tells whether a calendar has a link, who created it, when, whether it still answers, and — while it answers and can be displayed — its URL. Only someone allowed to manage the link gets an answer at all, and the answer is never cached: its body can carry a working capability URL, and the portal's security chain writes no cache header of its own.
      Parameters:
      request - the authenticated request
      calendarId - technical identifier of the calendar
      Returns:
      the status of the calendar's link
    • saveCalendarLink

      @PostMapping("calendars/{calendarId}/link") @Secured("users") public org.springframework.http.ResponseEntity<?> saveCalendarLink(jakarta.servlet.http.HttpServletRequest request, @PathVariable("calendarId") long calendarId)
      Creates the link of a calendar, replacing the one it has: the previous URL stops answering at once. The answer carries the new URL, and is never cached.
      Parameters:
      request - the authenticated request
      calendarId - technical identifier of the calendar
      Returns:
      the status of the new link, with its URL
    • deleteCalendarLink

      @DeleteMapping("calendars/{calendarId}/link") @Secured("users") public org.springframework.http.ResponseEntity<?> deleteCalendarLink(jakarta.servlet.http.HttpServletRequest request, @PathVariable("calendarId") long calendarId)
      Deletes the link of a calendar.
      Parameters:
      request - the authenticated request
      calendarId - technical identifier of the calendar
      Returns:
      no content
    • getCalendarFeed

      @GetMapping("ical/{token}.ics") public org.springframework.http.ResponseEntity<byte[]> getCalendarFeed(@PathVariable("token") String token)
      Serves the calendar a link publishes, to a calendar application with no eXo session. Deliberately not @Secured: the token is the credential.

      Every link that opens nothing — unknown, replaced, deleted, or whose creator lost their right — gets the same bodiless 404. The token never reaches a log line or a response.

      The 304 is Spring MVC's, not this method's: for a GET answering an ETag, HttpEntityMethodProcessor compares it with the request's If-None-Match and drops the body itself. AgendaCalendarLinkRestTest pins the behaviour through the dispatcher.

      Parameters:
      token - the token presented in the URL
      Returns:
      the iCalendar document, or a 404