CPD Results
The following document contains the results of PMD's CPD 6.55.0.
Duplications
File | Line |
---|---|
org/apache/struts/extras/actions/ActionDispatcher.java | 368 |
org/apache/struts/extras/actions/DispatchAction.java | 273 |
forward = (ActionForward) method.invoke(actionInstance, args); } catch (ClassCastException e) { log.atError() .setMessage(() -> messages.getMessage("dispatch.return", mapping.getPath(), name)) .setCause(e).log(); throw e; } catch (IllegalAccessException e) { log.atError() .setMessage(() -> messages.getMessage("dispatch.error", mapping.getPath(), name)) .setCause(e).log(); throw e; } catch (InvocationTargetException e) { // Rethrow the target exception if possible so that the // exception handling machinery can deal with it Throwable t = e.getTargetException(); if (t instanceof Exception) { throw ((Exception) t); } else { log.atError() .setMessage(() -> messages.getMessage("dispatch.error", mapping.getPath(), name)) .setCause(e).log(); throw new ServletException(t); } } // Return the returned ActionForward instance return (forward); } /** * Introspect the current class to identify a method of the specified name * that accepts the same parameter types as the <code>execute</code> * method does. * * @param name Name of the method to be introspected * @return The method with the specified name. * @throws NoSuchMethodException if no such method can be found */ protected Method getMethod(String name) |
File | Line |
---|---|
org/apache/struts/extras/actions/ActionDispatcher.java | 180 |
org/apache/struts/extras/actions/DispatchAction.java | 126 |
} // --------------------------------------------------------- Public Methods /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @return The forward to which control should be transferred, or * <code>null</code> if the response has been completed. * @throws Exception if an exception occurs */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Process "cancelled" if (isCancelled(request)) { ActionForward af = cancelled(mapping, form, request, response); if (af != null) { return af; } } // Identify the request parameter containing the method name String parameter = getParameter(mapping, form, request, response); // Get the method's name. This could be overridden in subclasses. String name = getMethodName(mapping, form, request, response, parameter); // Prevent recursive calls if ("execute".equals(name) || "perform".equals(name)) { String message = messages.getMessage("dispatch.recursive", mapping.getPath()); log.error(message); throw new ServletException(message); } // Invoke the named method, and return the result return dispatchMethod(mapping, form, request, response, name); } /** * <p>Dispatches to the target class' <code>unspecified</code> method, if * present, otherwise throws a ServletException. Classes utilizing * <code>ActionDispatcher</code> should provide an <code>unspecified</code> * method if they wish to provide behavior different than throwing a * ServletException.</p> * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The non-HTTP request we are processing * @param response The non-HTTP response we are creating * @return The forward to which control should be transferred, or * <code>null</code> if the response has been completed. * @throws Exception if the application business logic throws an * exception. */ protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Identify if there is an "unspecified" method to be dispatched to String name = "unspecified"; |
File | Line |
---|---|
org/apache/struts/extras/actions/EventActionDispatcher.java | 159 |
org/apache/struts/extras/actions/EventDispatchAction.java | 118 |
return dispatchMethod(mapping, form, request, response, name, method); } /** * Returns the method name, given a parameter's value. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if * any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @param parameter The <code>ActionMapping</code> parameter's name * @return The method's name. * @throws Exception if an error occurs. */ protected String getMethodName(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String parameter) throws Exception { StringTokenizer st = new StringTokenizer(parameter, ","); String defaultMethodName = null; while (st.hasMoreTokens()) { String methodKey = st.nextToken().trim(); String methodName = methodKey; // The key can either be a direct method name or an alias // to a method as indicated by a "key=value" signature int equals = methodKey.indexOf('='); if (equals > -1) { methodName = methodKey.substring(equals + 1).trim(); methodKey = methodKey.substring(0, equals).trim(); } // Set the default if it passes by if (methodKey.equals(DEFAULT_METHOD_KEY)) { defaultMethodName = methodName; } // If the method key exists as a standalone parameter or with // the image suffixes (.x/.y), the method name has been found. if ((request.getParameter(methodKey) != null) || (request.getParameter(methodKey + ".x") != null)) { return methodName; } } return defaultMethodName; } } |
File | Line |
---|---|
org/apache/struts/extras/actions/ActionDispatcher.java | 298 |
org/apache/struts/extras/actions/DispatchAction.java | 223 |
} // ----------------------------------------------------- Protected Methods /** * Dispatch to the specified method. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The non-HTTP request we are processing * @param response The non-HTTP response we are creating * @param name The name of the method to invoke * @return The forward to which control should be transferred, or * <code>null</code> if the response has been completed. * @throws Exception if the application business logic throws an * exception. */ protected ActionForward dispatchMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String name) throws Exception { // Make sure we have a valid method name to call. // This may be null if the user hacks the query string. if (name == null) { return this.unspecified(mapping, form, request, response); } // Identify the method object to be dispatched to Method method = null; try { method = getMethod(name); } catch (NoSuchMethodException e) { log.atError() .setMessage(() -> messages.getMessage("dispatch.method", mapping.getPath(), name)) .setCause(e).log(); String userMsg = messages.getMessage("dispatch.method.user", mapping.getPath()); NoSuchMethodException e2 = new NoSuchMethodException(userMsg); e2.initCause(e); throw e2; } |