[Bedework-commit] calendarapi r409 - in trunk:
calCore/src/org/bedework/calcore
calCore/src/org/bedework/calcore/caldav
calCore/src/org/bedework/calcore/hibernate
calCoreI/src/org/bedework/calcorei
calFacade/src/org/bedework/calfacade/util
calsvc/src/org/bedework/calsvc calsvci/src/org/bedework/calsvci
svnadmin at bedework.org
svnadmin at bedework.org
Mon Sep 10 14:36:08 EDT 2007
Author: douglm
Date: 2007-09-10 14:36:06 -0400 (Mon, 10 Sep 2007)
New Revision: 409
Added:
trunk/calsvc/src/org/bedework/calsvc/Syspars.java
trunk/calsvci/src/org/bedework/calsvci/SysparsI.java
Modified:
trunk/calCore/src/org/bedework/calcore/AccessUtil.java
trunk/calCore/src/org/bedework/calcore/CalintfBase.java
trunk/calCore/src/org/bedework/calcore/caldav/CalintfCaldavImpl.java
trunk/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
trunk/calCoreI/src/org/bedework/calcorei/Calintf.java
trunk/calFacade/src/org/bedework/calfacade/util/AccessUtilI.java
trunk/calsvc/src/org/bedework/calsvc/CalSvc.java
trunk/calsvci/src/org/bedework/calsvci/CalSvcI.java
Log:
Move system parameters processing out of CalIntf.
Needed this to get around some problems introduced with the last round of changes. Ity's also appropriate.
Modified: trunk/calCore/src/org/bedework/calcore/AccessUtil.java
===================================================================
--- trunk/calCore/src/org/bedework/calcore/AccessUtil.java 2007-09-10 02:55:09 UTC (rev 408)
+++ trunk/calCore/src/org/bedework/calcore/AccessUtil.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -69,7 +69,6 @@
import org.bedework.calfacade.BwCategory;
import org.bedework.calfacade.BwLocation;
import org.bedework.calfacade.BwContact;
-import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.BwUser;
import org.apache.log4j.Logger;
@@ -103,11 +102,11 @@
private BwUser authUser;
- private BwSystem syspars;
+ private CallBack cb;
- private String userRootPath;
+ private String urp;//userRootPath;
- private String userHomePathPrefix;
+ private String uhpp; //userHomePathPrefix;
private transient Logger log;
@@ -140,7 +139,8 @@
* @param debug
* @throws CalFacadeException
*/
- public void init(boolean debug) throws CalFacadeException {
+ public void init(CallBack cb, boolean debug) throws CalFacadeException {
+ this.cb = cb;
this.debug = debug;
try {
access = new Access(debug);
@@ -183,16 +183,6 @@
public void close() {
}
- /** Set the system parameters object.
- * @param val
- */
- public void setSyspars(BwSystem val) {
- syspars = val;
-
- userRootPath = "/" + syspars.getUserCalendarRoot();
- userHomePathPrefix = userRootPath + "/";
- }
-
/** Called to get the parent object for a shared entity. This method should be
* overriden if explicit calls to the back end calendar are required.
*
@@ -352,11 +342,11 @@
}
*/
if (!getSuperUser()) {
- if (userRootPath.equals(path)) {
+ if (getUserRootPath().equals(path)) {
ca = new CurrentAccess();
ca.privileges = PrivilegeSet.makeDefaultNonOwnerPrivileges();
- } else if (path.equals(userHomePathPrefix + account)){
+ } else if (path.equals(getUserHomePathPrefix() + account)){
// Accessing user home directory
// Set the maximumn access
maxPrivs = PrivilegeSet.userHomeMaxPrivileges;
@@ -562,6 +552,22 @@
}
}
+ private String getUserRootPath() throws CalFacadeException {
+ if (urp == null) {
+ urp = "/" + cb.getUserCalendarRoot();
+ }
+
+ return urp;
+ }
+
+ private String getUserHomePathPrefix() throws CalFacadeException {
+ if (uhpp == null) {
+ uhpp = getUserRootPath() + "/";
+ }
+
+ return uhpp;
+ }
+
/* Update the merged Acl for the given calendar.
* Doesn't work because any children in the table need the access changing.
private void updatePathInfo(BwCalendar cal, Acl acl) throws CalFacadeException {
Modified: trunk/calCore/src/org/bedework/calcore/CalintfBase.java
===================================================================
--- trunk/calCore/src/org/bedework/calcore/CalintfBase.java 2007-09-10 02:55:09 UTC (rev 408)
+++ trunk/calCore/src/org/bedework/calcore/CalintfBase.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -69,6 +69,7 @@
//import org.bedework.calfacade.BwSystem;
import org.bedework.calcorei.Calintf;
import org.bedework.calcorei.CalintfDefs;
+import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.BwUser;
//import org.bedework.calfacade.CalFacadeDefs;
//import org.bedework.calfacade.CalFacadeUnimplementedException;
@@ -102,7 +103,7 @@
* @author Mike Douglass douglm at rpi.edu
*/
public abstract class CalintfBase implements Calintf {
- private String systemName;
+ private BwSystem syspars;
protected String url;
@@ -134,15 +135,14 @@
/* (non-Javadoc)
* @see org.bedework.calfacade.Calintf#init(org.bedework.calfacade.BwUser, java.lang.String, boolean, boolean, boolean, java.lang.String, boolean)
*/
- public boolean init(String systemName,
+ public boolean init(BwSystem syspars,
String url,
String authenticatedUser,
String user,
boolean publicAdmin,
- Directories dirs
- ,
+ Directories dirs,
boolean debug) throws CalFacadeException {
- this.systemName = systemName;
+ this.syspars = syspars;
this.url = url;
this.debug = debug;
boolean userCreated = false;
@@ -160,25 +160,22 @@
return userCreated;
}
- public String getSystemName() {
- return systemName;
- }
-
public boolean getDebug() throws CalFacadeException {
return debug;
}
- public void setUser(String val) throws CalFacadeException {
- user = getUser(val);
- if (this.user == null) {
- throw new CalFacadeException(CalFacadeException.noSuchAccount, val);
- }
+ /* (non-Javadoc)
+ * @see org.bedework.calcorei.Calintf#setSyspars(org.bedework.calfacade.BwSystem)
+ */
+ public void setSyspars(BwSystem val) throws CalFacadeException {
+ syspars = val;
+ }
- logon(user);
-
- if (debug) {
- log.debug("User " + val + " set in calintf");
- }
+ /* (non-Javadoc)
+ * @see org.bedework.calcorei.Calintf#getSyspars()
+ */
+ public BwSystem getSyspars() throws CalFacadeException {
+ return syspars;
}
/* ====================================================================
@@ -292,43 +289,6 @@
return user;
}
- public void updateUser() throws CalFacadeException {
- updateUser(getUser());
- }
-
- /*
- public void updateUser(BwUser user) throws CalFacadeException {
- checkOpen();
- throw new CalFacadeUnimplementedException();
- }
-
- public void addUser(BwUser user) throws CalFacadeException {
- checkOpen();
-
- throw new CalFacadeUnimplementedException();
- }
-
- public BwUser getUser(int id) throws CalFacadeException {
- checkOpen();
- throw new CalFacadeUnimplementedException();
- }
-
- public BwUser getUser(String account) throws CalFacadeException {
- checkOpen();
- throw new CalFacadeUnimplementedException();
- }
-
- public Collection getInstanceOwners() throws CalFacadeException {
- checkOpen();
- throw new CalFacadeUnimplementedException();
- }
-
- private void logon(BwUser val) throws CalFacadeException {
- checkOpen();
- throw new CalFacadeUnimplementedException();
- }
- */
-
/* ====================================================================
* Access
* ==================================================================== */
Modified: trunk/calCore/src/org/bedework/calcore/caldav/CalintfCaldavImpl.java
===================================================================
--- trunk/calCore/src/org/bedework/calcore/caldav/CalintfCaldavImpl.java 2007-09-10 02:55:09 UTC (rev 408)
+++ trunk/calCore/src/org/bedework/calcore/caldav/CalintfCaldavImpl.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -109,14 +109,14 @@
/* (non-Javadoc)
* @see org.bedework.calfacade.Calintf#init(org.bedework.calfacade.BwUser, java.lang.String, boolean, boolean, boolean, java.lang.String, boolean)
*/
- public boolean init(String systemName,
+ public boolean init(BwSystem syspars,
String url,
String authenticatedUser,
String user,
boolean publicAdmin,
Directories dirs,
boolean debug) throws CalFacadeException {
- boolean userAdded = super.init(systemName, url, authenticatedUser, user, publicAdmin,
+ boolean userAdded = super.init(syspars, url, authenticatedUser, user, publicAdmin,
dirs, debug);
try {
if (httpManager == null) {
@@ -163,34 +163,10 @@
return null;
}
- public BwSystem getSyspars() throws CalFacadeException {
- return null;
- }
-
- public BwSystem getSyspars(String name) throws CalFacadeException {
- return null;
- }
-
- public void updateSyspars(BwSystem val) throws CalFacadeException {
- }
-
public CalintfInfo getInfo() throws CalFacadeException {
return info;
}
- public void setUser(String val) throws CalFacadeException {
- user = getUser(val);
- if (this.user == null) {
- throw new CalFacadeException("User " + val + " does not exist.");
- }
-
- logon(user);
-
- if (debug) {
- getLogger().debug("User " + val + " set in calintf");
- }
- }
-
public void setTimezonesHandler(CalTimezones val) throws CalFacadeException {
}
@@ -233,26 +209,9 @@
}
/* ====================================================================
- * Global parameters
- * ==================================================================== */
-
- public String getSysid() throws CalFacadeException {
- return "";
- }
-
- public String getSysname() throws CalFacadeException {
- return "";
- }
-
- /* ====================================================================
* Users
* ==================================================================== */
- public void updateUser(BwUser user) throws CalFacadeException {
- checkOpen();
- throw new CalFacadeUnimplementedException();
- }
-
public void addUser(BwUser user) throws CalFacadeException {
checkOpen();
Modified: trunk/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
===================================================================
--- trunk/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java 2007-09-10 02:55:09 UTC (rev 408)
+++ trunk/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -89,6 +89,7 @@
import org.bedework.calfacade.filter.BwOrFilter;
import org.bedework.calfacade.ifs.Directories;
import org.bedework.calfacade.timezones.CalTimezones;
+import org.bedework.calfacade.util.AccessUtilI;
import org.bedework.calfacade.util.ChangeTable;
import org.bedework.calfacade.util.Granulator.EventPeriod;
import org.bedework.calfacade.wrappers.CoreCalendarWrapper;
@@ -138,8 +139,6 @@
* @author Mike Douglass douglm at rpi.edu
*/
public class CalintfImpl extends CalintfBase implements PrivilegeDefs {
- private BwSystem syspars;
-
private BwStats stats = new BwRWStats();
private CalTimezones timezones;
@@ -195,16 +194,16 @@
* ==================================================================== */
/* (non-Javadoc)
- * @see org.bedework.calfacade.Calintf#init(org.bedework.calfacade.BwUser, java.lang.String, boolean, boolean, boolean, java.lang.String, boolean)
+ * @see org.bedework.calcore.CalintfBase#init(org.bedework.calfacade.BwSystem, java.lang.String, java.lang.String, java.lang.String, boolean, org.bedework.calfacade.ifs.Directories, boolean)
*/
- public boolean init(String systemName,
+ public boolean init(BwSystem syspars,
String url,
String authenticatedUser,
String user,
boolean publicAdmin,
Directories groups,
boolean debug) throws CalFacadeException {
- super.init(systemName, url, authenticatedUser, user, publicAdmin,
+ super.init(syspars, url, authenticatedUser, user, publicAdmin,
groups, debug);
boolean userCreated = false;
@@ -213,7 +212,7 @@
try {
access = new AccessUtil();
- access.init(debug);
+ access.init(new AccessUtilCb(), debug);
} catch (Throwable t) {
throw new CalFacadeException(t);
}
@@ -274,7 +273,6 @@
this.user.setGroups(groups.getAllGroups(this.user));
access.setAuthUser(this.user);
- access.setSyspars((BwSystem)getSyspars().clone());
CalintfHelperCallback cb = new CalintfHelperCallback(this);
CalintfHelperHib.HibSessionFetcher hsf = new HibSessionFetcher(this);
@@ -296,6 +294,15 @@
return userCreated;
}
+ private class AccessUtilCb extends AccessUtilI.CallBack {
+ /* (non-Javadoc)
+ * @see org.bedework.calfacade.util.AccessUtilI.CallBack#getUserCalendarRoot()
+ */
+ public String getUserCalendarRoot() throws CalFacadeException {
+ return getSyspars().getUserCalendarRoot();
+ }
+ }
+
private static class HibSessionFetcher implements CalintfHelperHib.HibSessionFetcher {
private CalintfBase intf;
@@ -393,37 +400,6 @@
return DbStatistics.getStats(dbStats);
}
- public BwSystem getSyspars() throws CalFacadeException {
- return getSyspars(getSystemName());
- }
-
- public BwSystem getSyspars(String name) throws CalFacadeException {
- if (syspars == null) {
- sess.namedQuery("getSystemPars");
-
- sess.setString("name", name);
-
- syspars = (BwSystem)sess.getUnique();
-
- if (syspars == null) {
- throw new CalFacadeException("No system parameters with name " +
- name);
- }
-
- if (debug) {
- trace("Read system parameters: " + syspars);
- }
- }
- return syspars;
- }
-
- public void updateSyspars(BwSystem val) throws CalFacadeException {
- checkOpen();
- sess.update(val);
- syspars = null; // Force refresh
- access.setSyspars((BwSystem)getSyspars().clone());
- }
-
public CalintfInfo getInfo() throws CalFacadeException {
return info;
}
@@ -585,24 +561,6 @@
}
/* ====================================================================
- * Global parameters
- * ==================================================================== */
-
- /* (non-Javadoc)
- * @see org.bedework.calcorei.Calintf#getSysid()
- */
- public String getSysid() throws CalFacadeException {
- return getSyspars().getSystemid();
- }
-
- /* (non-Javadoc)
- * @see org.bedework.calcorei.Calintf#getSysname()
- */
- public String getSysname() throws CalFacadeException {
- return getSyspars().getName();
- }
-
- /* ====================================================================
* Users
* ==================================================================== */
@@ -648,14 +606,6 @@
}
/* (non-Javadoc)
- * @see org.bedework.calcorei.Calintf#updateUser(org.bedework.calfacade.BwUser)
- */
- public void updateUser(BwUser user) throws CalFacadeException {
- checkOpen();
- sess.update(user);
- }
-
- /* (non-Javadoc)
* @see org.bedework.calcorei.Calintf#getInstanceOwners()
*/
public Collection<BwUser> getInstanceOwners() throws CalFacadeException {
Modified: trunk/calCoreI/src/org/bedework/calcorei/Calintf.java
===================================================================
--- trunk/calCoreI/src/org/bedework/calcorei/Calintf.java 2007-09-10 02:55:09 UTC (rev 408)
+++ trunk/calCoreI/src/org/bedework/calcorei/Calintf.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -94,7 +94,7 @@
public interface Calintf extends CalendarsI, EventsI {
/** Must be called to initialise the new object.
*
- * @param systemName Used to retrieve configuration about systems.
+ * @param syspars
* @param url String url to which we are connecting
* @param authenticatedUser String authenticated user of the application
* or null for guest
@@ -105,7 +105,7 @@
* @return boolean true if the authUser was added to the db
* @throws CalFacadeException
*/
- public boolean init(String systemName,
+ public boolean init(BwSystem syspars,
String url,
String authenticatedUser,
String user,
@@ -113,12 +113,6 @@
Directories groups,
boolean debug) throws CalFacadeException;
- /** Retrieve systemName supplied at init
- *
- * @return String name
- */
- public String getSystemName();
-
/** Can be called after init to flag the arrival of a user.
*
* @param val true for a super user
@@ -172,28 +166,6 @@
*/
public Collection<StatsEntry> getDbStats() throws CalFacadeException;
- /** Get the system pars using name supplied at init
- *
- * @return BwSystem object
- * @throws CalFacadeException if not admin
- */
- public BwSystem getSyspars() throws CalFacadeException;
-
- /** Get the system pars given name
- *
- * @param name
- * @return BwSystem object
- * @throws CalFacadeException if not admin
- */
- public BwSystem getSyspars(String name) throws CalFacadeException;
-
- /** Update the system pars
- *
- * @param val BwSystem object
- * @throws CalFacadeException if not admin
- */
- public void updateSyspars(BwSystem val) throws CalFacadeException;
-
/** Get information about this interface
*
* @return CalintfInfo
@@ -208,15 +180,6 @@
*/
public boolean getDebug() throws CalFacadeException;
- /** Switch to the given non-null user. The access rights are determined by
- * the previous call to init.
- *
- * @param val String user id
- * @throws CalFacadeException
- */
- public void setUser(String val) throws CalFacadeException;
-
-
/** Call early to set the timezones handler. which may be needed for UTC
* calculations.
*
@@ -305,6 +268,20 @@
*/
public void reAttach(BwDbentity val) throws CalFacadeException;
+ /** Set the current system pars
+ *
+ * @param val BwSystem object
+ * @throws CalFacadeException if not admin
+ */
+ public void setSyspars(BwSystem val) throws CalFacadeException;
+
+ /** Get the current system pars
+ *
+ * @return BwSystem object
+ * @throws CalFacadeException if not admin
+ */
+ public BwSystem getSyspars() throws CalFacadeException;
+
/* ====================================================================
* Users
* ==================================================================== */
@@ -316,19 +293,6 @@
*/
public BwUser getUser() throws CalFacadeException;
- /** Update the current user entry
- *
- * @throws CalFacadeException
- */
- public void updateUser() throws CalFacadeException;
-
- /** Update the given user entry
- *
- * @param user BwUser object to add.
- * @throws CalFacadeException
- */
- public void updateUser(BwUser user) throws CalFacadeException;
-
/** Add a user to the database
*
* @param user BwUser object to add.
@@ -352,30 +316,6 @@
public Collection<BwUser> getInstanceOwners() throws CalFacadeException;
/* ====================================================================
- * Global parameters
- * ==================================================================== */
-
- /** Get a name uniquely.identifying this system. This should take the form <br/>
- * name at host
- * <br/>where<ul>
- * <li>name identifies the particular calendar system at the site</li>
- * <li>host part identifies the domain of the site.</li>..
- * </ul>
- *
- * @return String globally unique system identifier.
- * @throws CalFacadeException
- */
- public String getSysid() throws CalFacadeException;
-
- /** Get a name uniquely.identifying this instance in the domain.
- * </ul>
- *
- * @return String globally unique system identifier.
- * @throws CalFacadeException
- */
- public String getSysname() throws CalFacadeException;
-
- /* ====================================================================
* Access
* ==================================================================== */
Modified: trunk/calFacade/src/org/bedework/calfacade/util/AccessUtilI.java
===================================================================
--- trunk/calFacade/src/org/bedework/calfacade/util/AccessUtilI.java 2007-09-10 02:55:09 UTC (rev 408)
+++ trunk/calFacade/src/org/bedework/calfacade/util/AccessUtilI.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -34,7 +34,6 @@
import org.bedework.calfacade.base.BwShareableDbentity;
import org.bedework.calfacade.exc.CalFacadeException;
import org.bedework.calfacade.BwCalendar;
-import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.BwUser;
import java.io.Serializable;
@@ -54,12 +53,24 @@
* @author Mike Douglass douglm at rpi.edu
*/
public interface AccessUtilI extends PrivilegeDefs, Serializable {
+ /** Methods called to obtain system information.
+ *
+ */
+ public static abstract class CallBack implements Serializable {
+ /** Returns something like "/user"
+ *
+ * @return String root
+ * @throws CalFacadeException
+ */
+ public abstract String getUserCalendarRoot() throws CalFacadeException;
+ }
/**
*
+ * @param cb
* @param debug
* @throws CalFacadeException
*/
- public void init(boolean debug) throws CalFacadeException;
+ public void init(CallBack cb, boolean debug) throws CalFacadeException;
/** Indicate if we are in superuser mode.
* @param val
@@ -87,11 +98,6 @@
*/
public void close();
- /** Set the system parameters object.
- * @param val
- */
- public void setSyspars(BwSystem val);
-
/** Called to get the parent object for a shared entity. This method should be
* overriden if explicit calls to the back end calendar are required.
*
Modified: trunk/calsvc/src/org/bedework/calsvc/CalSvc.java
===================================================================
--- trunk/calsvc/src/org/bedework/calsvc/CalSvc.java 2007-09-10 02:55:09 UTC (rev 408)
+++ trunk/calsvc/src/org/bedework/calsvc/CalSvc.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -118,6 +118,7 @@
import org.bedework.calsvci.SchedulingI;
import org.bedework.calsvci.SubscriptionsI;
import org.bedework.calsvci.SynchI;
+import org.bedework.calsvci.SysparsI;
import org.bedework.calsvci.TimeZonesStoreI;
import org.bedework.calsvci.EventProperties.EnsureEntityExistsResult;
import org.bedework.icalendar.IcalCallback;
@@ -180,6 +181,8 @@
private PreferencesI prefsHandler;
+ private SysparsI sysparsHandler;
+
private CalSuitesI calSuitesHandler;
private SubscriptionsI subscriptionsHandler;
@@ -443,14 +446,14 @@
}
public BwSystem getSyspars() throws CalFacadeException {
- return getCal().getSyspars(systemName);
+ return getSysparsHandler().get(systemName);
}
public void updateSyspars(BwSystem val) throws CalFacadeException {
if (!isSuper()) {
throw new CalFacadeAccessException();
}
- getCal().updateSyspars(val);
+ getSysparsHandler().update(val);
}
public void logStats() throws CalFacadeException {
@@ -539,7 +542,7 @@
}
public String getSysid() throws CalFacadeException {
- return getCal().getSysid();
+ return getSysparsHandler().getSysid();
}
public boolean refreshNeeded() throws CalFacadeException {
@@ -551,6 +554,15 @@
* Factory methods
* ==================================================================== */
+ public SysparsI getSysparsHandler() throws CalFacadeException {
+ if (sysparsHandler == null) {
+ sysparsHandler = new Syspars(this, null, systemName, debug);
+ handlers.add((CalSvcDb)sysparsHandler);
+ }
+
+ return sysparsHandler;
+ }
+
/* (non-Javadoc)
* @see org.bedework.calsvci.CalSvcI#getMailer()
*/
@@ -1984,6 +1996,8 @@
cali.open(); // Just for the user interactions
cali.beginTransaction();
+ publicUserAccount = getSysparsHandler().get().getPublicUser();
+
if (pars.getCalSuite() != null) {
BwCalSuite cs = CalSuites.fetch(cali.getDbSession(),
pars.getCalSuite());
@@ -2012,11 +2026,11 @@
}
}
- boolean userCreated = cali.init(systemName, null, pars.getAuthUser(),
+ boolean userCreated = cali.init(getSysparsHandler().get(),
+ null, pars.getAuthUser(),
pars.getUser(), pars.getPublicAdmin(),
getDirectories(), debug);
- publicUserAccount = cali.getSyspars().getPublicUser();
BwUser user;
if (!pars.getPublicAdmin() && !pars.isGuest()) {
@@ -2563,7 +2577,7 @@
return;
}
- val.setUid(guidPrefix + getCal().getSysid());
+ val.setUid(guidPrefix + getSysparsHandler().getSysid());
}
/** Set the owner and creator on a shareable entity.
Added: trunk/calsvc/src/org/bedework/calsvc/Syspars.java
===================================================================
--- trunk/calsvc/src/org/bedework/calsvc/Syspars.java (rev 0)
+++ trunk/calsvc/src/org/bedework/calsvc/Syspars.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -0,0 +1,118 @@
+/*
+ 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.
+
+ 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 Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+
+package org.bedework.calsvc;
+
+import org.bedework.calcorei.HibSession;
+import org.bedework.calfacade.BwSystem;
+import org.bedework.calfacade.BwUser;
+import org.bedework.calfacade.exc.CalFacadeException;
+import org.bedework.calsvci.SysparsI;
+
+/** This acts as an interface to the database for system parameters.
+ *
+ * @author Mike Douglass douglm - rpi.edu
+ */
+class Syspars extends CalSvcDb implements SysparsI {
+ private String systemName;
+
+ private BwSystem syspars;
+
+ Syspars(CalSvc svci, BwUser user, String systemName,
+ boolean debug) {
+ super(svci, user, debug);
+ this.systemName = systemName;
+ }
+
+ public String getSystemName() {
+ return systemName;
+ }
+
+ public BwSystem get() throws CalFacadeException {
+ return get(getSystemName());
+ }
+
+ public BwSystem get(String name) throws CalFacadeException {
+ if (syspars == null) {
+ HibSession sess = getSess();
+
+ sess.namedQuery("getSystemPars");
+
+ sess.setString("name", name);
+
+ syspars = (BwSystem)sess.getUnique();
+
+ if (syspars == null) {
+ throw new CalFacadeException("No system parameters with name " +
+ name);
+ }
+
+ if (debug) {
+ trace("Read system parameters: " + syspars);
+ }
+ }
+ return syspars;
+ }
+
+ public void update(BwSystem val) throws CalFacadeException {
+ HibSession sess = getSess();
+
+ sess.update(val);
+ syspars = null; // Force refresh
+ }
+
+ public String getSysid() throws CalFacadeException {
+ return get().getSystemid();
+ }
+}
Property changes on: trunk/calsvc/src/org/bedework/calsvc/Syspars.java
___________________________________________________________________
Name: svn:eol-style
+ LF
Modified: trunk/calsvci/src/org/bedework/calsvci/CalSvcI.java
===================================================================
--- trunk/calsvci/src/org/bedework/calsvci/CalSvcI.java 2007-09-10 02:55:09 UTC (rev 408)
+++ trunk/calsvci/src/org/bedework/calsvci/CalSvcI.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -276,6 +276,13 @@
* Factory methods
* ==================================================================== */
+ /** Obtain an object which handles system parameters
+ *
+ * @return SysparsI handler
+ * @throws CalFacadeException
+ */
+ public abstract SysparsI getSysparsHandler() throws CalFacadeException;
+
/** Get currently configured mailer.
*
* @return MailerIntf object of class in config
Added: trunk/calsvci/src/org/bedework/calsvci/SysparsI.java
===================================================================
--- trunk/calsvci/src/org/bedework/calsvci/SysparsI.java (rev 0)
+++ trunk/calsvci/src/org/bedework/calsvci/SysparsI.java 2007-09-10 18:36:06 UTC (rev 409)
@@ -0,0 +1,78 @@
+/* **********************************************************************
+ Copyright 2006 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:
+ The above copyright notice and this permission notice appear in all
+ copies and supporting documentation;
+
+ The name, identifiers, and trademarks of Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+package org.bedework.calsvci;
+
+import org.bedework.calfacade.BwSystem;
+import org.bedework.calfacade.exc.CalFacadeException;
+
+import java.io.Serializable;
+
+/** Interface for handling bedework system parameters.
+ *
+ * @author Mike Douglass
+ *
+ */
+public interface SysparsI extends Serializable {
+ /** Retrieve systemName supplied at init
+ *
+ * @return String name
+ */
+ public String getSystemName();
+
+ /** Get the system pars using name supplied at init
+ *
+ * @return BwSystem object
+ * @throws CalFacadeException if not admin
+ */
+ public BwSystem get() throws CalFacadeException;
+
+ /** Get the system pars given name
+ *
+ * @param name
+ * @return BwSystem object
+ * @throws CalFacadeException if not admin
+ */
+ public BwSystem get(String name) throws CalFacadeException;
+
+ /** Update the system pars
+ *
+ * @param val BwSystem object
+ * @throws CalFacadeException if not admin
+ */
+ public void update(BwSystem val) throws CalFacadeException;
+
+ /** Get a name uniquely.identifying this system. This should take the form <br/>
+ * name at host
+ * <br/>where<ul>
+ * <li>name identifies the particular calendar system at the site</li>
+ * <li>host part identifies the domain of the site.</li>..
+ * </ul>
+ *
+ * @return String globally unique system identifier.
+ * @throws CalFacadeException
+ */
+ public String getSysid() throws CalFacadeException;
+}
Property changes on: trunk/calsvci/src/org/bedework/calsvci/SysparsI.java
___________________________________________________________________
Name: svn:eol-style
+ LF
More information about the Bedework-commit
mailing list