diff --git a/src/java/com/threerings/crowd/server/PlaceManager.java b/src/java/com/threerings/crowd/server/PlaceManager.java index 7d3fae225..877ece406 100644 --- a/src/java/com/threerings/crowd/server/PlaceManager.java +++ b/src/java/com/threerings/crowd/server/PlaceManager.java @@ -1,5 +1,5 @@ // -// $Id: PlaceManager.java,v 1.36 2002/09/20 04:53:14 mdb Exp $ +// $Id: PlaceManager.java,v 1.37 2002/10/06 00:44:58 mdb Exp $ package com.threerings.crowd.server; @@ -171,6 +171,22 @@ public class PlaceManager }); } + /** + * Provides an opportunity for place managers to ratify the creation + * of a place based on whatever criterion they may require (based on + * information available to the manager at this post-init() but + * pre-startup() phase of initialization). + * + * @return If a permissions check is to fail, the manager should + * return a translatable string explaining the failure. + * null should be returned if initialization is to be + * allowed to proceed. + */ + public String checkPermissions () + { + return null; + } + /** * Called by the place manager after the place object has been * successfully created. diff --git a/src/java/com/threerings/crowd/server/PlaceRegistry.java b/src/java/com/threerings/crowd/server/PlaceRegistry.java index e6e814567..e314616d0 100644 --- a/src/java/com/threerings/crowd/server/PlaceRegistry.java +++ b/src/java/com/threerings/crowd/server/PlaceRegistry.java @@ -1,5 +1,5 @@ // -// $Id: PlaceRegistry.java,v 1.21 2002/08/14 19:07:49 mdb Exp $ +// $Id: PlaceRegistry.java,v 1.22 2002/10/06 00:44:58 mdb Exp $ package com.threerings.crowd.server; @@ -10,9 +10,10 @@ import com.samskivert.util.Tuple; import com.samskivert.util.Queue; import com.threerings.presents.dobj.DObject; -import com.threerings.presents.dobj.RootDObjectManager; import com.threerings.presents.dobj.ObjectAccessException; +import com.threerings.presents.dobj.RootDObjectManager; import com.threerings.presents.dobj.Subscriber; +import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationManager; import com.threerings.crowd.Log; @@ -81,10 +82,14 @@ public class PlaceRegistry * * @exception InstantiationException thrown if an error occurs trying * to instantiate and initialize the place manager. + * @exception InvocationException thrown if the place manager returns + * failure from the call to {@link PlaceManager#checkPermissions}. The + * error string returned by that call will be provided as in the + * exception. */ public PlaceManager createPlace ( PlaceConfig config, CreationObserver observer) - throws InstantiationException + throws InstantiationException, InvocationException { try { // load up the manager class @@ -94,6 +99,13 @@ public class PlaceRegistry // let the pmgr know about us and its configuration pmgr.init(this, _invmgr, _omgr, config); + // give the manager an opportunity to abort the whole process + // if it fails any permissions checks + String errmsg = pmgr.checkPermissions(); + if (errmsg != null) { + throw new InvocationException(errmsg); + } + // stick the manager on the creation queue because we know // we'll get our calls to objectAvailable()/requestFailed() in // the order that we call createObject() diff --git a/src/java/com/threerings/whirled/server/SceneRegistry.java b/src/java/com/threerings/whirled/server/SceneRegistry.java index 12a42db86..3791d27c1 100644 --- a/src/java/com/threerings/whirled/server/SceneRegistry.java +++ b/src/java/com/threerings/whirled/server/SceneRegistry.java @@ -1,5 +1,5 @@ // -// $Id: SceneRegistry.java,v 1.16 2002/08/14 19:07:57 mdb Exp $ +// $Id: SceneRegistry.java,v 1.17 2002/10/06 00:44:58 mdb Exp $ package com.threerings.whirled.server; @@ -209,9 +209,9 @@ public class SceneRegistry // will call back to the scene registry and let us know that // we can turn the penders loose - } catch (InstantiationException ie) { + } catch (Exception e) { // so close, but no cigar - processFailedResolution(model.sceneId, ie); + processFailedResolution(model.sceneId, e); } }