Revision: 3434
Author: ferguson.sebastian
Date: Tue Apr 6 11:05:39 2010
Log: Improved message dialogs when one cannot connect to a server, and
fixed an issue with the incorrect disabling of the projectsecurity panel
http://code.google.com/p/power-architect/source/detail?r=3434
Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/PrivilegesEditorPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ProjectSecurityPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ServerProjectsManagerPanel.java
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Tue Apr 6 10:20:51 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Tue Apr 6 11:05:39 2010
@@ -226,10 +226,17 @@
new ResponseHandler<DataSourceCollection<JDBCDataSource>>() {
public DataSourceCollection<JDBCDataSource>
handleResponse(HttpResponse response)
throws ClientProtocolException, IOException {
+
+ if (response.getStatusLine().getStatusCode() == 401) {
+ throw new AccessDeniedException("Access Denied");
+ }
+
if (response.getStatusLine().getStatusCode() != 200) {
throw new IOException(
"Server error while reading data sources: " +
response.getStatusLine());
}
+
+
PlDotIni plIni;
try {
plIni = new PlDotIni(
@@ -247,6 +254,8 @@
try {
dataSourceCollection =
executeServerRequest(outboundHttpClient,
projectLocation.getServiceInfo(), "/data-sources/", plIniHandler);
+ } catch (AccessDeniedException e) {
+ throw e;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
@@ -333,8 +342,7 @@
}
return workspaces;
} catch (AccessDeniedException e) {
- session.createUserPrompter("You do not have sufficient privileges
to perform that action.\n" +
- "Please hit the refresh button to re-synchonize with
the server.",
+ session.createUserPrompter("Unable to locate server.",
UserPromptType.MESSAGE,
UserPromptOptions.OK,
UserPromptResponse.OK,
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
Tue Apr 6 10:20:51 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
Tue Apr 6 11:05:39 2010
@@ -64,6 +64,7 @@
import javax.swing.tree.TreePath;
import org.apache.log4j.Logger;
+import org.springframework.security.AccessDeniedException;
import ca.sqlpower.architect.ArchitectProject;
import ca.sqlpower.architect.ArchitectSession;
@@ -134,6 +135,9 @@
import ca.sqlpower.sqlobject.undo.NotifyingUndoManager;
import ca.sqlpower.swingui.SPSUtils;
import ca.sqlpower.swingui.enterprise.client.SPServerInfoManagerPanel;
+import ca.sqlpower.util.UserPrompter.UserPromptOptions;
+import ca.sqlpower.util.UserPrompter.UserPromptResponse;
+import ca.sqlpower.util.UserPrompterFactory.UserPromptType;
/**
* The Main Window for the Architect Application; contains a main() method
that is
@@ -244,27 +248,40 @@
SPServerInfo si = sim.getSelectedServer();
if (si != null) {
- ((ArchitectSwingSessionContextImpl)
session.getContext()).createSecuritySession(si);
-
- final JDialog dialog =
SPSUtils.makeOwnedDialog(ArchitectFrame.this, "Projects");
- Action closeAction = new AbstractAction("Close") {
- public void actionPerformed(ActionEvent e) {
- dialog.dispose();
-
+ boolean accessible = true;
+
+ try {
+ ((ArchitectSwingSessionContextImpl)
session.getContext()).createSecuritySession(si);
+ } catch (AccessDeniedException ex) {
+ session.createUserPrompter("Unable to login to
server.",
+ UserPromptType.MESSAGE,
+ UserPromptOptions.OK,
+ UserPromptResponse.OK,
+ "OK", "OK").promptUser("");
+ accessible = false;
+ }
+
+ if (accessible) {
+ final JDialog dialog =
SPSUtils.makeOwnedDialog(ArchitectFrame.this, "Projects");
+ Action closeAction = new
AbstractAction("Close") {
+ public void actionPerformed(ActionEvent e)
{
+ dialog.dispose();
+
// if (!((JButton)
e.getSource()).getAction().getValue(Action.NAME).equals("Close")) {
// d.dispose();
// }
- }
- };
- ServerProjectsManagerPanel spm = new
ServerProjectsManagerPanel(si, session, session.getContext(),
- ArchitectFrame.this, closeAction);
-
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- dialog.setContentPane(spm.getPanel());
-
- SPSUtils.makeJDialogCancellable(dialog, null);
- dialog.pack();
- dialog.setLocationRelativeTo(ArchitectFrame.this);
- dialog.setVisible(true);
+ }
+ };
+ ServerProjectsManagerPanel spm = new
ServerProjectsManagerPanel(si, session, session.getContext(),
+ ArchitectFrame.this, closeAction);
+
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ dialog.setContentPane(spm.getPanel());
+
+ SPSUtils.makeJDialogCancellable(dialog, null);
+ dialog.pack();
+
dialog.setLocationRelativeTo(ArchitectFrame.this);
+ dialog.setVisible(true);
+ }
} else {
JOptionPane.showMessageDialog(ArchitectFrame.this, "Please select a
server", "", JOptionPane.INFORMATION_MESSAGE);
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java
Tue Apr 6 10:20:51 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java
Tue Apr 6 11:05:39 2010
@@ -36,6 +36,7 @@
import javax.swing.ImageIcon;
import org.apache.log4j.Logger;
+import org.springframework.security.AccessDeniedException;
import ca.sqlpower.architect.ArchitectSession;
import ca.sqlpower.architect.ArchitectSessionContext;
@@ -285,6 +286,8 @@
newSecuritySession.startUpdaterThread();
ArchitectClientSideSession.getSecuritySessions().put(serverInfo.getServerAddress(),
newSecuritySession);
session = newSecuritySession;
+ } catch (AccessDeniedException e) {
+ throw e;
} catch (SQLObjectException e) {
throw new RuntimeException("Unable to create security
session!!!", e);
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/PrivilegesEditorPanel.java
Tue Apr 6 10:20:51 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/PrivilegesEditorPanel.java
Tue Apr 6 11:05:39 2010
@@ -166,7 +166,7 @@
if (!doesNotRequireSave) {
Grant newGrant = new Grant(
- subject, type,
+ subject, subject != null ? null : type,
createPrivilege.isSelected(),
modifyPrivilege.isSelected(),
deletePrivilege.isSelected(),
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ProjectSecurityPanel.java
Tue Apr 6 10:20:51 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ProjectSecurityPanel.java
Tue Apr 6 11:05:39 2010
@@ -373,8 +373,8 @@
if (subject != null) {
for (final SPObject object : objectsWithSpecificGrants) {
// can pass in null, it will just be empty
- final PrivilegesEditorPanel specific = new
PrivilegesEditorPanel(specificGrants.get(object), object,
subject.getUUID(), null, username, securityWorkspace);
- final PrivilegesEditorPanel global = new
PrivilegesEditorPanel(globalGrants.get(object), object, subject.getUUID(),
null, username, securityWorkspace);
+ final PrivilegesEditorPanel specific = new
PrivilegesEditorPanel(specificGrants.get(object), object,
subject.getUUID(), ArchitectProject.class.getName(), username,
securityWorkspace);
+ final PrivilegesEditorPanel global = new
PrivilegesEditorPanel(globalGrants.get(object), object, subject.getUUID(),
ArchitectProject.class.getName(), username, securityWorkspace);
panels.add(specific);
panels.add(global);
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ServerProjectsManagerPanel.java
Tue Apr 6 10:20:51 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ServerProjectsManagerPanel.java
Tue Apr 6 11:05:39 2010
@@ -42,6 +42,8 @@
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
+import org.springframework.security.AccessDeniedException;
+
import ca.sqlpower.architect.ArchitectSession;
import ca.sqlpower.architect.ArchitectSessionContext;
import ca.sqlpower.architect.enterprise.ArchitectClientSideSession;
@@ -50,6 +52,9 @@
import ca.sqlpower.architect.swingui.ArchitectSwingSessionContextImpl;
import ca.sqlpower.architect.swingui.ArchitectSwingSessionImpl;
import ca.sqlpower.enterprise.client.SPServerInfo;
+import ca.sqlpower.util.UserPrompter.UserPromptOptions;
+import ca.sqlpower.util.UserPrompter.UserPromptResponse;
+import ca.sqlpower.util.UserPrompterFactory.UserPromptType;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.CellConstraints;
@@ -371,19 +376,32 @@
if (serviceInfo != null) {
try {
- ((ArchitectSwingSessionContextImpl)
context).createSecuritySession(serviceInfo);
-
- // Sorts the project locations alphabetically
- List<ProjectLocation> projects =
ArchitectClientSideSession.getWorkspaceNames(serviceInfo, session);
- Collections.sort(projects, new
Comparator<ProjectLocation>() {
- public int compare(ProjectLocation proj1,
ProjectLocation proj2) {
- return
proj1.getName().toUpperCase().compareTo(proj2.getName().toUpperCase());
- }
- });
-
- for (ProjectLocation pl : projects) {
- model.addElement(pl);
- }
+ boolean accessible = true;
+
+ try {
+ ((ArchitectSwingSessionContextImpl)
session.getContext()).createSecuritySession(serviceInfo);
+ } catch (AccessDeniedException ex) {
+ session.createUserPrompter("Unable to login to
server.",
+ UserPromptType.MESSAGE,
+ UserPromptOptions.OK,
+ UserPromptResponse.OK,
+ "OK", "OK").promptUser("");
+ accessible = false;
+ }
+
+ if (accessible) {
+ // Sorts the project locations alphabetically
+ List<ProjectLocation> projects =
ArchitectClientSideSession.getWorkspaceNames(serviceInfo, session);
+ Collections.sort(projects, new
Comparator<ProjectLocation>() {
+ public int compare(ProjectLocation proj1,
ProjectLocation proj2) {
+ return
proj1.getName().toUpperCase().compareTo(proj2.getName().toUpperCase());
+ }
+ });
+
+ for (ProjectLocation pl : projects) {
+ model.addElement(pl);
+ }
+ }
connected = true;
} catch (Exception ex) {
--
To unsubscribe, reply using "remove me" as the subject.