Revision: 3877
Author: [email protected]
Date: Thu Aug 12 11:32:38 2010
Log: NEW - bug 2943: Max Named Users is not checked
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2943
The number of users is now respected for the license file. If the user
tries to create more users than their license allows the transaction is
rejected with a friendly error message.
With this fix comes another fix on the error messages. Previously if a
friendly error message was sent from the server the NetworkConflictResolver
would catch it and display a friendly dialog. However, the persistence
layer was relying on an exception being thrown to interrupt the commit and
cause a correct roll back which was not being thrown. This caused the
commit to continue after some objects rolled back and a commit be sent to
persisters that had their transaction count set to 0 from the rollback. Now
these exceptions move up the stack and there is a new exception handler
that displays nicer dialogs for friendly exceptions that we have defined to
be user errors.
http://code.google.com/p/power-architect/source/detail?r=3877
Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ExceptionHandler.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/SecurityPanel.java
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java
Fri Jul 30 08:41:45 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java
Thu Aug 12 11:32:38 2010
@@ -43,6 +43,7 @@
import ca.sqlpower.architect.swingui.PlayPenComponent;
import ca.sqlpower.architect.swingui.PlayPenContentPane;
+import ca.sqlpower.dao.FriendlyRuntimeSPPersistenceException;
import ca.sqlpower.dao.MessageSender;
import ca.sqlpower.dao.PersistedSPOProperty;
import ca.sqlpower.dao.PersistedSPObject;
@@ -260,17 +261,7 @@
//push the persist forward again.
if (!response.isSuccessful() && response.getStatusCode()
== 412) {
logger.info("Friendly error occurred, " + response);
- if (upf != null) {
- upf.createUserPrompter(
- response.getBody(),
- UserPromptType.MESSAGE,
- UserPromptOptions.OK,
- UserPromptResponse.OK,
- "OK", "OK").promptUser("");
- } else {
- logger.warn("Missing a prompt session! Message
was " + response);
- }
- return;
+ throw new
FriendlyRuntimeSPPersistenceException(response.getBody());
}
String json;
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/ExceptionHandler.java
Mon Jul 12 08:21:11 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/ExceptionHandler.java
Thu Aug 12 11:32:38 2010
@@ -49,7 +49,7 @@
/**
* The session that this exception was caused in.
*/
- private ArchitectSwingSessionContext context;
+ protected final ArchitectSwingSessionContext context;
/**
* The exception handler is used for handling uncaught exceptions.
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/SecurityPanel.java
Thu Aug 12 09:22:38 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/SecurityPanel.java
Thu Aug 12 11:32:38 2010
@@ -163,18 +163,19 @@
user.addGrant(new Grant(category, true, true,
true, true, true));
securityWorkspace.addChild(category,
securityWorkspace.getChildren(DomainCategory.class).size());
securityWorkspace.commit();
-
- refreshTree();
- Enumeration<DefaultMutableTreeNode> userNodes =
usersNode.children();
- while (userNodes.hasMoreElements()) {
- DefaultMutableTreeNode dmtn =
userNodes.nextElement();
- if (((User)
dmtn.getUserObject()).getUUID().equals(user.getUUID())) {
- tree.setSelectionPath(new
TreePath(dmtn.getPath()));
- }
- }
} catch (Exception ex) {
+ securityWorkspace.rollback(ex.getMessage());
throw new RuntimeException(ex);
}
+
+ refreshTree();
+ Enumeration<DefaultMutableTreeNode> userNodes =
usersNode.children();
+ while (userNodes.hasMoreElements()) {
+ DefaultMutableTreeNode dmtn =
userNodes.nextElement();
+ if (((User)
dmtn.getUserObject()).getUUID().equals(user.getUUID())) {
+ tree.setSelectionPath(new
TreePath(dmtn.getPath()));
+ }
+ }
}
}
}