[Bedework-commit] dumprestore r220 - in
trunk/src/org/bedework/dumprestore: dump dump/dumpling
restore restore/rules
svnadmin at bedework.org
svnadmin at bedework.org
Tue Aug 19 16:34:42 EDT 2008
Author: douglm
Date: 2008-08-19 16:34:40 -0400 (Tue, 19 Aug 2008)
New Revision: 220
Modified:
trunk/src/org/bedework/dumprestore/dump/DumpGlobals.java
trunk/src/org/bedework/dumprestore/dump/DumpIntf.java
trunk/src/org/bedework/dumprestore/dump/HibDump.java
trunk/src/org/bedework/dumprestore/dump/dumpling/DumpUserPrefs.java
trunk/src/org/bedework/dumprestore/restore/HibRestore.java
trunk/src/org/bedework/dumprestore/restore/RestoreIntf.java
trunk/src/org/bedework/dumprestore/restore/SubscriptionsMap.java
trunk/src/org/bedework/dumprestore/restore/rules/UserPrefsFieldRule.java
Log:
Remove subscriptions code and completely replace with alias.
Currently views are broken but should be working soon. Committing this allows work to proceed on the xsl side.
Modified: trunk/src/org/bedework/dumprestore/dump/DumpGlobals.java
===================================================================
--- trunk/src/org/bedework/dumprestore/dump/DumpGlobals.java 2008-08-08 01:44:00 UTC (rev 219)
+++ trunk/src/org/bedework/dumprestore/dump/DumpGlobals.java 2008-08-19 20:34:40 UTC (rev 220)
@@ -62,12 +62,6 @@
public int timezones;
/** */
- public int subscribedUsers;
-
- /** */
- public int subscriptions;
-
- /** */
public int calendars;
/** */
@@ -116,8 +110,6 @@
System.out.println(" users: " + users);
System.out.println(" timezones: " + timezones);
System.out.println(" calendars: " + calendars);
- System.out.println(" subscribedUsers: " + subscribedUsers);
- System.out.println(" subscriptions: " + subscriptions);
System.out.println(" locations: " + locations);
System.out.println(" contacts: " + contacts);
System.out.println(" organizers: " + organizers);
Modified: trunk/src/org/bedework/dumprestore/dump/DumpIntf.java
===================================================================
--- trunk/src/org/bedework/dumprestore/dump/DumpIntf.java 2008-08-08 01:44:00 UTC (rev 219)
+++ trunk/src/org/bedework/dumprestore/dump/DumpIntf.java 2008-08-19 20:34:40 UTC (rev 220)
@@ -63,7 +63,7 @@
* <li>BwEvent</li>
* <li>BwEventAnnotation</li>
* <li>BwAdminGroup</li>
- * <li>BwPreferences + BwSubscription + BwView</li>
+ * <li>BwPreferences + BwView</li>
* <li>BwCalSuite</li>
*
* <li>BwFilter</li>
@@ -196,13 +196,6 @@
*/
public Iterator getSponsors() throws Throwable;
- /** Will return an Iterator returning Subscription objects.
- *
- * @return Iterator over entities
- * @throws Throwable
- */
- public Iterator getSubscriptions() throws Throwable;
-
/** Will return an Iterator returning system parameter objects.
*
* @return Iterator over entities
Modified: trunk/src/org/bedework/dumprestore/dump/HibDump.java
===================================================================
--- trunk/src/org/bedework/dumprestore/dump/HibDump.java 2008-08-08 01:44:00 UTC (rev 219)
+++ trunk/src/org/bedework/dumprestore/dump/HibDump.java 2008-08-19 20:34:40 UTC (rev 220)
@@ -45,7 +45,6 @@
import org.bedework.calfacade.exc.CalFacadeException;
import org.bedework.calfacade.svc.BwAdminGroup;
import org.bedework.calfacade.svc.BwCalSuite;
-import org.bedework.calfacade.svc.BwSubscription;
import org.bedework.calfacade.svc.BwView;
import org.bedework.calfacade.svc.EventInfo;
import org.bedework.calfacade.svc.prefs.BwPreferences;
@@ -213,10 +212,6 @@
return getObjects(BwContact.class.getName());
}
- public Iterator getSubscriptions() throws Throwable {
- return getObjects(BwSubscription.class.getName());
- }
-
public Iterator getSyspars() throws Throwable {
return getObjects(BwSystem.class.getName());
}
Modified: trunk/src/org/bedework/dumprestore/dump/dumpling/DumpUserPrefs.java
===================================================================
--- trunk/src/org/bedework/dumprestore/dump/dumpling/DumpUserPrefs.java 2008-08-08 01:44:00 UTC (rev 219)
+++ trunk/src/org/bedework/dumprestore/dump/dumpling/DumpUserPrefs.java 2008-08-19 20:34:40 UTC (rev 220)
@@ -28,7 +28,7 @@
*/
package org.bedework.dumprestore.dump.dumpling;
-import org.bedework.calfacade.svc.BwSubscription;
+import org.bedework.calfacade.BwCalendar;
import org.bedework.calfacade.svc.BwView;
import org.bedework.calfacade.svc.prefs.BwPreferences;
import org.bedework.dumprestore.dump.DumpGlobals;
@@ -70,38 +70,6 @@
ownedEntityTags(p);
- Collection<BwSubscription> s = p.getSubscriptions();
-
- if ((s != null) && (s.size() > 0)) {
- tagStart("subscriptions");
-
- for (BwSubscription sub: s) {
- tagStart("subscription");
-
- taggedVal("sub-id", sub.getId());
- taggedVal("sub-seq", sub.getSeq());
- userKey(sub.getOwner(), "owner");
-
- taggedVal("sub-name", sub.getName());
- taggedVal("sub-uri", sub.getUri());
- taggedVal("sub-affectsFreeBusy", sub.getAffectsFreeBusy());
- taggedVal("sub-ignoreTransparency", sub.getIgnoreTransparency());
- taggedVal("sub-display", sub.getDisplay());
- taggedVal("sub-style", sub.getStyle());
- taggedVal("sub-internalSubscription", sub.getInternalSubscription());
- taggedVal("sub-emailNotifications", sub.getEmailNotifications());
- taggedVal("sub-calendarDeleted", sub.getCalendarDeleted());
- taggedVal("sub-unremoveable", sub.getUnremoveable());
-
- tagEnd("subscription");
- globals.subscriptions++;
- }
-
- globals.subscribedUsers++;
-
- tagEnd("subscriptions");
- }
-
Collection<BwView> v = p.getViews();
if ((v != null) && (v.size() > 0)) {
@@ -111,20 +79,19 @@
tagStart("view");
taggedVal("view-id", view.getId());
- taggedVal("view-seq", view.getSeq());
userKey(view.getOwner(), "owner");
taggedVal("view-name", view.getName());
- Collection<BwSubscription> vs = view.getSubscriptions();
+ Collection<BwCalendar> cs = view.getCollections();
- if ((vs != null) && (vs.size() > 0)) {
- tagStart("view-subscriptions");
+ if ((cs != null) && (cs.size() > 0)) {
+ tagStart("view-collections");
- for (BwSubscription sub: vs) {
- taggedVal("view-sub-name", sub.getName());
+ for (BwCalendar c: cs) {
+ taggedVal("view-collection", c.getPath());
}
- tagEnd("view-subscriptions");
+ tagEnd("view-collections");
}
tagEnd("view");
Modified: trunk/src/org/bedework/dumprestore/restore/HibRestore.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/HibRestore.java 2008-08-08 01:44:00 UTC (rev 219)
+++ trunk/src/org/bedework/dumprestore/restore/HibRestore.java 2008-08-19 20:34:40 UTC (rev 220)
@@ -55,9 +55,11 @@
import org.bedework.calcore.AccessUtil;
import org.bedework.calcore.hibernate.CalintfHelperHib;
+import org.bedework.calcore.hibernate.CoreCalendars;
import org.bedework.calcore.hibernate.CoreEvents;
import org.bedework.calcore.hibernate.HibSessionImpl;
import org.bedework.calcorei.CalintfDefs;
+import org.bedework.calcorei.CoreCalendarsI;
import org.bedework.calcorei.CoreEventInfo;
import org.bedework.calcorei.CoreEventsI;
import org.bedework.calcorei.HibSession;
@@ -87,7 +89,6 @@
import org.bedework.calfacade.svc.BwAdminGroupEntry;
import org.bedework.calfacade.svc.BwAuthUser;
import org.bedework.calfacade.svc.BwCalSuite;
-import org.bedework.calfacade.svc.BwSubscription;
import org.bedework.calfacade.svc.BwView;
import org.bedework.calfacade.svc.EventInfo;
import org.bedework.calfacade.svc.prefs.BwPreferences;
@@ -128,6 +129,7 @@
private AccessUtil access;
private CoreEventsI events;
+ private CoreCalendarsI calendars;
/**
* @param debug
@@ -153,47 +155,6 @@
this.globals = globals;
}
- private CoreEventsI getEvents(BwUser user) throws Throwable {
- if (events != null) {
- access.setAuthUser(user);
- return events;
- }
-
- access = new AccessUtil();
- access.init(new AccessUtilCb(), globals.config.getDebug());
- access.setAuthUser(user);
- access.setSuperUser(true);
-
- CalintfHelperHib.HibSessionFetcher hsf = new HibSessionFetcher(this);
- events = new CoreEvents(hsf, globals.calCallback,
- null, // notifications
- access,
- currentMode, globals.config.getDebug());
-
- return events;
- }
-
- private class AccessUtilCb extends AccessUtilI.CallBack {
- /* (non-Javadoc)
- * @see org.bedework.calfacade.util.AccessUtilI.CallBack#getUserCalendarRoot()
- */
- public String getUserCalendarRoot() throws CalFacadeException {
- return globals.getSyspars().getUserCalendarRoot();
- }
- }
-
- private static class HibSessionFetcher implements CalintfHelperHib.HibSessionFetcher {
- private HibRestore intf;
-
- HibSessionFetcher(HibRestore intf) {
- this.intf = intf;
- }
-
- public HibSession getSess() throws CalFacadeException {
- return intf.hibSession;
- }
- }
-
/* (non-Javadoc)
* @see org.bedework.dumprestore.restore.RestoreIntf#open()
*/
@@ -471,11 +432,11 @@
/* (non-Javadoc)
* @see org.bedework.dumprestore.restore.RestoreIntf#getEvent(org.bedework.calfacade.BwUser, org.bedework.calfacade.BwCalendar, java.lang.String, java.lang.String)
*/
- public BwEvent getEvent(BwUser user, BwCalendar cal,
- String recurrenceId,
+ public BwEvent getEvent(BwUser user, BwCalendar cal,
+ String recurrenceId,
String uid) throws Throwable {
/* Open the session if not already open. Note we don't close it - that will
- * happen later.
+ * happen later.
*/
openHibSess();
CoreEventsI evi = getEvents(user);
@@ -496,13 +457,13 @@
recurrenceId + ", " + uid + "} found " + ceis.size());
return null;
}
-
+
BwEvent ev = ceis.iterator().next().getEvent();
if (ev instanceof BwEventAnnotation) {
ev = new BwEventProxy((BwEventAnnotation)ev);
}
-
+
return ev;
}
@@ -647,18 +608,6 @@
openHibSess();
- /* Unset the subscription id - hibernate cascades cause an error
- * We'll just have to go with a new id
- */
- Collection<BwSubscription> s = o.getSubscriptions();
- if (s != null) {
- for (BwSubscription sub: s) {
- sub.setId(CalFacadeDefs.unsavedItemKey);
-
- globals.subscriptions++;
- }
- }
-
/* Same for views */
Collection<BwView> v = o.getViews();
if (v != null) {
@@ -782,10 +731,89 @@
closeHibSess();
}
+ public String getUserHome(BwUser user) throws Throwable {
+ return getCalendars(user).getUserRootPath(user);
+ }
+
+ public void addCalendar(BwCalendar val,
+ String parentPath) throws Throwable {
+ openHibSess();
+ getCalendars(val.getOwner()).addCalendar(val, parentPath);
+ closeHibSess();
+ }
+
/* ====================================================================
* Private methods
* ==================================================================== */
+ /* I think we do this because of a (diminishing) number of reasons.
+ * Efficiency concerns
+ * Bypassing access restrictions
+ * Switching user - just set the authuser in the access routines.
+ *
+ * It would be easier just to use the standard api
+ */
+ private CoreEventsI getEvents(BwUser user) throws Throwable {
+ if (events != null) {
+ access.setAuthUser(user);
+ return events;
+ }
+
+ access = new AccessUtil();
+ access.init(new AccessUtilCb(), globals.config.getDebug());
+ access.setAuthUser(user);
+ access.setSuperUser(true);
+
+ CalintfHelperHib.HibSessionFetcher hsf = new HibSessionFetcher(this);
+ events = new CoreEvents(hsf, globals.calCallback,
+ null, // notifications
+ access,
+ currentMode, globals.config.getDebug());
+
+ return events;
+ }
+
+ private CoreCalendarsI getCalendars(BwUser user) throws Throwable {
+ if (calendars != null) {
+ access.setAuthUser(user);
+ return calendars;
+ }
+
+ access = new AccessUtil();
+ access.init(new AccessUtilCb(), globals.config.getDebug());
+ access.setAuthUser(user);
+ access.setSuperUser(true);
+
+ CalintfHelperHib.HibSessionFetcher hsf = new HibSessionFetcher(this);
+ calendars = new CoreCalendars(hsf, globals.calCallback,
+ null, // notifications
+ access,
+ currentMode, globals.config.getDebug());
+
+ return calendars;
+ }
+
+ private class AccessUtilCb extends AccessUtilI.CallBack {
+ /* (non-Javadoc)
+ * @see org.bedework.calfacade.util.AccessUtilI.CallBack#getUserCalendarRoot()
+ */
+ public String getUserCalendarRoot() throws CalFacadeException {
+ return globals.getSyspars().getUserCalendarRoot();
+ }
+ }
+
+ private static class HibSessionFetcher implements CalintfHelperHib.HibSessionFetcher {
+ private HibRestore intf;
+
+ HibSessionFetcher(HibRestore intf) {
+ this.intf = intf;
+ }
+
+ public HibSession getSess() throws CalFacadeException {
+ return intf.hibSession;
+ }
+ }
+
private void handleException(Throwable t, String msg) {
error(msg); // Update count
log.error(this, t);
Modified: trunk/src/org/bedework/dumprestore/restore/RestoreIntf.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/RestoreIntf.java 2008-08-08 01:44:00 UTC (rev 219)
+++ trunk/src/org/bedework/dumprestore/restore/RestoreIntf.java 2008-08-19 20:34:40 UTC (rev 220)
@@ -223,15 +223,15 @@
/** Get an event
*
* @param user - the current user we are acting as - eg, for an annotation and
- * fetching the master event this will be the annotation owner.
+ * fetching the master event this will be the annotation owner.
* @param cal
* @param recurrenceId
* @param uid
* @return BwEvent
* @throws Throwable
*/
- public BwEvent getEvent(BwUser user, BwCalendar cal,
- String recurrenceId,
+ public BwEvent getEvent(BwUser user, BwCalendar cal,
+ String recurrenceId,
String uid) throws Throwable;
/** See if an event name is in the given calendar
@@ -344,5 +344,21 @@
* @throws Throwable
*/
public void addCalendar(BwCalendar val) throws Throwable;
+
+ /** Get the user home collection for the given user
+ *
+ * @param user
+ * @return String path
+ * @throws Throwable
+ */
+ public String getUserHome(BwUser user) throws Throwable;
+
+ /**
+ * @param val
+ * @param parentPath
+ * @throws Throwable
+ */
+ public void addCalendar(BwCalendar val,
+ String parentPath) throws Throwable;
}
Modified: trunk/src/org/bedework/dumprestore/restore/SubscriptionsMap.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/SubscriptionsMap.java 2008-08-08 01:44:00 UTC (rev 219)
+++ trunk/src/org/bedework/dumprestore/restore/SubscriptionsMap.java 2008-08-19 20:34:40 UTC (rev 220)
@@ -1,33 +1,5 @@
-/*
- Copyright (c) 2000-2005 University of Washington. All rights reserved.
-
- Redistribution and use of this distribution in source and binary forms,
- with or without modification, are permitted provided that:
-
- The above copyright notice and this permission notice appear in
- all copies and supporting documentation;
-
- The name, identifiers, and trademarks of the University of Washington
- are not used in advertising or publicity without the express prior
- written permission of the University of Washington;
-
- Recipients acknowledge that this distribution is made available as a
- research courtesy, "as is", potentially with defects, without
- any obligation on the part of the University of Washington to
- provide support, services, or repair;
-
- THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR
- IMPLIED, WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION
- ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
- WASHINGTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING
- NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
/* **********************************************************************
- Copyright 2005 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+ Copyright 2008 Rensselaer Polytechnic Institute. All worldwide rights reserved.
Redistribution and use of this distribution in source and binary forms,
with or without modification, are permitted provided that:
@@ -53,8 +25,8 @@
*/
package org.bedework.dumprestore.restore;
+import org.bedework.calfacade.BwCalendar;
import org.bedework.calfacade.BwUser;
-import org.bedework.calfacade.svc.BwSubscription;
import java.util.ArrayList;
import java.util.Collection;
@@ -66,52 +38,68 @@
* @version 1.0
*/
public class SubscriptionsMap
- extends HashMap<PrincipalInfo, ArrayList<BwSubscription>> {
+ extends HashMap<PrincipalInfo, Collection<? extends Object>> {
/**
+ * @author douglm
+ */
+ private static class SubInfo {
+ int calId;
+ String name;
+ String path;
+
+ SubInfo(BwCalendar cal) {
+ calId = cal.getId();
+ name = cal.getName();
+ path = cal.getPath();
+ }
+ }
+
+ /**
* @param key BwUser
- * @param sub
+ * @param cal
*/
- public void put(BwUser key, BwSubscription sub) {
- put(PrincipalInfo.makeOwnerInfo(key), sub);
+ public void put(BwUser key, BwCalendar cal) {
+ put(PrincipalInfo.makeOwnerInfo(key), new SubInfo(cal));
}
/**
* @param key OwnerInfo
- * @param sub
+ * @param val
*/
- public void put(PrincipalInfo key, BwSubscription sub) {
- ArrayList<BwSubscription> al = get(key);
+ public void put(PrincipalInfo key, SubInfo val) {
+ Collection<SubInfo> al = getSubs(key);
if (al == null) {
- al = new ArrayList<BwSubscription>();
+ al = new ArrayList<SubInfo>();
put(key, al);
}
- al.add(sub);
+ al.add(val);
}
/**
* @param key OwnerInfo
- * @return Collection of BwSubscription
+ * @return Collection of String paths
*/
- public Collection<BwSubscription> getSubs(PrincipalInfo key) {
- return get(key);
+ public Collection<SubInfo> getSubs(PrincipalInfo key) {
+ return (Collection<SubInfo>)get(key);
}
/**
- * @param key OwnerInfo
- * @param subid
- * @return BwSubscription
+ * @param owner BwUser owner
+ * @param calid
+ * @return String path
*/
- public BwSubscription getSub(PrincipalInfo key, int subid) {
- Collection<BwSubscription> subs = getSubs(key);
+ public String getSub(BwUser owner, int calid) {
+ PrincipalInfo key = PrincipalInfo.makeOwnerInfo(owner);
+ Collection<SubInfo> subs = getSubs(key);
if (subs == null) {
return null;
}
- for (BwSubscription sub: subs) {
- if (sub.getId() == subid) {
- return sub;
+ for (SubInfo sub: subs) {
+ if (sub.calId == calid) {
+ return sub.path;
}
}
@@ -119,20 +107,21 @@
}
/**
- * @param key OwnerInfo
+ * @param owner BwUser owner
* @param name
- * @return BwSubscription
+ * @return String path
*/
- public BwSubscription getSub(PrincipalInfo key, String name) {
- Collection<BwSubscription> subs = getSubs(key);
+ public String getSub(BwUser owner, String name) {
+ PrincipalInfo key = PrincipalInfo.makeOwnerInfo(owner);
+ Collection<SubInfo> subs = getSubs(key);
if (subs == null) {
return null;
}
- for (BwSubscription sub: subs) {
- if (sub.getName().equals(name)) {
- return sub;
+ for (SubInfo sub: subs) {
+ if (sub.name.equals(name)) {
+ return sub.path;
}
}
Modified: trunk/src/org/bedework/dumprestore/restore/rules/UserPrefsFieldRule.java
===================================================================
--- trunk/src/org/bedework/dumprestore/restore/rules/UserPrefsFieldRule.java 2008-08-08 01:44:00 UTC (rev 219)
+++ trunk/src/org/bedework/dumprestore/restore/rules/UserPrefsFieldRule.java 2008-08-19 20:34:40 UTC (rev 220)
@@ -25,10 +25,10 @@
*/
package org.bedework.dumprestore.restore.rules;
-import org.bedework.calfacade.svc.BwSubscription;
+import org.bedework.calfacade.BwCalendar;
+import org.bedework.calfacade.exc.CalFacadeException;
import org.bedework.calfacade.svc.BwView;
import org.bedework.calfacade.svc.prefs.BwPreferences;
-import org.bedework.dumprestore.restore.PrincipalInfo;
import org.bedework.dumprestore.restore.RestoreGlobals;
import org.xml.sax.Attributes;
@@ -51,7 +51,7 @@
super.begin(namespace, name, attributes);
if (name.equals("subscription")) {
- push(new BwSubscription());
+ push(new BwCalendar());
} else if (name.equals("view")) {
push(new BwView());
}
@@ -67,11 +67,12 @@
}
BwPreferences p = null;
- BwSubscription sub = null;
+ BwCalendar cal = null;
BwView view = null;
+ String viewPath = null; // If non-null add given colllection to view
if (name.equals("subscription") || (name.startsWith("sub-"))) { // PRE3.5
- sub = (BwSubscription)getTop(BwSubscription.class, name);
+ cal = (BwCalendar)getTop(BwCalendar.class, name);
} else if (name.equals("view") || (name.startsWith("view-"))) {
view = (BwView)getTop(BwView.class, name);
} else {
@@ -113,46 +114,81 @@
// PRE3.5 subscription fields
} else if (name.equals("sub-owner")) { // PRE3.3
- sub.setOwner(userFld());
+ cal.setOwner(userFld());
+ } else if (name.equals("view-seq")) { // PRE3.5
- } else if (name.equals("subscription")) {
+ } else if (name.equals("subscription")) { // PRE3.5
pop();
p = (BwPreferences)getTop(BwPreferences.class, name);
- if (sub.getOwner().getUnauthenticated()) {
- error("No subscription owner for " + sub);
- } else if (!p.getOwner().equals(sub.getOwner())) {
- error("Subscription owners don't match for " + sub);
- error(" Found owner " + sub.getOwner() + " expected " + p.getOwner());
- sub.setOwner(p.getOwner());
+ cal.setCreator(cal.getOwner());
+
+ if (cal.getOwner().getUnauthenticated()) {
+ error("No owner for " + cal);
+ } else if (!p.getOwner().equals(cal.getOwner())) {
+ error("Owners don't match for " + cal);
+ error(" Found owner " + cal.getOwner() + " expected " + p.getOwner());
+ cal.setOwner(p.getOwner());
} else {
- globals.subscriptionsTbl.put(sub.getOwner(), sub);
- p.addSubscription(sub);
+ cal.setCalType(BwCalendar.calTypeAlias);
+
+ /* If this is a subscription to our own collection we don't need an
+ * alias
+ */
+ String calHome = globals.rintf.getUserHome(cal.getOwner());
+ String path = cal.getInternalAliasPath();
+
+ if (path.startsWith(calHome + "/")) { // TRAILSLASH
+ // The path we will store in the subscriptions table.
+ cal.setPath(path);
+ } else {
+ /* Create an alias with the current object
+ */
+ int suffix = 1;
+ String origName = cal.getName();
+
+ for (;;) {
+ try {
+ globals.rintf.addCalendar(cal, calHome);
+ break;
+ } catch (CalFacadeException cfe) {
+ if (CalFacadeException.duplicateCalendar.equals(cfe.getMessage())) {
+ if (suffix == 1) {
+ warn("Renamed subscription " + cal.getName());
+ }
+
+ cal.setName(origName + "_" + suffix);
+ suffix++;
+ }
+ }
+ }
+ }
+
+ globals.subscriptionsTbl.put(cal.getOwner(), cal);
}
} else if (name.equals("sub-id")) {
- sub.setId(intFld());
+ cal.setId(intFld());
} else if (name.equals("sub-seq")) {
- sub.setSeq(intFld());
} else if (name.equals("sub-name")) {
- sub.setName(stringFld());
+ cal.setName(stringFld());
} else if (name.equals("sub-uri")) {
- sub.setUri(stringFld());
+ cal.setAliasUri(stringFld());
} else if (name.equals("sub-affectsFreeBusy")) {
- sub.setAffectsFreeBusy(booleanFld());
+ cal.setAffectsFreeBusy(booleanFld());
} else if (name.equals("sub-ignoreTransparency")) {
- sub.setIgnoreTransparency(booleanFld());
+ cal.setIgnoreTransparency(booleanFld());
} else if (name.equals("sub-display")) {
- sub.setDisplay(booleanFld());
+ cal.setDisplay(booleanFld());
} else if (name.equals("sub-style")) {
- sub.setStyle(stringFld());
+ cal.setColor(stringFld());
} else if (name.equals("sub-internalSubscription")) {
- sub.setInternalSubscription(booleanFld());
+ //cal.setInternalSubscription(booleanFld());
} else if (name.equals("sub-emailNotifications")) {
- sub.setEmailNotifications(booleanFld());
+ //cal.setEmailNotifications(booleanFld());
} else if (name.equals("sub-calendarDeleted")) {
- sub.setCalendarDeleted(booleanFld());
+ cal.setDisabled(booleanFld());
} else if (name.equals("sub-unremoveable")) {
- sub.setUnremoveable(booleanFld());
+ cal.setUnremoveable(booleanFld());
// view fields
@@ -170,42 +206,53 @@
} else if (name.equals("view-id")) {
view = new BwView();
view.setId(intFld());
- } else if (name.equals("view-seq")) {
- view.setSeq(intFld());
} else if (name.equals("view-name")) {
view.setName(stringFld());
} else if (name.equals("view-subscriptions")) {
} else if (name.equals("view-sub-id")) {
// PRE3.1
- sub = globals.subscriptionsTbl.getSub(PrincipalInfo.makeOwnerInfo(view.getOwner()),
- intFld());
+ viewPath = globals.subscriptionsTbl.getSub(view.getOwner(), intFld());
- if (sub == null) {
- error(" Missing subscription " + intFld() + " for view " +
- view);
- } else {
- view.addSubscription(sub);
+ if (viewPath == null) {
+ error(" Unknown subscription " + intFld() + " for view " + view);
}
- } else if (name.equals("view-sub-name")) {
- sub = globals.subscriptionsTbl.getSub(PrincipalInfo.makeOwnerInfo(view.getOwner()),
- stringFld());
+ } else if (name.equals("view-sub-name")) { // PRE3.5
+ viewPath = globals.subscriptionsTbl.getSub(view.getOwner(), stringFld());
- if (sub == null) {
- error(" Missing subscription " + stringFld() + " for view " +
- view);
+ if (viewPath == null) {
+ error(" Unknown subscription " + stringFld() + " for view " + view);
+ }
+ } else if (name.equals("view-sub-path")) {
+ viewPath = stringFld();
+ }
+
+ if (viewPath != null) {
+ cal = globals.rintf.getCalendar(viewPath);
+ if (cal == null) {
+ error(" Missing subscription with path " + viewPath +
+ " for view " + view);
} else {
- view.addSubscription(sub);
+ view.addCollection(cal);
}
}
} catch (Exception e) {
error("Exception setting prefs " + p);
- if (sub != null) {
- error(sub.toString());
+ if (cal != null) {
+ error(cal.toString());
}
if (view != null) {
error(view.toString());
}
throw e;
+ } catch (Throwable t) {
+ error("Throwable setting prefs " + p);
+ if (cal != null) {
+ error(cal.toString());
+ }
+ if (view != null) {
+ error(view.toString());
+ }
+ throw new Exception(t);
}
}
}
More information about the Bedework-commit
mailing list