Author: heiko.braun(a)jboss.com
Date: 2008-12-03 08:19:19 -0500 (Wed, 03 Dec 2008)
New Revision: 3181
Added:
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/ConsoleConfig.java
Modified:
projects/gwt-console/trunk/war/src/main/java/jmaki/xhp/XmlHttpProxyServlet.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/MainView.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
projects/gwt-console/trunk/war/src/main/resources/jmaki/xhp/xhp.json
projects/gwt-console/trunk/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml
projects/gwt-console/trunk/war/src/main/resources/org/jboss/bpm/console/public/Application.html
Log:
Fix JBPM-1896: Make integration URL's configurable
Modified: projects/gwt-console/trunk/war/src/main/java/jmaki/xhp/XmlHttpProxyServlet.java
===================================================================
---
projects/gwt-console/trunk/war/src/main/java/jmaki/xhp/XmlHttpProxyServlet.java 2008-12-03
13:17:22 UTC (rev 3180)
+++
projects/gwt-console/trunk/war/src/main/java/jmaki/xhp/XmlHttpProxyServlet.java 2008-12-03
13:19:19 UTC (rev 3181)
@@ -30,7 +30,7 @@
private static boolean allowXDomain = false;
private static boolean requireSession = false;
private static boolean createSession = false;
- private static String responseContentType =
"application/json;charset=UTF-8";
+ private static String defaultContentType =
"application/json;charset=UTF-8";
private static boolean rDebug = false;
private Logger logger = null;
private XmlHttpProxy xhp = null;
@@ -52,7 +52,7 @@
ctx = config.getServletContext();
// set the response content type
if (ctx.getInitParameter("responseContentType") != null) {
- responseContentType = ctx.getInitParameter("responseContentType");
+ defaultContentType = ctx.getInitParameter("responseContentType");
}
// allow for resources dir over-ride at the xhp level otherwise allow
// for the jmaki level resources
@@ -243,11 +243,14 @@
if("xtest-pass".equals(name)) password =
req.getHeader("xtest-pass");
}
}
+
+ String contentType = null;
try
{
String actualServiceKey = serviceKey != null ? serviceKey :
"default";
if (services.has(actualServiceKey))
{
+
JSONObject service = services.getJSONObject(actualServiceKey);
String serviceURL = service.getString("url");
if(null==serviceURL)
@@ -256,6 +259,8 @@
if (service.has("passthrough")) passthrough =
Boolean.valueOf(service.getString("passthrough"));
+ if(service.has("contentType")) contentType =
service.getString("contentType");
+
if (service.has("username")) userName =
service.getString("username");
if (service.has("password")) password =
service.getString("password");
@@ -339,7 +344,9 @@
urlString = processURL(urlString, req, res);
}
// default to JSON
- res.setContentType(responseContentType);
+ String actualContentType = contentType!=null ? contentType :
defaultContentType;
+ res.setContentType(actualContentType);
+
out = res.getOutputStream();
// get the stream for the xsl stylesheet
if (xslURLString != null) {
Added:
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/ConsoleConfig.java
===================================================================
---
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/ConsoleConfig.java
(rev 0)
+++
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/ConsoleConfig.java 2008-12-03
13:19:19 UTC (rev 3181)
@@ -0,0 +1,70 @@
+/*
+ * 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.i18n.client.Dictionary;
+
+/**
+ * Initialize console config from host page (<code>Application.html</code>)
variable:
+ * <pre>
+ * var consoleConfig = {
+ consoleServerUrl: "http://localhost:8080/gwt-console-server",
+ reportServerUrl: "http://localhost:8080/report"
+ };
+ * </pre>
+ *
+ * @see com.google.gwt.i18n.client.Dictionary
+ *
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class ConsoleConfig
+{
+ private String consoleServerUrl;
+ private String reportServerUrl;
+
+ public ConsoleConfig()
+ {
+ Dictionary theme = Dictionary.getDictionary("consoleConfig");
+ consoleServerUrl = theme.get("consoleServerUrl");
+ reportServerUrl = theme.get("reportServerUrl");
+ }
+
+ public String getConsoleServerUrl()
+ {
+ return consoleServerUrl;
+ }
+
+ public void setConsoleServerUrl(String consoleServerUrl)
+ {
+ this.consoleServerUrl = consoleServerUrl;
+ }
+
+ public String getReportServerUrl()
+ {
+ return reportServerUrl;
+ }
+
+ public void setReportServerUrl(String reportServerUrl)
+ {
+ this.reportServerUrl = reportServerUrl;
+ }
+}
Modified:
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/MainView.java
===================================================================
---
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/MainView.java 2008-12-03
13:17:22 UTC (rev 3180)
+++
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/MainView.java 2008-12-03
13:19:19 UTC (rev 3181)
@@ -63,13 +63,22 @@
private Authentication auth;
+ public boolean isAttached()
+ {
+ return super.isAttached(); //To change body of overridden methods use File |
Settings | File Templates.
+ }
+
public MainView()
{
+ ConsoleConfig config = new ConsoleConfig();
+
if(!GWT.isScript()) // hosted mode used proxy by default
- urlBuilder = new URLBuilder(GWT.getModuleBaseURL(), "xhp");
- else
- urlBuilder = new URLBuilder( "http://localhost:8080",
"gwt-console-server"); // TODO: make configureable
+ config.setConsoleServerUrl(GWT.getModuleBaseURL()+"xhp");
+ ConsoleLog.debug("Console server: " + config.getConsoleServerUrl());
+ ConsoleLog.debug("Report server: " + config.getReportServerUrl());
+
+ urlBuilder = new URLBuilder(config);
Panel mainPanel = createMainPanel();
assembleMainApplication(mainPanel);
forceLogin(mainPanel);
Modified:
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
===================================================================
---
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2008-12-03
13:17:22 UTC (rev 3180)
+++
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2008-12-03
13:19:19 UTC (rev 3181)
@@ -21,7 +21,6 @@
*/
package org.jboss.bpm.console.client;
-import org.jboss.bpm.console.client.util.ConsoleLog;
import com.google.gwt.http.client.URL;
import org.jboss.bpm.console.client.model.ProcessInstanceRef;
import org.jboss.bpm.console.client.model.jbpm3.TokenReference;
@@ -31,40 +30,26 @@
*/
public class URLBuilder
{
- private final String consoleServerUrl;
- private final String webContext;
+ ConsoleConfig config;
- public URLBuilder(String consoleServerUrl, String webContext)
+ public URLBuilder(ConsoleConfig config)
{
- this.consoleServerUrl = consoleServerUrl;
- this.webContext = webContext;
-
- ConsoleLog.debug("Using gwt-console-server: " + getBaseUrl());
+ this.config = config;
}
public String getConsoleServerUrl()
{
- return consoleServerUrl;
+ return config.getConsoleServerUrl();
}
- public String getWebContext()
- {
- return webContext;
- }
-
- private String getBaseUrl()
- {
- return consoleServerUrl + "/" + webContext;
- }
-
public String getProcessDefinitionURL()
{
- return getBaseUrl() + "/rs/process/definitions";
+ return getConsoleServerUrl() + "/rs/process/definitions";
}
public String getProcessInstanceURL(long processId)
{
- return getBaseUrl() +
"/rs/process/definitions/"+processId+"/instances";
+ return getConsoleServerUrl() +
"/rs/process/definitions/"+processId+"/instances";
}
public String getUserInRoleURL(String[] possibleRoles)
@@ -76,104 +61,104 @@
if(i<possibleRoles.length-1)
sb.append(",");
}
- return getBaseUrl() +
"/rs/identity/user/roles?roleCheck="+sb.toString();
+ return getConsoleServerUrl() +
"/rs/identity/user/roles?roleCheck="+sb.toString();
}
@Deprecated
public String getRemoveDefinitionURL(long processId)
{
- return getBaseUrl() + "/rs/process/definitions/" + processId +
"/remove";
+ return getConsoleServerUrl() + "/rs/process/definitions/" + processId +
"/remove";
}
public String getProcessImageURL(long processId)
{
- return getBaseUrl() + "/rs/jbpm3/definitions/" + processId +
"/image";
+ return getConsoleServerUrl() + "/rs/jbpm3/definitions/" + processId +
"/image";
}
public String getDiagramInfoURL(long processId)
{
- return getBaseUrl() + "/rs/jbpm3/definitions/" + processId +
"/diagramInfo";
+ return getConsoleServerUrl() + "/rs/jbpm3/definitions/" + processId +
"/diagramInfo";
}
public String getActiveNodeInfoURL(long instanceId)
{
- return getBaseUrl() + "/rs/jbpm3/instances/" + instanceId +
"/activeNodeInfo";
+ return getConsoleServerUrl() + "/rs/jbpm3/instances/" + instanceId +
"/activeNodeInfo";
}
public String getStateChangeURL(long instanceId, ProcessInstanceRef.STATE state)
{
- return getBaseUrl() + "/rs/process/instances/" + instanceId +
"/state/"+state;
+ return getConsoleServerUrl() + "/rs/process/instances/" + instanceId +
"/state/"+state;
}
public String getStartNewInstanceURL(long processId)
{
- return getBaseUrl() +
"/rs/process/definitions/"+processId+"/instances/new";
+ return getConsoleServerUrl() +
"/rs/process/definitions/"+processId+"/instances/new";
}
public String getUploadDefinitionURL()
{
- return getBaseUrl() + "/rs/jbpm3/definitions/new";
+ return getConsoleServerUrl() + "/rs/jbpm3/definitions/new";
}
public String getTaskListByActorURL(String actor)
{
- return getBaseUrl() + "/rs/tasks/actor/"+URL.encode(actor);
+ return getConsoleServerUrl() + "/rs/tasks/actor/"+URL.encode(actor);
}
public String getTaskFormDefURL(long processId, long taskId)
{
- return getBaseUrl() + "/rs/tasks/forms/"+processId+"/"+taskId;
+ return getConsoleServerUrl() +
"/rs/tasks/forms/"+processId+"/"+taskId;
}
public String getTaskEndURL(long id)
{
- return getBaseUrl() +
"/rs/tasks/"+id+"/close/transition/default";
+ return getConsoleServerUrl() +
"/rs/tasks/"+id+"/close/transition/default";
}
public String getTaskEndURL(long id, String signalName)
{
- return getBaseUrl() +
"/rs/tasks/"+id+"/close/transition?signal=" + URL.encode(signalName);
+ return getConsoleServerUrl() +
"/rs/tasks/"+id+"/close/transition?signal=" + URL.encode(signalName);
}
public String getTaskAssignmentURL(long id, String actor)
{
String actualActor = actor == null ? "" : "/"+actor;
- return getBaseUrl() +
"/rs/tasks/"+id+"/assignment"+URL.encode(actualActor);
+ return getConsoleServerUrl() +
"/rs/tasks/"+id+"/assignment"+URL.encode(actualActor);
}
public String getTokenSignalUrl(TokenReference tok)
{
- return getBaseUrl() +
"/rs/jbpm3/tokens/"+tok.getId()+"/transition/default";
+ return getConsoleServerUrl() +
"/rs/jbpm3/tokens/"+tok.getId()+"/transition/default";
}
public String getTokenSignalUrl(TokenReference tok, String signal)
{
String encodedSignal = URL.encode(signal);
- return getBaseUrl() +
"/rs/jbpm3/tokens/"+tok.getId()+"/transition?signal="+encodedSignal;
+ return getConsoleServerUrl() +
"/rs/jbpm3/tokens/"+tok.getId()+"/transition?signal="+encodedSignal;
}
public String getAvailableActorsUrl(String actorId)
{
- return getBaseUrl() + "/rs/identity/user/"+actorId+"/actors";
+ return getConsoleServerUrl() +
"/rs/identity/user/"+actorId+"/actors";
}
public String getProcessDefinitionByNameURL(String name)
{
- return getBaseUrl() + "/rs/process/definitions/"+name;
+ return getConsoleServerUrl() + "/rs/process/definitions/"+name;
}
public String getDeployTestHarnessUrl()
{
- return getBaseUrl()+ "/rs/test/deploy/harness";
+ return getConsoleServerUrl()+ "/rs/test/deploy/harness";
}
public String getUndeployTestHarnessUrl()
{
- return getBaseUrl()+ "/rs/test/undeploy/harness";
+ return getConsoleServerUrl()+ "/rs/test/undeploy/harness";
}
public String getDefaultReportUrl()
{
- return
getBaseUrl()+"/run?__report=process_activity.rptdesign&id=birt";
+ return
config.getReportServerUrl()+"/preview?__report=process_activity.rptdesign";
}
}
Modified: projects/gwt-console/trunk/war/src/main/resources/jmaki/xhp/xhp.json
===================================================================
--- projects/gwt-console/trunk/war/src/main/resources/jmaki/xhp/xhp.json 2008-12-03
13:17:22 UTC (rev 3180)
+++ projects/gwt-console/trunk/war/src/main/resources/jmaki/xhp/xhp.json 2008-12-03
13:19:19 UTC (rev 3181)
@@ -8,8 +8,9 @@
"password":"manager"
},
{"id": "birt",
- "url":"http://localhost:8080/birt-viewer",
- "passthrough":true
+ "url":"http://localhost:8080/report",
+ "passthrough":true,
+ "contentType":"text/html"
}
]
}
Modified:
projects/gwt-console/trunk/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml
===================================================================
---
projects/gwt-console/trunk/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml 2008-12-03
13:17:22 UTC (rev 3180)
+++
projects/gwt-console/trunk/war/src/main/resources/org/jboss/bpm/console/Application.gwt.xml 2008-12-03
13:19:19 UTC (rev 3181)
@@ -3,6 +3,7 @@
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<inherits name='com.google.gwt.json.JSON'/>
+ <inherits name="com.google.gwt.i18n.I18N"/>
<inherits name='com.gwtext.GwtExt' />
<inherits name='com.googlecode.gchart.GChart'/>
Modified:
projects/gwt-console/trunk/war/src/main/resources/org/jboss/bpm/console/public/Application.html
===================================================================
---
projects/gwt-console/trunk/war/src/main/resources/org/jboss/bpm/console/public/Application.html 2008-12-03
13:17:22 UTC (rev 3180)
+++
projects/gwt-console/trunk/war/src/main/resources/org/jboss/bpm/console/public/Application.html 2008-12-03
13:19:19 UTC (rev 3181)
@@ -1,15 +1,24 @@
<html>
- <head>
- <title>GWT Console Application</title>
-<!-- -->
-<!-- This script loads your compiled module. -->
-<!-- If you add any GWT meta tags, they must -->
-<!-- be added before this line. -->
-<!-- -->
-<script language='javascript'
- src='org.jboss.bpm.console.Application.nocache.js'></script>
- <meta name="gwt:property" id="bpm-server-url"
content="localhost:8080"/>
- <link rel="stylesheet" href="console.css"
type="text/css">
+<head>
+ <title>GWT Console Application</title>
+
+ <!-- BPM console configuration -->
+ <script type="text/javascript">
+ var consoleConfig = {
+ consoleServerUrl: "http://localhost:8080/gwt-console-server",
+ reportServerUrl: "http://localhost:8080/report"
+ };
+ </script>
+
+ <!-- -->
+ <!-- This script loads your compiled module. -->
+ <!-- If you add any GWT meta tags, they must -->
+ <!-- be added before this line. -->
+ <!-- -->
+ <script language='javascript'
src='org.jboss.bpm.console.Application.nocache.js'/>
+
+ <link rel="stylesheet" href="console.css"
type="text/css">
+
</head>
<!-- -->
@@ -21,13 +30,6 @@
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame"
style="width: 0; height: 0; border: 0"></iframe>
-<!--table align=center>
- <tr align="center">
- <td>GWT Console<hr/></td>
- </tr>
- <tr align="center">
- <td id="mainpanel"></td>
- </tr>
-</table-->
+
</body>
</html>