Search in sources :

Example 6 with BwPrincipalInfo

use of org.bedework.calfacade.BwPrincipalInfo in project bw-calendar-engine by Bedework.

the class AbstractDirImpl method getDirInfo.

@Override
public BwPrincipalInfo getDirInfo(final BwPrincipal p) throws CalFacadeException {
    BwPrincipalInfo pi = principalInfoMap.get(p.getPrincipalRef());
    if (pi != null) {
        return pi;
    }
    // If carddav lookup is enabled - use that
    final CardDavInfo cdi = getCardDavInfo(false);
    if ((cdi == null) || (cdi.getHost() == null)) {
        return null;
    }
    BasicHttpClient cdc = null;
    pi = new BwPrincipalInfo();
    try {
        cdc = new BasicHttpClient(cdi.getHost(), cdi.getPort(), null, 15 * 1000);
        pi.setPropertiesFromVCard(getCard(cdc, cdi.getContextPath(), p), "text/vcard");
    } catch (final Throwable t) {
        if (getLogger().isDebugEnabled()) {
            error(t);
        }
    } finally {
        if (cdc != null) {
            cdc.close();
        }
    }
    principalInfoMap.put(p.getPrincipalRef(), pi);
    return pi;
}
Also used : BasicHttpClient(org.bedework.util.http.BasicHttpClient) CardDavInfo(org.bedework.calfacade.configs.CardDavInfo) BwPrincipalInfo(org.bedework.calfacade.BwPrincipalInfo)

Example 7 with BwPrincipalInfo

use of org.bedework.calfacade.BwPrincipalInfo in project bw-calendar-engine by Bedework.

the class AbstractDirImpl method find.

private List<BwPrincipalInfo> find(final BasicHttpClient cdc, final CardDavInfo cdi, final String cua, final String cutype) throws CalFacadeException {
    /* Typically a group entry in a directory doesn't have a mail -
       The cua is a uri which often looks like a mailto.
     */
    final List<WebdavProperty> props = new ArrayList<>();
    final CalAddr ca = new CalAddr(cua);
    if ((cutype != null) && cutype.equalsIgnoreCase(CuType.GROUP.getValue())) {
        final WebdavProperty fnProp = new WebdavProperty(WebdavTags.displayname, ca.getId());
        props.add(fnProp);
    }
    final WebdavProperty emailProp = new WebdavProperty(BedeworkServerTags.emailProp, ca.getNoScheme());
    props.add(emailProp);
    final List<BwPrincipalInfo> pis = new ArrayList<>();
    final List<MatchResult> mrs = matching(cdc, cdi.getContextPath() + getCutypePath(cutype, cdi), null, props);
    if (mrs == null) {
        return pis;
    }
    for (final MatchResult mr : mrs) {
        final BwPrincipalInfo pi = new BwPrincipalInfo();
        pi.setPropertiesFromVCard(mr.card, null);
        pis.add(pi);
    }
    return pis;
}
Also used : WebdavProperty(org.bedework.webdav.servlet.shared.WebdavProperty) ArrayList(java.util.ArrayList) BwPrincipalInfo(org.bedework.calfacade.BwPrincipalInfo)

Example 8 with BwPrincipalInfo

use of org.bedework.calfacade.BwPrincipalInfo in project bw-calendar-engine by Bedework.

the class AbstractDirImpl method find.

@Override
public List<BwPrincipalInfo> find(final List<WebdavProperty> props, final List<WebdavProperty> returnProps, final String cutype, final Holder<Boolean> truncated) throws CalFacadeException {
    final CardDavInfo cdi = getCardDavInfo(false);
    if ((cdi == null) || (cdi.getHost() == null)) {
        return null;
    }
    BasicHttpClient cdc = null;
    final String path = getCutypePath(cutype, cdi);
    String addrCtype = null;
    /* See if we want address data in any particular form */
    for (final WebdavProperty wd : returnProps) {
        if (!wd.getTag().equals(CarddavTags.addressData)) {
            continue;
        }
        addrCtype = wd.getAttr("content-type");
        break;
    }
    try {
        cdc = new BasicHttpClient(cdi.getHost(), cdi.getPort(), null, 15 * 1000);
        final List<MatchResult> mrs = matching(cdc, cdi.getContextPath() + path, addrCtype, props);
        final List<BwPrincipalInfo> pis = new ArrayList<>();
        if (mrs == null) {
            return pis;
        }
        for (final MatchResult mr : mrs) {
            final BwPrincipalInfo pi = new BwPrincipalInfo();
            pi.setPropertiesFromVCard(mr.card, addrCtype);
            pis.add(pi);
        }
        return pis;
    } catch (final Throwable t) {
        if (getLogger().isDebugEnabled()) {
            error(t);
        }
        throw new CalFacadeException(t);
    } finally {
        if (cdc != null) {
            cdc.close();
        }
    }
}
Also used : WebdavProperty(org.bedework.webdav.servlet.shared.WebdavProperty) ArrayList(java.util.ArrayList) BasicHttpClient(org.bedework.util.http.BasicHttpClient) CardDavInfo(org.bedework.calfacade.configs.CardDavInfo) BwPrincipalInfo(org.bedework.calfacade.BwPrincipalInfo) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

BwPrincipalInfo (org.bedework.calfacade.BwPrincipalInfo)8 ArrayList (java.util.ArrayList)4 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)4 WebdavProperty (org.bedework.webdav.servlet.shared.WebdavProperty)4 CardDavInfo (org.bedework.calfacade.configs.CardDavInfo)3 BasicHttpClient (org.bedework.util.http.BasicHttpClient)3 Holder (javax.xml.ws.Holder)2 Directories (org.bedework.calfacade.ifs.Directories)2 TreeSet (java.util.TreeSet)1 PropertyList (net.fortuna.ical4j.model.PropertyList)1 VVoter (net.fortuna.ical4j.model.component.VVoter)1 Voter (net.fortuna.ical4j.model.property.Voter)1 Property (net.fortuna.ical4j.vcard.Property)1 VCard (net.fortuna.ical4j.vcard.VCard)1 AccessPrincipal (org.bedework.access.AccessPrincipal)1 PrivilegeSet (org.bedework.access.PrivilegeSet)1 CalDAVCollection (org.bedework.caldav.server.CalDAVCollection)1 CalPrincipalInfo (org.bedework.caldav.server.sysinterface.CalPrincipalInfo)1 BwAttendee (org.bedework.calfacade.BwAttendee)1 BwEventProxy (org.bedework.calfacade.BwEventProxy)1