public static Map<String,Object> makeValidContext(ModelService model,String mode,Map<String,? extends Object> context) throws GenericServiceException {
  Map<String,Object> newContext;
  int modeInt=0;
  if (mode.equalsIgnoreCase("in")) {
    modeInt=1;
  }
 else   if (mode.equalsIgnoreCase("out")) {
    modeInt=2;
  }
  if (model == null) {
    throw new GenericServiceException("Model service is null! Should never happen.");
  }
 else {
switch (modeInt) {
case 2:
      newContext=model.makeValid(context,ModelService.OUT_PARAM,true,null);
    break;
case 1:
  newContext=model.makeValid(context,ModelService.IN_PARAM,true,null);
break;
default :
throw new GenericServiceException("Invalid mode, should be either IN or OUT");
}
return newContext;
}
}

public static Map < String , Object > makeValidContext ( ModelService model , String mode , Map < String , ? extends Object > context ) throws GenericServiceException { Map < String , Object > newContext ; int modeInt = 0 ; if ( mode . equalsIgnoreCase ( "in" ) ) { modeInt = 1 ; } else if ( mode . equalsIgnoreCase ( "out" ) ) { modeInt = 2 ; } if ( model == null ) { throw new GenericServiceException ( "Model service is null! Should never happen." ) ; } else { switch ( modeInt ) { case 2 : newContext = model . makeValid ( context , ModelService . OUT_PARAM , true , null ) ; break ; case 1 : newContext = model . makeValid ( context , ModelService . IN_PARAM , true , null ) ; break ; default : throw new GenericServiceException ( "Invalid mode, should be either IN or OUT" ) ; } return newContext ; } }
uses an existing map of name value pairs and extracts the keys which are used in servicename note : this goes not guarantee the context will be 100 % valid , there may be missing fields
