cancel
Showing results for 
Search instead for 
Did you mean: 

MultilingualContentService initialization

andrea_girardi
Champ in-the-making
Champ in-the-making
Hi all,

I'm trying to add multilinguage aspect to a node for a massive upload. This is the code I'm trying to use:

WebServiceFactory.setEndpointAddress(webServiceFactory); 
AuthenticationUtils.startSession(userName, password);
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
MultilingualContentService multilingualContentService = (MultilingualContentService) ctx.getBean("MultilingualContentService");
NodeRef nodeRef = new NodeRef("workspace://SpacesStore/" + contentNodeRef.getUuid());
multilingualContentService.makeTranslation(nodeRef, locale);

this code, obviusly returns this:
parsing XML document from class path resource [alfresco/application-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [alfresco/application-context.xml] cannot be opened because it does not exist

it's not clear how can I reach the spring configuration xml file that are stored on remote server. How can I initialize the MultilingualContentService? Is there another way to change make a translation of a node?

thanks,
Andrea
3 REPLIES 3

openpj
Elite Collaborator
Elite Collaborator
Your code is wrong in different points, contains a mix of local and remote APIs of Alfresco:
  • the WebServiceFactory must be used only when you want to implement a remote Web Services SOAP client: probably you want to use the ServiceRegistry locally but it depends on your requirements

  • AuthenticationUtils.startSession create a new user session (remotely) against a remote Alfresco instance

  • ApplicationContextHelper.getApplicationContext() creates a local Alfresco instance in the local JVM!
Have you tried to take a look at samples in the Alfresco SDK? I suggest to download the SDK  :wink:

What are your needs for your application?

andrea_girardi
Champ in-the-making
Champ in-the-making
The requirement I receive is to model some existing content available on a SQL Server database using Alfresco content management.

I created a batch java application that create a connection with Alfresco and create new content. I do all works (create new content and association) using WebServiceFactory, but, I didn't find any sample to add translation to a node using it so, for that reason, I tried to use ApplicationContextHelper.getApplicationContext().

How can I do that using WebServiceFactory? Where can I found an Example? Looking at SDK I didn't find anything.

Thanks for your reply!

openpj
Elite Collaborator
Elite Collaborator
You don't have that service exposed by the Web Services API, you need to create a custom action in the repository and then you can invoke this new custom action using the ActionService exposed by the Web Services API.

More information about custom action:
http://wiki.alfresco.com/wiki/Custom_Actions

Hope this helps.