use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class Xutil method xpropertiesToXcal.
/**
* @param pl
* @param xprops
* @param pattern
* @param masterClass
* @param wrapXprops wrap x-properties in bedework object - allows
* us to push them through soap
* @throws Throwable
*/
@SuppressWarnings("deprecation")
public static void xpropertiesToXcal(final List<JAXBElement<? extends BasePropertyType>> pl, final List<BwXproperty> xprops, final BaseComponentType pattern, final Class masterClass, final boolean wrapXprops) throws Throwable {
for (final BwXproperty x : xprops) {
// Skip any timezone we saved in the event.
final String xname = x.getName();
final String val = x.getValue();
if (xname.startsWith(BwXproperty.bedeworkTimezonePrefix)) {
continue;
}
if (xname.equals(BwXproperty.bedeworkExsynchEndtzid)) {
if (!emit(pattern, masterClass, XBedeworkExsynchEndtzidPropType.class)) {
continue;
}
final XBedeworkExsynchEndtzidPropType p = new XBedeworkExsynchEndtzidPropType();
p.setText(val);
pl.add(of.createXBedeworkExsynchEndtzid(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkExsynchLastmod)) {
if (!emit(pattern, masterClass, XBedeworkExsynchLastmodPropType.class)) {
continue;
}
final XBedeworkExsynchLastmodPropType p = new XBedeworkExsynchLastmodPropType();
p.setText(val);
pl.add(of.createXBedeworkExsynchLastmod(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkExsynchOrganizer)) {
continue;
}
if (xname.equals(BwXproperty.bedeworkExsynchStarttzid)) {
if (!emit(pattern, masterClass, XBedeworkExsynchStarttzidPropType.class)) {
continue;
}
final XBedeworkExsynchStarttzidPropType p = new XBedeworkExsynchStarttzidPropType();
p.setText(val);
pl.add(of.createXBedeworkExsynchStarttzid(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegStart)) {
if (!emit(pattern, masterClass, XBedeworkRegistrationStartPropType.class)) {
continue;
}
final XBedeworkRegistrationStartPropType p = new XBedeworkRegistrationStartPropType();
String tzid = null;
for (final Xpar xp : x.getParameters()) {
if (xp.getName().equalsIgnoreCase("TZID")) {
tzid = xp.getValue();
break;
}
}
XcalUtil.initDt(p, val, tzid);
pl.add(of.createXBedeworkRegistrationStart(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegEnd)) {
if (!emit(pattern, masterClass, XBedeworkRegistrationEndPropType.class)) {
continue;
}
final XBedeworkRegistrationEndPropType p = new XBedeworkRegistrationEndPropType();
String tzid = null;
for (final Xpar xp : x.getParameters()) {
if (xp.getName().equalsIgnoreCase("TZID")) {
tzid = xp.getValue();
break;
}
}
XcalUtil.initDt(p, val, tzid);
pl.add(of.createXBedeworkRegistrationEnd(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegMaxTickets)) {
if (!emit(pattern, masterClass, XBedeworkMaxTicketsPropType.class)) {
continue;
}
final XBedeworkMaxTicketsPropType p = new XBedeworkMaxTicketsPropType();
p.setInteger(BigInteger.valueOf(Long.valueOf(val)));
pl.add(of.createXBedeworkMaxTickets(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegMaxTicketsPerUser)) {
if (!emit(pattern, masterClass, XBedeworkMaxTicketsPerUserPropType.class)) {
continue;
}
final XBedeworkMaxTicketsPerUserPropType p = new XBedeworkMaxTicketsPerUserPropType();
p.setInteger(BigInteger.valueOf(Long.valueOf(val)));
pl.add(of.createXBedeworkMaxTicketsPerUser(p));
continue;
}
if (xname.equals(BwXproperty.bedeworkEventRegWaitListLimit)) {
if (!emit(pattern, masterClass, XBedeworkWaitListLimitPropType.class)) {
continue;
}
final XBedeworkWaitListLimitPropType p = new XBedeworkWaitListLimitPropType();
p.setText(val);
pl.add(of.createXBedeworkWaitListLimit(p));
continue;
}
if (xname.equals(BwXproperty.xBedeworkCategories)) {
if (!emit(pattern, masterClass, XBwCategoriesPropType.class)) {
continue;
}
final XBwCategoriesPropType p = new XBwCategoriesPropType();
p.getText().add(val);
pl.add(of.createXBedeworkCategories(p));
continue;
}
if (xname.equals(BwXproperty.xBedeworkContact)) {
if (!emit(pattern, masterClass, XBwContactPropType.class)) {
continue;
}
final XBwContactPropType p = new XBwContactPropType();
p.setText(val);
pl.add(of.createXBedeworkContact(p));
continue;
}
if (xname.equals(BwXproperty.xBedeworkLocation)) {
if (!emit(pattern, masterClass, XBwLocationPropType.class)) {
continue;
}
final XBwLocationPropType p = new XBwLocationPropType();
p.setText(val);
pl.add(of.createXBedeworkLocation(p));
continue;
}
if (!wrapXprops) {
if (getLog().isDebugEnabled()) {
warn("Not handing x-property " + xname);
}
continue;
}
final XBedeworkWrapperPropType wrapper = new XBedeworkWrapperPropType();
if (x.getParameters() != null) {
for (final Xpar xp : x.getParameters()) {
xparam(wrapper, xp);
}
}
final XBedeworkWrappedNameParamType wnp = new XBedeworkWrappedNameParamType();
wnp.setText(x.getName());
if (wrapper.getParameters() == null) {
wrapper.setParameters(new ArrayOfParameters());
}
wrapper.getParameters().getBaseParameter().add(of.createXBedeworkWrappedName(wnp));
wrapper.setText(val);
pl.add(of.createXBedeworkWrapper(wrapper));
}
}
use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class Xutil method uidProp.
protected static BasePropertyType uidProp(final BasePropertyType prop, final String uid) {
if (uid == null) {
return prop;
}
ArrayOfParameters pars = getAop(prop);
XBedeworkUidParamType x = new XBedeworkUidParamType();
x.setText(uid);
JAXBElement<XBedeworkUidParamType> param = of.createXBedeworkUid(x);
pars.getBaseParameter().add(param);
return prop;
}
use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class IcalTranslator method toXMLIcalendar.
/**
* @param val
* @param methodType
* @param pattern
* @return XML IcalendarType
* @throws CalFacadeException
*/
public IcalendarType toXMLIcalendar(final EventInfo val, final int methodType, final IcalendarType pattern, final boolean wrapXprops) throws CalFacadeException {
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(Xutil.of.createProdid(prod));
VersionPropType vers = new VersionPropType();
vers.setText("2.0");
pl.add(Xutil.of.createVersion(vers));
if ((methodType > ScheduleMethods.methodTypeNone) && (methodType < ScheduleMethods.methodTypeUnknown)) {
MethodPropType m = new MethodPropType();
m.setText(ScheduleMethods.methods[methodType]);
pl.add(Xutil.of.createMethod(m));
}
ArrayOfComponents aoc = vcal.getComponents();
if (aoc == null) {
aoc = new ArrayOfComponents();
vcal.setComponents(aoc);
}
BwEvent ev = val.getEvent();
JAXBElement<? extends BaseComponentType> el = null;
VcalendarType vc = null;
if ((pattern != null) && !pattern.getVcalendar().isEmpty()) {
vc = pattern.getVcalendar().get(0);
}
BaseComponentType bc = matches(vc, ev.getEntityType());
if ((vc != null) && (bc == null)) {
return ical;
}
if (!ev.getSuppressed()) {
if (ev.getEntityType() == IcalDefs.entityTypeFreeAndBusy) {
el = ToXEvent.toComponent(ev, false, wrapXprops, bc);
} else {
el = ToXEvent.toComponent(ev, false, wrapXprops, bc);
}
if (el != null) {
aoc.getBaseComponent().add(el);
}
}
if (val.getNumOverrides() == 0) {
return ical;
}
for (EventInfo oei : val.getOverrides()) {
ev = oei.getEvent();
el = ToXEvent.toComponent(ev, true, wrapXprops, bc);
if (el != null) {
aoc.getBaseComponent().add(el);
}
}
if (val.getNumContainedItems() > 0) {
for (EventInfo aei : val.getContainedItems()) {
ev = aei.getEvent();
el = ToXEvent.toComponent(ev, true, wrapXprops, bc);
if (el != null) {
aoc.getBaseComponent().add(el);
}
}
}
return ical;
}
use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class BwUpdates method addRemove.
private UpdateResult addRemove(final EventInfo ei, final Component subComponent, final boolean add, final List<PropertyReferenceType> refs, final IcalCallback cb) throws WebdavException {
for (PropertyReferenceType r : refs) {
BasePropertyType bprop;
QName pname;
if (r.getBaseProperty() == null) {
return new UpdateResult("No new value for add");
}
bprop = r.getBaseProperty().getValue();
pname = r.getBaseProperty().getName();
PropertyUpdater pu = getUpdater(bprop);
if (pu == null) {
return new UpdateResult("No updater for property: " + pname);
}
PropertyUpdateInfo ui = new PropertyUpdateInfo(bprop, pname, cb, ei, subComponent, state, userHref);
UpdateResult ur;
if (add) {
ur = ui.setAdd(r);
} else {
ur = ui.setRemove(r);
}
if (ur != null) {
return ur;
}
ur = pu.applyUpdate(ui);
if (!ur.getOk()) {
return ur;
}
}
return UpdateResult.getOkResult();
}
use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class BwUpdates method getCompSelector.
private CompSelector getCompSelector(final BaseComponentType selComp) throws WebdavException {
CompSelector cs = new CompSelector();
for (JAXBElement<? extends BasePropertyType> prop : selComp.getProperties().getBasePropertyOrTzid()) {
if (prop.getName().equals(XcalTags.uid)) {
cs.uid = ((UidPropType) prop.getValue()).getText();
if ((cs.uid != null) && (cs.recurrenceId != null)) {
return cs;
}
continue;
}
if (prop.getName().equals(XcalTags.recurrenceId)) {
RecurrenceIdPropType rid = (RecurrenceIdPropType) prop.getValue();
XcalUtil.DtTzid dtTzid = XcalUtil.getDtTzid(rid);
try {
cs.recurrenceId = BwDateTime.makeBwDateTime(dtTzid.dateOnly, dtTzid.dt, dtTzid.tzid);
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
}
if ((cs.uid != null) && (cs.recurrenceId != null)) {
return cs;
}
continue;
}
}
return cs;
}
Aggregations