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:

  1. move general pre-logic code of getlist() getlist(string param1) method.
  2. add filter param1 in getlist(string param1) handle case when parameter not null / empty.
  3. 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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -