On Wed, Jan 29, 2014 at 2:14 PM, Antonio ForniƩ Casarrubios <antonio.for...@gmail.com> wrote: > Hi, > > > I'm working on cloud-server#com.cloud.api.ApiDispatcher and related classes > and trying to do some refactoring here. But I just had a couple of > questions to make sure I'm not missing anything important. > > > 2* About the parameters received in the HTTP request, we have two methods > for "fixing" them for our needs. First, in ApiServer#verifyRequest, we have > a Map<String, String[]> but we never need to have an array of Strings, so > the code assumes the array will always have 1 item, and always uses > params[0] without even checking (the array could have 0 or 10 Strings). All > of this also happens along ApiServlet.
There are very few apis where one can pass maps as args like map.vm[0], map.vm[1] etc. I don't exactly remember them right now but a quick search across the api package will help you. But, if code has changed and we know for sure it is always the params[0] we are interested in so we should fix it. > > Later in ApiServer#handleRequest we do a first fix in the Map (which > doesn't seem to fit well in this method). Actually we move the values to a > Map<String, String> to stop having arrays. And from that point we use only > the new Map. > > > And finally, later in Apidispatcher we do a final fix in the Map: > > unpackedParams = cmd.unpackParams(params); > > So that params have values already lowercase and format validated. > > > So unless someone knows reason to keep it this way, I want to fix the Map > of params from the very beginning once and for all in a separate methods. > From that point all params will be checked, lower case and Map<String, > String> without 1-item arrays... so future methods coming later don't need > to worry about these details. Is there a reason doing this could be wrong? > Is there any point in the middle where it will brake if my values are > Strings instead of Arrays of Strings? Let one of the present API layer maintainers comment on them, but I agree they must be fixed. In general, we should fix ApiDispatcher and ApiServer/Servlet code all of which is messed up. Regards. > > > > Thanks. Cheers > > > Antonio Fornie > > MCE at Schuberg Philis