将Activiti Explorer与Ruby on Rails项目集成

时间:2015-10-09 20:31:31

标签: ruby-on-rails iframe mechanize activiti

我尝试了几种不同的方法来实现这一目标,但都没有成功。我试过jruby,其余api for activiti(这不会更新UI因此不适合我的目的),以及机械化宝石。机械化宝石不起作用,因为我认为运动探险家附带的VAADIN UI。我目前在我的rails应用程序中使用iframe托管了activiti,并且我正在尝试找到两者之间的通信方式。我像这样使用了宝石:

agent= Mechanize.new
agent.redirection_limit= 10
//page is used three times to illustrate different routes taken.
page= agent.get('http://127.0.0.1:8080/activiti-webapp-explorer2-5.18.0/)

page= agent.post('http://127.0.0.1:8080/activiti-webapp-explorer2-5.18.0/ui/APP/2/login',{'username'=>'kermit', 'password'=>'kermit'} )

page=agent.put('http://127.0.0.1:8080/activiti-webapp-explorer2-5.18.0/ui/1/loginHandler',{'username'=>'kermit', 'password'=>'kermit'})

这是使用mechanize时来自activiti explorer的示例响应:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">html, body {height:100%;margin:0;}</style><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="/activiti-webapp-explorer2-5.18.0/VAADIN/themes/activiti/favicon.ico" /><link rel="icon" type="image/vnd.microsoft.icon" href="/activiti-webapp-explorer2-5.18.0/VAADIN/themes/activiti/favicon.ico" /><title>Activiti&#32;Explorer</title>
</head>
<body scroll="auto" class="v-generated-body">
<script type="text/javascript">
//<![CDATA[
if(!vaadin || !vaadin.vaadinConfigurations) {
 if(!vaadin) { var vaadin = {}} 
vaadin.vaadinConfigurations = {};
if (!vaadin.themesLoaded) { vaadin.themesLoaded = {}; }
}
vaadin.vaadinConfigurations["activitiwebappexplorer25180ui-1091631569"] = {appUri:'/activiti-webapp-explorer2-5.18.0/ui', standalone: true, themeUri:"/activiti-webapp-explorer2-5.18.0/VAADIN/themes/activiti", versionInfo : {vaadinVersion:"6.8.8",applicationVersion:"NONVERSIONED"},"comErrMsg": {"caption":"Communication problem","message" : "Take note of any unsaved data, and <u>click here<\/u> to continue.","url" : null},"authErrMsg": {"caption":"Authentication problem","message" : "Take note of any unsaved data, and <u>click here<\/u> to continue.","url" : null}};
//]]>
</script>
<iframe tabIndex='-1' id='__gwt_historyFrame' style='position:absolute;width:0;height:0;border:0;overflow:hidden;' src='javascript:false'></iframe>
<script language='javascript' src='/activiti-webapp-explorer2-5.18.0/VAADIN/widgetsets/org.activiti.explorer.CustomWidgetset/org.activiti.explorer.CustomWidgetset.nocache.js?1444407987049'></script>
<script type="text/javascript">
//<![CDATA[
if(!vaadin.themesLoaded['activiti']) {
var stylesheet = document.createElement('link');
stylesheet.setAttribute('rel', 'stylesheet');
stylesheet.setAttribute('type', 'text/css');
stylesheet.setAttribute('href', '/activiti-webapp-explorer2-5.18.0/VAADIN/themes/activiti/styles.css');
document.getElementsByTagName('head')[0].appendChild(stylesheet);
vaadin.themesLoaded['activiti'] = true;
}
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
setTimeout('if (typeof org_activiti_explorer_CustomWidgetset == "undefined") {alert("Failed to load the widgetset: /activiti-webapp-explorer2-5.18.0/VAADIN/widgetsets/org.activiti.explorer.CustomWidgetset/org.activiti.explorer.CustomWidgetset.nocache.js?1444407987049")};',15000);
//]]>
</script>
<div id="activitiwebappexplorer25180ui-1091631569" class="v-app v-theme-activiti v-app-ExplorerApp" ><div class="v-app-loading"></div></div>
<noscript>You have to enable javascript in your browser to use an application    built with Vaadin.</noscript></body>
    </html>

我已尝试过在UI上看到的所有可能的网址,但这些网址都不起作用。我已经尝试了所有帖子,获取并放入这三个网址中的每一个。我通过查看加载的页面找到了这些网址,并注意到它们是嵌套的iframe。看到机械宝石的可行性的任何帮助都会很棒,感觉好像这对我的问题很容易解决。作为旁注,我已经更改了tomcat属性以允许CORS请求。此外,从rails到activiti explorer的http请求也不起作用,因此通信形式也已消失。

此外,如果您熟悉activiti-我已在默认登录处理程序中编辑了authenticate方法,尝试解析http请求以获取用户名和密码以自动登录。然而,这返回与上面打印的相同的html代码。任何帮助将不胜感激。以下是我从rails发出的http请求的示例:

auth = {:userid=> "kermit", :password => "kermit"}
puts HTTParty.get("http://activiti.testing.com:8080/activiti-webapp-explorer2-5.18.0/", :content_type => "application/json",
:basic_auth => auth)

1 个答案:

答案 0 :(得分:0)

我认为在iframe中集成Activiti Explorer并不是一个好主意。由于您的用户名和密码已暴露!前端的要求各不相同。

我最初喜欢Activiti Explorer,Modeler真是太棒了!但我使用Rails并发现很难定制和集成Activiti Explorer。我尝试与Activiti REST集成,而我更喜欢Activiti Java API,原因如下:

  1. Activiti REST是Activiti Java API的子集。例如:def foo(var): return True ires = foo if ires == True: print 'done' 在Activiti REST中无法使用。
  2. 表现问题。我开发了一个任务网页,但它需要超过10个http请求。
  3. 我喜欢Acitivi Modeler和Diagram Viewer。我需要运行Activiti Explorer并使它们协同工作。
  4. 所以我开发了一个名为jruby_activiti的宝石,集成了Activiti Engine,Modeler和Diagram Viewer。所有这些都可以在JRuby on Rails中使用!希望我的经历可以帮到你。