12-07-2016 10:10 AM
Hi ,
In my site all user require Collaborative role actually its consumer , so i added a configuration like this
<permissionSet type="st:site" expose="selected">
<permissionGroup name="SiteManager" allowFullControl="true" expose="true" />
<permissionGroup name="SiteCollaborator" allowFullControl="false" expose="true">
<includePermissionGroup permissionGroup="Collaborator" type="cm:cmobject" />
</permissionGroup>
<permissionGroup name="SiteContributor" allowFullControl="false" expose="true">
<includePermissionGroup permissionGroup="Contributor" type="cm:cmobject" />
</permissionGroup>
<permissionGroup name="SiteConsumer" allowFullControl="false" expose="true">
<includePermissionGroup permissionGroup="Collaborator" type="cm:cmobject" />
</permissionGroup>
<permissionGroup name="SiteCommentator" allowFullControl="false" expose="true">
<includePermissionGroup permissionGroup="Consumer" type="cm:cmobject" />
<includePermissionGroup permissionGroup="ReadPermissions" type="sys:base" />
</permissionGroup>
</permissionSet>
in alfresco-community\tomcat\shared\classes\alfresco\extension\sitePermissionDefinitions.xml
but its still access denied for some operations.
or if there is any other way, please let me know with sample codes
Thank you
12-08-2016 02:11 AM
Your sitePermissionDefinitions.xml is not an invalid xml file
Caused by: org.dom4j.DocumentException: Error on line 6 of document : Invalid byte 1 of 1-byte UTF-8 sequence. Nested exception: Invalid byte 1 of 1-byte UTF-8 sequence.
12-08-2016 04:54 AM
Thank you I fixed the issue...
please provide sample code for create a group and assign user to the group using java related
12-08-2016 07:41 AM
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.json.JSONObject;
public static void main(String[] args) {
WebScriptExample exmple = new WebScriptExample();
HttpClient client = exmple.getHttpClient();
exmple.addGroupOrUserToGroup(client);
}
private void addGroupOrUserToGroup(HttpClient client) {
String apiurl ="http://localhost:8080/alfresco/s/api/groups/{parent group name}/children/{user name or sub group name}";
PostMethod post = new PostMethod(apiurl);
try {
post.setDoAuthentication(true);
post.setRequestHeader("Content-Type", "application/json");
int status = client.executeMethod(post);
if (status != HttpStatus.SC_OK) {
System.err.println("Method failed: " + post.getStatusLine());
}
String resultString = post.getResponseBodyAsString();
System.out.println(resultString);
} catch (Exception e) {
e.printStackTrace();
} finally {
post.releaseConnection();
}
}
private HttpClient getHttpClient() {
HttpClient client = new HttpClient();
client.getState().setCredentials(
new AuthScope("localhost", 8080, "Alfresco"),
new UsernamePasswordCredentials("admin", "admin"));
return client;
}
Please note that if add sub group ,it's name should be prefix with GROUP_
for example add a sub group named subGroup1 to parent group named parentGroup,you url should be
String apiurl ="http://localhost:8080/alfresco/s/api/groups/parentGroup/children/GROUP_subGroup1 ";
12-08-2016 11:19 PM
Thank you,I am trying this example, but i got this errors
Method failed: HTTP/1.1 405 Method Not Allowed
Web Script Status 405 - Method Not Allowed
Script url /api/groups/CBGroupTest does not support the method POST
the url: String apiurl = "http://127.0.0.1:8090/alfresco/s/api/groups/CBGroupTest";
I gave like this.
12-08-2016 11:54 PM
Your url is not complete :
if you want to add an user to group CBGroupTest,the url should be like this
String apiurl = "http://127.0.0.1:8090/alfresco/s/api/groups/CBGroupTest/children/{userName}";
if you want to add an subgroup to group CBGroupTest,the url should be like this
String apiurl = "http://127.0.0.1:8090/alfresco/s/api/groups/CBGroupTest/children/{GROUP_groupName}";
12-09-2016 12:14 AM
thank you kayne,
I trying to create group ,once then later while creating user i have to add user to group , this is my scenario,
now i am trying to create group.
String apiurl = "http://127.0.0.1:8090/alfresco/s/api/groups/CBGroupTest/children/Group_CBGroupTest";
right now no user to that group
so its getting error
"The group :CBGroupTest, does not exist.
12-09-2016 12:37 AM
If you want to add sub group(CBGroupTest) to a parent group (CBGroupTest) , parent group CBGroupTest should exist.
Ifyou want to add root group please use
String apiurl ="http://localhost:8090/alfresco/s/api/rootgroups/{your root group name}";
12-09-2016 12:55 AM
thank you kayne
getting error
private void addGroupOrUserToGroup(HttpClient client) throws JSONException {
String apiurl = "http://127.0.0.1:8090/alfresco/s/api/rootgroups/CBGroup";
PostMethod post = new PostMethod(apiurl);
try {
post.setDoAuthentication(true);
post.setRequestHeader("Content-Type", "application/json");
int status = client.executeMethod(post);
if (status != HttpStatus.SC_OK) {
System.err.println("Method failed: " + post.getStatusLine());
}
String resultString = post.getResponseBodyAsString();
System.out.println(resultString);
} catch (Exception e) {
e.printStackTrace();
} finally {
post.releaseConnection();
}
}
"status" :
{
code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP server which prevented it from fulfilling the request."
},
12-09-2016 01:59 AM
Try to add following line in bold to your code
private void addGroupOrUserToGroup(HttpClient client) throws JSONException {
String apiurl = "http://127.0.0.1:8090/alfresco/s/api/rootgroups/CBGroup";
PostMethod post = new PostMethod(apiurl);
try {
JSONObject body = new JSONObject();
body.put("displayName", "CBGroup");
post.setDoAuthentication(true);
post.setRequestHeader("Content-Type", "application/json");
post.setRequestEntity(new StringRequestEntity(body.toString(),"application/json", "UTF-8"));
int status = client.executeMethod(post);
if (status != HttpStatus.SC_OK) {
System.err.println("Method failed: " + post.getStatusLine());
}
String resultString = post.getResponseBodyAsString();
System.out.println(resultString);
} catch (Exception e) {
e.printStackTrace();
} finally {
post.releaseConnection();
}
}
12-09-2016 02:06 AM
Thank You Very Much, Kayne
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.