[Bedework-commit] r360 - in trunk/calendar3:
calCore/src/org/bedework/calcore/hibernate
calFacade/src/org/bedework/calfacade/base
calFacade/src/org/bedework/calfacade/ifs
calsvc/src/org/bedework/calsvc
svnadmin at bedework.org
svnadmin at bedework.org
Mon Apr 10 22:54:08 EDT 2006
Author: douglm
Date: 2006-04-10 22:53:39 -0400 (Mon, 10 Apr 2006)
New Revision: 360
Modified:
trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java
trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java
trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java
trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java
trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
Log:
Don't use Trash to store deleted event annotations. Instead store in special calendar "Deleted"
That way we don't have to take any special actions when emptying trash
Modified: trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java
===================================================================
--- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java 2006-04-10 13:51:15 UTC (rev 359)
+++ trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Calendars.java 2006-04-11 02:53:39 UTC (rev 360)
@@ -81,7 +81,7 @@
* @param debug
* @throws CalFacadeException
*/
- public Calendars(Calintf cal, AccessUtil access,
+ public Calendars(Calintf cal, AccessUtil access,
int currentMode, boolean debug)
throws CalFacadeException {
super(cal, access, currentMode, debug);
@@ -177,6 +177,19 @@
cal.setCalendarCollection(true);
usercal.addChild(cal);
+ /* Add the deleted calendar */
+ cal = new BwCalendar();
+ // XXX new syspar cal.setName(getSyspars().getUserOutbox());
+ cal.setName("Deleted");
+ cal.setCreator(user);
+ cal.setOwner(user);
+ cal.setPublick(false);
+ // XXX new syspar cal.setPath(path + "/" + getSyspars().getUserOutbox());
+ cal.setPath(path + "/" + "Deleted");
+ cal.setCalendar(usercal);
+ cal.setCalendarCollection(true);
+ usercal.addChild(cal);
+
sess.save(usercal);
sess.update(user);
@@ -312,21 +325,53 @@
return getCalendar(sb.toString());
}
+ public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("/");
+ sb.append(getSyspars().getUserCalendarRoot());
+ sb.append("/");
+ sb.append(user.getAccount());
+ sb.append("/");
+ sb.append("Deleted");
+ // XXX new syspar sb.append(getSyspars().getDefaultTrashCalendar());
+
+ return getCalendar(sb.toString());
+ }
+
+ public void createDeletedCalendar(BwUser user) throws CalFacadeException {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("/");
+ sb.append(getSyspars().getUserCalendarRoot());
+ sb.append("/");
+ sb.append(user.getAccount());
+
+ String pathTo = sb.toString();
+
+ BwCalendar parent = getCalendar(pathTo);
+
+ if (parent == null) {
+ throw new CalFacadeException("org.bedework.calcore.calendars.unabletocreate");
+ }
+
+ BwCalendar cal = new BwCalendar();
+ cal.setName("Deleted");
+ cal.setOwner(user);
+ cal.setCreator(user);
+ cal.setPublick(parent.getPublick());
+ cal.setCalendarCollection(true);
+ addCalendar(cal, parent);
+ }
+
public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException {
HibSession sess = getSess();
- /* We need write access to the parent */
- access.checkAccess(parent, privWrite, false);
+ /* We need write content access to the parent */
+ access.checkAccess(parent, privWriteContent, false);
/** Is the parent a calendar collection?
*/
-/* sess.namedQuery("countCalendarEventRefs");
- sess.setEntity("cal", parent);
-
- Integer res = (Integer)sess.getUnique();
-
- if (res.intValue() > 0) {*/
-
if (parent.getCalendarCollection()) {
throw new CalFacadeException(CalFacadeException.illegalCalendarCreation);
}
@@ -351,7 +396,9 @@
}
val.setPath(path);
- val.setOwner(getUser());
+ if (val.getOwner() == null) {
+ val.setOwner(getUser());
+ }
val.setCalendar(parent);
parent.addChild(val);
@@ -426,7 +473,7 @@
while (it.hasNext()) {
BwCalendar cal = (BwCalendar)it.next();
- CurrentAccess ca = access.checkAccess(cal, desiredAccess,
+ CurrentAccess ca = access.checkAccess(cal, desiredAccess,
noAccessReturnsNull);
if (ca != null) {
//cal.setCurrentAccess(ca);
@@ -449,9 +496,9 @@
private BwCalendar cloneAndCheckOne(BwCalendar subroot, int desiredAccess,
boolean nullForNoAccess) throws CalFacadeException {
- CurrentAccess ca = access.checkAccess(subroot, desiredAccess,
+ CurrentAccess ca = access.checkAccess(subroot, desiredAccess,
nullForNoAccess);
-
+
if (!ca.accessAllowed) {
return null;
}
@@ -459,7 +506,7 @@
BwCalendar cal = (BwCalendar)subroot.shallowClone();
// XXX Temp fix - add id to the clone
cal.setId(subroot.getId());
-
+
cal.setCurrentAccess(ca);
Iterator it = subroot.iterateChildren();
Modified: trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
===================================================================
--- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java 2006-04-10 13:51:15 UTC (rev 359)
+++ trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java 2006-04-11 02:53:39 UTC (rev 360)
@@ -85,6 +85,7 @@
import org.bedework.icalendar.IcalTranslator;
import java.sql.Timestamp;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.TreeSet;
@@ -859,6 +860,10 @@
return calendars.getTrashCalendar(user);
}
+ public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException {
+ return calendars.getDeletedCalendar(user);
+ }
+
public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException {
checkOpen();
@@ -1105,7 +1110,15 @@
}
public Collection getDeletedProxies() throws CalFacadeException {
- return events.getDeletedProxies(this.getTrashCalendar(user));
+ BwCalendar cal = this.getDeletedCalendar(user);
+
+ if (cal == null) {
+ // Create the deleted calendar for another time
+ calendars.createDeletedCalendar(user);
+ return new ArrayList();
+ }
+
+ return events.getDeletedProxies(this.getDeletedCalendar(user));
}
/* ====================================================================
Modified: trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java
===================================================================
--- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java 2006-04-10 13:51:15 UTC (rev 359)
+++ trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java 2006-04-11 02:53:39 UTC (rev 360)
@@ -294,7 +294,7 @@
* Retrieve event proxies in the trash - they will be used to remove events
* from result sets.
*
- * @param cal Trash calendar object
+ * @param cal Deleted calendar object
* @return Collection of CoreEventInfo objects
*/
public Collection getDeletedProxies(BwCalendar cal) throws CalFacadeException {
Modified: trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java
===================================================================
--- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java 2006-04-10 13:51:15 UTC (rev 359)
+++ trunk/calendar3/calFacade/src/org/bedework/calfacade/base/CalintfBase.java 2006-04-11 02:53:39 UTC (rev 360)
@@ -469,6 +469,10 @@
throw new CalFacadeUnimplementedException();
}
+ public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException {
+ throw new CalFacadeUnimplementedException();
+ }
+
public void addCalendar(BwCalendar val, BwCalendar parent) throws CalFacadeException {
checkOpen();
Modified: trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java
===================================================================
--- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java 2006-04-10 13:51:15 UTC (rev 359)
+++ trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalendarsI.java 2006-04-11 02:53:39 UTC (rev 360)
@@ -105,10 +105,10 @@
public BwCalendar getCalendar(String path) throws CalFacadeException;
/** Get the default calendar for the given user. This is determined by the
- * name for the default calendar assigned to the system, not by any user
+ * name for the default calendar assigned to the system, not by any user
* preferences. This is normally used at initialisation of a new user.
*
- * @param user
+ * @param user
* @return BwCalendar null for unknown calendar
* @throws CalFacadeException
*/
@@ -116,12 +116,21 @@
/** Get the trash calendar for the given user.
*
- * @param user
+ * @param user
* @return BwCalendar null for unknown calendar
* @throws CalFacadeException
*/
public BwCalendar getTrashCalendar(BwUser user) throws CalFacadeException;
+ /** Get the deleted calendar for the given user. This holds annotations
+ * marking other events as deleted
+ *
+ * @param user
+ * @return BwCalendar null for unknown calendar
+ * @throws CalFacadeException
+ */
+ public BwCalendar getDeletedCalendar(BwUser user) throws CalFacadeException;
+
/** Add a calendar object
*
* <p>The new calendar object will be added to the db. If the indicated parent
Modified: trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
===================================================================
--- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java 2006-04-10 13:51:15 UTC (rev 359)
+++ trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java 2006-04-11 02:53:39 UTC (rev 360)
@@ -1682,7 +1682,7 @@
if (ca.accessAllowed) {
// Have write access - just set the flag and move it into the owners trash
event.setDeleted(true);
- event.setCalendar(getCal().getTrashCalendar(event.getOwner()));
+ event.setCalendar(getCal().getDeletedCalendar(event.getOwner()));
updateEvent(event);
return;
}
@@ -1694,7 +1694,7 @@
// Where does the ref go? Not in the same calendar - we have no access
// Put it in the trash - but don't delete on empty trash
- BwCalendar cal = getCal().getTrashCalendar(getUser());
+ BwCalendar cal = getCal().getDeletedCalendar(getUser());
proxy.setOwner(getUser());
proxy.setDeleted(true);
proxy.setCalendar(cal);
More information about the Bedework-commit
mailing list