public Matrix createVector(BitVector selector) { int rows = selector != null ? selector.countOnBits() : frame.size(); Matrix m = new Matrix(rows, 1); for (int i = 0, j = 0; j < frame.size(); j++) { if (selector == null || selector.isOn(j)) { M rowValue = frame.object(j); try { Number numValue = (Number) numericField.get(rowValue); m.set(i, 0, numValue.doubleValue()); } catch (IllegalAccessException e) { e.printStackTrace(); throw new IllegalStateException( String.format( "Couldn't access field %s: %s", numericField.getName(), e.getMessage())); } i++; } } return m; }
public void doArtefactConfiguration() { if (!pluginBean.isReadableProperty(ARTEFACTS)) { return; } List l = (List) plugin.getProperty(ARTEFACTS); for (Object artefact : l) { if (artefact instanceof Class) { Class artefactClass = (Class) artefact; if (ArtefactHandler.class.isAssignableFrom(artefactClass)) { try { application.registerArtefactHandler((ArtefactHandler) artefactClass.newInstance()); } catch (InstantiationException e) { LOG.error("Cannot instantiate an Artefact Handler:" + e.getMessage(), e); } catch (IllegalAccessException e) { LOG.error( "The constructor of the Artefact Handler is not accessible:" + e.getMessage(), e); } } else { LOG.error("This class is not an ArtefactHandler:" + artefactClass.getName()); } } else { if (artefact instanceof ArtefactHandler) { application.registerArtefactHandler((ArtefactHandler) artefact); } else { LOG.error( "This object is not an ArtefactHandler:" + artefact + "[" + artefact.getClass().getName() + "]"); } } } }
public static Object newInstance(Class clazz) throws FacesException { try { return clazz.newInstance(); } catch (NoClassDefFoundError e) { log.error("Class : " + clazz.getName() + " not found.", e); throw new FacesException(e); } catch (InstantiationException e) { log.error(e.getMessage(), e); throw new FacesException(e); } catch (IllegalAccessException e) { log.error(e.getMessage(), e); throw new FacesException(e); } }
public Matrix createVector() { int rows = frame.size(); Matrix m = new Matrix(rows, 1); for (int i = 0; i < rows; i++) { M rowValue = frame.object(i); try { Number numValue = (Number) numericField.get(rowValue); m.set(i, 0, numValue.doubleValue()); } catch (IllegalAccessException e) { e.printStackTrace(); throw new IllegalStateException( String.format("Couldn't access field %s: %s", numericField.getName(), e.getMessage())); } } return m; }
public static <T extends PaypalClassicResponseModel> T convertToAPIResponse( Map<String, String> mapdata, Class<T> clazz) { if (mapdata == null) { return null; } T paypalClassicResponseModel = null; try { paypalClassicResponseModel = mapToClazz(mapdata, clazz); } catch (InstantiationException e) { throw new ValidationException(e.getMessage()); } catch (IllegalAccessException e) { throw new ValidationException(e.getMessage()); } catch (InvocationTargetException e) { throw new ValidationException(e.getMessage()); } return paypalClassicResponseModel; }
/** * Creates an iterator that returns an {@link Options} containing each possible parameter set * defined by these {@link * com.biomatters.plugins.barcoding.validator.research.options.BatchOptions}. Note that the {@link * Options} object returned is always the same to save on initializing multiple copies. Each time * {@link java.util.Iterator#next()} is called the next parameter set is set on the {@link * Options}. * * @return An iterator that will iterate over all possible parameter sets specified by this {@link * com.biomatters.plugins.barcoding.validator.research.options.BatchOptions} * @throws DocumentOperationException if there is a problem creating the {@link Options} object */ public Iterator<T> iterator() throws DocumentOperationException { List<Set<OptionToSet>> possibleValues = new ArrayList<Set<OptionToSet>>(); Map<String, MultiValueOption<?>> multiValueOptions = getMultiValueOptions("", options); for (Map.Entry<String, MultiValueOption<?>> entry : multiValueOptions.entrySet()) { possibleValues.add(getOptionsToSet(entry.getKey(), entry.getValue())); } Set<List<OptionToSet>> lists = Sets.cartesianProduct(possibleValues); final Iterator<List<OptionToSet>> possibilityIterator = lists.iterator(); final T template; try { //noinspection unchecked template = (T) options.getClass().newInstance(); // getClass() doesn't return Class<T> :( template.valuesFromXML(options.valuesToXML(XMLSerializable.ROOT_ELEMENT_NAME)); } catch (InstantiationException e) { throw new DocumentOperationException("Failed to create Options: " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new DocumentOperationException("Failed to create Options: " + e.getMessage(), e); } return new Iterator<T>() { @Override public boolean hasNext() { return possibilityIterator.hasNext(); } @Override public T next() { List<OptionToSet> possibility = possibilityIterator.next(); for (OptionToSet optionToSet : possibility) { template.setValue(optionToSet.name, optionToSet.value); } return template; } @Override public void remove() { new UnsupportedOperationException(); } }; }
/** * Return a new strategy (Design Pattern Abstract Factory) * * @return a new strategy */ public static Strategy newStrategy() { Strategy strategy = null; Class stratClass; // FIXME: When you do a new Solution() it get an error because the strategies weren't // initialized before to do a newStrategy(). if (allStrategies == null) { Hocli.initStrategies(); setStrategy("FR"); } stratClass = allStrategies.get(Hocli.strategyTag.toUpperCase()); if (stratClass == null) { stopError("Hocli.newStrategy(Solution) : Unknown strategy class '" + Hocli.strategyTag + "'"); } try { strategy = (Strategy) stratClass.newInstance(); } catch (IllegalAccessException ex) { stopError(ex.getMessage()); } catch (InstantiationException ex) { stopError(ex.getMessage()); } return strategy; }
public void register(String processId, String name, Object extension) { if (log.isDebugEnabled()) log.debug("Registering " + name); PasswordManagementProcess p = this.runningProcesses.get(processId); Class clazz = p.getClass(); while (clazz != null) { Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { if (log.isDebugEnabled()) log.debug("Checking field : " + field.getName()); if (field.isAnnotationPresent(Extension.class)) { Extension ex = field.getAnnotation(Extension.class); if (ex.value().equals(name)) { log.debug("Injecting extension : " + name); try { // Make field accessible ... if (!field.isAccessible()) { field.setAccessible(true); } field.set(p, extension); return; } catch (IllegalAccessException e) { log.error(e.getMessage(), e); } } } } clazz = clazz.getSuperclass(); } }
/** * Processes the request coming to the servlet and grabs the attributes set by the servlet and * uses them to fire off pre-determined methods set in the setupActionMethods function of the * servlet. * * @param request the http request coming from the browser. * @param response the http response going to the browser. * @throws javax.servlet.ServletException * @throws java.io.IOException */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (!actionInitialized) { LogController.write(this, "This dispatcher servlet is not initialized properly!"); return; } if (actionTag == null) { LogController.write(this, "There is no action attribute tag name!"); return; } HttpSession httpSession = request.getSession(); UserSession userSession = (UserSession) httpSession.getAttribute("user_session"); if (userSession == null) { LogController.write(this, "User session is no longer available in this http session."); userSession = new UserSession(); // We always want a user session though... httpSession.setAttribute("user_session", userSession); } String action = (String) request.getAttribute(actionTag); try { if (action == null) { // There is no action attribute specified, check parameters. String external_action = (String) request.getParameter(actionTag); if (external_action != null) { Method method = externalActions.get(external_action); if (method != null) { LogController.write(this, "Performing external action: " + external_action); method.invoke(this, new Object[] {userSession, request, response}); } else { if (defaultExternalMethod != null) { LogController.write(this, "Performing default external action."); defaultExternalMethod.invoke(this, new Object[] {userSession, request, response}); } else { LogController.write(this, "Unable to perform default external action."); } } } else { if (defaultExternalMethod != null) { LogController.write(this, "Performing default external action."); defaultExternalMethod.invoke(this, new Object[] {userSession, request, response}); } else { LogController.write(this, "Unable to perform default external action."); } } } else { Method method = internalActions.get(action); if (method != null) { LogController.write(this, "Performing internal action: " + action); method.invoke(this, new Object[] {userSession, request, response}); } else { if (defaultInternalMethod != null) { LogController.write(this, "Performing default internal action."); defaultInternalMethod.invoke(this, new Object[] {userSession, request, response}); } else { LogController.write(this, "Unable to perform default internal action."); } } request.removeAttribute("application_action"); } } catch (IllegalAccessException accessEx) { LogController.write(this, "Exception while processing request: " + accessEx.getMessage()); } catch (InvocationTargetException invokeEx) { LogController.write(this, "Exception while processing request: " + invokeEx.toString()); invokeEx.printStackTrace(); } catch (Exception ex) { LogController.write(this, "Unknown exception: " + ex.toString()); } }
public ProcessResponse handleRequest(ProcessRequest request) throws PasswordManagementException { String processId = request.getProcessId(); String actionName = null; if (log.isDebugEnabled()) log.debug("Handling request for process [" + processId + "]"); try { PasswordManagementProcess p = runningProcesses.get(processId); if (p == null) throw new PasswordManagementException("No such process " + processId); String nextStep = p.getState().getNextStep(); if (log.isDebugEnabled()) log.debug("Handling request for process [" + processId + "]"); Method[] methods = p.getClass().getMethods(); for (Method method : methods) { if (log.isDebugEnabled()) log.debug("Processing method : " + method.getName()); if (!method.isAnnotationPresent(Action.class)) continue; Action action = method.getAnnotation(Action.class); if (log.isDebugEnabled()) log.debug("Processing method annotation : " + action); for (String actionStep : action.fromSteps()) { if (log.isDebugEnabled()) log.debug("Processing annotation step : " + actionStep); if (actionStep.equals(nextStep)) { actionName = method.getName(); if (log.isDebugEnabled()) log.debug( "Dispatching request from step " + nextStep + " to process [" + processId + "] action " + actionName); // Store response next step in process state : ProcessResponse r = (ProcessResponse) method.invoke(p, request); ((BaseProcessState) p.getState()).setNextStep(r.getNextStep()); return r; } } } throw new PasswordManagementException("Step [" + nextStep + "] not supported by process"); } catch (InvocationTargetException e) { throw new PasswordManagementException( "Cannot invoke process action [" + actionName + "] : " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new PasswordManagementException( "Cannot invoke process action [" + actionName + "] : " + e.getMessage(), e); } }
private int runEclipseCompiler(String[] output, List<String> cmdline) { try { List<String> final_cmdline = new LinkedList<String>(cmdline); // remove compiler name from argument list final_cmdline.remove(0); Class eclipseCompiler = Class.forName(ECLIPSE_COMPILER_CLASS); Method compileMethod = eclipseCompiler.getMethod("main", new Class[] {String[].class}); final_cmdline.add(0, "-noExit"); final_cmdline.add(0, "-progress"); final_cmdline.add(0, "-verbose"); File _logfile = new File(this.idata.getInstallPath(), "compile-" + getName() + ".log"); if (Debug.isTRACE()) { final_cmdline.add(0, _logfile.getPath()); final_cmdline.add(0, "-log"); } // get log files / determine results... try { // capture stdout and stderr PrintStream _orgStdout = System.out; PrintStream _orgStderr = System.err; int error_count = 0; try { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); EclipseStdOutHandler ownStdout = new EclipseStdOutHandler(outStream, this.listener); System.setOut(ownStdout); ByteArrayOutputStream errStream = new ByteArrayOutputStream(); EclipseStdErrHandler ownStderr = new EclipseStdErrHandler(errStream, this.listener); System.setErr(ownStderr); compileMethod.invoke( null, new Object[] {final_cmdline.toArray(new String[final_cmdline.size()])}); // TODO: launch thread which updates the progress output[0] = outStream.toString(); output[1] = errStream.toString(); error_count = ownStderr.getErrorCount(); // for debugging: write output to log files if (error_count > 0 || Debug.isTRACE()) { File _out = new File(_logfile.getPath() + ".stdout"); FileOutputStream _fout = new FileOutputStream(_out); _fout.write(outStream.toByteArray()); _fout.close(); _out = new File(_logfile.getPath() + ".stderr"); _fout = new FileOutputStream(_out); _fout.write(errStream.toByteArray()); _fout.close(); } } finally { System.setOut(_orgStdout); System.setErr(_orgStderr); } if (error_count == 0) { return 0; } // TODO: construct human readable error message from log this.listener.emitNotification("Compiler reported " + error_count + " errors"); return 1; } catch (FileNotFoundException fnfe) { this.listener.emitError("error compiling", fnfe.getMessage()); return -1; } catch (IOException ioe) { this.listener.emitError("error compiling", ioe.getMessage()); return -1; } } catch (ClassNotFoundException cnfe) { output[0] = "error getting eclipse compiler"; output[1] = cnfe.getMessage(); return -1; } catch (NoSuchMethodException nsme) { output[0] = "error getting eclipse compiler method"; output[1] = nsme.getMessage(); return -1; } catch (IllegalAccessException iae) { output[0] = "error calling eclipse compiler"; output[1] = iae.getMessage(); return -1; } catch (InvocationTargetException ite) { output[0] = "error calling eclipse compiler"; output[1] = ite.getMessage(); return -1; } }
/** * An HTTP WebEvent handler that checks to see is a userLogin is logged in. If not, the user is * forwarded to the login page. * * @param request The HTTP request object for the current JSP or Servlet request. * @param response The HTTP response object for the current JSP or Servlet request. * @return String */ public static String checkLogin(HttpServletRequest request, HttpServletResponse response) { GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); // anonymous shoppers are not logged in if (userLogin != null && "anonymous".equals(userLogin.getString("userLoginId"))) { userLogin = null; } // user is logged in; check to see if they have globally logged out if not // check if they have permission for this login attempt; if not log them out if (userLogin != null) { Element rootElement = getRootElement(request); boolean hasLdapLoggedOut = false; if (rootElement != null) { String className = UtilXml.childElementValue( rootElement, "AuthenticationHandler", "org.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler"); try { Class<?> handlerClass = Class.forName(className); InterfaceOFBizAuthenticationHandler authenticationHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.newInstance(); hasLdapLoggedOut = authenticationHandler.hasLdapLoggedOut(request, response, rootElement); } catch (ClassNotFoundException e) { Debug.logError(e, "Error calling checkLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (InstantiationException e) { Debug.logError(e, "Error calling checkLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (IllegalAccessException e) { Debug.logError(e, "Error calling checkLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (Exception e) { Debug.logError(e, "Error calling checkLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } } if (!hasBasePermission(userLogin, request) || isFlaggedLoggedOut(userLogin) || hasLdapLoggedOut) { Debug.logInfo("User does not have permission or is flagged as logged out", module); doBasicLogout(userLogin, request, response); userLogin = null; } } if (userLogin == null) { return login(request, response); } return "success"; }
/** * An HTTP WebEvent handler that logs out a userLogin by clearing the session. * * @param request The HTTP request object for the current request. * @param response The HTTP response object for the current request. * @return Return a boolean which specifies whether or not the calling request should generate its * own content. This allows an event to override the default content. */ public static String logout(HttpServletRequest request, HttpServletResponse response) { // run the before-logout events RequestHandler rh = RequestHandler.getRequestHandler(request.getSession().getServletContext()); rh.runBeforeLogoutEvents(request, response); // invalidate the security group list cache GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); doBasicLogout(userLogin, request, response); Element rootElement = getRootElement(request); String result = "error"; if (rootElement != null) { String className = UtilXml.childElementValue( rootElement, "AuthenticationHandler", "org.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler"); try { Class<?> handlerClass = Class.forName(className); InterfaceOFBizAuthenticationHandler authenticationHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.newInstance(); result = authenticationHandler.logout(request, response, rootElement); } catch (ClassNotFoundException e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (InstantiationException e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (IllegalAccessException e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (Exception e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } } if (request.getAttribute("_AUTO_LOGIN_LOGOUT_") == null) { return autoLoginCheck(request, response); } return result; }
/** * An HTTP WebEvent handler that logs in a userLogin. This should run before the security check. * * @param request The HTTP request object for the current JSP or Servlet request. * @param response The HTTP response object for the current JSP or Servlet request. * @return Return a boolean which specifies whether or not the calling Servlet or JSP should * generate its own content. This allows an event to override the default content. */ public static String login(HttpServletRequest request, HttpServletResponse response) { Element rootElement = getRootElement(request); String result = "error"; if (rootElement != null) { String className = UtilXml.childElementValue( rootElement, "AuthenticationHandler", "org.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler"); try { Class<?> handlerClass = Class.forName(className); InterfaceOFBizAuthenticationHandler authenticationHandler = (InterfaceOFBizAuthenticationHandler) handlerClass.newInstance(); result = authenticationHandler.login(request, response, rootElement); } catch (ClassNotFoundException e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (InstantiationException e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (IllegalAccessException e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (NamingException e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } catch (Exception e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage( resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); request.setAttribute("_ERROR_MESSAGE_", errMsg); } } if (result.equals("error")) { boolean useOFBizLoginWhenFail = Boolean.getBoolean( UtilXml.childElementValue(rootElement, "UseOFBizLoginWhenLDAPFail", "false")); if (useOFBizLoginWhenFail) { return LoginWorker.login(request, response); } } return result; }
public static Map<String, String> toRequestMap( PaypalClassicModel paypalClassicModel, String format) { Map<String, String> returnMap = new HashMap<>(); if (paypalClassicModel == null) { return returnMap; } ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); // ValidatorFactory factory = Validation.byDefaultProvider() // .configure() // .messageInterpolator( new MyMessageInterpolator() ) // .buildValidatorFactory(); Validator validator = factory.getValidator(); Set<ConstraintViolation<PaypalClassicModel>> violations = validator.validate(paypalClassicModel); if (violations.size() == 0) { try { for (Field field : FieldUtils.getAllFields(paypalClassicModel.getClass())) { if (field.getType().isAssignableFrom(String.class)) { if (BeanUtils.getProperty(paypalClassicModel, field.getName()) != null) { if (StringUtils.isNumeric(format)) { returnMap.put( field.getName().toUpperCase() + format, BeanUtils.getProperty(paypalClassicModel, field.getName())); } else { returnMap.put( getFormatedKeyName(format, field.getName(), null), BeanUtils.getProperty(paypalClassicModel, field.getName())); } } } if (PaypalClassicModel.class.isAssignableFrom(field.getType())) { if (PropertyUtils.getProperty(paypalClassicModel, field.getName()) != null) { returnMap.putAll( toRequestMap( (PaypalClassicModel) PropertyUtils.getProperty(paypalClassicModel, field.getName()), format)); } } if (List.class.isAssignableFrom(field.getType())) { List listItem = (List) PropertyUtils.getProperty(paypalClassicModel, field.getName()); if (listItem != null) { for (int i = 0; i < listItem.size(); i++) { if (listItem.get(i) instanceof PaypalClassicModel) { PaypalCollection paypalCollection = field.getAnnotation(PaypalCollection.class); if (paypalCollection != null && StringUtils.isNotEmpty(paypalCollection.format())) { String formatStr = field.getAnnotation(PaypalCollection.class).format(); returnMap.putAll( toRequestMap( (PaypalClassicModel) listItem.get(i), getFormatedKeyName(formatStr, null, i))); } else { if (StringUtils.isNoneEmpty(format)) { returnMap.putAll( toRequestMap( (PaypalClassicModel) listItem.get(i), format + String.valueOf(i))); } else { returnMap.putAll( toRequestMap((PaypalClassicModel) listItem.get(i), String.valueOf(i))); } } } if (listItem.get(i) instanceof List) { PaypalCollection paypalCollection = field.getAnnotation(PaypalCollection.class); if (paypalCollection != null && StringUtils.isNotEmpty(paypalCollection.format())) { String formatStr = field.getAnnotation(PaypalCollection.class).format(); returnMap.putAll( toRequestMap( (List) listItem.get(i), getFormatedKeyName(formatStr, null, i))); } else { if (StringUtils.isNoneEmpty(format)) { returnMap.putAll( toRequestMap((List) listItem.get(i), format + String.valueOf(i))); } else { returnMap.putAll(toRequestMap((List) listItem.get(i), String.valueOf(i))); } } } if (listItem.get(i) instanceof String) { PaypalCollection paypalCollection = field.getAnnotation(PaypalCollection.class); if (paypalCollection != null && StringUtils.isNotEmpty(paypalCollection.format())) { String formatStr = paypalCollection.format(); formatStr = getFormatedKeyName(formatStr, field.getName(), i); returnMap.put( getFormatedKeyName(format, formatStr, null), listItem.get(i).toString()); } else { returnMap.put( getFormatedKeyName(format, field.getName(), null) + i, listItem.get(i).toString()); } } } } } } } catch (IllegalAccessException e) { throw new ValidationException(e.getMessage()); } catch (InvocationTargetException e) { throw new ValidationException(e.getMessage()); } catch (NoSuchMethodException e) { throw new ValidationException(e.getMessage()); } } else { StringBuffer buf = new StringBuffer(); for (ConstraintViolation<PaypalClassicModel> violation : violations) { buf.append(violation.getMessage() + "\n"); } throw new ValidationException(buf.toString()); } return returnMap; }