hello,i am trying to create a site in alfresco by using WEB SCRIPT" POst http://localhost:8080/share/service/modules/create-site"i tested this java code that generates no errors and seems to execute fine but when i check in the alfresco dashboard the site is not created
public class TestShareCreateSitePost {
public static void main(String[] args) throws Exception {
System.out.println(createSite());
}
private static String createSite() {
try {
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(
"http://localhost:8080/share/page/dologin");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("username", "admin"));
nameValuePairs.add(new BasicNameValuePair("password", "admin"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
client.execute(post);
CookieStore cookieStore = client.getCookieStore();
client = new DefaultHttpClient();
client.setCookieStore(cookieStore);
post = new HttpPost(
"http://localhost:8080/share/service/modules/create-site");
post.setHeader("Content-Type", "application/json");
post.setEntity(new StringEntity(createSiteParameters(
"JavaTest-001", "Sito di test by JAVA", "JavaTest-001"),
"UTF-8"));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = client.execute(post, responseHandler);
return response;
} catch (Exception e) {
e.printStackTrace();
}
return "Error!";
}
private static String createSiteParameters(String title,
String description, String shortName) {
String site = "{\"visibility\":\"PUBLIC\", "
+ "\"sitePreset\":\"site-dashboard\", " + "\"title\":\""
+ title + "\", " + "\"description\":\"" + description + "\", "
+ "\"shortName\":\"" + shortName + "\"}";
System.out.println(site);
return site;
}
}
i have also made the modification to disable the CSRF filter but it didn't work also can someone tell me what im i missing ?thx