java - Build Liferay web service with optional parameter -
i need extend existing liferay webservice (created service builder) handle additional optional parameter.
with service builder, have specify every parameters inside method signature:
public string getlist(string param1){ .. }
this creates get-list
web service accepting parameter named param1
. have specify every parameters when making call or else call fail. if need optional parameters, pass empty value , handle missing parameter inside code.
my problem backward compatibility: web service used mobile app , cannot change call made app. additional parameter must handled without changing method signature.
taking @ baseserviceimpl, tried obtain parameter in way:
httpservletrequest request = com.liferay.util.axis.servletutil.getrequest(); string value = paramutil.getstring(request, "param-name");
but throws noclassdefexception
regarding com.liferay.util.axis.servletutil
.
is there way this?
to enhance , retain backward compatibility of code, 1 way overload getlist()
method accepts additional parameter. can achieve following:
- move general pre-logic code of
getlist()
getlist(string param1)
method. - add filter
param1
ingetlist(string param1)
handle case when parameter not null / empty. - call
getlist(null)
getlist()
.
while can call getlist(string param1)
directly when require pass additional parameter.
original method:
public string getlist(){ return getlist(null); }
overriden method:
public string getlist(string param1){ if(param1 != null){ // logic param1 } // rest of general code }
Comments
Post a Comment