Re: jData in a WebService

Emmanuel Grosjean <[email protected]>
Newsgroups gmane.comp.cms.jahia.template
Message-ID <[email protected]>
Hello,

You can create in this context a ParamBean and then a JahiaData.
I use the folowing snipet that works fine in Jahia 4.1 :

String userSite = ... // from WebService uour parameters
String userName = ... // from WebService uour parameters
String userPassword = ... // from WebService uour parameters

JahiaSitesService siteSrv = 
ServicesRegistry.getInstance().getJahiaSitesService();
JahiaUserManagerService usrSrv = 
ServicesRegistry.getInstance().getJahiaUserManagerService();

JahiaSite site = siteSrv.getSiteByKey(userSite );
JahiaUser user = usrSrv.lookupUser(site.getID(), userName );
if ( user==null )
     throw new Exception("unknow user '"+userName +"'");
if ( user.verifyPassword(userPassword )==false )
    throw new Exception("bad pawwsord");
if ( usrSrv.login(user.getUserKey(), userPassword)==false )
            throw new Exception("cannot login");
       
ParamBean paramBean = new AdminParamBean(request, response, 
request.getSession().getServletContext(), Jahia.getSettings(), 
System.currentTimeMillis(), ParamBean.GET_METHOD, site, user, null);
paramBean.setUser(user);
paramBean.setOperationMode(ParamBean.EDIT);
paramBean.getLocale(); // to initialyze 'currentLocale' field (to avoid 
NullPointerException under certains ciscumstances...)

JahiaData jData = new JahiaData(paramBean);


KAYA Ertugrul wrote:

> Hello,
> I want to use the import/export functionnality of Jahia in a WebService.
>  
> I've got a function that make it well, but this function is called in 
> Jahia context.
> Then it uses the jData parameters.
>  
> And my question is :
> can jData parameter be instantiate outside jahia context an servlet 
> context ?
>  
> If yes, how ?
>  
>  
> Thanks in advance.
> Ertu
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.