Author: jvelociter
Date: 2008-01-29 11:47:34 +0100 (Tue, 29 Jan 2008)
New Revision: 7149
Modified:
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManagerException.java
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManagerExtension.java
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerExtensionImpl.java
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
Log:
XPSM-3 preCreateSpace should allow to throw exception
Now the extension can abort the creation process sending an exception, so that
its cause can be known ; instead of silently doing
nothing.
Modified:
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManagerException.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManagerException.java
2008-01-29 02:30:21 UTC (rev 7148)
+++
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManagerException.java
2008-01-29 10:47:34 UTC (rev 7149)
@@ -33,6 +33,7 @@
public static final int ERROR_SPACE_MANAGER_REQUIRES_MAILSENDER_PLUGIN =
100006;
public static final int ERROR_SPACE_SENDING_EMAIL_FAILED = 100007;
public static final int ERROR_SPACE_CANNOT_FIND_EMAIL_ADDRESS = 100008;
+ public static final int ERROR_SPACE_CREATION_ABORTED_BY_EXTENSION = 100009;
public static final int ERROR_VALIDATE_TITLE_TOO_SHORT = 100009;
public static final int ERROR_VALIDATE_TITLE_TOO_LONG = 100010;
Modified:
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManagerExtension.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManagerExtension.java
2008-01-29 02:30:21 UTC (rev 7148)
+++
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/api/SpaceManagerExtension.java
2008-01-29 10:47:34 UTC (rev 7149)
@@ -51,9 +51,9 @@
*
* @param spaceName
* @param context
- * @return If it returns true, it will continue with the space creation,
otherwise it will abord it
+ * @throws SpaceManagerException when aborting the space creation process
*/
- public boolean preCreateSpace(String spaceName, XWikiContext context);
+ public void preCreateSpace(String spaceName, XWikiContext context)
throws SpaceManagerException;
/**
* API called after a space is created
Modified:
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerExtensionImpl.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerExtensionImpl.java
2008-01-29 02:30:21 UTC (rev 7148)
+++
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerExtensionImpl.java
2008-01-29 10:47:34 UTC (rev 7149)
@@ -36,15 +36,10 @@
}
/**
- * API called before the space in created
- *
- * @param spaceName
- * @param context
- * @return
+ * [EMAIL PROTECTED]
*/
- public boolean preCreateSpace(String spaceName, XWikiContext context) {
+ public void preCreateSpace(String spaceName, XWikiContext context)
throws SpaceManagerException {
// @todo: actions done before the creation of the space
- return true;
}
/**
Modified:
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
===================================================================
---
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
2008-01-29 02:30:21 UTC (rev 7148)
+++
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
2008-01-29 10:47:34 UTC (rev 7149)
@@ -481,8 +481,12 @@
Space newspace = newSpace(null, spaceTitle, true, context);
//execute precreate actions
- if( !getSpaceManagerExtension().preCreateSpace(
newspace.getSpaceName(), context ) )
- return null;
+ try {
+ getSpaceManagerExtension().preCreateSpace(
newspace.getSpaceName(), context );
+ }
+ catch (SpaceManagerException e) {
+ throw new
SpaceManagerException(SpaceManagerException.MODULE_PLUGIN_SPACEMANAGER,
SpaceManagerException.ERROR_SPACE_CREATION_ABORTED_BY_EXTENSION, "Space
creation aborted by extension", e);
+ }
// Make sure we set the type
newspace.setType(getSpaceTypeName());
@@ -517,8 +521,12 @@
Space newspace = newSpace(null, spaceTitle, false, context);
//execute precreate actions
- if( !getSpaceManagerExtension().preCreateSpace(
newspace.getSpaceName(), context ) )
- return null;
+ try {
+ getSpaceManagerExtension().preCreateSpace(
newspace.getSpaceName(), context );
+ }
+ catch (SpaceManagerException e) {
+ throw new
SpaceManagerException(SpaceManagerException.MODULE_PLUGIN_SPACEMANAGER,
SpaceManagerException.ERROR_SPACE_CREATION_ABORTED_BY_EXTENSION, "Space
creation aborted by extension", e);
+ }
// Make sure this space does not already exist
if (!newspace.isNew())
@@ -578,8 +586,12 @@
Space newspace = newSpace(null, spaceTitle, true, context);
//execute precreate actions
- if( !getSpaceManagerExtension().preCreateSpace(
newspace.getSpaceName(), context ) )
- return null;
+ try {
+ getSpaceManagerExtension().preCreateSpace(
newspace.getSpaceName(), context );
+ }
+ catch (SpaceManagerException e) {
+ throw new
SpaceManagerException(SpaceManagerException.MODULE_PLUGIN_SPACEMANAGER,
SpaceManagerException.ERROR_SPACE_CREATION_ABORTED_BY_EXTENSION, "Space
creation aborted by extension", e);
+ }
newspace.updateSpaceFromRequest();
if (!newspace.validateSpaceData())
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications