Hi.I have a Java app which create new people and communties throught Alfresco WebScripts.But I have a problem with the encoding because when I insert some special characters (á, é, í, ñ, Ü, ö…) Alfresco get them like ������.This is my code (add person):
String alfrescoUser = "usr0000000123";
String alfrescoFirstName = "José Miguel";
String alfrescoLastName = "Español";
String alfrescoEmail = "pruebas@mail_pruebas123.com";
JSONObject personaJSON = new JSONObject();
personaJSON.put("userName", alfrescoUser);
personaJSON.put("firstName", alfrescoFirstName);
personaJSON.put("lastName", alfrescoLastName);
personaJSON.put("email", alfrescoEmail);
postRequest = new HttpPost("http://'+ host + ":" + port + "/alfresco/service/api/people?alf_ticket=" + alfTicket);
input = new StringEntity(personaJSON.toString());
input.setContentType("application/json; charset=UTF-8");
input.setContentEncoding("UTF-8");
postRequest.setHeader("Content-Type","application/json; charset=UTF-8");
postRequest.setEntity(input);
response = httpClient.execute(postRequest);
I tried the following solutions but none of them have worked.1- File setenv.bat in tomcat/bin:
set JAVA_HOME=C:\Alfresco\java
set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8 -Djava.file.encoding=UTF-8 -Duser.languaje=es -Duser.region=ES -XX:PermSize=256m
set CATALINA_OPTS=%CATALINA_OPTS% -Dfile.encoding="UTF-8"
2- File tomcat/conf/web.xml: <servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>fileEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
3- File tomcat/conf/server.xml: <Connector port="8080" URIEncoding="UTF-8" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
I put some traces in my Java code and the output data are ok:Datos de la persona : {"password":"nadadenada","userName":"usuario_pruebas04","email":"pruebas@mail_pruebas123.com","firstName":"Usuario","lastName":"Pruebás"}Codigo: 200But the response is not ok (lastName is Prueb\ufffds instead of Pruebá)Respuesta del servidor ….
<< Response: HTTP/1.1 200 OK
{
"url": "\/alfresco\/service\/api\/person\/usuario_pruebas06",
"userName": "usuario_pruebas06",
"enabled": true,
"firstName": "Usuario",
"lastName": "Prueb\ufffds",
"jobtitle": null,
"organization": null,
"location": null,
"telephone": null,
"mobile": null,
"email": "pruebas@mail_pruebas123.com",
"companyaddress1": null,
"companyaddress2": null,
"companyaddress3": null,
"companypostcode": null,
"companytelephone": null,
"companyfax": null,
"companyemail": null,
"skype": null,
"instantmsg": null,
"userStatus": null,
"userStatusTime": null,
"googleusername": null,
"quota": -1,
"sizeCurrent": 0,
"emailFeedDisabled": false,
"persondescription": null
}Some ideas???Many thanks.