java - 使用 java 以编程方式创建 Alfresco 站点

标签 java rest alfresco alfresco-share

有人知道如何用java创建一个露天网站吗?我发现两个 api 调用应该创建一个站点:

1) POST/alfresco/service/api/sites.这成功创建了一个网站,但是当我尝试在露天访问该网站时,它给了我这个错误:

A server error has occured.

There are a number of reasons why this could have happened: You have attempted to access a page that does not exist - check the URL in the address bar. You have attempted to access a page that is not accessible to you, such as a private Site dashboard. A valid page has been requested but the server was unable to render it due to an internal error - contact your administrator.

Return to your dashboard page

Alfresco Software Inc. © 2005-2013 All rights reserved.

2) POST/share/service/modules/create-site 这给了我一个 401 未经授权的错误。我正在传递正确的露天身份验证票。有人有以编程方式创建网站的经验吗?最好用java。

最佳答案

这在 python 中对我有用。也许它对您在 Java 方面也有帮助。

首先在Share的DoLogin页面上发帖获取JSESSIONID Cookie、alflogin和alfusername

h1 = httplib.HTTPConnection(127.0.0.1,8080) 
headers = {"Content-type": "application/x-www-form-urlencoded"}
pa = "username="+username+"&password="+password
h1.request("POST","/share/page/dologin",pa,headers)
response = h1.getresponse().getheaders()

现在拆分 JSESSION ID、alfusername 和 alflogin 的响应

cookie = jsessionid +"; "+alflogin+"; "alfusername+";"
value = {"title": "Test Side", "visibility":"PUBLIC", "description":"Add descripton here","sitePreset": "MySitePreset", "shortName": "test_side"}
headers2 = {"Content-type":"application/json", "Accept":"application/json", "Cookie": cookie}
# Get Request on any Share Page to get in touch with Share 
request.get("http://127.0.0.1:8080/share/page/user/admin/dashboard", auth=(username,password), headers=headers2)
request.post("http://127.0.0.1:8080/share/service/modules/create-site", auth=(username,password), data=json.dumps(value), headers=headers2)

这将创建一个也可以访问的露天站点

关于java - 使用 java 以编程方式创建 Alfresco 站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27495129/

相关文章:

java - 一次一密,加密解密

java - 这个在 Spring 中处理 POST 请求的 REST 方法到底是如何工作的?

web-services - RESTful 创建或更新的正确 HTTP 方法?

java - Alfresco Share - 搜索不适用于非管理员用户

javascript - 使用 Alfresco 网页脚本进行文档预览配置

opencmis 方法 getdescendants(-1) 的 Java OutOfMemoryError

java - 使用 Ireport 和 JSP 生成 PDF

java编码在jsp中获取多个注释

java - findbugs 报告错误的行号并抑制错误?

ruby-on-rails-3 - Rails respond_with——为什么 POST 返回的是 URL 而不是数据?