Class RWClientImpl

All Implemented Interfaces:
Serializable, Client, RWClient, org.bedework.util.logging.Logged

public class RWClientImpl extends ROClientImpl implements RWClient
User: douglm Date: 6/27/13 Time: 2:05 PM
See Also:
  • Field Details

    • defaultFilterContextSet

      protected boolean defaultFilterContextSet
    • defaultFilterContext

      protected org.bedework.caldav.util.filter.FilterBase defaultFilterContext
  • Constructor Details

  • Method Details

    • reinit

      public void reinit(String authUser, String runAsUser, String appType)
    • copy

      public Client copy(String id)
      Specified by:
      copy in interface Client
      Overrides:
      copy in class ROClientImpl
    • getWebUser

      public boolean getWebUser()
      Specified by:
      getWebUser in interface RWClient
      Returns:
      true if we are the web user client.
    • unindex

      public void unindex(String href)
      Specified by:
      unindex in interface RWClient
      Parameters:
      href - to be unindexed
    • isGuest

      public boolean isGuest()
      Specified by:
      isGuest in interface Client
      Overrides:
      isGuest in class ROClientImpl
    • getOwner

      public org.bedework.calfacade.BwPrincipal<?> getOwner()
      Specified by:
      getOwner in interface Client
      Overrides:
      getOwner in class ROClientImpl
    • updatePreferences

      public void updatePreferences(org.bedework.calfacade.svc.BwPreferences val)
      Specified by:
      updatePreferences in interface Client
      Overrides:
      updatePreferences in class ROClientImpl
    • getCollection

      public org.bedework.calfacade.BwCalendar getCollection(String path)
      Specified by:
      getCollection in interface Client
      Overrides:
      getCollection in class ROClientImpl
    • addCollection

      public org.bedework.calfacade.BwCalendar addCollection(org.bedework.calfacade.BwCalendar val, String parentPath)
      Description copied from interface: RWClient
      Add a calendar collection

      The new collection object will be added to the db. If the indicated parent is null it will be added as a root level collection.

      Certain restrictions apply, mostly because of interoperability issues. A collection cannot be added to another collection which already contains entities, e.g. events etc.

      Names cannot contain certain characters - (complete this)

      Name must be unique at this level, i.e. all paths must be unique

      Specified by:
      addCollection in interface RWClient
      Parameters:
      val - BwCalendar new object
      parentPath - String path to parent.
      Returns:
      BwCalendar object as added. Parameter val MUST be discarded
    • updateCollection

      public void updateCollection(org.bedework.calfacade.BwCalendar col)
      Description copied from interface: RWClient
      Update the given collection
      Specified by:
      updateCollection in interface RWClient
      Parameters:
      col - the collection
    • deleteCollection

      public boolean deleteCollection(org.bedework.calfacade.BwCalendar val, boolean emptyIt)
      Description copied from interface: RWClient
      Delete a collection. Also remove it from the current user preferences (if any).
      Specified by:
      deleteCollection in interface RWClient
      Parameters:
      val - BwCalendar collection
      emptyIt - true to delete contents
      Returns:
      boolean true if it was deleted. false if it didn't exist
    • moveCollection

      public void moveCollection(org.bedework.calfacade.BwCalendar val, org.bedework.calfacade.BwCalendar newParent)
      Description copied from interface: RWClient
      Move a calendar object from one parent to another
      Specified by:
      moveCollection in interface RWClient
      Parameters:
      val - BwCalendar object
      newParent - BwCalendar potential parent
    • refreshSubscription

      public org.bedework.base.response.Response refreshSubscription(org.bedework.calfacade.BwCalendar val)
      Description copied from interface: RWClient
      Refresh a subscription represented by this calendar object
      Specified by:
      refreshSubscription in interface RWClient
      Parameters:
      val - BwCalendar object
    • getAddContentCollections

      public Collection<org.bedework.calfacade.BwCalendar> getAddContentCollections()
      Description copied from interface: RWClient
      Return a list of calendars in which calendar objects can be placed by the current user.

      Caldav does not allow collections inside collections so that calendar collections are the leaf nodes only.

      Specified by:
      getAddContentCollections in interface RWClient
      Returns:
      Set of BwCalendar
    • getPersistentCategory

      public org.bedework.calfacade.BwCategory getPersistentCategory(String uid)
      Specified by:
      getPersistentCategory in interface RWClient
      Parameters:
      uid - of the category
      Returns:
      category entity or null.
    • addCategory

      public boolean addCategory(org.bedework.calfacade.BwCategory val)
      Description copied from interface: RWClient
      Add the given category.
      Specified by:
      addCategory in interface RWClient
      Parameters:
      val - category
      Returns:
      false if not added because already exists
    • updateCategory

      public void updateCategory(org.bedework.calfacade.BwCategory val)
      Description copied from interface: RWClient
      Update a category.
      Specified by:
      updateCategory in interface RWClient
      Parameters:
      val - category object to be updated
    • deleteCategory

      public RWClient.DeleteReffedEntityResult deleteCategory(org.bedework.calfacade.BwCategory val)
      Description copied from interface: RWClient
      Delete a category
      Specified by:
      deleteCategory in interface RWClient
      Parameters:
      val - BwEventProperty object to be deleted
      Returns:
      result indicating what happened - null for not there
    • getPersistentContact

      public org.bedework.calfacade.BwContact getPersistentContact(String uid)
      Description copied from interface: RWClient
      Get the contact with the given uid.
      Specified by:
      getPersistentContact in interface RWClient
      Parameters:
      uid - of contact
      Returns:
      contact object
    • addContact

      public void addContact(org.bedework.calfacade.BwContact val)
      Description copied from interface: RWClient
      Add the contact
      Specified by:
      addContact in interface RWClient
      Parameters:
      val - contact
    • updateContact

      public void updateContact(org.bedework.calfacade.BwContact val)
      Description copied from interface: RWClient
      Update the contact
      Specified by:
      updateContact in interface RWClient
      Parameters:
      val - contact
    • deleteContact

      public RWClient.DeleteReffedEntityResult deleteContact(org.bedework.calfacade.BwContact val)
      Description copied from interface: RWClient
      Delete a contact
      Specified by:
      deleteContact in interface RWClient
      Parameters:
      val - contact to be deleted
      Returns:
      result indicating what happened - null for not there
    • ensureContactExists

      public org.bedework.calfacade.svc.EnsureEntityExistsResult<org.bedework.calfacade.BwContact> ensureContactExists(org.bedework.calfacade.BwContact val, String ownerHref)
      Description copied from interface: RWClient
      Ensure a contact exists. If it already does returns the object. If not creates the entity.
      Specified by:
      ensureContactExists in interface RWClient
      Parameters:
      val - contact object.
      ownerHref - String principal href, null for current user
      Returns:
      response object.
    • getPersistentLocation

      public org.bedework.calfacade.BwLocation getPersistentLocation(String uid)
      Description copied from interface: RWClient
      Get the location with the given uid.
      Specified by:
      getPersistentLocation in interface RWClient
      Parameters:
      uid - of location
      Returns:
      Location object
    • addLocation

      public boolean addLocation(org.bedework.calfacade.BwLocation val)
      Description copied from interface: RWClient
      Add the location
      Specified by:
      addLocation in interface RWClient
      Parameters:
      val - a location
      Returns:
      true if added
    • updateLocation

      public void updateLocation(org.bedework.calfacade.BwLocation val)
      Description copied from interface: RWClient
      Update the location
      Specified by:
      updateLocation in interface RWClient
      Parameters:
      val - a location
    • deleteLocation

      public RWClient.DeleteReffedEntityResult deleteLocation(org.bedework.calfacade.BwLocation val)
      Description copied from interface: RWClient
      Delete a location
      Specified by:
      deleteLocation in interface RWClient
      Parameters:
      val - location to be deleted
      Returns:
      result indicating what happened - null for not there
    • ensureLocationExists

      public org.bedework.calfacade.svc.EnsureEntityExistsResult<org.bedework.calfacade.BwLocation> ensureLocationExists(org.bedework.calfacade.BwLocation val, String ownerHref)
      Description copied from interface: RWClient
      Ensure a location exists. If it already does returns the object. If not creates the entity.
      Specified by:
      ensureLocationExists in interface RWClient
      Parameters:
      val - location object.
      ownerHref - String principal href, null for current user
      Returns:
      response object.
    • claimEvent

      public void claimEvent(org.bedework.calfacade.BwEvent ev)
      Description copied from interface: RWClient
      Claim ownership of this event
      Specified by:
      claimEvent in interface RWClient
      Parameters:
      ev - event
    • reAlias

      public org.bedework.calfacade.svc.RealiasResult reAlias(org.bedework.calfacade.BwEvent ev)
      Description copied from interface: RWClient
      Realias the event - set categories according to the set of aliases
      Specified by:
      reAlias in interface RWClient
      Parameters:
      ev - event
      Returns:
      set of categories referenced by the aliases
    • addEvent

      public org.bedework.calfacade.svc.EventInfo.UpdateResult addEvent(org.bedework.calfacade.svc.EventInfo ei, boolean noInvites, boolean rollbackOnError)
      Description copied from interface: RWClient
      Add an event and ensure its location and contact exist. The calendar path must be set in the event.

      For public events some calendar implementors choose to allow the dynamic creation of locations and contacts. For each of those, if we have an id, then the object represents a preexisting database item.

      Otherwise the client has provided information which will be used to locate an already existing location or contact. Failing that we use the information to create a new entry.

      For user clients, we generally assume no contact and the location is optional. However, both conditions are enforced at the application level.

      On return the event object will have been updated. In addition the location and contact may have been updated.

      If this is a scheduling event and noInvites is set to false then invitations wil be sent out to the attendees.

      The event to be added may be a reference to another event. In this case a number of fields should have been copied from that event. Other fields will come from the target.

      Specified by:
      addEvent in interface RWClient
      Parameters:
      ei - EventInfo object to be added
      noInvites - True for don't send invitations.
      rollbackOnError - rollback transaction if true
      Returns:
      UpdateResult Counts of changes.
    • updateEvent

      public org.bedework.calfacade.svc.EventInfo.UpdateResult updateEvent(org.bedework.calfacade.svc.EventInfo ei, boolean noInvites, String fromAttUri, boolean alwaysWrite)
      Description copied from interface: RWClient
      Update an event in response to an attendee. Exactly as normal update if fromAtt is null. Otherwise no status update is sent to the given attendee

      Any changeset should be embedded in the event info object.

      Specified by:
      updateEvent in interface RWClient
      Parameters:
      ei - EventInfo object to be added
      noInvites - True for don't send invitations.
      fromAttUri - attendee responding
      alwaysWrite - write and reindex whatever changetable says
      Returns:
      UpdateResult Counts of changes.
    • moveEvent

      public org.bedework.base.response.Response moveEvent(org.bedework.calfacade.svc.EventInfo ei, String newPath)
      Description copied from interface: RWClient
      Move the event to the collection specified in newPath. There must be no event with the same uid in the destination.
      Specified by:
      moveEvent in interface RWClient
      Parameters:
      ei - EventInfo object to be moved
      newPath - Destination collection.
      Returns:
      UpdateResult status.
    • deleteEvent

      public org.bedework.base.response.Response deleteEvent(org.bedework.calfacade.svc.EventInfo ei, boolean sendSchedulingMessage)
      Description copied from interface: RWClient
      Delete an event.
      Specified by:
      deleteEvent in interface RWClient
      Parameters:
      ei - BwEvent object to be deleted
      sendSchedulingMessage - Send a declined or cancel scheduling message
      Returns:
      Response with status ok if event deleted
    • markDeleted

      public void markDeleted(org.bedework.calfacade.BwEvent event)
      Description copied from interface: RWClient
      For an event to which we have write access we simply mark it deleted.

      Otherwise we add an annotation maarking the event as deleted.

      Specified by:
      markDeleted in interface RWClient
      Parameters:
      event - to delete
    • findNotification

      public org.bedework.caldav.util.notifications.NotificationType findNotification(String name)
      Description copied from interface: RWClient
      Find a notification in the notification collection for the current principal with the given name.
      Specified by:
      findNotification in interface RWClient
      Parameters:
      name - - of the notification
      Returns:
      null for no notification or the notification with that name
    • removeNotification

      public void removeNotification(String name)
      Description copied from interface: RWClient
      Remove the given notification from the notification collection for the current calendar user.
      Specified by:
      removeNotification in interface RWClient
      Parameters:
      name - of notification to remove
    • removeNotification

      public void removeNotification(org.bedework.caldav.util.notifications.NotificationType val)
      Description copied from interface: RWClient
      Remove the given notification from the notification collection for the current calendar user.
      Specified by:
      removeNotification in interface RWClient
      Parameters:
      val - notification to remove
    • removeAllNotifications

      public void removeAllNotifications(String principalHref)
      Description copied from interface: RWClient
      Remove all notifications for given principal
      Specified by:
      removeAllNotifications in interface RWClient
      Parameters:
      principalHref - principal to clean
    • subscribe

      public void subscribe(String principalHref, List<String> emails)
      Specified by:
      subscribe in interface RWClient
    • unsubscribe

      public void unsubscribe(String principalHref, List<String> emails)
      Specified by:
      unsubscribe in interface RWClient
    • getResource

      public org.bedework.calfacade.BwResource getResource(String path)
      Description copied from interface: RWClient
      Get a resource given the path - does not getResource content
      Specified by:
      getResource in interface RWClient
      Parameters:
      path - String path to resource
      Returns:
      BwResource null for unknown resource
    • getResourceContent

      public boolean getResourceContent(org.bedework.calfacade.BwResource val)
      Description copied from interface: RWClient
      Retrieve resource content given the resource. It will be set in the resource object
      Specified by:
      getResourceContent in interface RWClient
      Parameters:
      val - BwResource
      Returns:
      false if content missing
    • getAllResources

      public List<org.bedework.calfacade.BwResource> getAllResources(String path)
      Description copied from interface: RWClient
      Get resources to which this user has access - content is not fetched.
      Specified by:
      getAllResources in interface RWClient
      Parameters:
      path - String path to containing collection
      Returns:
      List of BwResource
    • getResources

      public List<org.bedework.calfacade.BwResource> getResources(String path, int count)
      Description copied from interface: RWClient
      Get resources to which this user has access - content is not fetched.
      Specified by:
      getResources in interface RWClient
      Parameters:
      path - String path to containing collection
      count - this many
      Returns:
      List of BwResource
    • saveResource

      public void saveResource(org.bedework.calfacade.BwResource val)
      Description copied from interface: RWClient
      Save a resource at the given collection path. The collection MUST exist.
      Specified by:
      saveResource in interface RWClient
      Parameters:
      val - resource with attached content
    • updateResource

      public void updateResource(org.bedework.calfacade.BwResource val, boolean updateContent)
      Description copied from interface: RWClient
      Update a resource.
      Specified by:
      updateResource in interface RWClient
      Parameters:
      val - resource
      updateContent - if true we also update the content
    • setResourceValue

      public void setResourceValue(org.bedework.calfacade.BwResource val, String content)
      Specified by:
      setResourceValue in interface RWClient
      Parameters:
      val - the resource object
      content - to embed
    • setResourceValue

      public void setResourceValue(org.bedework.calfacade.BwResource val, byte[] content)
      Specified by:
      setResourceValue in interface RWClient
      Parameters:
      val - the resource object
      content - to embed
    • setResourceValue

      public void setResourceValue(org.bedework.calfacade.BwResource val, InputStream content, long length)
      Specified by:
      setResourceValue in interface RWClient
      Parameters:
      val - the resource object
      content - input stream with content
    • findUserAttendee

      public org.bedework.calfacade.Participant findUserAttendee(org.bedework.calfacade.svc.EventInfo ei)
      Description copied from interface: RWClient
      Find the attendee in this event which corresponds to the current user
      Specified by:
      findUserAttendee in interface RWClient
      Parameters:
      ei - to search
      Returns:
      attendee or null.
    • getFreeBusy

      public org.bedework.calfacade.BwEvent getFreeBusy(Collection<org.bedework.calfacade.BwCalendar> fbset, org.bedework.calfacade.BwPrincipal<?> who, org.bedework.calfacade.BwDateTime start, org.bedework.calfacade.BwDateTime end, org.bedework.calfacade.BwOrganizer org, String uid, String exceptUid)
      Description copied from interface: RWClient
      Get the free busy for the given principal as a list of busy periods.
      Specified by:
      getFreeBusy in interface RWClient
      Parameters:
      fbset - Collections for which to provide free-busy. Null for the for default collection (as specified by user). Used for local access to a given calendar via e.g. caldav
      who - If cal is null getResource the info for this user, otherwise this is used as the free/busy result owner
      start - of freebusy period
      end - of freebusy period
      org - - needed to make the result compliant
      uid - - uid of requesting component or null for no request
      exceptUid - if non-null omit this uid from the freebusy calculation
      Returns:
      BwEvent
    • aggregateFreeBusy

      public org.bedework.calsvci.SchedulingI.FbResponses aggregateFreeBusy(org.bedework.calfacade.ScheduleResult sr, org.bedework.calfacade.BwDateTime start, org.bedework.calfacade.BwDateTime end, org.bedework.calfacade.BwDuration granularity)
      Description copied from interface: RWClient
      Get aggregated free busy for a ScheduleResult.
      Specified by:
      aggregateFreeBusy in interface RWClient
      Parameters:
      sr - ScheduleResult
      start - of period
      end - of period
      granularity - of result - eg 1 hour
      Returns:
      FbResponses
    • schedule

      public org.bedework.calfacade.ScheduleResult schedule(org.bedework.calfacade.svc.EventInfo ei, String recipient, String fromAttUri, boolean iSchedule)
      Description copied from interface: RWClient
      Schedule a meeting or publish an event. The event object must have the organizer and attendees and possibly recipients set according to itip + caldav.

      The event will be added to the users outbox which will trigger the send of requests to other users inboxes. For users within this system the request will be immediately addded to the recipients inbox. For external users they are sent via ischedule or mail.

      Specified by:
      schedule in interface RWClient
      Parameters:
      ei - EventInfo object containing with method=REQUEST, CANCEL, ADD, DECLINECOUNTER or PUBLISH
      recipient - - non null to send to this recipient only (for REFRESH)
      fromAttUri - - identifies the attendee
      iSchedule - true if it's an iSchedule request.
      Returns:
      ScheduleResult
    • getStoredMeeting

      public org.bedework.calfacade.svc.EventInfo getStoredMeeting(org.bedework.calfacade.BwEvent ev)
      Description copied from interface: RWClient
      Return the users copy of the active meeting with the same uid as that given.
      Specified by:
      getStoredMeeting in interface RWClient
      Parameters:
      ev - the event to search for
      Returns:
      possibly null meeting
    • requestRefresh

      public org.bedework.calfacade.ScheduleResult requestRefresh(org.bedework.calfacade.svc.EventInfo ei, String comment)
      Description copied from interface: RWClient
      Attendee wants a refresh
      Specified by:
      requestRefresh in interface RWClient
      Parameters:
      ei - event which is probably in a calendar.
      comment - - optional comment
      Returns:
      ScheduleResult
    • share

      public org.bedework.caldav.util.sharing.ShareResultType share(String principalHref, org.bedework.calfacade.BwCalendar col, org.bedework.caldav.util.sharing.ShareType share)
      Specified by:
      share in interface RWClient
      Parameters:
      principalHref - share as this user.
      col - MUST be a sharable collection
      share - the request
      Returns:
      list of ok and !ok sharees
    • publish

      public void publish(org.bedework.calfacade.BwCalendar col)
      Description copied from interface: RWClient
      Publish the collection - that is make it available for subscriptions.
      Specified by:
      publish in interface RWClient
      Parameters:
      col - collection object
    • unpublish

      public void unpublish(org.bedework.calfacade.BwCalendar col)
      Description copied from interface: RWClient
      Unpublish the collection - that is make it unavailable for subscriptions and remove any existing subscriptions.
      Specified by:
      unpublish in interface RWClient
      Parameters:
      col - collection object
    • sharingReply

      public org.bedework.calfacade.svc.SharingReplyResult sharingReply(org.bedework.caldav.util.sharing.InviteReplyType reply)
      Specified by:
      sharingReply in interface RWClient
      Parameters:
      reply - the request
      Returns:
      a ReplyResult object.
    • subscribe

      public org.bedework.calfacade.svc.SubscribeResult subscribe(String colPath, String subscribedName)
      Description copied from interface: RWClient
      Subscribe to the collection - must be a published collection.
      Specified by:
      subscribe in interface RWClient
      Parameters:
      colPath - collection path
      subscribedName - name for new alias
      Returns:
      path of new alias and flag
    • subscribeExternal

      public org.bedework.calfacade.svc.SubscribeResult subscribeExternal(String extUrl, String subscribedName, int refresh, String remoteId, String remotePw)
      Description copied from interface: RWClient
      Subscribe to an external url.
      Specified by:
      subscribeExternal in interface RWClient
      Parameters:
      extUrl - the url
      subscribedName - name for new alias
      refresh - - refresh rate in minutes <= 0 for default
      remoteId - - may be null
      remotePw - - may be null
      Returns:
      path of new alias and flag
    • getSynchInfo

      public org.bedework.calfacade.synch.BwSynchInfo getSynchInfo()
      Description copied from interface: RWClient
      Returns the synch service information.
      Specified by:
      getSynchInfo in interface RWClient
      Returns:
      full synch info
    • addView

      public boolean addView(org.bedework.calfacade.svc.BwView val, boolean makeDefault)
      Description copied from interface: RWClient
      Add a view.
      Specified by:
      addView in interface RWClient
      Parameters:
      val - BwView to add
      makeDefault - boolean true for make this the default.
      Returns:
      boolean false view not added, true - added.
    • addViewCollection

      public boolean addViewCollection(String name, String path)
      Description copied from interface: RWClient
      Add a collection path to the named view.
      Specified by:
      addViewCollection in interface RWClient
      Parameters:
      name - String view name - null means default
      path - collection path to add
      Returns:
      boolean false view not found, true - collection path added.
    • removeViewCollection

      public boolean removeViewCollection(String name, String path)
      Description copied from interface: RWClient
      Remove a collection path from the named view.
      Specified by:
      removeViewCollection in interface RWClient
      Parameters:
      name - String view name - null means default
      path - collection path to remove
      Returns:
      boolean false view not found, true - collection path removed.
    • removeView

      public boolean removeView(org.bedework.calfacade.svc.BwView val)
      Description copied from interface: RWClient
      Remove the view for the owner of the object.
      Specified by:
      removeView in interface RWClient
      Parameters:
      val - BwView
      Returns:
      boolean false - view not found.
    • moveContents

      public void moveContents(org.bedework.calfacade.BwCalendar cal, org.bedework.calfacade.BwCalendar newCal)
      Description copied from interface: RWClient
      Move the contents of one collection to another
      Specified by:
      moveContents in interface RWClient
      Parameters:
      cal - where from
      newCal - where to
    • postMessage

      public void postMessage(org.bedework.calfacade.mail.Message val)
      Specified by:
      postMessage in interface RWClient
      Parameters:
      val - mail message
    • changeAccess

      public void changeAccess(org.bedework.calfacade.base.ShareableEntity ent, Collection<org.bedework.access.Ace> aces, boolean replaceAll)
      Description copied from interface: RWClient
      Change the access to the given calendar entity.
      Specified by:
      changeAccess in interface RWClient
      Parameters:
      ent - BwShareableDbentity
      aces - Collection of ace
      replaceAll - true to replace the entire access list.
    • validateFilter

      public void validateFilter(String val)
      Description copied from interface: RWClient
      Validate a filter definition.
      Specified by:
      validateFilter in interface RWClient
      Parameters:
      val - String xml filter definition
    • addFilter

      public void addFilter(org.bedework.calfacade.BwFilterDef val)
      Description copied from interface: RWClient
      Validate and persist a new filter definition
      Specified by:
      addFilter in interface RWClient
      Parameters:
      val - filter definition
    • deleteFilter

      public void deleteFilter(String name)
      Description copied from interface: RWClient
      Delete a filter given the name
      Specified by:
      deleteFilter in interface RWClient
      Parameters:
      name - String name of filter
    • getDefaultFilterContext

      protected org.bedework.caldav.util.filter.FilterBase getDefaultFilterContext()
      Overrides:
      getDefaultFilterContext in class ROClientImpl