Search in sources :

Example 6 with NoProxy

use of org.bedework.calfacade.annotations.ical.NoProxy in project bw-calendar-engine by Bedework.

the class BwEvent method setDtstamps.

/**
 * Set the dtstamp, lastmod and created if created is not set already.
 * @param val
 */
@NoProxy
public void setDtstamps(final Timestamp val) {
    DateTime dt = new DateTime(val);
    setDtstamp(new DtStamp(dt).getValue());
    setLastmod(new LastModified(dt).getValue());
    setCtoken(getLastmod() + "-" + hex4FromNanos(val.getNanos()));
    if (getCreated() == null) {
        setCreated(new Created(dt).getValue());
    }
}
Also used : LastModified(net.fortuna.ical4j.model.property.LastModified) DtStamp(net.fortuna.ical4j.model.property.DtStamp) DateTime(net.fortuna.ical4j.model.DateTime) Created(net.fortuna.ical4j.model.property.Created) NoProxy(org.bedework.calfacade.annotations.ical.NoProxy)

Example 7 with NoProxy

use of org.bedework.calfacade.annotations.ical.NoProxy in project bw-calendar-engine by Bedework.

the class BwEvent method findAttendee.

/**
 * Find an attendee entry for the given uri (calendar address).
 *
 * @param uri
 * @return BwAttendee or null if none exists
 * @throws CalFacadeException
 */
@NoProxy
public BwAttendee findAttendee(final String uri) throws CalFacadeException {
    if (getNumAttendees() == 0) {
        return null;
    }
    int uriLen = uri.length();
    boolean hasMailTo = false;
    int uriStart = 0;
    if (uri.toLowerCase().startsWith(mailTo)) {
        hasMailTo = true;
        uriStart = 7;
    }
    while (uri.charAt(uriLen - 1) == '/') {
        uriLen--;
        if (uriLen <= uriStart) {
            return null;
        }
    }
    String uriSeg = uri.substring(uriStart, uriLen);
    for (BwAttendee att : getAttendees()) {
        String auri = att.getAttendeeUri();
        int auriLen = auri.length();
        int auriStart = 0;
        if (hasMailTo) {
            if (!auri.toLowerCase().startsWith(mailTo)) {
                return null;
            }
            auriStart = uriStart;
        }
        while (auri.charAt(auriLen - 1) == '/') {
            auriLen--;
            if (auriLen <= auriStart) {
                return null;
            }
        }
        if ((auriLen == uriLen) && (uriSeg.regionMatches(0, auri, auriStart, uriLen - auriStart))) {
            return att;
        }
    }
    return null;
}
Also used : ToString(org.bedework.util.misc.ToString) NoProxy(org.bedework.calfacade.annotations.ical.NoProxy)

Example 8 with NoProxy

use of org.bedework.calfacade.annotations.ical.NoProxy in project bw-calendar-engine by Bedework.

the class BwEvent method hex4FromNanos.

/**
 * @param val - nanoseconds
 * @return a 4 digit hex value
 */
@NoProxy
public static String hex4FromNanos(final int val) {
    final String formatted = Integer.toHexString(val / 100000);
    final StringBuilder buf = new StringBuilder("0000");
    buf.replace(4 - formatted.length(), 4, formatted);
    return buf.toString();
}
Also used : ToString(org.bedework.util.misc.ToString) NoProxy(org.bedework.calfacade.annotations.ical.NoProxy)

Example 9 with NoProxy

use of org.bedework.calfacade.annotations.ical.NoProxy in project bw-calendar-engine by Bedework.

the class BwEvent method getTimeZoneIds.

/**
 * Return all timezone ids this event uses. This is used when an event is
 * added by another user to ensure that the target user has a copy of user
 * specific timezones.
 *
 * @return Set of timezone ids.
 * @throws CalFacadeException
 */
@NoProxy
@NoDump
public Set<String> getTimeZoneIds() throws CalFacadeException {
    Set<String> ids = new TreeSet<String>();
    BwDateTime dt = getDtstart();
    if ((dt != null) && (dt.getTzid() != null)) {
        ids.add(dt.getTzid());
    }
    dt = getDtend();
    if ((dt != null) && (dt.getTzid() != null)) {
        ids.add(dt.getTzid());
    }
    Set<BwDateTime> dts = getRdates();
    if (dts != null) {
        for (BwDateTime rdt : dts) {
            if (rdt.getTzid() != null) {
                ids.add(rdt.getTzid());
            }
        }
    }
    dts = getExdates();
    if (dts != null) {
        for (BwDateTime rdt : dts) {
            if (rdt.getTzid() != null) {
                ids.add(rdt.getTzid());
            }
        }
    }
    List<BwFreeBusyComponent> fbcs = getFreeBusyPeriods();
    if (fbcs != null) {
        for (BwFreeBusyComponent fbc : fbcs) {
            for (Period p : fbc.getPeriods()) {
                DateTime fdt = p.getStart();
                if (fdt.getTimeZone() != null) {
                    ids.add(fdt.getTimeZone().getID());
                }
                fdt = p.getEnd();
                if (fdt.getTimeZone() != null) {
                    ids.add(fdt.getTimeZone().getID());
                }
            }
        }
    }
    return ids;
}
Also used : TreeSet(java.util.TreeSet) Period(net.fortuna.ical4j.model.Period) ToString(org.bedework.util.misc.ToString) DateTime(net.fortuna.ical4j.model.DateTime) NoProxy(org.bedework.calfacade.annotations.ical.NoProxy) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 10 with NoProxy

use of org.bedework.calfacade.annotations.ical.NoProxy in project bw-calendar-engine by Bedework.

the class BwEvent method hex4.

/* ====================================================================
   *                   Private methods
   *  =================================================================== */
/**
 * @param val number to convert to hex
 * @return a 4 digit hex value
 */
@NoProxy
public static String hex4(final int val) {
    final String formatted = Integer.toHexString(val % 32001);
    final StringBuilder buf = new StringBuilder("0000");
    buf.replace(4 - formatted.length(), 4, formatted);
    return buf.toString();
}
Also used : ToString(org.bedework.util.misc.ToString) NoProxy(org.bedework.calfacade.annotations.ical.NoProxy)

Aggregations

NoProxy (org.bedework.calfacade.annotations.ical.NoProxy)10 ToString (org.bedework.util.misc.ToString)6 DateTime (net.fortuna.ical4j.model.DateTime)3 NoDump (org.bedework.calfacade.annotations.NoDump)3 ArrayList (java.util.ArrayList)2 LastModified (net.fortuna.ical4j.model.property.LastModified)2 Xpar (org.bedework.calfacade.BwXproperty.Xpar)2 TreeSet (java.util.TreeSet)1 Period (net.fortuna.ical4j.model.Period)1 Created (net.fortuna.ical4j.model.property.Created)1 DtStamp (net.fortuna.ical4j.model.property.DtStamp)1 CloneForOverride (org.bedework.calfacade.annotations.CloneForOverride)1 NoWrap (org.bedework.calfacade.annotations.NoWrap)1