cancel
Showing results for 
Search instead for 
Did you mean: 

JAVA API - Get node description in different locale

nenadteo
Champ on-the-rise
Champ on-the-rise

Hello

in Alfresco Community v5.1.e we are executing the query in the custom Java based web script and then we take the metadata from the documents returned.

Users using different language settings in Browser which affects values for cm:description property.

Even if we specify in Locale in SearchParameters.java

SearchParameters sp = new SearchParameters();
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
sp.addLocale(Locale.GERMAN);
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
String query = "TYPE: "xyz:publishedDocument"
sp.setQuery(query);
...

we do not receive the German version of cm:description property of document.

If we call this GET webscript from Browser always Browser's language settings will be taken, so if English is set in Browser, we won't receive the cm:description values which were set in German, but if German is set in Browser we receive it. So somehow the searchService ignores explicite Locale settings in Java API and always uses Browsers settings.

Do you know where is the problem and how to force searchService to use Locale settings in SearchParameters?

Thanks...

1 ACCEPTED ANSWER

nenadteo
Champ on-the-rise
Champ on-the-rise
3 REPLIES 3

nenadteo
Champ on-the-rise
Champ on-the-rise

Hello

if I try to cast the property

MLText versionFolderDescriptionML =
(MLText) nodeService.getProperty(mainDocumentNodeRef, ContentModel.PROP_DESCRIPTION);

we receve 

"java.lang.ClassCastException: java.lang.String cannot be cast to org.alfresco.service.cmr.repository.MLText"

nenadteo
Champ on-the-rise
Champ on-the-rise

I found solution on this link:

https://stackoverflow.com/a/31110305

EddieMay
World-Class Innovator
World-Class Innovator

Hi @nenadteo,

Great that you found a solution & thanks for posting it - will help other users.

Thanks again, 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!