use of org.bedework.calfacade.BwLocation in project bw-calendar-engine by Bedework.
the class BwStringRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
if (name.equals("bwstring")) {
// 3.5 onwards we wrapped with a tag. Do nothing
return;
}
BwString entity = (BwString) pop();
if (top() instanceof BwRequestStatus) {
BwRequestStatus rs = (BwRequestStatus) top();
rs.setDescription(entity);
return;
}
if (top() instanceof BwCategory) {
BwCategory cat = (BwCategory) top();
if (name.equals("keyword")) {
cat.setWord(entity);
} else if (name.equals("desc")) {
cat.setDescription(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwContact) {
BwContact ent = (BwContact) top();
if (name.equals("value")) {
ent.setCn(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwLocation) {
BwLocation loc = (BwLocation) top();
if (name.equals("addr")) {
loc.setAddress(entity);
} else if (name.equals("subaddr")) {
loc.setSubaddress(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwFilterDef) {
BwFilterDef f = (BwFilterDef) top();
if (name.equals("display-name")) {
f.addDisplayName(entity);
} else if (name.equals("subaddr")) {
f.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwAlarm) {
BwAlarm a = (BwAlarm) top();
if (name.equals("description")) {
a.addDescription(entity);
if (entity.getLang() != null) {
a.addXproperty(new BwXproperty(entity.getLang(), null, entity.getValue()));
} else {
a.addDescription(entity);
}
return;
}
if (name.equals("summary")) {
a.addSummary(entity);
} else {
unknownTag(name);
}
return;
}
EventInfo ei = (EventInfo) top();
BwEvent e = ei.getEvent();
if (e instanceof BwEventProxy) {
e = ((BwEventProxy) e).getRef();
}
if (name.equals("comment")) {
e.addComment(entity);
} else if (name.equals("description")) {
e.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
} else if (name.equals("resource")) {
e.addResource(entity);
} else if (name.equals("summary")) {
e.addSummary(entity);
} else {
unknownTag(name);
}
}
use of org.bedework.calfacade.BwLocation in project bw-calendar-engine by Bedework.
the class SchedulingBase method copyEvent.
protected BwEvent copyEvent(final BwEvent origEv, final BwEvent masterEv, final BwPrincipal owner) throws CalFacadeException {
final BwEvent newEv;
BwEventProxy proxy = null;
final String ownerHref = owner.getPrincipalRef();
if (origEv instanceof BwEventProxy) {
proxy = (BwEventProxy) origEv;
if (masterEv == null) {
/* we are being asked to copy an instance of a recurring event - rather than
* a complete recurring event + all overrides - clone the master
*/
newEv = new BwEventObj();
origEv.copyTo(newEv);
newEv.setRecurring(false);
// Return the instance copy
proxy = null;
} else {
// Clone the annotation and set the master and target to our new master
// ANNOTATION
proxy = proxy.clone(masterEv, masterEv);
newEv = proxy.getRef();
}
} else {
// getSvc().reAttach(origEv);
newEv = (BwEvent) origEv.clone();
}
if (!Util.isEmpty(newEv.getAttendees())) {
for (BwAttendee att : newEv.getAttendees()) {
att.setScheduleStatus(null);
}
}
if (newEv.getOrganizer() != null) {
newEv.getOrganizer().setScheduleStatus(null);
}
newEv.setOwnerHref(ownerHref);
newEv.setCreatorHref(ownerHref);
newEv.setDtstamps(getCurrentTimestamp());
if (owner.equals(getPrincipal())) {
if (proxy != null) {
return proxy;
}
return newEv;
}
/* Copy event entities */
BwLocation loc = newEv.getLocation();
if (loc != null) {
loc = (BwLocation) loc.clone();
loc.setOwnerHref(ownerHref);
loc.setCreatorHref(ownerHref);
loc.initUid();
newEv.setLocation(loc);
}
BwContact contact = newEv.getContact();
if (contact != null) {
contact = (BwContact) contact.clone();
contact.setOwnerHref(ownerHref);
contact.setCreatorHref(ownerHref);
contact.initUid();
newEv.setContact(contact);
}
if (proxy != null) {
return proxy;
}
return newEv;
}
use of org.bedework.calfacade.BwLocation in project bw-calendar-engine by Bedework.
the class ProcessSetstatus method setStatusLocation.
private boolean setStatusLocation(final String uid, final String status) throws Throwable {
try {
if (uid == null) {
error("Expected a uid");
return false;
}
open();
final BwLocation ent = getSvci().getLocationsHandler().getPersistent(uid);
if (ent == null) {
error("No entity with uid " + uid);
return false;
}
ent.setStatus(status);
getSvci().getLocationsHandler().update(ent);
return true;
} finally {
close();
}
}
use of org.bedework.calfacade.BwLocation in project bw-calendar-engine by Bedework.
the class ProcessUpdate method updateLocation.
private boolean updateLocation() {
try {
open();
final BwLocation loc = getPersistentLoc();
if (loc == null) {
return true;
}
while (true) {
final String upname = word();
if (upname == null) {
break;
}
switch(upname) {
case "addkey":
{
final String name = qstringFor("key name");
final String val = qstringFor("key value");
loc.addKey(name, val);
break;
}
case "updkey":
{
final String name = qstringFor("key name");
final String val = qstringFor("key value");
loc.updKey(name, val);
break;
}
case "delkey":
{
final String name = qstringFor("key name");
loc.delKey(name);
break;
}
}
}
getSvci().getLocationsHandler().update(loc);
return true;
} catch (final Throwable t) {
error(t);
return false;
} finally {
close();
}
}
use of org.bedework.calfacade.BwLocation in project bw-calendar-engine by Bedework.
the class CmdUtilHelper method getPersistentLoc.
/* expect a quoted uid next
*/
protected BwLocation getPersistentLoc() throws Throwable {
final String uid = quotedVal();
if (uid == null) {
error("Expected a quoted uid");
return null;
}
final BwLocation loc = getSvci().getLocationsHandler().getPersistent(uid);
if (loc == null) {
error("Unable to access location " + uid);
}
return loc;
}
Aggregations