/* (non-Javadoc)
   * @see org.bedework.synch.ConnectorInstance#getItemsInfo()
   */
  @Override
  public SynchItemsInfo getItemsInfo() throws SynchException {
    SynchItemsInfo sii = new SynchItemsInfo();
    sii.items = new ArrayList<ItemInfo>();
    sii.setStatus(StatusType.OK);

    getIcal();

    if (sub.changed()) {
      cnctr.getSyncher().updateSubscription(sub);
    }

    for (MapEntry me : uidMap.values()) {
      sii.items.add(new ItemInfo(me.uid, me.lastMod, null)); // lastSynch
    }

    return sii;
  }
  /* (non-Javadoc)
   * @see org.bedework.synch.cnctrs.ConnectorInstance#fetchItem(java.lang.String)
   */
  @Override
  public FetchItemResponseType fetchItem(final String uid) throws SynchException {
    getIcal();

    if (sub.changed()) {
      cnctr.getSyncher().updateSubscription(sub);
    }

    MapEntry me = uidMap.get(uid);

    FetchItemResponseType fir = new FetchItemResponseType();

    if (me == null) {
      fir.setStatus(StatusType.NOT_FOUND);
      return fir;
    }

    fir.setHref(info.getUri() + "#" + uid);
    fir.setChangeToken(info.getChangeToken());

    IcalendarType ical = new IcalendarType();
    VcalendarType vcal = new VcalendarType();

    ical.getVcalendar().add(vcal);

    vcal.setProperties(new ArrayOfProperties());
    List<JAXBElement<? extends BasePropertyType>> pl = vcal.getProperties().getBasePropertyOrTzid();

    ProdidPropType prod = new ProdidPropType();
    prod.setText(prodid);
    pl.add(of.createProdid(prod));

    VersionPropType vers = new VersionPropType();
    vers.setText("2.0");
    pl.add(of.createVersion(vers));

    ArrayOfComponents aoc = new ArrayOfComponents();
    vcal.setComponents(aoc);

    aoc.getBaseComponent().addAll(me.comps);
    fir.setIcalendar(ical);

    return fir;
  }
  private DavClient getClient() throws SynchException {
    if (client != null) {
      return client;
    }

    DavClient cl = null;

    try {
      cl = new DavClient(15 * 1000);

      if (info.getPrincipalHref() != null) {
        cl.setCredentials(info.getPrincipalHref(), cnctr.getSyncher().decrypt(info.getPassword()));
      }

      client = cl;

      return cl;
    } catch (DavioException de) {
      throw new SynchException(de);
    }
  }