[jbpm-commits] JBoss JBPM SVN: r2509 - in jbpm3/trunk/modules/gwt-console: rpc/src/main/java/org/jboss/bpm/console/client/model and 6 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Oct 8 09:24:59 EDT 2008
Author: heiko.braun at jboss.com
Date: 2008-10-08 09:24:59 -0400 (Wed, 08 Oct 2008)
New Revision: 2509
Added:
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignment.java
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignmentWrapper.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java
Removed:
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/ProcessManagementService.java
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/ProcessManagementServiceAsync.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagementApplication.java
Modified:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/GWTJsonFilter.java
jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/web.xml
jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Config.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/ConsoleView.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/MainMenu.java
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/console.css
Log:
Login screen and authorization, first cut
Deleted: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/ProcessManagementService.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/ProcessManagementService.java 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/ProcessManagementService.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.console.client;
-
-import com.google.gwt.user.client.rpc.RemoteService;
-
-import java.util.List;
-
-import org.jboss.bpm.console.client.model.ProcessDefinition;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public interface ProcessManagementService extends RemoteService
-{
- List<ProcessDefinition> getAllProcessDefinitions();
-}
Deleted: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/ProcessManagementServiceAsync.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/ProcessManagementServiceAsync.java 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/ProcessManagementServiceAsync.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.console.client;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public interface ProcessManagementServiceAsync
-{
- void getAllProcessDefinitions(AsyncCallback async);
-}
Added: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignment.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignment.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignment.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.model;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at XmlRootElement(name = "roleAssignment")
+public class RoleAssignment
+{
+ private String role;
+ private boolean isAssigned;
+
+
+ public RoleAssignment()
+ {
+ }
+
+ public RoleAssignment(String role, boolean assigned)
+ {
+ this.role = role;
+ isAssigned = assigned;
+ }
+
+ @XmlElement(name = "role")
+ public String getRole()
+ {
+ return role;
+ }
+
+ public void setRole(String role)
+ {
+ this.role = role;
+ }
+
+ @XmlElement(name = "assigned")
+ public boolean isAssigned()
+ {
+ return isAssigned;
+ }
+
+ public void setAssigned(boolean assigned)
+ {
+ isAssigned = assigned;
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignment.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignmentWrapper.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignmentWrapper.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignmentWrapper.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at XmlRootElement(name = "wrapper")
+public class RoleAssignmentWrapper
+{
+ List<RoleAssignment> roles;
+
+ public RoleAssignmentWrapper()
+ {
+ }
+
+ public RoleAssignmentWrapper(List<RoleAssignment> roles)
+ {
+ this.roles = roles;
+ }
+
+ public List<RoleAssignment> getRoles()
+ {
+ return roles;
+ }
+
+ public void setRoles(List<RoleAssignment> roles)
+ {
+ this.roles = roles;
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/RoleAssignmentWrapper.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java (from rev 2494, jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagementApplication.java)
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.server;
+
+import javax.ws.rs.core.Application;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class ConsoleServerApplication extends Application
+{
+ HashSet<Object> singletons = new HashSet<Object>();
+
+ public ConsoleServerApplication()
+ {
+ singletons.add(new ProcessManagement());
+ singletons.add(new UserManagement());
+ }
+
+ @Override
+ public Set<Class<?>> getClasses()
+ {
+ HashSet<Class<?>> set = new HashSet<Class<?>>();
+ return set;
+ }
+
+ @Override
+ public Set<Object> getSingletons()
+ {
+ return singletons;
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/GWTJsonFilter.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/GWTJsonFilter.java 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/GWTJsonFilter.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -45,11 +45,11 @@
throws IOException, ServletException
{
- boolean isGWTRequest = false;
+ boolean isSOPCallback = false;
// identify GWT json requests
if(request.getParameter("callback")!=null)
- isGWTRequest = true;
+ isSOPCallback = true;
// sneak in repsonse wrapper
OutputStream out = response.getOutputStream();
@@ -62,15 +62,27 @@
String contentType = response.getContentType() != null ? response.getContentType() : "application/octet-stream";
boolean isJSONEncoding = contentType.equals("application/json");
StringBuffer sb = null;
- if(isGWTRequest && isJSONEncoding)
+ if(isJSONEncoding)
{
String payload = new String(wrapper.getData());
String gwtextFriendly = trimPayload(payload);
- sb = new StringBuffer(request.getParameter("callback"));
- sb.append("(");
+ sb = new StringBuffer();
+
+ if(isSOPCallback)
+ {
+ sb.append(request.getParameter("callback"));
+ sb.append("(");
+ }
+
+ // Strip wrapper when JSONRequest
sb.append(gwtextFriendly);
- sb.append(");");
+
+ if(isSOPCallback)
+ {
+ sb.append(");");
+ }
+
}
// flush
Deleted: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagementApplication.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagementApplication.java 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagementApplication.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.console.server;
-
-import javax.ws.rs.core.Application;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Heiko.Braun <heiko.braun at jboss.com>
- */
-public class ProcessManagementApplication extends Application
-{
- HashSet<Object> singletons = new HashSet<Object>();
-
- public ProcessManagementApplication()
- {
- singletons.add(new ProcessManagement());
- }
-
- @Override
- public Set<Class<?>> getClasses()
- {
- HashSet<Class<?>> set = new HashSet<Class<?>>();
- return set;
- }
-
- @Override
- public Set<Object> getSingletons()
- {
- return singletons;
- }
-}
Added: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.server;
+
+import org.jboss.bpm.console.client.model.RoleAssignmentWrapper;
+import org.jboss.bpm.console.client.model.RoleAssignment;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+/**
+ * REST server module for accessing user related data.
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+ at Path("user")
+public class UserManagement
+{
+
+ @GET
+ @Path("roles")
+ @Produces("application/json")
+ public RoleAssignmentWrapper getAssignedRoles(
+ @Context
+ HttpServletRequest request,
+ @QueryParam("roleCheck")
+ String roleCheck
+ )
+ {
+ if(null==roleCheck)
+ throw new WebApplicationException( new IllegalArgumentException("Missing parameter 'roleCheck'") );
+
+ System.out.println("Role check user: " + request.getRemoteUser() + ", actualRoles requested: " + roleCheck);
+
+ List<RoleAssignment> actualRoles = new ArrayList<RoleAssignment>();
+
+ StringTokenizer tok = new StringTokenizer(roleCheck, ",");
+ while(tok.hasMoreTokens())
+ {
+ String possibleRole = tok.nextToken();
+ actualRoles.add( new RoleAssignment(possibleRole, request.isUserInRole(possibleRole)));
+ }
+ return new RoleAssignmentWrapper(actualRoles);
+ }
+}
Property changes on: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/UserManagement.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/web.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/web.xml 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/web.xml 2008-10-08 13:24:59 UTC (rev 2509)
@@ -7,7 +7,7 @@
<context-param>
<param-name>javax.ws.rs.core.Application</param-name>
- <param-value>org.jboss.bpm.console.server.ProcessManagementApplication</param-value>
+ <param-value>org.jboss.bpm.console.server.ConsoleServerApplication</param-value>
</context-param>
<context-param>
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-08 13:24:59 UTC (rev 2509)
@@ -31,6 +31,16 @@
<td>application/json, text/html</td>
</tr>
+ <tr>
+ <td colspan=4>User Management</td>
+ </tr>
+
+ <tr>
+ <td>GET</td>
+ <td><a href="/gwt-console-server/rs/user/roles?roleCheck=admin,user">/rs/user/roles?roleCheck=a,b,c</a></td>
+ <td>A list of assigned roles</td>
+ <td>application/json</td>
+ </tr>
</table>
<h2>Example usage</h2>
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Config.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Config.java 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/Config.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -58,4 +58,16 @@
{
return consoleServerUrl + webContext + "/rs/process/definitions/"+processId+"/instances";
}
+
+ public String getUserInRoleURL(String[] possibleRoles)
+ {
+ StringBuffer sb = new StringBuffer();
+ for(int i=0; i<possibleRoles.length; i++)
+ {
+ sb.append(possibleRoles[i]);
+ if(i<possibleRoles.length-1)
+ sb.append(",");
+ }
+ return consoleServerUrl + webContext + "/rs/user/roles?roleCheck="+sb.toString();
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/ConsoleView.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/ConsoleView.java 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/ConsoleView.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -21,53 +21,79 @@
*/
package org.jboss.bpm.console.client;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.http.client.*;
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONParser;
+import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
+import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Margins;
import com.gwtext.client.core.RegionPosition;
-import com.gwtext.client.widgets.Panel;
-import com.gwtext.client.widgets.Viewport;
-import com.gwtext.client.widgets.MessageBox;
-import com.gwtext.client.widgets.MessageBoxConfig;
+import com.gwtext.client.widgets.*;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.layout.BorderLayout;
import com.gwtext.client.widgets.layout.BorderLayoutData;
import com.gwtext.client.widgets.layout.FitLayout;
+import com.gwtext.client.widgets.layout.VerticalLayout;
import org.jboss.bpm.console.client.metric.MetricOverviewEditor;
import org.jboss.bpm.console.client.process.ProcessDefinitionListEditor;
import org.jboss.bpm.console.client.widgets.EditorView;
import org.jboss.bpm.console.client.widgets.UIConstants;
-import org.jboss.bpm.console.client.model.ProcessDefinition;
+import java.util.ArrayList;
+import java.util.List;
+
/**
+ * The main composite that assembles the gwt console application.
+ *
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
public class ConsoleView extends Composite
{
- private Panel mainPanel = new Panel();
- private Panel borderPanel = new Panel();
-
- private HTML status = new HTML();
-
+ private HTML status = new HTML();
private HeaderPanel header;
private MainMenu mainMenu;
private EditorPanel editorPanel;
-
private Config config = new Config();
+ private String[] rolesAssigned = new String[] {};
+ private final static String[] POSSIBLE_ROLES = {"admin", "user"};
+
+ private static final int WIDTH = 1024;
+ private static final int HEIGHT = 768;
+
private Viewport viewport;
-
+
public ConsoleView()
{
+ Panel mainPanel = createMainPanel();
+ assembleMainApplication(mainPanel);
+ forceLogin(mainPanel);
+ viewport = new Viewport(mainPanel);
+ }
+
+ private Panel createMainPanel()
+ {
+ Panel mainPanel = new Panel();
mainPanel.setBorder(false);
mainPanel.setPaddings(5); // outer most padding
mainPanel.setLayout(new FitLayout());
- mainPanel.setWidth(1024);
- mainPanel.setHeight(768);
+ mainPanel.setWidth(WIDTH);
+ mainPanel.setHeight(HEIGHT);
+ mainPanel.hide();
initWidget( mainPanel );
-
- borderPanel.setLayout(new BorderLayout());
+ return mainPanel;
+ }
+ private void assembleMainApplication(Panel mainPanel)
+ {
+ Panel borderPanel = new Panel();
+ borderPanel.setLayout(new BorderLayout());
+
// ------------------------------------------
header = new HeaderPanel(this);
@@ -89,18 +115,116 @@
borderPanel.add(editorPanel, new BorderLayoutData(RegionPosition.CENTER));
// ------------------------------------------
-
+
editorPanel.addEditor( new ProcessDefinitionListEditor(this), false );
editorPanel.addEditor( new MetricOverviewEditor(this), false);
+
+ // ------------------------------------------
+
+ mainPanel.add(borderPanel);
+ }
+
+ private void forceLogin(final Panel mainPanel)
+ {
+ Panel panel = new Panel();
+ panel.setPaddings(20);
+ panel.setStyleName("login-panel-content");
+ panel.setLayout(new VerticalLayout(10));
+ panel.add( new HTML("Welcome, please login.") );
+ final Window window = new Window();
+ window.setTitle("GWT-Console");
+ window.setClosable(false);
+ window.setResizable(false);
+ window.setWidth(300);
+ window.setHeight(180);
+ window.setLayout(new BorderLayout());
+ window.setCloseAction(Window.CLOSE);
+
+ final Button submitBtn = new Button("Login",
+ new ButtonListenerAdapter()
+ {
+ public void onClick(Button button, EventObject e)
+ {
+
+ if(GWT.isScript())
+ {
+ String url = getConfig().getUserInRoleURL(POSSIBLE_ROLES);
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
+
+ try
+ {
+ rb.sendRequest(null,
+ new RequestCallback() {
+
+ public void onResponseReceived(Request request, Response response)
+ {
+ // parse roles
+ List<String> tmp = new ArrayList<String>();
+
+ JSONValue result = JSONParser.parse(response.getText());
+ JSONValue jsonValue = result.isObject().get("roles");
+ JSONArray array = jsonValue.isArray();
+ for (int i = 0; i < array.size(); ++i)
+ {
+ JSONObject item = array.get(i).isObject();
+ String assigned = item.get("assigned").toString();
+ String roleName = item.get("role").toString();
+
+
+ if(assigned.equals("true"))
+ {
+ tmp.add(roleName);
+ }
+
+ }
+
+ rolesAssigned = tmp.toArray(new String[] {});
+
+ window.close();
+ mainPanel.show();
+ mainPanel.doLayout();
+ }
+
+ public void onError(Request request, Throwable t)
+ {
+ // auth failed
+ setError("Authentication failed.");
+ t.printStackTrace(System.out);
+ }
+ });
+ }
+ catch (RequestException e1)
+ {
+ setError(e1.getMessage());
+ e1.printStackTrace();
+ }
+ }
+ else
+ {
+ // hosted mode roles grant any role
+ // will popup BASIC Auth windows when required
+ rolesAssigned = POSSIBLE_ROLES;
+
+ window.close();
+ mainPanel.show();
+ mainPanel.doLayout();
+ }
+ }
+ });
+
+ panel.add(submitBtn);
+
+ BorderLayoutData centerData = new BorderLayoutData(RegionPosition.CENTER);
+ centerData.setMargins(3, 0, 3, 3);
+
+ window.add(panel, centerData);
// ------------------------------------------
- mainPanel.add(borderPanel);
-
- // auto viewport and js init
- viewport = new Viewport(mainPanel);
+ window.show();
}
+
public void addEditorView(EditorView editorView)
{
editorPanel.addEditor(editorView, true);
@@ -118,17 +242,23 @@
public void showEditor(String id)
{
- editorPanel.showTab(id);
+ editorPanel.showTab(id);
}
public void setError(final String error)
{
- status.setText(error);
+ displayMessage(error, true);
+ }
+ public void displayMessage(final String message, final boolean isError)
+ {
+ status.setText(message);
+
MessageBox.show(new MessageBoxConfig() {
{
- setTitle("Unknown Error");
- setMsg(error);
+ String title = isError ? "Unknown error" : "System Message";
+ setTitle(title);
+ setMsg(message);
setButtons(MessageBox.OK);
setCallback(new MessageBox.PromptCallback()
{
@@ -139,4 +269,9 @@
}
});
}
+
+ public String[] getRolesAssigned()
+ {
+ return rolesAssigned;
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/MainMenu.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/MainMenu.java 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/MainMenu.java 2008-10-08 13:24:59 UTC (rev 2509)
@@ -28,6 +28,7 @@
import com.gwtext.client.widgets.tree.TreeNode;
import com.gwtext.client.widgets.tree.TreePanel;
import com.gwtext.client.widgets.tree.event.TreeNodeListenerAdapter;
+import com.google.gwt.user.client.ui.HTML;
import org.jboss.bpm.console.client.metric.MetricOverviewEditor;
import org.jboss.bpm.console.client.process.ProcessDefinitionListEditor;
import org.jboss.bpm.console.client.widgets.MainMenuPanel;
@@ -51,10 +52,10 @@
this.setWidth(200);
this.setLayout(accordion);
- Panel navPanel = new MainMenuPanel("Process Management", "bpm-process-icon", new ProcessTree());
+ Panel navPanel = new MainMenuPanel("Process Management", "bpm-process-icon", new ProcessTree());
Panel taskPanel = new MainMenuPanel("Task Management", "bpm-task-icon", null);
Panel metricPanel = new MainMenuPanel("Metrics and Stats", "bpm-metric-icon", new MetricTree());
- Panel settingsPanel = new MainMenuPanel("Settings", "bpm-settings-icon", null);
+ Panel settingsPanel = new MainMenuPanel("Settings", "bpm-settings-icon", new SettingsTree());
this.add(navPanel);
this.add(taskPanel);
@@ -72,7 +73,7 @@
TreeNode definitions = new TreeNode("View definitions");
definitions.setExpanded(true);
definitions.addListener(
- new TreeNodeListenerAdapter()
+ new TreeNodeListenerAdapter()
{
public void onClick(Node node, EventObject eventObject)
{
@@ -94,7 +95,7 @@
root.appendChild(definitions);
root.appendChild(upload);
- setRootVisible(true);
+ setRootVisible(true);
setRootNode(root);
root.setExpanded(true);
}
@@ -132,11 +133,44 @@
root.appendChild(overview);
root.appendChild(export);
+
+ setRootVisible(true);
+ setRootNode(root);
+ root.setExpanded(true);
+ }
+ }
+
+ class SettingsTree extends TreePanel
+ {
+
+ public SettingsTree()
+ {
+ TreeNode root = new TreeNode("Debug");
+
+ TreeNode overview = new TreeNode("Assigned roles");
+ overview.setExpanded(true);
+ overview.addListener(
+ new TreeNodeListenerAdapter()
+ {
+ public void onClick(Node node, EventObject eventObject)
+ {
+ StringBuffer sb = new StringBuffer();
+ for(String roleName : view.getRolesAssigned())
+ {
+ sb.append(roleName).append("/");
+ }
+
+ view.displayMessage("Assigned roles: " + sb.toString(), false);
+ }
+ }
+ );
+
+ root.appendChild(overview);
setRootVisible(true);
setRootNode(root);
root.setExpanded(true);
+
}
}
-
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml 2008-10-08 13:24:59 UTC (rev 2509)
@@ -2,6 +2,7 @@
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
+ <inherits name='com.google.gwt.json.JSON'/>
<inherits name='com.gwtext.GwtExt' />
<inherits name='com.googlecode.gchart.GChart'/>
<inherits name='org.gwtwidgets.WidgetLibrary'/>
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/console.css
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/console.css 2008-10-08 11:24:25 UTC (rev 2508)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/console.css 2008-10-08 13:24:59 UTC (rev 2509)
@@ -95,3 +95,7 @@
.bpm-enalrge-icon {
background-image: url( images/icons/49.png)
}
+
+.login-panel-content {
+ text-align: center;
+}
\ No newline at end of file
More information about the jbpm-commits
mailing list