JAVA API - Get node description in different locale

cancel
Showing results for 
Search instead for 
Did you mean: 
nenadteo
Partner

JAVA API - Get node description in different locale

Jump to solution

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 Solution

Accepted Solutions
nenadteo
Partner

Re: JAVA API - Get node description in different locale

Jump to solution
3 Replies
nenadteo
Partner

Re: JAVA API - Get node description in different locale

Jump to solution

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
Partner

Re: JAVA API - Get node description in different locale

Jump to solution

I found solution on this link:

 

https://stackoverflow.com/a/31110305

EddieMay
Alfresco Employee

Re: JAVA API - Get node description in different locale

Jump to solution

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!