Get quickshare url with javascript

2019-09-06 12:31发布

I want to share a document with JavaScript and get its share_id programatically. There is a REST API that can do that but I didn't know how to call it from script.

Any clues?

1条回答
劫难
2楼-- · 2019-09-06 13:20

The following hack will do the trick. (edit: Must be executed from the classpath in the repository)

var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var qsService = ctx.getBean("QuickShareService");
var sId = document.properties['qshare:sharedId'];
if (!sId) {
    sId = qsService.shareContent(document.nodeRef).id;
}

PS: It looks even more ugly on 5.0.a due to rhino-1.7.

查看更多
登录 后发表回答