use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.
the class AuthUserFieldRule method field.
/* (non-Javadoc)
* @see org.bedework.dumprestore.restore.rules.EntityFieldRule#field(java.lang.String)
*/
@Override
public void field(final String name) throws Throwable {
BwEventProperty ep = null;
BwCalendar cal = null;
try {
if (top() instanceof BwEventProperty) {
ep = (BwEventProperty) pop();
} else if (top() instanceof BwCalendar) {
cal = (BwCalendar) pop();
}
BwAuthUser au = (BwAuthUser) top();
if (name.equals("id") || name.equals("seq")) {
return;
}
if (name.equals("userHref")) {
au.setUserHref(Util.buildPath(false, stringFld()));
// } else if (name.equals("account")) { old?
// au.setUserHref(globals.rintf.getUser(stringFld()).getPrincipalRef());
// } else if (name.equals("user")) {
// // done above
} else if (name.equals("usertype")) {
int type = intFld();
au.setUsertype(type);
/* Prefs stuff next */
} else if (name.equals("autoAdd")) {
if (inCategoryPrefs) {
getCategoryPrefs(au).setAutoAdd(booleanFld());
} else if (inCollectionsPrefs) {
getCalendarPrefs(au).setAutoAdd(booleanFld());
} else if (inContactPrefs) {
getContactPrefs(au).setAutoAdd(booleanFld());
} else if (inLocationPrefs) {
getLocationPrefs(au).setAutoAdd(booleanFld());
} else {
error("Not in any prefs for autoAdd");
}
} else if (name.equals("category")) {
au.getPrefs().getCategoryPrefs().add((BwCategory) ep);
} else if (name.equals("collection")) {
au.getPrefs().getCalendarPrefs().add(cal);
} else if (name.equals("contact")) {
au.getPrefs().getContactPrefs().add((BwContact) ep);
} else if (name.equals("location")) {
au.getPrefs().getLocationPrefs().add((BwLocation) ep);
} else if (name.equals("categoryPrefs")) {
inCategoryPrefs = false;
} else if (name.equals("calendarPrefs")) {
inCollectionsPrefs = false;
} else if (name.equals("contactPrefs")) {
inContactPrefs = false;
} else if (name.equals("locationPrefs")) {
inLocationPrefs = false;
} else if (name.equals("prefs")) {
} else if (name.equals("byteSize")) {
} else {
unknownTag(name);
}
} catch (Throwable t) {
handleException(t);
}
}
use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.
the class Restore method makeUserHome.
private void makeUserHome(final BwCalendar userRoot, final BwPrincipal user) throws Throwable {
// Create root user home and default calendar
final BwCalendar userHome = makeCal(userRoot, user, BwCalendar.calTypeFolder, user.getAccount(), null);
makeCal(userHome, user, BwCalendar.calTypeCalendarCollection, RestoreGlobals.getBasicSyspars().getUserDefaultCalendar(), null);
}
use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.
the class Restore method makeCal.
private BwCalendar makeCal(final BwCalendar parent, final BwPrincipal owner, final int type, final String name, final String encodedAcl) throws Throwable {
final BwCalendar cal = new BwCalendar();
cal.setCalType(type);
String ppath = null;
if (parent != null) {
ppath = parent.getPath();
}
cal.setColPath(ppath);
cal.setName(name);
cal.setPath(Util.buildPath(colPathEndsWithSlash, ppath, "/", cal.getName()));
cal.setSummary(cal.getName());
cal.setOwnerHref(owner.getPrincipalRef());
cal.setCreatorHref(owner.getPrincipalRef());
cal.setAccess(encodedAcl);
globals.rintf.saveRootCalendar(cal);
return cal;
}
use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.
the class CollectionLastmodRule method end.
public void end(String ns, String name) throws Exception {
BwCollectionLastmod lm = (BwCollectionLastmod) pop();
BwCalendar ent = (BwCalendar) top();
ent.setLastmod(lm);
lm.setDbEntity(ent);
}
use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.
the class ContainerPathRule method field.
public void field(String name) throws Throwable {
if (name.equals("path")) {
/* If the top is an override skip this - container is set already. */
BwEventAnnotation ann = null;
BwEvent e = null;
if (top() instanceof EventInfo) {
EventInfo ei = (EventInfo) getTop(EventInfo.class, name);
e = ei.getEvent();
if (e instanceof BwEventProxy) {
ann = ((BwEventProxy) e).getRef();
if (ann.getOverride()) {
// Overrides have everything set already
return;
}
}
}
BwCalendar cal = globals.rintf.getCalendar(stringFld());
if (cal == null) {
error("No calendar for path " + stringFld());
}
if (top() instanceof BwShareableContainedDbentity) {
BwShareableContainedDbentity scde = (BwShareableContainedDbentity) top();
scde.setColPath(stringFld());
} else if (top() instanceof EventInfo) {
if (ann != null) {
/* Could be target or master */
String match = getDigester().getMatch();
if (match.contains("/target/")) {
ann.getTarget().setColPath(stringFld());
} else if (match.contains("/master/")) {
ann.getMaster().setColPath(stringFld());
} else {
ann.setColPath(stringFld());
}
}
e.setColPath(stringFld());
} else {
handleException(new Exception("Unexpected stack top "));
}
} else {
unknownTag(name);
}
}
Aggregations